aark-react-modalify 1.0.5 → 1.1.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 -0
- package/dist/components/Icon.d.ts +18 -0
- package/dist/components/{ModalRenderer.d.ts → Modal.d.ts} +4 -3
- package/dist/components/Notification.d.ts +9 -0
- package/dist/hooks/useModal.d.ts +2 -2
- package/dist/index.cjs.js +30 -21
- package/dist/index.d.ts +4 -2
- package/dist/index.esm.js +300 -137
- package/dist/logic/ModalManager.d.ts +6 -2
- package/dist/logic/ModalManagerNew.d.ts +0 -0
- package/dist/logic/aark.d.ts +3 -1
- package/dist/types/index.d.ts +19 -7
- package/dist/utils/modal-css.d.ts +1 -1
- package/package.json +6 -1
- package/dist/ModalProvider-BAlPeDjm.js +0 -12
- package/dist/ModalProvider-DA6KcJdZ.cjs +0 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{--aark-modal-overlay-bg: rgba(0, 0, 0, .5);--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-z: 9999;--aark-close-color: #666;--aark-close-hover: #f5f5f5;--aark-anim: .2s}.aark-modal-content{position:fixed;background:var(--aark-modal-bg);border-radius:var(--aark-modal-radius);box-shadow:var(--aark-modal-shadow);padding:var(--aark-modal-pad);z-index:calc(var(--aark-modal-z) + 1);max-width:90vw;min-width:280px;max-height:90vh;overflow:auto}.aark-modal-content.notification{pointer-events:auto;background:var(--aark-modal-bg);box-shadow:var(--aark-modal-shadow);padding:var(--aark-modal-pad);width:auto;max-width:400px;min-width:280px;border-radius:var(--aark-modal-radius)}.aark-modal-content.center{top:50%;left:50%;transform:translate(-50%,-50%);animation:scale-in var(--aark-anim)}.aark-modal-content.top-center{top:20px;left:50%;transform:translate(-50%);animation:slide-down var(--aark-anim)}.aark-modal-content.top-right{top:20px;right:20px;animation:slide-left var(--aark-anim)}.aark-modal-content.top-left{top:20px;left:20px;animation:slide-right var(--aark-anim)}.aark-modal-content.bottom-right{bottom:20px;right:20px;animation:slide-left var(--aark-anim)}.aark-modal-content.bottom-left{bottom:20px;left:20px;animation:slide-right var(--aark-anim)}.aark-modal-content.bottom-center{bottom:20px;left:50%;transform:translate(-50%);animation:slide-up var(--aark-anim)}.aark-modal-header{position:relative;padding-bottom:6px}.aark-modal-close{position:absolute;top:8px;right:8px;width:30px;height:30px;padding:.5rem;display:flex;align-items:center;justify-content:center;background:0;border:0;color:var(--aark-close-color);cursor:pointer;border-radius:50%;font-size:14px;line-height:1;transition:all var(--aark-anim)}.aark-modal-close:hover{background:var(--aark-close-hover);color:#333}.aark-modal-close:focus{outline:2px solid #007bff;outline-offset:2px}.aark-modal-body{padding-top:0}@keyframes fade-in{0%{opacity:0}to{opacity:1}}@keyframes scale-in{0%{opacity:0;transform:translate(-50%,-50%) scale(.9)}to{opacity:1;transform:translate(-50%,-50%) scale(1)}}@keyframes slide-down{0%{opacity:0;transform:translate(-50%) translateY(-20px)}to{opacity:1;transform:translate(-50%) translateY(0)}}@keyframes slide-up{0%{opacity:0;transform:translate(-50%) translateY(20px)}to{opacity:1;transform:translate(-50%) 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-modal-content{margin:10px;max-width:calc(100vw - 20px);min-width:auto}.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.top-left{left:10px;right:auto;transform:none}.aark-modal-content.bottom-right{right:10px;bottom:10px;left:auto;transform:none}.aark-modal-content.bottom-left{left:10px;bottom:10px;right:auto;transform:none}.aark-modal-content.notification{width:auto;max-width:calc(100vw - 20px);min-width:auto}}@media (max-width: 480px){.aark-modal-content{max-width:calc(100vw - 10px);margin:5px}.aark-modal-content.center{top:10px;left:50%;transform:translate(-50%);max-height:calc(100vh - 20px)}}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FC, CSSProperties } from "react";
|
|
2
|
+
declare const colors: Record<string, string>;
|
|
3
|
+
export type IconName = "close";
|
|
4
|
+
export type IconSize = string | number;
|
|
5
|
+
export type IconColor = keyof typeof colors | string;
|
|
6
|
+
export interface IconProps {
|
|
7
|
+
name: IconName;
|
|
8
|
+
size?: IconSize;
|
|
9
|
+
color?: IconColor;
|
|
10
|
+
style?: CSSProperties;
|
|
11
|
+
className?: string;
|
|
12
|
+
noHoverEffect?: boolean;
|
|
13
|
+
onClick?: () => void;
|
|
14
|
+
"aria-label"?: string;
|
|
15
|
+
title?: string;
|
|
16
|
+
}
|
|
17
|
+
declare const Icon: FC<IconProps>;
|
|
18
|
+
export default Icon;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { FC } from 'react';
|
|
2
2
|
import type { ModalConfig } from '../types';
|
|
3
|
-
|
|
3
|
+
import '../assets/styles/aark-modal.css';
|
|
4
|
+
interface ModalProps {
|
|
4
5
|
config: ModalConfig;
|
|
5
6
|
onClose: () => void;
|
|
6
7
|
}
|
|
7
|
-
declare const
|
|
8
|
-
export default
|
|
8
|
+
declare const Modal: FC<ModalProps>;
|
|
9
|
+
export default Modal;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { NotificationConfig } from '../types';
|
|
3
|
+
import '../assets/styles/aark-modal.css';
|
|
4
|
+
interface NotificationProps {
|
|
5
|
+
config: NotificationConfig;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
}
|
|
8
|
+
declare const Notification: FC<NotificationProps>;
|
|
9
|
+
export default Notification;
|
package/dist/hooks/useModal.d.ts
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
"use strict"
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
a.overlayBackground&&o.style.setProperty("--aark-modal-overlay-bg",a.overlayBackground),a.overlayBlur&&o.style.setProperty("--aark-modal-overlay-blur",a.overlayBlur),a.modalBackground&&o.style.setProperty("--aark-modal-bg",a.modalBackground),a.modalBorderRadius&&o.style.setProperty("--aark-modal-border-radius",a.modalBorderRadius),a.modalShadow&&o.style.setProperty("--aark-modal-shadow",a.modalShadow),a.modalPadding&&o.style.setProperty("--aark-modal-padding",a.modalPadding),a.modalZIndex&&o.style.setProperty("--aark-modal-z-index",a.modalZIndex.toString()),a.modalContentZIndex&&o.style.setProperty("--aark-modal-content-z-index",a.modalContentZIndex.toString()),a.closeButtonColor&&o.style.setProperty("--aark-modal-close-color",a.closeButtonColor),a.closeButtonHoverBackground&&o.style.setProperty("--aark-modal-close-hover-bg",a.closeButtonHoverBackground),a.closeButtonHoverColor&&o.style.setProperty("--aark-modal-close-hover-color",a.closeButtonHoverColor),a.closeButtonFocusOutline&&o.style.setProperty("--aark-modal-close-focus-outline",a.closeButtonFocusOutline),a.animationDuration&&o.style.setProperty("--aark-modal-animation-duration",a.animationDuration),a.fadeDuration&&o.style.setProperty("--aark-modal-fade-duration",a.fadeDuration),a.customOverlayBackground&&o.style.setProperty("--aark-custom-overlay-bg",a.customOverlayBackground),a.customOverlayBlur&&o.style.setProperty("--aark-custom-overlay-blur",a.customOverlayBlur),a.customModalGradientStart&&o.style.setProperty("--aark-custom-modal-gradient-start",a.customModalGradientStart),a.customModalGradientEnd&&o.style.setProperty("--aark-custom-modal-gradient-end",a.customModalGradientEnd),a.customModalTextColor&&o.style.setProperty("--aark-custom-modal-text-color",a.customModalTextColor),a.customModalShadow&&o.style.setProperty("--aark-custom-modal-shadow",a.customModalShadow),a.customModalCloseColor&&o.style.setProperty("--aark-custom-modal-close-color",a.customModalCloseColor),a.customModalCloseHoverBackground&&o.style.setProperty("--aark-custom-modal-close-hover-bg",a.customModalCloseHoverBackground),a.customModalCloseHoverColor&&o.style.setProperty("--aark-custom-modal-close-hover-color",a.customModalCloseHoverColor)}function t(){const a=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(o=>{a.style.removeProperty(o)})}function e(){const a=document.documentElement,o=getComputedStyle(a)
|
|
5
|
-
return{overlayBackground:o.getPropertyValue("--aark-modal-overlay-bg").trim(),overlayBlur:o.getPropertyValue("--aark-modal-overlay-blur").trim(),modalBackground:o.getPropertyValue("--aark-modal-bg").trim(),modalBorderRadius:o.getPropertyValue("--aark-modal-border-radius").trim(),modalShadow:o.getPropertyValue("--aark-modal-shadow").trim(),modalPadding:o.getPropertyValue("--aark-modal-padding").trim(),modalZIndex:parseInt(o.getPropertyValue("--aark-modal-z-index").trim())||void 0,modalContentZIndex:parseInt(o.getPropertyValue("--aark-modal-content-z-index").trim())||void 0,closeButtonColor:o.getPropertyValue("--aark-modal-close-color").trim(),closeButtonHoverBackground:o.getPropertyValue("--aark-modal-close-hover-bg").trim(),closeButtonHoverColor:o.getPropertyValue("--aark-modal-close-hover-color").trim(),closeButtonFocusOutline:o.getPropertyValue("--aark-modal-close-focus-outline").trim(),animationDuration:o.getPropertyValue("--aark-modal-animation-duration").trim(),fadeDuration:o.getPropertyValue("--aark-modal-fade-duration").trim(),customOverlayBackground:o.getPropertyValue("--aark-custom-overlay-bg").trim(),customOverlayBlur:o.getPropertyValue("--aark-custom-overlay-blur").trim(),customModalGradientStart:o.getPropertyValue("--aark-custom-modal-gradient-start").trim(),customModalGradientEnd:o.getPropertyValue("--aark-custom-modal-gradient-end").trim(),customModalTextColor:o.getPropertyValue("--aark-custom-modal-text-color").trim(),customModalShadow:o.getPropertyValue("--aark-custom-modal-shadow").trim(),customModalCloseColor:o.getPropertyValue("--aark-custom-modal-close-color").trim(),customModalCloseHoverBackground:o.getPropertyValue("--aark-custom-modal-close-hover-bg").trim(),customModalCloseHoverColor:o.getPropertyValue("--aark-custom-modal-close-hover-color").trim()}}Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})
|
|
6
|
-
const l=require("react"),n=require("react-dom/client"),d=require("react/jsx-runtime"),c=require("react-dom"),m=new Set
|
|
7
|
-
let s=null,i=null,u=null
|
|
8
|
-
const k={subscribe:function(a){return m.add(a),()=>m.delete(a)},fire:function(o,r){i||(i=document.createElement("div"),i.id="aark-react-modalify-root",i.style.position="relative",i.style.zIndex="9999",document.body.appendChild(i),Promise.resolve().then(()=>require("./ModalProvider-DA6KcJdZ.cjs")).then(({default:a})=>{i&&(u=n.createRoot(i),u.render(l.createElement(a)))}))
|
|
9
|
-
const t={content:o,options:Object.assign({position:"center",mode:"modal",showCloseIcon:!0,preventEscClose:!1,preventOverlayClose:!1},r)}
|
|
10
|
-
s=t,a("open",t)},close:o,isOpen:function(){return null!==s},getCurrentConfig:function(){return s},closeAll:function(){o()},cleanup:function(){i&&i.parentNode&&(i.parentNode.removeChild(i),i=null,u=null)}},p={fire:(a,o)=>k.fire(a,o),close:()=>k.close(),isOpen:()=>k.isOpen(),closeAll:()=>k.closeAll(),setTheme:a=>r(a),resetTheme:()=>t(),getTheme:()=>e()}
|
|
11
|
-
exports.ModalRenderer=({config:a,onClose:o})=>{const{content:r,options:t={}}=a,{position:e="center",mode:n="modal",showCloseIcon:m=!0,autoCloseTime:s,className:i="",overlayClassName:u="",preventEscClose:k=!1,preventOverlayClose:p=!1}=t
|
|
12
|
-
l.useEffect(()=>{((a,o)=>{if("undefined"==typeof document)return
|
|
13
|
-
if(document.getElementById(o))return
|
|
14
|
-
const r=document.createElement("style")
|
|
15
|
-
r.id=o,r.innerHTML=":root{--aark-modal-overlay-bg:rgba(0,0,0,.5);--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-z:9999;--aark-close-color:#666;--aark-close-hover:#f5f5f5;--aark-anim:.2s}.aark-modal-container{position:fixed;inset:0;z-index:var(--aark-modal-z)}.aark-modal-container.notification{pointer-events:none}.aark-modal-overlay{position:absolute;inset:0;background:var(--aark-modal-overlay-bg);backdrop-filter:blur(2px)}.aark-modal-content{position:fixed;background:var(--aark-modal-bg);border-radius:var(--aark-modal-radius);box-shadow:var(--aark-modal-shadow);padding:var(--aark-modal-pad);z-index:calc(var(--aark-modal-z) + 1);max-width:90vw;max-height:90vh;overflow:auto}.aark-modal-content.notification{pointer-events:auto}.aark-modal-content.center{top:50%;left:50%;transform:translate(-50%,-50%)}.aark-modal-content.top-center{top:20px;left:50%;transform:translateX(-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:translateX(-50%)}.aark-modal-close{position:absolute;top:8px;right:8px;width:24px;height:24px;display:flex;align-items:center;justify-content:center;background:0;border:0;color:var(--aark-close-color);cursor:pointer;border-radius:50%;font-size:14px;line-height:1;transition:all var(--aark-anim)}.aark-modal-close:hover{background:var(--aark-close-hover);color:#333}.aark-modal-close:focus{outline:2px solid #007bff;outline-offset:2px}.aark-modal-body{padding-top:8px}.aark-modal-container{animation:f var(--aark-anim)}.aark-modal-content{animation:s var(--aark-anim)}@keyframes f{0%{opacity:0}to{opacity:1}}@keyframes s{0%{opacity:0;transform:translate(-50%,-50%) scale(.95)}to{opacity:1;transform:translate(-50%,-50%) scale(1)}}.aark-modal-content.top-center{animation:d var(--aark-anim)}.aark-modal-content.top-right,.aark-modal-content.bottom-right{animation:l var(--aark-anim)}.aark-modal-content.bottom-center{animation:u var(--aark-anim)}@keyframes d{0%{opacity:0;transform:translateX(-50%) translateY(-10px)}to{opacity:1;transform:translateX(-50%) translateY(0)}}@keyframes l{0%{opacity:0;transform:translateX(10px)}to{opacity:1;transform:translateX(0)}}@keyframes u{0%{opacity:0;transform:translateX(-50%) translateY(10px)}to{opacity:1;transform:translateX(-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:translateX(-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}}",document.head.appendChild(r)})(0,"aark-modal-styles")},[]),l.useEffect(()=>{if(s&&"notification"===n){const a=setTimeout(o,s)
|
|
16
|
-
return()=>clearTimeout(a)}},[s,n,o]),l.useEffect(()=>{const a=a=>{"Escape"!==a.key||k||o()}
|
|
17
|
-
if(!k)return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[o,k])
|
|
18
|
-
const f=l.useCallback(a=>{a.target!==a.currentTarget||p||o()},[o,p]),v=l.useCallback(a=>{a.stopPropagation(),o()},[o]),b="aark-modal-container "+("notification"===n?"notification":""),g=`aark-modal-content ${e} ${"notification"===n?"notification":""} ${i}`.trim(),h=("aark-modal-overlay "+u).trim(),x=document.getElementById("aark-react-modalify-root")||document.body
|
|
19
|
-
return c.createPortal(d.jsxs("div",{className:b,children:["modal"===n&&d.jsx("div",{className:h,onClick:f,"aria-hidden":"true"}),d.jsxs("div",{className:g,role:"dialog","aria-modal":"true","aria-labelledby":"aark-modal-content",children:[m&&d.jsx("button",{onClick:v,className:"aark-modal-close","aria-label":"Close modal",type:"button",children:"×"}),d.jsx("div",{id:"aark-modal-content",className:"aark-modal-body",children:r})]})]}),x)},exports.aark=p,exports.getAarkModalTheme=e,exports.resetAarkModalTheme=t,exports.setAarkModalTheme=r,exports.useModal=function(){const[a,o]=l.useState(!1),[r,t]=l.useState(null),e=l.useCallback(()=>{k.close()},[])
|
|
20
|
-
return l.useEffect(()=>{const a=k.subscribe(a=>{switch(a.type){case"open":o(!0),t(a.config||null)
|
|
2
|
+
function o(){const[o,a]=s.useState(!1),[e,r]=s.useState(null),l=s.useCallback(()=>{y.close()},[])
|
|
3
|
+
return s.useEffect(()=>{const o=y.subscribe(o=>{switch(o.type){case"open":a(!0),r(o.config||null)
|
|
21
4
|
break
|
|
22
|
-
case"close":
|
|
23
|
-
return
|
|
5
|
+
case"close":a(!1),r(null)}})
|
|
6
|
+
return a(y.isOpen()),r(y.getCurrentConfig()),o},[]),{isOpen:o,config:e,close:l}}function a(){g||(g=document.createElement("div"),g.id="aark-react-modalify-root",g.style.position="relative",g.style.zIndex="9999",document.body.appendChild(g),g&&(h=d.createRoot(g),h.render(s.createElement(C))))}function e(o,a){const e={type:o,config:a}
|
|
7
|
+
b.forEach(o=>o(e))}function r(o,r){a()
|
|
8
|
+
const l={content:o,mode:"modal",options:Object.assign({position:"center",showCloseIcon:!0,preventEscClose:!1,preventOverlayClose:!1},r)}
|
|
9
|
+
p=l,e("open",l)}function l(){p&&(e("beforeClose",p),p=null,e("close"))}function t(o){const a=document.documentElement
|
|
10
|
+
o.overlayBackground&&a.style.setProperty("--aark-modal-overlay-bg",o.overlayBackground),o.overlayBlur&&a.style.setProperty("--aark-modal-overlay-blur",o.overlayBlur),o.modalBackground&&a.style.setProperty("--aark-modal-bg",o.modalBackground),o.modalBorderRadius&&a.style.setProperty("--aark-modal-border-radius",o.modalBorderRadius),o.modalShadow&&a.style.setProperty("--aark-modal-shadow",o.modalShadow),o.modalPadding&&a.style.setProperty("--aark-modal-padding",o.modalPadding),o.modalZIndex&&a.style.setProperty("--aark-modal-z-index",o.modalZIndex.toString()),o.modalContentZIndex&&a.style.setProperty("--aark-modal-content-z-index",o.modalContentZIndex.toString()),o.closeButtonColor&&a.style.setProperty("--aark-modal-close-color",o.closeButtonColor),o.closeButtonHoverBackground&&a.style.setProperty("--aark-modal-close-hover-bg",o.closeButtonHoverBackground),o.closeButtonHoverColor&&a.style.setProperty("--aark-modal-close-hover-color",o.closeButtonHoverColor),o.closeButtonFocusOutline&&a.style.setProperty("--aark-modal-close-focus-outline",o.closeButtonFocusOutline),o.animationDuration&&a.style.setProperty("--aark-modal-animation-duration",o.animationDuration),o.fadeDuration&&a.style.setProperty("--aark-modal-fade-duration",o.fadeDuration),o.customOverlayBackground&&a.style.setProperty("--aark-custom-overlay-bg",o.customOverlayBackground),o.customOverlayBlur&&a.style.setProperty("--aark-custom-overlay-blur",o.customOverlayBlur),o.customModalGradientStart&&a.style.setProperty("--aark-custom-modal-gradient-start",o.customModalGradientStart),o.customModalGradientEnd&&a.style.setProperty("--aark-custom-modal-gradient-end",o.customModalGradientEnd),o.customModalTextColor&&a.style.setProperty("--aark-custom-modal-text-color",o.customModalTextColor),o.customModalShadow&&a.style.setProperty("--aark-custom-modal-shadow",o.customModalShadow),o.customModalCloseColor&&a.style.setProperty("--aark-custom-modal-close-color",o.customModalCloseColor),o.customModalCloseHoverBackground&&a.style.setProperty("--aark-custom-modal-close-hover-bg",o.customModalCloseHoverBackground),o.customModalCloseHoverColor&&a.style.setProperty("--aark-custom-modal-close-hover-color",o.customModalCloseHoverColor)}function n(){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(a=>{o.style.removeProperty(a)})}function c(){const o=document.documentElement,a=getComputedStyle(o)
|
|
11
|
+
return{overlayBackground:a.getPropertyValue("--aark-modal-overlay-bg").trim(),overlayBlur:a.getPropertyValue("--aark-modal-overlay-blur").trim(),modalBackground:a.getPropertyValue("--aark-modal-bg").trim(),modalBorderRadius:a.getPropertyValue("--aark-modal-border-radius").trim(),modalShadow:a.getPropertyValue("--aark-modal-shadow").trim(),modalPadding:a.getPropertyValue("--aark-modal-padding").trim(),modalZIndex:parseInt(a.getPropertyValue("--aark-modal-z-index").trim())||void 0,modalContentZIndex:parseInt(a.getPropertyValue("--aark-modal-content-z-index").trim())||void 0,closeButtonColor:a.getPropertyValue("--aark-modal-close-color").trim(),closeButtonHoverBackground:a.getPropertyValue("--aark-modal-close-hover-bg").trim(),closeButtonHoverColor:a.getPropertyValue("--aark-modal-close-hover-color").trim(),closeButtonFocusOutline:a.getPropertyValue("--aark-modal-close-focus-outline").trim(),animationDuration:a.getPropertyValue("--aark-modal-animation-duration").trim(),fadeDuration:a.getPropertyValue("--aark-modal-fade-duration").trim(),customOverlayBackground:a.getPropertyValue("--aark-custom-overlay-bg").trim(),customOverlayBlur:a.getPropertyValue("--aark-custom-overlay-blur").trim(),customModalGradientStart:a.getPropertyValue("--aark-custom-modal-gradient-start").trim(),customModalGradientEnd:a.getPropertyValue("--aark-custom-modal-gradient-end").trim(),customModalTextColor:a.getPropertyValue("--aark-custom-modal-text-color").trim(),customModalShadow:a.getPropertyValue("--aark-custom-modal-shadow").trim(),customModalCloseColor:a.getPropertyValue("--aark-custom-modal-close-color").trim(),customModalCloseHoverBackground:a.getPropertyValue("--aark-custom-modal-close-hover-bg").trim(),customModalCloseHoverColor:a.getPropertyValue("--aark-custom-modal-close-hover-color").trim()}}Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})
|
|
12
|
+
const s=require("react"),d=require("react-dom/client"),i=require("react/jsx-runtime"),m=require("react-dom"),u={white:"#FFFFFF",black:"#0B071A"},k=s.memo(({name:o,color:a="black",style:e,className:r="",noHoverEffect:l=!1,onClick:t,size:n=24,"aria-label":c,title:d})=>{const m=s.useMemo(()=>n+"",[n]),k=s.useMemo(()=>u[a]?u[a]:(a.startsWith("#"),a),[a]),f=s.useMemo(()=>{const a=k
|
|
13
|
+
return"close"===o?i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:m,height:m,viewBox:"0 0 16 16",fill:"none",children:i.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:a})}):null},[o,k,m]),v=s.useMemo(()=>{const a={}
|
|
14
|
+
return a["aria-label"]=c||o+" icon",d&&(a.title=d),a.role=t?"button":"img",a},[c,d,o,t]),C=s.useMemo(()=>{if(t)return o=>{"Enter"!==o.key&&" "!==o.key||(o.preventDefault(),t())}},[t])
|
|
15
|
+
return i.jsx("i",{className:`\n inline-flex items-center justify-center bg-transparent outline-none border-none\n ${!l&&t&&"hover:opacity-80 cursor-pointer transition-opacity duration-200"}\n ${t&&"focus:outline-2 focus:outline-blue-500 focus:outline-offset-2"}\n ${r}\n `.trim(),style:e,onClick:t,onKeyDown:C,tabIndex:t?0:void 0,...v,children:f})})
|
|
16
|
+
k.displayName="Icon"
|
|
17
|
+
const f=({config:o,onClose:a})=>{const{content:e,options:r={}}=o,{position:l="center",showCloseIcon:t=!0,className:n="",overlayClassName:c="",preventEscClose:d=!1,preventOverlayClose:u=!1}=r
|
|
18
|
+
s.useEffect(()=>{const o=o=>{"Escape"!==o.key||d||a()}
|
|
19
|
+
if(!d)return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[a,d])
|
|
20
|
+
const f=s.useCallback(o=>{o.target!==o.currentTarget||u||a()},[a,u]),v=s.useCallback(o=>{o.stopPropagation(),a()},[a]),C=`aark-modal-content ${l} ${n}`.trim(),b=document.getElementById("aark-react-modalify-root")||document.body
|
|
21
|
+
return m.createPortal(i.jsx("div",{className:("aark-modal-overlay "+c).trim(),onClick:f,"aria-hidden":"true",style:{position:"fixed",inset:0,zIndex:"var(--aark-modal-z)",background:"var(--aark-modal-overlay-bg)",backdropFilter:"blur(2px)",animation:"fade-in var(--aark-anim)"},children:i.jsxs("div",{className:C,role:"dialog","aria-modal":"true","aria-labelledby":"aark-modal-content",onClick:o=>o.stopPropagation(),children:[t&&i.jsx("header",{className:"aark-modal-header",children:i.jsx("button",{onClick:v,className:"aark-modal-close","aria-label":"Close modal",type:"button",children:i.jsx(k,{name:"close",size:12})})}),i.jsx("div",{id:"aark-modal-content",className:"aark-modal-body",children:e})]})}),b)},v=({config:o,onClose:a})=>{const{content:e,options:r={}}=o,{position:l="top-right",showCloseIcon:t=!0,autoCloseTime:n=5e3,className:c="",preventEscClose:d=!1}=r
|
|
22
|
+
s.useEffect(()=>{if(n){const o=setTimeout(a,n)
|
|
23
|
+
return()=>clearTimeout(o)}},[n,a]),s.useEffect(()=>{const o=o=>{"Escape"!==o.key||d||a()}
|
|
24
|
+
if(!d)return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[a,d])
|
|
25
|
+
const u=s.useCallback(o=>{o.stopPropagation(),a()},[a]),k=`aark-modal-content notification ${l} ${c}`.trim(),f=document.getElementById("aark-react-modalify-root")||document.body
|
|
26
|
+
return m.createPortal(i.jsxs("div",{className:k,role:"alert","aria-live":"polite","aria-labelledby":"aark-notification-content",children:[t&&i.jsx("button",{onClick:u,className:"aark-modal-close","aria-label":"Close notification",type:"button",children:"×"}),i.jsx("div",{id:"aark-notification-content",className:"aark-modal-body",children:e})]}),f)},C=()=>{const{isOpen:a,config:e,close:r}=o()
|
|
27
|
+
return a&&e?"modal"===e.mode?i.jsx(f,{config:e,onClose:r}):"notification"===e.mode?i.jsx(v,{config:e,onClose:r}):null:null},b=new Set
|
|
28
|
+
let p=null,g=null,h=null
|
|
29
|
+
const y={subscribe:function(o){return b.add(o),()=>b.delete(o)},fire:function(o,a){r(o,a)},fireModal:r,fireNotification:function(o,r){a()
|
|
30
|
+
const l={content:o,mode:"notification",options:Object.assign({position:"top-right",showCloseIcon:!0,autoCloseTime:5e3,preventEscClose:!1},r)}
|
|
31
|
+
p=l,e("open",l)},close:l,isOpen:function(){return null!==p},getCurrentConfig:function(){return p},closeAll:function(){l()},cleanup:function(){g&&g.parentNode&&(g.parentNode.removeChild(g),g=null,h=null)}},x={fire:(o,a)=>y.fire(o,a),modal:(o,a)=>y.fireModal(o,a),notification:(o,a)=>y.fireNotification(o,a),close:()=>y.close(),isOpen:()=>y.isOpen(),closeAll:()=>y.closeAll(),setTheme:o=>t(o),resetTheme:()=>n(),getTheme:()=>c()}
|
|
32
|
+
exports.Modal=f,exports.ModalProvider=C,exports.Notification=v,exports.aark=x,exports.getAarkModalTheme=c,exports.resetAarkModalTheme=n,exports.setAarkModalTheme=t,exports.useModal=o
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { default as aark } from "./logic/aark";
|
|
2
|
-
export type { ModalOptions, ModalPosition, ModalMode, ModalConfig, ModalState, ModalEvent, ModalEventType, } from "./types";
|
|
2
|
+
export type { ModalOptions, NotificationOptions, ModalPosition, NotificationPosition, ModalMode, ModalConfig, NotificationConfig, ComponentConfig, ModalState, ModalEvent, ModalEventType, } from "./types";
|
|
3
3
|
export type { AarkModalTheme } from "./utils/theme";
|
|
4
4
|
export { setAarkModalTheme, resetAarkModalTheme, getAarkModalTheme, } from "./utils/theme";
|
|
5
5
|
export { useModal } from "./hooks/useModal";
|
|
6
|
-
export { default as
|
|
6
|
+
export { default as Modal } from "./components/Modal";
|
|
7
|
+
export { default as Notification } from "./components/Notification";
|
|
8
|
+
export { default as ModalProvider } from "./components/ModalProvider";
|
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,271 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useState, useCallback, useEffect, memo, useMemo, createElement } from "react";
|
|
2
2
|
import { createRoot } from "react-dom/client";
|
|
3
|
-
import {
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { createPortal } from "react-dom";
|
|
5
|
+
function useModal() {
|
|
6
|
+
const [isOpen2, setIsOpen] = useState(false);
|
|
7
|
+
const [config, setConfig] = useState(null);
|
|
8
|
+
const close2 = useCallback(() => {
|
|
9
|
+
modalManager.close();
|
|
10
|
+
}, []);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const handleModalEvent = (event) => {
|
|
13
|
+
switch (event.type) {
|
|
14
|
+
case "open":
|
|
15
|
+
setIsOpen(true);
|
|
16
|
+
setConfig(event.config || null);
|
|
17
|
+
break;
|
|
18
|
+
case "close":
|
|
19
|
+
setIsOpen(false);
|
|
20
|
+
setConfig(null);
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const unsubscribe = modalManager.subscribe(handleModalEvent);
|
|
25
|
+
setIsOpen(modalManager.isOpen());
|
|
26
|
+
setConfig(modalManager.getCurrentConfig());
|
|
27
|
+
return unsubscribe;
|
|
28
|
+
}, []);
|
|
29
|
+
return {
|
|
30
|
+
isOpen: isOpen2,
|
|
31
|
+
config,
|
|
32
|
+
close: close2
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const colors = {
|
|
36
|
+
white: "#FFFFFF",
|
|
37
|
+
black: "#0B071A"
|
|
38
|
+
};
|
|
39
|
+
const Icon = memo(
|
|
40
|
+
({
|
|
41
|
+
name,
|
|
42
|
+
color = "black",
|
|
43
|
+
style,
|
|
44
|
+
className = "",
|
|
45
|
+
noHoverEffect = false,
|
|
46
|
+
onClick,
|
|
47
|
+
size = 24,
|
|
48
|
+
"aria-label": ariaLabel,
|
|
49
|
+
title
|
|
50
|
+
}) => {
|
|
51
|
+
const resolvedSize = useMemo(() => {
|
|
52
|
+
return String(size);
|
|
53
|
+
}, [size]);
|
|
54
|
+
const resolvedColor = useMemo(() => {
|
|
55
|
+
if (colors[color]) {
|
|
56
|
+
return colors[color];
|
|
57
|
+
}
|
|
58
|
+
if (color.startsWith("#")) {
|
|
59
|
+
return color;
|
|
60
|
+
}
|
|
61
|
+
return color;
|
|
62
|
+
}, [color]);
|
|
63
|
+
const iconElement = useMemo(() => {
|
|
64
|
+
const fill = resolvedColor;
|
|
65
|
+
switch (name) {
|
|
66
|
+
case "close":
|
|
67
|
+
return /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: resolvedSize, height: resolvedSize, viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ 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 }) });
|
|
68
|
+
default:
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}, [name, resolvedColor, resolvedSize]);
|
|
72
|
+
const accessibilityProps = useMemo(() => {
|
|
73
|
+
const props = {};
|
|
74
|
+
if (ariaLabel) {
|
|
75
|
+
props["aria-label"] = ariaLabel;
|
|
76
|
+
} else {
|
|
77
|
+
props["aria-label"] = `${name} icon`;
|
|
78
|
+
}
|
|
79
|
+
if (title) {
|
|
80
|
+
props.title = title;
|
|
81
|
+
}
|
|
82
|
+
props.role = onClick ? "button" : "img";
|
|
83
|
+
return props;
|
|
84
|
+
}, [ariaLabel, title, name, onClick]);
|
|
85
|
+
const handleKeyDown = useMemo(() => {
|
|
86
|
+
if (!onClick) return void 0;
|
|
87
|
+
return (event) => {
|
|
88
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
onClick();
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}, [onClick]);
|
|
94
|
+
return /* @__PURE__ */ jsx(
|
|
95
|
+
"i",
|
|
96
|
+
{
|
|
97
|
+
className: `
|
|
98
|
+
inline-flex items-center justify-center bg-transparent outline-none border-none
|
|
99
|
+
${!noHoverEffect && onClick && "hover:opacity-80 cursor-pointer transition-opacity duration-200"}
|
|
100
|
+
${onClick && "focus:outline-2 focus:outline-blue-500 focus:outline-offset-2"}
|
|
101
|
+
${className}
|
|
102
|
+
`.trim(),
|
|
103
|
+
style,
|
|
104
|
+
onClick,
|
|
105
|
+
onKeyDown: handleKeyDown,
|
|
106
|
+
tabIndex: onClick ? 0 : void 0,
|
|
107
|
+
...accessibilityProps,
|
|
108
|
+
children: iconElement
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
Icon.displayName = "Icon";
|
|
114
|
+
const Modal = ({ config, onClose }) => {
|
|
115
|
+
const { content, options = {} } = config;
|
|
116
|
+
const {
|
|
117
|
+
position = "center",
|
|
118
|
+
showCloseIcon = true,
|
|
119
|
+
className = "",
|
|
120
|
+
overlayClassName = "",
|
|
121
|
+
preventEscClose = false,
|
|
122
|
+
preventOverlayClose = false
|
|
123
|
+
} = options;
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
const handleKeyDown = (event) => {
|
|
126
|
+
if (event.key === "Escape" && !preventEscClose) {
|
|
127
|
+
onClose();
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
if (!preventEscClose) {
|
|
131
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
132
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
133
|
+
}
|
|
134
|
+
}, [onClose, preventEscClose]);
|
|
135
|
+
const handleOverlayClick = useCallback(
|
|
136
|
+
(event) => {
|
|
137
|
+
if (event.target === event.currentTarget && !preventOverlayClose) {
|
|
138
|
+
onClose();
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
[onClose, preventOverlayClose]
|
|
142
|
+
);
|
|
143
|
+
const handleCloseClick = useCallback(
|
|
144
|
+
(event) => {
|
|
145
|
+
event.stopPropagation();
|
|
146
|
+
onClose();
|
|
147
|
+
},
|
|
148
|
+
[onClose]
|
|
149
|
+
);
|
|
150
|
+
const contentClasses = `aark-modal-content ${position} ${className}`.trim();
|
|
151
|
+
const modalContainer = document.getElementById("aark-react-modalify-root") || document.body;
|
|
152
|
+
return createPortal(
|
|
153
|
+
/* @__PURE__ */ jsx(
|
|
154
|
+
"div",
|
|
155
|
+
{
|
|
156
|
+
className: `aark-modal-overlay ${overlayClassName}`.trim(),
|
|
157
|
+
onClick: handleOverlayClick,
|
|
158
|
+
"aria-hidden": "true",
|
|
159
|
+
style: {
|
|
160
|
+
position: "fixed",
|
|
161
|
+
inset: 0,
|
|
162
|
+
zIndex: "var(--aark-modal-z)",
|
|
163
|
+
background: "var(--aark-modal-overlay-bg)",
|
|
164
|
+
backdropFilter: "blur(2px)",
|
|
165
|
+
animation: "fade-in var(--aark-anim)"
|
|
166
|
+
},
|
|
167
|
+
children: /* @__PURE__ */ jsxs(
|
|
168
|
+
"div",
|
|
169
|
+
{
|
|
170
|
+
className: contentClasses,
|
|
171
|
+
role: "dialog",
|
|
172
|
+
"aria-modal": "true",
|
|
173
|
+
"aria-labelledby": "aark-modal-content",
|
|
174
|
+
onClick: (e) => e.stopPropagation(),
|
|
175
|
+
children: [
|
|
176
|
+
showCloseIcon && /* @__PURE__ */ jsx("header", { className: "aark-modal-header", children: /* @__PURE__ */ jsx(
|
|
177
|
+
"button",
|
|
178
|
+
{
|
|
179
|
+
onClick: handleCloseClick,
|
|
180
|
+
className: "aark-modal-close",
|
|
181
|
+
"aria-label": "Close modal",
|
|
182
|
+
type: "button",
|
|
183
|
+
children: /* @__PURE__ */ jsx(Icon, { name: "close", size: 12 })
|
|
184
|
+
}
|
|
185
|
+
) }),
|
|
186
|
+
/* @__PURE__ */ jsx("div", { id: "aark-modal-content", className: "aark-modal-body", children: content })
|
|
187
|
+
]
|
|
188
|
+
}
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
),
|
|
192
|
+
modalContainer
|
|
193
|
+
);
|
|
194
|
+
};
|
|
195
|
+
const Notification = ({ config, onClose }) => {
|
|
196
|
+
const { content, options = {} } = config;
|
|
197
|
+
const {
|
|
198
|
+
position = "top-right",
|
|
199
|
+
showCloseIcon = true,
|
|
200
|
+
autoCloseTime = 5e3,
|
|
201
|
+
className = "",
|
|
202
|
+
preventEscClose = false
|
|
203
|
+
} = options;
|
|
204
|
+
useEffect(() => {
|
|
205
|
+
if (autoCloseTime) {
|
|
206
|
+
const timer = setTimeout(onClose, autoCloseTime);
|
|
207
|
+
return () => clearTimeout(timer);
|
|
208
|
+
}
|
|
209
|
+
}, [autoCloseTime, onClose]);
|
|
210
|
+
useEffect(() => {
|
|
211
|
+
const handleKeyDown = (event) => {
|
|
212
|
+
if (event.key === "Escape" && !preventEscClose) {
|
|
213
|
+
onClose();
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
if (!preventEscClose) {
|
|
217
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
218
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
219
|
+
}
|
|
220
|
+
}, [onClose, preventEscClose]);
|
|
221
|
+
const handleCloseClick = useCallback(
|
|
222
|
+
(event) => {
|
|
223
|
+
event.stopPropagation();
|
|
224
|
+
onClose();
|
|
225
|
+
},
|
|
226
|
+
[onClose]
|
|
227
|
+
);
|
|
228
|
+
const contentClasses = `aark-modal-content notification ${position} ${className}`.trim();
|
|
229
|
+
const modalContainer = document.getElementById("aark-react-modalify-root") || document.body;
|
|
230
|
+
return createPortal(
|
|
231
|
+
/* @__PURE__ */ jsxs(
|
|
232
|
+
"div",
|
|
233
|
+
{
|
|
234
|
+
className: contentClasses,
|
|
235
|
+
role: "alert",
|
|
236
|
+
"aria-live": "polite",
|
|
237
|
+
"aria-labelledby": "aark-notification-content",
|
|
238
|
+
children: [
|
|
239
|
+
showCloseIcon && /* @__PURE__ */ jsx(
|
|
240
|
+
"button",
|
|
241
|
+
{
|
|
242
|
+
onClick: handleCloseClick,
|
|
243
|
+
className: "aark-modal-close",
|
|
244
|
+
"aria-label": "Close notification",
|
|
245
|
+
type: "button",
|
|
246
|
+
children: "×"
|
|
247
|
+
}
|
|
248
|
+
),
|
|
249
|
+
/* @__PURE__ */ jsx("div", { id: "aark-notification-content", className: "aark-modal-body", children: content })
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
),
|
|
253
|
+
modalContainer
|
|
254
|
+
);
|
|
255
|
+
};
|
|
256
|
+
const ModalProvider = () => {
|
|
257
|
+
const { isOpen: isOpen2, config, close: close2 } = useModal();
|
|
258
|
+
if (!isOpen2 || !config) {
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
if (config.mode === "modal") {
|
|
262
|
+
return /* @__PURE__ */ jsx(Modal, { config, onClose: close2 });
|
|
263
|
+
}
|
|
264
|
+
if (config.mode === "notification") {
|
|
265
|
+
return /* @__PURE__ */ jsx(Notification, { config, onClose: close2 });
|
|
266
|
+
}
|
|
267
|
+
return null;
|
|
268
|
+
};
|
|
5
269
|
const listeners = /* @__PURE__ */ new Set();
|
|
6
270
|
let currentConfig = null;
|
|
7
271
|
let container = null;
|
|
@@ -13,12 +277,10 @@ function init() {
|
|
|
13
277
|
container.style.position = "relative";
|
|
14
278
|
container.style.zIndex = "9999";
|
|
15
279
|
document.body.appendChild(container);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
});
|
|
280
|
+
if (container) {
|
|
281
|
+
root = createRoot(container);
|
|
282
|
+
root.render(createElement(ModalProvider));
|
|
283
|
+
}
|
|
22
284
|
}
|
|
23
285
|
function subscribe(listener) {
|
|
24
286
|
listeners.add(listener);
|
|
@@ -28,14 +290,14 @@ function emit(type, config) {
|
|
|
28
290
|
const event = { type, config };
|
|
29
291
|
listeners.forEach((listener) => listener(event));
|
|
30
292
|
}
|
|
31
|
-
function
|
|
293
|
+
function fireModal(content, options) {
|
|
32
294
|
init();
|
|
33
295
|
const config = {
|
|
34
296
|
content,
|
|
297
|
+
mode: "modal",
|
|
35
298
|
options: Object.assign(
|
|
36
299
|
{
|
|
37
300
|
position: "center",
|
|
38
|
-
mode: "modal",
|
|
39
301
|
showCloseIcon: true,
|
|
40
302
|
preventEscClose: false,
|
|
41
303
|
preventOverlayClose: false
|
|
@@ -46,6 +308,27 @@ function fire(content, options) {
|
|
|
46
308
|
currentConfig = config;
|
|
47
309
|
emit("open", config);
|
|
48
310
|
}
|
|
311
|
+
function fireNotification(content, options) {
|
|
312
|
+
init();
|
|
313
|
+
const config = {
|
|
314
|
+
content,
|
|
315
|
+
mode: "notification",
|
|
316
|
+
options: Object.assign(
|
|
317
|
+
{
|
|
318
|
+
position: "top-right",
|
|
319
|
+
showCloseIcon: true,
|
|
320
|
+
autoCloseTime: 5e3,
|
|
321
|
+
preventEscClose: false
|
|
322
|
+
},
|
|
323
|
+
options
|
|
324
|
+
)
|
|
325
|
+
};
|
|
326
|
+
currentConfig = config;
|
|
327
|
+
emit("open", config);
|
|
328
|
+
}
|
|
329
|
+
function fire(content, options) {
|
|
330
|
+
fireModal(content, options);
|
|
331
|
+
}
|
|
49
332
|
function close() {
|
|
50
333
|
if (currentConfig) {
|
|
51
334
|
emit("beforeClose", currentConfig);
|
|
@@ -72,6 +355,8 @@ function cleanup() {
|
|
|
72
355
|
const modalManager = {
|
|
73
356
|
subscribe,
|
|
74
357
|
fire,
|
|
358
|
+
fireModal,
|
|
359
|
+
fireNotification,
|
|
75
360
|
close,
|
|
76
361
|
isOpen,
|
|
77
362
|
getCurrentConfig,
|
|
@@ -262,6 +547,8 @@ function getAarkModalTheme() {
|
|
|
262
547
|
}
|
|
263
548
|
const aark = {
|
|
264
549
|
fire: (content, options) => modalManager.fire(content, options),
|
|
550
|
+
modal: (content, options) => modalManager.fireModal(content, options),
|
|
551
|
+
notification: (content, options) => modalManager.fireNotification(content, options),
|
|
265
552
|
close: () => modalManager.close(),
|
|
266
553
|
isOpen: () => modalManager.isOpen(),
|
|
267
554
|
closeAll: () => modalManager.closeAll(),
|
|
@@ -269,134 +556,10 @@ const aark = {
|
|
|
269
556
|
resetTheme: () => resetAarkModalTheme(),
|
|
270
557
|
getTheme: () => getAarkModalTheme()
|
|
271
558
|
};
|
|
272
|
-
function useModal() {
|
|
273
|
-
const [isOpen2, setIsOpen] = useState(false);
|
|
274
|
-
const [config, setConfig] = useState(null);
|
|
275
|
-
const close2 = useCallback(() => {
|
|
276
|
-
modalManager.close();
|
|
277
|
-
}, []);
|
|
278
|
-
useEffect(() => {
|
|
279
|
-
const handleModalEvent = (event) => {
|
|
280
|
-
switch (event.type) {
|
|
281
|
-
case "open":
|
|
282
|
-
setIsOpen(true);
|
|
283
|
-
setConfig(event.config || null);
|
|
284
|
-
break;
|
|
285
|
-
case "close":
|
|
286
|
-
setIsOpen(false);
|
|
287
|
-
setConfig(null);
|
|
288
|
-
break;
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
const unsubscribe = modalManager.subscribe(handleModalEvent);
|
|
292
|
-
setIsOpen(modalManager.isOpen());
|
|
293
|
-
setConfig(modalManager.getCurrentConfig());
|
|
294
|
-
return unsubscribe;
|
|
295
|
-
}, []);
|
|
296
|
-
return {
|
|
297
|
-
isOpen: isOpen2,
|
|
298
|
-
config,
|
|
299
|
-
close: close2
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
const injectStyles = (css, id) => {
|
|
303
|
-
if (typeof document === "undefined") return;
|
|
304
|
-
if (document.getElementById(id)) return;
|
|
305
|
-
const style = document.createElement("style");
|
|
306
|
-
style.id = id;
|
|
307
|
-
style.innerHTML = css;
|
|
308
|
-
document.head.appendChild(style);
|
|
309
|
-
};
|
|
310
|
-
const MODAL_CSS = `:root{--aark-modal-overlay-bg:rgba(0,0,0,.5);--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-z:9999;--aark-close-color:#666;--aark-close-hover:#f5f5f5;--aark-anim:.2s}.aark-modal-container{position:fixed;inset:0;z-index:var(--aark-modal-z)}.aark-modal-container.notification{pointer-events:none}.aark-modal-overlay{position:absolute;inset:0;background:var(--aark-modal-overlay-bg);backdrop-filter:blur(2px)}.aark-modal-content{position:fixed;background:var(--aark-modal-bg);border-radius:var(--aark-modal-radius);box-shadow:var(--aark-modal-shadow);padding:var(--aark-modal-pad);z-index:calc(var(--aark-modal-z) + 1);max-width:90vw;max-height:90vh;overflow:auto}.aark-modal-content.notification{pointer-events:auto}.aark-modal-content.center{top:50%;left:50%;transform:translate(-50%,-50%)}.aark-modal-content.top-center{top:20px;left:50%;transform:translateX(-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:translateX(-50%)}.aark-modal-close{position:absolute;top:8px;right:8px;width:24px;height:24px;display:flex;align-items:center;justify-content:center;background:0;border:0;color:var(--aark-close-color);cursor:pointer;border-radius:50%;font-size:14px;line-height:1;transition:all var(--aark-anim)}.aark-modal-close:hover{background:var(--aark-close-hover);color:#333}.aark-modal-close:focus{outline:2px solid #007bff;outline-offset:2px}.aark-modal-body{padding-top:8px}.aark-modal-container{animation:f var(--aark-anim)}.aark-modal-content{animation:s var(--aark-anim)}@keyframes f{0%{opacity:0}to{opacity:1}}@keyframes s{0%{opacity:0;transform:translate(-50%,-50%) scale(.95)}to{opacity:1;transform:translate(-50%,-50%) scale(1)}}.aark-modal-content.top-center{animation:d var(--aark-anim)}.aark-modal-content.top-right,.aark-modal-content.bottom-right{animation:l var(--aark-anim)}.aark-modal-content.bottom-center{animation:u var(--aark-anim)}@keyframes d{0%{opacity:0;transform:translateX(-50%) translateY(-10px)}to{opacity:1;transform:translateX(-50%) translateY(0)}}@keyframes l{0%{opacity:0;transform:translateX(10px)}to{opacity:1;transform:translateX(0)}}@keyframes u{0%{opacity:0;transform:translateX(-50%) translateY(10px)}to{opacity:1;transform:translateX(-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:translateX(-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}}`;
|
|
311
|
-
const ModalRenderer = ({ config, onClose }) => {
|
|
312
|
-
const { content, options = {} } = config;
|
|
313
|
-
const {
|
|
314
|
-
position = "center",
|
|
315
|
-
mode = "modal",
|
|
316
|
-
showCloseIcon = true,
|
|
317
|
-
autoCloseTime,
|
|
318
|
-
className = "",
|
|
319
|
-
overlayClassName = "",
|
|
320
|
-
preventEscClose = false,
|
|
321
|
-
preventOverlayClose = false
|
|
322
|
-
} = options;
|
|
323
|
-
useEffect(() => {
|
|
324
|
-
injectStyles(MODAL_CSS, "aark-modal-styles");
|
|
325
|
-
}, []);
|
|
326
|
-
useEffect(() => {
|
|
327
|
-
if (autoCloseTime && mode === "notification") {
|
|
328
|
-
const timer = setTimeout(onClose, autoCloseTime);
|
|
329
|
-
return () => clearTimeout(timer);
|
|
330
|
-
}
|
|
331
|
-
}, [autoCloseTime, mode, onClose]);
|
|
332
|
-
useEffect(() => {
|
|
333
|
-
const handleKeyDown = (event) => {
|
|
334
|
-
if (event.key === "Escape" && !preventEscClose) {
|
|
335
|
-
onClose();
|
|
336
|
-
}
|
|
337
|
-
};
|
|
338
|
-
if (!preventEscClose) {
|
|
339
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
340
|
-
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
341
|
-
}
|
|
342
|
-
}, [onClose, preventEscClose]);
|
|
343
|
-
const handleOverlayClick = useCallback(
|
|
344
|
-
(event) => {
|
|
345
|
-
if (event.target === event.currentTarget && !preventOverlayClose) {
|
|
346
|
-
onClose();
|
|
347
|
-
}
|
|
348
|
-
},
|
|
349
|
-
[onClose, preventOverlayClose]
|
|
350
|
-
);
|
|
351
|
-
const handleCloseClick = useCallback(
|
|
352
|
-
(event) => {
|
|
353
|
-
event.stopPropagation();
|
|
354
|
-
onClose();
|
|
355
|
-
},
|
|
356
|
-
[onClose]
|
|
357
|
-
);
|
|
358
|
-
const containerClasses = `aark-modal-container ${mode === "notification" ? "notification" : ""}`;
|
|
359
|
-
const contentClasses = `aark-modal-content ${position} ${mode === "notification" ? "notification" : ""} ${className}`.trim();
|
|
360
|
-
const overlayClasses = `aark-modal-overlay ${overlayClassName}`.trim();
|
|
361
|
-
const modalContainer = document.getElementById("aark-react-modalify-root") || document.body;
|
|
362
|
-
return createPortal(
|
|
363
|
-
/* @__PURE__ */ jsxs("div", { className: containerClasses, children: [
|
|
364
|
-
mode === "modal" && /* @__PURE__ */ jsx(
|
|
365
|
-
"div",
|
|
366
|
-
{
|
|
367
|
-
className: overlayClasses,
|
|
368
|
-
onClick: handleOverlayClick,
|
|
369
|
-
"aria-hidden": "true"
|
|
370
|
-
}
|
|
371
|
-
),
|
|
372
|
-
/* @__PURE__ */ jsxs(
|
|
373
|
-
"div",
|
|
374
|
-
{
|
|
375
|
-
className: contentClasses,
|
|
376
|
-
role: "dialog",
|
|
377
|
-
"aria-modal": "true",
|
|
378
|
-
"aria-labelledby": "aark-modal-content",
|
|
379
|
-
children: [
|
|
380
|
-
showCloseIcon && /* @__PURE__ */ jsx(
|
|
381
|
-
"button",
|
|
382
|
-
{
|
|
383
|
-
onClick: handleCloseClick,
|
|
384
|
-
className: "aark-modal-close",
|
|
385
|
-
"aria-label": "Close modal",
|
|
386
|
-
type: "button",
|
|
387
|
-
children: "×"
|
|
388
|
-
}
|
|
389
|
-
),
|
|
390
|
-
/* @__PURE__ */ jsx("div", { id: "aark-modal-content", className: "aark-modal-body", children: content })
|
|
391
|
-
]
|
|
392
|
-
}
|
|
393
|
-
)
|
|
394
|
-
] }),
|
|
395
|
-
modalContainer
|
|
396
|
-
);
|
|
397
|
-
};
|
|
398
559
|
export {
|
|
399
|
-
|
|
560
|
+
Modal,
|
|
561
|
+
ModalProvider,
|
|
562
|
+
Notification,
|
|
400
563
|
aark,
|
|
401
564
|
getAarkModalTheme,
|
|
402
565
|
resetAarkModalTheme,
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ComponentConfig, ModalOptions, NotificationOptions, ModalEvent } from "../types";
|
|
3
3
|
type ModalListener = (event: ModalEvent) => void;
|
|
4
4
|
declare function subscribe(listener: ModalListener): () => void;
|
|
5
|
+
declare function fireModal(content: ReactNode, options?: ModalOptions): void;
|
|
6
|
+
declare function fireNotification(content: ReactNode, options?: NotificationOptions): void;
|
|
5
7
|
declare function fire(content: ReactNode, options?: ModalOptions): void;
|
|
6
8
|
declare function close(): void;
|
|
7
9
|
declare function isOpen(): boolean;
|
|
8
|
-
declare function getCurrentConfig():
|
|
10
|
+
declare function getCurrentConfig(): ComponentConfig | null;
|
|
9
11
|
declare function closeAll(): void;
|
|
10
12
|
declare function cleanup(): void;
|
|
11
13
|
export declare const modalManager: {
|
|
12
14
|
subscribe: typeof subscribe;
|
|
13
15
|
fire: typeof fire;
|
|
16
|
+
fireModal: typeof fireModal;
|
|
17
|
+
fireNotification: typeof fireNotification;
|
|
14
18
|
close: typeof close;
|
|
15
19
|
isOpen: typeof isOpen;
|
|
16
20
|
getCurrentConfig: typeof getCurrentConfig;
|
|
File without changes
|
package/dist/logic/aark.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import type { ModalOptions } from "../types";
|
|
2
|
+
import type { ModalOptions, NotificationOptions } from "../types";
|
|
3
3
|
import type { AarkModalTheme } from "../utils/theme";
|
|
4
4
|
declare const aark: {
|
|
5
5
|
fire: (content: ReactNode, options?: ModalOptions) => void;
|
|
6
|
+
modal: (content: ReactNode, options?: ModalOptions) => void;
|
|
7
|
+
notification: (content: ReactNode, options?: NotificationOptions) => void;
|
|
6
8
|
close: () => void;
|
|
7
9
|
isOpen: () => boolean;
|
|
8
10
|
closeAll: () => void;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,26 +1,38 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
export type ModalPosition = "center" | "top-center" | "top-right" | "bottom-right" | "bottom-center";
|
|
3
|
+
export type NotificationPosition = "top-right" | "top-center" | "top-left" | "bottom-right" | "bottom-center" | "bottom-left";
|
|
3
4
|
export type ModalMode = "modal" | "notification";
|
|
4
|
-
export interface
|
|
5
|
-
position?: ModalPosition;
|
|
6
|
-
mode?: ModalMode;
|
|
5
|
+
export interface BaseOptions {
|
|
7
6
|
showCloseIcon?: boolean;
|
|
8
|
-
autoCloseTime?: number;
|
|
9
7
|
className?: string;
|
|
10
|
-
overlayClassName?: string;
|
|
11
8
|
preventEscClose?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface ModalOptions extends BaseOptions {
|
|
11
|
+
position?: ModalPosition;
|
|
12
|
+
overlayClassName?: string;
|
|
12
13
|
preventOverlayClose?: boolean;
|
|
13
14
|
}
|
|
15
|
+
export interface NotificationOptions extends BaseOptions {
|
|
16
|
+
position?: NotificationPosition;
|
|
17
|
+
autoCloseTime?: number;
|
|
18
|
+
}
|
|
14
19
|
export interface ModalConfig {
|
|
15
20
|
content: ReactNode;
|
|
16
21
|
options?: ModalOptions;
|
|
22
|
+
mode: "modal";
|
|
23
|
+
}
|
|
24
|
+
export interface NotificationConfig {
|
|
25
|
+
content: ReactNode;
|
|
26
|
+
options?: NotificationOptions;
|
|
27
|
+
mode: "notification";
|
|
17
28
|
}
|
|
29
|
+
export type ComponentConfig = ModalConfig | NotificationConfig;
|
|
18
30
|
export interface ModalState {
|
|
19
31
|
isOpen: boolean;
|
|
20
|
-
config:
|
|
32
|
+
config: ComponentConfig | null;
|
|
21
33
|
}
|
|
22
34
|
export type ModalEventType = "open" | "close" | "beforeClose";
|
|
23
35
|
export interface ModalEvent {
|
|
24
36
|
type: ModalEventType;
|
|
25
|
-
config?:
|
|
37
|
+
config?: ComponentConfig;
|
|
26
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MODAL_CSS = ":root{--aark-modal-overlay-bg:rgba(0,0,0,.5);--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-z:9999;--aark-close-color:#666;--aark-close-hover:#f5f5f5;--aark-anim:.2s}.aark-modal-
|
|
1
|
+
export declare const MODAL_CSS = ":root{--aark-modal-overlay-bg:rgba(0,0,0,.5);--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-z:9999;--aark-close-color:#666;--aark-close-hover:#f5f5f5;--aark-anim:.2s}.aark-modal-content{position:fixed;background:var(--aark-modal-bg);border-radius:var(--aark-modal-radius);box-shadow:var(--aark-modal-shadow);padding:var(--aark-modal-pad);z-index:calc(var(--aark-modal-z) + 1);max-width:90vw;min-width:280px;max-height:90vh;overflow:auto}.aark-modal-content.notification{pointer-events:auto;background:var(--aark-modal-bg);box-shadow:var(--aark-modal-shadow);padding:var(--aark-modal-pad);width:auto;max-width:400px;min-width:280px;border-radius:var(--aark-modal-radius)}.aark-modal-content.center{top:50%;left:50%;transform:translate(-50%,-50%);animation:scale-in var(--aark-anim)}.aark-modal-content.top-center{top:20px;left:50%;transform:translateX(-50%);animation:slide-down var(--aark-anim)}.aark-modal-content.top-right{top:20px;right:20px;animation:slide-left var(--aark-anim)}.aark-modal-content.top-left{top:20px;left:20px;animation:slide-right var(--aark-anim)}.aark-modal-content.bottom-right{bottom:20px;right:20px;animation:slide-left var(--aark-anim)}.aark-modal-content.bottom-left{bottom:20px;left:20px;animation:slide-right var(--aark-anim)}.aark-modal-content.bottom-center{bottom:20px;left:50%;transform:translateX(-50%);animation:slide-up var(--aark-anim)}.aark-modal-close{position:absolute;top:8px;right:8px;width:30px;height:30px;padding:.5rem;display:flex;align-items:center;justify-content:center;background:0;border:0;color:var(--aark-close-color);cursor:pointer;border-radius:50%;font-size:14px;line-height:1;transition:all var(--aark-anim)}.aark-modal-close:hover{background:var(--aark-close-hover);color:#333}.aark-modal-close:focus{outline:2px solid #007bff;outline-offset:2px}.aark-modal-body{padding-top:8px}@keyframes fade-in{0%{opacity:0}to{opacity:1}}@keyframes scale-in{0%{opacity:0;transform:translate(-50%,-50%) scale(.9)}to{opacity:1;transform:translate(-50%,-50%) scale(1)}}@keyframes slide-down{0%{opacity:0;transform:translateX(-50%) translateY(-20px)}to{opacity:1;transform:translateX(-50%) translateY(0)}}@keyframes slide-up{0%{opacity:0;transform:translateX(-50%) translateY(20px)}to{opacity:1;transform:translateX(-50%) translateY(0)}}@keyframes slide-left{0%{opacity:0;transform:translateX(20px)}to{opacity:1;transform:translateX(0)}}@keyframes slide-right{0%{opacity:0;transform:translateX(-20px)}to{opacity:1;transform:translateX(0)}}@media (max-width:768px){.aark-modal-content{margin:10px;max-width:calc(100vw - 20px);min-width:auto}.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:translateX(-50%)}.aark-modal-content.top-right{right:10px;left:auto;transform:none}.aark-modal-content.top-left{left:10px;right:auto;transform:none}.aark-modal-content.bottom-right{right:10px;bottom:10px;left:auto;transform:none}.aark-modal-content.bottom-left{left:10px;bottom:10px;right:auto;transform:none}.aark-modal-content.notification{width:auto;max-width:calc(100vw - 20px);min-width:auto}}@media (max-width:480px){.aark-modal-content{max-width:calc(100vw - 10px);margin:5px}.aark-modal-content.center{top:10px;left:50%;transform:translateX(-50%);max-height:calc(100vh - 20px)}}";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aark-react-modalify",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
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
|
"private": false,
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"import": "./dist/index.esm.js",
|
|
14
14
|
"require": "./dist/index.cjs.js"
|
|
15
|
+
},
|
|
16
|
+
"./styles": {
|
|
17
|
+
"types": "./dist/index-with-styles.d.ts",
|
|
18
|
+
"import": "./dist/index-with-styles.esm.js",
|
|
19
|
+
"require": "./dist/index-with-styles.cjs.js"
|
|
15
20
|
}
|
|
16
21
|
},
|
|
17
22
|
"files": [
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useModal, ModalRenderer } from "./index.esm.js";
|
|
3
|
-
const ModalProvider = () => {
|
|
4
|
-
const { isOpen, config, close } = useModal();
|
|
5
|
-
if (!isOpen || !config) {
|
|
6
|
-
return null;
|
|
7
|
-
}
|
|
8
|
-
return /* @__PURE__ */ jsx(ModalRenderer, { config, onClose: close });
|
|
9
|
-
};
|
|
10
|
-
export {
|
|
11
|
-
ModalProvider as default
|
|
12
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict"
|
|
2
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})
|
|
3
|
-
const e=require("react/jsx-runtime"),s=require("./index.cjs.js")
|
|
4
|
-
exports.default=()=>{const{isOpen:o,config:r,close:n}=s.useModal()
|
|
5
|
-
return o&&r?e.jsx(s.ModalRenderer,{config:r,onClose:n}):null}
|