@onoxm/react-hooks 0.1.5 → 0.1.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
- import{useClickOutSide as r}from "./useClickOutSide.js";import{useCountdown as s}from "./useCountdown.js";import{useEventListener as u}from "./useEventListener.js";import{useGetElementSize as p}from "./useGetElementSize.js";import{useKeyPress as i}from "./useKeyPress.js";import{useMouseClick as l}from "./useMouseClick.js";import{useTheme as c}from "./useTheme.js";import{useThemePro as h}from "./useThemePro.js";export{r as useClickOutSide,s as useCountdown,u as useEventListener,p as useGetElementSize,i as useKeyPress,l as useMouseClick,c as useTheme,h as useThemePro};
1
+ import{useClickOutSide as r}from "./useClickOutSide.js";import{useCountdown as s}from "./useCountdown.js";import{useDefer as u}from "./useDefer.js";import{useEventListener as p}from "./useEventListener.js";import{useGetElementSize as i}from "./useGetElementSize.js";import{useKeyPress as d}from "./useKeyPress.js";import{useMouseClick as C}from "./useMouseClick.js";import{useTheme as c}from "./useTheme.js";import{useThemePro as k}from "./useThemePro.js";import{useWindowSize as z}from "./useWindowSize.js";export{r as useClickOutSide,s as useCountdown,u as useDefer,p as useEventListener,i as useGetElementSize,d as useKeyPress,C as useMouseClick,c as useTheme,k as useThemePro,z as useWindowSize};
@@ -1 +1 @@
1
- import{c as u}from "react/compiler-runtime";import{useEventListener as m}from "./useEventListener.js";const h=(e,i,c)=>{const t=u(10),f=c?.event||"click";let o,a,s,p;return t[0]!==f ?(o=((n)=>{const r=typeof n=="string" ? [n]:n;if(new Set(r).size!==r.length)throw new Error("there are duplicates in the event type");return r;})(f),t[0]=f,t[1]=o):o=t[1],t[2]!==i||t[3]!==e ?(a=(n)=>{if(e)if(e instanceof Array)e.map(l).some((r)=>!!r&&r.contains(n.target))||i(n);else{const r=e instanceof HTMLElement ? e:e.current;r&&!r.contains(n.target)&&i(n);}},t[2]=i,t[3]=e,t[4]=a):a=t[4],t[5]!==c?.deps ?(s=c?.deps||[],t[5]=c?.deps,t[6]=s):s=t[6],t[7]!==e||t[8]!==s ?(p={deps:[e,...s]},t[7]=e,t[8]=s,t[9]=p):p=t[9],m(o,a,p);};function l(e){return e instanceof HTMLElement ? e:e.current;}export{h as useClickOutSide};
1
+ import{c as m}from "react/compiler-runtime";import{isArray as u}from "./utils/dist/utils/is/isArray.js";import{useEventListener as l}from "./useEventListener.js";const v=(e,c,i)=>{const t=m(10),f=i?.event||"click";let o,a,n,p;return t[0]!==f ?(o=((s)=>{const r=typeof s=="string" ? [s]:s;if(new Set(r).size!==r.length)throw new Error("there are duplicates in the event type");return r;})(f),t[0]=f,t[1]=o):o=t[1],t[2]!==c||t[3]!==e ?(a=(s)=>{if(e)if(u(e))e.map(d).some((r)=>!!r&&r.contains(s.target))||c(s);else{const r=e instanceof HTMLElement ? e:e.current;r&&!r.contains(s.target)&&c(s);}},t[2]=c,t[3]=e,t[4]=a):a=t[4],t[5]!==i?.deps ?(n=i?.deps||[],t[5]=i?.deps,t[6]=n):n=t[6],t[7]!==e||t[8]!==n ?(p={deps:[e,...n]},t[7]=e,t[8]=n,t[9]=p):p=t[9],l(o,a,p);};function d(e){return e instanceof HTMLElement ? e:e.current;}export{v as useClickOutSide};
@@ -0,0 +1 @@
1
+ import{c as f}from "react/compiler-runtime";import{useState as l,useEffect as u}from "react";const F=(c)=>{const e=f(8),n=c===void 0 ? 100:c,[t,i]=l(0);let o,r,s,a;if(e[0]!==t||e[1]!==n){const m=()=>o=requestAnimationFrame(()=>{i(t+1),t>=n||m();});m(),e[0]=t,e[1]=n,e[2]=o;}else o=e[2];return e[3]!==o ?(r=()=>()=>{cancelAnimationFrame(o);},e[3]=o,e[4]=r):r=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(s=[],e[5]=s):s=e[5],u(r,s),e[6]!==t ?(a=(m)=>t>m,e[6]=t,e[7]=a):a=e[7],a;};export{F as useDefer};
@@ -1 +1 @@
1
- import{c as m}from "react/compiler-runtime";import{useEffect as L}from "react";const l=(t,v,c)=>{const e=m(19);let r;e[0]!==c ?(r=c||{},e[0]=c,e[1]=r):r=e[1];const{target:n,deps:p,isDeferred:s}=r;let w;e[2]!==v ?(w=(i)=>v(i),e[2]=v,e[3]=w):w=e[3];const o=w;let a,d,f,E;return e[4]!==t||e[5]!==o||e[6]!==s||e[7]!==n ?(a=()=>(typeof t=="string" ?!s&&(n||window).addEventListener(t,o):t.forEach((i)=>!s&&(n||window).addEventListener(i,o)),()=>{typeof t=="string" ?(n||window).removeEventListener(t,o):t.forEach((i)=>(n||window).removeEventListener(i,o));}),e[4]=t,e[5]=o,e[6]=s,e[7]=n,e[8]=a):a=e[8],e[9]!==p ?(d=p||[],e[9]=p,e[10]=d):d=e[10],e[11]!==d||e[12]!==n ?(f=[n,...d],e[11]=d,e[12]=n,e[13]=f):f=e[13],L(a,f),e[14]!==t||e[15]!==o||e[16]!==s||e[17]!==n ?(E=s ?()=>{typeof t=="string" ?(n||window).addEventListener(t,o):t.forEach((i)=>(n||window).addEventListener(i,o));}:void 0,e[14]=t,e[15]=o,e[16]=s,e[17]=n,e[18]=E):E=e[18],E;};export{l as useEventListener};
1
+ import{c as L}from "react/compiler-runtime";import{forEach as c}from "./utils/dist/utils/common/forEach.js";import{useEffect as g}from "react";const h=(t,E,m)=>{const e=L(19);let n;e[0]!==m ?(n=m||{},e[0]=m,e[1]=n):n=e[1];const{target:r,deps:p,isDeferred:o}=n;let w;e[2]!==E ?(w=(i)=>E(i),e[2]=E,e[3]=w):w=e[3];const s=w;let a,d,f,v;return e[4]!==t||e[5]!==s||e[6]!==o||e[7]!==r ?(a=()=>(typeof t=="string" ?!o&&(r||window).addEventListener(t,s):c(t,(i)=>!o&&(r||window).addEventListener(i,s)),()=>{typeof t=="string" ?(r||window).removeEventListener(t,s):c(t,(i)=>(r||window).removeEventListener(i,s));}),e[4]=t,e[5]=s,e[6]=o,e[7]=r,e[8]=a):a=e[8],e[9]!==p ?(d=p||[],e[9]=p,e[10]=d):d=e[10],e[11]!==d||e[12]!==r ?(f=[r,...d],e[11]=d,e[12]=r,e[13]=f):f=e[13],g(a,f),e[14]!==t||e[15]!==s||e[16]!==o||e[17]!==r ?(v=o ?()=>{typeof t=="string" ?(r||window).addEventListener(t,s):c(t,(i)=>(r||window).addEventListener(i,s));}:void 0,e[14]=t,e[15]=s,e[16]=o,e[17]=r,e[18]=v):v=e[18],v;};export{h as useEventListener};
@@ -1 +1 @@
1
- import{useEventListener as g}from "./useEventListener.js";const d=(c)=>c.toString().toLocaleLowerCase(),p=(c,f,a)=>{const K=(h)=>g(h,(u)=>((n,e,m)=>{n.forEach((s)=>{if(s.includes("+")&&s.length>1){const t=s.split("+"),o=e.ctrlKey&&t.includes("ctrl"),r=e.shiftKey&&t.includes("shift"),l=e.altKey&&t.includes("alt"),i=e.metaKey&&t.includes("meta"),y=(e.ctrlKey||e.metaKey)&&t.includes("commandorcontrol");t.length===2 ?(o||r||l||i||y)&&e.key.toLocaleLowerCase()===t[t.length-1]&&f(e,s):t.length===3&&(o&&r||o&&l||o&&i||o&&y||r&&l||r&&i||r&&y||l&&i||l&&y||i&&y)&&e.key.toLocaleLowerCase()===t[t.length-1]&&f(e,s);}else if(s.includes(d(e.key))){if(m)s===d(e.key)&&f(e,s);else if(!(e.ctrlKey||e.metaKey||e.shiftKey||e.altKey))return f(e,s);}});})(c instanceof Array ? c.map((n)=>d(n)):[d(c)],u,a?.exactMatch||!1),{deps:[a?.target,...a?.deps||[]]});a?.events instanceof Array ? a.events.forEach((h)=>K(h)):K(a?.events||"keydown");};export{p as useKeyPress};
1
+ import{forEach as K}from "./utils/dist/utils/common/forEach.js";import{isArray as h}from "./utils/dist/utils/is/isArray.js";import{useEventListener as L}from "./useEventListener.js";const m=(a)=>a.toString().toLocaleLowerCase(),C=(a,y,n)=>{const f=(u)=>L(u,(p)=>((d,e,g)=>{K(d,(l)=>{if(l.includes("+")&&l.length>1){const t=l.split("+"),o=e.ctrlKey&&t.includes("ctrl"),c=e.shiftKey&&t.includes("shift"),i=e.altKey&&t.includes("alt"),r=e.metaKey&&t.includes("meta"),s=(e.ctrlKey||e.metaKey)&&t.includes("commandorcontrol");t.length===2 ?(o||c||i||r||s)&&e.key.toLocaleLowerCase()===t[t.length-1]&&y(e,l):t.length===3&&(o&&c||o&&i||o&&r||o&&s||c&&i||c&&r||c&&s||i&&r||i&&s||r&&s)&&e.key.toLocaleLowerCase()===t[t.length-1]&&y(e,l);}else if(l.includes(m(e.key))){if(g)l===m(e.key)&&y(e,l);else if(!(e.ctrlKey||e.metaKey||e.shiftKey||e.altKey))return y(e,l);}});})(h(a)? a.map((d)=>m(d)):[m(a)],p,n?.exactMatch||!1),{deps:[n?.target,...n?.deps||[]]});h(n?.events)? K(n.events,f):f(n?.events||"keydown");};export{C as useKeyPress};
@@ -0,0 +1 @@
1
+ import{c}from "react/compiler-runtime";import{useState as m,useEffect as h}from "react";const d=()=>{const e=c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={width:0,height:0},e[0]=t):t=e[0];const [r,s]=m(t);let n,i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(n=()=>{const o=()=>s({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",o),o(),()=>{window.removeEventListener("resize",o);};},i=[],e[1]=n,e[2]=i):(n=e[1],i=e[2]),h(n,i),r;};export{d as useWindowSize};
@@ -0,0 +1 @@
1
+ const n=(o,f)=>{for(const c of o)f(c,o.indexOf(c));};export{n as forEach};
@@ -0,0 +1 @@
1
+ const a=(r)=>Array.isArray(r);export{a as isArray};
@@ -1 +1 @@
1
- const v=(c)=>{const r="ono-view-transition-clip-path-circle",{element:h,duration:d=300,themeRules:m,onChangeTheme:s}=c,a=m?.()||document.documentElement.classList.contains("dark")? "dark":"light";if(!document.startViewTransition)return s(a==="dark" ? "light":"dark");const u=document.startViewTransition(()=>{const t=document.documentElement.classList.contains("dark");s(t ? "light":"dark");}),{top:w,left:p,width:g,height:x}=h.getBoundingClientRect(),e=p+g/2,n=w+x/2,l=[`circle(0%at ${e}px ${n}px)`,`circle(${Math.hypot(Math.max(e,window.innerWidth-e),Math.max(n,window.innerHeight-n))}px at ${e}px ${n}px)`];((t,i)=>{const o=document.createElement("style");o.setAttribute("type","text/css"),o.setAttribute("data-style-tag",i),o.textContent="::view-transition-old(root),::view-transition-new(root){animation:none;}.dark::view-transition-old(root){z-index:1;}.dark::view-transition-new(root){z-index:999;}::view-transition-old(root){z-index:999;}::view-transition-new(root){z-index:1;}",document.head.appendChild(o);})(0,r),u.ready.then(()=>{document.documentElement.animate({clipPath:a==="light" ? l:l.reverse()},{duration:d,fill:"forwards",easing:"ease-in-out",pseudoElement:a==="light" ? "::view-transition-new(root)":"::view-transition-old(root)"}),setTimeout(()=>{return t=r,void document.head.querySelectorAll("style").forEach((i)=>i.getAttribute("data-style-tag")===t&&i.remove());var t;},d+50);});};export{v as changeThemeClipPathCircle};
1
+ import{forEach as v}from "../common/forEach.js";const y=(c)=>{const r="ono-view-transition-clip-path-circle",{element:m,duration:s=300,themeRules:h,onChangeTheme:d}=c,o=h?.()||document.documentElement.classList.contains("dark")? "dark":"light";if(!document.startViewTransition)return d(o==="dark" ? "light":"dark");const u=document.startViewTransition(()=>{const i=document.documentElement.classList.contains("dark");d(i ? "light":"dark");}),{top:w,left:p,width:g,height:x}=m.getBoundingClientRect(),e=p+g/2,n=w+x/2,l=[`circle(0%at ${e}px ${n}px)`,`circle(${Math.hypot(Math.max(e,window.innerWidth-e),Math.max(n,window.innerHeight-n))}px at ${e}px ${n}px)`];((i,a)=>{const t=document.createElement("style");t.setAttribute("type","text/css"),t.setAttribute("data-style-tag",a),t.textContent="::view-transition-old(root),::view-transition-new(root){animation:none;}.dark::view-transition-old(root){z-index:1;}.dark::view-transition-new(root){z-index:999;}::view-transition-old(root){z-index:999;}::view-transition-new(root){z-index:1;}",document.head.appendChild(t);})(0,r),u.ready.then(()=>{document.documentElement.animate({clipPath:o==="light" ? l:l.reverse()},{duration:s,fill:"forwards",easing:"ease-in-out",pseudoElement:o==="light" ? "::view-transition-new(root)":"::view-transition-old(root)"}),setTimeout(()=>((i)=>{const a=document.head.querySelectorAll("style");v([...a],(t)=>{t.getAttribute("data-style-tag")===i&&t.remove();});})(r),s+50);});};export{y as changeThemeClipPathCircle};
@@ -1,8 +1,10 @@
1
1
  export * from './useClickOutSide';
2
2
  export * from './useCountdown';
3
+ export * from './useDefer';
3
4
  export * from './useEventListener';
4
5
  export * from './useGetElementSize';
5
6
  export * from './useKeyPress';
6
7
  export * from './useMouseClick';
7
8
  export * from './useTheme';
8
9
  export * from './useThemePro';
10
+ export * from './useWindowSize';
@@ -0,0 +1 @@
1
+ export declare const useDefer: (maxCount?: number) => (n: number) => boolean;
@@ -0,0 +1,4 @@
1
+ export declare const useWindowSize: () => {
2
+ width: number;
3
+ height: number;
4
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@onoxm/react-hooks",
3
3
  "private": false,
4
- "version": "0.1.5",
4
+ "version": "0.1.7",
5
5
  "description": "Component library by React + Typescript",
6
6
  "type": "module",
7
7
  "main": "./dist/hooks/index.js",
@@ -31,11 +31,11 @@
31
31
  "author": "ono",
32
32
  "license": "MIT",
33
33
  "dependencies": {
34
- "@onoxm/utils": "0.1.5"
34
+ "@onoxm/utils": "0.1.7"
35
35
  },
36
36
  "peerDependencies": {
37
- "@types/react": ">=18",
38
- "react": ">=18"
37
+ "@types/react": ">=19",
38
+ "react": ">=19"
39
39
  },
40
40
  "peerDependenciesMeta": {
41
41
  "@types/react": {