@pieai/swimmer-ui-kit 2.11.0 → 2.13.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/CHANGELOG.md +32 -0
- package/README.md +10 -2
- package/dist/index.d.ts +71 -8
- package/dist/index.js +1394 -1127
- package/dist/liquid-presence.js +126 -126
- package/dist/{reducedMotion-C7O9ls34.js → liquidGooeySpring-WwyGKGPL.js} +83 -83
- package/dist/styles.css +1 -1
- package/package.json +2 -1
package/dist/liquid-presence.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { _ as e,
|
|
1
|
+
import { _ as e, g as t, m as n, p as r, r as i, s as a, t as o, u as s } from "./liquidGooeySpring-WwyGKGPL.js";
|
|
2
2
|
import { useEffect as c, useId as l, useLayoutEffect as u, useRef as d, useState as f } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
4
|
+
import { createPortal as g } from "react-dom";
|
|
5
5
|
import { FloatingPortal as _, autoUpdate as v, computePosition as y, flip as b, hide as x, offset as S, shift as C, size as w } from "@floating-ui/react";
|
|
6
6
|
function T(e, t, n) {
|
|
7
7
|
return Number.isFinite(e) ? Math.max(t, Math.min(n, e)) : t;
|
|
@@ -396,19 +396,19 @@ function ue(e, t, n, r) {
|
|
|
396
396
|
}
|
|
397
397
|
//#endregion
|
|
398
398
|
//#region src/useLiquidPresenceMotion.ts
|
|
399
|
-
function K(
|
|
400
|
-
let s = d(
|
|
401
|
-
s.current =
|
|
402
|
-
let l = !!
|
|
399
|
+
function K(e, i, a, o) {
|
|
400
|
+
let s = d(a);
|
|
401
|
+
s.current = a;
|
|
402
|
+
let l = !!a.guideContent, u = d(null), f = d(null), p = d(null), m = d(0), h = d(+(a.idleMotion === "breathe")), g = d(() => {});
|
|
403
403
|
c(() => {
|
|
404
|
-
let
|
|
405
|
-
if (!
|
|
404
|
+
let a = e.current, o = i.current;
|
|
405
|
+
if (!a || !o) return;
|
|
406
406
|
let c = {
|
|
407
|
-
source:
|
|
407
|
+
source: a,
|
|
408
408
|
overlay: o,
|
|
409
|
-
body:
|
|
410
|
-
bud:
|
|
411
|
-
satellites: [...
|
|
409
|
+
body: a.querySelector("[data-presence-body]"),
|
|
410
|
+
bud: a.querySelector("[data-presence-bud]"),
|
|
411
|
+
satellites: [...a.querySelectorAll("[data-presence-satellite]")],
|
|
412
412
|
flight: o.querySelector(".game-ui-liquid-presence-flight"),
|
|
413
413
|
flightBody: o.querySelector("[data-presence-flight-body]"),
|
|
414
414
|
trail: o.querySelector("[data-presence-trail]"),
|
|
@@ -423,8 +423,8 @@ function K(t, n, i, o) {
|
|
|
423
423
|
"land",
|
|
424
424
|
"gather",
|
|
425
425
|
"return"
|
|
426
|
-
].includes(d.phase) ? d.point : void 0, x = d?.point ?? O(
|
|
427
|
-
I &&
|
|
426
|
+
].includes(d.phase) ? d.point : void 0, x = d?.point ?? O(a.getBoundingClientRect()), E = d?.seatWidth ?? 48, k = d ?? void 0, j = a.getBoundingClientRect(), M = performance.now(), N = null, P = () => {}, F = !0, I = !1, L = !1, R = !0, z = 0, V = m.current, re = performance.now(), U = 0, W = 0, G = null, K = () => {}, q, J = () => {
|
|
427
|
+
I && n(), I = !1;
|
|
428
428
|
}, Y = (e) => {
|
|
429
429
|
if (l) {
|
|
430
430
|
f.current = l.key, l = null, _ = !!(u.current && u.current.phase !== "still"), k = u.current ?? void 0, v = u.current?.point, x = v ?? x, M = performance.now(), K(), clearTimeout(q), W++, B(c.label, !1);
|
|
@@ -521,13 +521,13 @@ function K(t, n, i, o) {
|
|
|
521
521
|
"speaking",
|
|
522
522
|
"working"
|
|
523
523
|
].includes(s.current.activity ?? "idle"), de = () => s.current.idleMotion === "breathe" && (s.current.activity ?? "idle") === "idle", fe = () => {
|
|
524
|
-
if (L = !1, s.current.reducedMotion || s.current.activity === "disabled" || document.hidden || !R || !D(
|
|
525
|
-
let
|
|
526
|
-
if (
|
|
524
|
+
if (L = !1, s.current.reducedMotion || s.current.activity === "disabled" || document.hidden || !R || !D(a.getBoundingClientRect(), H())) return !1;
|
|
525
|
+
let e = document.querySelector("dialog:modal");
|
|
526
|
+
if (e && !e.contains(a)) return !1;
|
|
527
527
|
let n = l?.contextElement?.closest("dialog") ?? null;
|
|
528
|
-
if (l &&
|
|
529
|
-
let
|
|
530
|
-
return o.maxAnimatedGroups === 0 ||
|
|
528
|
+
if (l && a.closest("dialog") !== n) return !1;
|
|
529
|
+
let i = 13184 + (a.getBoundingClientRect().width * 2) ** 2, o = r();
|
|
530
|
+
return o.maxAnimatedGroups === 0 || i > o.maxFilterArea ? (J(), !1) : !(l || _ || Q()) && de() && !I && o.activeGroups > 0 ? (L = !0, !1) : (I ||= t(i), I);
|
|
531
531
|
};
|
|
532
532
|
function pe(e) {
|
|
533
533
|
if (!F || document.hidden) return;
|
|
@@ -616,7 +616,7 @@ function K(t, n, i, o) {
|
|
|
616
616
|
}, ye = typeof IntersectionObserver > "u" ? null : new IntersectionObserver((e) => {
|
|
617
617
|
R = e[0]?.isIntersecting ?? !0, R || (P(), P = () => {}, N !== null && cancelAnimationFrame(N), N = null, J()), $();
|
|
618
618
|
});
|
|
619
|
-
ye?.observe(
|
|
619
|
+
ye?.observe(a), document.addEventListener("keydown", ge, !0), document.addEventListener("click", _e), document.addEventListener("visibilitychange", ve), document.addEventListener("close", $, !0), document.addEventListener("toggle", $, !0);
|
|
620
620
|
let be = le(() => {
|
|
621
621
|
Z(), $();
|
|
622
622
|
});
|
|
@@ -624,30 +624,30 @@ function K(t, n, i, o) {
|
|
|
624
624
|
F = !1, g.current = () => {}, W++, N !== null && cancelAnimationFrame(N), clearTimeout(q), P(), K(), be(), ye?.disconnect(), J(), document.removeEventListener("keydown", ge, !0), document.removeEventListener("click", _e), document.removeEventListener("visibilitychange", ve), document.removeEventListener("close", $, !0), document.removeEventListener("toggle", $, !0);
|
|
625
625
|
};
|
|
626
626
|
}, [
|
|
627
|
-
|
|
628
|
-
|
|
627
|
+
e,
|
|
628
|
+
i,
|
|
629
629
|
o,
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
630
|
+
a.target?.key,
|
|
631
|
+
a.reducedMotion,
|
|
632
|
+
a.size,
|
|
633
|
+
a.guideSize,
|
|
634
634
|
l
|
|
635
635
|
]), c(() => g.current(), [
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
636
|
+
a.activity,
|
|
637
|
+
a.idleMotion,
|
|
638
|
+
a.motionSpeed,
|
|
639
|
+
a.motionIntensity,
|
|
640
|
+
a.splashes
|
|
641
641
|
]);
|
|
642
642
|
}
|
|
643
643
|
//#endregion
|
|
644
644
|
//#region src/LiquidPresence.tsx
|
|
645
|
-
function q(
|
|
646
|
-
let
|
|
645
|
+
function q(t) {
|
|
646
|
+
let n = e() || t.reducedMotion === !0, r = T(t.size ?? 64, 32, 224), i = `presence-${l().replace(/[^a-zA-Z0-9_-]/g, "")}`, a = d(null), o = d(null), [u, _] = f(null);
|
|
647
647
|
c(() => {
|
|
648
|
-
let
|
|
649
|
-
_(
|
|
650
|
-
}, [
|
|
648
|
+
let e = t.target?.contextElement?.closest("dialog");
|
|
649
|
+
_(e ?? a.current?.closest("dialog") ?? document.body);
|
|
650
|
+
}, [t.target?.contextElement]), c(() => {
|
|
651
651
|
let e = a.current, t = o.current;
|
|
652
652
|
if (!e || !t) return;
|
|
653
653
|
let n = [
|
|
@@ -689,39 +689,39 @@ function q(e) {
|
|
|
689
689
|
i.disconnect(), window.removeEventListener("resize", r);
|
|
690
690
|
};
|
|
691
691
|
}, [u]), K(a, o, {
|
|
692
|
-
...
|
|
692
|
+
...t,
|
|
693
693
|
size: r,
|
|
694
|
-
reducedMotion:
|
|
694
|
+
reducedMotion: n
|
|
695
695
|
}, u);
|
|
696
696
|
let v = {
|
|
697
697
|
width: r,
|
|
698
698
|
height: r,
|
|
699
|
-
...
|
|
700
|
-
...
|
|
701
|
-
...["error", "unknown"].includes(
|
|
699
|
+
...t.colorFrom ? { "--liquid-presence-from": t.colorFrom } : {},
|
|
700
|
+
...t.colorTo ? { "--liquid-presence-to": t.colorTo } : {},
|
|
701
|
+
...["error", "unknown"].includes(t.activity ?? "") ? {
|
|
702
702
|
"--liquid-presence-from": "var(--game-ui-warning)",
|
|
703
703
|
"--liquid-presence-to": "var(--game-ui-warning)"
|
|
704
704
|
} : {}
|
|
705
|
-
}, y = (e, t) => /* @__PURE__ */
|
|
705
|
+
}, y = (e, t) => /* @__PURE__ */ h("defs", { children: [/* @__PURE__ */ h("linearGradient", {
|
|
706
706
|
id: `${i}-${e}-fill`,
|
|
707
707
|
gradientUnits: "userSpaceOnUse",
|
|
708
708
|
x1: e === "core" ? 24 : -24,
|
|
709
709
|
y1: e === "core" ? 16 : -18,
|
|
710
710
|
x2: e === "core" ? 136 : 24,
|
|
711
711
|
y2: e === "core" ? 146 : 18,
|
|
712
|
-
children: [/* @__PURE__ */
|
|
712
|
+
children: [/* @__PURE__ */ m("stop", {
|
|
713
713
|
offset: "0",
|
|
714
714
|
stopColor: "var(--liquid-presence-from, var(--game-ui-secondary))"
|
|
715
|
-
}), /* @__PURE__ */
|
|
715
|
+
}), /* @__PURE__ */ m("stop", {
|
|
716
716
|
offset: "1",
|
|
717
717
|
stopColor: "var(--liquid-presence-to, var(--game-ui-secondary))"
|
|
718
718
|
})]
|
|
719
|
-
}), /* @__PURE__ */
|
|
719
|
+
}), /* @__PURE__ */ m("filter", {
|
|
720
720
|
id: `${i}-${e}-goo`,
|
|
721
721
|
filterUnits: "userSpaceOnUse",
|
|
722
722
|
...t,
|
|
723
723
|
colorInterpolationFilters: "sRGB",
|
|
724
|
-
children: /* @__PURE__ */
|
|
724
|
+
children: /* @__PURE__ */ m(s, {
|
|
725
725
|
blur: e === "core" ? 5 : 2,
|
|
726
726
|
contrast: 18,
|
|
727
727
|
gloss: 3.5,
|
|
@@ -730,13 +730,13 @@ function q(e) {
|
|
|
730
730
|
waviness: 0
|
|
731
731
|
})
|
|
732
732
|
})] });
|
|
733
|
-
return /* @__PURE__ */
|
|
733
|
+
return /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m("span", {
|
|
734
734
|
ref: a,
|
|
735
|
-
className: `game-ui-liquid-presence ${
|
|
735
|
+
className: `game-ui-liquid-presence ${t.className ?? ""}`,
|
|
736
736
|
style: v,
|
|
737
|
-
"data-activity":
|
|
737
|
+
"data-activity": t.activity ?? "idle",
|
|
738
738
|
"aria-hidden": "true",
|
|
739
|
-
children: /* @__PURE__ */
|
|
739
|
+
children: /* @__PURE__ */ h("svg", {
|
|
740
740
|
viewBox: "0 0 160 160",
|
|
741
741
|
focusable: "false",
|
|
742
742
|
children: [y("core", {
|
|
@@ -744,15 +744,15 @@ function q(e) {
|
|
|
744
744
|
y: -80,
|
|
745
745
|
width: 320,
|
|
746
746
|
height: 320
|
|
747
|
-
}), /* @__PURE__ */
|
|
747
|
+
}), /* @__PURE__ */ h("g", {
|
|
748
748
|
fill: `url(#${i}-core-fill)`,
|
|
749
749
|
filter: `url(#${i}-core-goo)`,
|
|
750
750
|
children: [
|
|
751
|
-
/* @__PURE__ */
|
|
751
|
+
/* @__PURE__ */ m("path", {
|
|
752
752
|
"data-presence-body": "",
|
|
753
753
|
d: M()
|
|
754
754
|
}),
|
|
755
|
-
/* @__PURE__ */
|
|
755
|
+
/* @__PURE__ */ m("circle", {
|
|
756
756
|
"data-presence-bud": "",
|
|
757
757
|
cx: "80",
|
|
758
758
|
cy: "80",
|
|
@@ -763,7 +763,7 @@ function q(e) {
|
|
|
763
763
|
0,
|
|
764
764
|
1,
|
|
765
765
|
2
|
|
766
|
-
].map((e) => /* @__PURE__ */
|
|
766
|
+
].map((e) => /* @__PURE__ */ m("circle", {
|
|
767
767
|
"data-presence-satellite": "",
|
|
768
768
|
cx: "80",
|
|
769
769
|
cy: "80",
|
|
@@ -773,7 +773,7 @@ function q(e) {
|
|
|
773
773
|
]
|
|
774
774
|
})]
|
|
775
775
|
})
|
|
776
|
-
}), u &&
|
|
776
|
+
}), u && g(/* @__PURE__ */ h("div", {
|
|
777
777
|
ref: o,
|
|
778
778
|
className: "game-ui-liquid-presence-overlay",
|
|
779
779
|
style: {
|
|
@@ -783,7 +783,7 @@ function q(e) {
|
|
|
783
783
|
},
|
|
784
784
|
"data-presence-overlay": "",
|
|
785
785
|
children: [
|
|
786
|
-
/* @__PURE__ */
|
|
786
|
+
/* @__PURE__ */ h("svg", {
|
|
787
787
|
className: "game-ui-liquid-presence-flight",
|
|
788
788
|
viewBox: "-48 -36 96 72",
|
|
789
789
|
"aria-hidden": "true",
|
|
@@ -794,18 +794,18 @@ function q(e) {
|
|
|
794
794
|
y: -36,
|
|
795
795
|
width: 96,
|
|
796
796
|
height: 72
|
|
797
|
-
}), /* @__PURE__ */
|
|
797
|
+
}), /* @__PURE__ */ m("g", {
|
|
798
798
|
fill: `url(#${i}-flight-fill)`,
|
|
799
799
|
filter: `url(#${i}-flight-goo)`,
|
|
800
|
-
children: /* @__PURE__ */
|
|
800
|
+
children: /* @__PURE__ */ h("g", {
|
|
801
801
|
"data-presence-flight-body": "",
|
|
802
|
-
children: [/* @__PURE__ */
|
|
802
|
+
children: [/* @__PURE__ */ m("circle", { r: "16" }), /* @__PURE__ */ h("g", {
|
|
803
803
|
"data-presence-trail": "",
|
|
804
|
-
children: [/* @__PURE__ */
|
|
804
|
+
children: [/* @__PURE__ */ m("circle", {
|
|
805
805
|
cx: "-27",
|
|
806
806
|
cy: "5",
|
|
807
807
|
r: "4.5"
|
|
808
|
-
}), /* @__PURE__ */
|
|
808
|
+
}), /* @__PURE__ */ m("circle", {
|
|
809
809
|
cx: "-36",
|
|
810
810
|
cy: "8",
|
|
811
811
|
r: "2.5"
|
|
@@ -814,7 +814,7 @@ function q(e) {
|
|
|
814
814
|
})
|
|
815
815
|
})]
|
|
816
816
|
}),
|
|
817
|
-
/* @__PURE__ */
|
|
817
|
+
/* @__PURE__ */ h("svg", {
|
|
818
818
|
className: "game-ui-liquid-presence-seat",
|
|
819
819
|
viewBox: "-56 -28 112 56",
|
|
820
820
|
"aria-hidden": "true",
|
|
@@ -825,45 +825,45 @@ function q(e) {
|
|
|
825
825
|
y: -28,
|
|
826
826
|
width: 112,
|
|
827
827
|
height: 56
|
|
828
|
-
}), /* @__PURE__ */
|
|
828
|
+
}), /* @__PURE__ */ m("path", {
|
|
829
829
|
"data-presence-seat-body": "",
|
|
830
830
|
d: N(48, 1),
|
|
831
831
|
fill: `url(#${i}-seat-fill)`,
|
|
832
832
|
filter: `url(#${i}-seat-goo)`
|
|
833
833
|
})]
|
|
834
834
|
}),
|
|
835
|
-
/* @__PURE__ */
|
|
836
|
-
className: `game-ui-liquid-presence-label${
|
|
837
|
-
role:
|
|
838
|
-
"aria-atomic": !
|
|
839
|
-
onClick:
|
|
840
|
-
onPointerDown:
|
|
841
|
-
onKeyDown:
|
|
835
|
+
/* @__PURE__ */ m("div", {
|
|
836
|
+
className: `game-ui-liquid-presence-label${t.guideContent ? " game-ui-liquid-presence-label--guide" : ""}${t.guideContent && t.guideSize === "expanded" ? " game-ui-liquid-presence-label--expanded" : ""}`,
|
|
837
|
+
role: t.guideContent ? void 0 : "status",
|
|
838
|
+
"aria-atomic": !t.guideContent || void 0,
|
|
839
|
+
onClick: t.guideContent ? (e) => e.stopPropagation() : void 0,
|
|
840
|
+
onPointerDown: t.guideContent ? (e) => e.stopPropagation() : void 0,
|
|
841
|
+
onKeyDown: t.guideContent ? (e) => {
|
|
842
842
|
e.stopPropagation(), e.key === "Escape" && e.preventDefault();
|
|
843
843
|
} : void 0,
|
|
844
844
|
hidden: !0,
|
|
845
|
-
children:
|
|
845
|
+
children: t.guideContent ?? t.target?.label.slice(0, 240)
|
|
846
846
|
})
|
|
847
847
|
]
|
|
848
848
|
}), u)] });
|
|
849
849
|
}
|
|
850
850
|
//#endregion
|
|
851
851
|
//#region src/liquidRevealGeometry.ts
|
|
852
|
-
function J(e, n, r
|
|
853
|
-
let s = Math.max(44, e), c = Math.max(44,
|
|
852
|
+
function J(e, t, n, r = 0, o = 1) {
|
|
853
|
+
let s = Math.max(44, e), c = Math.max(44, t), l = Math.min(28, (s - 12) / 2, (c - 12) / 2), u = i(6, 6, s - 12, c - 12, [
|
|
854
854
|
l,
|
|
855
855
|
l,
|
|
856
856
|
l,
|
|
857
857
|
l
|
|
858
858
|
], {
|
|
859
|
-
amplitude: (
|
|
859
|
+
amplitude: (n ? 8 : 11) * Math.min(1.25, Math.max(.25, Number.isFinite(o) ? o : 1)),
|
|
860
860
|
lobes: 3,
|
|
861
861
|
seed: 17,
|
|
862
|
-
phase:
|
|
862
|
+
phase: r
|
|
863
863
|
}), d = Math.max(0, l - 2.5);
|
|
864
864
|
return {
|
|
865
865
|
outline: u,
|
|
866
|
-
ribbon: `${u} ${
|
|
866
|
+
ribbon: `${u} ${a(8.5, 8.5, s - 17, c - 17, [
|
|
867
867
|
d,
|
|
868
868
|
d,
|
|
869
869
|
d,
|
|
@@ -873,29 +873,29 @@ function J(e, n, r, a = 0, o = 1) {
|
|
|
873
873
|
}
|
|
874
874
|
//#endregion
|
|
875
875
|
//#region src/useLiquidRevealAmbient.ts
|
|
876
|
-
function Y(
|
|
876
|
+
function Y(e, i, a, o, s, l = 1, u = 1) {
|
|
877
877
|
let f = d(0);
|
|
878
878
|
return c(() => {
|
|
879
|
-
let c =
|
|
880
|
-
if (!c || !
|
|
879
|
+
let c = e.current;
|
|
880
|
+
if (!c || !i || !a || !o) {
|
|
881
881
|
c && (c.dataset.revealAmbient = "static");
|
|
882
882
|
return;
|
|
883
883
|
}
|
|
884
|
-
let d = !0, p = !0, m = performance.now(), h = () => {}, g = c.querySelector("[data-reveal-outline]"), _ = c.querySelector("[data-reveal-body]"), v = c.querySelector("[data-reveal-ribbon]"), y = (
|
|
884
|
+
let d = !0, p = !0, m = performance.now(), h = () => {}, g = c.querySelector("[data-reveal-outline]"), _ = c.querySelector("[data-reveal-body]"), v = c.querySelector("[data-reveal-ribbon]"), y = (a + 24) * (o + 24), b = (e) => {
|
|
885
885
|
if (!d || !p || document.hidden) return;
|
|
886
|
-
let
|
|
887
|
-
m =
|
|
888
|
-
let x = document.querySelector("dialog:modal"), S = x && !x.contains(c) || ["drawing", "preparing"].includes(c.dataset.revealMotion ?? ""), C =
|
|
889
|
-
if (S || C.activeGroups > 0 || !
|
|
886
|
+
let i = Math.min(160, Math.max(0, e - m));
|
|
887
|
+
m = e;
|
|
888
|
+
let x = document.querySelector("dialog:modal"), S = x && !x.contains(c) || ["drawing", "preparing"].includes(c.dataset.revealMotion ?? ""), C = r();
|
|
889
|
+
if (S || C.activeGroups > 0 || !t(y)) {
|
|
890
890
|
c.dataset.revealAmbient = "paused", h = te(b, 250);
|
|
891
891
|
return;
|
|
892
892
|
}
|
|
893
893
|
try {
|
|
894
|
-
f.current +=
|
|
895
|
-
let e = J(
|
|
894
|
+
f.current += i * Math.PI * 2 * u / 1e4;
|
|
895
|
+
let e = J(a, o, s, f.current, l);
|
|
896
896
|
g?.setAttribute("d", e.outline), _?.setAttribute("d", e.outline), v?.setAttribute("d", e.ribbon), c.dataset.revealAmbient = "flowing";
|
|
897
897
|
} finally {
|
|
898
|
-
|
|
898
|
+
n();
|
|
899
899
|
}
|
|
900
900
|
h = te(b);
|
|
901
901
|
}, x = () => {
|
|
@@ -907,9 +907,9 @@ function Y(t, n, i, o, s, l = 1, u = 1) {
|
|
|
907
907
|
d = !1, h(), S?.disconnect(), document.removeEventListener("visibilitychange", x), c.dataset.revealAmbient = "static";
|
|
908
908
|
};
|
|
909
909
|
}, [
|
|
910
|
-
|
|
911
|
-
n,
|
|
910
|
+
e,
|
|
912
911
|
i,
|
|
912
|
+
a,
|
|
913
913
|
o,
|
|
914
914
|
s,
|
|
915
915
|
l,
|
|
@@ -944,18 +944,18 @@ function Z(e, t, n, r, a, o, s = 1) {
|
|
|
944
944
|
}
|
|
945
945
|
//#endregion
|
|
946
946
|
//#region src/useLiquidRevealEntrance.ts
|
|
947
|
-
function Q(
|
|
947
|
+
function Q(e, r, i, a, o, s, c, l, f = 1) {
|
|
948
948
|
let p = d(null);
|
|
949
949
|
u(() => {
|
|
950
|
-
let u =
|
|
950
|
+
let u = e.current;
|
|
951
951
|
if (!u) return;
|
|
952
|
-
if (!
|
|
952
|
+
if (!r || s || u.contains(document.activeElement) || window.matchMedia("(forced-colors: active)").matches) {
|
|
953
953
|
p.current = i, u.dataset.revealMotion = "static";
|
|
954
954
|
return;
|
|
955
955
|
}
|
|
956
956
|
if (p.current === i || (u.dataset.revealMotion = "preparing", !a || !o)) return;
|
|
957
957
|
let d = !0, m = !1, h = !1, g = 0, _ = 0, v = [], y = () => {
|
|
958
|
-
v.forEach((e) => e.cancel()), v.length = 0, m &&
|
|
958
|
+
v.forEach((e) => e.cancel()), v.length = 0, m && n(), m = !1, u.dataset.revealMotion = h ? "settled" : "static";
|
|
959
959
|
}, b = () => {
|
|
960
960
|
if (!d) return;
|
|
961
961
|
if (getComputedStyle(u).visibility === "hidden") {
|
|
@@ -966,21 +966,21 @@ function Q(t, n, i, a, o, s, c, l, f = 1) {
|
|
|
966
966
|
y();
|
|
967
967
|
return;
|
|
968
968
|
}
|
|
969
|
-
let
|
|
970
|
-
if (p.current = i, u.contains(document.activeElement) || !
|
|
969
|
+
let e = r.current?.getBoundingClientRect(), n = u.getBoundingClientRect(), s = u.querySelector("[data-reveal-body]"), x = u.querySelector("[data-reveal-material]"), S = u.querySelector(".game-ui-liquid-reveal-content");
|
|
970
|
+
if (p.current = i, u.contains(document.activeElement) || !e || !E(e) || document.hidden || typeof u.animate != "function" || !t((a + 24) * (o + 24))) {
|
|
971
971
|
y();
|
|
972
972
|
return;
|
|
973
973
|
}
|
|
974
974
|
m = !0, h = !0, u.dataset.revealMotion = "drawing";
|
|
975
|
-
let C =
|
|
976
|
-
x: (
|
|
977
|
-
y: (
|
|
975
|
+
let C = n.width / a || 1, w = n.height / o || 1, T = {
|
|
976
|
+
x: (e.x + e.width / 2 - n.x) / C,
|
|
977
|
+
y: (e.y + e.height / 2 - n.y) / w
|
|
978
978
|
}, D = {
|
|
979
979
|
x: Math.min(a - 28, Math.max(28, T.x)),
|
|
980
980
|
y: T.y > o / 2 ? o - 28 : 28
|
|
981
981
|
}, O = {
|
|
982
|
-
x: -
|
|
983
|
-
y: -
|
|
982
|
+
x: -n.x / C,
|
|
983
|
+
y: -n.y / w,
|
|
984
984
|
width: innerWidth / C,
|
|
985
985
|
height: innerHeight / w
|
|
986
986
|
};
|
|
@@ -1016,7 +1016,7 @@ function Q(t, n, i, a, o, s, c, l, f = 1) {
|
|
|
1016
1016
|
fill: "both"
|
|
1017
1017
|
}));
|
|
1018
1018
|
} else x && v.push(x.animate([{ opacity: .2 }, { opacity: 1 }], { duration: 180 }));
|
|
1019
|
-
let k =
|
|
1019
|
+
let k = r.current?.querySelector(".game-ui-liquid-presence > svg");
|
|
1020
1020
|
k && v.push(k.animate([
|
|
1021
1021
|
{ transform: "scale(1)" },
|
|
1022
1022
|
{
|
|
@@ -1043,8 +1043,8 @@ function Q(t, n, i, a, o, s, c, l, f = 1) {
|
|
|
1043
1043
|
d = !1, x(), u.removeEventListener("focusin", x), u.removeEventListener("pointerdown", x, !0), document.removeEventListener("visibilitychange", S), window.removeEventListener("resize", x), window.removeEventListener("scroll", x, !0);
|
|
1044
1044
|
};
|
|
1045
1045
|
}, [
|
|
1046
|
-
|
|
1047
|
-
|
|
1046
|
+
e,
|
|
1047
|
+
r,
|
|
1048
1048
|
i,
|
|
1049
1049
|
a,
|
|
1050
1050
|
o,
|
|
@@ -1056,8 +1056,8 @@ function Q(t, n, i, a, o, s, c, l, f = 1) {
|
|
|
1056
1056
|
}
|
|
1057
1057
|
//#endregion
|
|
1058
1058
|
//#region src/LiquidReveal.tsx
|
|
1059
|
-
function de({ children:
|
|
1060
|
-
let x =
|
|
1059
|
+
function de({ children: t, source: n, revealKey: i = "initial", variant: a = "content", surface: o = "dark", reducedMotion: c, idleMotion: p = "still", colorFrom: g, colorTo: _, motionIntensity: v = 1, motionSpeed: y = 1, className: b = "" }) {
|
|
1060
|
+
let x = e() || c === !0, S = T(v, .25, 1.25), C = T(y, .5, 1.5), w = d(null), [E, D] = f({
|
|
1061
1061
|
width: 0,
|
|
1062
1062
|
height: 0
|
|
1063
1063
|
}), O = `liquid-reveal-${l().replace(/[^a-zA-Z0-9_-]/g, "")}`;
|
|
@@ -1074,22 +1074,22 @@ function de({ children: e, source: t, revealKey: r = "initial", variant: i = "co
|
|
|
1074
1074
|
t();
|
|
1075
1075
|
let n = new ResizeObserver(t);
|
|
1076
1076
|
return n.observe(e), () => n.disconnect();
|
|
1077
|
-
}, []), Q(w,
|
|
1078
|
-
let k = Math.max(44, E.width), A = Math.max(44, E.height), ee = Y(w, !x && p === "breathe", E.width, E.height,
|
|
1079
|
-
return /* @__PURE__ */
|
|
1077
|
+
}, []), Q(w, n, i, E.width, E.height, x, o === "material", a === "input", S);
|
|
1078
|
+
let k = Math.max(44, E.width), A = Math.max(44, E.height), ee = Y(w, !x && p === "breathe", E.width, E.height, a === "input", S, C), j = J(k, A, a === "input", ee.current, S), M = (k + 24) * (A + 24) <= r().maxFilterArea;
|
|
1079
|
+
return /* @__PURE__ */ h("div", {
|
|
1080
1080
|
ref: w,
|
|
1081
1081
|
className: `game-ui-liquid-reveal ${b}`,
|
|
1082
1082
|
style: {
|
|
1083
|
-
...
|
|
1083
|
+
...g ? { "--liquid-presence-from": g } : {},
|
|
1084
1084
|
..._ ? { "--liquid-presence-to": _ } : {}
|
|
1085
1085
|
},
|
|
1086
|
-
"data-reveal-variant":
|
|
1086
|
+
"data-reveal-variant": a,
|
|
1087
1087
|
"data-reveal-surface": o,
|
|
1088
1088
|
"data-reveal-filter": M ? "volume" : "flat",
|
|
1089
|
-
children: [/* @__PURE__ */
|
|
1089
|
+
children: [/* @__PURE__ */ m("div", {
|
|
1090
1090
|
className: "game-ui-liquid-reveal-content",
|
|
1091
|
-
children:
|
|
1092
|
-
}), E.width > 0 && /* @__PURE__ */
|
|
1091
|
+
children: t
|
|
1092
|
+
}), E.width > 0 && /* @__PURE__ */ h("svg", {
|
|
1093
1093
|
className: "game-ui-liquid-reveal-ink",
|
|
1094
1094
|
width: k,
|
|
1095
1095
|
height: A,
|
|
@@ -1097,20 +1097,20 @@ function de({ children: e, source: t, revealKey: r = "initial", variant: i = "co
|
|
|
1097
1097
|
"aria-hidden": "true",
|
|
1098
1098
|
focusable: "false",
|
|
1099
1099
|
children: [
|
|
1100
|
-
/* @__PURE__ */
|
|
1100
|
+
/* @__PURE__ */ h("defs", { children: [/* @__PURE__ */ h("linearGradient", {
|
|
1101
1101
|
id: `${O}-fill`,
|
|
1102
1102
|
x1: "0",
|
|
1103
1103
|
y1: "0",
|
|
1104
1104
|
x2: "1",
|
|
1105
1105
|
y2: "1",
|
|
1106
|
-
children: [/* @__PURE__ */
|
|
1106
|
+
children: [/* @__PURE__ */ m("stop", {
|
|
1107
1107
|
offset: "0",
|
|
1108
1108
|
stopColor: "var(--liquid-presence-from, var(--game-ui-secondary))"
|
|
1109
|
-
}), /* @__PURE__ */
|
|
1109
|
+
}), /* @__PURE__ */ m("stop", {
|
|
1110
1110
|
offset: "1",
|
|
1111
1111
|
stopColor: "var(--liquid-presence-to, var(--game-ui-secondary))"
|
|
1112
1112
|
})]
|
|
1113
|
-
}), /* @__PURE__ */
|
|
1113
|
+
}), /* @__PURE__ */ m("filter", {
|
|
1114
1114
|
id: `${O}-finish`,
|
|
1115
1115
|
x: "-12",
|
|
1116
1116
|
y: "-12",
|
|
@@ -1118,7 +1118,7 @@ function de({ children: e, source: t, revealKey: r = "initial", variant: i = "co
|
|
|
1118
1118
|
height: A + 24,
|
|
1119
1119
|
filterUnits: "userSpaceOnUse",
|
|
1120
1120
|
colorInterpolationFilters: "sRGB",
|
|
1121
|
-
children: /* @__PURE__ */
|
|
1121
|
+
children: /* @__PURE__ */ m(s, {
|
|
1122
1122
|
blur: 1.2,
|
|
1123
1123
|
contrast: 18,
|
|
1124
1124
|
gloss: 3.5,
|
|
@@ -1127,20 +1127,20 @@ function de({ children: e, source: t, revealKey: r = "initial", variant: i = "co
|
|
|
1127
1127
|
waviness: 0
|
|
1128
1128
|
})
|
|
1129
1129
|
})] }),
|
|
1130
|
-
o === "material" && /* @__PURE__ */
|
|
1130
|
+
o === "material" && /* @__PURE__ */ m("path", {
|
|
1131
1131
|
"data-reveal-body": "",
|
|
1132
1132
|
d: j.outline,
|
|
1133
1133
|
fill: `url(#${O}-fill)`
|
|
1134
1134
|
}),
|
|
1135
|
-
/* @__PURE__ */
|
|
1135
|
+
/* @__PURE__ */ h("g", {
|
|
1136
1136
|
"data-reveal-material": "",
|
|
1137
1137
|
filter: M ? `url(#${O}-finish)` : void 0,
|
|
1138
|
-
children: [/* @__PURE__ */
|
|
1138
|
+
children: [/* @__PURE__ */ m("path", {
|
|
1139
1139
|
"data-reveal-ribbon": "",
|
|
1140
1140
|
d: j.ribbon,
|
|
1141
1141
|
fillRule: "evenodd",
|
|
1142
1142
|
fill: `url(#${O}-fill)`
|
|
1143
|
-
}), /* @__PURE__ */
|
|
1143
|
+
}), /* @__PURE__ */ m("path", {
|
|
1144
1144
|
"data-reveal-outline": "",
|
|
1145
1145
|
d: j.outline,
|
|
1146
1146
|
pathLength: "1",
|
|
@@ -1258,10 +1258,10 @@ function fe({ source: e, children: t, placement: n = "top-end", onBoundsChange:
|
|
|
1258
1258
|
i,
|
|
1259
1259
|
n,
|
|
1260
1260
|
e
|
|
1261
|
-
]), s ? /* @__PURE__ */
|
|
1261
|
+
]), s ? /* @__PURE__ */ m(_, {
|
|
1262
1262
|
root: s,
|
|
1263
1263
|
preserveTabOrder: !1,
|
|
1264
|
-
children: /* @__PURE__ */
|
|
1264
|
+
children: /* @__PURE__ */ m("div", {
|
|
1265
1265
|
ref: a,
|
|
1266
1266
|
className: "game-ui-liquid-anchor",
|
|
1267
1267
|
style: {
|