the-omelet-ui 1.8.2 → 1.8.3
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/entries/dialog.d.ts +2 -0
- package/dist/entries/dialog.js +2 -2
- package/dist/entries/modal.js +15 -1
- package/package.json +1 -1
package/dist/entries/dialog.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ interface ConfirmOptions {
|
|
|
10
10
|
cancelVariant?: ButtonVariant;
|
|
11
11
|
confirmClassName?: string;
|
|
12
12
|
cancelClassName?: string;
|
|
13
|
+
icon?: ReactNode;
|
|
14
|
+
iconClassName?: string;
|
|
13
15
|
}
|
|
14
16
|
interface ConfirmContextType {
|
|
15
17
|
confirm: (options?: ConfirmOptions) => Promise<boolean>;
|
package/dist/entries/dialog.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a}from'../chunk-SDCZDRHR.js';import {createContext,useState,useCallback,useContext}from'react';import {jsxs,jsx}from'react/jsx-runtime';var c=createContext(void 0),l={primary:"bg-blue-600 hover:bg-blue-700 text-white",danger:"bg-[#FF382D] hover:bg-red-600 text-white",success:"bg-green-600 hover:bg-green-700 text-white",warning:"bg-yellow-500 hover:bg-yellow-600 text-white",secondary:"bg-gray-600 hover:bg-gray-700 text-white",ghost:"bg-transparent hover:bg-gray-100 text-gray-700 border border-gray-300"},b=({children:
|
|
1
|
+
import {a}from'../chunk-SDCZDRHR.js';import {createContext,useState,useCallback,useContext}from'react';import {jsxs,jsx}from'react/jsx-runtime';var c=createContext(void 0),l={primary:"bg-blue-600 hover:bg-blue-700 text-white",danger:"bg-[#FF382D] hover:bg-red-600 text-white",success:"bg-green-600 hover:bg-green-700 text-white",warning:"bg-yellow-500 hover:bg-yellow-600 text-white",secondary:"bg-gray-600 hover:bg-gray-700 text-white",ghost:"bg-transparent hover:bg-gray-100 text-gray-700 border border-gray-300"},b=({children:a$1})=>{let[t,r]=useState({isOpen:false,title:"\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E32\u0E23\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19",message:"\u0E04\u0E38\u0E13\u0E41\u0E19\u0E48\u0E43\u0E08\u0E27\u0E48\u0E32\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E32\u0E23\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E2B\u0E23\u0E37\u0E2D\u0E44\u0E21\u0E48",confirmText:"\u0E43\u0E0A\u0E48 \u0E22\u0E37\u0E19\u0E22\u0E31\u0E19",cancelText:"\u0E44\u0E21\u0E48 \u0E22\u0E01\u0E40\u0E25\u0E34\u0E01",confirmVariant:"danger",cancelVariant:"ghost",resolve:()=>{}}),m=useCallback(e=>new Promise(g=>{r({isOpen:true,title:e?.title||"\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E32\u0E23\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19",message:e?.message||"\u0E04\u0E38\u0E13\u0E41\u0E19\u0E48\u0E43\u0E08\u0E27\u0E48\u0E32\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E32\u0E23\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E2B\u0E23\u0E37\u0E2D\u0E44\u0E21\u0E48",confirmText:e?.confirmText||"\u0E43\u0E0A\u0E48 \u0E22\u0E37\u0E19\u0E22\u0E31\u0E19",cancelText:e?.cancelText||"\u0E44\u0E21\u0E48 \u0E22\u0E01\u0E40\u0E25\u0E34\u0E01",confirmVariant:e?.confirmVariant||"danger",cancelVariant:e?.cancelVariant||"ghost",confirmClassName:e?.confirmClassName,cancelClassName:e?.cancelClassName,icon:e?.icon,iconClassName:e?.iconClassName,resolve:g});}),[]),f=()=>{t.resolve(true),r(e=>({...e,isOpen:false}));},d=()=>{t.resolve(false),r(e=>({...e,isOpen:false}));},i=()=>{t.resolve(false),r(e=>({...e,isOpen:false}));};return jsxs(c.Provider,{value:{confirm:m},children:[a$1,t.isOpen&&jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-20 px-4",children:[jsx("div",{className:"fixed inset-0 bg-black/50",onClick:i}),jsxs("div",{className:"relative bg-white rounded-3xl shadow-2xl max-w-md w-full py-9 px-10 animate-slide-down",children:[jsx("button",{onClick:i,className:"absolute top-4 right-4 text-[#C9D7E3] hover:text-gray-600 transition-colors cursor-pointer","aria-label":"\u0E1B\u0E34\u0E14",children:jsx(a,{fontSize:14})}),t.icon&&jsx("div",{className:`flex justify-center mb-4 ${t.iconClassName||""}`,children:t.icon}),jsx("h2",{className:"text-2xl font-semibold text-center text-gray-900 mb-4",children:t.title}),jsx("p",{className:"text-center text-gray-600 mb-8 leading-relaxed",children:t.message}),jsxs("div",{className:"flex gap-4",children:[jsx("button",{onClick:d,className:`flex-1 px-6 py-3.5 font-medium rounded-lg transition-colors ${t.cancelClassName||l[t.cancelVariant||"ghost"]}`,children:t.cancelText}),jsx("button",{onClick:f,className:`flex-1 px-6 py-3.5 font-medium rounded-lg transition-colors ${t.confirmClassName||l[t.confirmVariant||"danger"]}`,children:t.confirmText})]})]})]}),jsx("style",{children:`
|
|
2
2
|
@keyframes slide-down {
|
|
3
3
|
from {
|
|
4
4
|
opacity: 0;
|
|
@@ -12,4 +12,4 @@ import {a}from'../chunk-SDCZDRHR.js';import {createContext,useState,useCallback,
|
|
|
12
12
|
.animate-slide-down {
|
|
13
13
|
animation: slide-down 0.3s ease-out;
|
|
14
14
|
}
|
|
15
|
-
`})]})},
|
|
15
|
+
`})]})},v=()=>{let a=useContext(c);if(!a)throw new Error("useConfirm must be used within a ConfirmProvider");return a};export{b as ConfirmProvider,v as useConfirm};
|
package/dist/entries/modal.js
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
import {a}from'../chunk-6GLPXMGB.js';import*as t from'react';import {createPortal}from'react-dom';import {jsx
|
|
1
|
+
import {a}from'../chunk-6GLPXMGB.js';import*as t from'react';import {createPortal}from'react-dom';import {jsxs,jsx}from'react/jsx-runtime';function P(a="ui-portal"){let[n,r]=t.useState(null);return t.useLayoutEffect(()=>{let e=document.getElementById(a);return e||(e=document.createElement("div"),e.id=a,document.body.appendChild(e)),r(e),()=>{e&&e.childElementCount===0&&e.remove();}},[a]),n}function D({open:a$1,onClose:n,icon:r,title:e,description:c,footer:f,wrapperClassName:N,contentClassName:M,showCloseX:L=false,closeOnEsc:p=true,closeOnOverlayClick:v=true,initialFocusRef:b,children:y}){let x=P(),i=t.useRef(null),R=t.useRef(null),C=t.useCallback(()=>{v&&n?.();},[v,n]);return t.useEffect(()=>{if(!a$1)return;R.current=document.activeElement??null;let d=document.body.style.overflow;document.body.style.overflow="hidden";let H=b?.current||i.current;requestAnimationFrame(()=>H?.focus());let h=l=>{if(l.key==="Escape"&&p&&(l.stopPropagation(),n?.()),l.key==="Tab"){let g=i.current;if(!g)return;let s=g.querySelectorAll('a[href],button,textarea,input,select,[tabindex]:not([tabindex="-1"])');if(!s.length)return;let w=s[0],E=s[s.length-1],k=document.activeElement;l.shiftKey&&k===w?(l.preventDefault(),E.focus()):!l.shiftKey&&k===E&&(l.preventDefault(),w.focus());}};return document.addEventListener("keydown",h),()=>{document.body.style.overflow=d,document.removeEventListener("keydown",h),R.current?.focus?.();}},[a$1,p,n,b]),!a$1||!x?null:createPortal(jsxs("div",{className:a("fixed inset-0 z-[1000] grid place-items-center p-4 bg-black/50",N),onMouseDown:C,"aria-live":"polite",children:[jsxs("div",{role:"dialog","aria-modal":"true",ref:i,tabIndex:-1,onMouseDown:d=>d.stopPropagation(),className:a("relative w-full max-w-[480px] rounded-2xl bg-white shadow-xl outline-none px-6 py-6 animate-slide-down",M),children:[L&&jsx("button",{"aria-label":"Close",onClick:n,className:"absolute right-3 top-3 grid h-8 w-8 place-items-center rounded-full text-black/60 hover:bg-black/5 focus-visible:ring-2 ring-black/20",children:jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18","aria-hidden":true,children:jsx("path",{d:"M6 6l12 12M18 6L6 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})}),(r||e||c)&&jsxs("div",{className:"text-center",children:[r&&jsx("div",{className:"mb-4 flex justify-center",children:r}),e&&jsx("h2",{className:"text-xl font-semibold text-black",children:e}),c&&jsx("p",{className:"mt-2 text-black/70",children:c})]}),y&&jsx("div",{className:"mt-4",children:y}),f&&jsx("div",{className:"mt-6 flex items-center justify-center gap-3",children:f})]}),jsx("style",{children:`
|
|
2
|
+
@keyframes slide-down {
|
|
3
|
+
from {
|
|
4
|
+
opacity: 0;
|
|
5
|
+
transform: translateY(-20px);
|
|
6
|
+
}
|
|
7
|
+
to {
|
|
8
|
+
opacity: 1;
|
|
9
|
+
transform: translateY(0);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
.animate-slide-down {
|
|
13
|
+
animation: slide-down 0.3s ease-out;
|
|
14
|
+
}
|
|
15
|
+
`})]}),x)}var A=D;export{A as default};
|