@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
package/dist/core/union.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
//#region src/core/union.ts
|
|
2
|
-
function e(e, t, n) {
|
|
3
|
-
let r = Math.max(0, Math.min(n.radius, n.width / 2, n.height / 2)), i = Math.abs(e - (n.x + n.width / 2)) - (n.width / 2 - r), a = Math.abs(t - (n.y + n.height / 2)) - (n.height / 2 - r);
|
|
4
|
-
return Math.hypot(Math.max(i, 0), Math.max(a, 0)) + Math.min(Math.max(i, a), 0) - r;
|
|
5
|
-
}
|
|
6
|
-
function t(e, t, n) {
|
|
7
|
-
if (n <= 0) return Math.min(e, t);
|
|
8
|
-
let r = Math.max(n - Math.abs(e - t), 0) / n;
|
|
9
|
-
return Math.min(e, t) - r * r * n * .25;
|
|
10
|
-
}
|
|
11
|
-
function n(e) {
|
|
12
|
-
let t = 0;
|
|
13
|
-
for (let n = 0; n < e.length; n++) {
|
|
14
|
-
let r = e[n], i = e[(n + 1) % e.length];
|
|
15
|
-
t += r[0] * i[1] - i[0] * r[1];
|
|
16
|
-
}
|
|
17
|
-
return t;
|
|
18
|
-
}
|
|
19
|
-
function r(e, t) {
|
|
20
|
-
if (e.length < 4) return e;
|
|
21
|
-
let n = new Uint8Array(e.length);
|
|
22
|
-
n[0] = n[e.length - 1] = 1;
|
|
23
|
-
let r = [[0, e.length - 1]];
|
|
24
|
-
for (; r.length;) {
|
|
25
|
-
let [i, a] = r.pop(), [o, s] = e[i], [c, l] = e[a], u = Math.hypot(c - o, l - s) || 1, d = -1, f = -1;
|
|
26
|
-
for (let t = i + 1; t < a; t++) {
|
|
27
|
-
let [n, r] = e[t], i = Math.abs((c - o) * (s - r) - (o - n) * (l - s)) / u;
|
|
28
|
-
i > d && (d = i, f = t);
|
|
29
|
-
}
|
|
30
|
-
d > t && (n[f] = 1, r.push([i, f], [f, a]));
|
|
31
|
-
}
|
|
32
|
-
return e.filter((e, t) => n[t]);
|
|
33
|
-
}
|
|
34
|
-
function i(e, t) {
|
|
35
|
-
let [n, i] = e[0], a = 0, o = -1;
|
|
36
|
-
e.forEach(([e, t], r) => {
|
|
37
|
-
let s = Math.hypot(e - n, t - i);
|
|
38
|
-
s > o && (o = s, a = r);
|
|
39
|
-
});
|
|
40
|
-
let s = r(e.slice(0, a + 1), t), c = r([...e.slice(a), e[0]], t);
|
|
41
|
-
return [...s, ...c.slice(1, -1)];
|
|
42
|
-
}
|
|
43
|
-
function a(r, a, o = 1, s = 1e3) {
|
|
44
|
-
if (!r.length) return [];
|
|
45
|
-
let c = a / 2 + 2 * o, l = Math.min(...r.map((e) => e.x)) - c, u = Math.min(...r.map((e) => e.y)) - c, d = Math.max(...r.map((e) => e.x + e.width)) + c, f = Math.max(...r.map((e) => e.y + e.height)) + c, p = Math.ceil((d - l) / o) + 1, m = Math.ceil((f - u) / o) + 1, h = new Float64Array(p * m);
|
|
46
|
-
for (let n = 0; n < m; n++) for (let i = 0; i < p; i++) {
|
|
47
|
-
let s = l + i * o, c = u + n * o, d = Infinity;
|
|
48
|
-
for (let n of r) d = d === Infinity ? e(s, c, n) : t(d, e(s, c, n), a);
|
|
49
|
-
h[n * p + i] = d;
|
|
50
|
-
}
|
|
51
|
-
let g = /* @__PURE__ */ new Map(), _ = (e, t, n, r) => {
|
|
52
|
-
let i = e === n ? (t * p + e) * 2 + 1 : (t * p + Math.min(e, n)) * 2;
|
|
53
|
-
if (!g.has(i)) {
|
|
54
|
-
let a = h[t * p + e], s = a / (a - h[r * p + n]);
|
|
55
|
-
g.set(i, [l + (e + (n - e) * s) * o, u + (t + (r - t) * s) * o]);
|
|
56
|
-
}
|
|
57
|
-
return i;
|
|
58
|
-
}, v = /* @__PURE__ */ new Map();
|
|
59
|
-
for (let e = 0; e < m - 1; e++) for (let t = 0; t < p - 1; t++) {
|
|
60
|
-
let n = h[e * p + t] < 0, r = h[e * p + t + 1] < 0, i = h[(e + 1) * p + t + 1] < 0, a = h[(e + 1) * p + t] < 0, o = () => _(t, e, t + 1, e), s = () => _(t + 1, e, t + 1, e + 1), c = () => _(t, e + 1, t + 1, e + 1), l = () => _(t, e, t, e + 1), u = (e, t) => v.set(e, t);
|
|
61
|
-
switch ((n ? 8 : 0) | (r ? 4 : 0) | (i ? 2 : 0) | !!a) {
|
|
62
|
-
case 1:
|
|
63
|
-
u(l(), c());
|
|
64
|
-
break;
|
|
65
|
-
case 2:
|
|
66
|
-
u(c(), s());
|
|
67
|
-
break;
|
|
68
|
-
case 3:
|
|
69
|
-
u(l(), s());
|
|
70
|
-
break;
|
|
71
|
-
case 4:
|
|
72
|
-
u(s(), o());
|
|
73
|
-
break;
|
|
74
|
-
case 5:
|
|
75
|
-
u(l(), o()), u(s(), c());
|
|
76
|
-
break;
|
|
77
|
-
case 6:
|
|
78
|
-
u(c(), o());
|
|
79
|
-
break;
|
|
80
|
-
case 7:
|
|
81
|
-
u(l(), o());
|
|
82
|
-
break;
|
|
83
|
-
case 8:
|
|
84
|
-
u(o(), l());
|
|
85
|
-
break;
|
|
86
|
-
case 9:
|
|
87
|
-
u(o(), c());
|
|
88
|
-
break;
|
|
89
|
-
case 10:
|
|
90
|
-
u(o(), s()), u(c(), l());
|
|
91
|
-
break;
|
|
92
|
-
case 11:
|
|
93
|
-
u(o(), s());
|
|
94
|
-
break;
|
|
95
|
-
case 12:
|
|
96
|
-
u(s(), l());
|
|
97
|
-
break;
|
|
98
|
-
case 13:
|
|
99
|
-
u(s(), c());
|
|
100
|
-
break;
|
|
101
|
-
case 14: u(c(), l());
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
let y = [], b = /* @__PURE__ */ new Set();
|
|
105
|
-
for (let e of v.keys()) {
|
|
106
|
-
if (b.has(e)) continue;
|
|
107
|
-
let t = [];
|
|
108
|
-
for (let n = e; n !== void 0 && !b.has(n); n = v.get(n)) b.add(n), t.push(g.get(n));
|
|
109
|
-
if (t.length < 3) continue;
|
|
110
|
-
let r = i(t, o * .12);
|
|
111
|
-
for (let e = o * .25; r.length > s; e *= 1.6) r = i(t, e);
|
|
112
|
-
n(r) < 0 && r.reverse(), y.push(r);
|
|
113
|
-
}
|
|
114
|
-
return y;
|
|
115
|
-
}
|
|
116
|
-
//#endregion
|
|
117
|
-
export { e as roundRectDistance, t as smoothMin, a as smoothUnion, n as windingArea };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { surfaceMapResult as e } from "./map-image.js";
|
|
2
|
-
//#region src/dom/compound-field.ts
|
|
3
|
-
var t = (e, t, n = 0) => e.x < t.x + t.w + n && t.x - n < e.x + e.w && e.y < t.y + t.h + n && t.y - n < e.y + e.h;
|
|
4
|
-
function n(e, n) {
|
|
5
|
-
let r = new Map(e.map((e) => [e, n.source(e)])), i = /* @__PURE__ */ new Map();
|
|
6
|
-
for (let e of r.values()) e && i.set(e, (i.get(e) ?? 0) + 1);
|
|
7
|
-
let a = /* @__PURE__ */ new Map();
|
|
8
|
-
for (let [o, s] of e.entries()) {
|
|
9
|
-
let c = r.get(s), l = c && e.find((e) => e.element === c);
|
|
10
|
-
if (!l || l === s || !l.maps || !s.maps || i.get(c) !== 1 || r.get(l) || i.has(s.element) || (l.baseOpacity ?? l.opacity) < .999 || (s.baseOpacity ?? s.opacity) < .999 || n.nested(l) || n.nested(s)) continue;
|
|
11
|
-
let u = l.options, d = s.options;
|
|
12
|
-
if ((u.material ?? "clear") !== (d.material ?? "clear") || (u.appearance ?? "light") !== (d.appearance ?? "light") || u.tint !== d.tint || n.refraction(l) !== n.refraction(s)) continue;
|
|
13
|
-
let f = e.indexOf(l);
|
|
14
|
-
f >= o || e.slice(f + 1, o).some((e) => e.maps && e.opacity >= .001 && t(l, e, Math.max(n.reach(l), n.reach(e)))) || a.set(s, l);
|
|
15
|
-
}
|
|
16
|
-
return a;
|
|
17
|
-
}
|
|
18
|
-
function r(t, n, r, i, a, o) {
|
|
19
|
-
let s = `x="${a.x}" y="${a.y}" width="${a.width}" height="${a.height}"`, c = e(t.serial, r), l = e(n.serial, r), u = Math.max(0, Math.min(1, t.opacity / (t.baseOpacity || 1))), d = (e, t) => `<feMerge result="${i}" ${s}><feMergeNode in="${e}"/><feMergeNode in="${t}"/></feMerge>`, f = `<feComponentTransfer in="${c}" result="${c}faded" ${s}><feFuncA type="linear" slope="${u}"/></feComponentTransfer>`, p = o(t, r, c) + o(n, r, l) + f;
|
|
20
|
-
return r === "field" ? p + d(`${c}faded`, l) : p + `<feComposite in="${c}faded" in2="${e(n.serial, "field")}" operator="out" result="${c}under" ${s}/>` + d(`${c}under`, l);
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
23
|
-
export { r as compoundFieldImage, n as compoundSources, t as fieldTouches };
|
package/dist/dom/exit-handoff.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//#region src/dom/exit-handoff.ts
|
|
2
|
-
var e = /* @__PURE__ */ new WeakMap();
|
|
3
|
-
function t(t) {
|
|
4
|
-
let n = e.get(t);
|
|
5
|
-
e.delete(t), n?.();
|
|
6
|
-
}
|
|
7
|
-
function n(t, n) {
|
|
8
|
-
let r = e.get(t);
|
|
9
|
-
return e.set(t, n), r?.(), () => {
|
|
10
|
-
e.get(t) === n && e.delete(t);
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
|
-
export { t as finishRetainedExit, n as retainLatestExit };
|
package/dist/dom/map-blend.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { mapImage as e } from "./map-image.js";
|
|
2
|
-
//#region src/dom/map-blend.ts
|
|
3
|
-
function t(t, n, r, i, a = !1) {
|
|
4
|
-
let { a: o, b: s, mix: c } = r, l = (n, r) => e(n.maps, t, r, n.x - 2, n.y - 2, n.w + 4, n.h + 4);
|
|
5
|
-
return a && (o === s || o.maps === s.maps && o.x === s.x && o.y === s.y && o.w === s.w && o.h === s.h) ? l(o, n) : l(o, `${n}A`) + l(s, `${n}B`) + `<feComposite in="${n}A" in2="${n}B" operator="arithmetic" k1="0" k2="${(1 - c).toFixed(4)}" k3="${c.toFixed(4)}" k4="0" result="${n}" x="${i.x - 2}" y="${i.y - 2}" width="${i.w + 4}" height="${i.h + 4}"/>`;
|
|
6
|
-
}
|
|
7
|
-
//#endregion
|
|
8
|
-
export { t as blendMapImage };
|
package/dist/dom/morph.js
DELETED
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
import { webkit as e } from "./engine.js";
|
|
2
|
-
import { Spring as t, settleTime as n, springs as r } from "../core/spring.js";
|
|
3
|
-
import { contentReveal as i, morphDraw as a, morphShape as o, openingAxis as ee, planMorph as s, radiusPixels as te, sourceConceal as ne } from "../core/morph-path.js";
|
|
4
|
-
import { finishRetainedExit as re, retainLatestExit as ie } from "./exit-handoff.js";
|
|
5
|
-
import { getLayoutSize as c } from "@lisse/core";
|
|
6
|
-
//#region src/dom/morph.ts
|
|
7
|
-
var l = (t) => e ? Math.max(4, Math.round(t / 2)) : t, ae = 140, oe = 1 / 60, u = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap();
|
|
8
|
-
function f(e) {
|
|
9
|
-
let t = e.parentElement?.closest(".lg-menu"), n = t ? d.get(t) : void 0;
|
|
10
|
-
return n?.visible() && n.trigger() !== e ? n.retain() : () => {};
|
|
11
|
-
}
|
|
12
|
-
function p(e) {
|
|
13
|
-
if (!(e instanceof HTMLElement)) return () => {};
|
|
14
|
-
u.set(e, (u.get(e) ?? 0) + 1), e.dataset.glassMorphSource = "";
|
|
15
|
-
let t = !1;
|
|
16
|
-
return () => {
|
|
17
|
-
if (t) return;
|
|
18
|
-
t = !0;
|
|
19
|
-
let n = (u.get(e) ?? 1) - 1;
|
|
20
|
-
n > 0 ? u.set(e, n) : (u.delete(e), delete e.dataset.glassMorphSource, e.style.removeProperty("--lg-morph-source"));
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function m(e) {
|
|
24
|
-
let t = e.getBoundingClientRect();
|
|
25
|
-
return {
|
|
26
|
-
left: t.left,
|
|
27
|
-
top: t.top,
|
|
28
|
-
width: t.width,
|
|
29
|
-
height: t.height
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
var h = (e) => {
|
|
33
|
-
let t = e.getAttribute("data-lg-container-radius");
|
|
34
|
-
if (t === "capsule" || t === "circle") return t;
|
|
35
|
-
let n = Number(t);
|
|
36
|
-
return Number.isFinite(n) && t !== null ? n : e.classList.contains("lg-surface") ? 8 : 0;
|
|
37
|
-
}, g = (e) => c(e), se = (e, t) => Math.hypot(e.left - t.left, e.top - t.top) > 1 || ce(e, t), ce = (e, t) => Math.abs(e.width - t.width) > .5 || Math.abs(e.height - t.height) > .5;
|
|
38
|
-
function _(c, u) {
|
|
39
|
-
let f = {
|
|
40
|
-
duration: .32,
|
|
41
|
-
bounce: .1
|
|
42
|
-
}, _ = u.submenu ? {
|
|
43
|
-
duration: .22,
|
|
44
|
-
bounce: 0
|
|
45
|
-
} : r.morph, le = u.submenu ? {
|
|
46
|
-
duration: .14,
|
|
47
|
-
bounce: 0
|
|
48
|
-
} : r.glow, v = new t(0, r.morph), y = new t(1, le), b = null, x = null, S = "become", C = {
|
|
49
|
-
left: 0,
|
|
50
|
-
top: 0,
|
|
51
|
-
width: 0,
|
|
52
|
-
height: 0
|
|
53
|
-
}, w, T, E = !1, D, O = 0, ue = 0, k, A, j = !1, M = !1, N = !1, P = 0, F = !1, I, L, R = null, z, B = 0, V = 0, H = {
|
|
54
|
-
element: c,
|
|
55
|
-
visible: () => !F,
|
|
56
|
-
trigger: () => u.from?.(),
|
|
57
|
-
retain: () => {
|
|
58
|
-
B++, D?.pause();
|
|
59
|
-
let e = !1;
|
|
60
|
-
return () => {
|
|
61
|
-
e || (e = !0, --B === 0 && !F && (O = performance.now(), D?.play()));
|
|
62
|
-
};
|
|
63
|
-
},
|
|
64
|
-
snapshot: () => A ?? (P && L ? L.snapshot() : m(c)),
|
|
65
|
-
finish: () => {
|
|
66
|
-
T?.(), T = void 0, j = !1, F = !0, P = 0, v.jump(0), y.jump(0), A = void 0, c.style.setProperty("--lg-morph", "0"), D?.finish(), c.dispatchEvent(new CustomEvent("glass:exited"));
|
|
67
|
-
}
|
|
68
|
-
}, U = (e, t) => u.radius === "capsule" ? "capsule" : te(u.radius, e, t), W = () => Math.min(devicePixelRatio || 1, 2), G = () => {
|
|
69
|
-
if (!u.submenu || L) return;
|
|
70
|
-
R = u.from?.()?.parentElement?.closest(".lg-menu") ?? null;
|
|
71
|
-
let e = R ? d.get(R) : void 0;
|
|
72
|
-
e !== H && e?.element.isConnected && e.visible() && (L = e, z = e.retain());
|
|
73
|
-
}, K = () => {
|
|
74
|
-
if (b = u.from?.() ?? null, u.submenu) {
|
|
75
|
-
G(), b = L?.element ?? null, x = null, S = "become", L && (C = { ...L.snapshot() }), N = !L;
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
let e = b?.classList.contains("lg-surface") ? b : null, t = b?.parentElement?.closest(".lg-surface") ?? null;
|
|
79
|
-
S = u.morph ?? (e ? "become" : "detach"), x = S === "become" ? e : e ?? (t && !t.contains(c) ? t : null), S === "become" && x && (b = x), b?.isConnected && (C = m(b)), N = !b?.isConnected || !C.width || !C.height;
|
|
80
|
-
}, q = () => {
|
|
81
|
-
let e = m(c), t = g(c);
|
|
82
|
-
if (!t.width || !t.height || N || !b) {
|
|
83
|
-
k = void 0;
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
let n = {
|
|
87
|
-
from: { ...C },
|
|
88
|
-
fromRadius: h(b),
|
|
89
|
-
to: e,
|
|
90
|
-
toRadius: u.radius,
|
|
91
|
-
along: ee(C, e)
|
|
92
|
-
}, r = S === "detach" && x?.isConnected ? (() => {
|
|
93
|
-
let e = m(x), t = g(x);
|
|
94
|
-
return {
|
|
95
|
-
...e,
|
|
96
|
-
radius: h(x),
|
|
97
|
-
layoutWidth: t.width || e.width,
|
|
98
|
-
layoutHeight: t.height || e.height
|
|
99
|
-
};
|
|
100
|
-
})() : void 0, i = u.neck ?? 18, a = s(n, i > 0 ? r : void 0, {
|
|
101
|
-
dpr: 1,
|
|
102
|
-
restDpr: W(),
|
|
103
|
-
neck: i,
|
|
104
|
-
stops: l(i > 0 ? 14 : 10)
|
|
105
|
-
});
|
|
106
|
-
if (S === "become" && x) {
|
|
107
|
-
let e = g(x);
|
|
108
|
-
e.width && e.height && Object.assign(a[0].shape, {
|
|
109
|
-
width: e.width,
|
|
110
|
-
height: e.height
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
Object.assign(a.at(-1).shape, {
|
|
114
|
-
width: t.width,
|
|
115
|
-
height: t.height
|
|
116
|
-
});
|
|
117
|
-
let o = i > 0 && r ? x ?? void 0 : void 0;
|
|
118
|
-
k = {
|
|
119
|
-
endpoints: n,
|
|
120
|
-
stops: a,
|
|
121
|
-
shapes: a.map((e) => e.shape),
|
|
122
|
-
glass: S === "become" ? x ?? void 0 : o,
|
|
123
|
-
glassRect: o && r ? {
|
|
124
|
-
left: r.left,
|
|
125
|
-
top: r.top,
|
|
126
|
-
width: r.width,
|
|
127
|
-
height: r.height
|
|
128
|
-
} : void 0
|
|
129
|
-
};
|
|
130
|
-
}, J = () => !k || !u.prepared || k.stops.every((e) => u.prepared(e.shape)) ? !0 : !k.stops.some((e) => e.shape.outline) && u.prepared(k.stops.at(-1).shape);
|
|
131
|
-
function de() {
|
|
132
|
-
if (u.motion() === "none") return;
|
|
133
|
-
T?.(), T = void 0, K(), R && d.set(R, H), E = !0, S === "become" && x && !N && (w?.(), w = p(x)), j = !0, M = !1, F = !1;
|
|
134
|
-
let e = N || u.motion() === "reduced";
|
|
135
|
-
v.configure(_).jump(+!!e), e ? (k = void 0, P = 0) : (q(), P = ue || performance.now()), y.jump(+!e).target = 1, c.dataset.glassMorph = "enter", c.style.setProperty("--lg-morph", "0");
|
|
136
|
-
}
|
|
137
|
-
function fe() {
|
|
138
|
-
if (u.motion() === "none") return;
|
|
139
|
-
E = !1, u.submenu && (k = void 0, N = !0, z?.(), z = void 0, L = void 0), j || (u.submenu || K(), !N && u.motion() !== "reduced" ? (S === "become" && x && (w ??= p(x)), !k || se(k.endpoints.to, m(c)) ? q() : k.endpoints.from = { ...C }, v.jump(1)) : k = void 0), j = !0, M = !0, P = 0;
|
|
140
|
-
let e = !k || N || u.motion() === "reduced";
|
|
141
|
-
v.configure(f).target = +!!e, y.target = +!e, c.dataset.glassMorph = "exit";
|
|
142
|
-
let t = e ? n(le, y.value, 0, y.velocity) : n(f, v.value, 0, v.velocity, .01);
|
|
143
|
-
D?.cancel(), O = performance.now();
|
|
144
|
-
let r = u.submenu ? 60 : 0;
|
|
145
|
-
V = O + r, D = c.animate([{}, {}], { duration: Math.max(16, t * 1e3 + 40 + r) }), B && D.pause();
|
|
146
|
-
let i = u.submenu ? R : b?.parentElement?.closest(".lg-menu");
|
|
147
|
-
i && (T = ie(i, () => {
|
|
148
|
-
M && !F && (T?.(), T = void 0, j = !1, F = !0, P = 0, v.jump(0), y.jump(0), A = void 0, c.style.setProperty("--lg-morph", "0"), w?.(), w = void 0, D?.finish(), c.dispatchEvent(new CustomEvent("glass:exited")));
|
|
149
|
-
}));
|
|
150
|
-
}
|
|
151
|
-
function Y() {
|
|
152
|
-
T?.(), T = void 0, E = !1, j = !1, M = !1, P = 0, D = void 0, delete c.dataset.glassMorph, c.style.removeProperty("--lg-morph");
|
|
153
|
-
}
|
|
154
|
-
let pe = new MutationObserver(() => {
|
|
155
|
-
let e = c.hasAttribute("data-ending-style");
|
|
156
|
-
e && !M ? fe() : !e && !c.hasAttribute("data-closed") && F && !M ? (F = !1, Z = u.enter !== !1 && u.motion() !== "none", Q = void 0, me = 0, $ = 0, Z && (G(), c.dataset.glassMorph = "enter", c.style.setProperty("--lg-morph", "0"))) : !e && !c.hasAttribute("data-closed") && M && (T?.(), T = void 0, E = !0, R && d.set(R, H), F && (F = !1, S === "become" && x && (w ??= p(x))), D?.cancel(), D = void 0, M = !1, j = !0, v.configure(_).target = 1, y.target = 1, P = u.motion() === "full" && k && !J() ? performance.now() : 0, c.dataset.glassMorph = "enter");
|
|
157
|
-
}), X = !!u.from && c.hasAttribute("data-ending-style");
|
|
158
|
-
F = !!u.from && !X && c.hasAttribute("data-closed");
|
|
159
|
-
let Z = !!u.from && u.enter !== !1 && !X && !F && u.motion() !== "none", Q, me = 0, $ = 0;
|
|
160
|
-
u.from && pe.observe(c, {
|
|
161
|
-
attributes: !0,
|
|
162
|
-
attributeFilter: ["data-ending-style", "data-closed"]
|
|
163
|
-
}), X && u.motion() !== "none" && fe(), Z && (G(), c.dataset.glassMorph = "enter", c.style.setProperty("--lg-morph", "0"));
|
|
164
|
-
let he = (e, t) => {
|
|
165
|
-
if (!e.box) return {
|
|
166
|
-
shape: e.shape,
|
|
167
|
-
...t
|
|
168
|
-
};
|
|
169
|
-
let n = k?.glassRect, r = n && k?.glass?.isConnected ? m(k.glass) : void 0, i = r && n ? r.left - n.left : 0, a = r && n ? r.top - n.top : 0;
|
|
170
|
-
return {
|
|
171
|
-
shape: e.shape,
|
|
172
|
-
left: e.box.left + i,
|
|
173
|
-
top: e.box.top + a,
|
|
174
|
-
width: e.box.width,
|
|
175
|
-
height: e.box.height
|
|
176
|
-
};
|
|
177
|
-
}, ge = (e, t) => {
|
|
178
|
-
let n = k ? a(k.stops, e) : void 0, r = !k?.glass || !n ? 0 : S === "become" ? 1 : n.absorb;
|
|
179
|
-
return {
|
|
180
|
-
...t,
|
|
181
|
-
draw: n && {
|
|
182
|
-
a: he(n.a, t),
|
|
183
|
-
b: n.b && he(n.b, t),
|
|
184
|
-
mix: n.mix
|
|
185
|
-
},
|
|
186
|
-
absorbs: r > 0 && k?.glass ? {
|
|
187
|
-
element: k.glass,
|
|
188
|
-
weight: r
|
|
189
|
-
} : void 0
|
|
190
|
-
};
|
|
191
|
-
};
|
|
192
|
-
return {
|
|
193
|
-
frame(e) {
|
|
194
|
-
let t = O ? Math.max(0, (e - O) / 1e3) : oe;
|
|
195
|
-
if (O = e, ue = e, B && M && !F) return !0;
|
|
196
|
-
if (M && u.submenu && (t = Math.min(t, Math.max(0, (e - V) / 1e3))), Z) {
|
|
197
|
-
let e = m(c), n = !c.hasAttribute("data-starting-style") && Q && Math.hypot(e.left - Q.left, e.top - Q.top) < .5 && Math.abs(e.width - Q.width) < .5 && Math.abs(e.height - Q.height) < .5;
|
|
198
|
-
Q = e, $ = n ? $ + 1 : 0, ($ >= 2 || ++me > 8) && (Z = !1, t = 0, c.hasAttribute("data-ending-style") || de(), j || Y());
|
|
199
|
-
}
|
|
200
|
-
if (u.layout && !j) {
|
|
201
|
-
let e = {
|
|
202
|
-
x: c.offsetLeft,
|
|
203
|
-
y: c.offsetTop,
|
|
204
|
-
width: c.offsetWidth,
|
|
205
|
-
height: c.offsetHeight
|
|
206
|
-
};
|
|
207
|
-
if (I && e.width && e.height && u.motion() === "full" && [
|
|
208
|
-
e.x - I.x,
|
|
209
|
-
e.y - I.y,
|
|
210
|
-
e.width - I.width,
|
|
211
|
-
e.height - I.height
|
|
212
|
-
].some((e) => Math.abs(e) > .5)) {
|
|
213
|
-
let n = k?.layout && A ? {
|
|
214
|
-
left: A.left - k.layout.x,
|
|
215
|
-
top: A.top - k.layout.y,
|
|
216
|
-
width: A.width,
|
|
217
|
-
height: A.height
|
|
218
|
-
} : {
|
|
219
|
-
left: I.x,
|
|
220
|
-
top: I.y,
|
|
221
|
-
width: I.width,
|
|
222
|
-
height: I.height
|
|
223
|
-
}, i = {
|
|
224
|
-
from: n,
|
|
225
|
-
fromRadius: U(n.width, n.height),
|
|
226
|
-
to: {
|
|
227
|
-
left: e.x,
|
|
228
|
-
top: e.y,
|
|
229
|
-
width: e.width,
|
|
230
|
-
height: e.height
|
|
231
|
-
},
|
|
232
|
-
toRadius: u.radius
|
|
233
|
-
}, a = s(i, void 0, {
|
|
234
|
-
stops: l(12),
|
|
235
|
-
dpr: 1,
|
|
236
|
-
restDpr: W()
|
|
237
|
-
});
|
|
238
|
-
k = {
|
|
239
|
-
endpoints: i,
|
|
240
|
-
stops: a,
|
|
241
|
-
shapes: a.map((e) => e.shape),
|
|
242
|
-
layout: e
|
|
243
|
-
}, v.configure(r.layout).jump(0).target = 1, t = 0;
|
|
244
|
-
}
|
|
245
|
-
e.width && e.height && (I = e);
|
|
246
|
-
}
|
|
247
|
-
if (P && (J() || e - P > ae) && (P = 0, v.target = 1, t = 0), P && (t = 0), E && !P) {
|
|
248
|
-
E = !1, L?.finish(), z?.(), z = void 0, L = void 0;
|
|
249
|
-
let e = u.submenu ? R : b?.parentElement?.closest(".lg-menu");
|
|
250
|
-
e && re(e);
|
|
251
|
-
}
|
|
252
|
-
v.step(t), y.step(t);
|
|
253
|
-
let n = () => {
|
|
254
|
-
let e = Z || j || P > 0 || !v.settled || !y.settled;
|
|
255
|
-
return e || (O = 0), e;
|
|
256
|
-
}, a = M && k && !N && u.motion() === "full" && v.value <= .012 && Math.abs(v.velocity) <= .15;
|
|
257
|
-
if (j && !P && (a || v.settled && y.settled) && (M ? (T?.(), T = void 0, j = !1, F = !0, k && v.jump(0), w?.(), w = void 0, c.dispatchEvent(new CustomEvent("glass:exited"))) : Y()), k?.layout) {
|
|
258
|
-
if (v.settled && v.value === 1) return k = void 0, A = void 0, n();
|
|
259
|
-
let e = m(c), t = v.value, r = o(k.endpoints, t), i = k.layout, a = {
|
|
260
|
-
left: e.left + r.left - i.x,
|
|
261
|
-
top: e.top + r.top - i.y,
|
|
262
|
-
width: r.width,
|
|
263
|
-
height: r.height,
|
|
264
|
-
radius: r.radius
|
|
265
|
-
};
|
|
266
|
-
return A = {
|
|
267
|
-
...ge(t, a),
|
|
268
|
-
radius: U(r.width, r.height)
|
|
269
|
-
}, !0;
|
|
270
|
-
}
|
|
271
|
-
if (F) return A = void 0, n();
|
|
272
|
-
if (j && k) {
|
|
273
|
-
if (b?.isConnected && !M) {
|
|
274
|
-
let t = m(c);
|
|
275
|
-
ce(k.endpoints.to, t) ? P || (C = m(b), q(), J() || (P = e)) : se(k.endpoints.to, t) && (k.endpoints.to = t);
|
|
276
|
-
}
|
|
277
|
-
let t = v.value, r = o(k.endpoints, t);
|
|
278
|
-
return c.style.setProperty("--lg-morph", (i(t) * y.value).toFixed(3)), S === "become" && x instanceof HTMLElement && x.style.setProperty("--lg-morph-source", ne(t).toFixed(3)), A = ge(t, r), n();
|
|
279
|
-
}
|
|
280
|
-
return j ? (c.style.setProperty("--lg-morph", y.value.toFixed(3)), A = void 0, n()) : (A = void 0, n());
|
|
281
|
-
},
|
|
282
|
-
geometry: () => A,
|
|
283
|
-
detachedSource: () => !F && S === "detach" && x?.isConnected && k?.stops.some((e) => e.absorbs) ? x : void 0,
|
|
284
|
-
waypoints: () => k?.shapes ?? [],
|
|
285
|
-
pending: () => P > 0,
|
|
286
|
-
positioning: () => Z,
|
|
287
|
-
opacity() {
|
|
288
|
-
return F || Z ? 0 : j ? k ? u.submenu || k.glass ? 1 : Math.min(1, Math.max(0, v.value / .2)) : e && !u.submenu ? 1 : y.value : 1;
|
|
289
|
-
},
|
|
290
|
-
dispose() {
|
|
291
|
-
z?.(), z = void 0, R && d.get(R) === H && d.delete(R), pe.disconnect(), D?.cancel(), w?.(), Y();
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
//#endregion
|
|
296
|
-
export { _ as attachGeometryMotion, f as prepareSubmenuHandoff, te as radiusPixels };
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { GlassShape as e } from "./shape.js";
|
|
3
|
-
import { useGlassForeground as t } from "./scene.js";
|
|
4
|
-
import { useMergedRef as n } from "./merged-ref.js";
|
|
5
|
-
import { switchDragState as r } from "./value-control-motion.js";
|
|
6
|
-
import { ControlThumb as i } from "./control-thumb.js";
|
|
7
|
-
import { useEffect as a, useRef as o, useState as s } from "react";
|
|
8
|
-
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
9
|
-
import { Slider as u } from "@base-ui/react/slider";
|
|
10
|
-
import { Switch as d } from "@base-ui/react/switch";
|
|
11
|
-
//#region src/react/value-controls.tsx
|
|
12
|
-
function f({ material: r, appearance: o, tint: d, refraction: f, radius: p = "capsule", motion: m, interactive: h = !0, className: g = "", style: _, ticks: v = !1, min: y = 0, max: b = 100, step: x = .1, thumbProps: S, "aria-label": C, "aria-labelledby": w, ...T }) {
|
|
13
|
-
if (!Number.isFinite(y) || !Number.isFinite(b) || b <= y || !Number.isFinite(b - y) || !Number.isFinite(x) || x <= 0) throw RangeError("GlassSlider requires finite min < max and a positive finite step.");
|
|
14
|
-
let E = (b - y) / x;
|
|
15
|
-
if (v && (E < 1 || E > 100 || Math.abs(E - Math.round(E)) > 1e-7)) throw RangeError("Ticked sliders require 1–100 evenly divided intervals.");
|
|
16
|
-
let D = t(), O = n(T.ref, D), { className: k = "", ...A } = S ?? {}, [j, M] = s(!1);
|
|
17
|
-
return a(() => {
|
|
18
|
-
if (!j) return;
|
|
19
|
-
let e = () => M(!1);
|
|
20
|
-
return window.addEventListener("pointerup", e), window.addEventListener("pointercancel", e), window.addEventListener("blur", e), () => {
|
|
21
|
-
window.removeEventListener("pointerup", e), window.removeEventListener("pointercancel", e), window.removeEventListener("blur", e);
|
|
22
|
-
};
|
|
23
|
-
}, [j]), /* @__PURE__ */ c(u.Root, {
|
|
24
|
-
defaultValue: y,
|
|
25
|
-
...T,
|
|
26
|
-
ref: O,
|
|
27
|
-
min: y,
|
|
28
|
-
max: b,
|
|
29
|
-
step: x,
|
|
30
|
-
className: `lg-slider ${g}`,
|
|
31
|
-
style: {
|
|
32
|
-
"--lg-accent": d ?? "#8e8e93",
|
|
33
|
-
..._
|
|
34
|
-
},
|
|
35
|
-
"data-ticks": v ? "" : void 0,
|
|
36
|
-
children: /* @__PURE__ */ l(u.Control, {
|
|
37
|
-
className: "lg-slider-control",
|
|
38
|
-
onPointerDownCapture: (e) => {
|
|
39
|
-
!e.defaultPrevented && e.button === 0 && M(!0);
|
|
40
|
-
},
|
|
41
|
-
onPointerUp: () => M(!1),
|
|
42
|
-
onPointerCancel: () => M(!1),
|
|
43
|
-
onLostPointerCapture: () => M(!1),
|
|
44
|
-
children: [
|
|
45
|
-
/* @__PURE__ */ c(e, {
|
|
46
|
-
radius: "capsule",
|
|
47
|
-
render: /* @__PURE__ */ c(u.Track, {}),
|
|
48
|
-
className: "lg-slider-track",
|
|
49
|
-
children: /* @__PURE__ */ c(e, {
|
|
50
|
-
radius: "capsule",
|
|
51
|
-
render: /* @__PURE__ */ c(u.Indicator, {}),
|
|
52
|
-
className: "lg-slider-fill"
|
|
53
|
-
})
|
|
54
|
-
}),
|
|
55
|
-
v && /* @__PURE__ */ c("div", {
|
|
56
|
-
className: "lg-slider-ticks",
|
|
57
|
-
"aria-hidden": "true",
|
|
58
|
-
children: Array.from({ length: Math.round(E) + 1 }, (e, t) => /* @__PURE__ */ c("span", {}, t))
|
|
59
|
-
}),
|
|
60
|
-
/* @__PURE__ */ c(u.Thumb, {
|
|
61
|
-
"aria-label": C,
|
|
62
|
-
"aria-labelledby": w,
|
|
63
|
-
...A,
|
|
64
|
-
render: (e, t) => /* @__PURE__ */ c(i, {
|
|
65
|
-
...e,
|
|
66
|
-
motion: m,
|
|
67
|
-
interactive: h,
|
|
68
|
-
pressed: j || t.dragging,
|
|
69
|
-
options: {
|
|
70
|
-
material: r,
|
|
71
|
-
appearance: o,
|
|
72
|
-
radius: p,
|
|
73
|
-
refraction: f
|
|
74
|
-
},
|
|
75
|
-
className: `lg-slider-thumb ${typeof k == "function" ? k(t) : k}`
|
|
76
|
-
})
|
|
77
|
-
})
|
|
78
|
-
]
|
|
79
|
-
})
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
function p({ material: a, appearance: u, tint: f, refraction: p, radius: m = "capsule", motion: h, interactive: g = !0, className: _ = "", style: v, ...y }) {
|
|
83
|
-
let b = t(), x = n(y.ref, b), [S, C] = s(!1), [w, T] = s(null), E = o(null), D = o(!1);
|
|
84
|
-
return /* @__PURE__ */ l(d.Root, {
|
|
85
|
-
...y,
|
|
86
|
-
ref: x,
|
|
87
|
-
nativeButton: !1,
|
|
88
|
-
className: `lg-switch ${_}`,
|
|
89
|
-
style: {
|
|
90
|
-
"--lg-accent": f ?? "#8e8e93",
|
|
91
|
-
...v
|
|
92
|
-
},
|
|
93
|
-
render: (e, t) => /* @__PURE__ */ c("span", {
|
|
94
|
-
...e,
|
|
95
|
-
role: "switch",
|
|
96
|
-
"aria-checked": t.checked,
|
|
97
|
-
tabIndex: e.tabIndex ?? 0,
|
|
98
|
-
style: {
|
|
99
|
-
...e.style,
|
|
100
|
-
"--lg-switch-position": w ?? +!!t.checked
|
|
101
|
-
},
|
|
102
|
-
"data-presentation-checked": w === null ? void 0 : w === 1 ? "true" : "false",
|
|
103
|
-
onPointerDown: (n) => {
|
|
104
|
-
if (e.onPointerDown?.(n), n.defaultPrevented || y.readOnly || n.button !== 0) return;
|
|
105
|
-
D.current = !1;
|
|
106
|
-
let r = getComputedStyle(n.currentTarget).direction === "rtl", i = +!!t.checked, a = n.currentTarget.getBoundingClientRect(), o = n.clientX >= a.left + a.width / 2 !== r;
|
|
107
|
-
E.current = {
|
|
108
|
-
id: n.pointerId,
|
|
109
|
-
x: n.clientX,
|
|
110
|
-
start: i,
|
|
111
|
-
current: i,
|
|
112
|
-
left: a.left,
|
|
113
|
-
width: a.width,
|
|
114
|
-
rtl: r,
|
|
115
|
-
oppositeHalf: o !== t.checked,
|
|
116
|
-
moved: !1
|
|
117
|
-
}, n.currentTarget.setPointerCapture(n.pointerId), T(i), C(!0);
|
|
118
|
-
},
|
|
119
|
-
onPointerMove: (t) => {
|
|
120
|
-
e.onPointerMove?.(t);
|
|
121
|
-
let n = E.current;
|
|
122
|
-
if (!n || n.id !== t.pointerId || t.defaultPrevented) return;
|
|
123
|
-
let i = t.clientX - n.x;
|
|
124
|
-
n.moved ||= Math.abs(i) > 3, n.current = Number(r(n, t.clientX)), n.moved && T(n.current);
|
|
125
|
-
},
|
|
126
|
-
onPointerUp: (n) => {
|
|
127
|
-
e.onPointerUp?.(n);
|
|
128
|
-
let r = E.current;
|
|
129
|
-
r && r.id === n.pointerId && (E.current = null, n.currentTarget.hasPointerCapture(n.pointerId) && n.currentTarget.releasePointerCapture(n.pointerId), r.moved && (!n.defaultPrevented && r.current >= .5 !== t.checked && n.currentTarget.click(), D.current = !0), T(null), C(!1));
|
|
130
|
-
},
|
|
131
|
-
onPointerCancel: (t) => {
|
|
132
|
-
e.onPointerCancel?.(t), E.current = null, D.current = !0, T(null), C(!1);
|
|
133
|
-
},
|
|
134
|
-
onLostPointerCapture: (t) => {
|
|
135
|
-
e.onLostPointerCapture?.(t), E.current && (E.current = null, D.current = !0, T(null), C(!1));
|
|
136
|
-
},
|
|
137
|
-
onClickCapture: (t) => {
|
|
138
|
-
if (D.current) {
|
|
139
|
-
D.current = !1, t.preventDefault(), t.stopPropagation();
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
e.onClickCapture?.(t);
|
|
143
|
-
},
|
|
144
|
-
onKeyDown: (t) => {
|
|
145
|
-
e.onKeyDown?.(t), D.current = !1, !t.defaultPrevented && !y.readOnly && (t.key === " " || t.key === "Enter") && C(!0);
|
|
146
|
-
},
|
|
147
|
-
onKeyUp: (t) => {
|
|
148
|
-
e.onKeyUp?.(t), C(!1);
|
|
149
|
-
},
|
|
150
|
-
onBlur: (t) => {
|
|
151
|
-
e.onBlur?.(t), C(!1);
|
|
152
|
-
}
|
|
153
|
-
}),
|
|
154
|
-
children: [/* @__PURE__ */ c(e, {
|
|
155
|
-
radius: "capsule",
|
|
156
|
-
render: /* @__PURE__ */ c("span", {}),
|
|
157
|
-
className: "lg-switch-track",
|
|
158
|
-
"aria-hidden": "true"
|
|
159
|
-
}), /* @__PURE__ */ c(d.Thumb, { render: (e) => /* @__PURE__ */ c(i, {
|
|
160
|
-
...e,
|
|
161
|
-
tag: "span",
|
|
162
|
-
pressed: S,
|
|
163
|
-
motion: h,
|
|
164
|
-
interactive: g,
|
|
165
|
-
options: {
|
|
166
|
-
material: a,
|
|
167
|
-
appearance: u,
|
|
168
|
-
radius: m,
|
|
169
|
-
refraction: p
|
|
170
|
-
},
|
|
171
|
-
className: "lg-switch-thumb"
|
|
172
|
-
}) })]
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
//#endregion
|
|
176
|
-
export { f as GlassSlider, p as GlassSwitch };
|