@kakadu/components 6.1.1 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/aria-text.d.ts +2 -1
- package/build/components/box.d.ts +2 -1
- package/build/components/button-tooltip.d.ts +2 -1
- package/build/components/button.d.ts +3 -3
- package/build/components/button.js +1 -1
- package/build/components/button.mjs +27 -25
- package/build/components/card.d.ts +2 -2
- package/build/components/click-ripples.d.ts +2 -2
- package/build/components/click-ripples.js +1 -1
- package/build/components/click-ripples.mjs +50 -45
- package/build/components/collapsible.d.ts +2 -2
- package/build/components/combobox.d.ts +2 -2
- package/build/components/combobox.js +1 -1
- package/build/components/combobox.mjs +161 -159
- package/build/components/copy-icon-button.d.ts +2 -1
- package/build/components/datum.d.ts +2 -2
- package/build/components/dot.d.ts +2 -2
- package/build/components/flex.d.ts +2 -1
- package/build/components/footer.d.ts +2 -2
- package/build/components/gauge.d.ts +2 -1
- package/build/components/header.d.ts +2 -1
- package/build/components/hover-gradient.d.ts +2 -2
- package/build/components/hover-gradient.js +1 -1
- package/build/components/hover-gradient.mjs +48 -35
- package/build/components/icon-button.d.ts +2 -2
- package/build/components/input.d.ts +3 -3
- package/build/components/input.js +2 -2
- package/build/components/input.mjs +21 -21
- package/build/components/logos/akt-logo.d.ts +2 -2
- package/build/components/logos/amedia-logo.d.ts +2 -2
- package/build/components/logos/bankaxept-logo.d.ts +2 -2
- package/build/components/logos/bankid-logo.d.ts +2 -2
- package/build/components/logos/dnb-logo.d.ts +2 -2
- package/build/components/logos/entur-logo.d.ts +2 -2
- package/build/components/logos/gjensidige-logo.d.ts +2 -2
- package/build/components/logos/kakadu-academy-logo.d.ts +2 -2
- package/build/components/logos/kakadu-guide-icon.d.ts +2 -1
- package/build/components/logos/kakadu-guide-logo.d.ts +3 -3
- package/build/components/logos/kakadu-index-logo.d.ts +2 -2
- package/build/components/logos/kakadu-logo.d.ts +2 -2
- package/build/components/logos/kakadu-play-logo.d.ts +2 -2
- package/build/components/logos/kolumbus-logo.d.ts +2 -2
- package/build/components/logos/nordea-logo.d.ts +2 -2
- package/build/components/logos/norsk-tipping-logo.d.ts +2 -2
- package/build/components/logos/ruter-logo.d.ts +2 -2
- package/build/components/logos/senteret-for-et-aldersvennlig-norge-logo.d.ts +2 -2
- package/build/components/logos/sparebank1-logo.d.ts +2 -2
- package/build/components/logos/sparebanken-norge-logo.d.ts +2 -2
- package/build/components/logos/sto-logo.d.ts +2 -2
- package/build/components/logos/storebrand-logo.d.ts +2 -2
- package/build/components/modal.d.ts +6 -6
- 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/notice.d.ts +2 -2
- package/build/components/notification.d.ts +8 -6
- package/build/components/notification.js +1 -1
- package/build/components/notification.mjs +87 -71
- package/build/components/popover-menu.d.ts +3 -3
- package/build/components/popover-menu.js +1 -1
- package/build/components/popover-menu.mjs +131 -129
- package/build/components/popover.d.ts +4 -4
- package/build/components/popover.js +1 -1
- package/build/components/popover.mjs +82 -73
- package/build/components/revealer.d.ts +2 -2
- package/build/components/select.d.ts +2 -2
- package/build/components/separator.d.ts +5 -5
- package/build/components/skeleton.d.ts +3 -2
- package/build/components/spinner.d.ts +3 -2
- package/build/components/text-button.d.ts +2 -2
- package/build/components/text.d.ts +9 -8
- package/build/components/theme-setter.d.ts +2 -2
- package/build/components/veil.d.ts +2 -1
- package/build/components/wrapper.d.ts +2 -2
- package/build/components.css +1 -1
- package/build/hooks/use-is-document-focused.js +1 -1
- package/build/hooks/use-is-document-focused.mjs +30 -14
- package/build/icons/anchor-down.d.ts +2 -2
- package/build/icons/anchor-up.d.ts +2 -2
- package/build/icons/arrow-down.d.ts +2 -2
- package/build/icons/arrow-left.d.ts +2 -2
- package/build/icons/arrow-right.d.ts +2 -2
- package/build/icons/arrow-up.d.ts +2 -2
- package/build/icons/caret-down.d.ts +2 -2
- package/build/icons/caret-left.d.ts +2 -2
- package/build/icons/caret-right.d.ts +2 -2
- package/build/icons/caret-up.d.ts +2 -2
- package/build/icons/check.d.ts +2 -2
- package/build/icons/chevron-down.d.ts +2 -2
- package/build/icons/chevron-left.d.ts +2 -2
- package/build/icons/chevron-right.d.ts +2 -2
- package/build/icons/chevron-up.d.ts +2 -2
- package/build/icons/chrome-browser-logo.d.ts +2 -2
- package/build/icons/cog.d.ts +2 -2
- package/build/icons/copy.d.ts +2 -2
- package/build/icons/document.d.ts +2 -2
- package/build/icons/dots.d.ts +2 -2
- package/build/icons/drag.d.ts +2 -2
- package/build/icons/edge-browser-logo.d.ts +2 -2
- package/build/icons/edit.d.ts +2 -2
- package/build/icons/exclamation-triangle.d.ts +2 -2
- package/build/icons/external.d.ts +2 -2
- package/build/icons/eye.d.ts +2 -2
- package/build/icons/icon.d.ts +2 -2
- package/build/icons/information.d.ts +2 -2
- package/build/icons/kakadu-guide-glyph.d.ts +2 -2
- package/build/icons/kakadu-guide-icon.d.ts +2 -2
- package/build/icons/menu.d.ts +2 -2
- package/build/icons/package.d.ts +2 -2
- package/build/icons/plus.d.ts +2 -2
- package/build/icons/select.d.ts +2 -2
- package/build/icons/share.d.ts +2 -2
- package/build/icons/sparkle.d.ts +2 -2
- package/build/icons/test.d.ts +2 -2
- package/build/icons/times.d.ts +2 -2
- package/build/icons/trash.d.ts +2 -2
- package/build/icons/trend-up.d.ts +2 -2
- package/build/index.d.ts +2 -0
- package/build/index.js +1 -1
- package/build/index.mjs +19 -17
- package/build/theme.d.ts +2 -1
- 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 +16 -22
|
@@ -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;
|
|
@@ -1,94 +1,97 @@
|
|
|
1
1
|
import { j as T } from "../jsx-runtime-B4hRZ52C.mjs";
|
|
2
|
-
import { useRef as
|
|
2
|
+
import { useRef as S, useState as E, useCallback as W, useEffect as q } from "react";
|
|
3
3
|
import { cx as U } from "@kuma-ui/core";
|
|
4
4
|
import Z from "../hooks/use-is-in-view.mjs";
|
|
5
5
|
import _ from "../hooks/use-is-document-focused.mjs";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
import $ from "../utilities/listeners.mjs";
|
|
7
|
+
const tt = $((l) => {
|
|
8
|
+
window.addEventListener("resize", l, {
|
|
9
|
+
passive: !0
|
|
10
|
+
});
|
|
11
|
+
}, (l) => {
|
|
12
|
+
window.removeEventListener("resize", l);
|
|
13
|
+
});
|
|
14
|
+
function at({
|
|
15
|
+
color: l,
|
|
16
|
+
opacity: j,
|
|
17
|
+
className: D,
|
|
18
|
+
minimumSize: F = 1,
|
|
19
|
+
maximumSize: R = 5,
|
|
20
|
+
maximumStarsCount: b = 50,
|
|
21
|
+
speed: k = 1,
|
|
22
|
+
hasMask: V = !1
|
|
15
23
|
}) {
|
|
16
|
-
const
|
|
17
|
-
const
|
|
24
|
+
const e = S(null), [s, N] = E(), [d, z] = E(0), [h, A] = E(0), w = W(() => {
|
|
25
|
+
const o = d * 1.5, n = d * 0.25, u = h * 1.5, i = h * 0.25, x = o * Math.random() - n, r = u * Math.random() - i;
|
|
18
26
|
return {
|
|
19
|
-
size: Math.max(
|
|
27
|
+
size: Math.max(F, R * Math.random()),
|
|
20
28
|
opacity: 0,
|
|
21
|
-
speed: Math.max(0.1, Math.random() / 2 *
|
|
22
|
-
startPosition: [
|
|
23
|
-
currentPosition: [
|
|
24
|
-
targetPosition: [
|
|
29
|
+
speed: Math.max(0.1, Math.random() / 2 * k),
|
|
30
|
+
startPosition: [x, r],
|
|
31
|
+
currentPosition: [x, r],
|
|
32
|
+
targetPosition: [o * Math.random() - n, u * Math.random() - i]
|
|
25
33
|
};
|
|
26
|
-
}, [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
}, [d, h, F, R, k]), C = W(() => l ?? (e.current ? getComputedStyle(e.current).color : "#000"), [l, e]), O = Z(e), B = _(), H = !O || !B, L = S(Array.from({
|
|
35
|
+
length: b
|
|
36
|
+
}).map(() => w()));
|
|
37
|
+
return q(() => {
|
|
38
|
+
if (H || !s)
|
|
39
|
+
return;
|
|
40
|
+
let o = !1, n, u = C();
|
|
41
|
+
function i() {
|
|
42
|
+
if (o || !s)
|
|
43
|
+
return;
|
|
44
|
+
const r = L.current;
|
|
45
|
+
s.clearRect(0, 0, d, h);
|
|
46
|
+
for (let f = r.length; f; f -= 1) {
|
|
47
|
+
const t = r[f - 1], [m, p] = t.startPosition, [v, g] = t.currentPosition, [a, c] = t.targetPosition;
|
|
48
|
+
let M = !0;
|
|
49
|
+
if (m > a ? v > a && (M = !1) : v < a && (M = !1), p > c ? g > c && (M = !1) : g < c && (M = !1), M) {
|
|
50
|
+
r.splice(f - 1, 1);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const G = (m + a) / 2 - m, J = v - m, K = (p + c) / 2 - p, Q = g - p, y = (J / (G || 1) + Q / (K || 1)) / 2;
|
|
54
|
+
t.opacity = y > 1 ? 2 - y : y;
|
|
55
|
+
const X = t.size / 2;
|
|
56
|
+
if (s.beginPath(), s.arc(v - X, g - X, X, 0, 2 * Math.PI, !1), s.globalAlpha = t.opacity, s.fillStyle = u, s.fill(), v !== a) {
|
|
57
|
+
const Y = Math.abs(m - a), I = Math.abs(p - c), P = Math.min(1, Y / I);
|
|
58
|
+
v < a ? t.currentPosition[0] += t.speed * P : t.currentPosition[0] -= t.speed * P;
|
|
37
59
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
let M = !0;
|
|
42
|
-
if (h > c ? p > c && (M = !1) : p < c && (M = !1), m > l ? v > l && (M = !1) : v < l && (M = !1), M) {
|
|
43
|
-
n.splice(a - 1, 1), r -= 1;
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
const G = (h + c) / 2 - h, J = p - h, K = (m + l) / 2 - m, Q = v - m, Y = (J / G + Q / K) / 2;
|
|
47
|
-
e.opacity = Y > 1 ? 2 - Y : Y;
|
|
48
|
-
const F = e.size / 2;
|
|
49
|
-
if (s.beginPath(), s.arc(p - F, v - F, F, 0, 2 * Math.PI, !1), s.globalAlpha = e.opacity, s.fillStyle = g, s.fill(), p !== c) {
|
|
50
|
-
const I = Math.abs(h - c), A = Math.abs(m - l), P = Math.min(1, I / A);
|
|
51
|
-
p < c ? e.currentPosition[0] += e.speed * P : e.currentPosition[0] -= e.speed * P;
|
|
52
|
-
}
|
|
53
|
-
if (v !== l) {
|
|
54
|
-
const I = Math.abs(h - c), A = Math.abs(m - l), P = Math.min(1, A / I);
|
|
55
|
-
v < l ? e.currentPosition[1] += e.speed * P : e.currentPosition[1] -= e.speed * P;
|
|
56
|
-
}
|
|
60
|
+
if (g !== c) {
|
|
61
|
+
const Y = Math.abs(m - a), I = Math.abs(p - c), P = Math.min(1, I / Y);
|
|
62
|
+
g < c ? t.currentPosition[1] += t.speed * P : t.currentPosition[1] -= t.speed * P;
|
|
57
63
|
}
|
|
58
|
-
i = requestAnimationFrame(d);
|
|
59
64
|
}
|
|
65
|
+
n = requestAnimationFrame(i);
|
|
60
66
|
}
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
n.push(y()), a -= 1, r += 1;
|
|
67
|
+
n = requestAnimationFrame(i);
|
|
68
|
+
const x = setInterval(() => {
|
|
69
|
+
u = C();
|
|
70
|
+
const r = L.current;
|
|
71
|
+
let f = r.length, t = b - f;
|
|
72
|
+
if (t > 0)
|
|
73
|
+
for (; t; )
|
|
74
|
+
r.push(w()), t -= 1, f += 1;
|
|
70
75
|
}, 500);
|
|
71
76
|
return () => {
|
|
72
|
-
o = !0,
|
|
77
|
+
o = !0, n && cancelAnimationFrame(n), clearInterval(x);
|
|
73
78
|
};
|
|
74
|
-
}, [
|
|
75
|
-
if (
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
return
|
|
82
|
-
|
|
83
|
-
}), () => {
|
|
84
|
-
o.disconnect(), window.removeEventListener("resize", r);
|
|
79
|
+
}, [H, s, C, d, h, b, w]), q(() => {
|
|
80
|
+
if (e.current) {
|
|
81
|
+
const o = e.current.getContext("2d");
|
|
82
|
+
o && N(o), z(e.current.offsetWidth), A(e.current.offsetHeight);
|
|
83
|
+
const n = () => {
|
|
84
|
+
e.current && (z(e.current.offsetWidth), A(e.current.offsetHeight));
|
|
85
|
+
}, u = tt(n), i = new ResizeObserver(n);
|
|
86
|
+
return i.observe(e.current), () => {
|
|
87
|
+
u(), i.disconnect();
|
|
85
88
|
};
|
|
86
89
|
}
|
|
87
|
-
}, [
|
|
88
|
-
"--color":
|
|
89
|
-
"--opacity":
|
|
90
|
-
}, className: U("kakadu-components-3366903902",
|
|
90
|
+
}, [e]), /* @__PURE__ */ T.jsx("canvas", { ref: e, "aria-hidden": !0, role: "presentation", style: {
|
|
91
|
+
"--color": l,
|
|
92
|
+
"--opacity": j
|
|
93
|
+
}, className: U("kakadu-components-3366903902", V && "kakadu-components-4049648322", D), width: d, height: h });
|
|
91
94
|
}
|
|
92
95
|
export {
|
|
93
|
-
|
|
96
|
+
at as default
|
|
94
97
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type HTMLProps } from 'react';
|
|
1
|
+
import React, { type HTMLProps } from 'react';
|
|
2
2
|
import { type IconType } from '../icons/icon';
|
|
3
3
|
export declare const noticeTypes: readonly ["default", "success", "information", "warning", "danger"];
|
|
4
4
|
export type NoticeType = (typeof noticeTypes)[number];
|
|
@@ -6,4 +6,4 @@ export type NoticeProperties = HTMLProps<HTMLDivElement> & {
|
|
|
6
6
|
readonly type?: NoticeType;
|
|
7
7
|
readonly icon?: IconType;
|
|
8
8
|
};
|
|
9
|
-
export default function Notice({ type, icon, className, children, ...properties }: NoticeProperties):
|
|
9
|
+
export default function Notice({ type, icon, className, children, ...properties }: NoticeProperties): React.JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type HTMLProps, type ReactNode } from 'react';
|
|
1
|
+
import React, { type HTMLProps, type ReactNode } from 'react';
|
|
2
2
|
import { type IconType } from '../icons/icon';
|
|
3
3
|
import { type NoticeType } from './notice';
|
|
4
4
|
export { noticeTypes as notificationTypes } from './notice';
|
|
@@ -8,12 +8,14 @@ export type NotificationProperties = {
|
|
|
8
8
|
readonly type?: NoticeType;
|
|
9
9
|
readonly icon?: IconType;
|
|
10
10
|
readonly children: ReactNode;
|
|
11
|
-
readonly onDismiss?: (
|
|
11
|
+
readonly onDismiss?: (id: string) => void;
|
|
12
12
|
};
|
|
13
|
-
export default function Notification({ type, icon, index, className, children, onDismiss, ...properties }: NotificationProperties & {
|
|
13
|
+
export default function Notification({ type, icon, id, index: inputIndex, shouldDismiss, className, children, onDismiss, ...properties }: NotificationProperties & {
|
|
14
14
|
readonly index?: number;
|
|
15
|
-
|
|
15
|
+
readonly shouldDismiss?: boolean;
|
|
16
|
+
} & HTMLProps<HTMLDivElement>): React.JSX.Element;
|
|
16
17
|
export declare function useCreateNotification(): (notification: NotificationProperties) => void;
|
|
17
|
-
export declare function NotificationProvider({ children, }: {
|
|
18
|
+
export declare function NotificationProvider({ limit, children, }: {
|
|
19
|
+
readonly limit?: number;
|
|
18
20
|
readonly children: ReactNode;
|
|
19
|
-
}):
|
|
21
|
+
}): React.JSX.Element;
|
|
@@ -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 f=require("../jsx-runtime-BB_1_6y_.js"),e=require("react"),E=require("@kuma-ui/core"),I=require("../utilities/generate-random-id.js"),T=require("./notice.js");function R({type:i,icon:p,id:u,index:d,shouldDismiss:r,className:k,children:N,onDismiss:c,...s}){const[t,a]=e.useState(!1),[o,m]=e.useState(!1),[n,x]=e.useState(!1),v=d??0,[h,M]=e.useState(v);e.useEffect(()=>{if(r||o)return;const l=setTimeout(()=>{a(!0)},100);return()=>{clearTimeout(l)}},[r,o]);const j=e.useRef(0),C=e.useRef(0),S=e.useCallback(()=>{x(!0)},[]),q=e.useCallback(()=>{x(!1)},[]);return e.useEffect(()=>{if(n){C.current+=Date.now()-j.current;return}if(t){j.current=Date.now();const l=6e3-C.current,w=setTimeout(()=>{a(!1),m(!0)},l);return()=>{clearTimeout(w)}}},[n,t]),e.useEffect(()=>{r&&!o&&(a(!1),m(!0))},[r,o]),e.useEffect(()=>{if(o&&!t){const l=setTimeout(()=>{u&&(c==null||c(u))},300);return()=>{clearTimeout(l)}}},[o,t,u,c]),e.useEffect(()=>{n||M(v)},[n,v]),f.jsxRuntimeExports.jsx("div",{...s,style:{"--index":h},className:E.cx("kakadu-components-1727618227",t&&"kakadu-components-3003995416",k),children:f.jsxRuntimeExports.jsxs(T.default,{role:"status","aria-live":"polite","aria-atomic":"true",type:i,icon:p,className:E.cx("kakadu-components-3951461646",t&&"kakadu-components-2837603142"),onMouseEnter:S,onMouseLeave:q,children:[N,f.jsxRuntimeExports.jsx("div",{className:"kakadu-components-2751825161",children:f.jsxRuntimeExports.jsx("div",{className:E.cx("kakadu-components-4050948330",n?"kakadu-components-758522476":"kakadu-components-3914681513")})})]})})}const b=e.createContext({createNotification(){throw new Error("useCreateNotification must be used within a NotificationProvider")}});function g(){const{createNotification:i}=e.useContext(b);return i}function P({limit:i=5,children:p}){const[u,d]=e.useState([]),r=e.useCallback(s=>{const t=I.default();d(a=>{const o=[...a,{...s,id:t}];if(o.length<=i)return o;const m=o.length-i;return o.map((n,x)=>x<m?{...n,shouldDismiss:!0}:n)})},[i]),k=e.useCallback(s=>{d(t=>t.filter(a=>a.id!==s))},[]),N=e.useMemo(()=>({createNotification:r}),[r]),c=e.useMemo(()=>[...u].reverse(),[u]);return f.jsxRuntimeExports.jsxs(b.Provider,{value:N,children:[p,c.map((s,t)=>f.jsxRuntimeExports.jsx(R,{...s,index:t,onDismiss:k},s.id))]})}exports.notificationTypes=T.noticeTypes;exports.NotificationProvider=P;exports.default=R;exports.useCreateNotification=g;
|