aark-react-modalify 1.0.0 → 1.0.1

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/README.md CHANGED
@@ -213,7 +213,7 @@ npm run lint
213
213
 
214
214
  ## 📄 License
215
215
 
216
- MIT License - see the [LICENSE](LICENSE) file for details.
216
+ Licensed under MIT
217
217
 
218
218
  ## 🤝 Contributing
219
219
 
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime");require("react");const r=require("./index.cjs.js");exports.default=()=>{const{isOpen:o,config:t,close:s}=r.useModal();return o&&t?e.jsx(r.ModalRenderer,{config:t,onClose:s}):null};
@@ -0,0 +1,13 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import "react";
3
+ import { useModal, ModalRenderer } from "./index.esm.js";
4
+ const ModalProvider = () => {
5
+ const { isOpen, config, close } = useModal();
6
+ if (!isOpen || !config) {
7
+ return null;
8
+ }
9
+ return /* @__PURE__ */ jsx(ModalRenderer, { config, onClose: close });
10
+ };
11
+ export {
12
+ ModalProvider as default
13
+ };
@@ -1 +1 @@
1
- :root{--aark-modal-overlay-bg: rgba(0, 0, 0, .5);--aark-modal-overlay-blur: 2px;--aark-modal-bg: #ffffff;--aark-modal-border-radius: 8px;--aark-modal-shadow: 0 10px 25px rgba(0, 0, 0, .15);--aark-modal-padding: 16px;--aark-modal-z-index: 9999;--aark-modal-content-z-index: 10000;--aark-modal-close-color: #666666;--aark-modal-close-hover-bg: #f5f5f5;--aark-modal-close-hover-color: #333333;--aark-modal-close-focus-outline: #007bff;--aark-modal-animation-duration: .2s;--aark-modal-fade-duration: .15s;--aark-custom-overlay-bg: rgba(0, 0, 0, .8);--aark-custom-overlay-blur: 5px;--aark-custom-modal-gradient-start: #667eea;--aark-custom-modal-gradient-end: #764ba2;--aark-custom-modal-text-color: #ffffff;--aark-custom-modal-shadow: 0 20px 40px rgba(0, 0, 0, .3);--aark-custom-modal-close-color: rgba(255, 255, 255, .8);--aark-custom-modal-close-hover-bg: rgba(255, 255, 255, .2);--aark-custom-modal-close-hover-color: #ffffff}.aark-modal-container{position:fixed;inset:0;z-index:var(--aark-modal-z-index)}.aark-modal-container.notification{pointer-events:none}.aark-modal-overlay{position:absolute;inset:0;background-color:var(--aark-modal-overlay-bg);-webkit-backdrop-filter:blur(var(--aark-modal-overlay-blur));backdrop-filter:blur(var(--aark-modal-overlay-blur))}.custom-overlay{background-color:var(--aark-custom-overlay-bg)!important;-webkit-backdrop-filter:blur(var(--aark-custom-overlay-blur))!important;backdrop-filter:blur(var(--aark-custom-overlay-blur))!important}.aark-modal-content{position:fixed;background-color:var(--aark-modal-bg);border-radius:var(--aark-modal-border-radius);box-shadow:var(--aark-modal-shadow);padding:var(--aark-modal-padding);z-index:var(--aark-modal-content-z-index);max-width:90vw;max-height:90vh;overflow:auto}.aark-modal-content.notification{pointer-events:auto}.aark-modal-content.custom-modal{background:linear-gradient(135deg,var(--aark-custom-modal-gradient-start) 0%,var(--aark-custom-modal-gradient-end) 100%)!important;color:var(--aark-custom-modal-text-color)!important;border:none!important;box-shadow:var(--aark-custom-modal-shadow)!important}.aark-modal-content.center{top:50%;left:50%;transform:translate(-50%,-50%)}.aark-modal-content.top-center{top:20px;left:50%;transform:translate(-50%)}.aark-modal-content.top-right{top:20px;right:20px}.aark-modal-content.bottom-right{bottom:20px;right:20px}.aark-modal-content.bottom-center{bottom:20px;left:50%;transform:translate(-50%)}.aark-modal-close{position:absolute;top:8px;right:8px;width:24px;height:24px;display:flex;align-items:center;justify-content:center;background:none;border:none;color:var(--aark-modal-close-color);cursor:pointer;border-radius:50%;font-size:14px;line-height:1;transition:all var(--aark-modal-animation-duration) ease}.aark-modal-close:hover{background-color:var(--aark-modal-close-hover-bg);color:var(--aark-modal-close-hover-color)}.aark-modal-close:focus{outline:2px solid var(--aark-modal-close-focus-outline);outline-offset:2px}.aark-modal-content.custom-modal .aark-modal-close{color:var(--aark-custom-modal-close-color)}.aark-modal-content.custom-modal .aark-modal-close:hover{background-color:var(--aark-custom-modal-close-hover-bg);color:var(--aark-custom-modal-close-hover-color)}.aark-modal-body{padding-top:8px}.aark-modal-container{animation:aark-modal-fade-in var(--aark-modal-fade-duration) ease-out}.aark-modal-content{animation:aark-modal-slide-in var(--aark-modal-animation-duration) ease-out}@keyframes aark-modal-fade-in{0%{opacity:0}to{opacity:1}}@keyframes aark-modal-slide-in{0%{opacity:0;transform:translate(-50%,-50%) scale(.95)}to{opacity:1;transform:translate(-50%,-50%) scale(1)}}.aark-modal-content.top-center{animation:aark-modal-slide-down var(--aark-modal-animation-duration) ease-out}.aark-modal-content.top-right,.aark-modal-content.bottom-right{animation:aark-modal-slide-left var(--aark-modal-animation-duration) ease-out}.aark-modal-content.bottom-center{animation:aark-modal-slide-up var(--aark-modal-animation-duration) ease-out}@keyframes aark-modal-slide-down{0%{opacity:0;transform:translate(-50%) translateY(-10px)}to{opacity:1;transform:translate(-50%) translateY(0)}}@keyframes aark-modal-slide-left{0%{opacity:0;transform:translate(10px)}to{opacity:1;transform:translate(0)}}@keyframes aark-modal-slide-up{0%{opacity:0;transform:translate(-50%) translateY(10px)}to{opacity:1;transform:translate(-50%) translateY(0)}}@media (max-width: 768px){.aark-modal-content{margin:10px;max-width:calc(100vw - 20px)}.aark-modal-content.center{top:50%;left:50%;transform:translate(-50%,-50%)}.aark-modal-content.top-center,.aark-modal-content.bottom-center{left:50%;transform:translate(-50%)}.aark-modal-content.top-right{right:10px;left:auto;transform:none}.aark-modal-content.bottom-right{right:10px;bottom:10px;left:auto;transform:none}}
1
+ :root{--aark-modal-overlay-bg: rgba(0, 0, 0, .5);--aark-modal-overlay-blur: 2px;--aark-modal-bg: #ffffff;--aark-modal-border-radius: 8px;--aark-modal-shadow: 0 10px 25px rgba(0, 0, 0, .15);--aark-modal-padding: 16px;--aark-modal-z-index: 9999;--aark-modal-content-z-index: 10000;--aark-modal-close-color: #666666;--aark-modal-close-hover-bg: #f5f5f5;--aark-modal-close-hover-color: #333333;--aark-modal-close-focus-outline: #007bff;--aark-modal-animation-duration: .2s;--aark-modal-fade-duration: .15s;--aark-custom-overlay-bg: rgba(0, 0, 0, .8);--aark-custom-overlay-blur: 5px;--aark-custom-modal-gradient-start: #667eea;--aark-custom-modal-gradient-end: #764ba2;--aark-custom-modal-text-color: #ffffff;--aark-custom-modal-shadow: 0 20px 40px rgba(0, 0, 0, .3);--aark-custom-modal-close-color: rgba(255, 255, 255, .8);--aark-custom-modal-close-hover-bg: rgba(255, 255, 255, .2);--aark-custom-modal-close-hover-color: #ffffff}.aark-modal-container{position:fixed;inset:0;z-index:var(--aark-modal-z-index)}.aark-modal-container.notification{pointer-events:none}.aark-modal-overlay{position:absolute;inset:0;background-color:var(--aark-modal-overlay-bg);backdrop-filter:blur(var(--aark-modal-overlay-blur))}.custom-overlay{background-color:var(--aark-custom-overlay-bg)!important;backdrop-filter:blur(var(--aark-custom-overlay-blur))!important}.aark-modal-content{position:fixed;background-color:var(--aark-modal-bg);border-radius:var(--aark-modal-border-radius);box-shadow:var(--aark-modal-shadow);padding:var(--aark-modal-padding);z-index:var(--aark-modal-content-z-index);max-width:90vw;max-height:90vh;overflow:auto}.aark-modal-content.notification{pointer-events:auto}.aark-modal-content.custom-modal{background:linear-gradient(135deg,var(--aark-custom-modal-gradient-start) 0%,var(--aark-custom-modal-gradient-end) 100%)!important;color:var(--aark-custom-modal-text-color)!important;border:none!important;box-shadow:var(--aark-custom-modal-shadow)!important}.aark-modal-content.center{top:50%;left:50%;transform:translate(-50%,-50%)}.aark-modal-content.top-center{top:20px;left:50%;transform:translate(-50%)}.aark-modal-content.top-right{top:20px;right:20px}.aark-modal-content.bottom-right{bottom:20px;right:20px}.aark-modal-content.bottom-center{bottom:20px;left:50%;transform:translate(-50%)}.aark-modal-close{position:absolute;top:8px;right:8px;width:24px;height:24px;display:flex;align-items:center;justify-content:center;background:none;border:none;color:var(--aark-modal-close-color);cursor:pointer;border-radius:50%;font-size:14px;line-height:1;transition:all var(--aark-modal-animation-duration) ease}.aark-modal-close:hover{background-color:var(--aark-modal-close-hover-bg);color:var(--aark-modal-close-hover-color)}.aark-modal-close:focus{outline:2px solid var(--aark-modal-close-focus-outline);outline-offset:2px}.aark-modal-content.custom-modal .aark-modal-close{color:var(--aark-custom-modal-close-color)}.aark-modal-content.custom-modal .aark-modal-close:hover{background-color:var(--aark-custom-modal-close-hover-bg);color:var(--aark-custom-modal-close-hover-color)}.aark-modal-body{padding-top:8px}.aark-modal-container{animation:aark-modal-fade-in var(--aark-modal-fade-duration) ease-out}.aark-modal-content{animation:aark-modal-slide-in var(--aark-modal-animation-duration) ease-out}@keyframes aark-modal-fade-in{0%{opacity:0}to{opacity:1}}@keyframes aark-modal-slide-in{0%{opacity:0;transform:translate(-50%,-50%) scale(.95)}to{opacity:1;transform:translate(-50%,-50%) scale(1)}}.aark-modal-content.top-center{animation:aark-modal-slide-down var(--aark-modal-animation-duration) ease-out}.aark-modal-content.top-right,.aark-modal-content.bottom-right{animation:aark-modal-slide-left var(--aark-modal-animation-duration) ease-out}.aark-modal-content.bottom-center{animation:aark-modal-slide-up var(--aark-modal-animation-duration) ease-out}@keyframes aark-modal-slide-down{0%{opacity:0;transform:translate(-50%) translateY(-10px)}to{opacity:1;transform:translate(-50%) translateY(0)}}@keyframes aark-modal-slide-left{0%{opacity:0;transform:translate(10px)}to{opacity:1;transform:translate(0)}}@keyframes aark-modal-slide-up{0%{opacity:0;transform:translate(-50%) translateY(10px)}to{opacity:1;transform:translate(-50%) translateY(0)}}@media (max-width: 768px){.aark-modal-content{margin:10px;max-width:calc(100vw - 20px)}.aark-modal-content.center{top:50%;left:50%;transform:translate(-50%,-50%)}.aark-modal-content.top-center,.aark-modal-content.bottom-center{left:50%;transform:translate(-50%)}.aark-modal-content.top-right{right:10px;left:auto;transform:none}.aark-modal-content.bottom-right{right:10px;bottom:10px;left:auto;transform:none}}
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CvIFkjib.cjs");exports.ModalRenderer=e.ModalRenderer;exports.aark=e.aark;exports.getAarkModalTheme=e.getAarkModalTheme;exports.resetAarkModalTheme=e.resetAarkModalTheme;exports.setAarkModalTheme=e.setAarkModalTheme;exports.useModal=e.useModal;
1
+ "use strict";var o=Object.defineProperty,e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,a=(e,t,r)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,l=(o,l)=>{for(var s in l||(l={}))t.call(l,s)&&a(o,s,l[s]);if(e)for(var s of e(l))r.call(l,s)&&a(o,s,l[s]);return o},s=(o,e,t)=>a(o,"symbol"!=typeof e?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),c=require("react-dom/client"),d=require("react/jsx-runtime"),i=require("react-dom");const u=new class{constructor(){s(this,"listeners",new Set),s(this,"currentConfig",null),s(this,"container",null),s(this,"root",null)}init(){this.container||(this.container=document.createElement("div"),this.container.id="aark-react-modalify-root",this.container.style.position="relative",this.container.style.zIndex="9999",document.body.appendChild(this.container),Promise.resolve().then(()=>require("./ModalProvider-B_DFPtUh.cjs")).then(({default:o})=>{this.container&&(this.root=c.createRoot(this.container),this.root.render(n.createElement(o)))}))}subscribe(o){return this.listeners.add(o),()=>this.listeners.delete(o)}emit(o,e){const t={type:o,config:e};this.listeners.forEach(o=>o(t))}fire(o,e){this.init();const t={content:o,options:l({position:"center",mode:"modal",showCloseIcon:!0,preventEscClose:!1,preventOverlayClose:!1},e)};this.currentConfig=t,this.emit("open",t)}close(){this.currentConfig&&(this.emit("beforeClose",this.currentConfig),this.currentConfig=null,this.emit("close"))}isOpen(){return null!==this.currentConfig}getCurrentConfig(){return this.currentConfig}closeAll(){this.close()}cleanup(){this.container&&this.container.parentNode&&(this.container.parentNode.removeChild(this.container),this.container=null,this.root=null)}};function m(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 y(){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 k(){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 p=class o{constructor(){}static getInstance(){return o.instance||(o.instance=new o),o.instance}fire(o,e){u.fire(o,e)}close(){u.close()}isOpen(){return u.isOpen()}closeAll(){u.closeAll()}setTheme(o){m(o)}resetTheme(){y()}getTheme(){return k()}static destroy(){o.instance=null}};s(p,"instance",null);const g=p.getInstance();exports.ModalRenderer=({config:o,onClose:e})=>{const{content:t,options:r={}}=o,{position:a="center",mode:l="modal",showCloseIcon:s=!0,autoCloseTime:c,className:u="",overlayClassName:m="",preventEscClose:y=!1,preventOverlayClose:k=!1}=r;n.useEffect(()=>{if(c&&"notification"===l){const o=setTimeout(e,c);return()=>clearTimeout(o)}},[c,l,e]),n.useEffect(()=>{const o=o=>{"Escape"!==o.key||y||e()};if(!y)return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[e,y]);const p=n.useCallback(o=>{o.target!==o.currentTarget||k||e()},[e,k]),g=n.useCallback(o=>{o.stopPropagation(),e()},[e]),h="aark-modal-container "+("notification"===l?"notification":""),v=`aark-modal-content ${a} ${"notification"===l?"notification":""} ${u}`.trim(),P=`aark-modal-overlay ${m}`.trim();return i.createPortal(d.jsxs("div",{className:h,children:["modal"===l&&d.jsx("div",{className:P,onClick:p,"aria-hidden":"true"}),d.jsxs("div",{className:v,role:"dialog","aria-modal":"true","aria-labelledby":"aark-modal-content",children:[s&&d.jsx("button",{onClick:g,className:"aark-modal-close","aria-label":"Close modal",type:"button",children:"×"}),d.jsx("div",{id:"aark-modal-content",className:"aark-modal-body",children:t})]})]}),document.body)},exports.aark=g,exports.getAarkModalTheme=k,exports.resetAarkModalTheme=y,exports.setAarkModalTheme=m,exports.useModal=function(){const[o,e]=n.useState(!1),[t,r]=n.useState(null),a=n.useCallback(()=>{u.close()},[]);return n.useEffect(()=>{const o=u.subscribe(o=>{switch(o.type){case"open":e(!0),r(o.config||null);break;case"close":e(!1),r(null)}});return e(u.isOpen()),r(u.getCurrentConfig()),o},[]),{isOpen:o,config:t,close:a}};
package/dist/index.esm.js CHANGED
@@ -1,9 +1,486 @@
1
- import { M as r, a as s, g as o, r as d, s as M, u as l } from "./index-DIT0k89J.js";
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
18
+ import React, { useState, useCallback, useEffect } from "react";
19
+ import { createRoot } from "react-dom/client";
20
+ import { jsxs, jsx } from "react/jsx-runtime";
21
+ import { createPortal } from "react-dom";
22
+ class ModalManager {
23
+ constructor() {
24
+ __publicField(this, "listeners", /* @__PURE__ */ new Set());
25
+ __publicField(this, "currentConfig", null);
26
+ __publicField(this, "container", null);
27
+ __publicField(this, "root", null);
28
+ }
29
+ /**
30
+ * Initialize the modal system
31
+ */
32
+ init() {
33
+ if (this.container) return;
34
+ this.container = document.createElement("div");
35
+ this.container.id = "aark-react-modalify-root";
36
+ this.container.style.position = "relative";
37
+ this.container.style.zIndex = "9999";
38
+ document.body.appendChild(this.container);
39
+ import("./ModalProvider-Bxtotq_Y.js").then(({ default: ModalProvider }) => {
40
+ if (this.container) {
41
+ this.root = createRoot(this.container);
42
+ this.root.render(React.createElement(ModalProvider));
43
+ }
44
+ });
45
+ }
46
+ /**
47
+ * Subscribe to modal events
48
+ */
49
+ subscribe(listener) {
50
+ this.listeners.add(listener);
51
+ return () => this.listeners.delete(listener);
52
+ }
53
+ /**
54
+ * Emit modal events to all listeners
55
+ */
56
+ emit(type, config) {
57
+ const event = { type, config };
58
+ this.listeners.forEach((listener) => listener(event));
59
+ }
60
+ /**
61
+ * Open a modal with content and options
62
+ */
63
+ fire(content, options) {
64
+ this.init();
65
+ const config = {
66
+ content,
67
+ options: __spreadValues({
68
+ position: "center",
69
+ mode: "modal",
70
+ showCloseIcon: true,
71
+ preventEscClose: false,
72
+ preventOverlayClose: false
73
+ }, options)
74
+ };
75
+ this.currentConfig = config;
76
+ this.emit("open", config);
77
+ }
78
+ /**
79
+ * Close the current modal
80
+ */
81
+ close() {
82
+ if (this.currentConfig) {
83
+ this.emit("beforeClose", this.currentConfig);
84
+ this.currentConfig = null;
85
+ this.emit("close");
86
+ }
87
+ }
88
+ /**
89
+ * Check if a modal is currently open
90
+ */
91
+ isOpen() {
92
+ return this.currentConfig !== null;
93
+ }
94
+ /**
95
+ * Get the current modal configuration
96
+ */
97
+ getCurrentConfig() {
98
+ return this.currentConfig;
99
+ }
100
+ /**
101
+ * Force close all modals (useful for cleanup)
102
+ */
103
+ closeAll() {
104
+ this.close();
105
+ }
106
+ /**
107
+ * Cleanup the modal system (useful for testing or when unmounting the app)
108
+ */
109
+ cleanup() {
110
+ if (this.container && this.container.parentNode) {
111
+ this.container.parentNode.removeChild(this.container);
112
+ this.container = null;
113
+ this.root = null;
114
+ }
115
+ }
116
+ }
117
+ const modalManager = new ModalManager();
118
+ function setAarkModalTheme(theme) {
119
+ const root = document.documentElement;
120
+ if (theme.overlayBackground) {
121
+ root.style.setProperty("--aark-modal-overlay-bg", theme.overlayBackground);
122
+ }
123
+ if (theme.overlayBlur) {
124
+ root.style.setProperty("--aark-modal-overlay-blur", theme.overlayBlur);
125
+ }
126
+ if (theme.modalBackground) {
127
+ root.style.setProperty("--aark-modal-bg", theme.modalBackground);
128
+ }
129
+ if (theme.modalBorderRadius) {
130
+ root.style.setProperty(
131
+ "--aark-modal-border-radius",
132
+ theme.modalBorderRadius
133
+ );
134
+ }
135
+ if (theme.modalShadow) {
136
+ root.style.setProperty("--aark-modal-shadow", theme.modalShadow);
137
+ }
138
+ if (theme.modalPadding) {
139
+ root.style.setProperty("--aark-modal-padding", theme.modalPadding);
140
+ }
141
+ if (theme.modalZIndex) {
142
+ root.style.setProperty(
143
+ "--aark-modal-z-index",
144
+ theme.modalZIndex.toString()
145
+ );
146
+ }
147
+ if (theme.modalContentZIndex) {
148
+ root.style.setProperty(
149
+ "--aark-modal-content-z-index",
150
+ theme.modalContentZIndex.toString()
151
+ );
152
+ }
153
+ if (theme.closeButtonColor) {
154
+ root.style.setProperty("--aark-modal-close-color", theme.closeButtonColor);
155
+ }
156
+ if (theme.closeButtonHoverBackground) {
157
+ root.style.setProperty(
158
+ "--aark-modal-close-hover-bg",
159
+ theme.closeButtonHoverBackground
160
+ );
161
+ }
162
+ if (theme.closeButtonHoverColor) {
163
+ root.style.setProperty(
164
+ "--aark-modal-close-hover-color",
165
+ theme.closeButtonHoverColor
166
+ );
167
+ }
168
+ if (theme.closeButtonFocusOutline) {
169
+ root.style.setProperty(
170
+ "--aark-modal-close-focus-outline",
171
+ theme.closeButtonFocusOutline
172
+ );
173
+ }
174
+ if (theme.animationDuration) {
175
+ root.style.setProperty(
176
+ "--aark-modal-animation-duration",
177
+ theme.animationDuration
178
+ );
179
+ }
180
+ if (theme.fadeDuration) {
181
+ root.style.setProperty("--aark-modal-fade-duration", theme.fadeDuration);
182
+ }
183
+ if (theme.customOverlayBackground) {
184
+ root.style.setProperty(
185
+ "--aark-custom-overlay-bg",
186
+ theme.customOverlayBackground
187
+ );
188
+ }
189
+ if (theme.customOverlayBlur) {
190
+ root.style.setProperty(
191
+ "--aark-custom-overlay-blur",
192
+ theme.customOverlayBlur
193
+ );
194
+ }
195
+ if (theme.customModalGradientStart) {
196
+ root.style.setProperty(
197
+ "--aark-custom-modal-gradient-start",
198
+ theme.customModalGradientStart
199
+ );
200
+ }
201
+ if (theme.customModalGradientEnd) {
202
+ root.style.setProperty(
203
+ "--aark-custom-modal-gradient-end",
204
+ theme.customModalGradientEnd
205
+ );
206
+ }
207
+ if (theme.customModalTextColor) {
208
+ root.style.setProperty(
209
+ "--aark-custom-modal-text-color",
210
+ theme.customModalTextColor
211
+ );
212
+ }
213
+ if (theme.customModalShadow) {
214
+ root.style.setProperty(
215
+ "--aark-custom-modal-shadow",
216
+ theme.customModalShadow
217
+ );
218
+ }
219
+ if (theme.customModalCloseColor) {
220
+ root.style.setProperty(
221
+ "--aark-custom-modal-close-color",
222
+ theme.customModalCloseColor
223
+ );
224
+ }
225
+ if (theme.customModalCloseHoverBackground) {
226
+ root.style.setProperty(
227
+ "--aark-custom-modal-close-hover-bg",
228
+ theme.customModalCloseHoverBackground
229
+ );
230
+ }
231
+ if (theme.customModalCloseHoverColor) {
232
+ root.style.setProperty(
233
+ "--aark-custom-modal-close-hover-color",
234
+ theme.customModalCloseHoverColor
235
+ );
236
+ }
237
+ }
238
+ function resetAarkModalTheme() {
239
+ const root = document.documentElement;
240
+ const properties = [
241
+ "--aark-modal-overlay-bg",
242
+ "--aark-modal-overlay-blur",
243
+ "--aark-modal-bg",
244
+ "--aark-modal-border-radius",
245
+ "--aark-modal-shadow",
246
+ "--aark-modal-padding",
247
+ "--aark-modal-z-index",
248
+ "--aark-modal-content-z-index",
249
+ "--aark-modal-close-color",
250
+ "--aark-modal-close-hover-bg",
251
+ "--aark-modal-close-hover-color",
252
+ "--aark-modal-close-focus-outline",
253
+ "--aark-modal-animation-duration",
254
+ "--aark-modal-fade-duration",
255
+ "--aark-custom-overlay-bg",
256
+ "--aark-custom-overlay-blur",
257
+ "--aark-custom-modal-gradient-start",
258
+ "--aark-custom-modal-gradient-end",
259
+ "--aark-custom-modal-text-color",
260
+ "--aark-custom-modal-shadow",
261
+ "--aark-custom-modal-close-color",
262
+ "--aark-custom-modal-close-hover-bg",
263
+ "--aark-custom-modal-close-hover-color"
264
+ ];
265
+ properties.forEach((property) => {
266
+ root.style.removeProperty(property);
267
+ });
268
+ }
269
+ function getAarkModalTheme() {
270
+ const root = document.documentElement;
271
+ const computedStyle = getComputedStyle(root);
272
+ return {
273
+ overlayBackground: computedStyle.getPropertyValue("--aark-modal-overlay-bg").trim(),
274
+ overlayBlur: computedStyle.getPropertyValue("--aark-modal-overlay-blur").trim(),
275
+ modalBackground: computedStyle.getPropertyValue("--aark-modal-bg").trim(),
276
+ modalBorderRadius: computedStyle.getPropertyValue("--aark-modal-border-radius").trim(),
277
+ modalShadow: computedStyle.getPropertyValue("--aark-modal-shadow").trim(),
278
+ modalPadding: computedStyle.getPropertyValue("--aark-modal-padding").trim(),
279
+ modalZIndex: parseInt(computedStyle.getPropertyValue("--aark-modal-z-index").trim()) || void 0,
280
+ modalContentZIndex: parseInt(
281
+ computedStyle.getPropertyValue("--aark-modal-content-z-index").trim()
282
+ ) || void 0,
283
+ closeButtonColor: computedStyle.getPropertyValue("--aark-modal-close-color").trim(),
284
+ closeButtonHoverBackground: computedStyle.getPropertyValue("--aark-modal-close-hover-bg").trim(),
285
+ closeButtonHoverColor: computedStyle.getPropertyValue("--aark-modal-close-hover-color").trim(),
286
+ closeButtonFocusOutline: computedStyle.getPropertyValue("--aark-modal-close-focus-outline").trim(),
287
+ animationDuration: computedStyle.getPropertyValue("--aark-modal-animation-duration").trim(),
288
+ fadeDuration: computedStyle.getPropertyValue("--aark-modal-fade-duration").trim(),
289
+ customOverlayBackground: computedStyle.getPropertyValue("--aark-custom-overlay-bg").trim(),
290
+ customOverlayBlur: computedStyle.getPropertyValue("--aark-custom-overlay-blur").trim(),
291
+ customModalGradientStart: computedStyle.getPropertyValue("--aark-custom-modal-gradient-start").trim(),
292
+ customModalGradientEnd: computedStyle.getPropertyValue("--aark-custom-modal-gradient-end").trim(),
293
+ customModalTextColor: computedStyle.getPropertyValue("--aark-custom-modal-text-color").trim(),
294
+ customModalShadow: computedStyle.getPropertyValue("--aark-custom-modal-shadow").trim(),
295
+ customModalCloseColor: computedStyle.getPropertyValue("--aark-custom-modal-close-color").trim(),
296
+ customModalCloseHoverBackground: computedStyle.getPropertyValue("--aark-custom-modal-close-hover-bg").trim(),
297
+ customModalCloseHoverColor: computedStyle.getPropertyValue("--aark-custom-modal-close-hover-color").trim()
298
+ };
299
+ }
300
+ const _Aark = class _Aark {
301
+ constructor() {
302
+ }
303
+ /**
304
+ * Get the singleton instance of Aark
305
+ */
306
+ static getInstance() {
307
+ if (!_Aark.instance) {
308
+ _Aark.instance = new _Aark();
309
+ }
310
+ return _Aark.instance;
311
+ }
312
+ /**
313
+ * Fire/open a modal with content and optional configuration
314
+ * @param content - React component or element to render in modal
315
+ * @param options - Optional configuration for modal behavior and styling
316
+ */
317
+ fire(content, options) {
318
+ modalManager.fire(content, options);
319
+ }
320
+ /**
321
+ * Close the currently open modal
322
+ */
323
+ close() {
324
+ modalManager.close();
325
+ }
326
+ /**
327
+ * Check if a modal is currently open
328
+ */
329
+ isOpen() {
330
+ return modalManager.isOpen();
331
+ }
332
+ /**
333
+ * Close all modals (alias for close since only one modal can be open at a time)
334
+ */
335
+ closeAll() {
336
+ modalManager.closeAll();
337
+ }
338
+ /**
339
+ * Set custom theme for AARK modals
340
+ */
341
+ setTheme(theme) {
342
+ setAarkModalTheme(theme);
343
+ }
344
+ /**
345
+ * Reset theme to default values
346
+ */
347
+ resetTheme() {
348
+ resetAarkModalTheme();
349
+ }
350
+ /**
351
+ * Get current theme values
352
+ */
353
+ getTheme() {
354
+ return getAarkModalTheme();
355
+ }
356
+ /**
357
+ * Destroy the singleton instance (useful for testing)
358
+ */
359
+ static destroy() {
360
+ _Aark.instance = null;
361
+ }
362
+ };
363
+ __publicField(_Aark, "instance", null);
364
+ let Aark = _Aark;
365
+ const aark = Aark.getInstance();
366
+ function useModal() {
367
+ const [isOpen, setIsOpen] = useState(false);
368
+ const [config, setConfig] = useState(null);
369
+ const close = useCallback(() => {
370
+ modalManager.close();
371
+ }, []);
372
+ useEffect(() => {
373
+ const handleModalEvent = (event) => {
374
+ switch (event.type) {
375
+ case "open":
376
+ setIsOpen(true);
377
+ setConfig(event.config || null);
378
+ break;
379
+ case "close":
380
+ setIsOpen(false);
381
+ setConfig(null);
382
+ break;
383
+ }
384
+ };
385
+ const unsubscribe = modalManager.subscribe(handleModalEvent);
386
+ setIsOpen(modalManager.isOpen());
387
+ setConfig(modalManager.getCurrentConfig());
388
+ return unsubscribe;
389
+ }, []);
390
+ return {
391
+ isOpen,
392
+ config,
393
+ close
394
+ };
395
+ }
396
+ const ModalRenderer = ({ config, onClose }) => {
397
+ const { content, options = {} } = config;
398
+ const {
399
+ position = "center",
400
+ mode = "modal",
401
+ showCloseIcon = true,
402
+ autoCloseTime,
403
+ className = "",
404
+ overlayClassName = "",
405
+ preventEscClose = false,
406
+ preventOverlayClose = false
407
+ } = options;
408
+ useEffect(() => {
409
+ if (autoCloseTime && mode === "notification") {
410
+ const timer = setTimeout(onClose, autoCloseTime);
411
+ return () => clearTimeout(timer);
412
+ }
413
+ }, [autoCloseTime, mode, onClose]);
414
+ useEffect(() => {
415
+ const handleKeyDown = (event) => {
416
+ if (event.key === "Escape" && !preventEscClose) {
417
+ onClose();
418
+ }
419
+ };
420
+ if (!preventEscClose) {
421
+ document.addEventListener("keydown", handleKeyDown);
422
+ return () => document.removeEventListener("keydown", handleKeyDown);
423
+ }
424
+ }, [onClose, preventEscClose]);
425
+ const handleOverlayClick = useCallback(
426
+ (event) => {
427
+ if (event.target === event.currentTarget && !preventOverlayClose) {
428
+ onClose();
429
+ }
430
+ },
431
+ [onClose, preventOverlayClose]
432
+ );
433
+ const handleCloseClick = useCallback(
434
+ (event) => {
435
+ event.stopPropagation();
436
+ onClose();
437
+ },
438
+ [onClose]
439
+ );
440
+ const containerClasses = `aark-modal-container ${mode === "notification" ? "notification" : ""}`;
441
+ const contentClasses = `aark-modal-content ${position} ${mode === "notification" ? "notification" : ""} ${className}`.trim();
442
+ const overlayClasses = `aark-modal-overlay ${overlayClassName}`.trim();
443
+ return createPortal(
444
+ /* @__PURE__ */ jsxs("div", { className: containerClasses, children: [
445
+ mode === "modal" && /* @__PURE__ */ jsx(
446
+ "div",
447
+ {
448
+ className: overlayClasses,
449
+ onClick: handleOverlayClick,
450
+ "aria-hidden": "true"
451
+ }
452
+ ),
453
+ /* @__PURE__ */ jsxs(
454
+ "div",
455
+ {
456
+ className: contentClasses,
457
+ role: "dialog",
458
+ "aria-modal": "true",
459
+ "aria-labelledby": "aark-modal-content",
460
+ children: [
461
+ showCloseIcon && /* @__PURE__ */ jsx(
462
+ "button",
463
+ {
464
+ onClick: handleCloseClick,
465
+ className: "aark-modal-close",
466
+ "aria-label": "Close modal",
467
+ type: "button",
468
+ children: "×"
469
+ }
470
+ ),
471
+ /* @__PURE__ */ jsx("div", { id: "aark-modal-content", className: "aark-modal-body", children: content })
472
+ ]
473
+ }
474
+ )
475
+ ] }),
476
+ document.body
477
+ );
478
+ };
2
479
  export {
3
- r as ModalRenderer,
4
- s as aark,
5
- o as getAarkModalTheme,
6
- d as resetAarkModalTheme,
7
- M as setAarkModalTheme,
8
- l as useModal
480
+ ModalRenderer,
481
+ aark,
482
+ getAarkModalTheme,
483
+ resetAarkModalTheme,
484
+ setAarkModalTheme,
485
+ useModal
9
486
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aark-react-modalify",
3
- "version": "1.0.0",
4
- "description": "A simple, global modal/notification library for React with TypeScript and TailwindCSS.",
3
+ "version": "1.0.1",
4
+ "description": "A lightweight, flexible React modal and notification library with TypeScript support. Features automatic DOM mounting, customizable styling, and a simple imperative API for displaying modals, alerts, confirmations, and toast notifications.",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
7
7
  "types": "dist/index.d.ts",
@@ -15,7 +15,6 @@
15
15
  },
16
16
  "files": [
17
17
  "dist",
18
- "src/styles/aark-modal.css",
19
18
  "README.md",
20
19
  "LICENSE"
21
20
  ],
@@ -28,7 +27,8 @@
28
27
  "prepare": "npm run build",
29
28
  "lint": "eslint src --ext .ts,.tsx",
30
29
  "lint:fix": "eslint src --ext .ts,.tsx --fix",
31
- "typecheck": "tsc --noEmit"
30
+ "typecheck": "tsc --noEmit",
31
+ "analyze": "npm run build && npx bundlesize"
32
32
  },
33
33
  "keywords": [
34
34
  "react",
@@ -37,8 +37,13 @@
37
37
  "toast",
38
38
  "popup",
39
39
  "dialog",
40
+ "alert",
41
+ "confirm",
40
42
  "typescript",
41
- "tailwindcss"
43
+ "imperative",
44
+ "lightweight",
45
+ "flexible",
46
+ "customizable"
42
47
  ],
43
48
  "peerDependencies": {
44
49
  "react": ">=16.8.0",
@@ -46,6 +51,7 @@
46
51
  },
47
52
  "devDependencies": {
48
53
  "@eslint/js": "^9.32.0",
54
+ "@types/node": "^24.2.1",
49
55
  "@types/react": "^19.1.9",
50
56
  "@types/react-dom": "^19.1.7",
51
57
  "@vitejs/plugin-react": "^4.7.0",
@@ -56,6 +62,7 @@
56
62
  "react": "^19.1.1",
57
63
  "react-dom": "^19.1.1",
58
64
  "rimraf": "^6.0.1",
65
+ "terser": "^5.43.1",
59
66
  "typescript": "~5.8.3",
60
67
  "typescript-eslint": "^8.39.0",
61
68
  "vite": "^7.1.0"
@@ -1,9 +0,0 @@
1
- import { u as s, j as n, M as t } from "./index-DIT0k89J.js";
2
- import "react";
3
- const i = () => {
4
- const { isOpen: e, config: o, close: r } = s();
5
- return !e || !o ? null : /* @__PURE__ */ n.jsx(t, { config: o, onClose: r });
6
- };
7
- export {
8
- i as default
9
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CvIFkjib.cjs");require("react");const t=()=>{const{isOpen:o,config:r,close:n}=e.useModal();return!o||!r?null:e.jsxRuntimeExports.jsx(e.ModalRenderer,{config:r,onClose:n})};exports.default=t;