@definable/ui 0.1.8 → 0.1.9
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/modal.esm.js +16 -16
- package/dist/components/modal.esm.js.map +1 -1
- package/dist/components/modal.js +1 -1
- package/dist/components/modal.js.map +1 -1
- package/dist/index.d.ts +32 -0
- package/dist/index.esm.js +397 -111
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utils-DSKoFOjv.cjs.map +1 -1
- package/dist/utils-qaFjX9_3.js.map +1 -1
- package/package.json +6 -1
|
@@ -2,7 +2,7 @@ import { j as e } from "../jsx-runtime-DGlMoOmv.js";
|
|
|
2
2
|
import { createPortal as y } from "react-dom";
|
|
3
3
|
import { AnimatePresence as g, motion as c } from "framer-motion";
|
|
4
4
|
import { X as N } from "lucide-react";
|
|
5
|
-
import { c as
|
|
5
|
+
import { c as t } from "../utils-qaFjX9_3.js";
|
|
6
6
|
import { useCallback as k, useEffect as E } from "react";
|
|
7
7
|
const z = {
|
|
8
8
|
sm: "max-w-sm",
|
|
@@ -14,7 +14,7 @@ const z = {
|
|
|
14
14
|
full: "w-[100vw]"
|
|
15
15
|
};
|
|
16
16
|
function M({
|
|
17
|
-
isOpen:
|
|
17
|
+
isOpen: r,
|
|
18
18
|
onClose: s,
|
|
19
19
|
title: a,
|
|
20
20
|
description: d,
|
|
@@ -24,17 +24,17 @@ function M({
|
|
|
24
24
|
size: x = "md",
|
|
25
25
|
showClose: u = !0,
|
|
26
26
|
className: f,
|
|
27
|
-
isContentScrollable:
|
|
28
|
-
mainClassName:
|
|
29
|
-
contentClassName:
|
|
30
|
-
header:
|
|
27
|
+
isContentScrollable: h = !0,
|
|
28
|
+
mainClassName: p,
|
|
29
|
+
contentClassName: b,
|
|
30
|
+
header: l,
|
|
31
31
|
zIndexClassName: j = "z-[50]"
|
|
32
32
|
}) {
|
|
33
|
-
const
|
|
34
|
-
w.key === "Escape" &&
|
|
35
|
-
}, [
|
|
36
|
-
E(() => (document.addEventListener("keydown",
|
|
37
|
-
const v = /* @__PURE__ */ e.jsx(g, { children:
|
|
33
|
+
const m = k((w) => {
|
|
34
|
+
w.key === "Escape" && r && s();
|
|
35
|
+
}, [r, s]);
|
|
36
|
+
E(() => (document.addEventListener("keydown", m), () => document.removeEventListener("keydown", m)), [m]);
|
|
37
|
+
const v = /* @__PURE__ */ e.jsx(g, { children: r && /* @__PURE__ */ e.jsx("div", { className: t("fixed inset-0 z-50 overflow-hidden", j), children: /* @__PURE__ */ e.jsxs("div", { className: t("min-h-full flex items-center justify-center p-4", p), children: [
|
|
38
38
|
/* @__PURE__ */ e.jsx(
|
|
39
39
|
c.div,
|
|
40
40
|
{
|
|
@@ -52,15 +52,15 @@ function M({
|
|
|
52
52
|
animate: { opacity: 1, scale: 1 },
|
|
53
53
|
exit: { opacity: 0, scale: 0.95 },
|
|
54
54
|
transition: { duration: 0.1, ease: "easeOut" },
|
|
55
|
-
className:
|
|
55
|
+
className: t(
|
|
56
56
|
"relative transform rounded-lg bg-background shadow-xl border border-border flex flex-col max-h-[85vh]",
|
|
57
57
|
z[x],
|
|
58
58
|
f
|
|
59
59
|
),
|
|
60
60
|
children: [
|
|
61
|
-
(a || d || i ||
|
|
62
|
-
|
|
63
|
-
i && /* @__PURE__ */ e.jsx("div", { className: "h-8 w-8 rounded-lg
|
|
61
|
+
(a || d || i || l) && /* @__PURE__ */ e.jsxs("div", { className: "flex-shrink-0 flex items-center justify-between p-2 border-b border-border", children: [
|
|
62
|
+
l || /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
63
|
+
i && /* @__PURE__ */ e.jsx("div", { className: "h-8 w-8 rounded-lg flex items-center justify-center", children: i }),
|
|
64
64
|
/* @__PURE__ */ e.jsxs("div", { children: [
|
|
65
65
|
a && /* @__PURE__ */ e.jsx("h2", { className: "text-sm font-small", children: a }),
|
|
66
66
|
d && /* @__PURE__ */ e.jsx("p", { className: "text-sm text-muted-foreground", children: d })
|
|
@@ -78,7 +78,7 @@ function M({
|
|
|
78
78
|
}
|
|
79
79
|
)
|
|
80
80
|
] }),
|
|
81
|
-
/* @__PURE__ */ e.jsx("div", { className:
|
|
81
|
+
/* @__PURE__ */ e.jsx("div", { className: t("flex-1 min-h-0", h ? "overflow-y-auto" : "", b), children: o }),
|
|
82
82
|
n && /* @__PURE__ */ e.jsx("div", { className: "flex-shrink-0 flex items-center justify-end gap-2 px-4 py-3 border-t border-border bg-muted/50", children: n })
|
|
83
83
|
]
|
|
84
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.esm.js","sources":["../../src/components/modal.tsx"],"sourcesContent":["import { createPortal } from 'react-dom';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport { X } from 'lucide-react';\nimport { cn } from '@/lib/utils';\nimport { useEffect, useCallback } from 'react';\n\nexport interface ModalProps {\n isOpen: boolean;\n onClose: () => void;\n title?: string;\n description?: string | React.ReactNode;\n icon?: React.ReactNode;\n children: React.ReactNode;\n footer?: React.ReactNode;\n size?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full' | '3xl';\n showClose?: boolean;\n className?: string;\n mainClassName?: string;\n isContentScrollable?: boolean;\n header?: React.ReactNode;\n headerClassName?: string;\n contentClassName?: string;\n zIndexClassName?: string;\n}\n\nconst sizeClasses = {\n sm: 'max-w-sm',\n md: 'max-w-md',\n lg: 'max-w-lg',\n xl: 'max-w-xl',\n '2xl': 'max-w-[1200px] w-[90vw]',\n '3xl': 'max-w-[1600px] w-[90vw]',\n full: 'w-[100vw]'\n};\n\nexport function Modal({\n isOpen,\n onClose,\n title,\n description,\n icon,\n children,\n footer,\n size = 'md',\n showClose = true,\n className,\n isContentScrollable = true,\n mainClassName,\n contentClassName,\n header,\n zIndexClassName = 'z-[50]'\n}: ModalProps) {\n const handleKeyDown = useCallback((e: KeyboardEvent) => {\n if (e.key === 'Escape' && isOpen) {\n onClose();\n }\n }, [isOpen, onClose]);\n\n useEffect(() => {\n document.addEventListener('keydown', handleKeyDown);\n return () => document.removeEventListener('keydown', handleKeyDown);\n }, [handleKeyDown]);\n\n const content = (\n <AnimatePresence>\n {isOpen && (\n <div className={cn(\"fixed inset-0 z-50 overflow-hidden\", zIndexClassName)}>\n <div className={cn(\"min-h-full flex items-center justify-center p-4\", mainClassName)}>\n <motion.div\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n className=\"fixed inset-0 bg-background/80 backdrop-blur-sm\"\n onClick={onClose}\n />\n \n <motion.div\n initial={{ opacity: 0, scale: 0.95 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{ opacity: 0, scale: 0.95 }}\n transition={{ duration: 0.1, ease: \"easeOut\" }}\n className={cn(\n \"relative transform rounded-lg bg-background shadow-xl border border-border flex flex-col max-h-[85vh]\",\n sizeClasses[size],\n className\n )}\n >\n {/* Header - Fixed */}\n {(title || description || icon || header) && (\n <div className=\"flex-shrink-0 flex items-center justify-between p-2 border-b border-border\">\n \n {header ? header: (\n <div className=\"flex items-center gap-3\">\n {icon && (\n <div className=\"h-8 w-8 rounded-lg
|
|
1
|
+
{"version":3,"file":"modal.esm.js","sources":["../../src/components/modal.tsx"],"sourcesContent":["import { createPortal } from 'react-dom';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport { X } from 'lucide-react';\nimport { cn } from '@/lib/utils';\nimport { useEffect, useCallback } from 'react';\n\nexport interface ModalProps {\n isOpen: boolean;\n onClose: () => void;\n title?: string;\n description?: string | React.ReactNode;\n icon?: React.ReactNode;\n children: React.ReactNode;\n footer?: React.ReactNode;\n size?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full' | '3xl';\n showClose?: boolean;\n className?: string;\n mainClassName?: string;\n isContentScrollable?: boolean;\n header?: React.ReactNode;\n headerClassName?: string;\n contentClassName?: string;\n zIndexClassName?: string;\n}\n\nconst sizeClasses = {\n sm: 'max-w-sm',\n md: 'max-w-md',\n lg: 'max-w-lg',\n xl: 'max-w-xl',\n '2xl': 'max-w-[1200px] w-[90vw]',\n '3xl': 'max-w-[1600px] w-[90vw]',\n full: 'w-[100vw]'\n};\n\nexport function Modal({\n isOpen,\n onClose,\n title,\n description,\n icon,\n children,\n footer,\n size = 'md',\n showClose = true,\n className,\n isContentScrollable = true,\n mainClassName,\n contentClassName,\n header,\n zIndexClassName = 'z-[50]'\n}: ModalProps) {\n const handleKeyDown = useCallback((e: KeyboardEvent) => {\n if (e.key === 'Escape' && isOpen) {\n onClose();\n }\n }, [isOpen, onClose]);\n\n useEffect(() => {\n document.addEventListener('keydown', handleKeyDown);\n return () => document.removeEventListener('keydown', handleKeyDown);\n }, [handleKeyDown]);\n\n const content = (\n <AnimatePresence>\n {isOpen && (\n <div className={cn(\"fixed inset-0 z-50 overflow-hidden\", zIndexClassName)}>\n <div className={cn(\"min-h-full flex items-center justify-center p-4\", mainClassName)}>\n <motion.div\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n className=\"fixed inset-0 bg-background/80 backdrop-blur-sm\"\n onClick={onClose}\n />\n \n <motion.div\n initial={{ opacity: 0, scale: 0.95 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{ opacity: 0, scale: 0.95 }}\n transition={{ duration: 0.1, ease: \"easeOut\" }}\n className={cn(\n \"relative transform rounded-lg bg-background shadow-xl border border-border flex flex-col max-h-[85vh]\",\n sizeClasses[size],\n className\n )}\n >\n {/* Header - Fixed */}\n {(title || description || icon || header) && (\n <div className=\"flex-shrink-0 flex items-center justify-between p-2 border-b border-border\">\n \n {header ? header: (\n <div className=\"flex items-center gap-3\">\n {icon && (\n <div className=\"h-8 w-8 rounded-lg flex items-center justify-center\">\n {icon}\n </div>\n )}\n <div>\n {title && <h2 className=\"text-sm font-small\">{title}</h2>}\n {description && <p className=\"text-sm text-muted-foreground\">{description}</p>}\n </div>\n </div>\n )}\n {showClose && (\n <button\n onClick={onClose}\n className=\"p-1.5 rounded-md hover:bg-muted text-muted-foreground\"\n >\n <div className=\"flex justify-center items-center\">\n <X className=\"h-4 w-4\" />\n <kbd className=\"ml-2 text-[10px] text-muted-foreground bg-muted px-1.5 py-0.5 rounded\">\n ESC\n </kbd>\n </div>\n </button>\n )}\n </div>\n )}\n\n {/* Content - Scrollable */}\n <div className={cn(\"flex-1 min-h-0\", isContentScrollable ? 'overflow-y-auto' : '', contentClassName )}>\n {children}\n </div>\n\n {/* Footer - Fixed */}\n {footer && (\n <div className=\"flex-shrink-0 flex items-center justify-end gap-2 px-4 py-3 border-t border-border bg-muted/50\">\n {footer}\n </div>\n )}\n </motion.div>\n </div>\n </div>\n )}\n </AnimatePresence>\n );\n\n return createPortal(content, document.body);\n}"],"names":["sizeClasses","Modal","isOpen","onClose","title","description","icon","children","footer","size","showClose","className","isContentScrollable","mainClassName","contentClassName","header","zIndexClassName","handleKeyDown","useCallback","e","useEffect","content","jsx","AnimatePresence","cn","jsxs","motion","X","createPortal"],"mappings":";;;;;;AAyBA,MAAMA,IAAc;AAAA,EAClB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,OAAO;AAAA,EACP,MAAM;AACR;AAEO,SAASC,EAAM;AAAA,EACpB,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,WAAAC,IAAY;AAAA,EACZ,WAAAC;AAAA,EACA,qBAAAC,IAAsB;AAAA,EACtB,eAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,QAAAC;AAAA,EACA,iBAAAC,IAAkB;AACpB,GAAe;AACb,QAAMC,IAAgBC,EAAY,CAACC,MAAqB;AACtD,IAAIA,EAAE,QAAQ,YAAYjB,KACxBC,E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,gBAAAA,EAAAA,IAAC,MAAA,EAAG,WAAU,sBAAsB,UAAAlB,GAAM;AAAA,gBACnDC,KAAeiB,gBAAAA,EAAAA,IAAC,KAAA,EAAE,WAAU,iCAAiC,UAAAjB,EAAA,CAAY;AAAA,cAAA,EAAA,CAC5E;AAAA,YAAA,GACF;AAAA,YAEDK,KACCY,gBAAAA,EAAAA;AAAAA,cAAC;AAAA,cAAA;AAAA,gBACC,SAASnB;AAAA,gBACT,WAAU;AAAA,gBAEV,UAAAsB,gBAAAA,EAAAA,KAAC,OAAA,EAAI,WAAU,oCACb,UAAA;AAAA,kBAAAH,gBAAAA,EAAAA,IAACK,GAAA,EAAE,WAAU,UAAA,CAAU;AAAA,kBACvBL,gBAAAA,EAAAA,IAAC,OAAA,EAAI,WAAU,yEAAwE,UAAA,MAAA,CAEvF;AAAA,gBAAA,EAAA,CACF;AAAA,cAAA;AAAA,YAAA;AAAA,UACF,GAEJ;AAAA,UAIFA,gBAAAA,EAAAA,IAAC,OAAA,EAAI,WAAWE,EAAG,kBAAkBZ,IAAsB,oBAAoB,IAAIE,CAAiB,GACjG,UAAAP,EAAA,CACH;AAAA,UAGCC,KACCc,gBAAAA,EAAAA,IAAC,OAAA,EAAI,WAAU,kGACZ,UAAAd,EAAA,CACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAEJ,EAAA,CACF,GACF,GAEJ;AAGF,SAAOoB,EAAaP,GAAS,SAAS,IAAI;AAC5C;"}
|
package/dist/components/modal.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../jsx-runtime-BYECrxsp.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../jsx-runtime-BYECrxsp.cjs"),y=require("react-dom"),c=require("framer-motion"),R=require("lucide-react"),t=require("../utils-DSKoFOjv.cjs"),d=require("react"),g={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl","2xl":"max-w-[1200px] w-[90vw]","3xl":"max-w-[1600px] w-[90vw]",full:"w-[100vw]"};function N({isOpen:r,onClose:s,title:n,description:i,icon:x,children:l,footer:m,size:u="md",showClose:j=!0,className:p,isContentScrollable:f=!0,mainClassName:b,contentClassName:h,header:a,zIndexClassName:v="z-[50]"}){const o=d.useCallback(w=>{w.key==="Escape"&&r&&s()},[r,s]);d.useEffect(()=>(document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)),[o]);const E=e.jsxRuntimeExports.jsx(c.AnimatePresence,{children:r&&e.jsxRuntimeExports.jsx("div",{className:t.cn("fixed inset-0 z-50 overflow-hidden",v),children:e.jsxRuntimeExports.jsxs("div",{className:t.cn("min-h-full flex items-center justify-center p-4",b),children:[e.jsxRuntimeExports.jsx(c.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-background/80 backdrop-blur-sm",onClick:s}),e.jsxRuntimeExports.jsxs(c.motion.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.1,ease:"easeOut"},className:t.cn("relative transform rounded-lg bg-background shadow-xl border border-border flex flex-col max-h-[85vh]",g[u],p),children:[(n||i||x||a)&&e.jsxRuntimeExports.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-2 border-b border-border",children:[a||e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[x&&e.jsxRuntimeExports.jsx("div",{className:"h-8 w-8 rounded-lg flex items-center justify-center",children:x}),e.jsxRuntimeExports.jsxs("div",{children:[n&&e.jsxRuntimeExports.jsx("h2",{className:"text-sm font-small",children:n}),i&&e.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:i})]})]}),j&&e.jsxRuntimeExports.jsx("button",{onClick:s,className:"p-1.5 rounded-md hover:bg-muted text-muted-foreground",children:e.jsxRuntimeExports.jsxs("div",{className:"flex justify-center items-center",children:[e.jsxRuntimeExports.jsx(R.X,{className:"h-4 w-4"}),e.jsxRuntimeExports.jsx("kbd",{className:"ml-2 text-[10px] text-muted-foreground bg-muted px-1.5 py-0.5 rounded",children:"ESC"})]})})]}),e.jsxRuntimeExports.jsx("div",{className:t.cn("flex-1 min-h-0",f?"overflow-y-auto":"",h),children:l}),m&&e.jsxRuntimeExports.jsx("div",{className:"flex-shrink-0 flex items-center justify-end gap-2 px-4 py-3 border-t border-border bg-muted/50",children:m})]})]})})});return y.createPortal(E,document.body)}exports.Modal=N;
|
|
2
2
|
//# sourceMappingURL=modal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.js","sources":["../../src/components/modal.tsx"],"sourcesContent":["import { createPortal } from 'react-dom';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport { X } from 'lucide-react';\nimport { cn } from '@/lib/utils';\nimport { useEffect, useCallback } from 'react';\n\nexport interface ModalProps {\n isOpen: boolean;\n onClose: () => void;\n title?: string;\n description?: string | React.ReactNode;\n icon?: React.ReactNode;\n children: React.ReactNode;\n footer?: React.ReactNode;\n size?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full' | '3xl';\n showClose?: boolean;\n className?: string;\n mainClassName?: string;\n isContentScrollable?: boolean;\n header?: React.ReactNode;\n headerClassName?: string;\n contentClassName?: string;\n zIndexClassName?: string;\n}\n\nconst sizeClasses = {\n sm: 'max-w-sm',\n md: 'max-w-md',\n lg: 'max-w-lg',\n xl: 'max-w-xl',\n '2xl': 'max-w-[1200px] w-[90vw]',\n '3xl': 'max-w-[1600px] w-[90vw]',\n full: 'w-[100vw]'\n};\n\nexport function Modal({\n isOpen,\n onClose,\n title,\n description,\n icon,\n children,\n footer,\n size = 'md',\n showClose = true,\n className,\n isContentScrollable = true,\n mainClassName,\n contentClassName,\n header,\n zIndexClassName = 'z-[50]'\n}: ModalProps) {\n const handleKeyDown = useCallback((e: KeyboardEvent) => {\n if (e.key === 'Escape' && isOpen) {\n onClose();\n }\n }, [isOpen, onClose]);\n\n useEffect(() => {\n document.addEventListener('keydown', handleKeyDown);\n return () => document.removeEventListener('keydown', handleKeyDown);\n }, [handleKeyDown]);\n\n const content = (\n <AnimatePresence>\n {isOpen && (\n <div className={cn(\"fixed inset-0 z-50 overflow-hidden\", zIndexClassName)}>\n <div className={cn(\"min-h-full flex items-center justify-center p-4\", mainClassName)}>\n <motion.div\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n className=\"fixed inset-0 bg-background/80 backdrop-blur-sm\"\n onClick={onClose}\n />\n \n <motion.div\n initial={{ opacity: 0, scale: 0.95 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{ opacity: 0, scale: 0.95 }}\n transition={{ duration: 0.1, ease: \"easeOut\" }}\n className={cn(\n \"relative transform rounded-lg bg-background shadow-xl border border-border flex flex-col max-h-[85vh]\",\n sizeClasses[size],\n className\n )}\n >\n {/* Header - Fixed */}\n {(title || description || icon || header) && (\n <div className=\"flex-shrink-0 flex items-center justify-between p-2 border-b border-border\">\n \n {header ? header: (\n <div className=\"flex items-center gap-3\">\n {icon && (\n <div className=\"h-8 w-8 rounded-lg
|
|
1
|
+
{"version":3,"file":"modal.js","sources":["../../src/components/modal.tsx"],"sourcesContent":["import { createPortal } from 'react-dom';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport { X } from 'lucide-react';\nimport { cn } from '@/lib/utils';\nimport { useEffect, useCallback } from 'react';\n\nexport interface ModalProps {\n isOpen: boolean;\n onClose: () => void;\n title?: string;\n description?: string | React.ReactNode;\n icon?: React.ReactNode;\n children: React.ReactNode;\n footer?: React.ReactNode;\n size?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full' | '3xl';\n showClose?: boolean;\n className?: string;\n mainClassName?: string;\n isContentScrollable?: boolean;\n header?: React.ReactNode;\n headerClassName?: string;\n contentClassName?: string;\n zIndexClassName?: string;\n}\n\nconst sizeClasses = {\n sm: 'max-w-sm',\n md: 'max-w-md',\n lg: 'max-w-lg',\n xl: 'max-w-xl',\n '2xl': 'max-w-[1200px] w-[90vw]',\n '3xl': 'max-w-[1600px] w-[90vw]',\n full: 'w-[100vw]'\n};\n\nexport function Modal({\n isOpen,\n onClose,\n title,\n description,\n icon,\n children,\n footer,\n size = 'md',\n showClose = true,\n className,\n isContentScrollable = true,\n mainClassName,\n contentClassName,\n header,\n zIndexClassName = 'z-[50]'\n}: ModalProps) {\n const handleKeyDown = useCallback((e: KeyboardEvent) => {\n if (e.key === 'Escape' && isOpen) {\n onClose();\n }\n }, [isOpen, onClose]);\n\n useEffect(() => {\n document.addEventListener('keydown', handleKeyDown);\n return () => document.removeEventListener('keydown', handleKeyDown);\n }, [handleKeyDown]);\n\n const content = (\n <AnimatePresence>\n {isOpen && (\n <div className={cn(\"fixed inset-0 z-50 overflow-hidden\", zIndexClassName)}>\n <div className={cn(\"min-h-full flex items-center justify-center p-4\", mainClassName)}>\n <motion.div\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n className=\"fixed inset-0 bg-background/80 backdrop-blur-sm\"\n onClick={onClose}\n />\n \n <motion.div\n initial={{ opacity: 0, scale: 0.95 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{ opacity: 0, scale: 0.95 }}\n transition={{ duration: 0.1, ease: \"easeOut\" }}\n className={cn(\n \"relative transform rounded-lg bg-background shadow-xl border border-border flex flex-col max-h-[85vh]\",\n sizeClasses[size],\n className\n )}\n >\n {/* Header - Fixed */}\n {(title || description || icon || header) && (\n <div className=\"flex-shrink-0 flex items-center justify-between p-2 border-b border-border\">\n \n {header ? header: (\n <div className=\"flex items-center gap-3\">\n {icon && (\n <div className=\"h-8 w-8 rounded-lg flex items-center justify-center\">\n {icon}\n </div>\n )}\n <div>\n {title && <h2 className=\"text-sm font-small\">{title}</h2>}\n {description && <p className=\"text-sm text-muted-foreground\">{description}</p>}\n </div>\n </div>\n )}\n {showClose && (\n <button\n onClick={onClose}\n className=\"p-1.5 rounded-md hover:bg-muted text-muted-foreground\"\n >\n <div className=\"flex justify-center items-center\">\n <X className=\"h-4 w-4\" />\n <kbd className=\"ml-2 text-[10px] text-muted-foreground bg-muted px-1.5 py-0.5 rounded\">\n ESC\n </kbd>\n </div>\n </button>\n )}\n </div>\n )}\n\n {/* Content - Scrollable */}\n <div className={cn(\"flex-1 min-h-0\", isContentScrollable ? 'overflow-y-auto' : '', contentClassName )}>\n {children}\n </div>\n\n {/* Footer - Fixed */}\n {footer && (\n <div className=\"flex-shrink-0 flex items-center justify-end gap-2 px-4 py-3 border-t border-border bg-muted/50\">\n {footer}\n </div>\n )}\n </motion.div>\n </div>\n </div>\n )}\n </AnimatePresence>\n );\n\n return createPortal(content, document.body);\n}"],"names":["sizeClasses","Modal","isOpen","onClose","title","description","icon","children","footer","size","showClose","className","isContentScrollable","mainClassName","contentClassName","header","zIndexClassName","handleKeyDown","useCallback","e","useEffect","content","jsx","AnimatePresence","cn","jsxs","motion","X","createPortal"],"mappings":"iQAyBMA,EAAc,CAClB,GAAI,WACJ,GAAI,WACJ,GAAI,WACJ,GAAI,WACJ,MAAO,0BACP,MAAO,0BACP,KAAM,WACR,EAEO,SAASC,EAAM,CACpB,OAAAC,EACA,QAAAC,EACA,MAAAC,EACA,YAAAC,EACA,KAAAC,EACA,SAAAC,EACA,OAAAC,EACA,KAAAC,EAAO,KACP,UAAAC,EAAY,GACZ,UAAAC,EACA,oBAAAC,EAAsB,GACtB,cAAAC,EACA,iBAAAC,EACA,OAAAC,EACA,gBAAAC,EAAkB,QACpB,EAAe,CACb,MAAMC,EAAgBC,cAAaC,GAAqB,CAClDA,EAAE,MAAQ,UAAYjB,GACxBC,EAAA,CAEJ,EAAG,CAACD,EAAQC,CAAO,CAAC,EAEpBiB,EAAAA,UAAU,KACR,SAAS,iBAAiB,UAAWH,CAAa,EAC3C,IAAM,SAAS,oBAAoB,UAAWA,CAAa,GACjE,CAACA,CAAa,CAAC,EAElB,MAAM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AACK,EAAAA,EAAA,CAAE,UAAU,SAAA,CAAU,EACvBL,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,wEAAwE,SAAA,KAAA,CAEvF,CAAA,CAAA,CACF,CAAA,CAAA,CACF,EAEJ,EAIFA,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAWE,EAAAA,GAAG,iBAAkBZ,EAAsB,kBAAoB,GAAIE,CAAiB,EACjG,SAAAP,CAAA,CACH,EAGCC,GACCc,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,iGACZ,SAAAd,CAAA,CACH,CAAA,CAAA,CAAA,CAEJ,CAAA,CACF,EACF,EAEJ,EAGF,OAAOoB,eAAaP,EAAS,SAAS,IAAI,CAC5C"}
|
package/dist/index.d.ts
CHANGED
|
@@ -33,6 +33,15 @@ declare const alertVariants: (props?: ({
|
|
|
33
33
|
variant?: "default" | "destructive" | null | undefined;
|
|
34
34
|
} & ClassProp) | undefined) => string;
|
|
35
35
|
|
|
36
|
+
declare interface Assistant {
|
|
37
|
+
provider: string;
|
|
38
|
+
name: string;
|
|
39
|
+
image?: string;
|
|
40
|
+
type: AssistantType;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
declare type AssistantType = "core" | "agent";
|
|
44
|
+
|
|
36
45
|
export declare const Avatar: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLDivElement> & React_2.RefAttributes<HTMLDivElement>>;
|
|
37
46
|
|
|
38
47
|
export declare const AvatarFallback: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLDivElement> & React_2.RefAttributes<HTMLDivElement>>;
|
|
@@ -292,6 +301,24 @@ export declare const DropdownMenuSeparator: React_2.ForwardRefExoticComponent<Dr
|
|
|
292
301
|
|
|
293
302
|
export declare const DropdownMenuTrigger: React_2.ForwardRefExoticComponent<DropdownMenuPrimitive.DropdownMenuTriggerProps & React_2.RefAttributes<HTMLButtonElement>>;
|
|
294
303
|
|
|
304
|
+
export declare const getAssistantIcon: (assistant: Assistant, props?: Props) => JSX_2.Element;
|
|
305
|
+
|
|
306
|
+
export declare const getLLMIcon: (provider: string, props?: Props) => JSX_2.Element;
|
|
307
|
+
|
|
308
|
+
declare interface IconProps {
|
|
309
|
+
className?: string;
|
|
310
|
+
size?: number;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export declare const Icons: {
|
|
314
|
+
claude: (props: IconProps) => JSX_2.Element;
|
|
315
|
+
anthropic: (props: IconProps) => JSX_2.Element;
|
|
316
|
+
openai: (props: IconProps) => JSX_2.Element;
|
|
317
|
+
deepseek: (props: IconProps) => JSX_2.Element;
|
|
318
|
+
grok: (props: IconProps) => JSX_2.Element;
|
|
319
|
+
gemini: (props: IconProps) => JSX_2.Element;
|
|
320
|
+
};
|
|
321
|
+
|
|
295
322
|
export declare const Input: React_2.ForwardRefExoticComponent<InputProps & React_2.RefAttributes<HTMLInputElement>>;
|
|
296
323
|
|
|
297
324
|
export declare interface InputProps extends React_2.InputHTMLAttributes<HTMLInputElement> {
|
|
@@ -369,6 +396,11 @@ export declare const PopoverTrigger: React_2.ForwardRefExoticComponent<PopoverPr
|
|
|
369
396
|
|
|
370
397
|
export declare const Progress: React_2.ForwardRefExoticComponent<Omit<ProgressPrimitive.ProgressProps & React_2.RefAttributes<HTMLDivElement>, "ref"> & React_2.RefAttributes<HTMLDivElement>>;
|
|
371
398
|
|
|
399
|
+
declare interface Props {
|
|
400
|
+
className?: string;
|
|
401
|
+
size?: number;
|
|
402
|
+
}
|
|
403
|
+
|
|
372
404
|
export declare const RadioGroup: React_2.ForwardRefExoticComponent<Omit<RadioGroupPrimitive.RadioGroupProps & React_2.RefAttributes<HTMLDivElement>, "ref"> & React_2.RefAttributes<HTMLDivElement>>;
|
|
373
405
|
|
|
374
406
|
export declare const RadioGroupItem: React_2.ForwardRefExoticComponent<Omit<RadioGroupPrimitive.RadioGroupItemProps & React_2.RefAttributes<HTMLButtonElement>, "ref"> & React_2.RefAttributes<HTMLButtonElement>>;
|