@zakisheriff/liquid-glass 0.2.7 → 0.3.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/LICENSE +21 -0
- package/README.md +46 -11
- package/dist/index.css +210 -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 +618 -189
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +605 -177
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
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,139 @@ 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
|
+
const top = sheet.offsetTop;
|
|
1157
|
+
hidden = layer.clientHeight - top + 24;
|
|
1158
|
+
medium = Math.max(0, layer.clientHeight * 0.5 - top);
|
|
1159
|
+
stops = wanted.length ? wanted.map((d) => d === "large" ? 0 : medium).sort((x, y) => x - y) : [0];
|
|
1160
|
+
rest = wanted.includes("medium") ? medium : stops[0];
|
|
1161
|
+
};
|
|
1162
|
+
measure();
|
|
1163
|
+
const paint = (y) => {
|
|
1047
1164
|
sheet.style.transform = `translateY(${y}px)`;
|
|
1048
|
-
|
|
1165
|
+
const dim = wanted.includes("medium") && medium > 0 ? clamp(1 - y / medium, 0, 1) : clamp(1 - y / Math.max(1, height), 0, 1);
|
|
1166
|
+
scrim.style.opacity = String(dim);
|
|
1167
|
+
const raised = y <= 1;
|
|
1168
|
+
if (wanted.length && sheet.hasAttribute("data-raised") !== raised) sheet.toggleAttribute("data-raised", raised);
|
|
1049
1169
|
};
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1170
|
+
let closing = false;
|
|
1171
|
+
const position = createSpring(hidden, OPEN, (y) => {
|
|
1172
|
+
paint(y);
|
|
1173
|
+
if (closing && y >= hidden - 1) setMounted(false);
|
|
1053
1174
|
});
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
set(
|
|
1057
|
-
|
|
1058
|
-
|
|
1175
|
+
const go = (y, feel) => {
|
|
1176
|
+
position.tune(feel);
|
|
1177
|
+
position.set(y);
|
|
1178
|
+
};
|
|
1179
|
+
api.current = {
|
|
1180
|
+
close() {
|
|
1181
|
+
closing = true;
|
|
1182
|
+
go(hidden, CLOSE);
|
|
1059
1183
|
}
|
|
1060
1184
|
};
|
|
1061
|
-
paint(
|
|
1185
|
+
paint(hidden);
|
|
1062
1186
|
requestAnimationFrame(() => {
|
|
1063
|
-
|
|
1064
|
-
|
|
1187
|
+
measure();
|
|
1188
|
+
position.set(hidden, true);
|
|
1189
|
+
if (open) go(rest, OPEN);
|
|
1065
1190
|
});
|
|
1066
1191
|
let gesture = null;
|
|
1067
1192
|
const down = (event) => {
|
|
1068
|
-
if (event.defaultPrevented) return;
|
|
1193
|
+
if (event.defaultPrevented || closing) return;
|
|
1069
1194
|
const target = event.target;
|
|
1070
|
-
|
|
1195
|
+
const raised = position.value <= 1;
|
|
1196
|
+
if (raised && !target.closest(".lg-sheet__grabber-zone") && sheet.scrollTop > 0) return;
|
|
1071
1197
|
if (target.closest('input, textarea, button, a, [role="slider"], [role="switch"]')) return;
|
|
1072
|
-
|
|
1198
|
+
position.stop();
|
|
1199
|
+
gesture = { id: event.pointerId, y: event.clientY, from: position.value, t: event.timeStamp, v: 0, last: position.value };
|
|
1073
1200
|
sheet.setPointerCapture(event.pointerId);
|
|
1074
1201
|
};
|
|
1075
1202
|
const move = (event) => {
|
|
1076
1203
|
if (event.pointerId !== gesture?.id) return;
|
|
1077
|
-
const
|
|
1204
|
+
const raw = gesture.from + event.clientY - gesture.y;
|
|
1205
|
+
const y = raw < 0 ? rubberband(raw, height, 0.3) : raw;
|
|
1078
1206
|
const dt = Math.max(1, event.timeStamp - gesture.t);
|
|
1079
|
-
gesture.v = (
|
|
1207
|
+
gesture.v = gesture.v * 0.2 + (y - gesture.last) / dt * 0.8;
|
|
1080
1208
|
gesture.t = event.timeStamp;
|
|
1081
|
-
|
|
1082
|
-
|
|
1209
|
+
gesture.last = y;
|
|
1210
|
+
position.set(y, true);
|
|
1211
|
+
paint(y);
|
|
1083
1212
|
};
|
|
1084
1213
|
const up = (event) => {
|
|
1085
1214
|
if (event.pointerId !== gesture?.id) return;
|
|
1086
|
-
const
|
|
1215
|
+
const { v, last: last2 } = gesture;
|
|
1087
1216
|
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);
|
|
1217
|
+
const projected = last2 + v * 180;
|
|
1218
|
+
const lowest = stops[stops.length - 1];
|
|
1219
|
+
if (projected > lowest + (hidden - lowest) * 0.45 || v > 0.9 && last2 >= lowest - 4) {
|
|
1220
|
+
closing = true;
|
|
1221
|
+
go(hidden, CLOSE);
|
|
1097
1222
|
closeRef.current?.();
|
|
1098
|
-
|
|
1099
|
-
settle.set(0);
|
|
1223
|
+
return;
|
|
1100
1224
|
}
|
|
1225
|
+
const target = stops.reduce((best, stop) => Math.abs(stop - projected) < Math.abs(best - projected) ? stop : best, stops[0]);
|
|
1226
|
+
go(target, SNAP);
|
|
1101
1227
|
};
|
|
1102
1228
|
const key = (event) => {
|
|
1103
1229
|
if (event.key === "Escape") closeRef.current?.();
|
|
1104
1230
|
};
|
|
1231
|
+
const resize = () => {
|
|
1232
|
+
const at = position.target;
|
|
1233
|
+
const was = stops.indexOf(at);
|
|
1234
|
+
measure();
|
|
1235
|
+
if (!closing) go(was >= 0 ? stops[Math.min(was, stops.length - 1)] : rest, SNAP);
|
|
1236
|
+
};
|
|
1237
|
+
const observer = new ResizeObserver(resize);
|
|
1238
|
+
observer.observe(layer);
|
|
1105
1239
|
sheet.addEventListener("pointerdown", down);
|
|
1106
1240
|
sheet.addEventListener("pointermove", move);
|
|
1107
1241
|
sheet.addEventListener("pointerup", up);
|
|
1108
1242
|
sheet.addEventListener("pointercancel", up);
|
|
1109
1243
|
window.addEventListener("keydown", key);
|
|
1110
1244
|
const overflow = document.body.style.overflow;
|
|
1111
|
-
document.body.style.overflow = "hidden";
|
|
1245
|
+
if (!container2) document.body.style.overflow = "hidden";
|
|
1112
1246
|
sheet.focus({ preventScroll: true });
|
|
1113
1247
|
return () => {
|
|
1114
|
-
|
|
1115
|
-
|
|
1248
|
+
position.stop();
|
|
1249
|
+
api.current = null;
|
|
1250
|
+
observer.disconnect();
|
|
1116
1251
|
sheet.removeEventListener("pointerdown", down);
|
|
1117
1252
|
sheet.removeEventListener("pointermove", move);
|
|
1118
1253
|
sheet.removeEventListener("pointerup", up);
|
|
1119
1254
|
sheet.removeEventListener("pointercancel", up);
|
|
1120
1255
|
window.removeEventListener("keydown", key);
|
|
1121
|
-
document.body.style.overflow = overflow;
|
|
1256
|
+
if (!container2) document.body.style.overflow = overflow;
|
|
1122
1257
|
};
|
|
1123
|
-
}, [mounted]);
|
|
1258
|
+
}, [mounted, container2, stopsKey]);
|
|
1124
1259
|
if (!mounted || typeof document === "undefined") return null;
|
|
1125
1260
|
return (0, import_react_dom.createPortal)(
|
|
1126
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "lg-sheet-layer", "data-liquid-glass": "", children: [
|
|
1261
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "lg-sheet-layer", "data-liquid-glass": "", style: container2 ? { position: "absolute" } : void 0, children: [
|
|
1127
1262
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { ref: scrimRef, className: "lg-sheet__scrim", onClick: () => onClose?.(), "aria-hidden": "true" }),
|
|
1128
1263
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1129
1264
|
"div",
|
|
@@ -1133,7 +1268,7 @@ var GlassSheet = ({ open, onClose, intensity = 5, tint, children, "aria-label":
|
|
|
1133
1268
|
"aria-modal": "true",
|
|
1134
1269
|
"aria-label": ariaLabel,
|
|
1135
1270
|
tabIndex: -1,
|
|
1136
|
-
className: "lg-glass lg-glass--host lg-sheet",
|
|
1271
|
+
className: ["lg-glass", "lg-glass--host", "lg-sheet", detents?.length ? "lg-sheet--detents" : ""].filter(Boolean).join(" "),
|
|
1137
1272
|
style: tint ? { "--lg-host-tint": tint } : void 0,
|
|
1138
1273
|
children: [
|
|
1139
1274
|
/* @__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 +1277,263 @@ var GlassSheet = ({ open, onClose, intensity = 5, tint, children, "aria-label":
|
|
|
1142
1277
|
}
|
|
1143
1278
|
)
|
|
1144
1279
|
] }),
|
|
1145
|
-
document.body
|
|
1280
|
+
container2 ?? document.body
|
|
1146
1281
|
);
|
|
1147
1282
|
};
|
|
1148
1283
|
GlassSheet.displayName = "GlassSheet";
|
|
1149
1284
|
|
|
1285
|
+
// src/components/GlassMenu/GlassMenu.tsx
|
|
1286
|
+
var import_react7 = require("react");
|
|
1287
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1288
|
+
var OPEN2 = springFrom(0.36, 0.74);
|
|
1289
|
+
var CLOSE2 = springFrom(0.34, 0.9);
|
|
1290
|
+
var FADE = springFrom(0.24, 1);
|
|
1291
|
+
var FADE_OUT = springFrom(0.14, 1);
|
|
1292
|
+
var JELLY = springFrom(0.42, 0.4);
|
|
1293
|
+
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" }) });
|
|
1294
|
+
var GlassMenu = ({
|
|
1295
|
+
icon,
|
|
1296
|
+
items,
|
|
1297
|
+
"aria-label": ariaLabel,
|
|
1298
|
+
align = "end",
|
|
1299
|
+
size = "md",
|
|
1300
|
+
width = 230,
|
|
1301
|
+
check,
|
|
1302
|
+
className
|
|
1303
|
+
}) => {
|
|
1304
|
+
const [open, setOpen] = (0, import_react7.useState)(false);
|
|
1305
|
+
const [mounted, setMounted] = (0, import_react7.useState)(false);
|
|
1306
|
+
const anchorRef = (0, import_react7.useRef)(null);
|
|
1307
|
+
const triggerRef = (0, import_react7.useRef)(null);
|
|
1308
|
+
const surfaceRef = (0, import_react7.useRef)(null);
|
|
1309
|
+
const panelRef = (0, import_react7.useRef)(null);
|
|
1310
|
+
const contentRef = (0, import_react7.useRef)(null);
|
|
1311
|
+
const spring = (0, import_react7.useRef)(null);
|
|
1312
|
+
const itemsRef = (0, import_react7.useRef)(items);
|
|
1313
|
+
itemsRef.current = items;
|
|
1314
|
+
usePress(surfaceRef, { grow: 0.035, lean: 6, stretch: 0.1, disabled: !mounted });
|
|
1315
|
+
(0, import_react7.useEffect)(() => {
|
|
1316
|
+
if (open) setMounted(true);
|
|
1317
|
+
else if (spring.current) {
|
|
1318
|
+
spring.current.tune(CLOSE2);
|
|
1319
|
+
spring.current.set(0);
|
|
1320
|
+
}
|
|
1321
|
+
}, [open]);
|
|
1322
|
+
(0, import_react7.useLayoutEffect)(() => {
|
|
1323
|
+
if (!mounted) return;
|
|
1324
|
+
const surface = surfaceRef.current;
|
|
1325
|
+
const panel = panelRef.current;
|
|
1326
|
+
const content = contentRef.current;
|
|
1327
|
+
const trigger = triggerRef.current;
|
|
1328
|
+
const w = trigger.offsetWidth;
|
|
1329
|
+
const h = trigger.offsetHeight;
|
|
1330
|
+
const W = Math.max(w, Math.min(width, window.innerWidth - 24));
|
|
1331
|
+
content.style.width = `${W}px`;
|
|
1332
|
+
const H = Math.max(h, content.offsetHeight);
|
|
1333
|
+
surface.style.width = `${W}px`;
|
|
1334
|
+
surface.style.height = `${H}px`;
|
|
1335
|
+
const end = align === "end";
|
|
1336
|
+
const box = { cw: w, ch: h, r: h / 2 };
|
|
1337
|
+
let scaleNow = 1;
|
|
1338
|
+
const clipContent = () => {
|
|
1339
|
+
const k = scaleNow;
|
|
1340
|
+
const right = Math.max(0, W - box.cw / k);
|
|
1341
|
+
const bottom = Math.max(0, H - box.ch / k);
|
|
1342
|
+
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)`;
|
|
1343
|
+
};
|
|
1344
|
+
const shape = (p) => {
|
|
1345
|
+
const cw = Math.max(1, w + (W - w) * p);
|
|
1346
|
+
const ch = Math.max(1, h + (H - h) * p);
|
|
1347
|
+
const sx = cw / W;
|
|
1348
|
+
const sy = ch / H;
|
|
1349
|
+
panel.style.transform = `scale(${sx}, ${sy})`;
|
|
1350
|
+
const land = clamp((p - 0.5) / 0.5, 0, 1);
|
|
1351
|
+
const r = Math.min(cw, ch) / 2 * (1 - land) + 24 * land;
|
|
1352
|
+
panel.style.borderRadius = `${r / sx}px / ${r / sy}px`;
|
|
1353
|
+
box.cw = cw;
|
|
1354
|
+
box.ch = ch;
|
|
1355
|
+
box.r = r;
|
|
1356
|
+
clipContent();
|
|
1357
|
+
const k = clamp(p / 0.35, 0, 1);
|
|
1358
|
+
panel.style.opacity = String(k);
|
|
1359
|
+
trigger.style.opacity = String(1 - k);
|
|
1360
|
+
};
|
|
1361
|
+
const reveal = (q) => {
|
|
1362
|
+
const t = clamp(q, 0, 1);
|
|
1363
|
+
const blur = 9 * (1 - t) ** 2.5;
|
|
1364
|
+
content.style.opacity = String(t);
|
|
1365
|
+
scaleNow = t < 0.999 ? 0.82 + 0.18 * t : 1;
|
|
1366
|
+
content.style.scale = scaleNow === 1 ? "" : String(scaleNow);
|
|
1367
|
+
clipContent();
|
|
1368
|
+
content.style.filter = blur > 0.05 ? `blur(${blur.toFixed(2)}px)` : "none";
|
|
1369
|
+
};
|
|
1370
|
+
shape(0);
|
|
1371
|
+
reveal(0);
|
|
1372
|
+
const s = createSpring(0, OPEN2, (p) => {
|
|
1373
|
+
shape(p);
|
|
1374
|
+
if (p <= 0.02 && s.target === 0) {
|
|
1375
|
+
trigger.style.opacity = "";
|
|
1376
|
+
const jelly = createSpring(0.07, JELLY, (v) => {
|
|
1377
|
+
trigger.style.scale = Math.abs(v) < 5e-4 ? "" : `${1 - v} ${1 + v}`;
|
|
1378
|
+
});
|
|
1379
|
+
jelly.set(0);
|
|
1380
|
+
setMounted(false);
|
|
1381
|
+
}
|
|
1382
|
+
});
|
|
1383
|
+
const fade = createSpring(0, FADE, reveal);
|
|
1384
|
+
spring.current = {
|
|
1385
|
+
...s,
|
|
1386
|
+
tune: s.tune,
|
|
1387
|
+
set(target, instant) {
|
|
1388
|
+
fade.tune(target ? FADE : FADE_OUT);
|
|
1389
|
+
fade.set(target, instant);
|
|
1390
|
+
s.set(target, instant);
|
|
1391
|
+
}
|
|
1392
|
+
};
|
|
1393
|
+
spring.current.set(1);
|
|
1394
|
+
content.querySelector('[role="menuitem"]:not([disabled])')?.focus({ preventScroll: true });
|
|
1395
|
+
return () => {
|
|
1396
|
+
s.stop();
|
|
1397
|
+
fade.stop();
|
|
1398
|
+
spring.current = null;
|
|
1399
|
+
trigger.style.opacity = "";
|
|
1400
|
+
};
|
|
1401
|
+
}, [mounted]);
|
|
1402
|
+
(0, import_react7.useEffect)(() => {
|
|
1403
|
+
if (!mounted) return;
|
|
1404
|
+
const panel = surfaceRef.current;
|
|
1405
|
+
let held = null;
|
|
1406
|
+
let hot = null;
|
|
1407
|
+
const itemAt = (x, y) => document.elementFromPoint(x, y)?.closest(".lg-menu__item:not(:disabled)") ?? null;
|
|
1408
|
+
const light = (next) => {
|
|
1409
|
+
if (next === hot) return;
|
|
1410
|
+
hot?.removeAttribute("data-active");
|
|
1411
|
+
hot = next;
|
|
1412
|
+
if (hot) {
|
|
1413
|
+
hot.setAttribute("data-active", "");
|
|
1414
|
+
haptic();
|
|
1415
|
+
}
|
|
1416
|
+
};
|
|
1417
|
+
const down = (event) => {
|
|
1418
|
+
if (!event.isPrimary || event.button !== 0) return;
|
|
1419
|
+
held = event.pointerId;
|
|
1420
|
+
hot = null;
|
|
1421
|
+
light(itemAt(event.clientX, event.clientY));
|
|
1422
|
+
};
|
|
1423
|
+
const move = (event) => {
|
|
1424
|
+
if (event.pointerId === held) light(itemAt(event.clientX, event.clientY));
|
|
1425
|
+
};
|
|
1426
|
+
const up = (event) => {
|
|
1427
|
+
if (event.pointerId !== held) return;
|
|
1428
|
+
held = null;
|
|
1429
|
+
const target = hot;
|
|
1430
|
+
light(null);
|
|
1431
|
+
const index = target ? Number(target.dataset.index) : -1;
|
|
1432
|
+
const item = itemsRef.current[index];
|
|
1433
|
+
if (item && !item.disabled) {
|
|
1434
|
+
event.preventDefault();
|
|
1435
|
+
haptic();
|
|
1436
|
+
item.onSelect?.();
|
|
1437
|
+
setOpen(false);
|
|
1438
|
+
}
|
|
1439
|
+
};
|
|
1440
|
+
const cancel = (event) => {
|
|
1441
|
+
if (event.pointerId !== held) return;
|
|
1442
|
+
held = null;
|
|
1443
|
+
light(null);
|
|
1444
|
+
};
|
|
1445
|
+
const hold = (event) => {
|
|
1446
|
+
if (held !== null && event.cancelable) event.preventDefault();
|
|
1447
|
+
};
|
|
1448
|
+
panel.addEventListener("pointerdown", down);
|
|
1449
|
+
window.addEventListener("pointermove", move);
|
|
1450
|
+
window.addEventListener("pointerup", up);
|
|
1451
|
+
window.addEventListener("pointercancel", cancel);
|
|
1452
|
+
panel.addEventListener("touchmove", hold, { passive: false });
|
|
1453
|
+
return () => {
|
|
1454
|
+
panel.removeEventListener("pointerdown", down);
|
|
1455
|
+
window.removeEventListener("pointermove", move);
|
|
1456
|
+
window.removeEventListener("pointerup", up);
|
|
1457
|
+
window.removeEventListener("pointercancel", cancel);
|
|
1458
|
+
panel.removeEventListener("touchmove", hold);
|
|
1459
|
+
};
|
|
1460
|
+
}, [mounted]);
|
|
1461
|
+
(0, import_react7.useEffect)(() => {
|
|
1462
|
+
if (!open) return;
|
|
1463
|
+
const outside = (event) => {
|
|
1464
|
+
if (!anchorRef.current?.contains(event.target)) setOpen(false);
|
|
1465
|
+
};
|
|
1466
|
+
const key = (event) => {
|
|
1467
|
+
if (event.key === "Escape") {
|
|
1468
|
+
setOpen(false);
|
|
1469
|
+
triggerRef.current?.focus({ preventScroll: true });
|
|
1470
|
+
}
|
|
1471
|
+
};
|
|
1472
|
+
document.addEventListener("pointerdown", outside, true);
|
|
1473
|
+
window.addEventListener("keydown", key);
|
|
1474
|
+
return () => {
|
|
1475
|
+
document.removeEventListener("pointerdown", outside, true);
|
|
1476
|
+
window.removeEventListener("keydown", key);
|
|
1477
|
+
};
|
|
1478
|
+
}, [open]);
|
|
1479
|
+
const select = (item) => {
|
|
1480
|
+
haptic();
|
|
1481
|
+
item.onSelect?.();
|
|
1482
|
+
setOpen(false);
|
|
1483
|
+
};
|
|
1484
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { ref: anchorRef, className: ["lg-menu-anchor", className].filter(Boolean).join(" "), "data-align": align, children: [
|
|
1485
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1486
|
+
GlassButton,
|
|
1487
|
+
{
|
|
1488
|
+
ref: triggerRef,
|
|
1489
|
+
size,
|
|
1490
|
+
icon,
|
|
1491
|
+
"aria-label": ariaLabel,
|
|
1492
|
+
"aria-haspopup": "menu",
|
|
1493
|
+
"aria-expanded": open,
|
|
1494
|
+
onClick: () => setOpen((value) => !value)
|
|
1495
|
+
}
|
|
1496
|
+
),
|
|
1497
|
+
mounted && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ref: surfaceRef, className: "lg-menu-surface", children: [
|
|
1498
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ref: panelRef, className: "lg-glass lg-menu", "data-liquid-glass": "", "aria-hidden": "true" }),
|
|
1499
|
+
/* @__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)(
|
|
1500
|
+
"button",
|
|
1501
|
+
{
|
|
1502
|
+
type: "button",
|
|
1503
|
+
role: "menuitem",
|
|
1504
|
+
className: "lg-menu__item",
|
|
1505
|
+
"data-destructive": item.destructive ? "" : void 0,
|
|
1506
|
+
"data-index": index,
|
|
1507
|
+
disabled: item.disabled,
|
|
1508
|
+
onClick: (event) => {
|
|
1509
|
+
if (event.detail === 0) select(item);
|
|
1510
|
+
},
|
|
1511
|
+
children: [
|
|
1512
|
+
item.icon != null && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "lg-menu__icon", children: item.icon }),
|
|
1513
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "lg-menu__label", children: item.label }),
|
|
1514
|
+
item.checked && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "lg-menu__check", children: check ?? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Tick, {}) })
|
|
1515
|
+
]
|
|
1516
|
+
},
|
|
1517
|
+
index
|
|
1518
|
+
)) })
|
|
1519
|
+
] })
|
|
1520
|
+
] });
|
|
1521
|
+
};
|
|
1522
|
+
GlassMenu.displayName = "GlassMenu";
|
|
1523
|
+
|
|
1150
1524
|
// src/components/GlassNav/GlassNav.tsx
|
|
1151
|
-
var
|
|
1525
|
+
var import_react10 = __toESM(require("react"));
|
|
1152
1526
|
|
|
1153
1527
|
// src/components/internal/LensTrack.tsx
|
|
1154
|
-
var
|
|
1528
|
+
var import_react9 = require("react");
|
|
1155
1529
|
|
|
1156
1530
|
// src/engine/lensTrack.ts
|
|
1157
|
-
var
|
|
1531
|
+
var import_react8 = require("react");
|
|
1158
1532
|
function useLensTrack(refs, options) {
|
|
1159
|
-
const latest = (0,
|
|
1533
|
+
const latest = (0, import_react8.useRef)(options);
|
|
1160
1534
|
latest.current = options;
|
|
1161
|
-
const api = (0,
|
|
1162
|
-
(0,
|
|
1535
|
+
const api = (0, import_react8.useRef)(null);
|
|
1536
|
+
(0, import_react8.useEffect)(() => {
|
|
1163
1537
|
const bar = refs.bar.current;
|
|
1164
1538
|
const lens = refs.lens.current;
|
|
1165
1539
|
const glass = refs.glass.current;
|
|
@@ -1176,7 +1550,7 @@ function useLensTrack(refs, options) {
|
|
|
1176
1550
|
let gesture = null;
|
|
1177
1551
|
let dropTimer = 0;
|
|
1178
1552
|
let suppressClick = false;
|
|
1179
|
-
const buttons = Array.from(bar.querySelectorAll("[data-lg-item]"));
|
|
1553
|
+
const buttons = Array.from(bar.querySelectorAll(":scope > [data-lg-item]"));
|
|
1180
1554
|
let glyphs = [];
|
|
1181
1555
|
const preview = (index) => {
|
|
1182
1556
|
if (index === void 0) delete bar.dataset.previewing;
|
|
@@ -1199,14 +1573,23 @@ function useLensTrack(refs, options) {
|
|
|
1199
1573
|
select.style.width = `${slot}px`;
|
|
1200
1574
|
select.style.left = `${pad}px`;
|
|
1201
1575
|
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
|
-
|
|
1576
|
+
(button) => Array.from(button.querySelectorAll(".lg-nav__label, .lg-nav__icon > .lg-symbol")).map((node) => {
|
|
1577
|
+
const label2 = node.classList.contains("lg-nav__label");
|
|
1578
|
+
const host = label2 ? node : node.parentElement;
|
|
1579
|
+
const n = node.getBoundingClientRect();
|
|
1580
|
+
const h = host.getBoundingClientRect();
|
|
1581
|
+
return {
|
|
1582
|
+
node,
|
|
1583
|
+
x: button.offsetLeft + node.offsetLeft - pad,
|
|
1584
|
+
y: node.offsetTop,
|
|
1585
|
+
width: node.offsetWidth,
|
|
1586
|
+
height: node.offsetHeight,
|
|
1587
|
+
label: label2,
|
|
1588
|
+
host,
|
|
1589
|
+
dx: n.left - h.left,
|
|
1590
|
+
dy: n.top - h.top
|
|
1591
|
+
};
|
|
1592
|
+
})
|
|
1210
1593
|
);
|
|
1211
1594
|
};
|
|
1212
1595
|
const paint = () => {
|
|
@@ -1228,8 +1611,24 @@ function useLensTrack(refs, options) {
|
|
|
1228
1611
|
if (lift2 <= 0.02 && !gesture) {
|
|
1229
1612
|
glyph.node.style.removeProperty("--lg-content-tint");
|
|
1230
1613
|
glyph.node.style.removeProperty("transform");
|
|
1614
|
+
glyph.host.style.removeProperty("--lg-content-hide");
|
|
1231
1615
|
continue;
|
|
1232
1616
|
}
|
|
1617
|
+
if (latest.current.copied) {
|
|
1618
|
+
const hy = H * ky / 2;
|
|
1619
|
+
const hx = H * kx / 2;
|
|
1620
|
+
const run = Math.max(0, (W - H) * kx / 2);
|
|
1621
|
+
const ccx = x2 + slot / 2 - glyph.x + glyph.dx;
|
|
1622
|
+
const ccy = height / 2 - glyph.y + glyph.dy;
|
|
1623
|
+
const fade = clamp(lift2 * 3, 0, 1);
|
|
1624
|
+
const solid = `rgb(0 0 0 / ${fade})`;
|
|
1625
|
+
glyph.host.style.setProperty("--lg-content-hide", [
|
|
1626
|
+
"linear-gradient(#000, #000)",
|
|
1627
|
+
`radial-gradient(ellipse ${hx}px ${hy}px at ${ccx - run}px ${ccy}px, ${solid} calc(100% - 1px), transparent 100%)`,
|
|
1628
|
+
`radial-gradient(ellipse ${hx}px ${hy}px at ${ccx + run}px ${ccy}px, ${solid} calc(100% - 1px), transparent 100%)`,
|
|
1629
|
+
`linear-gradient(${solid}, ${solid}) ${ccx - run}px ${ccy - hy}px / ${run * 2}px ${hy * 2}px no-repeat`
|
|
1630
|
+
].join(", "));
|
|
1631
|
+
}
|
|
1233
1632
|
const zoom = latest.current.contentZoom ?? 1;
|
|
1234
1633
|
const ry = H * ky / (2 * zoom);
|
|
1235
1634
|
const rx = H * kx / (2 * zoom);
|
|
@@ -1422,6 +1821,7 @@ function useLensTrack(refs, options) {
|
|
|
1422
1821
|
x.set(current * slot, true);
|
|
1423
1822
|
bar.dataset.ready = "";
|
|
1424
1823
|
observer.observe(bar);
|
|
1824
|
+
const unguard = guardSelection(bar);
|
|
1425
1825
|
bar.addEventListener("pointerdown", onDown);
|
|
1426
1826
|
window.addEventListener("pointermove", onMove);
|
|
1427
1827
|
window.addEventListener("pointerup", onUp);
|
|
@@ -1435,6 +1835,7 @@ function useLensTrack(refs, options) {
|
|
|
1435
1835
|
clearTimeout(dropTimer);
|
|
1436
1836
|
api.current = null;
|
|
1437
1837
|
[x, lift, swell].forEach((s) => s.stop());
|
|
1838
|
+
unguard();
|
|
1438
1839
|
observer.disconnect();
|
|
1439
1840
|
bar.removeEventListener("pointerdown", onDown);
|
|
1440
1841
|
window.removeEventListener("pointermove", onMove);
|
|
@@ -1447,19 +1848,20 @@ function useLensTrack(refs, options) {
|
|
|
1447
1848
|
delete bar.dataset.ready;
|
|
1448
1849
|
delete bar.dataset.lifted;
|
|
1449
1850
|
preview();
|
|
1450
|
-
glyphs.forEach(({ node }) => {
|
|
1851
|
+
glyphs.forEach(({ node, host }) => {
|
|
1451
1852
|
node.style.removeProperty("--lg-content-tint");
|
|
1452
1853
|
node.style.removeProperty("transform");
|
|
1854
|
+
host.style.removeProperty("--lg-content-hide");
|
|
1453
1855
|
});
|
|
1454
1856
|
};
|
|
1455
1857
|
}, [options.count]);
|
|
1456
|
-
(0,
|
|
1858
|
+
(0, import_react8.useEffect)(() => {
|
|
1457
1859
|
api.current?.setIndex(options.index);
|
|
1458
1860
|
}, [options.index]);
|
|
1459
1861
|
}
|
|
1460
1862
|
|
|
1461
1863
|
// src/components/internal/LensTrack.tsx
|
|
1462
|
-
var
|
|
1864
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1463
1865
|
function LensTrack({
|
|
1464
1866
|
items,
|
|
1465
1867
|
labels,
|
|
@@ -1471,28 +1873,36 @@ function LensTrack({
|
|
|
1471
1873
|
style,
|
|
1472
1874
|
"aria-label": ariaLabel
|
|
1473
1875
|
}) {
|
|
1474
|
-
const bar = (0,
|
|
1475
|
-
const glass = (0,
|
|
1476
|
-
const lens = (0,
|
|
1477
|
-
const select = (0,
|
|
1876
|
+
const bar = (0, import_react9.useRef)(null);
|
|
1877
|
+
const glass = (0, import_react9.useRef)(null);
|
|
1878
|
+
const lens = (0, import_react9.useRef)(null);
|
|
1879
|
+
const select = (0, import_react9.useRef)(null);
|
|
1478
1880
|
const strength = Math.max(1, Math.min(10, intensity)) / 5;
|
|
1479
1881
|
const tabbar = variant === "tabbar";
|
|
1480
1882
|
const zoom = tabbar ? 1.14 : 1.1;
|
|
1481
1883
|
useRefraction(glass, { kind: "surface", strength });
|
|
1482
|
-
|
|
1884
|
+
const overhang = tabbar ? 14 : 12;
|
|
1885
|
+
useRefraction(
|
|
1886
|
+
lens,
|
|
1887
|
+
{ kind: "lens", strength: 0.85, zoom, dispersion: 0.25, inset: overhang / 2, copy: "refract" },
|
|
1888
|
+
true,
|
|
1889
|
+
bar,
|
|
1890
|
+
() => bar.current?.hasAttribute("data-lifted") ?? false
|
|
1891
|
+
);
|
|
1483
1892
|
useLensTrack(
|
|
1484
1893
|
{ bar, glass, lens, select },
|
|
1485
1894
|
{
|
|
1486
1895
|
count: items.length,
|
|
1487
1896
|
index,
|
|
1488
1897
|
onSelect: (next) => onChange?.(next),
|
|
1489
|
-
overhang
|
|
1898
|
+
overhang,
|
|
1490
1899
|
spread: tabbar ? 0.3 : 0.16,
|
|
1491
|
-
contentZoom:
|
|
1900
|
+
contentZoom: zoom,
|
|
1901
|
+
copied: true,
|
|
1492
1902
|
swell: tabbar ? 8 : 14
|
|
1493
1903
|
}
|
|
1494
1904
|
);
|
|
1495
|
-
return /* @__PURE__ */ (0,
|
|
1905
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1496
1906
|
"div",
|
|
1497
1907
|
{
|
|
1498
1908
|
ref: bar,
|
|
@@ -1502,9 +1912,9 @@ function LensTrack({
|
|
|
1502
1912
|
"data-liquid-glass": "",
|
|
1503
1913
|
style: { ...style, "--lg-count": items.length, "--lg-index": index },
|
|
1504
1914
|
children: [
|
|
1505
|
-
/* @__PURE__ */ (0,
|
|
1506
|
-
/* @__PURE__ */ (0,
|
|
1507
|
-
items.map((item, i) => /* @__PURE__ */ (0,
|
|
1915
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { ref: glass, className: "lg-glass lg-track__glass", "aria-hidden": "true" }),
|
|
1916
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { ref: select, className: "lg-track__select", "aria-hidden": "true" }),
|
|
1917
|
+
items.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1508
1918
|
"button",
|
|
1509
1919
|
{
|
|
1510
1920
|
type: "button",
|
|
@@ -1518,38 +1928,40 @@ function LensTrack({
|
|
|
1518
1928
|
},
|
|
1519
1929
|
i
|
|
1520
1930
|
)),
|
|
1521
|
-
/* @__PURE__ */ (0,
|
|
1931
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { ref: lens, className: "lg-glass lg-track__lens", "data-lg-mirror-bare": "", "aria-hidden": "true" })
|
|
1522
1932
|
]
|
|
1523
1933
|
}
|
|
1524
1934
|
);
|
|
1525
1935
|
}
|
|
1526
1936
|
|
|
1527
1937
|
// src/components/GlassNav/GlassNav.tsx
|
|
1528
|
-
var
|
|
1938
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1529
1939
|
var GlassNav = ({
|
|
1530
1940
|
items,
|
|
1531
1941
|
activeIndex = 0,
|
|
1532
1942
|
onChange,
|
|
1533
1943
|
intensity = 5,
|
|
1944
|
+
showLabels = true,
|
|
1534
1945
|
className,
|
|
1535
1946
|
style,
|
|
1536
1947
|
"aria-label": ariaLabel = "Tabs"
|
|
1537
1948
|
}) => {
|
|
1538
1949
|
const hasIcons = items.some((item) => item.icon != null);
|
|
1539
|
-
|
|
1950
|
+
const iconsOnly = hasIcons && !showLabels;
|
|
1951
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1540
1952
|
LensTrack,
|
|
1541
1953
|
{
|
|
1542
1954
|
variant: "tabbar",
|
|
1543
|
-
className: ["lg-nav", hasIcons ? "" : "lg-track--labels-only", className].filter(Boolean).join(" "),
|
|
1955
|
+
className: ["lg-nav", hasIcons ? "" : "lg-track--labels-only", iconsOnly ? "lg-track--icons-only" : "", className].filter(Boolean).join(" "),
|
|
1544
1956
|
style,
|
|
1545
1957
|
"aria-label": ariaLabel,
|
|
1546
1958
|
intensity,
|
|
1547
1959
|
index: activeIndex,
|
|
1548
1960
|
onChange,
|
|
1549
1961
|
labels: items.map((item) => item.label),
|
|
1550
|
-
items: items.map((item, i) => /* @__PURE__ */ (0,
|
|
1551
|
-
item.icon != null && /* @__PURE__ */ (0,
|
|
1552
|
-
/* @__PURE__ */ (0,
|
|
1962
|
+
items: items.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react10.default.Fragment, { children: [
|
|
1963
|
+
item.icon != null && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "lg-nav__icon", children: item.icon }),
|
|
1964
|
+
!iconsOnly && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "lg-nav__label", children: item.label })
|
|
1553
1965
|
] }, i))
|
|
1554
1966
|
}
|
|
1555
1967
|
);
|
|
@@ -1557,8 +1969,8 @@ var GlassNav = ({
|
|
|
1557
1969
|
GlassNav.displayName = "GlassNav";
|
|
1558
1970
|
|
|
1559
1971
|
// src/components/GlassSegmented/GlassSegmented.tsx
|
|
1560
|
-
var
|
|
1561
|
-
var
|
|
1972
|
+
var import_react11 = __toESM(require("react"));
|
|
1973
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1562
1974
|
var GlassSegmented = ({
|
|
1563
1975
|
options,
|
|
1564
1976
|
value,
|
|
@@ -1570,7 +1982,7 @@ var GlassSegmented = ({
|
|
|
1570
1982
|
"aria-label": ariaLabel
|
|
1571
1983
|
}) => {
|
|
1572
1984
|
const normalized = options.map((option) => typeof option === "string" ? { label: option } : option);
|
|
1573
|
-
return /* @__PURE__ */ (0,
|
|
1985
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1574
1986
|
LensTrack,
|
|
1575
1987
|
{
|
|
1576
1988
|
variant: "segmented",
|
|
@@ -1581,9 +1993,9 @@ var GlassSegmented = ({
|
|
|
1581
1993
|
index: value,
|
|
1582
1994
|
onChange,
|
|
1583
1995
|
labels: normalized.map((option) => option.label),
|
|
1584
|
-
items: normalized.map((option, i) => /* @__PURE__ */ (0,
|
|
1996
|
+
items: normalized.map((option, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react11.default.Fragment, { children: [
|
|
1585
1997
|
option.icon,
|
|
1586
|
-
/* @__PURE__ */ (0,
|
|
1998
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "lg-nav__label", children: option.label })
|
|
1587
1999
|
] }, i))
|
|
1588
2000
|
}
|
|
1589
2001
|
);
|
|
@@ -1591,9 +2003,9 @@ var GlassSegmented = ({
|
|
|
1591
2003
|
GlassSegmented.displayName = "GlassSegmented";
|
|
1592
2004
|
|
|
1593
2005
|
// src/components/GlassSlider/GlassSlider.tsx
|
|
1594
|
-
var
|
|
1595
|
-
var
|
|
1596
|
-
var GlassSlider =
|
|
2006
|
+
var import_react12 = __toESM(require("react"));
|
|
2007
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2008
|
+
var GlassSlider = import_react12.default.forwardRef(
|
|
1597
2009
|
({
|
|
1598
2010
|
value = 0,
|
|
1599
2011
|
min = 0,
|
|
@@ -1612,22 +2024,23 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1612
2024
|
disabled,
|
|
1613
2025
|
...rest
|
|
1614
2026
|
}, 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,
|
|
2027
|
+
const rootRef = (0, import_react12.useRef)(null);
|
|
2028
|
+
const inputRef = (0, import_react12.useRef)(null);
|
|
2029
|
+
const thumbRef = (0, import_react12.useRef)(null);
|
|
2030
|
+
const faceRef = (0, import_react12.useRef)(null);
|
|
2031
|
+
const blockRef = (0, import_react12.useRef)(null);
|
|
2032
|
+
const pastRef = (0, import_react12.useRef)(0);
|
|
2033
|
+
(0, import_react12.useImperativeHandle)(forwardedRef, () => inputRef.current);
|
|
2034
|
+
(0, import_react12.useEffect)(() => {
|
|
1622
2035
|
const input2 = inputRef.current;
|
|
1623
2036
|
const root = rootRef.current;
|
|
1624
2037
|
const setValue = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value").set;
|
|
1625
2038
|
let drag = null;
|
|
1626
2039
|
const update = (clientX) => {
|
|
1627
2040
|
if (!drag || max <= min) return;
|
|
1628
|
-
const
|
|
1629
|
-
const
|
|
1630
|
-
|
|
2041
|
+
const raw = drag.from + (clientX - drag.x) / drag.travel;
|
|
2042
|
+
const fraction = clamp(raw, 0, 1);
|
|
2043
|
+
pastRef.current = (raw - fraction) * drag.travel;
|
|
1631
2044
|
let next = min + fraction * (max - min);
|
|
1632
2045
|
const increment = Number(step2);
|
|
1633
2046
|
if (step2 !== "any" && Number.isFinite(increment) && increment > 0) {
|
|
@@ -1646,13 +2059,11 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1646
2059
|
if (event.pointerType !== "touch") input2.focus({ preventScroll: true });
|
|
1647
2060
|
const box = root.getBoundingClientRect();
|
|
1648
2061
|
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 };
|
|
2062
|
+
const from = max > min ? clamp((input2.valueAsNumber - min) / (max - min), 0, 1) : 0;
|
|
2063
|
+
drag = { id: event.pointerId, x: event.clientX, from, travel: Math.max(1, box.width - inset * 2) };
|
|
2064
|
+
pastRef.current = 0;
|
|
1653
2065
|
root.dataset.dragging = "";
|
|
1654
2066
|
root.setPointerCapture(event.pointerId);
|
|
1655
|
-
update(event.clientX);
|
|
1656
2067
|
};
|
|
1657
2068
|
const move = (event) => {
|
|
1658
2069
|
if (event.pointerId !== drag?.id) return;
|
|
@@ -1663,6 +2074,7 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1663
2074
|
if (!drag) return;
|
|
1664
2075
|
const id = drag.id;
|
|
1665
2076
|
drag = null;
|
|
2077
|
+
pastRef.current = 0;
|
|
1666
2078
|
delete root.dataset.dragging;
|
|
1667
2079
|
if (root.hasPointerCapture(id)) root.releasePointerCapture(id);
|
|
1668
2080
|
};
|
|
@@ -1671,6 +2083,7 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1671
2083
|
update(event.clientX);
|
|
1672
2084
|
release();
|
|
1673
2085
|
};
|
|
2086
|
+
const unguard = guardSelection(root);
|
|
1674
2087
|
root.addEventListener("pointerdown", down);
|
|
1675
2088
|
root.addEventListener("pointermove", move);
|
|
1676
2089
|
root.addEventListener("pointerup", up);
|
|
@@ -1679,6 +2092,7 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1679
2092
|
window.addEventListener("blur", release);
|
|
1680
2093
|
return () => {
|
|
1681
2094
|
release();
|
|
2095
|
+
unguard();
|
|
1682
2096
|
root.removeEventListener("pointerdown", down);
|
|
1683
2097
|
root.removeEventListener("pointermove", move);
|
|
1684
2098
|
root.removeEventListener("pointerup", up);
|
|
@@ -1688,29 +2102,31 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1688
2102
|
};
|
|
1689
2103
|
}, [min, max, step2, showThumb]);
|
|
1690
2104
|
const strength = Math.max(1, Math.min(10, intensity)) / 5;
|
|
1691
|
-
const [mirrored, setMirrored] =
|
|
1692
|
-
(0,
|
|
2105
|
+
const [mirrored, setMirrored] = import_react12.default.useState(false);
|
|
2106
|
+
(0, import_react12.useEffect)(() => setMirrored(!canRefractBackdrop()), []);
|
|
1693
2107
|
const progress = max > min ? clamp((Number(value) - min) / (max - min), 0, 1) : 0;
|
|
1694
2108
|
useRefraction(
|
|
1695
2109
|
thumbRef,
|
|
1696
|
-
{ kind: "lens", zoom: 1.95, bezel: 7, thickness: 16, strength, dispersion: 0.6 },
|
|
2110
|
+
{ kind: "lens", zoom: 1.95, bezel: 7, thickness: 16, strength, dispersion: 0.6, inset: 11 },
|
|
1697
2111
|
showThumb,
|
|
1698
2112
|
rootRef,
|
|
1699
2113
|
() => parseFloat(rootRef.current?.style.getPropertyValue("--lg-lift") || "0") > 0.01
|
|
1700
2114
|
);
|
|
1701
2115
|
useRefraction(blockRef, { kind: "surface", strength }, !showThumb);
|
|
1702
|
-
(0,
|
|
2116
|
+
(0, import_react12.useEffect)(() => {
|
|
1703
2117
|
if (!showThumb) return;
|
|
1704
2118
|
const input2 = inputRef.current;
|
|
1705
2119
|
const thumb = thumbRef.current;
|
|
1706
2120
|
const face = faceRef.current;
|
|
1707
2121
|
const root = rootRef.current;
|
|
1708
|
-
const v = { lift: 0, stretch: 0 };
|
|
2122
|
+
const v = { lift: 0, stretch: 0, over: 0 };
|
|
1709
2123
|
const paint = () => {
|
|
1710
2124
|
const s = 0.655 + 0.345 * v.lift;
|
|
1711
|
-
|
|
2125
|
+
const pull = Math.abs(v.over) / 58 * 0.6;
|
|
2126
|
+
thumb.style.scale = `${s * (1 + v.stretch + pull)} ${s * (1 - v.stretch * 0.5 - pull * 0.4)}`;
|
|
1712
2127
|
face.style.opacity = String(1 - clamp(v.lift, 0, 1) * 0.92);
|
|
1713
2128
|
root.style.setProperty("--lg-lift", String(clamp(v.lift, 0, 1)));
|
|
2129
|
+
root.style.setProperty("--lg-over", `${v.over.toFixed(2)}px`);
|
|
1714
2130
|
if (v.lift < 0.01 && lift.target === 0) delete root.dataset.lifted;
|
|
1715
2131
|
};
|
|
1716
2132
|
const lift = createSpring(0, SPRINGS.lift, (x) => {
|
|
@@ -1721,6 +2137,10 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1721
2137
|
v.stretch = x;
|
|
1722
2138
|
paint();
|
|
1723
2139
|
});
|
|
2140
|
+
const over = createSpring(0, SPRINGS.release, (x) => {
|
|
2141
|
+
v.over = x;
|
|
2142
|
+
paint();
|
|
2143
|
+
});
|
|
1724
2144
|
paint();
|
|
1725
2145
|
let lastX = 0;
|
|
1726
2146
|
let lastT = 0;
|
|
@@ -1741,6 +2161,8 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1741
2161
|
lastT = event.timeStamp;
|
|
1742
2162
|
stretch.tune(SPRINGS.drag);
|
|
1743
2163
|
stretch.set(clamp(speed * 0.015, 0, 0.035));
|
|
2164
|
+
over.tune(SPRINGS.drag);
|
|
2165
|
+
over.set(rubberband(pastRef.current, 12, 0.5));
|
|
1744
2166
|
};
|
|
1745
2167
|
const up = () => {
|
|
1746
2168
|
if (lift.target === 0) return;
|
|
@@ -1748,6 +2170,8 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1748
2170
|
lift.set(0);
|
|
1749
2171
|
stretch.tune(SPRINGS.release);
|
|
1750
2172
|
stretch.set(0);
|
|
2173
|
+
over.tune(SPRINGS.release);
|
|
2174
|
+
over.set(0);
|
|
1751
2175
|
};
|
|
1752
2176
|
root.addEventListener("pointerdown", down);
|
|
1753
2177
|
window.addEventListener("pointermove", move);
|
|
@@ -1758,6 +2182,7 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1758
2182
|
return () => {
|
|
1759
2183
|
lift.stop();
|
|
1760
2184
|
stretch.stop();
|
|
2185
|
+
over.stop();
|
|
1761
2186
|
root.removeEventListener("pointerdown", down);
|
|
1762
2187
|
window.removeEventListener("pointermove", move);
|
|
1763
2188
|
window.removeEventListener("pointerup", up);
|
|
@@ -1767,7 +2192,7 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1767
2192
|
delete root.dataset.lifted;
|
|
1768
2193
|
};
|
|
1769
2194
|
}, [showThumb]);
|
|
1770
|
-
(0,
|
|
2195
|
+
(0, import_react12.useEffect)(() => {
|
|
1771
2196
|
if (showThumb) return;
|
|
1772
2197
|
const input2 = inputRef.current;
|
|
1773
2198
|
const block = blockRef.current;
|
|
@@ -1791,17 +2216,15 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1791
2216
|
let active2 = null;
|
|
1792
2217
|
const down = (event) => {
|
|
1793
2218
|
if (input2.disabled || !event.isPrimary || event.button !== 0) return;
|
|
1794
|
-
active2 = { id: event.pointerId
|
|
2219
|
+
active2 = { id: event.pointerId };
|
|
1795
2220
|
swell.tune(SPRINGS.press);
|
|
1796
2221
|
swell.set(1);
|
|
1797
2222
|
haptic();
|
|
1798
2223
|
};
|
|
1799
2224
|
const move = (event) => {
|
|
1800
2225
|
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
2226
|
over.tune(SPRINGS.drag);
|
|
1804
|
-
over.set(rubberband(
|
|
2227
|
+
over.set(rubberband(pastRef.current, 26, 0.6));
|
|
1805
2228
|
};
|
|
1806
2229
|
const reset = () => {
|
|
1807
2230
|
if (!active2) return;
|
|
@@ -1831,7 +2254,7 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1831
2254
|
window.removeEventListener("pointercancel", up);
|
|
1832
2255
|
};
|
|
1833
2256
|
}, [showThumb]);
|
|
1834
|
-
const input = /* @__PURE__ */ (0,
|
|
2257
|
+
const input = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1835
2258
|
"input",
|
|
1836
2259
|
{
|
|
1837
2260
|
ref: inputRef,
|
|
@@ -1851,7 +2274,7 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1851
2274
|
);
|
|
1852
2275
|
const vars = { "--lg-progress": progress, ...tint ? { "--lg-slider-fill": tint } : {}, ...style };
|
|
1853
2276
|
if (!showThumb) {
|
|
1854
|
-
return /* @__PURE__ */ (0,
|
|
2277
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1855
2278
|
"div",
|
|
1856
2279
|
{
|
|
1857
2280
|
ref: rootRef,
|
|
@@ -1859,16 +2282,16 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1859
2282
|
"data-liquid-glass": "",
|
|
1860
2283
|
style: vars,
|
|
1861
2284
|
children: [
|
|
1862
|
-
/* @__PURE__ */ (0,
|
|
1863
|
-
/* @__PURE__ */ (0,
|
|
1864
|
-
icon && /* @__PURE__ */ (0,
|
|
1865
|
-
label2 && /* @__PURE__ */ (0,
|
|
1866
|
-
/* @__PURE__ */ (0,
|
|
2285
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { ref: blockRef, className: "lg-glass lg-slider__block", children: [
|
|
2286
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { className: "lg-slider__block-content", "aria-hidden": "true", children: [
|
|
2287
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__icon", children: icon }),
|
|
2288
|
+
label2 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__label", children: label2 }),
|
|
2289
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__value", children: Math.round(Number(value)) })
|
|
1867
2290
|
] }),
|
|
1868
|
-
/* @__PURE__ */ (0,
|
|
1869
|
-
icon && /* @__PURE__ */ (0,
|
|
1870
|
-
label2 && /* @__PURE__ */ (0,
|
|
1871
|
-
/* @__PURE__ */ (0,
|
|
2291
|
+
/* @__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: [
|
|
2292
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__icon", children: icon }),
|
|
2293
|
+
label2 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__label", children: label2 }),
|
|
2294
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "lg-slider__value", children: Math.round(Number(value)) })
|
|
1872
2295
|
] }) })
|
|
1873
2296
|
] }),
|
|
1874
2297
|
input
|
|
@@ -1876,7 +2299,7 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1876
2299
|
}
|
|
1877
2300
|
);
|
|
1878
2301
|
}
|
|
1879
|
-
return /* @__PURE__ */ (0,
|
|
2302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1880
2303
|
"div",
|
|
1881
2304
|
{
|
|
1882
2305
|
ref: rootRef,
|
|
@@ -1885,8 +2308,8 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1885
2308
|
"data-mirror": mirrored ? "" : void 0,
|
|
1886
2309
|
style: vars,
|
|
1887
2310
|
children: [
|
|
1888
|
-
/* @__PURE__ */ (0,
|
|
1889
|
-
/* @__PURE__ */ (0,
|
|
2311
|
+
/* @__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" }) }),
|
|
2312
|
+
/* @__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
2313
|
input
|
|
1891
2314
|
]
|
|
1892
2315
|
}
|
|
@@ -1896,22 +2319,22 @@ var GlassSlider = import_react11.default.forwardRef(
|
|
|
1896
2319
|
GlassSlider.displayName = "GlassSlider";
|
|
1897
2320
|
|
|
1898
2321
|
// src/components/GlassSwitch/GlassSwitch.tsx
|
|
1899
|
-
var
|
|
1900
|
-
var
|
|
2322
|
+
var import_react13 = __toESM(require("react"));
|
|
2323
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1901
2324
|
var SETTLE = springFrom(0.36, 0.68);
|
|
1902
2325
|
var REST = 0.655;
|
|
1903
2326
|
var TRAVEL = 22;
|
|
1904
|
-
var GlassSwitch =
|
|
2327
|
+
var GlassSwitch = import_react13.default.forwardRef(
|
|
1905
2328
|
({ 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,
|
|
2329
|
+
const ref = (0, import_react13.useRef)(null);
|
|
2330
|
+
const thumbRef = (0, import_react13.useRef)(null);
|
|
2331
|
+
const fillRef = (0, import_react13.useRef)(null);
|
|
2332
|
+
const faceRef = (0, import_react13.useRef)(null);
|
|
2333
|
+
(0, import_react13.useImperativeHandle)(forwardedRef, () => ref.current);
|
|
2334
|
+
const [inner, setInner] = (0, import_react13.useState)(defaultChecked);
|
|
1912
2335
|
const controlled = checkedProp !== void 0;
|
|
1913
2336
|
const checked = controlled ? checkedProp : inner;
|
|
1914
|
-
const latest = (0,
|
|
2337
|
+
const latest = (0, import_react13.useRef)({ checked, set: (_) => {
|
|
1915
2338
|
}, disabled });
|
|
1916
2339
|
latest.current = {
|
|
1917
2340
|
checked,
|
|
@@ -1921,15 +2344,15 @@ var GlassSwitch = import_react12.default.forwardRef(
|
|
|
1921
2344
|
onChange?.(next);
|
|
1922
2345
|
}
|
|
1923
2346
|
};
|
|
1924
|
-
const sync = (0,
|
|
2347
|
+
const sync = (0, import_react13.useRef)(null);
|
|
1925
2348
|
useRefraction(
|
|
1926
2349
|
thumbRef,
|
|
1927
|
-
{ kind: "lens", zoom: 1, dispersion: 0.5, strength: Math.max(1, Math.min(10, intensity)) / 5 },
|
|
2350
|
+
{ kind: "lens", zoom: 0.72, zoomX: 1, dispersion: 0.5, copy: true, strength: Math.max(1, Math.min(10, intensity)) / 5 },
|
|
1928
2351
|
true,
|
|
1929
2352
|
ref,
|
|
1930
2353
|
() => parseFloat(ref.current?.style.getPropertyValue("--lg-lift") || "0") > 0.01
|
|
1931
2354
|
);
|
|
1932
|
-
(0,
|
|
2355
|
+
(0, import_react13.useEffect)(() => {
|
|
1933
2356
|
const el2 = ref.current;
|
|
1934
2357
|
const thumb = thumbRef.current;
|
|
1935
2358
|
const fill = fillRef.current;
|
|
@@ -1940,6 +2363,8 @@ var GlassSwitch = import_react12.default.forwardRef(
|
|
|
1940
2363
|
const sy = s * (1 - v.stretch * 0.5);
|
|
1941
2364
|
thumb.style.transform = `translate(${v.x * TRAVEL}px, -50%) scale(${sx}, ${sy})`;
|
|
1942
2365
|
const l = clamp(v.lift, 0, 1);
|
|
2366
|
+
el2.style.setProperty("--lg-knob-x", `${(21 + v.x * TRAVEL).toFixed(2)}px`);
|
|
2367
|
+
el2.style.setProperty("--lg-hole", `${(l > 0.01 ? 23 * sx : 0).toFixed(2)}px`);
|
|
1943
2368
|
el2.style.setProperty("--lg-lift", String(l));
|
|
1944
2369
|
el2.toggleAttribute("data-lifted", l > 0.01);
|
|
1945
2370
|
};
|
|
@@ -2029,6 +2454,7 @@ var GlassSwitch = import_react12.default.forwardRef(
|
|
|
2029
2454
|
latest.current.set(next);
|
|
2030
2455
|
sync.current?.(next);
|
|
2031
2456
|
};
|
|
2457
|
+
const unguard = guardSelection(el2);
|
|
2032
2458
|
el2.addEventListener("pointerdown", down);
|
|
2033
2459
|
el2.addEventListener("pointermove", move);
|
|
2034
2460
|
el2.addEventListener("pointerup", up);
|
|
@@ -2037,6 +2463,7 @@ var GlassSwitch = import_react12.default.forwardRef(
|
|
|
2037
2463
|
return () => {
|
|
2038
2464
|
clearTimeout(dropTimer);
|
|
2039
2465
|
[position, lift, color].forEach((s) => s.stop());
|
|
2466
|
+
unguard();
|
|
2040
2467
|
el2.removeEventListener("pointerdown", down);
|
|
2041
2468
|
el2.removeEventListener("pointermove", move);
|
|
2042
2469
|
el2.removeEventListener("pointerup", up);
|
|
@@ -2044,10 +2471,10 @@ var GlassSwitch = import_react12.default.forwardRef(
|
|
|
2044
2471
|
el2.removeEventListener("click", click);
|
|
2045
2472
|
};
|
|
2046
2473
|
}, []);
|
|
2047
|
-
(0,
|
|
2474
|
+
(0, import_react13.useEffect)(() => {
|
|
2048
2475
|
sync.current?.(checked);
|
|
2049
2476
|
}, [checked]);
|
|
2050
|
-
return /* @__PURE__ */ (0,
|
|
2477
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
2051
2478
|
"button",
|
|
2052
2479
|
{
|
|
2053
2480
|
ref,
|
|
@@ -2064,8 +2491,9 @@ var GlassSwitch = import_react12.default.forwardRef(
|
|
|
2064
2491
|
rest.onKeyDown?.(event);
|
|
2065
2492
|
},
|
|
2066
2493
|
children: [
|
|
2067
|
-
/* @__PURE__ */ (0,
|
|
2068
|
-
/* @__PURE__ */ (0,
|
|
2494
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "lg-switch__track", "aria-hidden": "true" }),
|
|
2495
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { ref: fillRef, className: "lg-switch__fill", "aria-hidden": "true" }),
|
|
2496
|
+
/* @__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
2497
|
]
|
|
2070
2498
|
}
|
|
2071
2499
|
);
|
|
@@ -2074,29 +2502,29 @@ var GlassSwitch = import_react12.default.forwardRef(
|
|
|
2074
2502
|
GlassSwitch.displayName = "GlassSwitch";
|
|
2075
2503
|
|
|
2076
2504
|
// src/filters/LiquidGlassFilter.tsx
|
|
2077
|
-
var
|
|
2078
|
-
var
|
|
2079
|
-
var GlassFilterContext = (0,
|
|
2505
|
+
var import_react14 = require("react");
|
|
2506
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2507
|
+
var GlassFilterContext = (0, import_react14.createContext)(false);
|
|
2080
2508
|
function LiquidGlassFilter({ children }) {
|
|
2081
|
-
return /* @__PURE__ */ (0,
|
|
2082
|
-
/* @__PURE__ */ (0,
|
|
2509
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(GlassFilterContext.Provider, { value: true, children: [
|
|
2510
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(GlassFilterSVG, {}),
|
|
2083
2511
|
children
|
|
2084
2512
|
] });
|
|
2085
2513
|
}
|
|
2086
2514
|
function GlassFilterSVG() {
|
|
2087
|
-
return /* @__PURE__ */ (0,
|
|
2515
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2088
2516
|
"svg",
|
|
2089
2517
|
{
|
|
2090
2518
|
width: "0",
|
|
2091
2519
|
height: "0",
|
|
2092
2520
|
style: { position: "absolute", pointerEvents: "none" },
|
|
2093
2521
|
"aria-hidden": "true",
|
|
2094
|
-
children: /* @__PURE__ */ (0,
|
|
2522
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("defs", { children: Array.from({ length: 10 }, (_, i) => {
|
|
2095
2523
|
const level = i + 1;
|
|
2096
2524
|
const scale = level * 2;
|
|
2097
2525
|
const freq1 = 0.012 + level * 1e-3;
|
|
2098
2526
|
const freq2 = 0.01 + level * 8e-4;
|
|
2099
|
-
return /* @__PURE__ */ (0,
|
|
2527
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2100
2528
|
"filter",
|
|
2101
2529
|
{
|
|
2102
2530
|
id: `liquid-glass-refract-${level}`,
|
|
@@ -2106,7 +2534,7 @@ function GlassFilterSVG() {
|
|
|
2106
2534
|
height: "120%",
|
|
2107
2535
|
colorInterpolationFilters: "sRGB",
|
|
2108
2536
|
children: [
|
|
2109
|
-
/* @__PURE__ */ (0,
|
|
2537
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2110
2538
|
"feTurbulence",
|
|
2111
2539
|
{
|
|
2112
2540
|
type: "fractalNoise",
|
|
@@ -2116,7 +2544,7 @@ function GlassFilterSVG() {
|
|
|
2116
2544
|
result: "noise"
|
|
2117
2545
|
}
|
|
2118
2546
|
),
|
|
2119
|
-
/* @__PURE__ */ (0,
|
|
2547
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2120
2548
|
"feDisplacementMap",
|
|
2121
2549
|
{
|
|
2122
2550
|
in: "SourceGraphic",
|
|
@@ -2136,7 +2564,7 @@ function GlassFilterSVG() {
|
|
|
2136
2564
|
}
|
|
2137
2565
|
|
|
2138
2566
|
// src/hooks/useGlassEffect.ts
|
|
2139
|
-
var
|
|
2567
|
+
var import_react15 = require("react");
|
|
2140
2568
|
function parseTintColor(tint) {
|
|
2141
2569
|
const defaults = { h: 0, s: 0, l: 100, a: 0.1 };
|
|
2142
2570
|
if (!tint) return defaults;
|
|
@@ -2188,7 +2616,7 @@ function useGlassEffect(options = {}) {
|
|
|
2188
2616
|
thickness,
|
|
2189
2617
|
blur
|
|
2190
2618
|
} = options;
|
|
2191
|
-
return (0,
|
|
2619
|
+
return (0, import_react15.useMemo)(() => {
|
|
2192
2620
|
const clampedIntensity = Math.max(1, Math.min(10, Math.round(intensity)));
|
|
2193
2621
|
const filterId = `liquid-glass-refract-${clampedIntensity}`;
|
|
2194
2622
|
const style = {
|
|
@@ -2213,21 +2641,21 @@ function useGlassEffect(options = {}) {
|
|
|
2213
2641
|
}
|
|
2214
2642
|
|
|
2215
2643
|
// src/hooks/useGlassAnimation.ts
|
|
2216
|
-
var
|
|
2644
|
+
var import_react16 = require("react");
|
|
2217
2645
|
function useGlassAnimation() {
|
|
2218
|
-
const [isHovered, setIsHovered] = (0,
|
|
2219
|
-
const [isPressed, setIsPressed] = (0,
|
|
2220
|
-
const [isFocused, setIsFocused] = (0,
|
|
2646
|
+
const [isHovered, setIsHovered] = (0, import_react16.useState)(false);
|
|
2647
|
+
const [isPressed, setIsPressed] = (0, import_react16.useState)(false);
|
|
2648
|
+
const [isFocused, setIsFocused] = (0, import_react16.useState)(false);
|
|
2221
2649
|
const handlers = {
|
|
2222
|
-
onPointerEnter: (0,
|
|
2223
|
-
onPointerLeave: (0,
|
|
2650
|
+
onPointerEnter: (0, import_react16.useCallback)(() => setIsHovered(true), []),
|
|
2651
|
+
onPointerLeave: (0, import_react16.useCallback)(() => {
|
|
2224
2652
|
setIsHovered(false);
|
|
2225
2653
|
setIsPressed(false);
|
|
2226
2654
|
}, []),
|
|
2227
|
-
onPointerDown: (0,
|
|
2228
|
-
onPointerUp: (0,
|
|
2229
|
-
onFocus: (0,
|
|
2230
|
-
onBlur: (0,
|
|
2655
|
+
onPointerDown: (0, import_react16.useCallback)(() => setIsPressed(true), []),
|
|
2656
|
+
onPointerUp: (0, import_react16.useCallback)(() => setIsPressed(false), []),
|
|
2657
|
+
onFocus: (0, import_react16.useCallback)(() => setIsFocused(true), []),
|
|
2658
|
+
onBlur: (0, import_react16.useCallback)(() => setIsFocused(false), [])
|
|
2231
2659
|
};
|
|
2232
2660
|
return { isHovered, isPressed, isFocused, handlers };
|
|
2233
2661
|
}
|
|
@@ -2236,6 +2664,7 @@ function useGlassAnimation() {
|
|
|
2236
2664
|
GlassButton,
|
|
2237
2665
|
GlassCard,
|
|
2238
2666
|
GlassInput,
|
|
2667
|
+
GlassMenu,
|
|
2239
2668
|
GlassNav,
|
|
2240
2669
|
GlassSegmented,
|
|
2241
2670
|
GlassSheet,
|