@glass-sdk/liquid-glass 0.0.2 → 0.0.3-beta.1
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/CHANGELOG.md +124 -0
- package/README.md +66 -149
- package/dist/core/concentric.js +20 -3
- package/dist/core/corner-options.js +12 -0
- package/dist/core/corner-path.js +118 -0
- package/dist/core/materials.js +264 -32
- package/dist/core/optics.js +1 -2
- package/dist/core/progressive.js +1 -2
- package/dist/core/shape.js +18 -28
- package/dist/core/spring.js +5 -10
- package/dist/core.js +5 -6
- package/dist/dom/backdrop-glass.js +46 -0
- package/dist/dom/compose-layers.js +42 -31
- package/dist/dom/composited.js +136 -0
- package/dist/dom/control-motion.js +58 -47
- package/dist/dom/engine.js +1 -2
- package/dist/dom/escaped-layers.js +179 -0
- package/dist/dom/filter-bounds.js +42 -13
- package/dist/dom/filter-budget.js +1 -2
- package/dist/dom/filter-chain.js +40 -0
- package/dist/dom/filter-groups.js +33 -14
- package/dist/dom/filter-paint-root.js +8 -6
- package/dist/dom/filter-patch.js +94 -55
- package/dist/dom/filter-reach.js +32 -19
- package/dist/dom/filter-stages.js +1 -2
- package/dist/dom/fixed-shape.js +23 -16
- package/dist/dom/foreground.js +16 -17
- package/dist/dom/interaction.js +65 -92
- package/dist/dom/layout-rect.js +42 -0
- package/dist/dom/layout-size.js +28 -0
- package/dist/dom/lens-layers.js +250 -136
- package/dist/dom/map-encoder.js +16 -13
- package/dist/dom/map-encoder.worker.js +2 -3
- package/dist/dom/map-encoding.js +49 -12
- package/dist/dom/map-image.js +29 -7
- package/dist/dom/map-store.js +1 -2
- package/dist/dom/maps.js +133 -83
- package/dist/dom/material-graph.js +108 -29
- package/dist/dom/media-mirror.js +244 -0
- package/dist/dom/page-zoom.js +19 -18
- package/dist/dom/png.js +1 -2
- package/dist/dom/progressive.js +152 -147
- package/dist/dom/renderer.js +1 -2
- package/dist/dom/sampling-bounds.js +1 -2
- package/dist/dom/selection.js +133 -79
- package/dist/dom/shape-attributes.js +9 -0
- package/dist/dom/shape-effects.js +14 -0
- package/dist/dom/shape-geometry.js +3 -0
- package/dist/dom/shape-layout.js +115 -116
- package/dist/dom/shared-backdrop.js +33 -25
- package/dist/dom/specular.js +116 -0
- package/dist/dom/ticker.js +28 -19
- package/dist/dom/tint-color.js +24 -0
- package/dist/dom/warm.js +63 -59
- package/dist/dom.js +591 -505
- package/dist/gpu/geometry.js +2 -3
- package/dist/gpu/maps.js +1109 -7
- package/dist/gpu/planes.js +2 -3
- package/dist/gpu.js +66 -64
- package/dist/index.js +12 -10
- package/dist/react/button.js +12 -11
- package/dist/react/color-picker.js +199 -0
- package/dist/react/control-thumb.js +4 -5
- package/dist/react/menu.js +82 -111
- package/dist/react/merged-ref.js +1 -2
- package/dist/react/progressive.js +1 -2
- package/dist/react/scene.js +71 -55
- package/dist/react/shape.js +67 -47
- package/dist/react/slider.js +81 -0
- package/dist/react/surface.js +90 -56
- package/dist/react/switch.js +101 -0
- package/dist/react/tabs.js +85 -63
- package/dist/react/toolbar.js +38 -123
- package/dist/react/value-control-motion.js +1 -2
- package/dist/styles.css +517 -111
- package/dist/types/core/concentric.d.ts +8 -0
- package/dist/types/core/corner-options.d.ts +4 -0
- package/dist/types/core/corner-path.d.ts +8 -0
- package/dist/types/core/index.d.ts +3 -5
- package/dist/types/core/materials.d.ts +100 -28
- package/dist/types/core/shape.d.ts +4 -6
- package/dist/types/core/spring.d.ts +8 -12
- package/dist/types/dom/backdrop-glass.d.ts +38 -0
- package/dist/types/dom/compose-layers.d.ts +4 -0
- package/dist/types/dom/composited.d.ts +61 -0
- package/dist/types/dom/escaped-layers.d.ts +32 -0
- package/dist/types/dom/filter-bounds.d.ts +4 -0
- package/dist/types/dom/filter-chain.d.ts +6 -0
- package/dist/types/dom/filter-groups.d.ts +1 -1
- package/dist/types/dom/filter-paint-root.d.ts +3 -0
- package/dist/types/dom/filter-patch.d.ts +5 -0
- package/dist/types/dom/filter-reach.d.ts +9 -9
- package/dist/types/dom/foreground.d.ts +2 -1
- package/dist/types/dom/index.d.ts +8 -19
- package/dist/types/dom/interaction.d.ts +8 -8
- package/dist/types/dom/layout-rect.d.ts +17 -0
- package/dist/types/dom/layout-size.d.ts +11 -0
- package/dist/types/dom/lens-layers.d.ts +18 -10
- package/dist/types/dom/map-encoder.d.ts +5 -2
- package/dist/types/dom/map-encoding.d.ts +12 -3
- package/dist/types/dom/map-image.d.ts +7 -1
- package/dist/types/dom/maps.d.ts +25 -7
- package/dist/types/dom/material-graph.d.ts +73 -10
- package/dist/types/dom/media-mirror.d.ts +49 -0
- package/dist/types/dom/progressive.d.ts +2 -5
- package/dist/types/dom/sampling-bounds.d.ts +1 -3
- package/dist/types/dom/selection.d.ts +29 -4
- package/dist/types/dom/shape-attributes.d.ts +6 -0
- package/dist/types/dom/shape-effects.d.ts +10 -0
- package/dist/types/dom/shape-geometry.d.ts +6 -0
- package/dist/types/dom/shape-layout.d.ts +2 -4
- package/dist/types/dom/shared-backdrop.d.ts +7 -3
- package/dist/types/dom/specular.d.ts +50 -0
- package/dist/types/dom/ticker.d.ts +4 -1
- package/dist/types/dom/tint-color.d.ts +11 -0
- package/dist/types/dom/warm.d.ts +8 -2
- package/dist/types/gpu/geometry.d.ts +2 -0
- package/dist/types/gpu/planes.d.ts +3 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/react/button.d.ts +1 -1
- package/dist/types/react/color-picker.d.ts +26 -0
- package/dist/types/react/index.d.ts +14 -10
- package/dist/types/react/menu.d.ts +4 -5
- package/dist/types/react/progressive.d.ts +1 -1
- package/dist/types/react/scene.d.ts +4 -2
- package/dist/types/react/shape.d.ts +11 -1
- package/dist/types/react/slider.d.ts +14 -0
- package/dist/types/react/surface.d.ts +11 -22
- package/dist/types/react/switch.d.ts +9 -0
- package/dist/types/react/tabs.d.ts +3 -3
- package/dist/types/react/toolbar.d.ts +1 -1
- package/package.json +46 -40
- package/dist/core/morph-path.js +0 -206
- package/dist/core/union.js +0 -117
- package/dist/dom/compound-field.js +0 -23
- package/dist/dom/exit-handoff.js +0 -14
- package/dist/dom/map-blend.js +0 -8
- package/dist/dom/morph.js +0 -296
- package/dist/react/value-controls.js +0 -176
- package/dist/types/core/morph-path.d.ts +0 -110
- package/dist/types/core/union.d.ts +0 -20
- package/dist/types/dom/compound-field.d.ts +0 -35
- package/dist/types/dom/exit-handoff.d.ts +0 -7
- package/dist/types/dom/map-blend.d.ts +0 -22
- package/dist/types/dom/morph.d.ts +0 -78
- package/dist/types/react/value-controls.d.ts +0 -20
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useGlassForeground as e } from "./scene.js";
|
|
3
|
+
import { useMergedRef as t } from "./merged-ref.js";
|
|
4
|
+
import { GlassShape as n } from "./shape.js";
|
|
5
|
+
import { ControlThumb as r } from "./control-thumb.js";
|
|
6
|
+
import { useEffect as i, useState as a } from "react";
|
|
7
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
8
|
+
import { Slider as c } from "@base-ui/react/slider";
|
|
9
|
+
// src/react/slider.tsx
|
|
10
|
+
function l({ material: l, appearance: u, tint: d, refraction: f, specular: p, radius: m = "capsule", motion: h, interactive: g = !0, className: _ = "", style: v, ticks: y = !1, min: b = 0, max: x = 100, step: S = .1, thumbProps: C, "aria-label": w, "aria-labelledby": T, ...E }) {
|
|
11
|
+
if (!Number.isFinite(b) || !Number.isFinite(x) || x <= b || !Number.isFinite(x - b) || !Number.isFinite(S) || S <= 0) throw RangeError("GlassSlider requires finite min < max and a positive finite step.");
|
|
12
|
+
let D = (x - b) / S;
|
|
13
|
+
if (y && (D < 1 || D > 100 || Math.abs(D - Math.round(D)) > 1e-7)) throw RangeError("Ticked sliders require 1–100 evenly divided intervals.");
|
|
14
|
+
let O = e(), k = t(E.ref, O), { className: A = "", ...j } = C ?? {}, [M, N] = a(!1);
|
|
15
|
+
return i(() => {
|
|
16
|
+
if (!M) return;
|
|
17
|
+
let e = () => N(!1);
|
|
18
|
+
return window.addEventListener("pointerup", e), window.addEventListener("pointercancel", e), window.addEventListener("blur", e), () => {
|
|
19
|
+
window.removeEventListener("pointerup", e), window.removeEventListener("pointercancel", e), window.removeEventListener("blur", e);
|
|
20
|
+
};
|
|
21
|
+
}, [M]), /* @__PURE__ */ o(c.Root, {
|
|
22
|
+
defaultValue: b,
|
|
23
|
+
...E,
|
|
24
|
+
ref: k,
|
|
25
|
+
min: b,
|
|
26
|
+
max: x,
|
|
27
|
+
step: S,
|
|
28
|
+
className: `lg-slider ${_}`,
|
|
29
|
+
style: {
|
|
30
|
+
...d === void 0 ? {} : { "--lg-accent": d },
|
|
31
|
+
...v
|
|
32
|
+
},
|
|
33
|
+
"data-ticks": y ? "" : void 0,
|
|
34
|
+
children: /* @__PURE__ */ s(c.Control, {
|
|
35
|
+
className: "lg-slider-control",
|
|
36
|
+
onPointerDownCapture: (e) => {
|
|
37
|
+
!e.defaultPrevented && !E.disabled && e.button === 0 && N(!0);
|
|
38
|
+
},
|
|
39
|
+
onPointerUp: () => N(!1),
|
|
40
|
+
onPointerCancel: () => N(!1),
|
|
41
|
+
onLostPointerCapture: () => N(!1),
|
|
42
|
+
children: [
|
|
43
|
+
/* @__PURE__ */ o(n, {
|
|
44
|
+
radius: "capsule",
|
|
45
|
+
render: /* @__PURE__ */ o(c.Track, {}),
|
|
46
|
+
className: "lg-slider-track",
|
|
47
|
+
children: /* @__PURE__ */ o(n, {
|
|
48
|
+
radius: "capsule",
|
|
49
|
+
render: /* @__PURE__ */ o(c.Indicator, {}),
|
|
50
|
+
className: "lg-slider-fill"
|
|
51
|
+
})
|
|
52
|
+
}),
|
|
53
|
+
y && /* @__PURE__ */ o("div", {
|
|
54
|
+
className: "lg-slider-ticks",
|
|
55
|
+
"aria-hidden": "true",
|
|
56
|
+
children: Array.from({ length: Math.round(D) + 1 }, (e, t) => /* @__PURE__ */ o("span", {}, t))
|
|
57
|
+
}),
|
|
58
|
+
/* @__PURE__ */ o(c.Thumb, {
|
|
59
|
+
"aria-label": w,
|
|
60
|
+
"aria-labelledby": T,
|
|
61
|
+
...j,
|
|
62
|
+
render: (e, t) => /* @__PURE__ */ o(r, {
|
|
63
|
+
...e,
|
|
64
|
+
motion: h,
|
|
65
|
+
interactive: g,
|
|
66
|
+
pressed: M || t.dragging,
|
|
67
|
+
options: {
|
|
68
|
+
material: l,
|
|
69
|
+
appearance: u,
|
|
70
|
+
radius: m,
|
|
71
|
+
refraction: f,
|
|
72
|
+
specular: p
|
|
73
|
+
},
|
|
74
|
+
className: `lg-slider-thumb ${typeof A == "function" ? A(t) : A}`
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
]
|
|
78
|
+
})
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
export { l as GlassSlider };
|
package/dist/react/surface.js
CHANGED
|
@@ -1,69 +1,103 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { shapeContainerAttributes as e } from "../dom/shape-
|
|
2
|
+
import { shapeContainerAttributes as e } from "../dom/shape-attributes.js";
|
|
3
3
|
import { useScene as t } from "./scene.js";
|
|
4
|
-
import { useCallback as n, useLayoutEffect as r, useMemo as i, useRef as a } from "react";
|
|
5
|
-
import { useRender as
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
import { useCallback as n, useLayoutEffect as r, useMemo as i, useRef as a, useState as o } from "react";
|
|
5
|
+
import { useRender as s } from "@base-ui/react/use-render";
|
|
6
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
7
|
+
// src/react/surface.tsx
|
|
8
|
+
function l(e) {
|
|
9
|
+
return /* @__PURE__ */ c(f, { ...e });
|
|
10
|
+
}
|
|
11
|
+
function u(e, t) {
|
|
12
|
+
let n, r = 0, i = e.ownerDocument.defaultView ?? window, a = new MutationObserver(() => {
|
|
13
|
+
if (n || !e.hasAttribute("data-ending-style")) return;
|
|
14
|
+
n = e.animate([{ opacity: 1 }, { opacity: 1 }], { duration: 400 });
|
|
15
|
+
let a = 0, o = () => {
|
|
16
|
+
a = (t ?? e.ownerDocument).querySelector("[data-glass-pending]") ? 0 : a + 1, a >= 2 ? n?.finish() : r = i.requestAnimationFrame(o);
|
|
17
|
+
};
|
|
18
|
+
r = i.requestAnimationFrame(o);
|
|
13
19
|
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
return a.observe(e, {
|
|
21
|
+
attributes: !0,
|
|
22
|
+
attributeFilter: ["data-ending-style"]
|
|
23
|
+
}), () => {
|
|
24
|
+
a.disconnect(), i.cancelAnimationFrame(r);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function d(e) {
|
|
28
|
+
return /* @__PURE__ */ c(f, {
|
|
29
|
+
...e,
|
|
30
|
+
popup: !0
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function f({ material: c, appearance: l, radius: d, concentric: f, refraction: p, tint: m, specular: h, frost: g, floating: _, aberration: v, interactive: y = !1, motion: b, popup: x = !1, render: S, ref: C, children: w, className: T = "", style: E, ...D }) {
|
|
34
|
+
let O = t(), { controller: k } = O;
|
|
35
|
+
c ??= O.material, l ??= O.appearance, b ??= O.motion, h ??= O.specular, g ??= O.frost, _ ??= x;
|
|
36
|
+
let A = !!f, j = typeof f == "object" ? f.inset : void 0, M = {
|
|
37
|
+
material: c,
|
|
38
|
+
appearance: l,
|
|
39
|
+
refraction: p,
|
|
40
|
+
tint: m,
|
|
41
|
+
frost: g,
|
|
42
|
+
floating: _,
|
|
43
|
+
aberration: v
|
|
44
|
+
}, N = a(M);
|
|
45
|
+
N.current = M;
|
|
46
|
+
let P = i(() => ({
|
|
47
|
+
radius: d,
|
|
48
|
+
concentric: A ? { inset: j } : void 0,
|
|
49
|
+
specular: h,
|
|
50
|
+
interactive: y,
|
|
51
|
+
motion: b,
|
|
52
|
+
popup: x
|
|
31
53
|
}), [
|
|
32
|
-
|
|
54
|
+
d,
|
|
55
|
+
A,
|
|
56
|
+
j,
|
|
57
|
+
h,
|
|
58
|
+
y,
|
|
59
|
+
b,
|
|
60
|
+
x
|
|
61
|
+
]), [F, I] = o(null), L = n((e) => {
|
|
62
|
+
if (!e) return;
|
|
63
|
+
let t = k.addSurface(e, {
|
|
64
|
+
...P,
|
|
65
|
+
...N.current
|
|
66
|
+
}), n = x ? u(e, O.root) : void 0;
|
|
67
|
+
return I(e), () => {
|
|
68
|
+
n?.(), t(), I(null);
|
|
69
|
+
};
|
|
70
|
+
}, [
|
|
71
|
+
k,
|
|
72
|
+
P,
|
|
73
|
+
x,
|
|
74
|
+
O.root
|
|
75
|
+
]);
|
|
76
|
+
return r(() => {
|
|
77
|
+
F && k.updateSurface(F, M);
|
|
78
|
+
}, [
|
|
79
|
+
k,
|
|
80
|
+
F,
|
|
33
81
|
c,
|
|
34
82
|
l,
|
|
35
|
-
O,
|
|
36
|
-
k,
|
|
37
|
-
d,
|
|
38
|
-
f,
|
|
39
83
|
p,
|
|
40
|
-
|
|
41
|
-
y,
|
|
42
|
-
h,
|
|
84
|
+
m,
|
|
43
85
|
g,
|
|
44
86
|
_,
|
|
45
|
-
|
|
46
|
-
]),
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return () => {
|
|
50
|
-
t();
|
|
51
|
-
};
|
|
52
|
-
}, [D, M]);
|
|
53
|
-
return o({
|
|
54
|
-
render: b,
|
|
55
|
-
ref: [N, x ?? null],
|
|
87
|
+
v
|
|
88
|
+
]), s({
|
|
89
|
+
render: S,
|
|
90
|
+
ref: [L, C ?? null],
|
|
56
91
|
props: {
|
|
57
|
-
...
|
|
58
|
-
...e(
|
|
59
|
-
"data-glass-material":
|
|
60
|
-
"data-glass-appearance":
|
|
61
|
-
"data-glass-interactive":
|
|
62
|
-
className: `lg-surface ${
|
|
63
|
-
style: { ...
|
|
64
|
-
...
|
|
92
|
+
...D,
|
|
93
|
+
...e(d ?? 8),
|
|
94
|
+
"data-glass-material": c,
|
|
95
|
+
"data-glass-appearance": l,
|
|
96
|
+
"data-glass-interactive": y ? "" : void 0,
|
|
97
|
+
className: `lg-surface ${T}`,
|
|
98
|
+
style: { ...E },
|
|
99
|
+
...w === void 0 ? {} : { children: w }
|
|
65
100
|
}
|
|
66
101
|
});
|
|
67
102
|
}
|
|
68
|
-
|
|
69
|
-
export { s as GlassSurface };
|
|
103
|
+
export { d as GlassPopupSurface, l as GlassSurface };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useGlassForeground as e } from "./scene.js";
|
|
3
|
+
import { useMergedRef as t } from "./merged-ref.js";
|
|
4
|
+
import { GlassShape as n } from "./shape.js";
|
|
5
|
+
import { switchDragState as r } from "./value-control-motion.js";
|
|
6
|
+
import { ControlThumb as i } from "./control-thumb.js";
|
|
7
|
+
import { useRef as a, useState as o } from "react";
|
|
8
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
9
|
+
import { Switch as l } from "@base-ui/react/switch";
|
|
10
|
+
// src/react/switch.tsx
|
|
11
|
+
function u({ material: u, appearance: d, tint: f, refraction: p, specular: m, radius: h = "capsule", motion: g, interactive: _ = !0, className: v = "", style: y, ...b }) {
|
|
12
|
+
let x = e(), S = t(b.ref, x), [C, w] = o(!1), [T, E] = o(null), D = a(null), O = a(!1), k = b.readOnly || b.disabled;
|
|
13
|
+
return /* @__PURE__ */ c(l.Root, {
|
|
14
|
+
...b,
|
|
15
|
+
ref: S,
|
|
16
|
+
nativeButton: !1,
|
|
17
|
+
className: `lg-switch ${v}`,
|
|
18
|
+
style: {
|
|
19
|
+
...f === void 0 ? {} : { "--lg-accent": f },
|
|
20
|
+
...y
|
|
21
|
+
},
|
|
22
|
+
render: (e, t) => /* @__PURE__ */ s("span", {
|
|
23
|
+
...e,
|
|
24
|
+
role: "switch",
|
|
25
|
+
"aria-checked": t.checked,
|
|
26
|
+
tabIndex: e.tabIndex ?? 0,
|
|
27
|
+
style: {
|
|
28
|
+
...e.style,
|
|
29
|
+
"--lg-switch-position": T ?? +!!t.checked
|
|
30
|
+
},
|
|
31
|
+
"data-presentation-checked": T === null ? void 0 : T === 1 ? "true" : "false",
|
|
32
|
+
onPointerDown: (n) => {
|
|
33
|
+
if (e.onPointerDown?.(n), n.defaultPrevented || k || n.button !== 0) return;
|
|
34
|
+
O.current = !1;
|
|
35
|
+
let r = getComputedStyle(n.currentTarget).direction === "rtl", i = +!!t.checked, a = n.currentTarget.getBoundingClientRect(), o = n.clientX >= a.left + a.width / 2 !== r;
|
|
36
|
+
D.current = {
|
|
37
|
+
id: n.pointerId,
|
|
38
|
+
x: n.clientX,
|
|
39
|
+
start: i,
|
|
40
|
+
current: i,
|
|
41
|
+
left: a.left,
|
|
42
|
+
width: a.width,
|
|
43
|
+
rtl: r,
|
|
44
|
+
oppositeHalf: o !== t.checked,
|
|
45
|
+
moved: !1
|
|
46
|
+
}, n.currentTarget.setPointerCapture(n.pointerId), E(i), w(!0);
|
|
47
|
+
},
|
|
48
|
+
onPointerMove: (t) => {
|
|
49
|
+
e.onPointerMove?.(t);
|
|
50
|
+
let n = D.current;
|
|
51
|
+
if (!n || n.id !== t.pointerId || t.defaultPrevented) return;
|
|
52
|
+
let i = t.clientX - n.x;
|
|
53
|
+
n.moved ||= Math.abs(i) > 3, n.current = Number(r(n, t.clientX)), n.moved && E(n.current);
|
|
54
|
+
},
|
|
55
|
+
onPointerUp: (n) => {
|
|
56
|
+
e.onPointerUp?.(n);
|
|
57
|
+
let r = D.current;
|
|
58
|
+
r && r.id === n.pointerId && (D.current = null, n.currentTarget.hasPointerCapture(n.pointerId) && n.currentTarget.releasePointerCapture(n.pointerId), r.moved && (!n.defaultPrevented && r.current >= .5 !== t.checked && n.currentTarget.click(), O.current = !0), E(null), w(!1));
|
|
59
|
+
},
|
|
60
|
+
onPointerCancel: (t) => {
|
|
61
|
+
e.onPointerCancel?.(t), D.current = null, O.current = !0, E(null), w(!1);
|
|
62
|
+
},
|
|
63
|
+
onLostPointerCapture: (t) => {
|
|
64
|
+
e.onLostPointerCapture?.(t), D.current && (D.current = null, O.current = !0, E(null), w(!1));
|
|
65
|
+
},
|
|
66
|
+
onClickCapture: (t) => {
|
|
67
|
+
O.current ? (O.current = !1, t.preventDefault(), t.stopPropagation()) : e.onClickCapture?.(t);
|
|
68
|
+
},
|
|
69
|
+
onKeyDown: (t) => {
|
|
70
|
+
e.onKeyDown?.(t), O.current = !1, t.defaultPrevented || k || t.key !== " " && t.key !== "Enter" || w(!0);
|
|
71
|
+
},
|
|
72
|
+
onKeyUp: (t) => {
|
|
73
|
+
e.onKeyUp?.(t), w(!1);
|
|
74
|
+
},
|
|
75
|
+
onBlur: (t) => {
|
|
76
|
+
e.onBlur?.(t), w(!1);
|
|
77
|
+
}
|
|
78
|
+
}),
|
|
79
|
+
children: [/* @__PURE__ */ s(n, {
|
|
80
|
+
radius: "capsule",
|
|
81
|
+
render: /* @__PURE__ */ s("span", {}),
|
|
82
|
+
className: "lg-switch-track",
|
|
83
|
+
"aria-hidden": "true"
|
|
84
|
+
}), /* @__PURE__ */ s(l.Thumb, { render: (e) => /* @__PURE__ */ s(i, {
|
|
85
|
+
...e,
|
|
86
|
+
tag: "span",
|
|
87
|
+
pressed: C,
|
|
88
|
+
motion: g,
|
|
89
|
+
interactive: _,
|
|
90
|
+
options: {
|
|
91
|
+
material: u,
|
|
92
|
+
appearance: d,
|
|
93
|
+
radius: h,
|
|
94
|
+
refraction: p,
|
|
95
|
+
specular: m
|
|
96
|
+
},
|
|
97
|
+
className: "lg-switch-thumb"
|
|
98
|
+
}) })]
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
export { u as GlassSwitch };
|
package/dist/react/tabs.js
CHANGED
|
@@ -1,88 +1,111 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { attachSelectionLens as e } from "../dom/selection.js";
|
|
3
3
|
import { resolveMotion as t } from "../dom/interaction.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { createContext as s, useCallback as c, useContext as l } from "react";
|
|
9
|
-
import { jsx as
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
import { useMergedRef as n } from "./merged-ref.js";
|
|
5
|
+
import { GlassShape as r } from "./shape.js";
|
|
6
|
+
import { useGlassMotion as i, useScene as a } from "./scene.js";
|
|
7
|
+
import { GlassSurface as o } from "./surface.js";
|
|
8
|
+
import { createContext as s, useCallback as c, useContext as l, useState as u } from "react";
|
|
9
|
+
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
10
|
+
import { createPortal as m } from "react-dom";
|
|
11
|
+
import { Tabs as h } from "@base-ui/react/tabs";
|
|
12
|
+
// src/react/tabs.tsx
|
|
13
|
+
var g = h.Root, _ = h.Panel, v = s({});
|
|
14
|
+
function y({ material: e, appearance: t, radius: n = "capsule", refraction: r, tint: i, specular: s, frost: c, interactive: l = !1, motion: u, size: d = "default", className: p = "", style: m, children: g, ..._ }) {
|
|
15
|
+
let y = a(), b = {
|
|
16
|
+
material: e ?? y.material,
|
|
17
|
+
appearance: t ?? y.appearance,
|
|
18
|
+
motion: u
|
|
18
19
|
};
|
|
19
|
-
return /* @__PURE__ */
|
|
20
|
-
value:
|
|
21
|
-
children: /* @__PURE__ */
|
|
22
|
-
material:
|
|
23
|
-
appearance:
|
|
20
|
+
return /* @__PURE__ */ f(v.Provider, {
|
|
21
|
+
value: b,
|
|
22
|
+
children: /* @__PURE__ */ f(o, {
|
|
23
|
+
material: b.material,
|
|
24
|
+
appearance: b.appearance,
|
|
24
25
|
radius: n,
|
|
25
26
|
refraction: r,
|
|
26
|
-
tint:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
tint: i,
|
|
28
|
+
specular: s,
|
|
29
|
+
frost: c,
|
|
30
|
+
interactive: l,
|
|
31
|
+
motion: u,
|
|
32
|
+
style: m,
|
|
33
|
+
className: `lg-tabs-list ${p}`,
|
|
34
|
+
"data-size": d,
|
|
35
|
+
render: /* @__PURE__ */ f(h.List, {
|
|
33
36
|
activateOnFocus: !0,
|
|
34
|
-
...
|
|
37
|
+
..._
|
|
35
38
|
}),
|
|
36
|
-
children:
|
|
39
|
+
children: g
|
|
37
40
|
})
|
|
38
41
|
});
|
|
39
42
|
}
|
|
40
|
-
function
|
|
41
|
-
let
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
43
|
+
function b({ material: r = "regular", appearance: s, radius: g = "capsule", refraction: _, tint: y, specular: b, frost: x, motion: S, className: C = "", style: w, ref: T, ...E }) {
|
|
44
|
+
let D = l(v), { controller: O, root: k } = a(), A = i(S ?? D.motion), [j, M] = u(null), [N, P] = u(!1), F = c((n) => {
|
|
45
|
+
if (!n) return;
|
|
46
|
+
let r = e(n, () => t(A), P);
|
|
47
|
+
M(r);
|
|
48
|
+
let i = O.addAnimator(r);
|
|
49
|
+
return () => {
|
|
50
|
+
i(), M(null);
|
|
51
|
+
};
|
|
52
|
+
}, [O, A]), I = c((e) => (j?.setLens(e, k), () => j?.setLens(null, null)), [j, k]), L = s ?? D.appearance;
|
|
53
|
+
return /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f(o, {
|
|
54
|
+
material: r,
|
|
55
|
+
appearance: L,
|
|
56
|
+
radius: g,
|
|
57
|
+
refraction: _,
|
|
58
|
+
tint: y,
|
|
59
|
+
specular: b,
|
|
60
|
+
frost: x,
|
|
61
|
+
style: w,
|
|
62
|
+
ref: n(F, T),
|
|
63
|
+
className: `lg-tab-indicator ${C}`,
|
|
64
|
+
render: /* @__PURE__ */ f(h.Indicator, { ...E })
|
|
65
|
+
}), k && j && N ? m(/* @__PURE__ */ f(o, {
|
|
66
|
+
material: "lens",
|
|
67
|
+
refraction: 6,
|
|
68
|
+
aberration: !0,
|
|
69
|
+
appearance: L,
|
|
70
|
+
radius: g,
|
|
71
|
+
ref: I,
|
|
72
|
+
className: "lg-tab-lens",
|
|
73
|
+
"aria-hidden": "true",
|
|
74
|
+
render: /* @__PURE__ */ f("span", {})
|
|
75
|
+
}), k) : null] });
|
|
55
76
|
}
|
|
56
|
-
function
|
|
57
|
-
return /* @__PURE__ */
|
|
77
|
+
function x({ children: e, className: t, ...n }) {
|
|
78
|
+
return /* @__PURE__ */ f(r, {
|
|
58
79
|
radius: "capsule",
|
|
59
80
|
concentric: !0,
|
|
60
|
-
render: /* @__PURE__ */
|
|
61
|
-
...
|
|
62
|
-
className: (e) => `lg-tab ${typeof
|
|
81
|
+
render: /* @__PURE__ */ f(h.Tab, {
|
|
82
|
+
...n,
|
|
83
|
+
className: (e) => `lg-tab ${typeof t == "function" ? t(e) : t ?? ""}`
|
|
63
84
|
}),
|
|
64
|
-
children: /* @__PURE__ */
|
|
85
|
+
children: /* @__PURE__ */ f("span", {
|
|
65
86
|
className: "lg-tab-label",
|
|
66
|
-
children:
|
|
87
|
+
children: e
|
|
67
88
|
})
|
|
68
89
|
});
|
|
69
90
|
}
|
|
70
|
-
function
|
|
71
|
-
return /* @__PURE__ */
|
|
72
|
-
...
|
|
91
|
+
function S({ items: e, defaultValue: t, material: n, appearance: r, radius: i, refraction: a, tint: o, specular: s, frost: c, interactive: l, motion: u, size: d, className: m = "", "aria-label": h = "Sections", ..._ }) {
|
|
92
|
+
return /* @__PURE__ */ f(g, {
|
|
93
|
+
..._,
|
|
73
94
|
defaultValue: t ?? e.find((e) => !e.disabled)?.value,
|
|
74
|
-
className: `lg-tabs ${
|
|
75
|
-
children: /* @__PURE__ */
|
|
95
|
+
className: `lg-tabs ${m}`,
|
|
96
|
+
children: /* @__PURE__ */ p(y, {
|
|
76
97
|
material: n,
|
|
77
98
|
appearance: r,
|
|
78
99
|
radius: i,
|
|
79
100
|
refraction: a,
|
|
80
101
|
tint: o,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
102
|
+
specular: s,
|
|
103
|
+
frost: c,
|
|
104
|
+
interactive: l,
|
|
105
|
+
motion: u,
|
|
106
|
+
size: d,
|
|
107
|
+
"aria-label": h,
|
|
108
|
+
children: [/* @__PURE__ */ f(b, { tint: o }), e.map((e) => /* @__PURE__ */ f(x, {
|
|
86
109
|
value: e.value,
|
|
87
110
|
disabled: e.disabled,
|
|
88
111
|
children: e.label
|
|
@@ -90,5 +113,4 @@ function y({ items: e, defaultValue: t, material: n, appearance: r, radius: i, r
|
|
|
90
113
|
})
|
|
91
114
|
});
|
|
92
115
|
}
|
|
93
|
-
|
|
94
|
-
export { y as GlassTabs, m as GlassTabsContent, _ as GlassTabsIndicator, g as GlassTabsList, p as GlassTabsRoot, v as GlassTabsTrigger };
|
|
116
|
+
export { S as GlassTabs, _ as GlassTabsContent, b as GlassTabsIndicator, y as GlassTabsList, g as GlassTabsRoot, x as GlassTabsTrigger };
|