reaxify 0.0.83 → 0.0.85
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/Badge/index.cjs.js +1 -1
- package/dist/components/Badge/index.es.js +12 -12
- package/dist/components/Drawer/index.cjs.js +1 -1
- package/dist/components/Drawer/index.d.ts +2 -4
- package/dist/components/Drawer/index.es.js +16 -21
- package/dist/components/Menu/index.cjs.js +1 -1
- package/dist/components/Menu/index.d.ts +3 -3
- package/dist/components/Menu/index.es.js +71 -77
- package/dist/components/Modal/index.cjs.js +1 -1
- package/dist/components/Modal/index.d.ts +2 -4
- package/dist/components/Modal/index.es.js +36 -41
- package/dist/helpers/scrollIntoView.cjs.js +1 -1
- package/dist/helpers/scrollIntoView.d.ts +1 -1
- package/dist/helpers/scrollIntoView.es.js +4 -3
- package/dist/hooks/index.cjs.js +1 -1
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/index.es.js +6 -8
- package/dist/node_modules/@tanstack/hotkeys/dist/constants.cjs.js +1 -0
- package/dist/node_modules/@tanstack/hotkeys/dist/constants.es.js +206 -0
- package/dist/node_modules/@tanstack/hotkeys/dist/format.cjs.js +1 -0
- package/dist/node_modules/@tanstack/hotkeys/dist/format.es.js +10 -0
- package/dist/node_modules/@tanstack/hotkeys/dist/hotkey-manager.cjs.js +1 -0
- package/dist/node_modules/@tanstack/hotkeys/dist/hotkey-manager.es.js +276 -0
- package/dist/node_modules/@tanstack/hotkeys/dist/manager.utils.cjs.js +1 -0
- package/dist/node_modules/@tanstack/hotkeys/dist/manager.utils.es.js +48 -0
- package/dist/node_modules/@tanstack/hotkeys/dist/match.cjs.js +1 -0
- package/dist/node_modules/@tanstack/hotkeys/dist/match.es.js +27 -0
- package/dist/node_modules/@tanstack/hotkeys/dist/parse.cjs.js +1 -0
- package/dist/node_modules/@tanstack/hotkeys/dist/parse.es.js +72 -0
- package/dist/node_modules/@tanstack/react-hotkeys/dist/HotkeysProvider.cjs.js +1 -0
- package/dist/node_modules/@tanstack/react-hotkeys/dist/HotkeysProvider.es.js +10 -0
- package/dist/node_modules/@tanstack/react-hotkeys/dist/useHotkey.cjs.js +1 -0
- package/dist/node_modules/@tanstack/react-hotkeys/dist/useHotkey.es.js +35 -0
- package/dist/node_modules/@tanstack/react-hotkeys/dist/utils.cjs.js +1 -0
- package/dist/node_modules/@tanstack/react-hotkeys/dist/utils.es.js +7 -0
- package/dist/node_modules/@tanstack/store/dist/esm/alien.cjs.js +1 -0
- package/dist/node_modules/@tanstack/store/dist/esm/alien.es.js +129 -0
- package/dist/node_modules/@tanstack/store/dist/esm/atom.cjs.js +1 -0
- package/dist/node_modules/@tanstack/store/dist/esm/atom.es.js +124 -0
- package/dist/node_modules/@tanstack/store/dist/esm/store.cjs.js +1 -0
- package/dist/node_modules/@tanstack/store/dist/esm/store.es.js +24 -0
- package/dist/types/index.d.ts +2 -2
- package/package.json +4 -3
- package/dist/hooks/useKeyDown.cjs.js +0 -1
- package/dist/hooks/useKeyDown.d.ts +0 -6
- package/dist/hooks/useKeyDown.es.js +0 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";const w=require("react/jsx-runtime"),a=require("../../helpers/cn.cjs.js"),h=require("../../hooks/useClasses.cjs.js"),u=require("react"),k=require("../../node_modules/tailwind-merge/dist/bundle-mjs.cjs.js");function q({as:x,variant:i="solid",color:n=
|
|
1
|
+
"use client";"use strict";const w=require("react/jsx-runtime"),a=require("../../helpers/cn.cjs.js"),h=require("../../hooks/useClasses.cjs.js"),u=require("react"),k=require("../../node_modules/tailwind-merge/dist/bundle-mjs.cjs.js");function q({as:x,variant:i="solid",color:n="primary",size:s="md",className:c,children:p,...l}){const r=h(e=>e.badge),m=x||"span",f=u.useMemo(()=>{var t,b,g;if(!n)return"border-transparent";const e={primary:{solid:"bg-primary text-white border-primary",outline:"bg-transparent text-primary border-primary",soft:"bg-primary/10 text-primary border-primary/10"},secondary:{solid:"bg-secondary text-white border-secondary",outline:"bg-transparent text-secondary border-secondary",soft:"bg-secondary/10 text-secondary border-secondary/10"},success:{solid:"bg-success text-white border-success",outline:"bg-transparent text-success border-success",soft:"bg-success/10 text-success border-success/10"},info:{solid:"bg-info text-white border-info",outline:"bg-transparent text-info border-info",soft:"bg-info/10 text-info border-info/10"},warning:{solid:"bg-warning text-white border-warning",outline:"bg-transparent text-warning border-warning",soft:"bg-warning/10 text-warning border-warning/10"},danger:{solid:"bg-danger text-white border-danger",outline:"bg-transparent text-danger border-danger",soft:"bg-danger/10 text-danger border-danger/10"},dark:{solid:"bg-dark text-white border-dark",outline:"bg-transparent text-dark border-dark",soft:"bg-dark/10 text-dark border-dark/10"},light:{solid:"bg-light text-dark border-light",outline:"bg-transparent text-dark border-light",soft:"bg-light/10 text-dark border-light/10"}},o=(t=e==null?void 0:e[n])==null?void 0:t[i],d=(g=(b=r==null?void 0:r.color)==null?void 0:b[n])==null?void 0:g[i];return[o,d]},[n,i,r==null?void 0:r.color]),y=u.useMemo(()=>{var o,d,t;if(!s)return null;const e={sm:a("text-xs py-0.5 px-1.5",(o=r==null?void 0:r.size)==null?void 0:o.sm),md:a("text-sm py-[0.1875rem] px-2",(d=r==null?void 0:r.size)==null?void 0:d.md),lg:a("text-base py-1 px-3",(t=r==null?void 0:r.size)==null?void 0:t.lg)};return e==null?void 0:e[s]},[s,r==null?void 0:r.size]);return w.jsx(m,{className:k.twMerge("inline-flex border border-[#e8eaee] items-center text-center font-medium align-middle whitespace-nowrap rounded",r==null?void 0:r.base,f,y,c),...l,children:p})}module.exports=q;
|
|
@@ -7,15 +7,15 @@ import { twMerge as k } from "../../node_modules/tailwind-merge/dist/bundle-mjs.
|
|
|
7
7
|
function B({
|
|
8
8
|
as: p,
|
|
9
9
|
variant: i = "solid",
|
|
10
|
-
color:
|
|
10
|
+
color: o = "primary",
|
|
11
11
|
size: a = "md",
|
|
12
12
|
className: m,
|
|
13
13
|
children: u,
|
|
14
|
-
...
|
|
14
|
+
...c
|
|
15
15
|
}) {
|
|
16
|
-
const r = h((e) => e.badge),
|
|
16
|
+
const r = h((e) => e.badge), f = p || "span", l = x(() => {
|
|
17
17
|
var t, b, g;
|
|
18
|
-
if (!
|
|
18
|
+
if (!o) return "border-transparent";
|
|
19
19
|
const e = {
|
|
20
20
|
primary: {
|
|
21
21
|
solid: "bg-primary text-white border-primary",
|
|
@@ -57,29 +57,29 @@ function B({
|
|
|
57
57
|
outline: "bg-transparent text-dark border-light",
|
|
58
58
|
soft: "bg-light/10 text-dark border-light/10"
|
|
59
59
|
}
|
|
60
|
-
},
|
|
61
|
-
return [
|
|
62
|
-
}, [
|
|
63
|
-
var
|
|
60
|
+
}, n = (t = e == null ? void 0 : e[o]) == null ? void 0 : t[i], d = (g = (b = r == null ? void 0 : r.color) == null ? void 0 : b[o]) == null ? void 0 : g[i];
|
|
61
|
+
return [n, d];
|
|
62
|
+
}, [o, i, r == null ? void 0 : r.color]), y = x(() => {
|
|
63
|
+
var n, d, t;
|
|
64
64
|
if (!a) return null;
|
|
65
65
|
const e = {
|
|
66
|
-
sm: s("text-xs py-0.5 px-1.5", (
|
|
66
|
+
sm: s("text-xs py-0.5 px-1.5", (n = r == null ? void 0 : r.size) == null ? void 0 : n.sm),
|
|
67
67
|
md: s("text-sm py-[0.1875rem] px-2", (d = r == null ? void 0 : r.size) == null ? void 0 : d.md),
|
|
68
68
|
lg: s("text-base py-1 px-3", (t = r == null ? void 0 : r.size) == null ? void 0 : t.lg)
|
|
69
69
|
};
|
|
70
70
|
return e == null ? void 0 : e[a];
|
|
71
71
|
}, [a, r == null ? void 0 : r.size]);
|
|
72
72
|
return /* @__PURE__ */ w(
|
|
73
|
-
|
|
73
|
+
f,
|
|
74
74
|
{
|
|
75
75
|
className: k(
|
|
76
76
|
"inline-flex border border-[#e8eaee] items-center text-center font-medium align-middle whitespace-nowrap rounded",
|
|
77
77
|
r == null ? void 0 : r.base,
|
|
78
|
-
|
|
78
|
+
l,
|
|
79
79
|
y,
|
|
80
80
|
m
|
|
81
81
|
),
|
|
82
|
-
...
|
|
82
|
+
...c,
|
|
83
83
|
children: u
|
|
84
84
|
}
|
|
85
85
|
);
|
|
@@ -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"),
|
|
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"),u=require("react"),q=require("../../node_modules/@tanstack/react-hotkeys/dist/useHotkey.cjs.js"),g=require("../../node_modules/tailwind-merge/dist/bundle-mjs.cjs.js"),v=require("../../helpers/cn.cjs.js"),f=require("../Card/index.cjs.js"),D=require("../Portal/index.cjs.js"),R=require("../../node_modules/react-transition-group/esm/Transition.cjs.js"),p=u.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:i="end",className:w="",children:y,...b}){const t=d(l=>l.drawer),c=u.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=u.useMemo(()=>{var h;const l={start:"flex-row-reverse",end:"flex-row",top:"flex-col-reverse",bottom:"flex-col"},M=(h=t==null?void 0:t.anchor)==null?void 0:h[i];return[l[i],M]},[i,t==null?void 0:t.anchor]);return u.useImperativeHandle(a,()=>c.current),q.useHotkey("Escape",()=>e(),{enabled:r}),s.jsx(D,{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),...b,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:i},children:y})]})})})}function H({children:n,className:a="",...r}){const e=d(t=>t.drawer.menu),{anchor:o,duration:i,transitionState:w}=u.useContext(p),y=u.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 max-h-[92.5%] rounded-b mb-auto",bottom:"w-full 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]),b=u.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:`${i}ms`},className:g.twMerge("relative flex flex-col transition-[translate,width] rounded-none",e==null?void 0:e.base,b[w],y,a),...r,children:n})}function N({className:n,...a}){const r=d(e=>e.drawer.header.base);return s.jsx(f.Header,{className:v(r,n),...a})}function k({className:n,...a}){const r=d(e=>e.drawer.body.base);return s.jsx(f.Body,{className:v("flex-1 overflow-auto",r,n),...a})}function S({className:n,...a}){const r=d(e=>e.drawer.footer.base);return s.jsx(f.Footer,{className:v(r,n),...a})}x.Menu=H;x.Header=N;x.Body=k;x.Footer=S;exports.DrawerContext=p;exports.default=x;
|
|
@@ -3,16 +3,14 @@ import { ComponentProps, ElementType } from 'react';
|
|
|
3
3
|
import { TransitionStatus } from 'react-transition-group';
|
|
4
4
|
type Anchor = "start" | "end" | "top" | "bottom";
|
|
5
5
|
type Context = {
|
|
6
|
-
open: boolean;
|
|
7
|
-
onClose: VoidFunction;
|
|
8
6
|
duration: number;
|
|
9
7
|
anchor: Anchor;
|
|
10
8
|
transitionState: TransitionStatus;
|
|
11
|
-
};
|
|
9
|
+
} & ToggleProps;
|
|
12
10
|
type DrawerBaseProps = {
|
|
13
11
|
anchor?: Anchor;
|
|
14
12
|
duration?: number;
|
|
15
|
-
} & ToggleProps
|
|
13
|
+
} & Partial<ToggleProps>;
|
|
16
14
|
type DrawerProps<E extends ElementType> = ComponentPropsWithAs<E, DrawerBaseProps>;
|
|
17
15
|
type DrawerMenuProps = Omit<ComponentProps<"div">, "as" | "ref">;
|
|
18
16
|
type DrawerHeaderProps = ComponentProps<"div">;
|
|
@@ -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
|
|
5
|
-
import B from "../../
|
|
4
|
+
import { createContext as H, useRef as k, useMemo as y, useImperativeHandle as M, useContext as z } from "react";
|
|
5
|
+
import { useHotkey as B } from "../../node_modules/@tanstack/react-hotkeys/dist/useHotkey.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 = H({
|
|
12
12
|
open: !1,
|
|
13
13
|
onClose: () => {
|
|
14
14
|
},
|
|
@@ -28,28 +28,23 @@ 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 = k(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",
|
|
35
35
|
exited: "opacity-0 pointer-events-none",
|
|
36
36
|
unmounted: ""
|
|
37
|
-
},
|
|
37
|
+
}, D = y(() => {
|
|
38
38
|
var b;
|
|
39
39
|
const l = {
|
|
40
40
|
start: "flex-row-reverse",
|
|
41
41
|
end: "flex-row",
|
|
42
42
|
top: "flex-col-reverse",
|
|
43
43
|
bottom: "flex-col"
|
|
44
|
-
},
|
|
45
|
-
return [l[i],
|
|
44
|
+
}, R = (b = e == null ? void 0 : e.anchor) == null ? void 0 : b[i];
|
|
45
|
+
return [l[i], R];
|
|
46
46
|
}, [i, e == null ? void 0 : e.anchor]);
|
|
47
|
-
return M(a, () => u.current), B(
|
|
48
|
-
() => {
|
|
49
|
-
t == null || t();
|
|
50
|
-
},
|
|
51
|
-
{ skip: !r, targetKey: "Escape" }
|
|
52
|
-
), /* @__PURE__ */ s(F, { children: /* @__PURE__ */ s(S, { nodeRef: u, in: r, timeout: o, unmountOnExit: !0, children: (l) => /* @__PURE__ */ N(
|
|
47
|
+
return M(a, () => u.current), B("Escape", () => t(), { enabled: r }), /* @__PURE__ */ s(F, { children: /* @__PURE__ */ s(S, { nodeRef: u, in: r, timeout: o, unmountOnExit: !0, children: (l) => /* @__PURE__ */ N(
|
|
53
48
|
c,
|
|
54
49
|
{
|
|
55
50
|
ref: u,
|
|
@@ -58,8 +53,8 @@ function f({
|
|
|
58
53
|
className: h(
|
|
59
54
|
"fixed size-full inset-0 flex z-10 bg-black/20 backdrop-blur transition-opacity [--drawer-ratio:1] rtl:[--drawer-ratio:-1]",
|
|
60
55
|
e == null ? void 0 : e.base,
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
C[l],
|
|
57
|
+
D,
|
|
63
58
|
x
|
|
64
59
|
),
|
|
65
60
|
...p,
|
|
@@ -95,8 +90,8 @@ function j({ children: n, className: a = "", ...r }) {
|
|
|
95
90
|
const e = {
|
|
96
91
|
start: "w-[31.875rem] h-full max-w-[92.5%] rounded-e me-auto",
|
|
97
92
|
end: "w-[31.875rem] h-full max-w-[92.5%] rounded-s ms-auto",
|
|
98
|
-
top: "w-full
|
|
99
|
-
bottom: "w-full
|
|
93
|
+
top: "w-full max-h-[92.5%] rounded-b mb-auto",
|
|
94
|
+
bottom: "w-full max-h-[92.5%] rounded-t mt-auto"
|
|
100
95
|
}, u = (c = t == null ? void 0 : t.anchor) == null ? void 0 : c[o];
|
|
101
96
|
return [e[o], u];
|
|
102
97
|
}, [o, t == null ? void 0 : t.anchor]), p = y(() => ({
|
|
@@ -150,7 +145,7 @@ function E({ className: n, ...a }) {
|
|
|
150
145
|
const r = d((t) => t.drawer.header.base);
|
|
151
146
|
return /* @__PURE__ */ s(m.Header, { className: v(r, n), ...a });
|
|
152
147
|
}
|
|
153
|
-
function
|
|
148
|
+
function P({ className: n, ...a }) {
|
|
154
149
|
const r = d((t) => t.drawer.body.base);
|
|
155
150
|
return /* @__PURE__ */ s(
|
|
156
151
|
m.Body,
|
|
@@ -160,14 +155,14 @@ function K({ className: n, ...a }) {
|
|
|
160
155
|
}
|
|
161
156
|
);
|
|
162
157
|
}
|
|
163
|
-
function
|
|
158
|
+
function $({ className: n, ...a }) {
|
|
164
159
|
const r = d((t) => t.drawer.footer.base);
|
|
165
160
|
return /* @__PURE__ */ s(m.Footer, { className: v(r, n), ...a });
|
|
166
161
|
}
|
|
167
162
|
f.Menu = j;
|
|
168
163
|
f.Header = E;
|
|
169
|
-
f.Body =
|
|
170
|
-
f.Footer =
|
|
164
|
+
f.Body = P;
|
|
165
|
+
f.Footer = $;
|
|
171
166
|
export {
|
|
172
167
|
g as DrawerContext,
|
|
173
168
|
f as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";const
|
|
1
|
+
"use client";"use strict";const i=require("react/jsx-runtime"),z=require("../../hooks/useClasses.cjs.js"),t=require("react"),N=require("../../node_modules/@tanstack/react-hotkeys/dist/useHotkey.cjs.js"),j=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"),b=t.createContext({open:!1,onClose:()=>{},transitionState:"unmounted",closeOnClick:!1});function E({as:o,ref:l,open:s,onClose:c,closeOnClick:u=!1,anchorEl:d=null,className:m,children:h,...C}){const M=z(e=>e.menu.base),f=o||"div",n=16,r=t.useRef(null),p=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=>{p.current=e},[]),H=t.useCallback(e=>{var a,v,x;(a=r.current)==null||a.style.setProperty("--left",`${e.left}px`),(v=r.current)==null||v.style.setProperty("--right",`${e.right}px`),(x=r.current)==null||x.style.setProperty("--top",`${e.top}px`)},[]),g=t.useCallback(()=>{var q,P;if(!s||!d)return;const e=d.getBoundingClientRect(),a=window.innerWidth,v=window.innerHeight,x=((q=r.current)==null?void 0:q.offsetWidth)||150,L=((P=r.current)==null?void 0:P.offsetHeight)||200;let w=e.left,k=e.right,y=e.bottom;w=Math.min(Math.max(w,n),a-x-n),k=Math.min(Math.max(a-e.right,n),a-x-n),y=Math.min(Math.max(y,n),v-L-n),R({left:w,right:k,top:y}),H({left:w,right:k,top:y})},[s,d,R,H]);return t.useEffect(()=>{g()},[g,h]),t.useEffect(()=>{const e=()=>{g()};return window.addEventListener("scroll",e),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e),window.removeEventListener("resize",e)}},[g]),t.useImperativeHandle(l,()=>r.current),N.useHotkey("Escape",()=>c==null?void 0:c(),{enabled:s}),i.jsx(W,{children:i.jsx(I.default,{nodeRef:r,in:s,timeout:300,unmountOnExit:!0,children:e=>i.jsx(b.Provider,{value:{open:s,onClose:c,transitionState:e,closeOnClick:u},children:i.jsxs(S,{children:[i.jsx($,{}),i.jsx(f,{ref:r,"data-open":s,className:j.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],m),...C,children:h})]})})})})}function S({children:o}){const{transitionState:l}=t.useContext(b),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:j.twMerge("fixed inset-0 size-full flex flex-col bg-transparent transition-opacity overflow-hidden z-10",s[l]),children:o})}function $(){const{onClose:o}=t.useContext(b);return i.jsx("button",{type:"button",className:"w-full flex-1 opacity-0 cursor-default lg:absolute lg:size-full lg:inset-0",onClick:o})}function B({as:o,closeOnClick:l,className:s,children:c,onClick:u,...d}){const m=o||"button",h=m==="button"?"button":void 0,C=z(p=>p.menu.item.base),{closeOnClick:M,onClose:f}=t.useContext(b),n=l??M,r=p=>{n&&(f==null||f()),u==null||u(p)};return i.jsx(m,{type:h,className:j.twMerge("flex items-center px-3 py-2 w-full text-dark text-base font-normal rounded cursor-pointer transition-colors hover:bg-dark hover:text-white",C,s),onClick:r,...d,children:c})}E.Item=B;module.exports=E;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ComponentPropsWithAs, ToggleProps } from '../../types';
|
|
2
2
|
import { ElementType } from 'react';
|
|
3
|
-
type MenuProps =
|
|
3
|
+
type MenuProps = {
|
|
4
4
|
anchorEl?: HTMLElement | null;
|
|
5
5
|
closeOnClick?: boolean;
|
|
6
|
-
};
|
|
6
|
+
} & ToggleProps;
|
|
7
7
|
type MenuItemProps = {
|
|
8
8
|
closeOnClick?: boolean;
|
|
9
9
|
};
|
|
@@ -11,5 +11,5 @@ declare function Menu<E extends ElementType = "div">({ as, ref, open, onClose, c
|
|
|
11
11
|
declare namespace Menu {
|
|
12
12
|
var Item: typeof MenuItem;
|
|
13
13
|
}
|
|
14
|
-
declare function MenuItem<E extends ElementType = "button">({ as, closeOnClick: itemCloseOnClick,
|
|
14
|
+
declare function MenuItem<E extends ElementType = "button">({ as, closeOnClick: itemCloseOnClick, className, children, onClick, ...props }: ComponentPropsWithAs<E, MenuItemProps>): import("react/jsx-runtime").JSX.Element;
|
|
15
15
|
export default Menu;
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
2
|
+
import { jsx as r, 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
|
|
6
|
-
import { twMerge as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
const
|
|
5
|
+
import { useHotkey as T } from "../../node_modules/@tanstack/react-hotkeys/dist/useHotkey.es.js";
|
|
6
|
+
import { twMerge as H } from "../../node_modules/tailwind-merge/dist/bundle-mjs.es.js";
|
|
7
|
+
import q from "../Portal/index.es.js";
|
|
8
|
+
import A from "../../node_modules/react-transition-group/esm/Transition.es.js";
|
|
9
|
+
const y = j({
|
|
10
10
|
open: !1,
|
|
11
11
|
onClose: () => {
|
|
12
12
|
},
|
|
13
13
|
transitionState: "unmounted",
|
|
14
14
|
closeOnClick: !1
|
|
15
15
|
});
|
|
16
|
-
function
|
|
17
|
-
as:
|
|
18
|
-
ref:
|
|
16
|
+
function D({
|
|
17
|
+
as: i,
|
|
18
|
+
ref: l,
|
|
19
19
|
open: o,
|
|
20
|
-
onClose:
|
|
21
|
-
closeOnClick:
|
|
22
|
-
anchorEl:
|
|
23
|
-
className:
|
|
24
|
-
children:
|
|
20
|
+
onClose: s,
|
|
21
|
+
closeOnClick: c = !1,
|
|
22
|
+
anchorEl: u = null,
|
|
23
|
+
className: p,
|
|
24
|
+
children: h,
|
|
25
25
|
...b
|
|
26
26
|
}) {
|
|
27
|
-
const C = W((t) => t.menu.base),
|
|
27
|
+
const C = W((t) => t.menu.base), f = i || "div", e = 16, n = L(null), d = L({
|
|
28
28
|
left: e,
|
|
29
29
|
right: e,
|
|
30
30
|
top: e
|
|
@@ -34,71 +34,66 @@ function q({
|
|
|
34
34
|
exiting: "scale-90 opacity-0",
|
|
35
35
|
exited: "scale-90 opacity-0",
|
|
36
36
|
unmounted: ""
|
|
37
|
-
},
|
|
38
|
-
|
|
37
|
+
}, z = k((t) => {
|
|
38
|
+
d.current = t;
|
|
39
39
|
}, []), O = k((t) => {
|
|
40
|
-
var
|
|
41
|
-
(
|
|
42
|
-
}, []),
|
|
40
|
+
var a, v, m;
|
|
41
|
+
(a = n.current) == null || a.style.setProperty("--left", `${t.left}px`), (v = n.current) == null || v.style.setProperty("--right", `${t.right}px`), (m = n.current) == null || m.style.setProperty("--top", `${t.top}px`);
|
|
42
|
+
}, []), g = k(() => {
|
|
43
43
|
var R, E;
|
|
44
|
-
if (!o || !
|
|
45
|
-
const t =
|
|
46
|
-
let
|
|
47
|
-
|
|
48
|
-
Math.max(
|
|
49
|
-
|
|
50
|
-
),
|
|
51
|
-
}, [o,
|
|
44
|
+
if (!o || !u) return;
|
|
45
|
+
const t = u.getBoundingClientRect(), a = window.innerWidth, v = window.innerHeight, m = ((R = n.current) == null ? void 0 : R.offsetWidth) || 150, S = ((E = n.current) == null ? void 0 : E.offsetHeight) || 200;
|
|
46
|
+
let x = t.left, M = t.right, w = t.bottom;
|
|
47
|
+
x = Math.min(Math.max(x, e), a - m - e), M = Math.min(
|
|
48
|
+
Math.max(a - t.right, e),
|
|
49
|
+
a - m - e
|
|
50
|
+
), w = Math.min(Math.max(w, e), v - S - e), z({ left: x, right: M, top: w }), O({ left: x, right: M, top: w });
|
|
51
|
+
}, [o, u, z, O]);
|
|
52
52
|
return N(() => {
|
|
53
|
-
|
|
54
|
-
}, [
|
|
53
|
+
g();
|
|
54
|
+
}, [g, h]), N(() => {
|
|
55
55
|
const t = () => {
|
|
56
|
-
|
|
56
|
+
g();
|
|
57
57
|
};
|
|
58
58
|
return window.addEventListener("scroll", t), window.addEventListener("resize", t), () => {
|
|
59
59
|
window.removeEventListener("scroll", t), window.removeEventListener("resize", t);
|
|
60
60
|
};
|
|
61
|
-
}, [
|
|
62
|
-
|
|
63
|
-
a == null || a();
|
|
64
|
-
},
|
|
65
|
-
{ skip: !o, targetKey: "Escape" }
|
|
66
|
-
), /* @__PURE__ */ i(D, { children: /* @__PURE__ */ i(T, { nodeRef: n, in: o, timeout: 300, unmountOnExit: !0, children: (t) => /* @__PURE__ */ i(
|
|
67
|
-
x.Provider,
|
|
61
|
+
}, [g]), B(l, () => n.current), T("Escape", () => s == null ? void 0 : s(), { enabled: o }), /* @__PURE__ */ r(q, { children: /* @__PURE__ */ r(A, { nodeRef: n, in: o, timeout: 300, unmountOnExit: !0, children: (t) => /* @__PURE__ */ r(
|
|
62
|
+
y.Provider,
|
|
68
63
|
{
|
|
69
64
|
value: {
|
|
70
65
|
open: o,
|
|
71
|
-
onClose:
|
|
66
|
+
onClose: s,
|
|
72
67
|
transitionState: t,
|
|
73
|
-
closeOnClick:
|
|
68
|
+
closeOnClick: c
|
|
74
69
|
},
|
|
75
|
-
children: /* @__PURE__ */ $(
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
/* @__PURE__ */
|
|
78
|
-
|
|
70
|
+
children: /* @__PURE__ */ $(F, { children: [
|
|
71
|
+
/* @__PURE__ */ r(G, {}),
|
|
72
|
+
/* @__PURE__ */ r(
|
|
73
|
+
f,
|
|
79
74
|
{
|
|
80
75
|
ref: n,
|
|
81
76
|
"data-open": o,
|
|
82
|
-
className:
|
|
77
|
+
className: H(
|
|
83
78
|
"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",
|
|
84
79
|
C,
|
|
85
80
|
I[t],
|
|
86
|
-
|
|
81
|
+
p
|
|
87
82
|
),
|
|
88
83
|
...b,
|
|
89
|
-
children:
|
|
84
|
+
children: h
|
|
90
85
|
}
|
|
91
86
|
)
|
|
92
87
|
] })
|
|
93
88
|
}
|
|
94
89
|
) }) });
|
|
95
90
|
}
|
|
96
|
-
function
|
|
97
|
-
const { transitionState:
|
|
98
|
-
return /* @__PURE__ */
|
|
91
|
+
function F({ children: i }) {
|
|
92
|
+
const { transitionState: l } = P(y);
|
|
93
|
+
return /* @__PURE__ */ r(
|
|
99
94
|
"div",
|
|
100
95
|
{
|
|
101
|
-
className:
|
|
96
|
+
className: H(
|
|
102
97
|
"fixed inset-0 size-full flex flex-col bg-transparent transition-opacity overflow-hidden z-10",
|
|
103
98
|
{
|
|
104
99
|
entering: "active pointer-events-auto",
|
|
@@ -106,51 +101,50 @@ function A({ children: r }) {
|
|
|
106
101
|
exiting: "pointer-events-none",
|
|
107
102
|
exited: "pointer-events-none",
|
|
108
103
|
unmounted: ""
|
|
109
|
-
}[
|
|
104
|
+
}[l]
|
|
110
105
|
),
|
|
111
|
-
children:
|
|
106
|
+
children: i
|
|
112
107
|
}
|
|
113
108
|
);
|
|
114
109
|
}
|
|
115
|
-
function
|
|
116
|
-
const { onClose:
|
|
117
|
-
return /* @__PURE__ */
|
|
110
|
+
function G() {
|
|
111
|
+
const { onClose: i } = P(y);
|
|
112
|
+
return /* @__PURE__ */ r(
|
|
118
113
|
"button",
|
|
119
114
|
{
|
|
120
115
|
type: "button",
|
|
121
116
|
className: "w-full flex-1 opacity-0 cursor-default lg:absolute lg:size-full lg:inset-0",
|
|
122
|
-
onClick:
|
|
117
|
+
onClick: i
|
|
123
118
|
}
|
|
124
119
|
);
|
|
125
120
|
}
|
|
126
|
-
function
|
|
127
|
-
as:
|
|
128
|
-
closeOnClick:
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
...y
|
|
121
|
+
function J({
|
|
122
|
+
as: i,
|
|
123
|
+
closeOnClick: l,
|
|
124
|
+
className: o,
|
|
125
|
+
children: s,
|
|
126
|
+
onClick: c,
|
|
127
|
+
...u
|
|
134
128
|
}) {
|
|
135
|
-
const
|
|
136
|
-
e && (
|
|
129
|
+
const p = i || "button", h = p === "button" ? "button" : void 0, b = W((d) => d.menu.item.base), { closeOnClick: C, onClose: f } = P(y), e = l ?? C, n = (d) => {
|
|
130
|
+
e && (f == null || f()), c == null || c(d);
|
|
137
131
|
};
|
|
138
|
-
return /* @__PURE__ */
|
|
139
|
-
|
|
132
|
+
return /* @__PURE__ */ r(
|
|
133
|
+
p,
|
|
140
134
|
{
|
|
141
|
-
type:
|
|
142
|
-
className:
|
|
143
|
-
"flex items-center px-3 py-2 w-full text-dark text-base font-normal rounded transition-colors hover:bg-dark hover:text-white",
|
|
135
|
+
type: h,
|
|
136
|
+
className: H(
|
|
137
|
+
"flex items-center px-3 py-2 w-full text-dark text-base font-normal rounded cursor-pointer transition-colors hover:bg-dark hover:text-white",
|
|
144
138
|
b,
|
|
145
|
-
|
|
139
|
+
o
|
|
146
140
|
),
|
|
147
141
|
onClick: n,
|
|
148
|
-
...
|
|
149
|
-
children:
|
|
142
|
+
...u,
|
|
143
|
+
children: s
|
|
150
144
|
}
|
|
151
145
|
);
|
|
152
146
|
}
|
|
153
|
-
|
|
147
|
+
D.Item = J;
|
|
154
148
|
export {
|
|
155
|
-
|
|
149
|
+
D as default
|
|
156
150
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
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("../../node_modules/@tanstack/react-hotkeys/dist/useHotkey.cjs.js"),g=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"),v=u.createContext({size:"md",open:!1,onClose:()=>{},transitionState:"unmounted",duration:300});function c({as:t,ref:n,size:o="md",open:e=!1,onClose:a=()=>{},duration:r=300,className:f,children:p,...b}){const d=l(m=>m.modal.base),i=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,()=>i.current),q.useHotkey("Escape",()=>a(),{enabled:e}),s.jsx(z,{children:s.jsx(C.default,{nodeRef:i,in:e,timeout:r,unmountOnExit:!0,children:m=>s.jsxs(M,{ref:i,"data-open":e,style:{transitionDuration:`${r}ms`},className:g.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:()=>a(),className:"absolute inset-0 cursor-default opacity-0"}),s.jsx(v.Provider,{value:{size:o,open:e,onClose:a,transitionState:m,duration:r},children:p})]})})})}function w({className:t,children:n,...o}){const e=l(d=>d.modal.dialog),{size:a,transitionState:r,duration:f}=u.useContext(v),p={entering:"scale-100",entered:"scale-100",exiting:"scale-75",exited:"scale-75",unmounted:""},b=u.useMemo(()=>{var i;return[{sm:"min-[576px]:w-[300px]",md:"min-[576px]:w-[500px]",lg:"min-[992px]:w-[800px]"}[a],(i=e==null?void 0:e.size)==null?void 0:i[a]]},[a,e==null?void 0:e.size]);return s.jsx(x,{as:"div",style:{transitionDuration:`${f}ms`},className:g.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 H({className:t,...n}){const o=l(e=>e.modal.header.base);return s.jsx(x.Header,{className:y(o,t),...n})}function N({className:t,...n}){const o=l(e=>e.modal.body.base);return s.jsx(x.Body,{className:y(o,t),...n})}function S({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=H;c.Body=N;c.Footer=S;exports.ModalContext=v;exports.default=c;
|
|
@@ -3,15 +3,13 @@ import { ComponentProps, ElementType } from 'react';
|
|
|
3
3
|
import { TransitionStatus } from 'react-transition-group';
|
|
4
4
|
type Context = {
|
|
5
5
|
size: Size;
|
|
6
|
-
open: boolean;
|
|
7
|
-
onClose: VoidFunction;
|
|
8
6
|
transitionState: TransitionStatus;
|
|
9
7
|
duration: number;
|
|
10
|
-
};
|
|
8
|
+
} & ToggleProps;
|
|
11
9
|
type ModalProps = {
|
|
12
10
|
size?: Size;
|
|
13
11
|
duration?: number;
|
|
14
|
-
} & ToggleProps
|
|
12
|
+
} & Partial<ToggleProps>;
|
|
15
13
|
type ModalDialogProps = Omit<ComponentProps<"div">, "as" | "ref">;
|
|
16
14
|
type ModalHeaderProps = ComponentProps<"div">;
|
|
17
15
|
type ModalBodyProps = ComponentProps<"div">;
|