@zakisheriff/liquid-glass 0.2.7 → 0.3.0
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/README.md +20 -4
- package/dist/index.css +205 -13
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +65 -2
- package/dist/index.d.ts +65 -2
- package/dist/index.js +616 -188
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +603 -176
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -34,6 +34,7 @@ __export(index_exports, {
|
|
|
34
34
|
GlassButton: () => GlassButton,
|
|
35
35
|
GlassCard: () => GlassCard,
|
|
36
36
|
GlassInput: () => GlassInput,
|
|
37
|
+
GlassMenu: () => GlassMenu,
|
|
37
38
|
GlassNav: () => GlassNav,
|
|
38
39
|
GlassSegmented: () => GlassSegmented,
|
|
39
40
|
GlassSheet: () => GlassSheet,
|
|
@@ -186,6 +187,37 @@ function rubberband(offset, dimension, constant = 0.55) {
|
|
|
186
187
|
}
|
|
187
188
|
var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
188
189
|
|
|
190
|
+
// src/engine/selection.ts
|
|
191
|
+
function guardSelection(el2) {
|
|
192
|
+
let held = false;
|
|
193
|
+
const block = (event) => {
|
|
194
|
+
if (held) event.preventDefault();
|
|
195
|
+
};
|
|
196
|
+
const clear = () => {
|
|
197
|
+
const selection = window.getSelection?.();
|
|
198
|
+
if (selection && !selection.isCollapsed) selection.removeAllRanges();
|
|
199
|
+
};
|
|
200
|
+
const down = () => {
|
|
201
|
+
held = true;
|
|
202
|
+
clear();
|
|
203
|
+
};
|
|
204
|
+
const up = () => {
|
|
205
|
+
if (!held) return;
|
|
206
|
+
held = false;
|
|
207
|
+
clear();
|
|
208
|
+
};
|
|
209
|
+
el2.addEventListener("pointerdown", down, true);
|
|
210
|
+
document.addEventListener("selectstart", block, true);
|
|
211
|
+
window.addEventListener("pointerup", up, true);
|
|
212
|
+
window.addEventListener("pointercancel", up, true);
|
|
213
|
+
return () => {
|
|
214
|
+
el2.removeEventListener("pointerdown", down, true);
|
|
215
|
+
document.removeEventListener("selectstart", block, true);
|
|
216
|
+
window.removeEventListener("pointerup", up, true);
|
|
217
|
+
window.removeEventListener("pointercancel", up, true);
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
189
221
|
// src/engine/press.ts
|
|
190
222
|
var FOLLOW = springFrom(0.2, 0.82);
|
|
191
223
|
function usePress(ref, options = {}) {
|
|
@@ -215,18 +247,20 @@ function usePress(ref, options = {}) {
|
|
|
215
247
|
};
|
|
216
248
|
const track = (event) => {
|
|
217
249
|
if (!pointer) return;
|
|
218
|
-
const { box, base } = pointer;
|
|
250
|
+
const { box, base, w, h } = pointer;
|
|
219
251
|
light(event, box);
|
|
220
252
|
const dx = event.clientX - pointer.x;
|
|
221
253
|
const dy = event.clientY - pointer.y;
|
|
222
|
-
const tx = rubberband(dx, lean * 2.2, 0.5);
|
|
223
|
-
const ty = rubberband(dy, lean * 2.2, 0.5);
|
|
224
254
|
const dist = Math.hypot(dx, dy);
|
|
225
|
-
const pull = 1 - 1 / (1 + dist / 55);
|
|
226
|
-
const k = stretch * pull;
|
|
227
255
|
const cx = dist ? (dx / dist) ** 2 : 0;
|
|
228
256
|
const cy = dist ? (dy / dist) ** 2 : 0;
|
|
229
|
-
|
|
257
|
+
const span = Math.min(w * cx + h * cy, 64);
|
|
258
|
+
const reach = rubberband(dist, span * stretch * 2, 0.55);
|
|
259
|
+
const ex = reach * cx / w;
|
|
260
|
+
const ey = reach * cy / h;
|
|
261
|
+
const tx = Math.sign(dx) * (reach * cx * base) / 2 + rubberband(dx, lean * 0.6, 0.4);
|
|
262
|
+
const ty = Math.sign(dy) * (reach * cy * base) / 2 + rubberband(dy, lean * 0.6, 0.4);
|
|
263
|
+
to([base * (1 + ex - ey * 0.35), base * (1 + ey - ex * 0.35), tx, ty], FOLLOW);
|
|
230
264
|
};
|
|
231
265
|
const move = (event) => {
|
|
232
266
|
if (event.pointerId === pointer?.id) track(event);
|
|
@@ -249,7 +283,7 @@ function usePress(ref, options = {}) {
|
|
|
249
283
|
const natural = Math.min(0.22, Math.max(0.07, 9 / Math.sqrt(w * h)));
|
|
250
284
|
const amount = (grow ?? natural) * (event.pointerType === "mouse" ? 0.75 : 1);
|
|
251
285
|
const base = 1 + amount;
|
|
252
|
-
pointer = { id: event.pointerId, x: event.clientX, y: event.clientY, box, base };
|
|
286
|
+
pointer = { id: event.pointerId, x: event.clientX, y: event.clientY, box, base, w, h };
|
|
253
287
|
el2.dataset.pressed = "";
|
|
254
288
|
light(event, box);
|
|
255
289
|
to([base, base, 0, 0], SPRINGS.press);
|
|
@@ -261,12 +295,14 @@ function usePress(ref, options = {}) {
|
|
|
261
295
|
const hold = (event) => {
|
|
262
296
|
if (pointer && event.cancelable) event.preventDefault();
|
|
263
297
|
};
|
|
298
|
+
const unguard = guardSelection(el2);
|
|
264
299
|
el2.addEventListener("touchmove", hold, { passive: false });
|
|
265
300
|
el2.addEventListener("pointerdown", down);
|
|
266
301
|
window.addEventListener("blur", blur);
|
|
267
302
|
return () => {
|
|
268
303
|
up();
|
|
269
304
|
springs.forEach((s) => s.stop());
|
|
305
|
+
unguard();
|
|
270
306
|
el2.removeEventListener("pointerdown", down);
|
|
271
307
|
el2.removeEventListener("touchmove", hold);
|
|
272
308
|
window.removeEventListener("blur", blur);
|
|
@@ -296,6 +332,7 @@ function clone(source) {
|
|
|
296
332
|
});
|
|
297
333
|
root.querySelectorAll(`[${SELF}], .lg-mirror, [data-lg-mirror-skip], input, textarea, select`).forEach((n) => n.remove());
|
|
298
334
|
root.removeAttribute("data-mirror");
|
|
335
|
+
root.setAttribute("data-lg-copy", "");
|
|
299
336
|
root.setAttribute("inert", "");
|
|
300
337
|
root.setAttribute("aria-hidden", "true");
|
|
301
338
|
return { root, pairs };
|
|
@@ -319,6 +356,7 @@ function backdropChain(glass, source) {
|
|
|
319
356
|
}
|
|
320
357
|
return chain;
|
|
321
358
|
}
|
|
359
|
+
var stateOf = (el2) => Array.from(el2.attributes).map((a) => a.name).filter((name) => name.startsWith("data-") && name !== "data-mirror" && !name.startsWith("data-lg-mirror")).sort().join(" ");
|
|
322
360
|
var BACKGROUND = ["background-color", "background-image", "background-size", "background-position", "background-repeat", "border-radius"];
|
|
323
361
|
function mirrorBackdrop(glass, source, padding, zoom, active2 = () => true) {
|
|
324
362
|
const layer = document.createElement("div");
|
|
@@ -402,6 +440,10 @@ function mirrorBackdrop(glass, source, padding, zoom, active2 = () => true) {
|
|
|
402
440
|
root.style.margin = "0px";
|
|
403
441
|
root.style.width = `${sw}px`;
|
|
404
442
|
root.style.height = `${sh}px`;
|
|
443
|
+
root.style.maxWidth = "none";
|
|
444
|
+
root.style.maxHeight = "none";
|
|
445
|
+
root.style.minWidth = "0px";
|
|
446
|
+
root.style.minHeight = "0px";
|
|
405
447
|
root.style.scale = "none";
|
|
406
448
|
root.style.translate = "none";
|
|
407
449
|
root.style.transformOrigin = "0 0";
|
|
@@ -424,10 +466,19 @@ function mirrorBackdrop(glass, source, padding, zoom, active2 = () => true) {
|
|
|
424
466
|
pair.copy.className = cls;
|
|
425
467
|
}
|
|
426
468
|
}
|
|
469
|
+
const flags = stateOf(source);
|
|
470
|
+
if (flags !== copyFlags) {
|
|
471
|
+
const now = new Set(flags.split(" "));
|
|
472
|
+
for (const name of copyFlags.split(" ")) if (name && !now.has(name)) copy.root.removeAttribute(name);
|
|
473
|
+
for (const name of flags.split(" ")) if (name) copy.root.setAttribute(name, source.getAttribute(name) ?? "");
|
|
474
|
+
copyFlags = flags;
|
|
475
|
+
}
|
|
427
476
|
};
|
|
477
|
+
let copyFlags = "";
|
|
428
478
|
let zoomed = "";
|
|
429
479
|
const applyZoom = () => {
|
|
430
|
-
const
|
|
480
|
+
const z = zoom();
|
|
481
|
+
const value = Array.isArray(z) ? `scale(${z[0]}, ${z[1]})` : `scale(${z})`;
|
|
431
482
|
if (value !== zoomed) zoomer.style.transform = zoomed = value;
|
|
432
483
|
};
|
|
433
484
|
const tick = () => {
|
|
@@ -453,6 +504,7 @@ function mirrorBackdrop(glass, source, padding, zoom, active2 = () => true) {
|
|
|
453
504
|
const next = clone(source);
|
|
454
505
|
copy.root.replaceWith(next.root);
|
|
455
506
|
copy = next;
|
|
507
|
+
copyFlags = "";
|
|
456
508
|
placed = "";
|
|
457
509
|
buildUnder();
|
|
458
510
|
align();
|
|
@@ -540,10 +592,17 @@ function bake(width, height, radius, shape, pad = 0, simple = false) {
|
|
|
540
592
|
const rimA = new Float32Array(cw * ch);
|
|
541
593
|
const rimHue = new Float32Array(cw * ch);
|
|
542
594
|
const inside = new Float32Array(cw * ch);
|
|
595
|
+
const zone = new Float32Array(cw * ch);
|
|
543
596
|
let max = 1e-4;
|
|
544
597
|
const hw = width / 2;
|
|
545
598
|
const hh = height / 2;
|
|
546
599
|
const px1 = 1 / density;
|
|
600
|
+
const edge = hh - shape.inset;
|
|
601
|
+
const band = (py) => {
|
|
602
|
+
if (!shape.inset) return 1;
|
|
603
|
+
const t = clamp((Math.abs(py) - (edge - 2)) / 3, 0, 1);
|
|
604
|
+
return 1 - t * t * (3 - 2 * t);
|
|
605
|
+
};
|
|
547
606
|
for (let y = 0; y < ch; y++) {
|
|
548
607
|
for (let x = 0; x < cw; x++) {
|
|
549
608
|
const px = (x + 0.5) * W / cw - W / 2;
|
|
@@ -567,18 +626,19 @@ function bake(width, height, radius, shape, pad = 0, simple = false) {
|
|
|
567
626
|
ny = Math.sign(py);
|
|
568
627
|
}
|
|
569
628
|
const i = y * cw + x;
|
|
570
|
-
const s = shift(d) * shape.strength * direction;
|
|
629
|
+
const s = shift(d) * shape.strength * direction * band(py);
|
|
571
630
|
let vx = nx * s;
|
|
572
631
|
let vy = ny * s;
|
|
573
632
|
if (simple && magnify) {
|
|
574
|
-
vx -= px * magnify;
|
|
575
|
-
vy -= py * magnify;
|
|
633
|
+
vx -= px * magnify * band(py);
|
|
634
|
+
vy -= py * magnify * band(py);
|
|
576
635
|
}
|
|
577
636
|
dx[i] = vx;
|
|
578
637
|
dy[i] = vy;
|
|
579
638
|
const m = Math.max(Math.abs(vx), Math.abs(vy));
|
|
580
639
|
if (m > max) max = m;
|
|
581
640
|
inside[i] = clamp(d / px1 + 0.5, 0, 1);
|
|
641
|
+
zone[i] = (d <= 0 ? 1 : clamp(1 - d / Math.max(1, shape.bezel), 0, 1) ** 1.3) * band(py);
|
|
582
642
|
if (d >= -px1) {
|
|
583
643
|
const facing = -(nx + ny) * Math.SQRT1_2;
|
|
584
644
|
const light = 0.22 + 0.78 * Math.abs(facing) ** 2.2 * (facing > 0 ? 1 : 0.62);
|
|
@@ -613,8 +673,9 @@ function bake(width, height, radius, shape, pad = 0, simple = false) {
|
|
|
613
673
|
const o = (y * cw + x) * 4;
|
|
614
674
|
const px = (x + 0.5) * W / cw - W / 2;
|
|
615
675
|
const py = (y + 0.5) * H / ch - H / 2;
|
|
616
|
-
|
|
617
|
-
ramp.data[o
|
|
676
|
+
const k = band(py);
|
|
677
|
+
ramp.data[o] = Math.round(127.5 - px / reach * 127.5 * k);
|
|
678
|
+
ramp.data[o + 1] = Math.round(127.5 - py / reach * 127.5 * k);
|
|
618
679
|
ramp.data[o + 2] = 128;
|
|
619
680
|
ramp.data[o + 3] = 255;
|
|
620
681
|
}
|
|
@@ -650,6 +711,17 @@ function bake(width, height, radius, shape, pad = 0, simple = false) {
|
|
|
650
711
|
}
|
|
651
712
|
ctx.putImageData(shapeMask, 0, 0);
|
|
652
713
|
const mask = canvas.toDataURL();
|
|
714
|
+
let smooth = "";
|
|
715
|
+
if (lens && !simple) {
|
|
716
|
+
const soft = ctx.createImageData(cw, ch);
|
|
717
|
+
for (let i = 0; i < cw * ch; i++) {
|
|
718
|
+
const o = i * 4;
|
|
719
|
+
soft.data[o] = soft.data[o + 1] = soft.data[o + 2] = 255;
|
|
720
|
+
soft.data[o + 3] = Math.round(zone[i] * 255);
|
|
721
|
+
}
|
|
722
|
+
ctx.putImageData(soft, 0, 0);
|
|
723
|
+
smooth = canvas.toDataURL();
|
|
724
|
+
}
|
|
653
725
|
const id = `lg-refract-${++counter}`;
|
|
654
726
|
const box = { x: 0, y: 0, width: W, height: H };
|
|
655
727
|
const filter = el("filter", {
|
|
@@ -714,9 +786,20 @@ function bake(width, height, radius, shape, pad = 0, simple = false) {
|
|
|
714
786
|
})
|
|
715
787
|
);
|
|
716
788
|
}
|
|
789
|
+
let out = "bent";
|
|
790
|
+
if (smooth) {
|
|
791
|
+
filter.append(
|
|
792
|
+
el("feGaussianBlur", { in: "bent", stdDeviation: 0.65, result: "bent-soft" }),
|
|
793
|
+
el("feImage", { href: smooth, ...box, preserveAspectRatio: "none", result: "rim-zone" }),
|
|
794
|
+
el("feComposite", { in: "bent-soft", in2: "rim-zone", operator: "in", result: "rim-soft" }),
|
|
795
|
+
el("feComposite", { in: "bent", in2: "rim-zone", operator: "out", result: "core" }),
|
|
796
|
+
el("feComposite", { in: "rim-soft", in2: "core", operator: "arithmetic", k2: 1, k3: 1, result: "smoothed" })
|
|
797
|
+
);
|
|
798
|
+
out = "smoothed";
|
|
799
|
+
}
|
|
717
800
|
filter.append(
|
|
718
801
|
el("feImage", { href: mask, ...box, preserveAspectRatio: "none", result: "shape" }),
|
|
719
|
-
el("feComposite", { in:
|
|
802
|
+
el("feComposite", { in: out, in2: "shape", operator: "in" })
|
|
720
803
|
);
|
|
721
804
|
container().append(filter);
|
|
722
805
|
return { filter: `url(#${id})`, rim: `url("${rim}")`, inner: `url("${mask}")` };
|
|
@@ -731,8 +814,11 @@ function resolve(shape, width, height) {
|
|
|
731
814
|
thickness: shape.thickness ?? (lens ? short * 0.55 : clamp(short * 0.32, 8, 26)),
|
|
732
815
|
ior: shape.ior ?? 1.5,
|
|
733
816
|
zoom: shape.zoom ?? (lens ? 1.16 : 1),
|
|
817
|
+
zoomX: shape.zoomX ?? shape.zoom ?? (lens ? 1.16 : 1),
|
|
734
818
|
dispersion: shape.dispersion ?? (lens ? 1 : 0),
|
|
735
|
-
strength: shape.strength ?? 1
|
|
819
|
+
strength: shape.strength ?? 1,
|
|
820
|
+
inset: shape.inset ?? 0,
|
|
821
|
+
copy: shape.copy ?? false
|
|
736
822
|
};
|
|
737
823
|
}
|
|
738
824
|
function glassFor(width, height, radius, shape = {}, pad = 0, simple = false) {
|
|
@@ -740,7 +826,7 @@ function glassFor(width, height, radius, shape = {}, pad = 0, simple = false) {
|
|
|
740
826
|
const h = Math.round(height);
|
|
741
827
|
const r = Math.min(w / 2, h / 2, Math.max(0, radius));
|
|
742
828
|
const full = resolve(shape, w, h);
|
|
743
|
-
const key = [w, h, Math.round(r * 2) / 2, full.kind, full.bezel.toFixed(1), full.thickness.toFixed(1), full.ior, full.zoom, full.dispersion, full.strength, pad, simple].join("|");
|
|
829
|
+
const key = [w, h, Math.round(r * 2) / 2, full.kind, full.bezel.toFixed(1), full.thickness.toFixed(1), full.ior, full.zoom, full.dispersion, full.strength, full.inset, pad, simple].join("|");
|
|
744
830
|
let baked = cache.get(key);
|
|
745
831
|
if (!baked) {
|
|
746
832
|
baked = bake(w, h, r, full, pad, simple);
|
|
@@ -767,11 +853,18 @@ function useRefraction(ref, shape = {}, enabled = true, mirror, mirrorActive) {
|
|
|
767
853
|
(0, import_react2.useEffect)(() => {
|
|
768
854
|
const element = ref.current;
|
|
769
855
|
if (!element || !enabled) return;
|
|
770
|
-
const live = canRefractBackdrop();
|
|
856
|
+
const live = canRefractBackdrop() && !(shape.copy && mirror);
|
|
771
857
|
let cancel;
|
|
772
858
|
let filter = "";
|
|
773
859
|
let pad = 0;
|
|
774
860
|
let zoom = 1;
|
|
861
|
+
let zoomX = 1;
|
|
862
|
+
const bendCopy = shape.copy === "refract" && canRefractBackdrop() && !!mirror;
|
|
863
|
+
let copyFilter = "";
|
|
864
|
+
const applyCopyFilter = () => {
|
|
865
|
+
const viewport = element.querySelector(":scope > .lg-mirror > .lg-mirror__viewport");
|
|
866
|
+
if (viewport && copyFilter) viewport.style.filter = copyFilter;
|
|
867
|
+
};
|
|
775
868
|
const fit = () => {
|
|
776
869
|
const width = element.offsetWidth;
|
|
777
870
|
const height = element.offsetHeight;
|
|
@@ -781,10 +874,17 @@ function useRefraction(ref, shape = {}, enabled = true, mirror, mirrorActive) {
|
|
|
781
874
|
filter = baked.filter;
|
|
782
875
|
if (!live && mirror?.current) {
|
|
783
876
|
pad = Math.ceil(Math.min(width, height) * 0.45 + 6);
|
|
784
|
-
zoom = resolve(shape, width, height)
|
|
877
|
+
({ zoom, zoomX } = resolve(shape, width, height));
|
|
785
878
|
element.style.setProperty("--lg-inner-mask", baked.inner);
|
|
879
|
+
if (bendCopy) {
|
|
880
|
+
copyFilter = glassFor(width, height, radius, { ...shape, zoom: 1, zoomX: 1, dispersion: 0 }, pad).filter;
|
|
881
|
+
applyCopyFilter();
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
if (live) {
|
|
885
|
+
element.style.setProperty("--lg-filter", baked.filter);
|
|
886
|
+
element.setAttribute("data-lg-refract", "");
|
|
786
887
|
}
|
|
787
|
-
if (live) element.style.setProperty("--lg-filter", baked.filter);
|
|
788
888
|
element.style.setProperty("--lg-rim", baked.rim);
|
|
789
889
|
};
|
|
790
890
|
const observer = new ResizeObserver(() => {
|
|
@@ -794,13 +894,15 @@ function useRefraction(ref, shape = {}, enabled = true, mirror, mirrorActive) {
|
|
|
794
894
|
observer.observe(element);
|
|
795
895
|
fit();
|
|
796
896
|
const source = mirror?.current;
|
|
797
|
-
const unmirror = !live && source ? mirrorBackdrop(element, source, () => pad, () => zoom, mirrorActive) : void 0;
|
|
897
|
+
const unmirror = !live && source ? mirrorBackdrop(element, source, () => pad, () => [zoomX, zoom], mirrorActive) : void 0;
|
|
898
|
+
applyCopyFilter();
|
|
798
899
|
return () => {
|
|
799
900
|
cancel?.();
|
|
800
901
|
unmirror?.();
|
|
801
902
|
observer.disconnect();
|
|
802
903
|
element.style.removeProperty("--lg-filter");
|
|
803
904
|
element.style.removeProperty("--lg-rim");
|
|
905
|
+
element.removeAttribute("data-lg-refract");
|
|
804
906
|
};
|
|
805
907
|
}, [ref, signature, enabled, mirror]);
|
|
806
908
|
}
|
|
@@ -1024,106 +1126,138 @@ var import_react_dom = require("react-dom");
|
|
|
1024
1126
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1025
1127
|
var OPEN = springFrom(0.42, 0.86);
|
|
1026
1128
|
var CLOSE = springFrom(0.34, 1);
|
|
1027
|
-
var
|
|
1129
|
+
var SNAP = springFrom(0.4, 0.84);
|
|
1130
|
+
var GlassSheet = ({ open, onClose, intensity = 5, tint, container: container2, detents, children, "aria-label": ariaLabel }) => {
|
|
1028
1131
|
const [mounted, setMounted] = (0, import_react6.useState)(open);
|
|
1029
1132
|
const sheetRef = (0, import_react6.useRef)(null);
|
|
1030
1133
|
const scrimRef = (0, import_react6.useRef)(null);
|
|
1031
|
-
const
|
|
1134
|
+
const api = (0, import_react6.useRef)(null);
|
|
1135
|
+
const stopsKey = detents?.join(",") ?? "";
|
|
1032
1136
|
const closeRef = (0, import_react6.useRef)(onClose);
|
|
1033
1137
|
closeRef.current = onClose;
|
|
1034
1138
|
(0, import_react6.useEffect)(() => {
|
|
1035
1139
|
if (open) setMounted(true);
|
|
1036
|
-
else
|
|
1140
|
+
else api.current?.close();
|
|
1037
1141
|
}, [open]);
|
|
1038
1142
|
useRefraction(sheetRef, { kind: "surface", strength: Math.max(1, Math.min(10, intensity)) / 5, bezel: 20, thickness: 28 }, mounted);
|
|
1039
1143
|
(0, import_react6.useEffect)(() => {
|
|
1040
1144
|
if (!mounted) return;
|
|
1041
1145
|
const sheet = sheetRef.current;
|
|
1042
1146
|
const scrim = scrimRef.current;
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1147
|
+
const layer = sheet.parentElement;
|
|
1148
|
+
const wanted = stopsKey ? stopsKey.split(",") : [];
|
|
1149
|
+
let height = 0;
|
|
1150
|
+
let hidden = 0;
|
|
1151
|
+
let stops = [0];
|
|
1152
|
+
let rest = 0;
|
|
1153
|
+
let medium = 0;
|
|
1154
|
+
const measure = () => {
|
|
1155
|
+
height = sheet.offsetHeight || 400;
|
|
1156
|
+
hidden = height + 24;
|
|
1157
|
+
medium = Math.max(0, height - layer.clientHeight * 0.5);
|
|
1158
|
+
stops = wanted.length ? wanted.map((d) => d === "large" ? 0 : medium).sort((x, y) => x - y) : [0];
|
|
1159
|
+
rest = wanted.includes("medium") ? medium : stops[0];
|
|
1160
|
+
};
|
|
1161
|
+
measure();
|
|
1162
|
+
const paint = (y) => {
|
|
1047
1163
|
sheet.style.transform = `translateY(${y}px)`;
|
|
1048
|
-
|
|
1164
|
+
const dim = wanted.includes("medium") && medium > 0 ? clamp(1 - y / medium, 0, 1) : clamp(1 - y / Math.max(1, height), 0, 1);
|
|
1165
|
+
scrim.style.opacity = String(dim);
|
|
1166
|
+
const raised = y <= 1;
|
|
1167
|
+
if (wanted.length && sheet.hasAttribute("data-raised") !== raised) sheet.toggleAttribute("data-raised", raised);
|
|
1049
1168
|
};
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1169
|
+
let closing = false;
|
|
1170
|
+
const position = createSpring(hidden, OPEN, (y) => {
|
|
1171
|
+
paint(y);
|
|
1172
|
+
if (closing && y >= hidden - 1) setMounted(false);
|
|
1053
1173
|
});
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
set(
|
|
1057
|
-
|
|
1058
|
-
|
|
1174
|
+
const go = (y, feel) => {
|
|
1175
|
+
position.tune(feel);
|
|
1176
|
+
position.set(y);
|
|
1177
|
+
};
|
|
1178
|
+
api.current = {
|
|
1179
|
+
close() {
|
|
1180
|
+
closing = true;
|
|
1181
|
+
go(hidden, CLOSE);
|
|
1059
1182
|
}
|
|
1060
1183
|
};
|
|
1061
|
-
paint(
|
|
1184
|
+
paint(hidden);
|
|
1062
1185
|
requestAnimationFrame(() => {
|
|
1063
|
-
|
|
1064
|
-
|
|
1186
|
+
measure();
|
|
1187
|
+
position.set(hidden, true);
|
|
1188
|
+
if (open) go(rest, OPEN);
|
|
1065
1189
|
});
|
|
1066
1190
|
let gesture = null;
|
|
1067
1191
|
const down = (event) => {
|
|
1068
|
-
if (event.defaultPrevented) return;
|
|
1192
|
+
if (event.defaultPrevented || closing) return;
|
|
1069
1193
|
const target = event.target;
|
|
1070
|
-
|
|
1194
|
+
const raised = position.value <= 1;
|
|
1195
|
+
if (raised && !target.closest(".lg-sheet__grabber-zone") && sheet.scrollTop > 0) return;
|
|
1071
1196
|
if (target.closest('input, textarea, button, a, [role="slider"], [role="switch"]')) return;
|
|
1072
|
-
|
|
1197
|
+
position.stop();
|
|
1198
|
+
gesture = { id: event.pointerId, y: event.clientY, from: position.value, t: event.timeStamp, v: 0, last: position.value };
|
|
1073
1199
|
sheet.setPointerCapture(event.pointerId);
|
|
1074
1200
|
};
|
|
1075
1201
|
const move = (event) => {
|
|
1076
1202
|
if (event.pointerId !== gesture?.id) return;
|
|
1077
|
-
const
|
|
1203
|
+
const raw = gesture.from + event.clientY - gesture.y;
|
|
1204
|
+
const y = raw < 0 ? rubberband(raw, height, 0.3) : raw;
|
|
1078
1205
|
const dt = Math.max(1, event.timeStamp - gesture.t);
|
|
1079
|
-
gesture.v = (
|
|
1206
|
+
gesture.v = gesture.v * 0.2 + (y - gesture.last) / dt * 0.8;
|
|
1080
1207
|
gesture.t = event.timeStamp;
|
|
1081
|
-
|
|
1082
|
-
|
|
1208
|
+
gesture.last = y;
|
|
1209
|
+
position.set(y, true);
|
|
1210
|
+
paint(y);
|
|
1083
1211
|
};
|
|
1084
1212
|
const up = (event) => {
|
|
1085
1213
|
if (event.pointerId !== gesture?.id) return;
|
|
1086
|
-
const
|
|
1214
|
+
const { v, last: last2 } = gesture;
|
|
1087
1215
|
gesture = null;
|
|
1088
|
-
const
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
settle.stop();
|
|
1094
|
-
const p = 1 - clamp(drag / (height + 24), 0, 1);
|
|
1095
|
-
drag = 0;
|
|
1096
|
-
spring.set(p, true);
|
|
1216
|
+
const projected = last2 + v * 180;
|
|
1217
|
+
const lowest = stops[stops.length - 1];
|
|
1218
|
+
if (projected > lowest + (hidden - lowest) * 0.45 || v > 0.9 && last2 >= lowest - 4) {
|
|
1219
|
+
closing = true;
|
|
1220
|
+
go(hidden, CLOSE);
|
|
1097
1221
|
closeRef.current?.();
|
|
1098
|
-
|
|
1099
|
-
settle.set(0);
|
|
1222
|
+
return;
|
|
1100
1223
|
}
|
|
1224
|
+
const target = stops.reduce((best, stop) => Math.abs(stop - projected) < Math.abs(best - projected) ? stop : best, stops[0]);
|
|
1225
|
+
go(target, SNAP);
|
|
1101
1226
|
};
|
|
1102
1227
|
const key = (event) => {
|
|
1103
1228
|
if (event.key === "Escape") closeRef.current?.();
|
|
1104
1229
|
};
|
|
1230
|
+
const resize = () => {
|
|
1231
|
+
const at = position.target;
|
|
1232
|
+
const was = stops.indexOf(at);
|
|
1233
|
+
measure();
|
|
1234
|
+
if (!closing) go(was >= 0 ? stops[Math.min(was, stops.length - 1)] : rest, SNAP);
|
|
1235
|
+
};
|
|
1236
|
+
const observer = new ResizeObserver(resize);
|
|
1237
|
+
observer.observe(layer);
|
|
1105
1238
|
sheet.addEventListener("pointerdown", down);
|
|
1106
1239
|
sheet.addEventListener("pointermove", move);
|
|
1107
1240
|
sheet.addEventListener("pointerup", up);
|
|
1108
1241
|
sheet.addEventListener("pointercancel", up);
|
|
1109
1242
|
window.addEventListener("keydown", key);
|
|
1110
1243
|
const overflow = document.body.style.overflow;
|
|
1111
|
-
document.body.style.overflow = "hidden";
|
|
1244
|
+
if (!container2) document.body.style.overflow = "hidden";
|
|
1112
1245
|
sheet.focus({ preventScroll: true });
|
|
1113
1246
|
return () => {
|
|
1114
|
-
|
|
1115
|
-
|
|
1247
|
+
position.stop();
|
|
1248
|
+
api.current = null;
|
|
1249
|
+
observer.disconnect();
|
|
1116
1250
|
sheet.removeEventListener("pointerdown", down);
|
|
1117
1251
|
sheet.removeEventListener("pointermove", move);
|
|
1118
1252
|
sheet.removeEventListener("pointerup", up);
|
|
1119
1253
|
sheet.removeEventListener("pointercancel", up);
|
|
1120
1254
|
window.removeEventListener("keydown", key);
|
|
1121
|
-
document.body.style.overflow = overflow;
|
|
1255
|
+
if (!container2) document.body.style.overflow = overflow;
|
|
1122
1256
|
};
|
|
1123
|
-
}, [mounted]);
|
|
1257
|
+
}, [mounted, container2, stopsKey]);
|
|
1124
1258
|
if (!mounted || typeof document === "undefined") return null;
|
|
1125
1259
|
return (0, import_react_dom.createPortal)(
|
|
1126
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "lg-sheet-layer", "data-liquid-glass": "", children: [
|
|
1260
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "lg-sheet-layer", "data-liquid-glass": "", style: container2 ? { position: "absolute" } : void 0, children: [
|
|
1127
1261
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { ref: scrimRef, className: "lg-sheet__scrim", onClick: () => onClose?.(), "aria-hidden": "true" }),
|
|
1128
1262
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1129
1263
|
"div",
|
|
@@ -1133,7 +1267,7 @@ var GlassSheet = ({ open, onClose, intensity = 5, tint, children, "aria-label":
|
|
|
1133
1267
|
"aria-modal": "true",
|
|
1134
1268
|
"aria-label": ariaLabel,
|
|
1135
1269
|
tabIndex: -1,
|
|
1136
|
-
className: "lg-glass lg-glass--host lg-sheet",
|
|
1270
|
+
className: ["lg-glass", "lg-glass--host", "lg-sheet", detents?.length ? "lg-sheet--detents" : ""].filter(Boolean).join(" "),
|
|
1137
1271
|
style: tint ? { "--lg-host-tint": tint } : void 0,
|
|
1138
1272
|
children: [
|
|
1139
1273
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "lg-sheet__grabber-zone", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "lg-sheet__grabber" }) }),
|
|
@@ -1142,24 +1276,263 @@ var GlassSheet = ({ open, onClose, intensity = 5, tint, children, "aria-label":
|
|
|
1142
1276
|
}
|
|
1143
1277
|
)
|
|
1144
1278
|
] }),
|
|
1145
|
-
document.body
|
|
1279
|
+
container2 ?? document.body
|
|
1146
1280
|
);
|
|
1147
1281
|
};
|
|
1148
1282
|
GlassSheet.displayName = "GlassSheet";
|
|
1149
1283
|
|
|
1284
|
+
// src/components/GlassMenu/GlassMenu.tsx
|
|
1285
|
+
var import_react7 = require("react");
|
|
1286
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1287
|
+
var OPEN2 = springFrom(0.36, 0.74);
|
|
1288
|
+
var CLOSE2 = springFrom(0.34, 0.9);
|
|
1289
|
+
var FADE = springFrom(0.24, 1);
|
|
1290
|
+
var FADE_OUT = springFrom(0.14, 1);
|
|
1291
|
+
var JELLY = springFrom(0.42, 0.4);
|
|
1292
|
+
var Tick = () => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: "M3.5 8.5l3 3 6-7", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
1293
|
+
var GlassMenu = ({
|
|
1294
|
+
icon,
|
|
1295
|
+
items,
|
|
1296
|
+
"aria-label": ariaLabel,
|
|
1297
|
+
align = "end",
|
|
1298
|
+
size = "md",
|
|
1299
|
+
width = 230,
|
|
1300
|
+
check,
|
|
1301
|
+
className
|
|
1302
|
+
}) => {
|
|
1303
|
+
const [open, setOpen] = (0, import_react7.useState)(false);
|
|
1304
|
+
const [mounted, setMounted] = (0, import_react7.useState)(false);
|
|
1305
|
+
const anchorRef = (0, import_react7.useRef)(null);
|
|
1306
|
+
const triggerRef = (0, import_react7.useRef)(null);
|
|
1307
|
+
const surfaceRef = (0, import_react7.useRef)(null);
|
|
1308
|
+
const panelRef = (0, import_react7.useRef)(null);
|
|
1309
|
+
const contentRef = (0, import_react7.useRef)(null);
|
|
1310
|
+
const spring = (0, import_react7.useRef)(null);
|
|
1311
|
+
const itemsRef = (0, import_react7.useRef)(items);
|
|
1312
|
+
itemsRef.current = items;
|
|
1313
|
+
usePress(surfaceRef, { grow: 0.035, lean: 6, stretch: 0.1, disabled: !mounted });
|
|
1314
|
+
(0, import_react7.useEffect)(() => {
|
|
1315
|
+
if (open) setMounted(true);
|
|
1316
|
+
else if (spring.current) {
|
|
1317
|
+
spring.current.tune(CLOSE2);
|
|
1318
|
+
spring.current.set(0);
|
|
1319
|
+
}
|
|
1320
|
+
}, [open]);
|
|
1321
|
+
(0, import_react7.useLayoutEffect)(() => {
|
|
1322
|
+
if (!mounted) return;
|
|
1323
|
+
const surface = surfaceRef.current;
|
|
1324
|
+
const panel = panelRef.current;
|
|
1325
|
+
const content = contentRef.current;
|
|
1326
|
+
const trigger = triggerRef.current;
|
|
1327
|
+
const w = trigger.offsetWidth;
|
|
1328
|
+
const h = trigger.offsetHeight;
|
|
1329
|
+
const W = Math.max(w, Math.min(width, window.innerWidth - 24));
|
|
1330
|
+
content.style.width = `${W}px`;
|
|
1331
|
+
const H = Math.max(h, content.offsetHeight);
|
|
1332
|
+
surface.style.width = `${W}px`;
|
|
1333
|
+
surface.style.height = `${H}px`;
|
|
1334
|
+
const end = align === "end";
|
|
1335
|
+
const box = { cw: w, ch: h, r: h / 2 };
|
|
1336
|
+
let scaleNow = 1;
|
|
1337
|
+
const clipContent = () => {
|
|
1338
|
+
const k = scaleNow;
|
|
1339
|
+
const right = Math.max(0, W - box.cw / k);
|
|
1340
|
+
const bottom = Math.max(0, H - box.ch / k);
|
|
1341
|
+
content.style.clipPath = box.cw >= W - 0.5 && box.ch >= H - 0.5 && k === 1 ? "" : `inset(0 ${end ? 0 : right}px ${bottom}px ${end ? right : 0}px round ${box.r / k}px)`;
|
|
1342
|
+
};
|
|
1343
|
+
const shape = (p) => {
|
|
1344
|
+
const cw = Math.max(1, w + (W - w) * p);
|
|
1345
|
+
const ch = Math.max(1, h + (H - h) * p);
|
|
1346
|
+
const sx = cw / W;
|
|
1347
|
+
const sy = ch / H;
|
|
1348
|
+
panel.style.transform = `scale(${sx}, ${sy})`;
|
|
1349
|
+
const land = clamp((p - 0.5) / 0.5, 0, 1);
|
|
1350
|
+
const r = Math.min(cw, ch) / 2 * (1 - land) + 24 * land;
|
|
1351
|
+
panel.style.borderRadius = `${r / sx}px / ${r / sy}px`;
|
|
1352
|
+
box.cw = cw;
|
|
1353
|
+
box.ch = ch;
|
|
1354
|
+
box.r = r;
|
|
1355
|
+
clipContent();
|
|
1356
|
+
const k = clamp(p / 0.35, 0, 1);
|
|
1357
|
+
panel.style.opacity = String(k);
|
|
1358
|
+
trigger.style.opacity = String(1 - k);
|
|
1359
|
+
};
|
|
1360
|
+
const reveal = (q) => {
|
|
1361
|
+
const t = clamp(q, 0, 1);
|
|
1362
|
+
const blur = 9 * (1 - t) ** 2.5;
|
|
1363
|
+
content.style.opacity = String(t);
|
|
1364
|
+
scaleNow = t < 0.999 ? 0.82 + 0.18 * t : 1;
|
|
1365
|
+
content.style.scale = scaleNow === 1 ? "" : String(scaleNow);
|
|
1366
|
+
clipContent();
|
|
1367
|
+
content.style.filter = blur > 0.05 ? `blur(${blur.toFixed(2)}px)` : "none";
|
|
1368
|
+
};
|
|
1369
|
+
shape(0);
|
|
1370
|
+
reveal(0);
|
|
1371
|
+
const s = createSpring(0, OPEN2, (p) => {
|
|
1372
|
+
shape(p);
|
|
1373
|
+
if (p <= 0.02 && s.target === 0) {
|
|
1374
|
+
trigger.style.opacity = "";
|
|
1375
|
+
const jelly = createSpring(0.07, JELLY, (v) => {
|
|
1376
|
+
trigger.style.scale = Math.abs(v) < 5e-4 ? "" : `${1 - v} ${1 + v}`;
|
|
1377
|
+
});
|
|
1378
|
+
jelly.set(0);
|
|
1379
|
+
setMounted(false);
|
|
1380
|
+
}
|
|
1381
|
+
});
|
|
1382
|
+
const fade = createSpring(0, FADE, reveal);
|
|
1383
|
+
spring.current = {
|
|
1384
|
+
...s,
|
|
1385
|
+
tune: s.tune,
|
|
1386
|
+
set(target, instant) {
|
|
1387
|
+
fade.tune(target ? FADE : FADE_OUT);
|
|
1388
|
+
fade.set(target, instant);
|
|
1389
|
+
s.set(target, instant);
|
|
1390
|
+
}
|
|
1391
|
+
};
|
|
1392
|
+
spring.current.set(1);
|
|
1393
|
+
content.querySelector('[role="menuitem"]:not([disabled])')?.focus({ preventScroll: true });
|
|
1394
|
+
return () => {
|
|
1395
|
+
s.stop();
|
|
1396
|
+
fade.stop();
|
|
1397
|
+
spring.current = null;
|
|
1398
|
+
trigger.style.opacity = "";
|
|
1399
|
+
};
|
|
1400
|
+
}, [mounted]);
|
|
1401
|
+
(0, import_react7.useEffect)(() => {
|
|
1402
|
+
if (!mounted) return;
|
|
1403
|
+
const panel = surfaceRef.current;
|
|
1404
|
+
let held = null;
|
|
1405
|
+
let hot = null;
|
|
1406
|
+
const itemAt = (x, y) => document.elementFromPoint(x, y)?.closest(".lg-menu__item:not(:disabled)") ?? null;
|
|
1407
|
+
const light = (next) => {
|
|
1408
|
+
if (next === hot) return;
|
|
1409
|
+
hot?.removeAttribute("data-active");
|
|
1410
|
+
hot = next;
|
|
1411
|
+
if (hot) {
|
|
1412
|
+
hot.setAttribute("data-active", "");
|
|
1413
|
+
haptic();
|
|
1414
|
+
}
|
|
1415
|
+
};
|
|
1416
|
+
const down = (event) => {
|
|
1417
|
+
if (!event.isPrimary || event.button !== 0) return;
|
|
1418
|
+
held = event.pointerId;
|
|
1419
|
+
hot = null;
|
|
1420
|
+
light(itemAt(event.clientX, event.clientY));
|
|
1421
|
+
};
|
|
1422
|
+
const move = (event) => {
|
|
1423
|
+
if (event.pointerId === held) light(itemAt(event.clientX, event.clientY));
|
|
1424
|
+
};
|
|
1425
|
+
const up = (event) => {
|
|
1426
|
+
if (event.pointerId !== held) return;
|
|
1427
|
+
held = null;
|
|
1428
|
+
const target = hot;
|
|
1429
|
+
light(null);
|
|
1430
|
+
const index = target ? Number(target.dataset.index) : -1;
|
|
1431
|
+
const item = itemsRef.current[index];
|
|
1432
|
+
if (item && !item.disabled) {
|
|
1433
|
+
event.preventDefault();
|
|
1434
|
+
haptic();
|
|
1435
|
+
item.onSelect?.();
|
|
1436
|
+
setOpen(false);
|
|
1437
|
+
}
|
|
1438
|
+
};
|
|
1439
|
+
const cancel = (event) => {
|
|
1440
|
+
if (event.pointerId !== held) return;
|
|
1441
|
+
held = null;
|
|
1442
|
+
light(null);
|
|
1443
|
+
};
|
|
1444
|
+
const hold = (event) => {
|
|
1445
|
+
if (held !== null && event.cancelable) event.preventDefault();
|
|
1446
|
+
};
|
|
1447
|
+
panel.addEventListener("pointerdown", down);
|
|
1448
|
+
window.addEventListener("pointermove", move);
|
|
1449
|
+
window.addEventListener("pointerup", up);
|
|
1450
|
+
window.addEventListener("pointercancel", cancel);
|
|
1451
|
+
panel.addEventListener("touchmove", hold, { passive: false });
|
|
1452
|
+
return () => {
|
|
1453
|
+
panel.removeEventListener("pointerdown", down);
|
|
1454
|
+
window.removeEventListener("pointermove", move);
|
|
1455
|
+
window.removeEventListener("pointerup", up);
|
|
1456
|
+
window.removeEventListener("pointercancel", cancel);
|
|
1457
|
+
panel.removeEventListener("touchmove", hold);
|
|
1458
|
+
};
|
|
1459
|
+
}, [mounted]);
|
|
1460
|
+
(0, import_react7.useEffect)(() => {
|
|
1461
|
+
if (!open) return;
|
|
1462
|
+
const outside = (event) => {
|
|
1463
|
+
if (!anchorRef.current?.contains(event.target)) setOpen(false);
|
|
1464
|
+
};
|
|
1465
|
+
const key = (event) => {
|
|
1466
|
+
if (event.key === "Escape") {
|
|
1467
|
+
setOpen(false);
|
|
1468
|
+
triggerRef.current?.focus({ preventScroll: true });
|
|
1469
|
+
}
|
|
1470
|
+
};
|
|
1471
|
+
document.addEventListener("pointerdown", outside, true);
|
|
1472
|
+
window.addEventListener("keydown", key);
|
|
1473
|
+
return () => {
|
|
1474
|
+
document.removeEventListener("pointerdown", outside, true);
|
|
1475
|
+
window.removeEventListener("keydown", key);
|
|
1476
|
+
};
|
|
1477
|
+
}, [open]);
|
|
1478
|
+
const select = (item) => {
|
|
1479
|
+
haptic();
|
|
1480
|
+
item.onSelect?.();
|
|
1481
|
+
setOpen(false);
|
|
1482
|
+
};
|
|
1483
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { ref: anchorRef, className: ["lg-menu-anchor", className].filter(Boolean).join(" "), "data-align": align, children: [
|
|
1484
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1485
|
+
GlassButton,
|
|
1486
|
+
{
|
|
1487
|
+
ref: triggerRef,
|
|
1488
|
+
size,
|
|
1489
|
+
icon,
|
|
1490
|
+
"aria-label": ariaLabel,
|
|
1491
|
+
"aria-haspopup": "menu",
|
|
1492
|
+
"aria-expanded": open,
|
|
1493
|
+
onClick: () => setOpen((value) => !value)
|
|
1494
|
+
}
|
|
1495
|
+
),
|
|
1496
|
+
mounted && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ref: surfaceRef, className: "lg-menu-surface", children: [
|
|
1497
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ref: panelRef, className: "lg-glass lg-menu", "data-liquid-glass": "", "aria-hidden": "true" }),
|
|
1498
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ref: contentRef, className: "lg-menu__content", role: "menu", "aria-label": ariaLabel, children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1499
|
+
"button",
|
|
1500
|
+
{
|
|
1501
|
+
type: "button",
|
|
1502
|
+
role: "menuitem",
|
|
1503
|
+
className: "lg-menu__item",
|
|
1504
|
+
"data-destructive": item.destructive ? "" : void 0,
|
|
1505
|
+
"data-index": index,
|
|
1506
|
+
disabled: item.disabled,
|
|
1507
|
+
onClick: (event) => {
|
|
1508
|
+
if (event.detail === 0) select(item);
|
|
1509
|
+
},
|
|
1510
|
+
children: [
|
|
1511
|
+
item.icon != null && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "lg-menu__icon", children: item.icon }),
|
|
1512
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "lg-menu__label", children: item.label }),
|
|
1513
|
+
item.checked && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "lg-menu__check", children: check ?? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Tick, {}) })
|
|
1514
|
+
]
|
|
1515
|
+
},
|
|
1516
|
+
index
|
|
1517
|
+
)) })
|
|
1518
|
+
] })
|
|
1519
|
+
] });
|
|
1520
|
+
};
|
|
1521
|
+
GlassMenu.displayName = "GlassMenu";
|
|
1522
|
+
|
|
1150
1523
|
// src/components/GlassNav/GlassNav.tsx
|
|
1151
|
-
var
|
|
1524
|
+
var import_react10 = __toESM(require("react"));
|
|
1152
1525
|
|
|
1153
1526
|
// src/components/internal/LensTrack.tsx
|
|
1154
|
-
var
|
|
1527
|
+
var import_react9 = require("react");
|
|
1155
1528
|
|
|
1156
1529
|
// src/engine/lensTrack.ts
|
|
1157
|
-
var
|
|
1530
|
+
var import_react8 = require("react");
|
|
1158
1531
|
function useLensTrack(refs, options) {
|
|
1159
|
-
const latest = (0,
|
|
1532
|
+
const latest = (0, import_react8.useRef)(options);
|
|
1160
1533
|
latest.current = options;
|
|
1161
|
-
const api = (0,
|
|
1162
|
-
(0,
|
|
1534
|
+
const api = (0, import_react8.useRef)(null);
|
|
1535
|
+
(0, import_react8.useEffect)(() => {
|
|
1163
1536
|
const bar = refs.bar.current;
|
|
1164
1537
|
const lens = refs.lens.current;
|
|
1165
1538
|
const glass = refs.glass.current;
|
|
@@ -1176,7 +1549,7 @@ function useLensTrack(refs, options) {
|
|
|
1176
1549
|
let gesture = null;
|
|
1177
1550
|
let dropTimer = 0;
|
|
1178
1551
|
let suppressClick = false;
|
|
1179
|
-
const buttons = Array.from(bar.querySelectorAll("[data-lg-item]"));
|
|
1552
|
+
const buttons = Array.from(bar.querySelectorAll(":scope > [data-lg-item]"));
|
|
1180
1553
|
let glyphs = [];
|
|
1181
1554
|
const preview = (index) => {
|
|
1182
1555
|
if (index === void 0) delete bar.dataset.previewing;
|
|
@@ -1199,14 +1572,23 @@ function useLensTrack(refs, options) {
|
|
|
1199
1572
|
select.style.width = `${slot}px`;
|
|
1200
1573
|
select.style.left = `${pad}px`;
|
|
1201
1574
|
glyphs = buttons.flatMap(
|
|
1202
|
-
(button) => Array.from(button.querySelectorAll(".lg-nav__label, .lg-nav__icon > .lg-symbol")).map((node) =>
|
|
1203
|
-
node
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1575
|
+
(button) => Array.from(button.querySelectorAll(".lg-nav__label, .lg-nav__icon > .lg-symbol")).map((node) => {
|
|
1576
|
+
const label2 = node.classList.contains("lg-nav__label");
|
|
1577
|
+
const host = label2 ? node : node.parentElement;
|
|
1578
|
+
const n = node.getBoundingClientRect();
|
|
1579
|
+
const h = host.getBoundingClientRect();
|
|
1580
|
+
return {
|
|
1581
|
+
node,
|
|
1582
|
+
x: button.offsetLeft + node.offsetLeft - pad,
|
|
1583
|
+
y: node.offsetTop,
|
|
1584
|
+
width: node.offsetWidth,
|
|
1585
|
+
height: node.offsetHeight,
|
|
1586
|
+
label: label2,
|
|
1587
|
+
host,
|
|
1588
|
+
dx: n.left - h.left,
|
|
1589
|
+
dy: n.top - h.top
|
|
1590
|
+
};
|
|
1591
|
+
})
|
|
1210
1592
|
);
|
|
1211
1593
|
};
|
|
1212
1594
|
const paint = () => {
|
|
@@ -1228,8 +1610,24 @@ function useLensTrack(refs, options) {
|
|
|
1228
1610
|
if (lift2 <= 0.02 && !gesture) {
|
|
1229
1611
|
glyph.node.style.removeProperty("--lg-content-tint");
|
|
1230
1612
|
glyph.node.style.removeProperty("transform");
|
|
1613
|
+
glyph.host.style.removeProperty("--lg-content-hide");
|
|
1231
1614
|
continue;
|
|
1232
1615
|
}
|
|
1616
|
+
if (latest.current.copied) {
|
|
1617
|
+
const hy = H * ky / 2;
|
|
1618
|
+
const hx = H * kx / 2;
|
|
1619
|
+
const run = Math.max(0, (W - H) * kx / 2);
|
|
1620
|
+
const ccx = x2 + slot / 2 - glyph.x + glyph.dx;
|
|
1621
|
+
const ccy = height / 2 - glyph.y + glyph.dy;
|
|
1622
|
+
const fade = clamp(lift2 * 3, 0, 1);
|
|
1623
|
+
const solid = `rgb(0 0 0 / ${fade})`;
|
|
1624
|
+
glyph.host.style.setProperty("--lg-content-hide", [
|
|
1625
|
+
"linear-gradient(#000, #000)",
|
|
1626
|
+
`radial-gradient(ellipse ${hx}px ${hy}px at ${ccx - run}px ${ccy}px, ${solid} calc(100% - 1px), transparent 100%)`,
|
|
1627
|
+
`radial-gradient(ellipse ${hx}px ${hy}px at ${ccx + run}px ${ccy}px, ${solid} calc(100% - 1px), transparent 100%)`,
|
|
1628
|
+
`linear-gradient(${solid}, ${solid}) ${ccx - run}px ${ccy - hy}px / ${run * 2}px ${hy * 2}px no-repeat`
|
|
1629
|
+
].join(", "));
|
|
1630
|
+
}
|
|
1233
1631
|
const zoom = latest.current.contentZoom ?? 1;
|
|
1234
1632
|
const ry = H * ky / (2 * zoom);
|
|
1235
1633
|
const rx = H * kx / (2 * zoom);
|
|
@@ -1422,6 +1820,7 @@ function useLensTrack(refs, options) {
|
|
|
1422
1820
|
x.set(current * slot, true);
|
|
1423
1821
|
bar.dataset.ready = "";
|
|
1424
1822
|
observer.observe(bar);
|
|
1823
|
+
const unguard = guardSelection(bar);
|
|
1425
1824
|
bar.addEventListener("pointerdown", onDown);
|
|
1426
1825
|
window.addEventListener("pointermove", onMove);
|
|
1427
1826
|
window.addEventListener("pointerup", onUp);
|
|
@@ -1435,6 +1834,7 @@ function useLensTrack(refs, options) {
|
|
|
1435
1834
|
clearTimeout(dropTimer);
|
|
1436
1835
|
api.current = null;
|
|
1437
1836
|
[x, lift, swell].forEach((s) => s.stop());
|
|
1837
|
+
unguard();
|
|
1438
1838
|
observer.disconnect();
|
|
1439
1839
|
bar.removeEventListener("pointerdown", onDown);
|
|
1440
1840
|
window.removeEventListener("pointermove", onMove);
|
|
@@ -1447,19 +1847,20 @@ function useLensTrack(refs, options) {
|
|
|
1447
1847
|
delete bar.dataset.ready;
|
|
1448
1848
|
delete bar.dataset.lifted;
|
|
1449
1849
|
preview();
|
|
1450
|
-
glyphs.forEach(({ node }) => {
|
|
1850
|
+
glyphs.forEach(({ node, host }) => {
|
|
1451
1851
|
node.style.removeProperty("--lg-content-tint");
|
|
1452
1852
|
node.style.removeProperty("transform");
|
|
1853
|
+
host.style.removeProperty("--lg-content-hide");
|
|
1453
1854
|
});
|
|
1454
1855
|
};
|
|
1455
1856
|
}, [options.count]);
|
|
1456
|
-
(0,
|
|
1857
|
+
(0, import_react8.useEffect)(() => {
|
|
1457
1858
|
api.current?.setIndex(options.index);
|
|
1458
1859
|
}, [options.index]);
|
|
1459
1860
|
}
|
|
1460
1861
|
|
|
1461
1862
|
// src/components/internal/LensTrack.tsx
|
|
1462
|
-
var
|
|
1863
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1463
1864
|
function LensTrack({
|
|
1464
1865
|
items,
|
|
1465
1866
|
labels,
|
|
@@ -1471,28 +1872,36 @@ function LensTrack({
|
|
|
1471
1872
|
style,
|
|
1472
1873
|
"aria-label": ariaLabel
|
|
1473
1874
|
}) {
|
|
1474
|
-
const bar = (0,
|
|
1475
|
-
const glass = (0,
|
|
1476
|
-
const lens = (0,
|
|
1477
|
-
const select = (0,
|
|
1875
|
+
const bar = (0, import_react9.useRef)(null);
|
|
1876
|
+
const glass = (0, import_react9.useRef)(null);
|
|
1877
|
+
const lens = (0, import_react9.useRef)(null);
|
|
1878
|
+
const select = (0, import_react9.useRef)(null);
|
|
1478
1879
|
const strength = Math.max(1, Math.min(10, intensity)) / 5;
|
|
1479
1880
|
const tabbar = variant === "tabbar";
|
|
1480
1881
|
const zoom = tabbar ? 1.14 : 1.1;
|
|
1481
1882
|
useRefraction(glass, { kind: "surface", strength });
|
|
1482
|
-
|
|
1883
|
+
const overhang = tabbar ? 14 : 12;
|
|
1884
|
+
useRefraction(
|
|
1885
|
+
lens,
|
|
1886
|
+
{ kind: "lens", strength: 0.85, zoom, dispersion: 0.25, inset: overhang / 2, copy: "refract" },
|
|
1887
|
+
true,
|
|
1888
|
+
bar,
|
|
1889
|
+
() => bar.current?.hasAttribute("data-lifted") ?? false
|
|
1890
|
+
);
|
|
1483
1891
|
useLensTrack(
|
|
1484
1892
|
{ bar, glass, lens, select },
|
|
1485
1893
|
{
|
|
1486
1894
|
count: items.length,
|
|
1487
1895
|
index,
|
|
1488
1896
|
onSelect: (next) => onChange?.(next),
|
|
1489
|
-
overhang
|
|
1897
|
+
overhang,
|
|
1490
1898
|
spread: tabbar ? 0.3 : 0.16,
|
|
1491
|
-
contentZoom:
|
|
1899
|
+
contentZoom: zoom,
|
|
1900
|
+
copied: true,
|
|
1492
1901
|
swell: tabbar ? 8 : 14
|
|
1493
1902
|
}
|
|
1494
1903
|
);
|
|
1495
|
-
return /* @__PURE__ */ (0,
|
|
1904
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1496
1905
|
"div",
|
|
1497
1906
|
{
|
|
1498
1907
|
ref: bar,
|
|
@@ -1502,9 +1911,9 @@ function LensTrack({
|
|
|
1502
1911
|
"data-liquid-glass": "",
|
|
1503
1912
|
style: { ...style, "--lg-count": items.length, "--lg-index": index },
|
|
1504
1913
|
children: [
|
|
1505
|
-
/* @__PURE__ */ (0,
|
|
1506
|
-
/* @__PURE__ */ (0,
|
|
1507
|
-
items.map((item, i) => /* @__PURE__ */ (0,
|
|
1914
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { ref: glass, className: "lg-glass lg-track__glass", "aria-hidden": "true" }),
|
|
1915
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { ref: select, className: "lg-track__select", "aria-hidden": "true" }),
|
|
1916
|
+
items.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1508
1917
|
"button",
|
|
1509
1918
|
{
|
|
1510
1919
|
type: "button",
|
|
@@ -1518,38 +1927,40 @@ function LensTrack({
|
|
|
1518
1927
|
},
|
|
1519
1928
|
i
|
|
1520
1929
|
)),
|
|
1521
|
-
/* @__PURE__ */ (0,
|
|
1930
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { ref: lens, className: "lg-glass lg-track__lens", "data-lg-mirror-bare": "", "aria-hidden": "true" })
|
|
1522
1931
|
]
|
|
1523
1932
|
}
|
|
1524
1933
|
);
|
|
1525
1934
|
}
|
|
1526
1935
|
|
|
1527
1936
|
// src/components/GlassNav/GlassNav.tsx
|
|
1528
|
-
var
|
|
1937
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1529
1938
|
var GlassNav = ({
|
|
1530
1939
|
items,
|
|
1531
1940
|
activeIndex = 0,
|
|
1532
1941
|
onChange,
|
|
1533
1942
|
intensity = 5,
|
|
1943
|
+
showLabels = true,
|
|
1534
1944
|
className,
|
|
1535
1945
|
style,
|
|
1536
1946
|
"aria-label": ariaLabel = "Tabs"
|
|
1537
1947
|
}) => {
|
|
1538
1948
|
const hasIcons = items.some((item) => item.icon != null);
|
|
1539
|
-
|
|
1949
|
+
const iconsOnly = hasIcons && !showLabels;
|
|
1950
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1540
1951
|
LensTrack,
|
|
1541
1952
|
{
|
|
1542
1953
|
variant: "tabbar",
|
|
1543
|
-
className: ["lg-nav", hasIcons ? "" : "lg-track--labels-only", className].filter(Boolean).join(" "),
|
|
1954
|
+
className: ["lg-nav", hasIcons ? "" : "lg-track--labels-only", iconsOnly ? "lg-track--icons-only" : "", className].filter(Boolean).join(" "),
|
|
1544
1955
|
style,
|
|
1545
1956
|
"aria-label": ariaLabel,
|
|
1546
1957
|
intensity,
|
|
1547
1958
|
index: activeIndex,
|
|
1548
1959
|
onChange,
|
|
1549
1960
|
labels: items.map((item) => item.label),
|
|
1550
|
-
items: items.map((item, i) => /* @__PURE__ */ (0,
|
|
1551
|
-
item.icon != null && /* @__PURE__ */ (0,
|
|
1552
|
-
/* @__PURE__ */ (0,
|
|
1961
|
+
items: items.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react10.default.Fragment, { children: [
|
|
1962
|
+
item.icon != null && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "lg-nav__icon", children: item.icon }),
|
|
1963
|
+
!iconsOnly && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "lg-nav__label", children: item.label })
|
|
1553
1964
|
] }, i))
|
|
1554
1965
|
}
|
|
1555
1966
|
);
|
|
@@ -1557,8 +1968,8 @@ var GlassNav = ({
|
|
|
1557
1968
|
GlassNav.displayName = "GlassNav";
|
|
1558
1969
|
|
|
1559
1970
|
// src/components/GlassSegmented/GlassSegmented.tsx
|
|
1560
|
-
var
|
|
1561
|
-
var
|
|
1971
|
+
var import_react11 = __toESM(require("react"));
|
|
1972
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1562
1973
|
var GlassSegmented = ({
|
|
1563
1974
|
options,
|
|
1564
1975
|
value,
|
|
@@ -1570,7 +1981,7 @@ var GlassSegmented = ({
|
|
|
1570
1981
|
"aria-label": ariaLabel
|
|
1571
1982
|
}) => {
|
|
1572
1983
|
const normalized = options.map((option) => typeof option === "string" ? { label: option } : option);
|
|
1573
|
-
return /* @__PURE__ */ (0,
|
|
1984
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1574
1985
|
LensTrack,
|
|
1575
1986
|
{
|
|
1576
1987
|
variant: "segmented",
|
|
@@ -1581,9 +1992,9 @@ var GlassSegmented = ({
|
|
|
1581
1992
|
index: value,
|
|
1582
1993
|
onChange,
|
|
1583
1994
|
labels: normalized.map((option) => option.label),
|
|
1584
|
-
items: normalized.map((option, i) => /* @__PURE__ */ (0,
|
|
1995
|
+
items: normalized.map((option, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react11.default.Fragment, { children: [
|
|
1585
1996
|
option.icon,
|
|
1586
|
-
/* @__PURE__ */ (0,
|
|
1997
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "lg-nav__label", children: option.label })
|
|
1587
1998
|
] }, i))
|
|
1588
1999
|
}
|
|
1589
2000
|
);
|
|
@@ -1591,9 +2002,9 @@ var GlassSegmented = ({
|
|
|
1591
2002
|
GlassSegmented.displayName = "GlassSegmented";
|
|
1592
2003
|
|
|
1593
2004
|
// src/components/GlassSlider/GlassSlider.tsx
|
|
1594
|
-
var
|
|
1595
|
-
var
|
|
1596
|
-
var GlassSlider =
|
|
2005
|
+
var import_react12 = __toESM(require("react"));
|
|
2006
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2007
|
+
var GlassSlider = import_react12.default.forwardRef(
|
|
1597
2008
|
({
|
|
1598
2009
|
value = 0,
|
|
1599
2010
|
min = 0,
|
|
@@ -1612,22 +2023,23 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1612
2023
|
disabled,
|
|
1613
2024
|
...rest
|
|
1614
2025
|
}, forwardedRef) => {
|
|
1615
|
-
const rootRef = (0,
|
|
1616
|
-
const inputRef = (0,
|
|
1617
|
-
const thumbRef = (0,
|
|
1618
|
-
const faceRef = (0,
|
|
1619
|
-
const blockRef = (0,
|
|
1620
|
-
(0,
|
|
1621
|
-
(0,
|
|
2026
|
+
const rootRef = (0, import_react12.useRef)(null);
|
|
2027
|
+
const inputRef = (0, import_react12.useRef)(null);
|
|
2028
|
+
const thumbRef = (0, import_react12.useRef)(null);
|
|
2029
|
+
const faceRef = (0, import_react12.useRef)(null);
|
|
2030
|
+
const blockRef = (0, import_react12.useRef)(null);
|
|
2031
|
+
const pastRef = (0, import_react12.useRef)(0);
|
|
2032
|
+
(0, import_react12.useImperativeHandle)(forwardedRef, () => inputRef.current);
|
|
2033
|
+
(0, import_react12.useEffect)(() => {
|
|
1622
2034
|
const input2 = inputRef.current;
|
|
1623
2035
|
const root = rootRef.current;
|
|
1624
2036
|
const setValue = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value").set;
|
|
1625
2037
|
let drag = null;
|
|
1626
2038
|
const update = (clientX) => {
|
|
1627
2039
|
if (!drag || max <= min) return;
|
|
1628
|
-
const
|
|
1629
|
-
const
|
|
1630
|
-
|
|
2040
|
+
const raw = drag.from + (clientX - drag.x) / drag.travel;
|
|
2041
|
+
const fraction = clamp(raw, 0, 1);
|
|
2042
|
+
pastRef.current = (raw - fraction) * drag.travel;
|
|
1631
2043
|
let next = min + fraction * (max - min);
|
|
1632
2044
|
const increment = Number(step2);
|
|
1633
2045
|
if (step2 !== "any" && Number.isFinite(increment) && increment > 0) {
|
|
@@ -1646,13 +2058,11 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1646
2058
|
if (event.pointerType !== "touch") input2.focus({ preventScroll: true });
|
|
1647
2059
|
const box = root.getBoundingClientRect();
|
|
1648
2060
|
const inset = showThumb ? 19 * box.width / root.offsetWidth : 0;
|
|
1649
|
-
const
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
drag = { id: event.pointerId, left: box.left, width: box.width, offset };
|
|
2061
|
+
const from = max > min ? clamp((input2.valueAsNumber - min) / (max - min), 0, 1) : 0;
|
|
2062
|
+
drag = { id: event.pointerId, x: event.clientX, from, travel: Math.max(1, box.width - inset * 2) };
|
|
2063
|
+
pastRef.current = 0;
|
|
1653
2064
|
root.dataset.dragging = "";
|
|
1654
2065
|
root.setPointerCapture(event.pointerId);
|
|
1655
|
-
update(event.clientX);
|
|
1656
2066
|
};
|
|
1657
2067
|
const move = (event) => {
|
|
1658
2068
|
if (event.pointerId !== drag?.id) return;
|
|
@@ -1663,6 +2073,7 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1663
2073
|
if (!drag) return;
|
|
1664
2074
|
const id = drag.id;
|
|
1665
2075
|
drag = null;
|
|
2076
|
+
pastRef.current = 0;
|
|
1666
2077
|
delete root.dataset.dragging;
|
|
1667
2078
|
if (root.hasPointerCapture(id)) root.releasePointerCapture(id);
|
|
1668
2079
|
};
|
|
@@ -1671,6 +2082,7 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1671
2082
|
update(event.clientX);
|
|
1672
2083
|
release();
|
|
1673
2084
|
};
|
|
2085
|
+
const unguard = guardSelection(root);
|
|
1674
2086
|
root.addEventListener("pointerdown", down);
|
|
1675
2087
|
root.addEventListener("pointermove", move);
|
|
1676
2088
|
root.addEventListener("pointerup", up);
|
|
@@ -1679,6 +2091,7 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1679
2091
|
window.addEventListener("blur", release);
|
|
1680
2092
|
return () => {
|
|
1681
2093
|
release();
|
|
2094
|
+
unguard();
|
|
1682
2095
|
root.removeEventListener("pointerdown", down);
|
|
1683
2096
|
root.removeEventListener("pointermove", move);
|
|
1684
2097
|
root.removeEventListener("pointerup", up);
|
|
@@ -1688,8 +2101,8 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1688
2101
|
};
|
|
1689
2102
|
}, [min, max, step2, showThumb]);
|
|
1690
2103
|
const strength = Math.max(1, Math.min(10, intensity)) / 5;
|
|
1691
|
-
const [mirrored, setMirrored] =
|
|
1692
|
-
(0,
|
|
2104
|
+
const [mirrored, setMirrored] = import_react12.default.useState(false);
|
|
2105
|
+
(0, import_react12.useEffect)(() => setMirrored(!canRefractBackdrop()), []);
|
|
1693
2106
|
const progress = max > min ? clamp((Number(value) - min) / (max - min), 0, 1) : 0;
|
|
1694
2107
|
useRefraction(
|
|
1695
2108
|
thumbRef,
|
|
@@ -1699,18 +2112,20 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1699
2112
|
() => parseFloat(rootRef.current?.style.getPropertyValue("--lg-lift") || "0") > 0.01
|
|
1700
2113
|
);
|
|
1701
2114
|
useRefraction(blockRef, { kind: "surface", strength }, !showThumb);
|
|
1702
|
-
(0,
|
|
2115
|
+
(0, import_react12.useEffect)(() => {
|
|
1703
2116
|
if (!showThumb) return;
|
|
1704
2117
|
const input2 = inputRef.current;
|
|
1705
2118
|
const thumb = thumbRef.current;
|
|
1706
2119
|
const face = faceRef.current;
|
|
1707
2120
|
const root = rootRef.current;
|
|
1708
|
-
const v = { lift: 0, stretch: 0 };
|
|
2121
|
+
const v = { lift: 0, stretch: 0, over: 0 };
|
|
1709
2122
|
const paint = () => {
|
|
1710
2123
|
const s = 0.655 + 0.345 * v.lift;
|
|
1711
|
-
|
|
2124
|
+
const pull = Math.abs(v.over) / 58 * 0.6;
|
|
2125
|
+
thumb.style.scale = `${s * (1 + v.stretch + pull)} ${s * (1 - v.stretch * 0.5 - pull * 0.4)}`;
|
|
1712
2126
|
face.style.opacity = String(1 - clamp(v.lift, 0, 1) * 0.92);
|
|
1713
2127
|
root.style.setProperty("--lg-lift", String(clamp(v.lift, 0, 1)));
|
|
2128
|
+
root.style.setProperty("--lg-over", `${v.over.toFixed(2)}px`);
|
|
1714
2129
|
if (v.lift < 0.01 && lift.target === 0) delete root.dataset.lifted;
|
|
1715
2130
|
};
|
|
1716
2131
|
const lift = createSpring(0, SPRINGS.lift, (x) => {
|
|
@@ -1721,6 +2136,10 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1721
2136
|
v.stretch = x;
|
|
1722
2137
|
paint();
|
|
1723
2138
|
});
|
|
2139
|
+
const over = createSpring(0, SPRINGS.release, (x) => {
|
|
2140
|
+
v.over = x;
|
|
2141
|
+
paint();
|
|
2142
|
+
});
|
|
1724
2143
|
paint();
|
|
1725
2144
|
let lastX = 0;
|
|
1726
2145
|
let lastT = 0;
|
|
@@ -1741,6 +2160,8 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1741
2160
|
lastT = event.timeStamp;
|
|
1742
2161
|
stretch.tune(SPRINGS.drag);
|
|
1743
2162
|
stretch.set(clamp(speed * 0.015, 0, 0.035));
|
|
2163
|
+
over.tune(SPRINGS.drag);
|
|
2164
|
+
over.set(rubberband(pastRef.current, 12, 0.5));
|
|
1744
2165
|
};
|
|
1745
2166
|
const up = () => {
|
|
1746
2167
|
if (lift.target === 0) return;
|
|
@@ -1748,6 +2169,8 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1748
2169
|
lift.set(0);
|
|
1749
2170
|
stretch.tune(SPRINGS.release);
|
|
1750
2171
|
stretch.set(0);
|
|
2172
|
+
over.tune(SPRINGS.release);
|
|
2173
|
+
over.set(0);
|
|
1751
2174
|
};
|
|
1752
2175
|
root.addEventListener("pointerdown", down);
|
|
1753
2176
|
window.addEventListener("pointermove", move);
|
|
@@ -1758,6 +2181,7 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1758
2181
|
return () => {
|
|
1759
2182
|
lift.stop();
|
|
1760
2183
|
stretch.stop();
|
|
2184
|
+
over.stop();
|
|
1761
2185
|
root.removeEventListener("pointerdown", down);
|
|
1762
2186
|
window.removeEventListener("pointermove", move);
|
|
1763
2187
|
window.removeEventListener("pointerup", up);
|
|
@@ -1767,7 +2191,7 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1767
2191
|
delete root.dataset.lifted;
|
|
1768
2192
|
};
|
|
1769
2193
|
}, [showThumb]);
|
|
1770
|
-
(0,
|
|
2194
|
+
(0, import_react12.useEffect)(() => {
|
|
1771
2195
|
if (showThumb) return;
|
|
1772
2196
|
const input2 = inputRef.current;
|
|
1773
2197
|
const block = blockRef.current;
|
|
@@ -1791,17 +2215,15 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1791
2215
|
let active2 = null;
|
|
1792
2216
|
const down = (event) => {
|
|
1793
2217
|
if (input2.disabled || !event.isPrimary || event.button !== 0) return;
|
|
1794
|
-
active2 = { id: event.pointerId
|
|
2218
|
+
active2 = { id: event.pointerId };
|
|
1795
2219
|
swell.tune(SPRINGS.press);
|
|
1796
2220
|
swell.set(1);
|
|
1797
2221
|
haptic();
|
|
1798
2222
|
};
|
|
1799
2223
|
const move = (event) => {
|
|
1800
2224
|
if (event.pointerId !== active2?.id) return;
|
|
1801
|
-
const { box } = active2;
|
|
1802
|
-
const past = event.clientX < box.left ? event.clientX - box.left : event.clientX > box.right ? event.clientX - box.right : 0;
|
|
1803
2225
|
over.tune(SPRINGS.drag);
|
|
1804
|
-
over.set(rubberband(
|
|
2226
|
+
over.set(rubberband(pastRef.current, 26, 0.6));
|
|
1805
2227
|
};
|
|
1806
2228
|
const reset = () => {
|
|
1807
2229
|
if (!active2) return;
|
|
@@ -1831,7 +2253,7 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1831
2253
|
window.removeEventListener("pointercancel", up);
|
|
1832
2254
|
};
|
|
1833
2255
|
}, [showThumb]);
|
|
1834
|
-
const input = /* @__PURE__ */ (0,
|
|
2256
|
+
const input = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1835
2257
|
"input",
|
|
1836
2258
|
{
|
|
1837
2259
|
ref: inputRef,
|
|
@@ -1851,7 +2273,7 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1851
2273
|
);
|
|
1852
2274
|
const vars = { "--lg-progress": progress, ...tint ? { "--lg-slider-fill": tint } : {}, ...style };
|
|
1853
2275
|
if (!showThumb) {
|
|
1854
|
-
return /* @__PURE__ */ (0,
|
|
2276
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1855
2277
|
"div",
|
|
1856
2278
|
{
|
|
1857
2279
|
ref: rootRef,
|
|
@@ -1859,16 +2281,16 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1859
2281
|
"data-liquid-glass": "",
|
|
1860
2282
|
style: vars,
|
|
1861
2283
|
children: [
|
|
1862
|
-
/* @__PURE__ */ (0,
|
|
1863
|
-
/* @__PURE__ */ (0,
|
|
1864
|
-
icon && /* @__PURE__ */ (0,
|
|
1865
|
-
label2 && /* @__PURE__ */ (0,
|
|
1866
|
-
/* @__PURE__ */ (0,
|
|
2284
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { ref: blockRef, className: "lg-glass lg-slider__block", children: [
|
|
2285
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { className: "lg-slider__block-content", "aria-hidden": "true", children: [
|
|
2286
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__icon", children: icon }),
|
|
2287
|
+
label2 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__label", children: label2 }),
|
|
2288
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__value", children: Math.round(Number(value)) })
|
|
1867
2289
|
] }),
|
|
1868
|
-
/* @__PURE__ */ (0,
|
|
1869
|
-
icon && /* @__PURE__ */ (0,
|
|
1870
|
-
label2 && /* @__PURE__ */ (0,
|
|
1871
|
-
/* @__PURE__ */ (0,
|
|
2290
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__block-fill", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { className: "lg-slider__block-content lg-slider__block-content--lit", children: [
|
|
2291
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__icon", children: icon }),
|
|
2292
|
+
label2 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__label", children: label2 }),
|
|
2293
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__value", children: Math.round(Number(value)) })
|
|
1872
2294
|
] }) })
|
|
1873
2295
|
] }),
|
|
1874
2296
|
input
|
|
@@ -1876,7 +2298,7 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1876
2298
|
}
|
|
1877
2299
|
);
|
|
1878
2300
|
}
|
|
1879
|
-
return /* @__PURE__ */ (0,
|
|
2301
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1880
2302
|
"div",
|
|
1881
2303
|
{
|
|
1882
2304
|
ref: rootRef,
|
|
@@ -1885,8 +2307,8 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1885
2307
|
"data-mirror": mirrored ? "" : void 0,
|
|
1886
2308
|
style: vars,
|
|
1887
2309
|
children: [
|
|
1888
|
-
/* @__PURE__ */ (0,
|
|
1889
|
-
/* @__PURE__ */ (0,
|
|
2310
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__rail", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__fill" }) }),
|
|
2311
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__thumb-slot", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { ref: thumbRef, className: "lg-glass lg-slider__thumb", "data-lg-mirror-bare": "", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { ref: faceRef, className: "lg-slider__face" }) }) }),
|
|
1890
2312
|
input
|
|
1891
2313
|
]
|
|
1892
2314
|
}
|
|
@@ -1896,22 +2318,22 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1896
2318
|
GlassSlider.displayName = "GlassSlider";
|
|
1897
2319
|
|
|
1898
2320
|
// src/components/GlassSwitch/GlassSwitch.tsx
|
|
1899
|
-
var
|
|
1900
|
-
var
|
|
2321
|
+
var import_react13 = __toESM(require("react"));
|
|
2322
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1901
2323
|
var SETTLE = springFrom(0.36, 0.68);
|
|
1902
2324
|
var REST = 0.655;
|
|
1903
2325
|
var TRAVEL = 22;
|
|
1904
|
-
var GlassSwitch =
|
|
2326
|
+
var GlassSwitch = import_react13.default.forwardRef(
|
|
1905
2327
|
({ checked: checkedProp, defaultChecked = false, onChange, tint, intensity = 5, className, style, disabled, ...rest }, forwardedRef) => {
|
|
1906
|
-
const ref = (0,
|
|
1907
|
-
const thumbRef = (0,
|
|
1908
|
-
const fillRef = (0,
|
|
1909
|
-
const faceRef = (0,
|
|
1910
|
-
(0,
|
|
1911
|
-
const [inner, setInner] = (0,
|
|
2328
|
+
const ref = (0, import_react13.useRef)(null);
|
|
2329
|
+
const thumbRef = (0, import_react13.useRef)(null);
|
|
2330
|
+
const fillRef = (0, import_react13.useRef)(null);
|
|
2331
|
+
const faceRef = (0, import_react13.useRef)(null);
|
|
2332
|
+
(0, import_react13.useImperativeHandle)(forwardedRef, () => ref.current);
|
|
2333
|
+
const [inner, setInner] = (0, import_react13.useState)(defaultChecked);
|
|
1912
2334
|
const controlled = checkedProp !== void 0;
|
|
1913
2335
|
const checked = controlled ? checkedProp : inner;
|
|
1914
|
-
const latest = (0,
|
|
2336
|
+
const latest = (0, import_react13.useRef)({ checked, set: (_) => {
|
|
1915
2337
|
}, disabled });
|
|
1916
2338
|
latest.current = {
|
|
1917
2339
|
checked,
|
|
@@ -1921,15 +2343,15 @@ var GlassSwitch = import_react12.default.forwardRef(
|
|
|
1921
2343
|
onChange?.(next);
|
|
1922
2344
|
}
|
|
1923
2345
|
};
|
|
1924
|
-
const sync = (0,
|
|
2346
|
+
const sync = (0, import_react13.useRef)(null);
|
|
1925
2347
|
useRefraction(
|
|
1926
2348
|
thumbRef,
|
|
1927
|
-
{ kind: "lens", zoom: 1, dispersion: 0.5, strength: Math.max(1, Math.min(10, intensity)) / 5 },
|
|
2349
|
+
{ kind: "lens", zoom: 0.72, zoomX: 1, dispersion: 0.5, copy: true, strength: Math.max(1, Math.min(10, intensity)) / 5 },
|
|
1928
2350
|
true,
|
|
1929
2351
|
ref,
|
|
1930
2352
|
() => parseFloat(ref.current?.style.getPropertyValue("--lg-lift") || "0") > 0.01
|
|
1931
2353
|
);
|
|
1932
|
-
(0,
|
|
2354
|
+
(0, import_react13.useEffect)(() => {
|
|
1933
2355
|
const el2 = ref.current;
|
|
1934
2356
|
const thumb = thumbRef.current;
|
|
1935
2357
|
const fill = fillRef.current;
|
|
@@ -1940,6 +2362,8 @@ var GlassSwitch = import_react12.default.forwardRef(
|
|
|
1940
2362
|
const sy = s * (1 - v.stretch * 0.5);
|
|
1941
2363
|
thumb.style.transform = `translate(${v.x * TRAVEL}px, -50%) scale(${sx}, ${sy})`;
|
|
1942
2364
|
const l = clamp(v.lift, 0, 1);
|
|
2365
|
+
el2.style.setProperty("--lg-knob-x", `${(21 + v.x * TRAVEL).toFixed(2)}px`);
|
|
2366
|
+
el2.style.setProperty("--lg-hole", `${(l > 0.01 ? 23 * sx : 0).toFixed(2)}px`);
|
|
1943
2367
|
el2.style.setProperty("--lg-lift", String(l));
|
|
1944
2368
|
el2.toggleAttribute("data-lifted", l > 0.01);
|
|
1945
2369
|
};
|
|
@@ -2029,6 +2453,7 @@ var GlassSwitch = import_react12.default.forwardRef(
|
|
|
2029
2453
|
latest.current.set(next);
|
|
2030
2454
|
sync.current?.(next);
|
|
2031
2455
|
};
|
|
2456
|
+
const unguard = guardSelection(el2);
|
|
2032
2457
|
el2.addEventListener("pointerdown", down);
|
|
2033
2458
|
el2.addEventListener("pointermove", move);
|
|
2034
2459
|
el2.addEventListener("pointerup", up);
|
|
@@ -2037,6 +2462,7 @@ var GlassSwitch = import_react12.default.forwardRef(
|
|
|
2037
2462
|
return () => {
|
|
2038
2463
|
clearTimeout(dropTimer);
|
|
2039
2464
|
[position, lift, color].forEach((s) => s.stop());
|
|
2465
|
+
unguard();
|
|
2040
2466
|
el2.removeEventListener("pointerdown", down);
|
|
2041
2467
|
el2.removeEventListener("pointermove", move);
|
|
2042
2468
|
el2.removeEventListener("pointerup", up);
|
|
@@ -2044,10 +2470,10 @@ var GlassSwitch = import_react12.default.forwardRef(
|
|
|
2044
2470
|
el2.removeEventListener("click", click);
|
|
2045
2471
|
};
|
|
2046
2472
|
}, []);
|
|
2047
|
-
(0,
|
|
2473
|
+
(0, import_react13.useEffect)(() => {
|
|
2048
2474
|
sync.current?.(checked);
|
|
2049
2475
|
}, [checked]);
|
|
2050
|
-
return /* @__PURE__ */ (0,
|
|
2476
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
2051
2477
|
"button",
|
|
2052
2478
|
{
|
|
2053
2479
|
ref,
|
|
@@ -2064,8 +2490,9 @@ var GlassSwitch = import_react12.default.forwardRef(
|
|
|
2064
2490
|
rest.onKeyDown?.(event);
|
|
2065
2491
|
},
|
|
2066
2492
|
children: [
|
|
2067
|
-
/* @__PURE__ */ (0,
|
|
2068
|
-
/* @__PURE__ */ (0,
|
|
2493
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "lg-switch__track", "aria-hidden": "true" }),
|
|
2494
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { ref: fillRef, className: "lg-switch__fill", "aria-hidden": "true" }),
|
|
2495
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { ref: thumbRef, className: "lg-glass lg-switch__thumb", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { ref: faceRef, className: "lg-switch__face" }) })
|
|
2069
2496
|
]
|
|
2070
2497
|
}
|
|
2071
2498
|
);
|
|
@@ -2074,29 +2501,29 @@ var GlassSwitch = import_react12.default.forwardRef(
|
|
|
2074
2501
|
GlassSwitch.displayName = "GlassSwitch";
|
|
2075
2502
|
|
|
2076
2503
|
// src/filters/LiquidGlassFilter.tsx
|
|
2077
|
-
var
|
|
2078
|
-
var
|
|
2079
|
-
var GlassFilterContext = (0,
|
|
2504
|
+
var import_react14 = require("react");
|
|
2505
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2506
|
+
var GlassFilterContext = (0, import_react14.createContext)(false);
|
|
2080
2507
|
function LiquidGlassFilter({ children }) {
|
|
2081
|
-
return /* @__PURE__ */ (0,
|
|
2082
|
-
/* @__PURE__ */ (0,
|
|
2508
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(GlassFilterContext.Provider, { value: true, children: [
|
|
2509
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(GlassFilterSVG, {}),
|
|
2083
2510
|
children
|
|
2084
2511
|
] });
|
|
2085
2512
|
}
|
|
2086
2513
|
function GlassFilterSVG() {
|
|
2087
|
-
return /* @__PURE__ */ (0,
|
|
2514
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2088
2515
|
"svg",
|
|
2089
2516
|
{
|
|
2090
2517
|
width: "0",
|
|
2091
2518
|
height: "0",
|
|
2092
2519
|
style: { position: "absolute", pointerEvents: "none" },
|
|
2093
2520
|
"aria-hidden": "true",
|
|
2094
|
-
children: /* @__PURE__ */ (0,
|
|
2521
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("defs", { children: Array.from({ length: 10 }, (_, i) => {
|
|
2095
2522
|
const level = i + 1;
|
|
2096
2523
|
const scale = level * 2;
|
|
2097
2524
|
const freq1 = 0.012 + level * 1e-3;
|
|
2098
2525
|
const freq2 = 0.01 + level * 8e-4;
|
|
2099
|
-
return /* @__PURE__ */ (0,
|
|
2526
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2100
2527
|
"filter",
|
|
2101
2528
|
{
|
|
2102
2529
|
id: `liquid-glass-refract-${level}`,
|
|
@@ -2106,7 +2533,7 @@ function GlassFilterSVG() {
|
|
|
2106
2533
|
height: "120%",
|
|
2107
2534
|
colorInterpolationFilters: "sRGB",
|
|
2108
2535
|
children: [
|
|
2109
|
-
/* @__PURE__ */ (0,
|
|
2536
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2110
2537
|
"feTurbulence",
|
|
2111
2538
|
{
|
|
2112
2539
|
type: "fractalNoise",
|
|
@@ -2116,7 +2543,7 @@ function GlassFilterSVG() {
|
|
|
2116
2543
|
result: "noise"
|
|
2117
2544
|
}
|
|
2118
2545
|
),
|
|
2119
|
-
/* @__PURE__ */ (0,
|
|
2546
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2120
2547
|
"feDisplacementMap",
|
|
2121
2548
|
{
|
|
2122
2549
|
in: "SourceGraphic",
|
|
@@ -2136,7 +2563,7 @@ function GlassFilterSVG() {
|
|
|
2136
2563
|
}
|
|
2137
2564
|
|
|
2138
2565
|
// src/hooks/useGlassEffect.ts
|
|
2139
|
-
var
|
|
2566
|
+
var import_react15 = require("react");
|
|
2140
2567
|
function parseTintColor(tint) {
|
|
2141
2568
|
const defaults = { h: 0, s: 0, l: 100, a: 0.1 };
|
|
2142
2569
|
if (!tint) return defaults;
|
|
@@ -2188,7 +2615,7 @@ function useGlassEffect(options = {}) {
|
|
|
2188
2615
|
thickness,
|
|
2189
2616
|
blur
|
|
2190
2617
|
} = options;
|
|
2191
|
-
return (0,
|
|
2618
|
+
return (0, import_react15.useMemo)(() => {
|
|
2192
2619
|
const clampedIntensity = Math.max(1, Math.min(10, Math.round(intensity)));
|
|
2193
2620
|
const filterId = `liquid-glass-refract-${clampedIntensity}`;
|
|
2194
2621
|
const style = {
|
|
@@ -2213,21 +2640,21 @@ function useGlassEffect(options = {}) {
|
|
|
2213
2640
|
}
|
|
2214
2641
|
|
|
2215
2642
|
// src/hooks/useGlassAnimation.ts
|
|
2216
|
-
var
|
|
2643
|
+
var import_react16 = require("react");
|
|
2217
2644
|
function useGlassAnimation() {
|
|
2218
|
-
const [isHovered, setIsHovered] = (0,
|
|
2219
|
-
const [isPressed, setIsPressed] = (0,
|
|
2220
|
-
const [isFocused, setIsFocused] = (0,
|
|
2645
|
+
const [isHovered, setIsHovered] = (0, import_react16.useState)(false);
|
|
2646
|
+
const [isPressed, setIsPressed] = (0, import_react16.useState)(false);
|
|
2647
|
+
const [isFocused, setIsFocused] = (0, import_react16.useState)(false);
|
|
2221
2648
|
const handlers = {
|
|
2222
|
-
onPointerEnter: (0,
|
|
2223
|
-
onPointerLeave: (0,
|
|
2649
|
+
onPointerEnter: (0, import_react16.useCallback)(() => setIsHovered(true), []),
|
|
2650
|
+
onPointerLeave: (0, import_react16.useCallback)(() => {
|
|
2224
2651
|
setIsHovered(false);
|
|
2225
2652
|
setIsPressed(false);
|
|
2226
2653
|
}, []),
|
|
2227
|
-
onPointerDown: (0,
|
|
2228
|
-
onPointerUp: (0,
|
|
2229
|
-
onFocus: (0,
|
|
2230
|
-
onBlur: (0,
|
|
2654
|
+
onPointerDown: (0, import_react16.useCallback)(() => setIsPressed(true), []),
|
|
2655
|
+
onPointerUp: (0, import_react16.useCallback)(() => setIsPressed(false), []),
|
|
2656
|
+
onFocus: (0, import_react16.useCallback)(() => setIsFocused(true), []),
|
|
2657
|
+
onBlur: (0, import_react16.useCallback)(() => setIsFocused(false), [])
|
|
2231
2658
|
};
|
|
2232
2659
|
return { isHovered, isPressed, isFocused, handlers };
|
|
2233
2660
|
}
|
|
@@ -2236,6 +2663,7 @@ function useGlassAnimation() {
|
|
|
2236
2663
|
GlassButton,
|
|
2237
2664
|
GlassCard,
|
|
2238
2665
|
GlassInput,
|
|
2666
|
+
GlassMenu,
|
|
2239
2667
|
GlassNav,
|
|
2240
2668
|
GlassSegmented,
|
|
2241
2669
|
GlassSheet,
|