aark-react-modalify 1.2.2 → 1.3.0
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/aark-react-modalify.css +1 -1
- package/dist/index-no-styles.cjs.js +14 -1
- package/dist/index-no-styles.d.mts +189 -0
- package/dist/index-no-styles.d.ts +189 -0
- package/dist/index-no-styles.esm.js +14 -14
- package/dist/index.cjs.js +14 -51
- package/dist/index.d.mts +189 -0
- package/dist/index.d.ts +189 -9
- package/dist/index.esm.js +14 -62
- package/package.json +86 -92
- package/dist/components/Icon.d.ts +0 -18
- package/dist/components/Modal.d.ts +0 -9
- package/dist/components/ModalProvider.d.ts +0 -7
- package/dist/components/Notification.d.ts +0 -9
- package/dist/components/modals/StandardModal.d.ts +0 -8
- package/dist/components/modals/index.d.ts +0 -1
- package/dist/components/notifications/StandardNotification.d.ts +0 -8
- package/dist/components/notifications/index.d.ts +0 -1
- package/dist/hooks/useModal.d.ts +0 -10
- package/dist/logic/ModalManager.d.ts +0 -24
- package/dist/logic/ModalManagerNew.d.ts +0 -0
- package/dist/logic/aark.d.ts +0 -15
- package/dist/types/index.d.ts +0 -102
- package/dist/utils/inject-styles.d.ts +0 -4
- package/dist/utils/modal-css.d.ts +0 -1
- package/dist/utils/modal-root.d.ts +0 -18
- package/dist/utils/theme.d.ts +0 -40
- package/dist/vite.svg +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
:root{--aark-modal-overlay-bg:rgba(0,0,0
|
|
1
|
+
:root{--aark-modal-overlay-bg: rgba(0, 0, 0, .5);--aark-modal-overlay-blur: 0px;--aark-modal-bg: #fff;--aark-modal-radius: 8px;--aark-modal-shadow: 0 10px 25px rgba(0, 0, 0, .15);--aark-modal-pad: 16px;--aark-modal-max-width: 700px;--aark-modal-z: 9999;--aark-close-color: #666;--aark-close-hover: #f5f5f5;--aark-close-hover-color: #333;--aark-close-focus-outline: 2px solid #007bff;--aark-anim: .2s}.aark-modal-overlay{position:fixed;inset:0;z-index:var(--aark-modal-z);pointer-events:auto}.aark-modal-container{width:100%;max-width:var(--aark-modal-max-width);min-width:280px;position:relative;z-index:2;pointer-events:auto}.aark-modal-wrapper{width:100%;height:100%;position:relative;z-index:2;pointer-events:auto}.aark-modal-container.center{animation:scale-in var(--aark-anim)}.aark-modal-container.top-center{animation:slide-down var(--aark-anim)}.aark-modal-container.top-right{animation:slide-left var(--aark-anim)}.aark-modal-container.top-left{animation:slide-right var(--aark-anim)}.aark-modal-container.bottom-right{animation:slide-left var(--aark-anim)}.aark-modal-container.bottom-left{animation:slide-right var(--aark-anim)}.aark-modal-container.bottom-center{animation:slide-up var(--aark-anim)}.aark-modal-header{position:relative;padding-bottom:0;margin-bottom:0}.aark-modal-close{position:absolute;top:8px;right:8px;width:30px;height:30px;padding:.5rem;display:flex;align-items:center;justify-content:center;background:transparent;border:0;color:var(--aark-close-color);cursor:pointer;border-radius:50%;font-size:14px;line-height:1;transition:all var(--aark-anim);z-index:10}.aark-modal-close:hover{background:var(--aark-close-hover);color:var(--aark-close-hover-color)}.aark-modal-close:focus{outline:var(--aark-close-focus-outline);outline-offset:2px}.aark-modal-body{background:var(--aark-modal-bg);border-radius:var(--aark-modal-radius);box-shadow:var(--aark-modal-shadow);padding:var(--aark-modal-pad);width:100%;max-height:90vh;overflow-y:auto;margin:auto;position:relative;z-index:2;pointer-events:auto;box-sizing:border-box}.aark-modal-content{flex:1;margin:1rem 0}.aark-modal-footer{display:flex;gap:.5rem;justify-content:flex-end;margin-top:1.5rem}.aark-standard-modal{background:var(--aark-modal-bg);border-radius:var(--aark-modal-radius);box-shadow:var(--aark-modal-shadow);padding:var(--aark-modal-pad);max-height:90vh;overflow-y:auto;margin:auto;display:flex;flex-direction:column;position:relative;z-index:2;pointer-events:auto;box-sizing:border-box;width:100%;max-width:var(--aark-modal-max-width);min-width:280px}@media(max-width:768px){.aark-modal-container,.aark-standard-modal{width:calc(100vw - 24px);max-width:calc(100vw - 24px);margin:12px}.aark-modal-body{max-height:calc(100vh - 80px)}}@media(max-width:480px){.aark-modal-container,.aark-standard-modal{width:calc(100vw - 16px);max-width:calc(100vw - 16px);margin:8px;max-height:calc(100vh - 40px)}.aark-modal-body{max-height:calc(100vh - 40px);border-radius:calc(var(--aark-modal-radius) / 2)}}.aark-standard-modal .aark-modal-header{margin-bottom:1rem}.aark-standard-modal .aark-modal-title{margin:0;font-size:1.5rem;font-weight:600;color:#1f2937;text-align:center}.aark-standard-modal .aark-modal-content{flex:1;margin:1rem 0}.aark-standard-modal .aark-modal-icon{text-align:center;font-size:3rem;margin-bottom:1rem}.aark-standard-modal .aark-modal-content p{margin:0;font-size:1rem;color:#6b7280;line-height:1.5;text-align:center}.aark-standard-modal .aark-modal-footer{display:flex;gap:.5rem;justify-content:flex-end;margin-top:1.5rem}.aark-standard-modal .aark-modal-cancel-button,.aark-standard-modal .aark-modal-confirm-button{padding:.5rem 1rem;border-radius:4px;cursor:pointer;font-size:.875rem;font-weight:500;transition:all .2s;border:none}.aark-standard-modal .aark-modal-cancel-button{border:1px solid #d1d5db;background:#fff;color:#374151}.aark-standard-modal .aark-modal-cancel-button:hover{background:#f9fafb;border-color:#9ca3af}.aark-standard-modal .aark-modal-confirm-button{color:#fff}.aark-standard-modal .aark-modal-confirm-button:hover{opacity:.9}@keyframes fade-in{0%{opacity:0}to{opacity:1}}:root{--aark-notification-bg: #fff;--aark-notification-radius: 8px;--aark-notification-shadow: 0 4px 12px rgba(0, 0, 0, .1);--aark-notification-pad: 16px;--aark-notification-z: 10000;--aark-close-color: #666;--aark-close-hover: #f5f5f5;--aark-anim: .2s}.aark-notification-container{pointer-events:auto;width:auto;max-width:400px;min-width:280px;position:relative;z-index:10001}.aark-notification-wrapper{position:relative;z-index:10001;pointer-events:auto}.aark-notification-container.center{animation:scale-in var(--aark-anim)}.aark-notification-container.top-center{animation:slide-down var(--aark-anim)}.aark-notification-container.top-right{animation:slide-left var(--aark-anim)}.aark-notification-container.top-left{animation:slide-right var(--aark-anim)}.aark-notification-container.bottom-right{animation:slide-left var(--aark-anim)}.aark-notification-container.bottom-left{animation:slide-right var(--aark-anim)}.aark-notification-container.bottom-center{animation:slide-up var(--aark-anim)}.aark-standard-notification{background:var(--aark-notification-bg);border-radius:var(--aark-notification-radius);box-shadow:var(--aark-notification-shadow);padding:var(--aark-notification-pad);position:relative;overflow:hidden;cursor:pointer;transition:all var(--aark-anim);border:1px solid #e5e7eb;max-width:400px;min-width:280px;z-index:10001;pointer-events:auto}.aark-standard-notification:hover{box-shadow:0 8px 25px #00000026;transform:translateY(-1px)}.aark-notification-header{margin-bottom:.5rem;position:relative;z-index:10001;pointer-events:auto}.aark-notification-title{margin:0;font-size:.875rem;font-weight:600;color:#1f2937;line-height:1.25}.aark-notification-content{color:#6b7280;font-size:.75rem;line-height:1.4;background-color:var(--aark-notification-bg);position:relative;z-index:10001;pointer-events:auto}.aark-notification-body{background:var(--aark-notification-bg);border-radius:var(--aark-notification-radius);box-shadow:var(--aark-notification-shadow);padding:var(--aark-notification-pad);position:relative;z-index:10001;pointer-events:auto}.aark-notification-content p{margin:0}.aark-notification-icon{font-size:1.25rem;flex-shrink:0;margin-top:.125rem;position:relative;z-index:10001;pointer-events:auto}.aark-notification-close{background:none;border:none;font-size:1rem;color:#9ca3af;cursor:pointer;padding:0;line-height:1;flex-shrink:0;transition:color var(--aark-anim);position:relative;z-index:10002;pointer-events:auto}.aark-notification-close:hover{color:#6b7280}.aark-notification-close:focus{outline:2px solid #3b82f6;outline-offset:2px;border-radius:2px}.aark-notification-footer{display:flex;gap:.5rem;justify-content:flex-end;margin-top:1rem;position:relative;z-index:10001;pointer-events:auto}.aark-notification-cancel-button,.aark-notification-confirm-button{padding:.5rem 1rem;border-radius:4px;cursor:pointer;font-size:.875rem;font-weight:500;transition:all .2s;border:none;position:relative;z-index:10001;pointer-events:auto}.aark-notification-cancel-button{border:1px solid #d1d5db;background:#fff;color:#374151}.aark-notification-cancel-button:hover{background:#f9fafb;border-color:#9ca3af}.aark-notification-confirm-button{color:#fff}.aark-notification-confirm-button:hover{opacity:.9}.aark-notification-progress{position:absolute;bottom:0;left:0;height:3px;transform-origin:left;border-radius:0 0 var(--aark-notification-radius) var(--aark-notification-radius)}.aark-notification-success{border-left:4px solid #4ade80}.aark-notification-error{border-left:4px solid #ef4444}.aark-notification-warning{border-left:4px solid #f59e0b}.aark-notification-info{border-left:4px solid #3b82f6}.aark-notification-question{border-left:4px solid #8b5cf6}@keyframes aark-notification-progress{0%{transform:scaleX(1)}to{transform:scaleX(0)}}@keyframes notification-fade-in{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}@keyframes notification-fade-out{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-10px)}}@keyframes notification-slide-in-right{0%{opacity:0;transform:translate(100%)}to{opacity:1;transform:translate(0)}}@keyframes notification-slide-out-right{0%{opacity:1;transform:translate(0)}to{opacity:0;transform:translate(100%)}}@keyframes notification-slide-in-left{0%{opacity:0;transform:translate(-100%)}to{opacity:1;transform:translate(0)}}@keyframes notification-slide-out-left{0%{opacity:1;transform:translate(0)}to{opacity:0;transform:translate(-100%)}}@keyframes scale-in{0%{opacity:0;transform:scale(.9)}to{opacity:1;transform:scale(1)}}@keyframes slide-down{0%{opacity:0;transform:translateY(-20px)}to{opacity:1;transform:translateY(0)}}@keyframes slide-up{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}@keyframes slide-left{0%{opacity:0;transform:translate(20px)}to{opacity:1;transform:translate(0)}}@keyframes slide-right{0%{opacity:0;transform:translate(-20px)}to{opacity:1;transform:translate(0)}}@media(max-width:768px){.aark-notification-container,.aark-standard-notification{max-width:calc(100vw - 40px);min-width:auto}}@media(max-width:480px){.aark-notification-container{max-width:calc(100vw - 20px)}.aark-standard-notification{max-width:calc(100vw - 20px);min-width:auto}}
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),e=require("react-dom/client"),t=require("react/jsx-runtime"),a=require("react-dom");function r(){const[e,t]=o.useState(!1),[a,r]=o.useState(null),n=o.useCallback(()=>{w.close()},[]);return o.useEffect(()=>{const o=w.subscribe(o=>{switch(o.type){case"open":t(!0),r(o.config||null);break;case"close":t(!1),r(null)}});return t(w.isOpen()),r(w.getCurrentConfig()),o},[]),{isOpen:e,config:a,close:n}}const n={white:"#FFFFFF",black:"#0B071A"},l=o.memo(({name:e,color:a="black",style:r,className:l="",noHoverEffect:s=!1,onClick:i,size:c=24,"aria-label":d,title:m})=>{const u=o.useMemo(()=>String(c),[c]),p=o.useMemo(()=>n[a]?n[a]:(a.startsWith("#"),a),[a]),f=o.useMemo(()=>{const o=p;return"close"===e?t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:u,height:u,viewBox:"0 0 16 16",fill:"none",children:t.jsx("path",{d:"M15.281 14.2198C15.3507 14.2895 15.406 14.3722 15.4437 14.4632C15.4814 14.5543 15.5008 14.6519 15.5008 14.7504C15.5008 14.849 15.4814 14.9465 15.4437 15.0376C15.406 15.1286 15.3507 15.2114 15.281 15.281C15.2114 15.3507 15.1286 15.406 15.0376 15.4437C14.9465 15.4814 14.849 15.5008 14.7504 15.5008C14.6519 15.5008 14.5543 15.4814 14.4632 15.4437C14.3722 15.406 14.2895 15.3507 14.2198 15.281L8.00042 9.06073L1.78104 15.281C1.64031 15.4218 1.44944 15.5008 1.25042 15.5008C1.05139 15.5008 0.860523 15.4218 0.719792 15.281C0.579062 15.1403 0.5 14.9494 0.5 14.7504C0.5 14.5514 0.579062 14.3605 0.719792 14.2198L6.9401 8.00042L0.719792 1.78104C0.579062 1.64031 0.5 1.44944 0.5 1.25042C0.5 1.05139 0.579062 0.860523 0.719792 0.719792C0.860523 0.579062 1.05139 0.5 1.25042 0.5C1.44944 0.5 1.64031 0.579062 1.78104 0.719792L8.00042 6.9401L14.2198 0.719792C14.3605 0.579062 14.5514 0.5 14.7504 0.5C14.9494 0.5 15.1403 0.579062 15.281 0.719792C15.4218 0.860523 15.5008 1.05139 15.5008 1.25042C15.5008 1.44944 15.4218 1.64031 15.281 1.78104L9.06073 8.00042L15.281 14.2198Z",fill:o})}):null},[e,p,u]),y=o.useMemo(()=>{const o={};return o["aria-label"]=d||`${e} icon`,m&&(o.title=m),o.role=i?"button":"img",o},[d,m,e,i]),k=o.useMemo(()=>{if(i)return o=>{"Enter"!==o.key&&" "!==o.key||(o.preventDefault(),i())}},[i]);return t.jsx("i",{className:`\n inline-flex items-center justify-center bg-transparent outline-none border-none\n ${!s&&i&&"hover:opacity-80 cursor-pointer transition-opacity duration-200"}\n ${i&&"focus:outline-2 focus:outline-blue-500 focus:outline-offset-2"}\n ${l}\n `.trim(),style:r,onClick:i,onKeyDown:k,tabIndex:i?0:void 0,...y,children:f})});l.displayName="Icon";const s={success:"✓",error:"✕",warning:"⚠",info:"ⓘ",question:"?"},i={success:"#4ade80",error:"#ef4444",warning:"#f59e0b",info:"#3b82f6",question:"#8b5cf6"},c=({props:e,onClose:a})=>{const{title:r,text:n,type:l="info",cancelText:c="Cancel",confirmText:d="OK",onCancel:m,onConfirm:u,icon:p,html:f,showCancelButton:y=!1,showConfirmButton:k=!0,reverseButtons:g=!1,width:h="auto",fullWidth:v=!1,customClass:x={}}=e,C=()=>{m?.(),a()},b=()=>{u?.(),a()},P=o.useMemo(()=>p?"string"==typeof p?t.jsx("span",{children:p}):p:t.jsx("span",{style:{color:i[l]},children:s[l]}),[p,l]),j=g?["confirm","cancel"]:["cancel","confirm"],w=o.useMemo(()=>{const o={};return v?(o.width="calc(100vw - 20px)",o.maxWidth="calc(100vw - 20px)"):o.width="number"==typeof h?`${h}px`:h,o},[h,v]);return t.jsxs("div",{className:`aark-standard-modal ${x.popup||""}`,style:w,children:[t.jsxs("div",{className:`aark-modal-content ${x.content||""}`,children:[P&&t.jsx("div",{className:`aark-modal-icon ${x.icon||""}`,children:P}),r&&t.jsx("div",{className:`aark-modal-header ${x.header||""}`,children:t.jsx("h2",{className:`aark-modal-title ${x.title||""}`,children:r})}),f?t.jsx("div",{dangerouslySetInnerHTML:{__html:"string"==typeof f?f:""}}):n?t.jsx("p",{children:n}):null]}),(y||k)&&t.jsx("div",{className:`aark-modal-footer ${x.actions||""}`,children:j.map(o=>"cancel"===o&&y?t.jsx("button",{onClick:C,className:`aark-modal-cancel-button ${x.cancelButton||""}`,children:c},"cancel"):"confirm"===o&&k?t.jsx("button",{onClick:b,className:`aark-modal-confirm-button ${x.confirmButton||""}`,style:{background:i[l]},children:d},"confirm"):null)})]})};let d=null;const m=()=>(d||(d=document.getElementById("aark-react-modalify-root"),d||(d=document.createElement("div"),d.id="aark-react-modalify-root",d.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n z-index: 9998;\n ",document.body.appendChild(d))),d),u=({config:e,onClose:r})=>{const{content:n,props:s,options:i={}}=e,{position:d="center",showCloseIcon:u=!0,className:p="",overlayClassName:f="",preventEscClose:y=!1,preventOverlayClose:k=!1}=i;o.useEffect(()=>{const o=o=>{"Escape"!==o.key||y||r()};if(!y)return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[r,y]);const g=o.useCallback(o=>{o.target!==o.currentTarget||k||r()},[r,k]),h=o.useCallback(o=>{o.stopPropagation(),r()},[r]),v=`aark-modal-container ${d} ${p}`.trim(),x=m();return a.createPortal(t.jsx("div",{className:`aark-modal-overlay ${f}`.trim(),onClick:g,"aria-hidden":"true",style:{position:"fixed",inset:0,zIndex:9999,background:"var(--aark-modal-overlay-bg)",backdropFilter:"blur(2px)",animation:"fade-in var(--aark-anim)",display:"flex",alignItems:d.includes("center")?"center":d.includes("top")?"flex-start":"flex-end",justifyContent:d.includes("center")?"center":d.includes("right")?"flex-end":"flex-start",padding:"1rem"},children:s?t.jsxs("div",{className:v,role:"dialog","aria-modal":"true",onClick:o=>o.stopPropagation(),children:[u&&t.jsx("button",{onClick:h,className:"aark-modal-close","aria-label":"Close Modal",type:"button",children:t.jsx(l,{name:"close",size:12})}),t.jsx("div",{className:"aark-modal-wrapper",children:t.jsx(c,{props:s,onClose:r})})]}):n?t.jsxs("div",{className:v,role:"dialog","aria-modal":"true",onClick:o=>o.stopPropagation(),children:[u&&t.jsx("button",{onClick:h,className:"aark-modal-close","aria-label":"Close Modal",type:"button",children:t.jsx(l,{name:"close",size:12})}),t.jsx("div",{className:"aark-modal-body",children:n})]}):null}),x)},p={success:"✓",error:"✕",warning:"⚠",info:"ⓘ",question:"?"},f={success:"#4ade80",error:"#ef4444",warning:"#f59e0b",info:"#3b82f6",question:"#8b5cf6"},y=({props:e,onClose:a})=>{const{title:r,text:n,type:l="info",icon:s,html:i,timer:c=5e3,showCloseButton:d=!0,clickToClose:m=!0,width:u="300px",fullWidth:y=!1,padding:k="1rem",background:g="#ffffff",customClass:h={}}=e;o.useEffect(()=>{if(c&&c>0){const o=setTimeout(a,c);return()=>clearTimeout(o)}},[c,a]);const v=o.useMemo(()=>s?"string"==typeof s?t.jsx("span",{children:s}):s:t.jsx("span",{style:{color:f[l]},children:p[l]}),[s,l]),x=o.useMemo(()=>{const o={padding:k,background:g,borderRadius:"8px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.1)",border:`1px solid ${f[l]}`,cursor:m?"pointer":"default",position:"relative",overflow:"hidden"};return y?(o.width="calc(100vw - 40px)",o.maxWidth="calc(100vw - 40px)"):o.width="number"==typeof u?`${u}px`:u,o},[u,y,k,g,l,m]);return t.jsxs("div",{className:`aark-standard-notification ${h.popup||""}`,style:x,onClick:()=>{m&&a()},children:[c&&c>0&&t.jsx("div",{style:{position:"absolute",bottom:0,left:0,height:"3px",background:f[l],animation:`aark-notification-progress ${c}ms linear forwards`,transformOrigin:"left"}}),t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem"},children:[v&&t.jsx("div",{className:`aark-notification-icon ${h.icon||""}`,style:{fontSize:"1.25rem",flexShrink:0,marginTop:"0.125rem"},children:v}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[r&&t.jsx("div",{className:`aark-notification-header ${h.header||""}`,children:t.jsx("h4",{className:`aark-notification-title ${h.title||""}`,style:{margin:0,fontSize:"0.875rem",fontWeight:"600",color:"#1f2937"},children:r})}),t.jsx("div",{className:`aark-notification-content ${h.content||""}`,style:{marginTop:r?"0.25rem":0},children:i?t.jsx("div",{dangerouslySetInnerHTML:{__html:"string"==typeof i?i:""}}):n?t.jsx("p",{style:{margin:0,fontSize:"0.75rem",color:"#6b7280",lineHeight:"1.4"},children:n}):null})]}),d&&t.jsx("button",{onClick:o=>{o.stopPropagation(),a()},className:`aark-notification-close ${h.closeButton||""}`,style:{background:"none",border:"none",fontSize:"1rem",color:"#9ca3af",cursor:"pointer",padding:0,lineHeight:1,flexShrink:0},"aria-label":"Close notification",children:"×"})]}),t.jsx("style",{children:"\n @keyframes aark-notification-progress {\n from {\n transform: scaleX(1);\n }\n to {\n transform: scaleX(0);\n }\n }\n "})]})},k=({config:e,onClose:r})=>{const{content:n,props:l,options:s={}}=e,{position:i="top-right",showCloseIcon:c=!0,autoCloseTime:d=5e3,className:u="",preventEscClose:p=!1}=s;o.useEffect(()=>{if(d&&!l){const o=setTimeout(r,d);return()=>clearTimeout(o)}},[d,r,l]),o.useEffect(()=>{const o=o=>{"Escape"!==o.key||p||r()};if(!p)return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[r,p]);const f=o.useCallback(o=>{o.stopPropagation(),r()},[r]),k=`aark-notification-container ${i} ${u}`.trim(),g=m();return a.createPortal(t.jsx("div",{style:(()=>{const o={position:"fixed",zIndex:1e4,margin:"1rem"};switch(i){case"top-left":return{...o,top:0,left:0};case"top-center":return{...o,top:0,left:"50%",transform:"translateX(-50%)"};case"top-right":default:return{...o,top:0,right:0};case"bottom-left":return{...o,bottom:0,left:0};case"bottom-center":return{...o,bottom:0,left:"50%",transform:"translateX(-50%)"};case"bottom-right":return{...o,bottom:0,right:0}}})(),children:l?t.jsx("div",{className:"aark-notification-wrapper",children:t.jsx(y,{props:l,onClose:r})}):n?t.jsxs("div",{className:k,role:"alert","aria-live":"polite","aria-labelledby":"aark-notification-content",children:[c&&t.jsx("button",{onClick:f,className:"aark-notification-close","aria-label":"Close notification",type:"button",children:"×"}),t.jsx("div",{id:"aark-notification-body",className:"aark-notification-body",children:n})]}):null}),g)},g=()=>{const{isOpen:o,config:e,close:a}=r();return o&&e?"modal"===e.mode?t.jsx(u,{config:e,onClose:a}):"notification"===e.mode?t.jsx(k,{config:e,onClose:a}):null:null},h=new Set;let v=null,x=null;function C(){if(x)return;const t=m();x=e.createRoot(t),x.render(o.createElement(g))}function b(o,e){const t={type:o,config:e};h.forEach(o=>o(t))}function P(o,e){let t,a;C(),!o||"object"!=typeof o||"$$typeof"in o||Array.isArray(o)?(t=o,a=void 0):(a=o,t=void 0);const r={content:t,props:a,mode:"modal",options:Object.assign({position:"center",showCloseIcon:!0,preventEscClose:!1,preventOverlayClose:!1},e)};v=r,b("open",r)}function j(){v&&(b("beforeClose",v),v=null,b("close"))}const w={subscribe:function(o){return h.add(o),()=>h.delete(o)},fire:function(o,e){P(o,e)},fireModal:P,fireNotification:function(o,e){let t,a;C(),!o||"object"!=typeof o||"$$typeof"in o||Array.isArray(o)?(t=o,a=void 0):(a=o,t=void 0);const r={content:t,props:a,mode:"notification",options:Object.assign({position:"top-right",showCloseIcon:!0,autoCloseTime:5e3,preventEscClose:!1},e)};v=r,b("open",r)},close:j,isOpen:function(){return null!==v},getCurrentConfig:function(){return v},closeAll:function(){j()},cleanup:function(){x&&(x.unmount(),x=null),d&&0===d.children.length&&(d.remove(),d=null)}};function B(o){const e=document.documentElement;o.overlayBackground&&e.style.setProperty("--aark-modal-overlay-bg",o.overlayBackground),o.overlayBlur&&e.style.setProperty("--aark-modal-overlay-blur",o.overlayBlur),o.modalBackground&&e.style.setProperty("--aark-modal-bg",o.modalBackground),o.modalBorderRadius&&e.style.setProperty("--aark-modal-border-radius",o.modalBorderRadius),o.modalShadow&&e.style.setProperty("--aark-modal-shadow",o.modalShadow),o.modalPadding&&e.style.setProperty("--aark-modal-padding",o.modalPadding),o.modalZIndex&&e.style.setProperty("--aark-modal-z-index",o.modalZIndex.toString()),o.modalContentZIndex&&e.style.setProperty("--aark-modal-content-z-index",o.modalContentZIndex.toString()),o.closeButtonColor&&e.style.setProperty("--aark-modal-close-color",o.closeButtonColor),o.closeButtonHoverBackground&&e.style.setProperty("--aark-modal-close-hover-bg",o.closeButtonHoverBackground),o.closeButtonHoverColor&&e.style.setProperty("--aark-modal-close-hover-color",o.closeButtonHoverColor),o.closeButtonFocusOutline&&e.style.setProperty("--aark-modal-close-focus-outline",o.closeButtonFocusOutline),o.animationDuration&&e.style.setProperty("--aark-modal-animation-duration",o.animationDuration),o.fadeDuration&&e.style.setProperty("--aark-modal-fade-duration",o.fadeDuration),o.customOverlayBackground&&e.style.setProperty("--aark-custom-overlay-bg",o.customOverlayBackground),o.customOverlayBlur&&e.style.setProperty("--aark-custom-overlay-blur",o.customOverlayBlur),o.customModalGradientStart&&e.style.setProperty("--aark-custom-modal-gradient-start",o.customModalGradientStart),o.customModalGradientEnd&&e.style.setProperty("--aark-custom-modal-gradient-end",o.customModalGradientEnd),o.customModalTextColor&&e.style.setProperty("--aark-custom-modal-text-color",o.customModalTextColor),o.customModalShadow&&e.style.setProperty("--aark-custom-modal-shadow",o.customModalShadow),o.customModalCloseColor&&e.style.setProperty("--aark-custom-modal-close-color",o.customModalCloseColor),o.customModalCloseHoverBackground&&e.style.setProperty("--aark-custom-modal-close-hover-bg",o.customModalCloseHoverBackground),o.customModalCloseHoverColor&&e.style.setProperty("--aark-custom-modal-close-hover-color",o.customModalCloseHoverColor)}function M(){const o=document.documentElement;["--aark-modal-overlay-bg","--aark-modal-overlay-blur","--aark-modal-bg","--aark-modal-border-radius","--aark-modal-shadow","--aark-modal-padding","--aark-modal-z-index","--aark-modal-content-z-index","--aark-modal-close-color","--aark-modal-close-hover-bg","--aark-modal-close-hover-color","--aark-modal-close-focus-outline","--aark-modal-animation-duration","--aark-modal-fade-duration","--aark-custom-overlay-bg","--aark-custom-overlay-blur","--aark-custom-modal-gradient-start","--aark-custom-modal-gradient-end","--aark-custom-modal-text-color","--aark-custom-modal-shadow","--aark-custom-modal-close-color","--aark-custom-modal-close-hover-bg","--aark-custom-modal-close-hover-color"].forEach(e=>{o.style.removeProperty(e)})}function N(){const o=document.documentElement,e=getComputedStyle(o);return{overlayBackground:e.getPropertyValue("--aark-modal-overlay-bg").trim(),overlayBlur:e.getPropertyValue("--aark-modal-overlay-blur").trim(),modalBackground:e.getPropertyValue("--aark-modal-bg").trim(),modalBorderRadius:e.getPropertyValue("--aark-modal-border-radius").trim(),modalShadow:e.getPropertyValue("--aark-modal-shadow").trim(),modalPadding:e.getPropertyValue("--aark-modal-padding").trim(),modalZIndex:parseInt(e.getPropertyValue("--aark-modal-z-index").trim())||void 0,modalContentZIndex:parseInt(e.getPropertyValue("--aark-modal-content-z-index").trim())||void 0,closeButtonColor:e.getPropertyValue("--aark-modal-close-color").trim(),closeButtonHoverBackground:e.getPropertyValue("--aark-modal-close-hover-bg").trim(),closeButtonHoverColor:e.getPropertyValue("--aark-modal-close-hover-color").trim(),closeButtonFocusOutline:e.getPropertyValue("--aark-modal-close-focus-outline").trim(),animationDuration:e.getPropertyValue("--aark-modal-animation-duration").trim(),fadeDuration:e.getPropertyValue("--aark-modal-fade-duration").trim(),customOverlayBackground:e.getPropertyValue("--aark-custom-overlay-bg").trim(),customOverlayBlur:e.getPropertyValue("--aark-custom-overlay-blur").trim(),customModalGradientStart:e.getPropertyValue("--aark-custom-modal-gradient-start").trim(),customModalGradientEnd:e.getPropertyValue("--aark-custom-modal-gradient-end").trim(),customModalTextColor:e.getPropertyValue("--aark-custom-modal-text-color").trim(),customModalShadow:e.getPropertyValue("--aark-custom-modal-shadow").trim(),customModalCloseColor:e.getPropertyValue("--aark-custom-modal-close-color").trim(),customModalCloseHoverBackground:e.getPropertyValue("--aark-custom-modal-close-hover-bg").trim(),customModalCloseHoverColor:e.getPropertyValue("--aark-custom-modal-close-hover-color").trim()}}const $={fire:(o,e)=>w.fire(o,e),modal:(o,e)=>w.fireModal(o,e),notification:(o,e)=>w.fireNotification(o,e),close:()=>w.close(),isOpen:()=>w.isOpen(),closeAll:()=>w.closeAll(),setTheme:o=>B(o),resetTheme:()=>M(),getTheme:()=>N()};exports.Modal=u,exports.ModalProvider=g,exports.Notification=k,exports.aark=$,exports.getAarkModalTheme=N,exports.resetAarkModalTheme=M,exports.setAarkModalTheme=B,exports.useModal=r;
|
|
1
|
+
"use strict";var V=Object.defineProperty;var po=Object.getOwnPropertyDescriptor;var go=Object.getOwnPropertyNames;var yo=Object.prototype.hasOwnProperty;var vo=(e,o)=>{for(var t in o)V(e,t,{get:o[t],enumerable:!0})},ko=(e,o,t,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of go(o))!yo.call(e,n)&&n!==t&&V(e,n,{get:()=>o[n],enumerable:!(a=po(o,n))||a.enumerable});return e};var Co=e=>ko(V({},"__esModule",{value:!0}),e);var Oo={};vo(Oo,{Modal:()=>L,ModalProvider:()=>H,Notification:()=>W,aark:()=>uo,getAarkModalTheme:()=>_,resetAarkModalTheme:()=>Z,setAarkModalTheme:()=>D,useModal:()=>O});module.exports=Co(Oo);var ro=require("react"),lo=require("react-dom/client");var S=require("react");function O(){let[e,o]=(0,S.useState)(!1),[t,a]=(0,S.useState)(null),n=(0,S.useCallback)(()=>{h.close()},[]);return(0,S.useEffect)(()=>{let i=s=>{switch(s.type){case"open":o(!0),a(s.config||null);break;case"close":o(!1),a(null);break;case"beforeClose":break}},p=h.subscribe(i);return o(h.isOpen()),a(h.getCurrentConfig()),p},[]),{isOpen:e,config:t,close:n}}var T=require("react"),to=require("react-dom");var w=require("react"),z=require("react/jsx-runtime"),G={white:"#FFFFFF",black:"#0B071A"},J=(0,w.memo)(({name:e,color:o="black",style:t,className:a="",noHoverEffect:n=!1,onClick:i,size:p=24,"aria-label":s,title:x})=>{let f=(0,w.useMemo)(()=>String(p),[p]),m=(0,w.useMemo)(()=>G[o]?G[o]:(o.startsWith("#"),o),[o]),g=(0,w.useMemo)(()=>{let d=m;return e==="close"?(0,z.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:f,height:f,viewBox:"0 0 16 16",fill:"none",children:(0,z.jsx)("path",{d:"M15.281 14.2198C15.3507 14.2895 15.406 14.3722 15.4437 14.4632C15.4814 14.5543 15.5008 14.6519 15.5008 14.7504C15.5008 14.849 15.4814 14.9465 15.4437 15.0376C15.406 15.1286 15.3507 15.2114 15.281 15.281C15.2114 15.3507 15.1286 15.406 15.0376 15.4437C14.9465 15.4814 14.849 15.5008 14.7504 15.5008C14.6519 15.5008 14.5543 15.4814 14.4632 15.4437C14.3722 15.406 14.2895 15.3507 14.2198 15.281L8.00042 9.06073L1.78104 15.281C1.64031 15.4218 1.44944 15.5008 1.25042 15.5008C1.05139 15.5008 0.860523 15.4218 0.719792 15.281C0.579062 15.1403 0.5 14.9494 0.5 14.7504C0.5 14.5514 0.579062 14.3605 0.719792 14.2198L6.9401 8.00042L0.719792 1.78104C0.579062 1.64031 0.5 1.44944 0.5 1.25042C0.5 1.05139 0.579062 0.860523 0.719792 0.719792C0.860523 0.579062 1.05139 0.5 1.25042 0.5C1.44944 0.5 1.64031 0.579062 1.78104 0.719792L8.00042 6.9401L14.2198 0.719792C14.3605 0.579062 14.5514 0.5 14.7504 0.5C14.9494 0.5 15.1403 0.579062 15.281 0.719792C15.4218 0.860523 15.5008 1.05139 15.5008 1.25042C15.5008 1.44944 15.4218 1.64031 15.281 1.78104L9.06073 8.00042L15.281 14.2198Z",fill:d})}):null},[e,m,f]),c=(0,w.useMemo)(()=>{let d={};return s?d["aria-label"]=s:d["aria-label"]=`${e} icon`,x&&(d.title=x),d.role=i?"button":"img",d},[s,x,e,i]),u=(0,w.useMemo)(()=>{if(i)return d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),i())}},[i]);return(0,z.jsx)("i",{className:`
|
|
2
|
+
inline-flex items-center justify-center bg-transparent outline-none border-none
|
|
3
|
+
${!n&&i&&"hover:opacity-80 cursor-pointer transition-opacity duration-200"}
|
|
4
|
+
${i&&"focus:outline-2 focus:outline-blue-500 focus:outline-offset-2"}
|
|
5
|
+
${a}
|
|
6
|
+
`.trim(),style:t,onClick:i,onKeyDown:u,tabIndex:i?0:void 0,...c,children:g})});J.displayName="Icon";var j=J;var U=require("react"),C=require("react/jsx-runtime"),ho={success:"\u2713",error:"\u2715",warning:"\u26A0",info:"\u24D8",question:"?"},Q={success:"#4ade80",error:"#ef4444",warning:"#f59e0b",info:"#3b82f6",question:"#8b5cf6"},Mo=({props:e,onClose:o})=>{let{title:t,text:a,type:n="info",cancelText:i="Cancel",confirmText:p="OK",onCancel:s,onConfirm:x,icon:f,html:m,showCancelButton:g=!1,showConfirmButton:c=!0,reverseButtons:u=!1,width:d="auto",fullWidth:r=!1,customClass:y={}}=e,k=()=>{s?.(),o()},q=()=>{x?.(),o()},F=(0,U.useMemo)(()=>f?typeof f=="string"?(0,C.jsx)("span",{children:f}):f:(0,C.jsx)("span",{style:{color:Q[n]},children:ho[n]}),[f,n]),l=u?["confirm","cancel"]:["cancel","confirm"],E=(0,U.useMemo)(()=>{let N={};return r?(N.width="calc(100vw - 20px)",N.maxWidth="calc(100vw - 20px)"):typeof d=="number"?N.width=`${d}px`:N.width=d,N},[d,r]);return(0,C.jsxs)("div",{className:`aark-standard-modal ${y.popup||""}`,style:E,children:[(0,C.jsxs)("div",{className:`aark-modal-content ${y.content||""}`,children:[F&&(0,C.jsx)("div",{className:`aark-modal-icon ${y.icon||""}`,children:F}),t&&(0,C.jsx)("div",{className:`aark-modal-header ${y.header||""}`,children:(0,C.jsx)("h2",{className:`aark-modal-title ${y.title||""}`,children:t})}),m?(0,C.jsx)("div",{dangerouslySetInnerHTML:{__html:typeof m=="string"?m:""}}):a?(0,C.jsx)("p",{children:a}):null]}),(g||c)&&(0,C.jsx)("div",{className:`aark-modal-footer ${y.actions||""}`,children:l.map(N=>N==="cancel"&&g?(0,C.jsx)("button",{onClick:k,className:`aark-modal-cancel-button ${y.cancelButton||""}`,children:i},"cancel"):N==="confirm"&&c?(0,C.jsx)("button",{onClick:q,className:`aark-modal-confirm-button ${y.confirmButton||""}`,style:{background:Q[n]},children:p},"confirm"):null)})]})},oo=Mo;var M=null,R=()=>(M||(M=document.getElementById("aark-react-modalify-root"),M||(M=document.createElement("div"),M.id="aark-react-modalify-root",M.style.cssText=`
|
|
7
|
+
position: fixed;
|
|
8
|
+
top: 0;
|
|
9
|
+
left: 0;
|
|
10
|
+
width: 100%;
|
|
11
|
+
height: 100%;
|
|
12
|
+
pointer-events: none;
|
|
13
|
+
z-index: 9998;
|
|
14
|
+
`,document.body.appendChild(M))),M),eo=()=>{M&&M.children.length===0&&(M.remove(),M=null)};var b=require("react/jsx-runtime"),bo={sm:"400px",md:"550px",lg:"700px",xl:"900px",full:"calc(100vw - 32px)"},xo=({config:e,onClose:o})=>{let{content:t,props:a,options:n={}}=e,{position:i="center",showCloseIcon:p=!0,className:s="",overlayClassName:x="",preventEscClose:f=!1,preventOverlayClose:m=!1,width:g,maxWidth:c,size:u}=n;(0,T.useEffect)(()=>{if(f)return;let l=E=>{E.key==="Escape"&&o()};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[o,f]);let d=(0,T.useCallback)(l=>{l.target===l.currentTarget&&!m&&o()},[o,m]),r=(0,T.useCallback)(l=>{l.stopPropagation(),o()},[o]),y=(0,T.useMemo)(()=>{let l={};if(g!==void 0&&(l.width=typeof g=="number"?`${g}px`:g,c===void 0&&(l.maxWidth=l.width)),c!==void 0)l.maxWidth=typeof c=="number"?`${c}px`:c;else if(u){let E=bo[u];u==="full"&&(l.width=l.width??E),l.maxWidth=E}return l},[g,c,u]),k=`aark-modal-container ${i} ${s}`.trim(),q=R(),F=()=>a?(0,b.jsxs)("div",{className:k,style:y,role:"dialog","aria-modal":"true",onClick:l=>l.stopPropagation(),children:[p&&(0,b.jsx)("button",{onClick:r,className:"aark-modal-close","aria-label":"Close Modal",type:"button",children:(0,b.jsx)(j,{name:"close",size:12})}),(0,b.jsx)("div",{className:"aark-modal-wrapper",children:(0,b.jsx)(oo,{props:a,onClose:o})})]}):t?(0,b.jsx)("div",{className:k,style:y,role:"dialog","aria-modal":"true",onClick:l=>l.stopPropagation(),children:(0,b.jsxs)("div",{className:"aark-modal-body",children:[p&&(0,b.jsx)("button",{onClick:r,className:"aark-modal-close","aria-label":"Close Modal",type:"button",children:(0,b.jsx)(j,{name:"close",size:12})}),t]})}):null;return(0,to.createPortal)((0,b.jsx)("div",{className:`aark-modal-overlay ${x}`.trim(),onClick:d,"aria-hidden":"true",style:{position:"fixed",inset:0,zIndex:"var(--aark-modal-z, 9999)",background:"var(--aark-modal-overlay-bg)",backdropFilter:"blur(var(--aark-modal-overlay-blur, 0px))",WebkitBackdropFilter:"blur(var(--aark-modal-overlay-blur, 0px))",animation:"fade-in var(--aark-anim)",display:"flex",alignItems:i.includes("center")?"center":i.includes("top")?"flex-start":"flex-end",justifyContent:i.includes("center")?"center":i.includes("right")?"flex-end":"flex-start",padding:"1rem",overflowY:"auto",boxSizing:"border-box"},children:F()}),q)},L=xo;var A=require("react"),io=require("react-dom");var $=require("react"),v=require("react/jsx-runtime"),ao={success:"#4ade80",error:"#ef4444",warning:"#f59e0b",info:"#3b82f6",question:"#8b5cf6"},No={success:"\u2713",error:"\u2715",warning:"\u26A0",info:"\u24D8",question:"?"},wo=({props:e,onClose:o})=>{let{title:t,text:a,type:n="info",icon:i,html:p,timer:s=5e3,showCloseButton:x=!0,clickToClose:f=!0,width:m,fullWidth:g=!1,padding:c,customClass:u={}}=e;(0,$.useEffect)(()=>{if(s&&s>0){let k=setTimeout(o,s);return()=>clearTimeout(k)}},[s,o]);let d=()=>{f&&o()},r=(0,$.useMemo)(()=>i?typeof i=="string"?(0,v.jsx)("span",{children:i}):i:(0,v.jsx)("span",{style:{color:ao[n]},children:No[n]}),[i,n]),y=(0,$.useMemo)(()=>{let k={};return c!==void 0&&(k.padding=typeof c=="number"?`${c}px`:c),g?(k.width="calc(100vw - 40px)",k.maxWidth="calc(100vw - 40px)"):m!==void 0&&(k.width=typeof m=="number"?`${m}px`:m),k},[m,g,c]);return(0,v.jsxs)("div",{className:`aark-standard-notification aark-notification-${n} ${u.popup||""}`,style:y,onClick:d,children:[s&&s>0&&(0,v.jsx)("div",{className:"aark-notification-progress",style:{background:ao[n],animation:`aark-notification-progress ${s}ms linear forwards`}}),(0,v.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem"},children:[r&&(0,v.jsx)("div",{className:`aark-notification-icon ${u.icon||""}`,children:r}),(0,v.jsxs)("div",{style:{flex:1,minWidth:0},children:[t&&(0,v.jsx)("div",{className:`aark-notification-header ${u.header||""}`,children:(0,v.jsx)("h4",{className:`aark-notification-title ${u.title||""}`,children:t})}),(0,v.jsx)("div",{className:`aark-notification-content ${u.content||""}`,style:{marginTop:t?"0.25rem":0},children:p?(0,v.jsx)("div",{dangerouslySetInnerHTML:{__html:typeof p=="string"?p:""}}):a?(0,v.jsx)("p",{children:a}):null})]}),x&&(0,v.jsx)("button",{onClick:k=>{k.stopPropagation(),o()},className:`aark-notification-close ${u.closeButton||""}`,"aria-label":"Close notification",type:"button",children:"\xD7"})]})]})},no=wo;var P=require("react/jsx-runtime"),Po=({config:e,onClose:o})=>{let{content:t,props:a,options:n={}}=e,{position:i="top-right",showCloseIcon:p=!0,autoCloseTime:s=5e3,className:x="",preventEscClose:f=!1}=n;(0,A.useEffect)(()=>{if(s&&!a){let r=setTimeout(o,s);return()=>clearTimeout(r)}},[s,o,a]),(0,A.useEffect)(()=>{if(f)return;let r=y=>{y.key==="Escape"&&o()};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[o,f]);let m=(0,A.useCallback)(r=>{r.stopPropagation(),o()},[o]),g=`aark-notification-container ${i} ${x}`.trim(),c=R(),u=()=>{let r={position:"fixed",zIndex:1e4,margin:"1rem"};switch(i){case"top-left":return{...r,top:0,left:0};case"top-center":return{...r,top:0,left:"50%",transform:"translateX(-50%)"};case"top-right":return{...r,top:0,right:0};case"bottom-left":return{...r,bottom:0,left:0};case"bottom-center":return{...r,bottom:0,left:"50%",transform:"translateX(-50%)"};case"bottom-right":return{...r,bottom:0,right:0};default:return{...r,top:0,right:0}}},d=()=>a?(0,P.jsx)("div",{className:"aark-notification-wrapper",children:(0,P.jsx)(no,{props:a,onClose:o})}):t?(0,P.jsxs)("div",{className:g,role:"alert","aria-live":"polite",children:[p&&(0,P.jsx)("button",{onClick:m,className:"aark-notification-close","aria-label":"Close notification",type:"button",children:"\xD7"}),(0,P.jsx)("div",{className:"aark-notification-body",children:t})]}):null;return(0,io.createPortal)((0,P.jsx)("div",{style:u(),children:d()}),c)},W=Po;var X=require("react/jsx-runtime"),Eo=()=>{let{isOpen:e,config:o,close:t}=O();return!e||!o?null:o.mode==="modal"?(0,X.jsx)(L,{config:o,onClose:t}):o.mode==="notification"?(0,X.jsx)(W,{config:o,onClose:t}):null},H=Eo;var Y=new Set,B=null,I=null;function so(){if(I)return;let e=R();I=(0,lo.createRoot)(e),I.render((0,ro.createElement)(H))}function So(e){return Y.add(e),()=>Y.delete(e)}function K(e,o){let t={type:e,config:o};Y.forEach(a=>a(t))}function co(e,o){so();let t,a;e&&typeof e=="object"&&!("$$typeof"in e)&&!Array.isArray(e)?(a=e,t=void 0):(t=e,a=void 0);let n={content:t,props:a,mode:"modal",options:Object.assign({position:"center",showCloseIcon:!0,preventEscClose:!1,preventOverlayClose:!1},o)};B=n,K("open",n)}function To(e,o){so();let t,a;e&&typeof e=="object"&&!("$$typeof"in e)&&!Array.isArray(e)?(a=e,t=void 0):(t=e,a=void 0);let n={content:t,props:a,mode:"notification",options:Object.assign({position:"top-right",showCloseIcon:!0,autoCloseTime:5e3,preventEscClose:!1},o)};B=n,K("open",n)}function Bo(e,o){co(e,o)}function fo(){B&&(K("beforeClose",B),B=null,K("close"))}function Ro(){return B!==null}function Io(){return B}function $o(){fo()}function Ao(){I&&(I.unmount(),I=null),eo()}var h={subscribe:So,fire:Bo,fireModal:co,fireNotification:To,close:fo,isOpen:Ro,getCurrentConfig:Io,closeAll:$o,cleanup:Ao};var mo={overlayBackground:"--aark-modal-overlay-bg",overlayBlur:"--aark-modal-overlay-blur",modalBackground:"--aark-modal-bg",modalBorderRadius:"--aark-modal-radius",modalShadow:"--aark-modal-shadow",modalPadding:"--aark-modal-pad",modalMaxWidth:"--aark-modal-max-width",modalZIndex:"--aark-modal-z",closeButtonColor:"--aark-close-color",closeButtonHoverBackground:"--aark-close-hover",closeButtonHoverColor:"--aark-close-hover-color",closeButtonFocusOutline:"--aark-close-focus-outline",animationDuration:"--aark-anim",notificationBackground:"--aark-notification-bg",notificationBorderRadius:"--aark-notification-radius",notificationShadow:"--aark-notification-shadow",notificationPadding:"--aark-notification-pad",notificationZIndex:"--aark-notification-z"};function D(e){let o=document.documentElement;Object.keys(e).forEach(t=>{let a=e[t],n=mo[t];a!==void 0&&n&&o.style.setProperty(n,String(a))})}function Z(){let e=document.documentElement;Object.values(mo).forEach(o=>{e.style.removeProperty(o)})}function _(){let e=document.documentElement,o=getComputedStyle(e),t=a=>o.getPropertyValue(a).trim()||void 0;return{overlayBackground:t("--aark-modal-overlay-bg"),overlayBlur:t("--aark-modal-overlay-blur"),modalBackground:t("--aark-modal-bg"),modalBorderRadius:t("--aark-modal-radius"),modalShadow:t("--aark-modal-shadow"),modalPadding:t("--aark-modal-pad"),modalMaxWidth:t("--aark-modal-max-width"),modalZIndex:parseInt(t("--aark-modal-z")??"0")||void 0,closeButtonColor:t("--aark-close-color"),closeButtonHoverBackground:t("--aark-close-hover"),closeButtonHoverColor:t("--aark-close-hover-color"),closeButtonFocusOutline:t("--aark-close-focus-outline"),animationDuration:t("--aark-anim"),notificationBackground:t("--aark-notification-bg"),notificationBorderRadius:t("--aark-notification-radius"),notificationShadow:t("--aark-notification-shadow"),notificationPadding:t("--aark-notification-pad"),notificationZIndex:parseInt(t("--aark-notification-z")??"0")||void 0}}var Fo={fire:(e,o)=>h.fire(e,o),modal:(e,o)=>h.fireModal(e,o),notification:(e,o)=>h.fireNotification(e,o),close:()=>h.close(),isOpen:()=>h.isOpen(),closeAll:()=>h.closeAll(),setTheme:e=>D(e),resetTheme:()=>Z(),getTheme:()=>_()},uo=Fo;0&&(module.exports={Modal,ModalProvider,Notification,aark,getAarkModalTheme,resetAarkModalTheme,setAarkModalTheme,useModal});
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { ReactNode, FC } from 'react';
|
|
2
|
+
|
|
3
|
+
type ModalPosition = "center" | "top-center" | "top-right" | "bottom-right" | "bottom-center";
|
|
4
|
+
type NotificationPosition = "top-right" | "top-center" | "top-left" | "bottom-right" | "bottom-center" | "bottom-left";
|
|
5
|
+
type ModalMode = "modal" | "notification";
|
|
6
|
+
type ModalType = "success" | "error" | "warning" | "info" | "question";
|
|
7
|
+
/** Convenience size presets — maps to max-width values */
|
|
8
|
+
type ModalSize = "sm" | "md" | "lg" | "xl" | "full";
|
|
9
|
+
interface ModalProps$1 {
|
|
10
|
+
title?: string;
|
|
11
|
+
text?: string;
|
|
12
|
+
type?: ModalType;
|
|
13
|
+
cancelText?: string;
|
|
14
|
+
confirmText?: string;
|
|
15
|
+
onCancel?: () => void;
|
|
16
|
+
onConfirm?: () => void;
|
|
17
|
+
icon?: string | ReactNode;
|
|
18
|
+
html?: string | ReactNode;
|
|
19
|
+
showCancelButton?: boolean;
|
|
20
|
+
showConfirmButton?: boolean;
|
|
21
|
+
allowOutsideClick?: boolean;
|
|
22
|
+
allowEscapeKey?: boolean;
|
|
23
|
+
reverseButtons?: boolean;
|
|
24
|
+
focusConfirm?: boolean;
|
|
25
|
+
focusCancel?: boolean;
|
|
26
|
+
width?: string | number;
|
|
27
|
+
fullWidth?: boolean;
|
|
28
|
+
padding?: string | number;
|
|
29
|
+
background?: string;
|
|
30
|
+
customClass?: {
|
|
31
|
+
container?: string;
|
|
32
|
+
popup?: string;
|
|
33
|
+
header?: string;
|
|
34
|
+
title?: string;
|
|
35
|
+
closeButton?: string;
|
|
36
|
+
icon?: string;
|
|
37
|
+
image?: string;
|
|
38
|
+
content?: string;
|
|
39
|
+
input?: string;
|
|
40
|
+
actions?: string;
|
|
41
|
+
confirmButton?: string;
|
|
42
|
+
cancelButton?: string;
|
|
43
|
+
footer?: string;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
interface NotificationProps$1 {
|
|
47
|
+
title?: string;
|
|
48
|
+
text?: string;
|
|
49
|
+
type?: ModalType;
|
|
50
|
+
icon?: string | ReactNode;
|
|
51
|
+
html?: string | ReactNode;
|
|
52
|
+
timer?: number;
|
|
53
|
+
showCloseButton?: boolean;
|
|
54
|
+
clickToClose?: boolean;
|
|
55
|
+
width?: string | number;
|
|
56
|
+
fullWidth?: boolean;
|
|
57
|
+
padding?: string | number;
|
|
58
|
+
background?: string;
|
|
59
|
+
customClass?: {
|
|
60
|
+
container?: string;
|
|
61
|
+
popup?: string;
|
|
62
|
+
header?: string;
|
|
63
|
+
title?: string;
|
|
64
|
+
closeButton?: string;
|
|
65
|
+
icon?: string;
|
|
66
|
+
content?: string;
|
|
67
|
+
footer?: string;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
interface BaseOptions {
|
|
71
|
+
showCloseIcon?: boolean;
|
|
72
|
+
className?: string;
|
|
73
|
+
preventEscClose?: boolean;
|
|
74
|
+
}
|
|
75
|
+
interface ModalOptions extends BaseOptions {
|
|
76
|
+
position?: ModalPosition;
|
|
77
|
+
overlayClassName?: string;
|
|
78
|
+
preventOverlayClose?: boolean;
|
|
79
|
+
/** Convenience size preset. Overridden by explicit width/maxWidth. */
|
|
80
|
+
size?: ModalSize;
|
|
81
|
+
/** Explicit width (e.g. '500px', '80%', 600). Overrides size preset. */
|
|
82
|
+
width?: string | number;
|
|
83
|
+
/** Explicit max-width (e.g. '600px', '90vw'). Overrides size preset. */
|
|
84
|
+
maxWidth?: string | number;
|
|
85
|
+
}
|
|
86
|
+
interface NotificationOptions extends BaseOptions {
|
|
87
|
+
position?: NotificationPosition;
|
|
88
|
+
autoCloseTime?: number;
|
|
89
|
+
}
|
|
90
|
+
interface ModalConfig {
|
|
91
|
+
content?: ReactNode;
|
|
92
|
+
props?: ModalProps$1;
|
|
93
|
+
options?: ModalOptions;
|
|
94
|
+
mode: "modal";
|
|
95
|
+
}
|
|
96
|
+
interface NotificationConfig {
|
|
97
|
+
content?: ReactNode;
|
|
98
|
+
props?: NotificationProps$1;
|
|
99
|
+
options?: NotificationOptions;
|
|
100
|
+
mode: "notification";
|
|
101
|
+
}
|
|
102
|
+
type ComponentConfig = ModalConfig | NotificationConfig;
|
|
103
|
+
interface ModalState {
|
|
104
|
+
isOpen: boolean;
|
|
105
|
+
config: ComponentConfig | null;
|
|
106
|
+
}
|
|
107
|
+
type ModalEventType = "open" | "close" | "beforeClose";
|
|
108
|
+
interface ModalEvent {
|
|
109
|
+
type: ModalEventType;
|
|
110
|
+
config?: ComponentConfig;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* CSS Theme customization utilities for AARK React Modalify
|
|
115
|
+
*/
|
|
116
|
+
interface AarkModalTheme {
|
|
117
|
+
overlayBackground?: string;
|
|
118
|
+
overlayBlur?: string;
|
|
119
|
+
modalBackground?: string;
|
|
120
|
+
modalBorderRadius?: string;
|
|
121
|
+
modalShadow?: string;
|
|
122
|
+
modalPadding?: string;
|
|
123
|
+
modalMaxWidth?: string;
|
|
124
|
+
modalZIndex?: number;
|
|
125
|
+
closeButtonColor?: string;
|
|
126
|
+
closeButtonHoverBackground?: string;
|
|
127
|
+
closeButtonHoverColor?: string;
|
|
128
|
+
closeButtonFocusOutline?: string;
|
|
129
|
+
animationDuration?: string;
|
|
130
|
+
notificationBackground?: string;
|
|
131
|
+
notificationBorderRadius?: string;
|
|
132
|
+
notificationShadow?: string;
|
|
133
|
+
notificationPadding?: string;
|
|
134
|
+
notificationZIndex?: number;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Apply custom theme to AARK Modal CSS variables
|
|
138
|
+
*/
|
|
139
|
+
declare function setAarkModalTheme(theme: AarkModalTheme): void;
|
|
140
|
+
/**
|
|
141
|
+
* Reset AARK Modal theme to default values
|
|
142
|
+
*/
|
|
143
|
+
declare function resetAarkModalTheme(): void;
|
|
144
|
+
/**
|
|
145
|
+
* Get current AARK Modal theme values
|
|
146
|
+
*/
|
|
147
|
+
declare function getAarkModalTheme(): AarkModalTheme;
|
|
148
|
+
|
|
149
|
+
declare const aark: {
|
|
150
|
+
fire: (contentOrProps: ReactNode | ModalProps$1, options?: ModalOptions) => void;
|
|
151
|
+
modal: (contentOrProps: ReactNode | ModalProps$1, options?: ModalOptions) => void;
|
|
152
|
+
notification: (contentOrProps: ReactNode | NotificationProps$1, options?: NotificationOptions) => void;
|
|
153
|
+
close: () => void;
|
|
154
|
+
isOpen: () => boolean;
|
|
155
|
+
closeAll: () => void;
|
|
156
|
+
setTheme: (theme: AarkModalTheme) => void;
|
|
157
|
+
resetTheme: () => void;
|
|
158
|
+
getTheme: () => AarkModalTheme;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
interface UseModalReturn {
|
|
162
|
+
isOpen: boolean;
|
|
163
|
+
config: ComponentConfig | null;
|
|
164
|
+
close: () => void;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Hook to manage modal state and listen to modal events
|
|
168
|
+
*/
|
|
169
|
+
declare function useModal(): UseModalReturn;
|
|
170
|
+
|
|
171
|
+
interface ModalProps {
|
|
172
|
+
config: ModalConfig;
|
|
173
|
+
onClose: () => void;
|
|
174
|
+
}
|
|
175
|
+
declare const Modal: FC<ModalProps>;
|
|
176
|
+
|
|
177
|
+
interface NotificationProps {
|
|
178
|
+
config: NotificationConfig;
|
|
179
|
+
onClose: () => void;
|
|
180
|
+
}
|
|
181
|
+
declare const Notification: FC<NotificationProps>;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* ModalProvider component that renders modals globally
|
|
185
|
+
* This component should be rendered once in your app's root
|
|
186
|
+
*/
|
|
187
|
+
declare const ModalProvider: FC;
|
|
188
|
+
|
|
189
|
+
export { type AarkModalTheme, type ComponentConfig, Modal, type ModalConfig, type ModalEvent, type ModalEventType, type ModalMode, type ModalOptions, type ModalPosition, type ModalProps$1 as ModalProps, ModalProvider, type ModalSize, type ModalState, type ModalType, Notification, type NotificationConfig, type NotificationOptions, type NotificationPosition, type NotificationProps$1 as NotificationProps, aark, getAarkModalTheme, resetAarkModalTheme, setAarkModalTheme, useModal };
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { ReactNode, FC } from 'react';
|
|
2
|
+
|
|
3
|
+
type ModalPosition = "center" | "top-center" | "top-right" | "bottom-right" | "bottom-center";
|
|
4
|
+
type NotificationPosition = "top-right" | "top-center" | "top-left" | "bottom-right" | "bottom-center" | "bottom-left";
|
|
5
|
+
type ModalMode = "modal" | "notification";
|
|
6
|
+
type ModalType = "success" | "error" | "warning" | "info" | "question";
|
|
7
|
+
/** Convenience size presets — maps to max-width values */
|
|
8
|
+
type ModalSize = "sm" | "md" | "lg" | "xl" | "full";
|
|
9
|
+
interface ModalProps$1 {
|
|
10
|
+
title?: string;
|
|
11
|
+
text?: string;
|
|
12
|
+
type?: ModalType;
|
|
13
|
+
cancelText?: string;
|
|
14
|
+
confirmText?: string;
|
|
15
|
+
onCancel?: () => void;
|
|
16
|
+
onConfirm?: () => void;
|
|
17
|
+
icon?: string | ReactNode;
|
|
18
|
+
html?: string | ReactNode;
|
|
19
|
+
showCancelButton?: boolean;
|
|
20
|
+
showConfirmButton?: boolean;
|
|
21
|
+
allowOutsideClick?: boolean;
|
|
22
|
+
allowEscapeKey?: boolean;
|
|
23
|
+
reverseButtons?: boolean;
|
|
24
|
+
focusConfirm?: boolean;
|
|
25
|
+
focusCancel?: boolean;
|
|
26
|
+
width?: string | number;
|
|
27
|
+
fullWidth?: boolean;
|
|
28
|
+
padding?: string | number;
|
|
29
|
+
background?: string;
|
|
30
|
+
customClass?: {
|
|
31
|
+
container?: string;
|
|
32
|
+
popup?: string;
|
|
33
|
+
header?: string;
|
|
34
|
+
title?: string;
|
|
35
|
+
closeButton?: string;
|
|
36
|
+
icon?: string;
|
|
37
|
+
image?: string;
|
|
38
|
+
content?: string;
|
|
39
|
+
input?: string;
|
|
40
|
+
actions?: string;
|
|
41
|
+
confirmButton?: string;
|
|
42
|
+
cancelButton?: string;
|
|
43
|
+
footer?: string;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
interface NotificationProps$1 {
|
|
47
|
+
title?: string;
|
|
48
|
+
text?: string;
|
|
49
|
+
type?: ModalType;
|
|
50
|
+
icon?: string | ReactNode;
|
|
51
|
+
html?: string | ReactNode;
|
|
52
|
+
timer?: number;
|
|
53
|
+
showCloseButton?: boolean;
|
|
54
|
+
clickToClose?: boolean;
|
|
55
|
+
width?: string | number;
|
|
56
|
+
fullWidth?: boolean;
|
|
57
|
+
padding?: string | number;
|
|
58
|
+
background?: string;
|
|
59
|
+
customClass?: {
|
|
60
|
+
container?: string;
|
|
61
|
+
popup?: string;
|
|
62
|
+
header?: string;
|
|
63
|
+
title?: string;
|
|
64
|
+
closeButton?: string;
|
|
65
|
+
icon?: string;
|
|
66
|
+
content?: string;
|
|
67
|
+
footer?: string;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
interface BaseOptions {
|
|
71
|
+
showCloseIcon?: boolean;
|
|
72
|
+
className?: string;
|
|
73
|
+
preventEscClose?: boolean;
|
|
74
|
+
}
|
|
75
|
+
interface ModalOptions extends BaseOptions {
|
|
76
|
+
position?: ModalPosition;
|
|
77
|
+
overlayClassName?: string;
|
|
78
|
+
preventOverlayClose?: boolean;
|
|
79
|
+
/** Convenience size preset. Overridden by explicit width/maxWidth. */
|
|
80
|
+
size?: ModalSize;
|
|
81
|
+
/** Explicit width (e.g. '500px', '80%', 600). Overrides size preset. */
|
|
82
|
+
width?: string | number;
|
|
83
|
+
/** Explicit max-width (e.g. '600px', '90vw'). Overrides size preset. */
|
|
84
|
+
maxWidth?: string | number;
|
|
85
|
+
}
|
|
86
|
+
interface NotificationOptions extends BaseOptions {
|
|
87
|
+
position?: NotificationPosition;
|
|
88
|
+
autoCloseTime?: number;
|
|
89
|
+
}
|
|
90
|
+
interface ModalConfig {
|
|
91
|
+
content?: ReactNode;
|
|
92
|
+
props?: ModalProps$1;
|
|
93
|
+
options?: ModalOptions;
|
|
94
|
+
mode: "modal";
|
|
95
|
+
}
|
|
96
|
+
interface NotificationConfig {
|
|
97
|
+
content?: ReactNode;
|
|
98
|
+
props?: NotificationProps$1;
|
|
99
|
+
options?: NotificationOptions;
|
|
100
|
+
mode: "notification";
|
|
101
|
+
}
|
|
102
|
+
type ComponentConfig = ModalConfig | NotificationConfig;
|
|
103
|
+
interface ModalState {
|
|
104
|
+
isOpen: boolean;
|
|
105
|
+
config: ComponentConfig | null;
|
|
106
|
+
}
|
|
107
|
+
type ModalEventType = "open" | "close" | "beforeClose";
|
|
108
|
+
interface ModalEvent {
|
|
109
|
+
type: ModalEventType;
|
|
110
|
+
config?: ComponentConfig;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* CSS Theme customization utilities for AARK React Modalify
|
|
115
|
+
*/
|
|
116
|
+
interface AarkModalTheme {
|
|
117
|
+
overlayBackground?: string;
|
|
118
|
+
overlayBlur?: string;
|
|
119
|
+
modalBackground?: string;
|
|
120
|
+
modalBorderRadius?: string;
|
|
121
|
+
modalShadow?: string;
|
|
122
|
+
modalPadding?: string;
|
|
123
|
+
modalMaxWidth?: string;
|
|
124
|
+
modalZIndex?: number;
|
|
125
|
+
closeButtonColor?: string;
|
|
126
|
+
closeButtonHoverBackground?: string;
|
|
127
|
+
closeButtonHoverColor?: string;
|
|
128
|
+
closeButtonFocusOutline?: string;
|
|
129
|
+
animationDuration?: string;
|
|
130
|
+
notificationBackground?: string;
|
|
131
|
+
notificationBorderRadius?: string;
|
|
132
|
+
notificationShadow?: string;
|
|
133
|
+
notificationPadding?: string;
|
|
134
|
+
notificationZIndex?: number;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Apply custom theme to AARK Modal CSS variables
|
|
138
|
+
*/
|
|
139
|
+
declare function setAarkModalTheme(theme: AarkModalTheme): void;
|
|
140
|
+
/**
|
|
141
|
+
* Reset AARK Modal theme to default values
|
|
142
|
+
*/
|
|
143
|
+
declare function resetAarkModalTheme(): void;
|
|
144
|
+
/**
|
|
145
|
+
* Get current AARK Modal theme values
|
|
146
|
+
*/
|
|
147
|
+
declare function getAarkModalTheme(): AarkModalTheme;
|
|
148
|
+
|
|
149
|
+
declare const aark: {
|
|
150
|
+
fire: (contentOrProps: ReactNode | ModalProps$1, options?: ModalOptions) => void;
|
|
151
|
+
modal: (contentOrProps: ReactNode | ModalProps$1, options?: ModalOptions) => void;
|
|
152
|
+
notification: (contentOrProps: ReactNode | NotificationProps$1, options?: NotificationOptions) => void;
|
|
153
|
+
close: () => void;
|
|
154
|
+
isOpen: () => boolean;
|
|
155
|
+
closeAll: () => void;
|
|
156
|
+
setTheme: (theme: AarkModalTheme) => void;
|
|
157
|
+
resetTheme: () => void;
|
|
158
|
+
getTheme: () => AarkModalTheme;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
interface UseModalReturn {
|
|
162
|
+
isOpen: boolean;
|
|
163
|
+
config: ComponentConfig | null;
|
|
164
|
+
close: () => void;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Hook to manage modal state and listen to modal events
|
|
168
|
+
*/
|
|
169
|
+
declare function useModal(): UseModalReturn;
|
|
170
|
+
|
|
171
|
+
interface ModalProps {
|
|
172
|
+
config: ModalConfig;
|
|
173
|
+
onClose: () => void;
|
|
174
|
+
}
|
|
175
|
+
declare const Modal: FC<ModalProps>;
|
|
176
|
+
|
|
177
|
+
interface NotificationProps {
|
|
178
|
+
config: NotificationConfig;
|
|
179
|
+
onClose: () => void;
|
|
180
|
+
}
|
|
181
|
+
declare const Notification: FC<NotificationProps>;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* ModalProvider component that renders modals globally
|
|
185
|
+
* This component should be rendered once in your app's root
|
|
186
|
+
*/
|
|
187
|
+
declare const ModalProvider: FC;
|
|
188
|
+
|
|
189
|
+
export { type AarkModalTheme, type ComponentConfig, Modal, type ModalConfig, type ModalEvent, type ModalEventType, type ModalMode, type ModalOptions, type ModalPosition, type ModalProps$1 as ModalProps, ModalProvider, type ModalSize, type ModalState, type ModalType, Notification, type NotificationConfig, type NotificationOptions, type NotificationPosition, type NotificationProps$1 as NotificationProps, aark, getAarkModalTheme, resetAarkModalTheme, setAarkModalTheme, useModal };
|