@kakadu/components 6.2.0 → 6.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/build/components/click-ripples.js +1 -1
- package/build/components/click-ripples.mjs +50 -45
- package/build/components/combobox.js +1 -1
- package/build/components/combobox.mjs +161 -159
- package/build/components/hover-gradient.js +1 -1
- package/build/components/hover-gradient.mjs +49 -42
- package/build/components/modal.js +1 -1
- package/build/components/modal.mjs +86 -85
- package/build/components/moving-gradients.js +1 -1
- package/build/components/moving-gradients.mjs +80 -70
- package/build/components/moving-stars.js +1 -1
- package/build/components/moving-stars.mjs +77 -74
- package/build/components/notification.js +1 -1
- package/build/components/notification.mjs +2 -2
- package/build/components/popover-menu.js +1 -1
- package/build/components/popover-menu.mjs +131 -129
- package/build/components/popover.js +1 -1
- package/build/components/popover.mjs +82 -73
- package/build/hooks/use-is-document-focused.js +1 -1
- package/build/hooks/use-is-document-focused.mjs +30 -14
- package/build/index.d.ts +2 -0
- package/build/index.js +1 -1
- package/build/index.mjs +19 -17
- package/build/utilities/listeners.d.ts +5 -0
- package/build/utilities/listeners.js +1 -0
- package/build/utilities/listeners.mjs +16 -0
- package/package.json +1 -1
|
@@ -1,54 +1,61 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { cx as
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { j as p } from "../jsx-runtime-B4hRZ52C.mjs";
|
|
2
|
+
import { useRef as v, useState as x, useEffect as $ } from "react";
|
|
3
|
+
import { cx as k } from "@kuma-ui/core";
|
|
4
|
+
import h from "../hooks/use-is-in-view.mjs";
|
|
5
|
+
import B from "../utilities/listeners.mjs";
|
|
6
|
+
const H = "kakadu-components-2608453841", N = B((e) => {
|
|
7
|
+
window.addEventListener("mousemove", e, {
|
|
8
|
+
passive: !0
|
|
9
|
+
});
|
|
10
|
+
}, (e) => {
|
|
11
|
+
window.removeEventListener("mousemove", e);
|
|
12
|
+
});
|
|
13
|
+
function P({
|
|
14
|
+
isActive: e = !0,
|
|
15
|
+
size: L = 200,
|
|
16
|
+
className: E,
|
|
17
|
+
...w
|
|
11
18
|
}) {
|
|
12
|
-
const
|
|
13
|
-
return
|
|
14
|
-
if (!
|
|
15
|
-
|
|
19
|
+
const s = v(null), o = h(s), n = v(null), [g, r] = x(!1), [i, b] = x();
|
|
20
|
+
return $(() => {
|
|
21
|
+
if (!e || !o) {
|
|
22
|
+
r(!1);
|
|
16
23
|
return;
|
|
17
24
|
}
|
|
18
|
-
const c =
|
|
25
|
+
const c = s.current;
|
|
19
26
|
if (!c)
|
|
20
27
|
return;
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
if (!
|
|
28
|
+
n.current || (n.current = c.parentElement);
|
|
29
|
+
const t = n.current;
|
|
30
|
+
if (!t)
|
|
24
31
|
return;
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
32
|
+
const j = N((l) => {
|
|
33
|
+
const I = l.target;
|
|
34
|
+
if (!t.contains(I))
|
|
28
35
|
return;
|
|
29
|
-
const
|
|
30
|
-
clientX:
|
|
31
|
-
clientY:
|
|
32
|
-
} =
|
|
33
|
-
left:
|
|
34
|
-
right:
|
|
35
|
-
top:
|
|
36
|
-
bottom:
|
|
37
|
-
} =
|
|
38
|
-
|
|
39
|
-
}, m = () => {
|
|
40
|
-
|
|
36
|
+
const M = t.getBoundingClientRect(), {
|
|
37
|
+
clientX: u,
|
|
38
|
+
clientY: a
|
|
39
|
+
} = l, {
|
|
40
|
+
left: f,
|
|
41
|
+
right: V,
|
|
42
|
+
top: d,
|
|
43
|
+
bottom: y
|
|
44
|
+
} = M;
|
|
45
|
+
u > f && u < V && a > d && a < y && (r(!0), b([u - f, a - d]));
|
|
46
|
+
}), m = () => {
|
|
47
|
+
r(!1);
|
|
41
48
|
};
|
|
42
|
-
return
|
|
43
|
-
|
|
49
|
+
return t.addEventListener("mouseleave", m), () => {
|
|
50
|
+
j(), t.removeEventListener("mouseleave", m);
|
|
44
51
|
};
|
|
45
|
-
}, [
|
|
46
|
-
"--size": `${
|
|
47
|
-
"--offset-x": `${
|
|
48
|
-
"--offset-y": `${
|
|
49
|
-
}, className:
|
|
52
|
+
}, [e, o]), /* @__PURE__ */ p.jsx("div", { ...w, ref: s, className: k("kakadu-components-1237006455", E), children: i && o ? /* @__PURE__ */ p.jsx("div", { style: {
|
|
53
|
+
"--size": `${L}px`,
|
|
54
|
+
"--offset-x": `${i[0]}px`,
|
|
55
|
+
"--offset-y": `${i[1]}px`
|
|
56
|
+
}, className: k("kakadu-components-611160091", g && "kakadu-components-3627966847") }) : null });
|
|
50
57
|
}
|
|
51
58
|
export {
|
|
52
|
-
|
|
53
|
-
|
|
59
|
+
P as default,
|
|
60
|
+
H as normalBlendStyles
|
|
54
61
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("../jsx-runtime-BB_1_6y_.js"),e=require("react"),E=require("@kuma-ui/core"),P=require("react-dom"),$=require("../focus-trap-react-B7f3iC5h.js"),B=require("../utilities/listeners.js"),D=require("./text-button.js"),T=require("./decorators.js"),_=require("./flex.js"),K=require("./atom.js"),y=require("./text.js"),z=B.default(s=>{window.addEventListener("keydown",s)},s=>{window.removeEventListener("keydown",s)}),S=e.createContext({isVisible:!1,isInteractive:!1}),{Provider:G}=S;function L(){return e.useContext(S)}function J(){const{isInteractive:s,close:r}=L(),a=e.useCallback(()=>{r==null||r()},[r]);return o.jsxRuntimeExports.jsx("div",{className:"kakadu-components-2566044647",children:o.jsxRuntimeExports.jsx(D.default,{iconLeft:"times",label:"Close",disabled:!s,onClick:a})})}function Q(s){return o.jsxRuntimeExports.jsx(_.default,{gap:2,...s})}function U({as:s,className:r,...a}){return o.jsxRuntimeExports.jsx(y.Heading,{...a,as:s??y.defaultHeadingElementType,className:E.cx("kakadu-components-4275938488",r)})}function V({as:s,...r}){return o.jsxRuntimeExports.jsx(_.default,{direction:"row",gap:1,preset:"end",...r,as:s??K.defaultAtomElementType})}function X({root:s,outerDecorators:r=[],innerDecorators:a=[],label:k,maxWidth:c,className:f,isVisible:n,isFullWidth:i=!1,shouldCloseOnOutsideClick:x=!0,shouldCloseOnEscapePress:m=!0,showCloseButton:v=!0,onClose:l,children:d}){const R=e.useRef(null),p=e.useRef(null),[q,N]=e.useState(!1),[u,j]=e.useState(!1),w=e.useCallback(t=>{R.current=t,j(!1)},[]),M=e.useRef(null),g=e.useCallback(t=>{t&&(M.current=t)},[]),[b,h]=e.useState(n??!1),A=e.useMemo(()=>({isVisible:b,isInteractive:u,setInitialFocus:g,close:w}),[b,u,g,w]);e.useEffect(()=>{if(n){const t=setTimeout(()=>{j(!0)},100);return()=>{clearTimeout(t)}}j(!1)},[n]),e.useEffect(()=>{n&&(N(!0),h(!0))},[n]),e.useEffect(()=>{const t=p.current;if(n&&x&&t){const I=H=>{t===H.target&&j(!1)};return t.addEventListener("click",I),()=>{t.removeEventListener("click",I)}}},[n,x]),e.useEffect(()=>{if(!(!n||!m))return z(t=>{t.key==="Escape"&&j(!1)})},[n,m]),e.useEffect(()=>{if(q&&!u){const t=setTimeout(()=>{h(!1),l==null||l(R.current??void 0)},370);return()=>{clearTimeout(t)}}},[q,u,l]);const F=e.useMemo(()=>({initialFocus:()=>M.current??void 0,onActivate:()=>{var t;return(t=M.current)==null?void 0:t.focus()}}),[]);if(!b)return null;const C=o.jsxRuntimeExports.jsx(T.default,{decorators:r,children:o.jsxRuntimeExports.jsx("div",{"aria-hidden":!u,style:{"--max-width":c?`${c}px`:void 0},className:E.cx("kakadu-components-4119461136",u&&"kakadu-components-2522346797",f),children:o.jsxRuntimeExports.jsx(T.default,{decorators:a,children:o.jsxRuntimeExports.jsx($.focusTrapReactExports.FocusTrap,{active:u,focusTrapOptions:F,children:o.jsxRuntimeExports.jsx("div",{ref:p,className:"kakadu-components-4011815997",children:o.jsxRuntimeExports.jsx("div",{role:"dialog","aria-modal":"true","aria-label":k??"Modal",className:E.cx("kakadu-components-3324483532",i&&"kakadu-components-3799971070",u&&"kakadu-components-968755580"),children:o.jsxRuntimeExports.jsxs(G,{value:A,children:[v?o.jsxRuntimeExports.jsx(J,{}):null,o.jsxRuntimeExports.jsx("div",{className:E.cx("kakadu-components-633990035",i&&"kakadu-components-171969824"),children:d})]})})})})})})});return s?P.createPortal(C,s):C}function Y(s,r){const[a,k]=e.useState(!1),[c,f]=e.useState(!1),n=e.useRef(void 0),i=e.useRef(void 0),x=e.useCallback(async()=>(i.current=void 0,k(!0),f(!0),new Promise(d=>{n.current=d})),[]),m=e.useCallback(d=>{i.current=d,f(!1)},[]),v=e.useCallback(d=>{var p;const R=d??i.current;i.current=void 0,(p=n.current)==null||p.call(n,R),n.current=void 0,k(!1),f(!1)},[]),l=e.useMemo(()=>a?o.jsxRuntimeExports.jsx(s,{...r,isVisible:c,onClose:v}):null,[a,s,r,c,v]);return e.useMemo(()=>({isVisible:c,show:x,close:m,modal:l}),[c,x,m,l])}exports.ModalActions=V;exports.ModalContent=Q;exports.ModalHeading=U;exports.default=X;exports.useModal=Y;exports.useModalContext=L;
|
|
@@ -1,55 +1,60 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { cx as
|
|
4
|
-
import { createPortal as
|
|
5
|
-
import { f as
|
|
6
|
-
import
|
|
1
|
+
import { j as o } from "../jsx-runtime-B4hRZ52C.mjs";
|
|
2
|
+
import { createContext as $, useRef as j, useState as w, useCallback as d, useMemo as E, useEffect as v, useContext as q } from "react";
|
|
3
|
+
import { cx as T } from "@kuma-ui/core";
|
|
4
|
+
import { createPortal as z } from "react-dom";
|
|
5
|
+
import { f as G } from "../focus-trap-react-Dr3BYLw6.mjs";
|
|
6
|
+
import J from "../utilities/listeners.mjs";
|
|
7
|
+
import Q from "./text-button.mjs";
|
|
7
8
|
import A from "./decorators.mjs";
|
|
8
9
|
import H from "./flex.mjs";
|
|
9
|
-
import { defaultAtomElementType as
|
|
10
|
-
import { Heading as
|
|
11
|
-
const
|
|
10
|
+
import { defaultAtomElementType as U } from "./atom.mjs";
|
|
11
|
+
import { Heading as V, defaultHeadingElementType as X } from "./text.mjs";
|
|
12
|
+
const Y = J((t) => {
|
|
13
|
+
window.addEventListener("keydown", t);
|
|
14
|
+
}, (t) => {
|
|
15
|
+
window.removeEventListener("keydown", t);
|
|
16
|
+
}), B = $({
|
|
12
17
|
isVisible: !1,
|
|
13
18
|
isInteractive: !1
|
|
14
19
|
}), {
|
|
15
|
-
Provider:
|
|
20
|
+
Provider: Z
|
|
16
21
|
} = B;
|
|
17
|
-
function
|
|
18
|
-
return
|
|
22
|
+
function _() {
|
|
23
|
+
return q(B);
|
|
19
24
|
}
|
|
20
|
-
function
|
|
25
|
+
function W() {
|
|
21
26
|
const {
|
|
22
|
-
isInteractive:
|
|
23
|
-
close:
|
|
24
|
-
} =
|
|
25
|
-
|
|
26
|
-
}, [
|
|
27
|
-
return /* @__PURE__ */
|
|
27
|
+
isInteractive: t,
|
|
28
|
+
close: r
|
|
29
|
+
} = _(), s = d(() => {
|
|
30
|
+
r == null || r();
|
|
31
|
+
}, [r]);
|
|
32
|
+
return /* @__PURE__ */ o.jsx("div", { className: "kakadu-components-2566044647", children: /* @__PURE__ */ o.jsx(Q, { iconLeft: "times", label: "Close", disabled: !t, onClick: s }) });
|
|
28
33
|
}
|
|
29
|
-
function
|
|
30
|
-
return /* @__PURE__ */
|
|
34
|
+
function le(t) {
|
|
35
|
+
return /* @__PURE__ */ o.jsx(H, { gap: 2, ...t });
|
|
31
36
|
}
|
|
32
|
-
function
|
|
33
|
-
as:
|
|
34
|
-
className:
|
|
35
|
-
...
|
|
37
|
+
function de({
|
|
38
|
+
as: t,
|
|
39
|
+
className: r,
|
|
40
|
+
...s
|
|
36
41
|
}) {
|
|
37
|
-
return /* @__PURE__ */
|
|
42
|
+
return /* @__PURE__ */ o.jsx(V, { ...s, as: t ?? X, className: T("kakadu-components-4275938488", r) });
|
|
38
43
|
}
|
|
39
|
-
function
|
|
40
|
-
as:
|
|
41
|
-
...
|
|
44
|
+
function fe({
|
|
45
|
+
as: t,
|
|
46
|
+
...r
|
|
42
47
|
}) {
|
|
43
|
-
return /* @__PURE__ */
|
|
48
|
+
return /* @__PURE__ */ o.jsx(H, { direction: "row", gap: 1, preset: "end", ...r, as: t ?? U });
|
|
44
49
|
}
|
|
45
|
-
function
|
|
46
|
-
root:
|
|
47
|
-
outerDecorators:
|
|
48
|
-
innerDecorators:
|
|
49
|
-
label:
|
|
50
|
+
function me({
|
|
51
|
+
root: t,
|
|
52
|
+
outerDecorators: r = [],
|
|
53
|
+
innerDecorators: s = [],
|
|
54
|
+
label: h,
|
|
50
55
|
maxWidth: c,
|
|
51
56
|
className: f,
|
|
52
|
-
isVisible:
|
|
57
|
+
isVisible: n,
|
|
53
58
|
isFullWidth: i = !1,
|
|
54
59
|
shouldCloseOnOutsideClick: m = !0,
|
|
55
60
|
shouldCloseOnEscapePress: p = !0,
|
|
@@ -57,18 +62,18 @@ function le({
|
|
|
57
62
|
onClose: u,
|
|
58
63
|
children: l
|
|
59
64
|
}) {
|
|
60
|
-
const M = j(null), x = j(null), [
|
|
65
|
+
const M = j(null), x = j(null), [R, P] = w(!1), [a, k] = w(!1), L = d((e) => {
|
|
61
66
|
M.current = e, k(!1);
|
|
62
|
-
}, []),
|
|
63
|
-
e && (
|
|
64
|
-
}, []), [y,
|
|
67
|
+
}, []), g = j(null), N = d((e) => {
|
|
68
|
+
e && (g.current = e);
|
|
69
|
+
}, []), [y, b] = w(n ?? !1), D = E(() => ({
|
|
65
70
|
isVisible: y,
|
|
66
71
|
isInteractive: a,
|
|
67
|
-
setInitialFocus:
|
|
68
|
-
close:
|
|
69
|
-
}), [y, a,
|
|
72
|
+
setInitialFocus: N,
|
|
73
|
+
close: L
|
|
74
|
+
}), [y, a, N, L]);
|
|
70
75
|
v(() => {
|
|
71
|
-
if (
|
|
76
|
+
if (n) {
|
|
72
77
|
const e = setTimeout(() => {
|
|
73
78
|
k(!0);
|
|
74
79
|
}, 100);
|
|
@@ -77,65 +82,61 @@ function le({
|
|
|
77
82
|
};
|
|
78
83
|
}
|
|
79
84
|
k(!1);
|
|
80
|
-
}, [
|
|
81
|
-
|
|
82
|
-
}, [
|
|
85
|
+
}, [n]), v(() => {
|
|
86
|
+
n && (P(!0), b(!0));
|
|
87
|
+
}, [n]), v(() => {
|
|
83
88
|
const e = x.current;
|
|
84
|
-
if (
|
|
85
|
-
const
|
|
86
|
-
e ===
|
|
89
|
+
if (n && m && e) {
|
|
90
|
+
const C = (S) => {
|
|
91
|
+
e === S.target && k(!1);
|
|
87
92
|
};
|
|
88
|
-
return e.addEventListener("click",
|
|
89
|
-
e.removeEventListener("click",
|
|
93
|
+
return e.addEventListener("click", C), () => {
|
|
94
|
+
e.removeEventListener("click", C);
|
|
90
95
|
};
|
|
91
96
|
}
|
|
92
|
-
}, [
|
|
93
|
-
if (!
|
|
94
|
-
return
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
window.removeEventListener("keydown", e);
|
|
100
|
-
};
|
|
101
|
-
}, [t, p]), v(() => {
|
|
102
|
-
if (L && !a) {
|
|
97
|
+
}, [n, m]), v(() => {
|
|
98
|
+
if (!(!n || !p))
|
|
99
|
+
return Y((e) => {
|
|
100
|
+
e.key === "Escape" && k(!1);
|
|
101
|
+
});
|
|
102
|
+
}, [n, p]), v(() => {
|
|
103
|
+
if (R && !a) {
|
|
103
104
|
const e = setTimeout(() => {
|
|
104
|
-
|
|
105
|
+
b(!1), u == null || u(M.current ?? void 0);
|
|
105
106
|
}, 370);
|
|
106
107
|
return () => {
|
|
107
108
|
clearTimeout(e);
|
|
108
109
|
};
|
|
109
110
|
}
|
|
110
|
-
}, [
|
|
111
|
-
const
|
|
112
|
-
initialFocus: () =>
|
|
111
|
+
}, [R, a, u]);
|
|
112
|
+
const K = E(() => ({
|
|
113
|
+
initialFocus: () => g.current ?? void 0,
|
|
113
114
|
onActivate: () => {
|
|
114
115
|
var e;
|
|
115
|
-
return (e =
|
|
116
|
+
return (e = g.current) == null ? void 0 : e.focus();
|
|
116
117
|
}
|
|
117
118
|
}), []);
|
|
118
119
|
if (!y)
|
|
119
120
|
return null;
|
|
120
|
-
const
|
|
121
|
+
const F = /* @__PURE__ */ o.jsx(A, { decorators: r, children: /* @__PURE__ */ o.jsx("div", { "aria-hidden": !a, style: {
|
|
121
122
|
"--max-width": c ? `${c}px` : void 0
|
|
122
|
-
}, className:
|
|
123
|
-
I ? /* @__PURE__ */
|
|
124
|
-
/* @__PURE__ */
|
|
123
|
+
}, className: T("kakadu-components-4119461136", a && "kakadu-components-2522346797", f), children: /* @__PURE__ */ o.jsx(A, { decorators: s, children: /* @__PURE__ */ o.jsx(G.FocusTrap, { active: a, focusTrapOptions: K, children: /* @__PURE__ */ o.jsx("div", { ref: x, className: "kakadu-components-4011815997", children: /* @__PURE__ */ o.jsx("div", { role: "dialog", "aria-modal": "true", "aria-label": h ?? "Modal", className: T("kakadu-components-3324483532", i && "kakadu-components-3799971070", a && "kakadu-components-968755580"), children: /* @__PURE__ */ o.jsxs(Z, { value: D, children: [
|
|
124
|
+
I ? /* @__PURE__ */ o.jsx(W, {}) : null,
|
|
125
|
+
/* @__PURE__ */ o.jsx("div", { className: T("kakadu-components-633990035", i && "kakadu-components-171969824"), children: l })
|
|
125
126
|
] }) }) }) }) }) }) });
|
|
126
|
-
return
|
|
127
|
+
return t ? z(F, t) : F;
|
|
127
128
|
}
|
|
128
|
-
function
|
|
129
|
-
const [
|
|
130
|
-
|
|
129
|
+
function pe(t, r) {
|
|
130
|
+
const [s, h] = w(!1), [c, f] = w(!1), n = j(void 0), i = j(void 0), m = d(async () => (i.current = void 0, h(!0), f(!0), new Promise((l) => {
|
|
131
|
+
n.current = l;
|
|
131
132
|
})), []), p = d((l) => {
|
|
132
133
|
i.current = l, f(!1);
|
|
133
134
|
}, []), I = d((l) => {
|
|
134
135
|
var x;
|
|
135
136
|
const M = l ?? i.current;
|
|
136
|
-
i.current = void 0, (x =
|
|
137
|
-
}, []), u =
|
|
138
|
-
return
|
|
137
|
+
i.current = void 0, (x = n.current) == null || x.call(n, M), n.current = void 0, h(!1), f(!1);
|
|
138
|
+
}, []), u = E(() => s ? /* @__PURE__ */ o.jsx(t, { ...r, isVisible: c, onClose: I }) : null, [s, t, r, c, I]);
|
|
139
|
+
return E(() => ({
|
|
139
140
|
isVisible: c,
|
|
140
141
|
show: m,
|
|
141
142
|
close: p,
|
|
@@ -143,10 +144,10 @@ function de(o, s) {
|
|
|
143
144
|
}), [c, m, p, u]);
|
|
144
145
|
}
|
|
145
146
|
export {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
147
|
+
fe as ModalActions,
|
|
148
|
+
le as ModalContent,
|
|
149
|
+
de as ModalHeading,
|
|
150
|
+
me as default,
|
|
151
|
+
pe as useModal,
|
|
152
|
+
_ as useModalContext
|
|
152
153
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const N=require("../jsx-runtime-BB_1_6y_.js"),o=require("react"),O=require("@kuma-ui/core"),V=require("../hooks/use-is-in-view.js"),T=require("../hooks/use-is-document-focused.js"),B=require("../utilities/listeners.js"),J=B.default(m=>{window.addEventListener("resize",m,{passive:!0})},m=>{window.removeEventListener("resize",m)}),K=["rgb(46, 75, 164)","rgb(58, 125, 159)","rgb(42, 81, 142)","rgb(48, 132, 168)","rgb(45, 64, 157)"];function Q(m){return m.map(C=>{var t;const[M,q,R]=((t=C.match(/\d+/g))==null?void 0:t.map(Number))??[];return[M,q,R]})}function U({className:m,colors:C=K,maximumGradientsCount:M=10,speed:q=1,opacity:R=.2}){const t=o.useRef(null),[h,H]=o.useState(),[g,j]=o.useState(0),[p,F]=o.useState(0),w=o.useMemo(()=>Q(C),[C]),I=o.useMemo(()=>w.length,[w]),y=o.useCallback(()=>{const n=Math.random(),b=w[Math.floor(I*n)],u=g*1.25,i=g*.25,s=p*1.25,e=p*.25,a=u*Math.random()-i,c=s*Math.random()-e,r=Math.max(u,s);return{color:b,size:r*n+r/2,opacity:0,speed:Math.max(.1,n/2*q),startPosition:[a,c],currentPosition:[a,c],targetPosition:[u*Math.random()-i,s*Math.random()-e]}},[w,I,g,p,q]),L=V.default(t),W=T.default(),k=!L||!W,G=o.useRef(Array.from({length:M}).map(()=>y()));return o.useEffect(()=>{if(k||!h)return;let v=!1,n;function b(){if(v||!h)return;const i=G.current;h.clearRect(0,0,g,p);for(let s=i.length;s;s-=1){const e=i[s-1],[a,c]=e.startPosition,[r,l]=e.currentPosition,[d,f]=e.targetPosition;let x=!0;if(a>d?r>d&&(x=!1):r<d&&(x=!1),c>f?l>f&&(x=!1):l<f&&(x=!1),x){i.splice(s-1,1);continue}const _=(a+d)/2-a,$=r-a,A=(c+f)/2-c,D=l-c,z=($/(_||1)+D/(A||1))/2;e.opacity=z>1?2-z:z;const S=e.size/2,X=h.createRadialGradient(r,l,S,r,l,0);if(X.addColorStop(0,`rgba(${e.color.join(",")},0)`),X.addColorStop(1,`rgba(${e.color.join(",")},${e.opacity})`),h.fillStyle=X,h.fillRect(r-S,l-S,e.size,e.size),r!==d){const Y=Math.abs(a-d),E=Math.abs(c-f),P=Math.min(1,Y/E);r<d?e.currentPosition[0]+=e.speed*P:e.currentPosition[0]-=e.speed*P}if(l!==f){const Y=Math.abs(a-d),E=Math.abs(c-f),P=Math.min(1,E/Y);l<f?e.currentPosition[1]+=e.speed*P:e.currentPosition[1]-=e.speed*P}}n=requestAnimationFrame(b)}n=requestAnimationFrame(b);const u=setInterval(()=>{const i=G.current;let s=i.length,e=M-s;if(e>0)for(;e;)i.push(y()),e-=1,s+=1},1500);return()=>{v=!0,n&&cancelAnimationFrame(n),clearInterval(u)}},[k,h,g,p,M,y]),o.useEffect(()=>{if(t.current){const v=t.current.getContext("2d");v&&H(v),j(t.current.offsetWidth),F(t.current.offsetHeight);const n=()=>{t.current&&(j(t.current.offsetWidth),F(t.current.offsetHeight))},b=J(n),u=new ResizeObserver(n);return u.observe(t.current),()=>{b(),u.disconnect()}}},[t]),N.jsxRuntimeExports.jsx("canvas",{ref:t,"aria-hidden":!0,role:"presentation",width:g,height:p,style:{"--opacity":R},className:O.cx("kakadu-components-4131181690",m)})}exports.default=U;
|
|
@@ -1,90 +1,100 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { useRef as
|
|
1
|
+
import { j as J } from "../jsx-runtime-B4hRZ52C.mjs";
|
|
2
|
+
import { useRef as q, useState as I, useMemo as A, useCallback as K, useEffect as S } from "react";
|
|
3
3
|
import { cx as Q } from "@kuma-ui/core";
|
|
4
4
|
import T from "../hooks/use-is-in-view.mjs";
|
|
5
5
|
import U from "../hooks/use-is-document-focused.mjs";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
import Z from "../utilities/listeners.mjs";
|
|
7
|
+
const _ = Z((f) => {
|
|
8
|
+
window.addEventListener("resize", f, {
|
|
9
|
+
passive: !0
|
|
10
|
+
});
|
|
11
|
+
}, (f) => {
|
|
12
|
+
window.removeEventListener("resize", f);
|
|
13
|
+
}), tt = ["rgb(46, 75, 164)", "rgb(58, 125, 159)", "rgb(42, 81, 142)", "rgb(48, 132, 168)", "rgb(45, 64, 157)"];
|
|
14
|
+
function et(f) {
|
|
15
|
+
return f.map((C) => {
|
|
16
|
+
var e;
|
|
17
|
+
const [b, P, z] = ((e = C.match(/\d+/g)) == null ? void 0 : e.map(Number)) ?? [];
|
|
18
|
+
return [b, P, z];
|
|
12
19
|
});
|
|
13
20
|
}
|
|
14
|
-
function
|
|
15
|
-
className:
|
|
16
|
-
colors:
|
|
17
|
-
maximumGradientsCount:
|
|
18
|
-
speed:
|
|
19
|
-
opacity:
|
|
21
|
+
function ct({
|
|
22
|
+
className: f,
|
|
23
|
+
colors: C = tt,
|
|
24
|
+
maximumGradientsCount: b = 10,
|
|
25
|
+
speed: P = 1,
|
|
26
|
+
opacity: z = 0.2
|
|
20
27
|
}) {
|
|
21
|
-
const
|
|
22
|
-
const
|
|
28
|
+
const e = q(null), [m, k] = I(), [h, L] = I(0), [p, j] = I(0), w = A(() => et(C), [C]), G = A(() => w.length, [w]), y = K(() => {
|
|
29
|
+
const n = Math.random(), v = w[Math.floor(G * n)], c = h * 1.25, o = h * 0.25, r = p * 1.25, t = p * 0.25, i = c * Math.random() - o, a = r * Math.random() - t, s = Math.max(c, r);
|
|
23
30
|
return {
|
|
24
|
-
color:
|
|
25
|
-
size: s *
|
|
31
|
+
color: v,
|
|
32
|
+
size: s * n + s / 2,
|
|
26
33
|
opacity: 0,
|
|
27
|
-
speed: Math.max(0.1,
|
|
28
|
-
startPosition: [
|
|
29
|
-
currentPosition: [
|
|
30
|
-
targetPosition: [
|
|
34
|
+
speed: Math.max(0.1, n / 2 * P),
|
|
35
|
+
startPosition: [i, a],
|
|
36
|
+
currentPosition: [i, a],
|
|
37
|
+
targetPosition: [c * Math.random() - o, r * Math.random() - t]
|
|
31
38
|
};
|
|
32
|
-
}, [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
}, [w, G, h, p, P]), D = T(e), $ = U(), H = !D || !$, W = q(Array.from({
|
|
40
|
+
length: b
|
|
41
|
+
}).map(() => y()));
|
|
42
|
+
return S(() => {
|
|
43
|
+
if (H || !m)
|
|
44
|
+
return;
|
|
45
|
+
let g = !1, n;
|
|
46
|
+
function v() {
|
|
47
|
+
if (g || !m)
|
|
48
|
+
return;
|
|
49
|
+
const o = W.current;
|
|
50
|
+
m.clearRect(0, 0, h, p);
|
|
51
|
+
for (let r = o.length; r; r -= 1) {
|
|
52
|
+
const t = o[r - 1], [i, a] = t.startPosition, [s, l] = t.currentPosition, [u, d] = t.targetPosition;
|
|
53
|
+
let M = !0;
|
|
54
|
+
if (i > u ? s > u && (M = !1) : s < u && (M = !1), a > d ? l > d && (M = !1) : l < d && (M = !1), M) {
|
|
55
|
+
o.splice(r - 1, 1);
|
|
56
|
+
continue;
|
|
43
57
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
const q = t.size / 2, w = m.createRadialGradient(a, c, q, a, c, 0);
|
|
55
|
-
if (w.addColorStop(0, `rgba(${t.color.join(",")},0)`), w.addColorStop(1, `rgba(${t.color.join(",")},${t.opacity})`), m.fillStyle = w, m.fillRect(a - q, c - q, t.size, t.size), a !== l) {
|
|
56
|
-
const A = Math.abs(r - l), R = Math.abs(s - u), x = Math.min(1, A / R);
|
|
57
|
-
a < l ? t.currentPosition[0] += t.speed * x : t.currentPosition[0] -= t.speed * x;
|
|
58
|
-
}
|
|
59
|
-
if (c !== u) {
|
|
60
|
-
const A = Math.abs(r - l), R = Math.abs(s - u), x = Math.min(1, R / A);
|
|
61
|
-
c < u ? t.currentPosition[1] += t.speed * x : t.currentPosition[1] -= t.speed * x;
|
|
62
|
-
}
|
|
58
|
+
const N = (i + u) / 2 - i, V = s - i, O = (a + d) / 2 - a, B = l - a, R = (V / (N || 1) + B / (O || 1)) / 2;
|
|
59
|
+
t.opacity = R > 1 ? 2 - R : R;
|
|
60
|
+
const X = t.size / 2, Y = m.createRadialGradient(s, l, X, s, l, 0);
|
|
61
|
+
if (Y.addColorStop(0, `rgba(${t.color.join(",")},0)`), Y.addColorStop(1, `rgba(${t.color.join(",")},${t.opacity})`), m.fillStyle = Y, m.fillRect(s - X, l - X, t.size, t.size), s !== u) {
|
|
62
|
+
const E = Math.abs(i - u), F = Math.abs(a - d), x = Math.min(1, E / F);
|
|
63
|
+
s < u ? t.currentPosition[0] += t.speed * x : t.currentPosition[0] -= t.speed * x;
|
|
64
|
+
}
|
|
65
|
+
if (l !== d) {
|
|
66
|
+
const E = Math.abs(i - u), F = Math.abs(a - d), x = Math.min(1, F / E);
|
|
67
|
+
l < d ? t.currentPosition[1] += t.speed * x : t.currentPosition[1] -= t.speed * x;
|
|
63
68
|
}
|
|
64
|
-
o = requestAnimationFrame(g);
|
|
65
69
|
}
|
|
70
|
+
n = requestAnimationFrame(v);
|
|
66
71
|
}
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
i.push(F()), e -= 1, d += 1;
|
|
72
|
+
n = requestAnimationFrame(v);
|
|
73
|
+
const c = setInterval(() => {
|
|
74
|
+
const o = W.current;
|
|
75
|
+
let r = o.length, t = b - r;
|
|
76
|
+
if (t > 0)
|
|
77
|
+
for (; t; )
|
|
78
|
+
o.push(y()), t -= 1, r += 1;
|
|
75
79
|
}, 1500);
|
|
76
80
|
return () => {
|
|
77
|
-
|
|
81
|
+
g = !0, n && cancelAnimationFrame(n), clearInterval(c);
|
|
78
82
|
};
|
|
79
|
-
}, [
|
|
80
|
-
if (
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
+
}, [H, m, h, p, b, y]), S(() => {
|
|
84
|
+
if (e.current) {
|
|
85
|
+
const g = e.current.getContext("2d");
|
|
86
|
+
g && k(g), L(e.current.offsetWidth), j(e.current.offsetHeight);
|
|
87
|
+
const n = () => {
|
|
88
|
+
e.current && (L(e.current.offsetWidth), j(e.current.offsetHeight));
|
|
89
|
+
}, v = _(n), c = new ResizeObserver(n);
|
|
90
|
+
return c.observe(e.current), () => {
|
|
91
|
+
v(), c.disconnect();
|
|
92
|
+
};
|
|
83
93
|
}
|
|
84
|
-
}, [
|
|
85
|
-
"--opacity":
|
|
86
|
-
}, className: Q("kakadu-components-4131181690",
|
|
94
|
+
}, [e]), /* @__PURE__ */ J.jsx("canvas", { ref: e, "aria-hidden": !0, role: "presentation", width: h, height: p, style: {
|
|
95
|
+
"--opacity": z
|
|
96
|
+
}, className: Q("kakadu-components-4131181690", f) });
|
|
87
97
|
}
|
|
88
98
|
export {
|
|
89
|
-
|
|
99
|
+
ct as default
|
|
90
100
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const T=require("../jsx-runtime-BB_1_6y_.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const T=require("../jsx-runtime-BB_1_6y_.js"),o=require("react"),B=require("@kuma-ui/core"),G=require("../hooks/use-is-in-view.js"),J=require("../hooks/use-is-document-focused.js"),K=require("../utilities/listeners.js"),Q=K.default(l=>{window.addEventListener("resize",l,{passive:!0})},l=>{window.removeEventListener("resize",l)});function U({color:l,opacity:H,className:W,minimumSize:X=1,maximumSize:Y=5,maximumStarsCount:q=50,speed:E=1,hasMask:_=!1}){const t=o.useRef(null),[n,j]=o.useState(),[h,I]=o.useState(0),[v,F]=o.useState(0),C=o.useCallback(()=>{const i=h*1.5,s=h*.25,d=v*1.5,a=v*.25,x=i*Math.random()-s,r=d*Math.random()-a;return{size:Math.max(X,Y*Math.random()),opacity:0,speed:Math.max(.1,Math.random()/2*E),startPosition:[x,r],currentPosition:[x,r],targetPosition:[i*Math.random()-s,d*Math.random()-a]}},[h,v,X,Y,E]),w=o.useCallback(()=>l??(t.current?getComputedStyle(t.current).color:"#000"),[l,t]),L=G.default(t),D=J.default(),z=!L||!D,A=o.useRef(Array.from({length:q}).map(()=>C()));return o.useEffect(()=>{if(z||!n)return;let i=!1,s,d=w();function a(){if(i||!n)return;const r=A.current;n.clearRect(0,0,h,v);for(let f=r.length;f;f-=1){const e=r[f-1],[p,g]=e.startPosition,[m,M]=e.currentPosition,[c,u]=e.targetPosition;let P=!0;if(p>c?m>c&&(P=!1):m<c&&(P=!1),g>u?M>u&&(P=!1):M<u&&(P=!1),P){r.splice(f-1,1);continue}const O=(p+c)/2-p,V=m-p,$=(g+u)/2-g,N=M-g,y=(V/(O||1)+N/($||1))/2;e.opacity=y>1?2-y:y;const S=e.size/2;if(n.beginPath(),n.arc(m-S,M-S,S,0,2*Math.PI,!1),n.globalAlpha=e.opacity,n.fillStyle=d,n.fill(),m!==c){const k=Math.abs(p-c),R=Math.abs(g-u),b=Math.min(1,k/R);m<c?e.currentPosition[0]+=e.speed*b:e.currentPosition[0]-=e.speed*b}if(M!==u){const k=Math.abs(p-c),R=Math.abs(g-u),b=Math.min(1,R/k);M<u?e.currentPosition[1]+=e.speed*b:e.currentPosition[1]-=e.speed*b}}s=requestAnimationFrame(a)}s=requestAnimationFrame(a);const x=setInterval(()=>{d=w();const r=A.current;let f=r.length,e=q-f;if(e>0)for(;e;)r.push(C()),e-=1,f+=1},500);return()=>{i=!0,s&&cancelAnimationFrame(s),clearInterval(x)}},[z,n,w,h,v,q,C]),o.useEffect(()=>{if(t.current){const i=t.current.getContext("2d");i&&j(i),I(t.current.offsetWidth),F(t.current.offsetHeight);const s=()=>{t.current&&(I(t.current.offsetWidth),F(t.current.offsetHeight))},d=Q(s),a=new ResizeObserver(s);return a.observe(t.current),()=>{d(),a.disconnect()}}},[t]),T.jsxRuntimeExports.jsx("canvas",{ref:t,"aria-hidden":!0,role:"presentation",style:{"--color":l,"--opacity":H},className:B.cx("kakadu-components-3366903902",_&&"kakadu-components-4049648322",W),width:h,height:v})}exports.default=U;
|