@kakadu/components 5.0.6 → 5.0.7

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("../jsx-runtime-BB_1_6y_.js"),r=require("react"),w=require("@kuma-ui/core");function v({id:t,x:o,y:i,onEnd:s}){return r.useEffect(()=>{const n=setTimeout(()=>{s(t)},370);return()=>{clearTimeout(n)}},[s,t]),a.jsxRuntimeExports.jsx("div",{style:{top:i,left:o},className:"kakadu-components-3828473824"})}function y({isActive:t=!0,size:o=150,className:i,...s}){const n=r.useRef(null),[p,f]=r.useState([]);r.useEffect(()=>{if(!t)return;const e=u=>{if(n.current){const c=n.current.getBoundingClientRect(),{clientX:l,clientY:d}=u,{left:m,right:E,top:x,bottom:R}=c;l>m&&l<E&&d>x&&d<R&&f(k=>[...k,{id:Date.now()+Math.random()*1e3,x:l-m,y:d-x}])}};return window.addEventListener("pointerdown",e),()=>{window.removeEventListener("pointerdown",e)}},[t]);const j=r.useCallback(e=>{f(u=>u.filter(c=>c.id!==e))},[]);return a.jsxRuntimeExports.jsx("div",{...s,ref:n,style:{"--size":`${o}px`},className:w.cx("kakadu-components-4189236582",i),children:p.map(e=>a.jsxRuntimeExports.jsx(v,{id:e.id,x:e.x,y:e.y,onEnd:j},e.id))})}exports.default=y;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("../jsx-runtime-BB_1_6y_.js"),s=require("react"),v=require("@kuma-ui/core"),y=require("../hooks/use-is-in-view.js");function b({id:n,x:o,y:i,onEnd:r}){return s.useEffect(()=>{const t=setTimeout(()=>{r(n)},370);return()=>{clearTimeout(t)}},[r,n]),m.jsxRuntimeExports.jsx("div",{style:{top:i,left:o},className:"kakadu-components-3828473824"})}function g({isActive:n=!0,size:o=150,className:i,...r}){const t=s.useRef(null),u=y.default(t),[w,c]=s.useState([]);s.useEffect(()=>{if(!n||!u){c([]);return}const e=l=>{if(t.current){const d=t.current.getBoundingClientRect(),{clientX:a,clientY:f}=l,{left:x,right:k,top:p,bottom:E}=d;a>x&&a<k&&f>p&&f<E&&c(R=>[...R,{id:Date.now()+Math.random()*1e3,x:a-x,y:f-p}])}};return window.addEventListener("pointerdown",e),()=>{window.removeEventListener("pointerdown",e)}},[n,u]);const j=s.useCallback(e=>{c(l=>l.filter(d=>d.id!==e))},[]);return m.jsxRuntimeExports.jsx("div",{...r,ref:t,style:{"--size":`${o}px`},className:v.cx("kakadu-components-4189236582",i),children:u?w.map(e=>m.jsxRuntimeExports.jsx(b,{id:e.id,x:e.x,y:e.y,onEnd:j},e.id)):null})}exports.default=g;
@@ -1,63 +1,66 @@
1
- import { j as a } from "../jsx-runtime-B4hRZ52C.mjs";
2
- import { useRef as E, useState as R, useEffect as p, useCallback as h } from "react";
3
- import { cx as v } from "@kuma-ui/core";
4
- function C({
5
- id: t,
1
+ import { j as m } from "../jsx-runtime-B4hRZ52C.mjs";
2
+ import { useRef as R, useState as h, useEffect as x, useCallback as v } from "react";
3
+ import { cx as C } from "@kuma-ui/core";
4
+ import b from "../hooks/use-is-in-view.mjs";
5
+ function g({
6
+ id: n,
6
7
  x: r,
7
8
  y: s,
8
9
  onEnd: o
9
10
  }) {
10
- return p(() => {
11
- const n = setTimeout(() => {
12
- o(t);
11
+ return x(() => {
12
+ const t = setTimeout(() => {
13
+ o(n);
13
14
  }, 370);
14
15
  return () => {
15
- clearTimeout(n);
16
+ clearTimeout(t);
16
17
  };
17
- }, [o, t]), /* @__PURE__ */ a.jsx("div", { style: {
18
+ }, [o, n]), /* @__PURE__ */ m.jsx("div", { style: {
18
19
  top: s,
19
20
  left: r
20
21
  }, className: "kakadu-components-3828473824" });
21
22
  }
22
- function N({
23
- isActive: t = !0,
23
+ function V({
24
+ isActive: n = !0,
24
25
  size: r = 150,
25
26
  className: s,
26
27
  ...o
27
28
  }) {
28
- const n = E(null), [x, d] = R([]);
29
- p(() => {
30
- if (!t)
29
+ const t = R(null), i = b(t), [w, c] = h([]);
30
+ x(() => {
31
+ if (!n || !i) {
32
+ c([]);
31
33
  return;
32
- const e = (i) => {
33
- if (n.current) {
34
- const c = n.current.getBoundingClientRect(), {
35
- clientX: u,
36
- clientY: l
37
- } = i, {
38
- left: m,
39
- right: w,
40
- top: f,
41
- bottom: j
42
- } = c;
43
- u > m && u < w && l > f && l < j && d((y) => [...y, {
34
+ }
35
+ const e = (u) => {
36
+ if (t.current) {
37
+ const l = t.current.getBoundingClientRect(), {
38
+ clientX: a,
39
+ clientY: d
40
+ } = u, {
41
+ left: f,
42
+ right: j,
43
+ top: p,
44
+ bottom: y
45
+ } = l;
46
+ a > f && a < j && d > p && d < y && c((E) => [...E, {
44
47
  id: Date.now() + Math.random() * 1e3,
45
- x: u - m,
46
- y: l - f
48
+ x: a - f,
49
+ y: d - p
47
50
  }]);
48
51
  }
49
52
  };
50
53
  return window.addEventListener("pointerdown", e), () => {
51
54
  window.removeEventListener("pointerdown", e);
52
55
  };
53
- }, [t]);
54
- const k = h((e) => {
55
- d((i) => i.filter((c) => c.id !== e));
56
+ }, [n, i]);
57
+ const k = v((e) => {
58
+ c((u) => u.filter((l) => l.id !== e));
56
59
  }, []);
57
- return /* @__PURE__ */ a.jsx("div", { ...o, ref: n, style: {
60
+ return /* @__PURE__ */ m.jsx("div", { ...o, ref: t, style: {
58
61
  "--size": `${r}px`
59
- }, className: v("kakadu-components-4189236582", s), children: x.map((e) => /* @__PURE__ */ a.jsx(C, { id: e.id, x: e.x, y: e.y, onEnd: k }, e.id)) });
62
+ }, className: C("kakadu-components-4189236582", s), children: i ? w.map((e) => /* @__PURE__ */ m.jsx(g, { id: e.id, x: e.x, y: e.y, onEnd: k }, e.id)) : null });
60
63
  }
61
64
  export {
62
- N as default
65
+ V as default
63
66
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("../jsx-runtime-BB_1_6y_.js"),t=require("react"),x=require("@kuma-ui/core"),$="kakadu-components-2608453841";function q({isActive:i=!0,size:k=200,className:E,...g}){const l=t.useRef(null),n=t.useRef(null),[b,s]=t.useState(!1),[o,j]=t.useState();return t.useEffect(()=>{if(!i){s(!1);return}const c=l.current;if(!c)return;n.current||(n.current=c.parentElement);const e=n.current;if(!e)return;const a=f=>{const S=f.target;if(!e.contains(S))return;const y=e.getBoundingClientRect(),{clientX:r,clientY:u}=f,{left:d,right:L,top:v,bottom:R}=y;r>d&&r<L&&u>v&&u<R&&(s(!0),j([r-d,u-v]))},m=()=>{s(!1)};return e.addEventListener("mousemove",a),e.addEventListener("mouseleave",m),()=>{e.removeEventListener("mousemove",a),e.removeEventListener("mouseleave",m)}},[i]),p.jsxRuntimeExports.jsx("div",{...g,ref:l,className:x.cx("kakadu-components-1237006455",E),children:o?p.jsxRuntimeExports.jsx("div",{style:{"--size":`${k}px`,"--offset-x":`${o[0]}px`,"--offset-y":`${o[1]}px`},className:x.cx("kakadu-components-611160091",b&&"kakadu-components-3627966847")}):null})}exports.default=q;exports.normalBlendStyles=$;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const x=require("../jsx-runtime-BB_1_6y_.js"),t=require("react"),k=require("@kuma-ui/core"),$=require("../hooks/use-is-in-view.js"),I="kakadu-components-2608453841";function V({isActive:l=!0,size:E=200,className:g,...b}){const s=t.useRef(null),o=$.default(s),n=t.useRef(null),[j,r]=t.useState(!1),[u,S]=t.useState();return t.useEffect(()=>{if(!l||!o){r(!1);return}const a=s.current;if(!a)return;n.current||(n.current=a.parentElement);const e=n.current;if(!e)return;const m=d=>{const q=d.target;if(!e.contains(q))return;const y=e.getBoundingClientRect(),{clientX:i,clientY:c}=d,{left:v,right:L,top:p,bottom:R}=y;i>v&&i<L&&c>p&&c<R&&(r(!0),S([i-v,c-p]))},f=()=>{r(!1)};return e.addEventListener("mousemove",m),e.addEventListener("mouseleave",f),()=>{e.removeEventListener("mousemove",m),e.removeEventListener("mouseleave",f)}},[l,o]),x.jsxRuntimeExports.jsx("div",{...b,ref:s,className:k.cx("kakadu-components-1237006455",g),children:u&&o?x.jsxRuntimeExports.jsx("div",{style:{"--size":`${E}px`,"--offset-x":`${u[0]}px`,"--offset-y":`${u[1]}px`},className:k.cx("kakadu-components-611160091",j&&"kakadu-components-3627966847")}):null})}exports.default=V;exports.normalBlendStyles=I;
@@ -1,53 +1,54 @@
1
- import { j as p } from "../jsx-runtime-B4hRZ52C.mjs";
2
- import { useRef as v, useState as x, useEffect as N } from "react";
3
- import { cx as k } from "@kuma-ui/core";
4
- const z = "kakadu-components-2608453841";
5
- function C({
6
- isActive: i = !0,
7
- size: E = 200,
8
- className: g,
9
- ...L
1
+ import { j as v } from "../jsx-runtime-B4hRZ52C.mjs";
2
+ import { useRef as x, useState as k, useEffect as w } from "react";
3
+ import { cx as E } from "@kuma-ui/core";
4
+ import B from "../hooks/use-is-in-view.mjs";
5
+ const C = "kakadu-components-2608453841";
6
+ function G({
7
+ isActive: a = !0,
8
+ size: g = 200,
9
+ className: L,
10
+ ...b
10
11
  }) {
11
- const a = v(null), t = v(null), [b, n] = x(!1), [s, j] = x();
12
- return N(() => {
13
- if (!i) {
14
- n(!1);
12
+ const n = x(null), s = B(n), t = x(null), [j, o] = k(!1), [r, I] = k();
13
+ return w(() => {
14
+ if (!a || !s) {
15
+ o(!1);
15
16
  return;
16
17
  }
17
- const u = a.current;
18
- if (!u)
18
+ const c = n.current;
19
+ if (!c)
19
20
  return;
20
- t.current || (t.current = u.parentElement);
21
+ t.current || (t.current = c.parentElement);
21
22
  const e = t.current;
22
23
  if (!e)
23
24
  return;
24
- const c = (m) => {
25
- const y = m.target;
26
- if (!e.contains(y))
25
+ const l = (f) => {
26
+ const V = f.target;
27
+ if (!e.contains(V))
27
28
  return;
28
- const $ = e.getBoundingClientRect(), {
29
- clientX: o,
30
- clientY: r
31
- } = m, {
32
- left: f,
33
- right: h,
34
- top: d,
35
- bottom: B
36
- } = $;
37
- o > f && o < h && r > d && r < B && (n(!0), j([o - f, r - d]));
38
- }, l = () => {
39
- n(!1);
29
+ const y = e.getBoundingClientRect(), {
30
+ clientX: i,
31
+ clientY: u
32
+ } = f, {
33
+ left: d,
34
+ right: $,
35
+ top: p,
36
+ bottom: h
37
+ } = y;
38
+ i > d && i < $ && u > p && u < h && (o(!0), I([i - d, u - p]));
39
+ }, m = () => {
40
+ o(!1);
40
41
  };
41
- return e.addEventListener("mousemove", c), e.addEventListener("mouseleave", l), () => {
42
- e.removeEventListener("mousemove", c), e.removeEventListener("mouseleave", l);
42
+ return e.addEventListener("mousemove", l), e.addEventListener("mouseleave", m), () => {
43
+ e.removeEventListener("mousemove", l), e.removeEventListener("mouseleave", m);
43
44
  };
44
- }, [i]), /* @__PURE__ */ p.jsx("div", { ...L, ref: a, className: k("kakadu-components-1237006455", g), children: s ? /* @__PURE__ */ p.jsx("div", { style: {
45
- "--size": `${E}px`,
46
- "--offset-x": `${s[0]}px`,
47
- "--offset-y": `${s[1]}px`
48
- }, className: k("kakadu-components-611160091", b && "kakadu-components-3627966847") }) : null });
45
+ }, [a, s]), /* @__PURE__ */ v.jsx("div", { ...b, ref: n, className: E("kakadu-components-1237006455", L), children: r && s ? /* @__PURE__ */ v.jsx("div", { style: {
46
+ "--size": `${g}px`,
47
+ "--offset-x": `${r[0]}px`,
48
+ "--offset-y": `${r[1]}px`
49
+ }, className: E("kakadu-components-611160091", j && "kakadu-components-3627966847") }) : null });
49
50
  }
50
51
  export {
51
- C as default,
52
- z as normalBlendStyles
52
+ G as default,
53
+ C as normalBlendStyles
53
54
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kakadu/components",
3
- "version": "5.0.6",
3
+ "version": "5.0.7",
4
4
  "description": "Kakadu components library",
5
5
  "license": "MIT",
6
6
  "main": "./build/index.js",