reaxify 0.0.77 → 0.0.78
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/dist/components/Drawer/index.cjs.js +1 -1
- package/dist/components/Drawer/index.es.js +8 -8
- package/dist/components/Menu/index.cjs.js +1 -1
- package/dist/components/Menu/index.es.js +14 -14
- package/dist/components/Modal/index.cjs.js +1 -1
- package/dist/components/Modal/index.es.js +4 -4
- package/dist/hooks/useKeyDown.cjs.js +1 -1
- package/dist/hooks/useKeyDown.d.ts +6 -1
- package/dist/hooks/useKeyDown.es.js +7 -7
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),d=require("../../hooks/useClasses.cjs.js"),i=require("react"),M=require("../../hooks/useKeyDown.cjs.js"),g=require("../../node_modules/tailwind-merge/dist/bundle-mjs.cjs.js"),b=require("../../helpers/cn.cjs.js"),f=require("../Card/index.cjs.js"),q=require("../Portal/index.cjs.js"),R=require("../../node_modules/react-transition-group/esm/Transition.cjs.js"),
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),d=require("../../hooks/useClasses.cjs.js"),i=require("react"),M=require("../../hooks/useKeyDown.cjs.js"),g=require("../../node_modules/tailwind-merge/dist/bundle-mjs.cjs.js"),b=require("../../helpers/cn.cjs.js"),f=require("../Card/index.cjs.js"),q=require("../Portal/index.cjs.js"),R=require("../../node_modules/react-transition-group/esm/Transition.cjs.js"),p=i.createContext({open:!1,onClose:()=>{},duration:300,anchor:"start",transitionState:"unmounted"});function x({as:n,ref:a,open:r=!1,onClose:e=()=>{},duration:o=300,anchor:u="end",className:w="",children:y,...v}){const t=d(l=>l.drawer),c=i.useRef(null),m=n||"div",j={entering:"active opacity-100 pointer-events-auto",entered:"active opacity-100 pointer-events-auto",exiting:"opacity-0 pointer-events-none",exited:"opacity-0 pointer-events-none",unmounted:""},C=i.useMemo(()=>{var h;const l={start:"flex-row-reverse",end:"flex-row",top:"flex-col-reverse",bottom:"flex-col"},D=(h=t==null?void 0:t.anchor)==null?void 0:h[u];return[l[u],D]},[u,t==null?void 0:t.anchor]);return i.useImperativeHandle(a,()=>c.current),M(e,{skip:r,targetKey:"Escape"}),s.jsx(q,{children:s.jsx(R.default,{nodeRef:c,in:r,timeout:o,unmountOnExit:!0,children:l=>s.jsxs(m,{ref:c,style:{transitionDuration:`${o}ms`},"data-open":r,className:g.twMerge("fixed size-full inset-0 flex z-10 bg-black/20 backdrop-blur transition-opacity [--drawer-ratio:1] rtl:[--drawer-ratio:-1]",t==null?void 0:t.base,j[l],C,w),...v,children:[s.jsx("button",{type:"button",onClick:()=>e(),className:"absolute inset-0 size-full cursor-default opacity-0"}),s.jsx(p.Provider,{value:{open:r,onClose:e,transitionState:l,duration:o,anchor:u},children:y})]})})})}function N({children:n,className:a="",...r}){const e=d(t=>t.drawer.menu),{anchor:o,duration:u,transitionState:w}=i.useContext(p),y=i.useMemo(()=>{var m;const t={start:"w-[31.875rem] h-full max-w-[92.5%] rounded-e me-auto",end:"w-[31.875rem] h-full max-w-[92.5%] rounded-s ms-auto",top:"w-full h-[31.875rem] max-h-[92.5%] rounded-b mb-auto",bottom:"w-full h-[31.875rem] max-h-[92.5%] rounded-t mt-auto"},c=(m=e==null?void 0:e.anchor)==null?void 0:m[o];return[t[o],c]},[o,e==null?void 0:e.anchor]),v=i.useMemo(()=>({start:{entering:"translate-x-0",entered:"translate-x-0",exiting:"-translate-x-[calc(100%*var(--drawer-ratio))]",exited:"-translate-x-[calc(100%*var(--drawer-ratio))]",unmounted:""},end:{entering:"translate-x-0",entered:"translate-x-0",exiting:"translate-x-[calc(100%*var(--drawer-ratio))]",exited:"translate-x-[calc(100%*var(--drawer-ratio))]",unmounted:""},top:{entering:"translate-y-0",entered:"translate-y-0",exiting:"-translate-y-full",exited:"-translate-y-full",unmounted:""},bottom:{entering:"translate-y-0",entered:"translate-y-0",exiting:"translate-y-full",exited:"translate-y-full",unmounted:""}})[o],[o]);return s.jsx(f,{as:"div",style:{transitionDuration:`${u}ms`},className:g.twMerge("relative flex flex-col transition-[translate,width] rounded-none",e==null?void 0:e.base,v[w],y,a),...r,children:n})}function S({className:n,...a}){const r=d(e=>e.drawer.header.base);return s.jsx(f.Header,{className:b(r,n),...a})}function k({className:n,...a}){const r=d(e=>e.drawer.body.base);return s.jsx(f.Body,{className:b("flex-1 overflow-auto",r,n),...a})}function H({className:n,...a}){const r=d(e=>e.drawer.footer.base);return s.jsx(f.Footer,{className:b(r,n),...a})}x.Menu=N;x.Header=S;x.Body=k;x.Footer=H;exports.DrawerContext=p;exports.default=x;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as s, jsxs as N } from "react/jsx-runtime";
|
|
3
3
|
import d from "../../hooks/useClasses.es.js";
|
|
4
|
-
import { createContext as
|
|
4
|
+
import { createContext as k, useRef as H, useMemo as y, useImperativeHandle as M, useContext as z } from "react";
|
|
5
5
|
import B from "../../hooks/useKeyDown.es.js";
|
|
6
6
|
import { twMerge as h } from "../../node_modules/tailwind-merge/dist/bundle-mjs.es.js";
|
|
7
7
|
import v from "../../helpers/cn.es.js";
|
|
8
8
|
import m from "../Card/index.es.js";
|
|
9
9
|
import F from "../Portal/index.es.js";
|
|
10
10
|
import S from "../../node_modules/react-transition-group/esm/Transition.es.js";
|
|
11
|
-
const g =
|
|
11
|
+
const g = k({
|
|
12
12
|
open: !1,
|
|
13
13
|
onClose: () => {
|
|
14
14
|
},
|
|
@@ -28,7 +28,7 @@ function f({
|
|
|
28
28
|
children: w,
|
|
29
29
|
...p
|
|
30
30
|
}) {
|
|
31
|
-
const e = d((l) => l.drawer), u =
|
|
31
|
+
const e = d((l) => l.drawer), u = H(null), c = n || "div", C = {
|
|
32
32
|
entering: "active opacity-100 pointer-events-auto",
|
|
33
33
|
entered: "active opacity-100 pointer-events-auto",
|
|
34
34
|
exiting: "opacity-0 pointer-events-none",
|
|
@@ -44,7 +44,7 @@ function f({
|
|
|
44
44
|
}, R = (b = e == null ? void 0 : e.anchor) == null ? void 0 : b[i];
|
|
45
45
|
return [l[i], R];
|
|
46
46
|
}, [i, e == null ? void 0 : e.anchor]);
|
|
47
|
-
return
|
|
47
|
+
return M(a, () => u.current), B(t, { skip: r, targetKey: "Escape" }), /* @__PURE__ */ s(F, { children: /* @__PURE__ */ s(S, { nodeRef: u, in: r, timeout: o, unmountOnExit: !0, children: (l) => /* @__PURE__ */ N(
|
|
48
48
|
c,
|
|
49
49
|
{
|
|
50
50
|
ref: u,
|
|
@@ -145,7 +145,7 @@ function E({ className: n, ...a }) {
|
|
|
145
145
|
const r = d((t) => t.drawer.header.base);
|
|
146
146
|
return /* @__PURE__ */ s(m.Header, { className: v(r, n), ...a });
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function K({ className: n, ...a }) {
|
|
149
149
|
const r = d((t) => t.drawer.body.base);
|
|
150
150
|
return /* @__PURE__ */ s(
|
|
151
151
|
m.Body,
|
|
@@ -155,14 +155,14 @@ function P({ className: n, ...a }) {
|
|
|
155
155
|
}
|
|
156
156
|
);
|
|
157
157
|
}
|
|
158
|
-
function
|
|
158
|
+
function P({ className: n, ...a }) {
|
|
159
159
|
const r = d((t) => t.drawer.footer.base);
|
|
160
160
|
return /* @__PURE__ */ s(m.Footer, { className: v(r, n), ...a });
|
|
161
161
|
}
|
|
162
162
|
f.Menu = j;
|
|
163
163
|
f.Header = E;
|
|
164
|
-
f.Body =
|
|
165
|
-
f.Footer =
|
|
164
|
+
f.Body = K;
|
|
165
|
+
f.Footer = P;
|
|
166
166
|
export {
|
|
167
167
|
g as DrawerContext,
|
|
168
168
|
f as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";const i=require("react/jsx-runtime"),E=require("../../hooks/useClasses.cjs.js"),t=require("react"),N=require("../../hooks/useKeyDown.cjs.js"),k=require("../../node_modules/tailwind-merge/dist/bundle-mjs.cjs.js"),W=require("../Portal/index.cjs.js"),I=require("../../node_modules/react-transition-group/esm/Transition.cjs.js"),w=t.createContext({open:!1,onClose:()=>{},transitionState:"unmounted",closeOnClick:!1});function H({as:r,ref:a,open:s,onClose:
|
|
1
|
+
"use client";"use strict";const i=require("react/jsx-runtime"),E=require("../../hooks/useClasses.cjs.js"),t=require("react"),N=require("../../hooks/useKeyDown.cjs.js"),k=require("../../node_modules/tailwind-merge/dist/bundle-mjs.cjs.js"),W=require("../Portal/index.cjs.js"),I=require("../../node_modules/react-transition-group/esm/Transition.cjs.js"),w=t.createContext({open:!1,onClose:()=>{},transitionState:"unmounted",closeOnClick:!1});function H({as:r,ref:a,open:s,onClose:p,closeOnClick:C=!1,anchorEl:c=null,className:y,children:x,...b}){const M=E(e=>e.menu.base),u=r||"div",n=16,o=t.useRef(null),d=t.useRef({left:n,right:n,top:n}),O={entering:"scale-100 opacity-100",entered:"scale-100 opacity-100",exiting:"scale-90 opacity-0",exited:"scale-90 opacity-0",unmounted:""},R=t.useCallback(e=>{d.current=e},[]),q=t.useCallback(e=>{var l,h,f;(l=o.current)==null||l.style.setProperty("--left",`${e.left}px`),(h=o.current)==null||h.style.setProperty("--right",`${e.right}px`),(f=o.current)==null||f.style.setProperty("--top",`${e.top}px`)},[]),m=t.useCallback(()=>{var P,z;if(!s||!c)return;const e=c.getBoundingClientRect(),l=window.innerWidth,h=window.innerHeight,f=((P=o.current)==null?void 0:P.offsetWidth)||150,L=((z=o.current)==null?void 0:z.offsetHeight)||200;let g=e.left,j=e.right,v=e.bottom;g=Math.min(Math.max(g,n),l-f-n),j=Math.min(Math.max(l-e.right,n),l-f-n),v=Math.min(Math.max(v,n),h-L-n),R({left:g,right:j,top:v}),q({left:g,right:j,top:v})},[s,c,R,q]);return t.useEffect(()=>{m()},[m,x]),t.useEffect(()=>{const e=()=>{m()};return window.addEventListener("scroll",e),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e),window.removeEventListener("resize",e)}},[m]),t.useImperativeHandle(a,()=>o.current),N(p,{skip:s,targetKey:"Escape"}),i.jsx(W,{children:i.jsx(I.default,{nodeRef:o,in:s,timeout:300,unmountOnExit:!0,children:e=>i.jsx(w.Provider,{value:{open:s,onClose:p,transitionState:e,closeOnClick:C},children:i.jsxs(S,{children:[i.jsx($,{}),i.jsx(u,{ref:o,"data-open":s,className:k.twMerge("w-fit min-w-[12.5rem] bg-white shadow rounded p-2 transition-[scale,opacity] absolute top-[var(--top)] left-[var(--left)] right-auto origin-top-left rtl:left-auto rtl:right-[var(--right)] rtl:origin-top-right",M,O[e],y),...b,children:x})]})})})})}function S({children:r}){const{transitionState:a}=t.useContext(w),s={entering:"active pointer-events-auto",entered:"active pointer-events-auto",exiting:"pointer-events-none",exited:"pointer-events-none",unmounted:""};return i.jsx("div",{className:k.twMerge("fixed inset-0 size-full flex flex-col bg-transparent transition-opacity overflow-hidden z-10",s[a]),children:r})}function $(){const{onClose:r}=t.useContext(w);return i.jsx("button",{type:"button",className:"w-full flex-1 opacity-0 cursor-default lg:absolute lg:size-full lg:inset-0",onClick:r})}function B({as:r,closeOnClick:a,type:s="button",className:p,children:C,onClick:c,...y}){const x=r||"div",b=E(d=>d.menu.item.base),{closeOnClick:M,onClose:u}=t.useContext(w),n=a??M,o=d=>{n&&(u==null||u()),c==null||c(d)};return i.jsx(x,{type:s,className:k.twMerge("flex items-center px-3 py-2 w-full text-dark text-base font-normal rounded transition-colors hover:bg-dark hover:text-white",b,p),onClick:o,...y,children:C})}H.Item=B;module.exports=H;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { jsx as i, jsxs as $ } from "react/jsx-runtime";
|
|
3
3
|
import W from "../../hooks/useClasses.es.js";
|
|
4
4
|
import { createContext as j, useRef as L, useCallback as k, useEffect as N, useImperativeHandle as B, useContext as P } from "react";
|
|
5
|
-
import
|
|
5
|
+
import K from "../../hooks/useKeyDown.es.js";
|
|
6
6
|
import { twMerge as z } from "../../node_modules/tailwind-merge/dist/bundle-mjs.es.js";
|
|
7
|
-
import
|
|
7
|
+
import D from "../Portal/index.es.js";
|
|
8
8
|
import T from "../../node_modules/react-transition-group/esm/Transition.es.js";
|
|
9
9
|
const x = j({
|
|
10
10
|
open: !1,
|
|
@@ -15,7 +15,7 @@ const x = j({
|
|
|
15
15
|
});
|
|
16
16
|
function q({
|
|
17
17
|
as: r,
|
|
18
|
-
ref:
|
|
18
|
+
ref: l,
|
|
19
19
|
open: o,
|
|
20
20
|
onClose: d,
|
|
21
21
|
closeOnClick: w = !1,
|
|
@@ -37,16 +37,16 @@ function q({
|
|
|
37
37
|
}, H = k((t) => {
|
|
38
38
|
u.current = t;
|
|
39
39
|
}, []), O = k((t) => {
|
|
40
|
-
var
|
|
41
|
-
(
|
|
40
|
+
var a, h, f;
|
|
41
|
+
(a = n.current) == null || a.style.setProperty("--left", `${t.left}px`), (h = n.current) == null || h.style.setProperty("--right", `${t.right}px`), (f = n.current) == null || f.style.setProperty("--top", `${t.top}px`);
|
|
42
42
|
}, []), p = k(() => {
|
|
43
43
|
var R, E;
|
|
44
44
|
if (!o || !s) return;
|
|
45
|
-
const t = s.getBoundingClientRect(),
|
|
45
|
+
const t = s.getBoundingClientRect(), a = window.innerWidth, h = window.innerHeight, f = ((R = n.current) == null ? void 0 : R.offsetWidth) || 150, S = ((E = n.current) == null ? void 0 : E.offsetHeight) || 200;
|
|
46
46
|
let g = t.left, M = t.right, v = t.bottom;
|
|
47
|
-
g = Math.min(Math.max(g, e),
|
|
48
|
-
Math.max(
|
|
49
|
-
|
|
47
|
+
g = Math.min(Math.max(g, e), a - f - e), M = Math.min(
|
|
48
|
+
Math.max(a - t.right, e),
|
|
49
|
+
a - f - e
|
|
50
50
|
), v = Math.min(Math.max(v, e), h - S - e), H({ left: g, right: M, top: v }), O({ left: g, right: M, top: v });
|
|
51
51
|
}, [o, s, H, O]);
|
|
52
52
|
return N(() => {
|
|
@@ -58,7 +58,7 @@ function q({
|
|
|
58
58
|
return window.addEventListener("scroll", t), window.addEventListener("resize", t), () => {
|
|
59
59
|
window.removeEventListener("scroll", t), window.removeEventListener("resize", t);
|
|
60
60
|
};
|
|
61
|
-
}, [p]), B(
|
|
61
|
+
}, [p]), B(l, () => n.current), K(d, { skip: o, targetKey: "Escape" }), /* @__PURE__ */ i(D, { children: /* @__PURE__ */ i(T, { nodeRef: n, in: o, timeout: 300, unmountOnExit: !0, children: (t) => /* @__PURE__ */ i(
|
|
62
62
|
x.Provider,
|
|
63
63
|
{
|
|
64
64
|
value: {
|
|
@@ -89,7 +89,7 @@ function q({
|
|
|
89
89
|
) }) });
|
|
90
90
|
}
|
|
91
91
|
function A({ children: r }) {
|
|
92
|
-
const { transitionState:
|
|
92
|
+
const { transitionState: l } = P(x);
|
|
93
93
|
return /* @__PURE__ */ i(
|
|
94
94
|
"div",
|
|
95
95
|
{
|
|
@@ -101,7 +101,7 @@ function A({ children: r }) {
|
|
|
101
101
|
exiting: "pointer-events-none",
|
|
102
102
|
exited: "pointer-events-none",
|
|
103
103
|
unmounted: ""
|
|
104
|
-
}[
|
|
104
|
+
}[l]
|
|
105
105
|
),
|
|
106
106
|
children: r
|
|
107
107
|
}
|
|
@@ -120,14 +120,14 @@ function F() {
|
|
|
120
120
|
}
|
|
121
121
|
function G({
|
|
122
122
|
as: r,
|
|
123
|
-
closeOnClick:
|
|
123
|
+
closeOnClick: l,
|
|
124
124
|
type: o = "button",
|
|
125
125
|
className: d,
|
|
126
126
|
children: w,
|
|
127
127
|
onClick: s,
|
|
128
128
|
...y
|
|
129
129
|
}) {
|
|
130
|
-
const m = r || "div", C = W((u) => u.menu.item.base), { closeOnClick: b, onClose: c } = P(x), e =
|
|
130
|
+
const m = r || "div", C = W((u) => u.menu.item.base), { closeOnClick: b, onClose: c } = P(x), e = l ?? b, n = (u) => {
|
|
131
131
|
e && (c == null || c()), s == null || s(u);
|
|
132
132
|
};
|
|
133
133
|
return /* @__PURE__ */ i(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),y=require("../../helpers/cn.cjs.js"),l=require("../../hooks/useClasses.cjs.js"),u=require("react"),q=require("../../hooks/useKeyDown.cjs.js"),
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),y=require("../../helpers/cn.cjs.js"),l=require("../../hooks/useClasses.cjs.js"),u=require("react"),q=require("../../hooks/useKeyDown.cjs.js"),v=require("../../node_modules/tailwind-merge/dist/bundle-mjs.cjs.js"),x=require("../Card/index.cjs.js"),z=require("../Portal/index.cjs.js"),C=require("../../node_modules/react-transition-group/esm/Transition.cjs.js"),g=u.createContext({size:"md",open:!1,onClose:()=>{},transitionState:"unmounted",duration:300});function c({as:t,ref:n,size:o="md",open:e=!1,onClose:i=()=>{},duration:r=300,className:f,children:p,...b}){const d=l(m=>m.modal.base),a=u.useRef(null),M=t||"div",j={entering:"active opacity-100 pointer-events-auto",entered:"active opacity-100 pointer-events-auto",exiting:"opacity-0 pointer-events-none",exited:"opacity-0 pointer-events-none",unmounted:""};return u.useImperativeHandle(n,()=>a.current),q(i,{skip:e,targetKey:"Escape"}),s.jsx(z,{children:s.jsx(C.default,{nodeRef:a,in:e,timeout:r,unmountOnExit:!0,children:m=>s.jsxs(M,{ref:a,"data-open":e,style:{transitionDuration:`${r}ms`},className:v.twMerge("modal fixed size-full inset-0 flex flex-col z-10 bg-black/20 transition-opacity backdrop-blur p-4",d,j[m],f),...b,children:[s.jsx("button",{type:"button",onClick:()=>i(),className:"absolute inset-0 cursor-default opacity-0"}),s.jsx(g.Provider,{value:{size:o,open:e,onClose:i,transitionState:m,duration:r},children:p})]})})})}function w({className:t,children:n,...o}){const e=l(d=>d.modal.dialog),{size:i,transitionState:r,duration:f}=u.useContext(g),p={entering:"scale-100",entered:"scale-100",exiting:"scale-75",exited:"scale-75",unmounted:""},b=u.useMemo(()=>{var a;return[{sm:"min-[576px]:w-[300px]",md:"min-[576px]:w-[500px]",lg:"min-[992px]:w-[800px]"}[i],(a=e==null?void 0:e.size)==null?void 0:a[i]]},[i,e==null?void 0:e.size]);return s.jsx(x,{as:"div",style:{transitionDuration:`${f}ms`},className:v.twMerge("max-w-full max-h-full m-auto transition-transform",e==null?void 0:e.base,b,p[r],t),...o,children:n})}function N({className:t,...n}){const o=l(e=>e.modal.header.base);return s.jsx(x.Header,{className:y(o,t),...n})}function S({className:t,...n}){const o=l(e=>e.modal.body.base);return s.jsx(x.Body,{className:y(o,t),...n})}function h({className:t,...n}){const o=l(e=>e.modal.footer.base);return s.jsx(x.Footer,{className:y(o,t),...n})}c.Dialog=w;c.Header=N;c.Body=S;c.Footer=h;exports.ModalContext=g;exports.default=c;
|
|
@@ -3,11 +3,11 @@ import { jsx as a, jsxs as C } from "react/jsx-runtime";
|
|
|
3
3
|
import y from "../../helpers/cn.es.js";
|
|
4
4
|
import l from "../../hooks/useClasses.es.js";
|
|
5
5
|
import { createContext as M, useRef as w, useImperativeHandle as N, useContext as h, useMemo as D } from "react";
|
|
6
|
-
import
|
|
6
|
+
import k from "../../hooks/useKeyDown.es.js";
|
|
7
7
|
import { twMerge as b } from "../../node_modules/tailwind-merge/dist/bundle-mjs.es.js";
|
|
8
8
|
import d from "../Card/index.es.js";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
9
|
+
import H from "../Portal/index.es.js";
|
|
10
|
+
import S from "../../node_modules/react-transition-group/esm/Transition.es.js";
|
|
11
11
|
const v = M({
|
|
12
12
|
size: "md",
|
|
13
13
|
open: !1,
|
|
@@ -35,7 +35,7 @@ function u({
|
|
|
35
35
|
exited: "opacity-0 pointer-events-none",
|
|
36
36
|
unmounted: ""
|
|
37
37
|
};
|
|
38
|
-
return N(o, () => s.current),
|
|
38
|
+
return N(o, () => s.current), k(i, { skip: e, targetKey: "Escape" }), /* @__PURE__ */ a(H, { children: /* @__PURE__ */ a(S, { nodeRef: s, in: e, timeout: r, unmountOnExit: !0, children: (c) => /* @__PURE__ */ C(
|
|
39
39
|
g,
|
|
40
40
|
{
|
|
41
41
|
ref: s,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";const s=require("react");function o(r,e=null
|
|
1
|
+
"use client";"use strict";const s=require("react");function o(r,{skip:i=!1,targetKey:e=null}={}){s.useEffect(()=>{if(!r||i)return;const u=n=>e?Array.isArray(e)?e.includes(n):n===e:!0,t=n=>{u(n.key)&&r(n.key)};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[r,e,i])}module.exports=o;
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
type Options = {
|
|
2
|
+
skip?: boolean;
|
|
3
|
+
targetKey?: null | string | string[];
|
|
4
|
+
};
|
|
5
|
+
export default function useKeyDown(callback?: (key: string) => void, { skip, targetKey }?: Options): void;
|
|
6
|
+
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useEffect as
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
if (!r ||
|
|
6
|
-
const
|
|
7
|
-
|
|
2
|
+
import { useEffect as t } from "react";
|
|
3
|
+
function s(r, { skip: i = !1, targetKey: n = null } = {}) {
|
|
4
|
+
t(() => {
|
|
5
|
+
if (!r || i) return;
|
|
6
|
+
const o = (e) => n ? Array.isArray(n) ? n.includes(e) : e === n : !0, u = (e) => {
|
|
7
|
+
o(e.key) && r(e.key);
|
|
8
8
|
};
|
|
9
9
|
return window.addEventListener("keydown", u), () => {
|
|
10
10
|
window.removeEventListener("keydown", u);
|
|
@@ -12,5 +12,5 @@ function d(r, n = null, i = !0) {
|
|
|
12
12
|
}, [r, n, i]);
|
|
13
13
|
}
|
|
14
14
|
export {
|
|
15
|
-
|
|
15
|
+
s as default
|
|
16
16
|
};
|