@floegence/floe-webapp-core 0.90.11 → 0.90.12
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 +95 -28
- package/dist/styles.css +1 -1
- package/dist/surface.css +17 -0
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { spread as
|
|
2
|
-
import { splitProps as
|
|
3
|
-
import { cn as
|
|
4
|
-
var
|
|
5
|
-
const
|
|
1
|
+
import { use as $, spread as V, mergeProps as q, insert as k, createComponent as W, memo as B, effect as j, setAttribute as p, className as A, setStyleProperty as x, template as H, delegateEvents as G } from "solid-js/web";
|
|
2
|
+
import { splitProps as I, createSignal as J, createEffect as K, onMount as Q, onCleanup as D, For as U, untrack as X } from "solid-js";
|
|
3
|
+
import { cn as z } from "../../utils/cn.js";
|
|
4
|
+
var Y = /* @__PURE__ */ H("<div role=group data-floe-surface=inset data-floe-surface-part=rail><span aria-hidden=true>"), Z = /* @__PURE__ */ H('<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 ee = {
|
|
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,46 +19,113 @@ const F = {
|
|
|
19
19
|
icon: "w-4 h-4"
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
function
|
|
23
|
-
const [
|
|
24
|
-
|
|
22
|
+
function ne(L) {
|
|
23
|
+
const [r, N] = I(L, ["value", "onChange", "options", "size", "disabled", "class"]);
|
|
24
|
+
let d, c;
|
|
25
|
+
const b = /* @__PURE__ */ new Map(), [s, S] = J();
|
|
26
|
+
let f, u, h;
|
|
27
|
+
const y = () => {
|
|
28
|
+
const o = b.get(r.value);
|
|
29
|
+
if (!d || !o) {
|
|
30
|
+
u?.cancel(), S(void 0), h = void 0;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (!o.offsetWidth || !d.getClientRects().length) return;
|
|
34
|
+
const n = {
|
|
35
|
+
x: o.offsetLeft,
|
|
36
|
+
y: o.offsetTop,
|
|
37
|
+
width: o.offsetWidth,
|
|
38
|
+
height: o.offsetHeight
|
|
39
|
+
}, v = X(s);
|
|
40
|
+
if (v && Object.keys(n).every((a) => n[a] === v[a]) && h === r.value) return;
|
|
41
|
+
const e = v && h !== r.value && c && !window.matchMedia("(prefers-reduced-motion: reduce), (forced-colors: active)").matches ? getComputedStyle(c) : void 0, l = e ? {
|
|
42
|
+
transform: e.transform,
|
|
43
|
+
width: e.width
|
|
44
|
+
} : void 0;
|
|
45
|
+
if (u?.cancel(), S(n), h = r.value, l && c) {
|
|
46
|
+
const a = getComputedStyle(d);
|
|
47
|
+
u = c.animate([l, {
|
|
48
|
+
transform: `translate(${n.x}px, ${n.y}px)`,
|
|
49
|
+
width: `${n.width}px`
|
|
50
|
+
}], {
|
|
51
|
+
duration: parseFloat(a.getPropertyValue("--floe-duration-base")) || 200,
|
|
52
|
+
easing: a.getPropertyValue("--floe-ease-out").trim() || "ease-out"
|
|
53
|
+
}), u.id = "floe-segmented-selection";
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
K(() => {
|
|
57
|
+
r.value, r.options, r.size, y();
|
|
58
|
+
}), Q(() => {
|
|
59
|
+
if (typeof ResizeObserver < "u") {
|
|
60
|
+
f = new ResizeObserver(y), f.observe(d);
|
|
61
|
+
for (const o of b.values()) f.observe(o);
|
|
62
|
+
}
|
|
63
|
+
y();
|
|
64
|
+
}), D(() => {
|
|
65
|
+
f?.disconnect(), u?.cancel();
|
|
66
|
+
});
|
|
67
|
+
const P = () => r.size ?? "md", w = () => ee[P()], T = (o, n) => {
|
|
68
|
+
r.disabled || n || o !== r.value && r.onChange(o);
|
|
25
69
|
};
|
|
26
70
|
return (() => {
|
|
27
|
-
var
|
|
28
|
-
|
|
71
|
+
var o = Y(), n = o.firstChild, v = d;
|
|
72
|
+
typeof v == "function" ? $(v, o) : d = o, V(o, q({
|
|
73
|
+
get "data-floe-segmented-pill"() {
|
|
74
|
+
return s() ? "true" : void 0;
|
|
75
|
+
},
|
|
76
|
+
get "data-floe-segmented-motion"() {
|
|
77
|
+
return s() ? "ready" : void 0;
|
|
78
|
+
},
|
|
29
79
|
get class() {
|
|
30
|
-
return
|
|
80
|
+
return z("floe-segmented-control relative inline-flex items-center border", "rounded-group", "text-[length:var(--floe-type-control)] leading-[var(--floe-line-control)]", w().container, r.disabled && "opacity-50 pointer-events-none", r.class);
|
|
31
81
|
}
|
|
32
|
-
},
|
|
82
|
+
}, N), !1, !0);
|
|
83
|
+
var C = c;
|
|
84
|
+
return typeof C == "function" ? $(C, n) : c = n, k(o, W(U, {
|
|
33
85
|
get each() {
|
|
34
|
-
return
|
|
86
|
+
return r.options;
|
|
35
87
|
},
|
|
36
|
-
children: (
|
|
37
|
-
const l = () =>
|
|
88
|
+
children: (e) => {
|
|
89
|
+
const l = () => r.value === e.value, a = () => r.disabled || e.disabled;
|
|
38
90
|
return (() => {
|
|
39
|
-
var
|
|
40
|
-
return
|
|
41
|
-
|
|
42
|
-
|
|
91
|
+
var i = Z(), g = i.firstChild, m = g.firstChild;
|
|
92
|
+
return i.$$click = () => T(e.value, e.disabled), $((t) => {
|
|
93
|
+
b.set(e.value, t), f?.observe(t), D(() => {
|
|
94
|
+
f?.unobserve(t), b.delete(e.value);
|
|
95
|
+
});
|
|
96
|
+
}, i), k(g, (() => {
|
|
97
|
+
var t = B(() => !!e.icon);
|
|
98
|
+
return () => t() && W(e.icon, {
|
|
43
99
|
get class() {
|
|
44
|
-
return
|
|
100
|
+
return w().icon;
|
|
45
101
|
}
|
|
46
102
|
});
|
|
47
|
-
})(),
|
|
48
|
-
var
|
|
49
|
-
return
|
|
103
|
+
})(), m), k(m, () => e.label), j((t) => {
|
|
104
|
+
var _ = e.label, M = e.label, O = l() ? "raised" : "flat", R = l(), E = a(), F = z("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)]", w().button, l() ? "text-[var(--primary-foreground)]" : "text-[var(--floe-ink-soft)] hover:text-foreground", a() && "cursor-not-allowed opacity-50");
|
|
105
|
+
return _ !== t.e && p(i, "aria-label", t.e = _), M !== t.t && p(i, "title", t.t = M), O !== t.a && p(i, "data-floe-surface", t.a = O), R !== t.o && p(i, "aria-checked", t.o = R), E !== t.i && (i.disabled = t.i = E), F !== t.n && A(i, t.n = F), t;
|
|
50
106
|
}, {
|
|
51
107
|
e: void 0,
|
|
52
108
|
t: void 0,
|
|
53
109
|
a: void 0,
|
|
54
|
-
o: void 0
|
|
55
|
-
|
|
110
|
+
o: void 0,
|
|
111
|
+
i: void 0,
|
|
112
|
+
n: void 0
|
|
113
|
+
}), i;
|
|
56
114
|
})();
|
|
57
115
|
}
|
|
58
|
-
})),
|
|
116
|
+
}), null), j((e) => {
|
|
117
|
+
var l = z("floe-segmented-control__pill", P() === "lg" ? "rounded-md" : "rounded-sm"), a = s() ? "visible" : "hidden", i = `translate(${s()?.x ?? 0}px, ${s()?.y ?? 0}px)`, g = `${s()?.width ?? 0}px`, m = `${s()?.height ?? 0}px`;
|
|
118
|
+
return l !== e.e && A(n, e.e = l), a !== e.t && x(n, "visibility", e.t = a), i !== e.a && x(n, "transform", e.a = i), g !== e.o && x(n, "width", e.o = g), m !== e.i && x(n, "height", e.i = m), e;
|
|
119
|
+
}, {
|
|
120
|
+
e: void 0,
|
|
121
|
+
t: void 0,
|
|
122
|
+
a: void 0,
|
|
123
|
+
o: void 0,
|
|
124
|
+
i: void 0
|
|
125
|
+
}), o;
|
|
59
126
|
})();
|
|
60
127
|
}
|
|
61
|
-
|
|
128
|
+
G(["click"]);
|
|
62
129
|
export {
|
|
63
|
-
|
|
130
|
+
ne as SegmentedControl
|
|
64
131
|
};
|