aark-react-modalify 1.1.0 → 1.2.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 +225 -118
- package/dist/aark-react-modalify.css +1 -1
- package/dist/components/modals/StandardModal.d.ts +8 -0
- package/dist/components/modals/index.d.ts +1 -0
- package/dist/components/notifications/StandardNotification.d.ts +8 -0
- package/dist/components/notifications/index.d.ts +1 -0
- package/dist/index-no-styles.cjs.js +1 -0
- package/dist/index-no-styles.esm.js +14 -0
- package/dist/index.d.ts +2 -1
- package/dist/logic/ModalManager.d.ts +4 -4
- package/dist/logic/aark.d.ts +4 -4
- package/dist/types/index.d.ts +66 -2
- package/dist/utils/inject-styles.d.ts +3 -0
- package/dist/utils/modal-root.d.ts +18 -0
- package/package.json +27 -25
- package/dist/index.cjs.js +0 -32
- package/dist/index.esm.js +0 -568
package/dist/logic/aark.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import type { ModalOptions, NotificationOptions } from "../types";
|
|
2
|
+
import type { ModalOptions, NotificationOptions, ModalProps, NotificationProps } from "../types";
|
|
3
3
|
import type { AarkModalTheme } from "../utils/theme";
|
|
4
4
|
declare const aark: {
|
|
5
|
-
fire: (
|
|
6
|
-
modal: (
|
|
7
|
-
notification: (
|
|
5
|
+
fire: (contentOrProps: ReactNode | ModalProps, options?: ModalOptions) => void;
|
|
6
|
+
modal: (contentOrProps: ReactNode | ModalProps, options?: ModalOptions) => void;
|
|
7
|
+
notification: (contentOrProps: ReactNode | NotificationProps, options?: NotificationOptions) => void;
|
|
8
8
|
close: () => void;
|
|
9
9
|
isOpen: () => boolean;
|
|
10
10
|
closeAll: () => void;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,6 +2,68 @@ import type { ReactNode } from "react";
|
|
|
2
2
|
export type ModalPosition = "center" | "top-center" | "top-right" | "bottom-right" | "bottom-center";
|
|
3
3
|
export type NotificationPosition = "top-right" | "top-center" | "top-left" | "bottom-right" | "bottom-center" | "bottom-left";
|
|
4
4
|
export type ModalMode = "modal" | "notification";
|
|
5
|
+
export type ModalType = "success" | "error" | "warning" | "info" | "question";
|
|
6
|
+
export interface ModalProps {
|
|
7
|
+
title?: string;
|
|
8
|
+
text?: string;
|
|
9
|
+
type?: ModalType;
|
|
10
|
+
cancelText?: string;
|
|
11
|
+
confirmText?: string;
|
|
12
|
+
onCancel?: () => void;
|
|
13
|
+
onConfirm?: () => void;
|
|
14
|
+
icon?: string | ReactNode;
|
|
15
|
+
html?: string | ReactNode;
|
|
16
|
+
showCancelButton?: boolean;
|
|
17
|
+
showConfirmButton?: boolean;
|
|
18
|
+
allowOutsideClick?: boolean;
|
|
19
|
+
allowEscapeKey?: boolean;
|
|
20
|
+
reverseButtons?: boolean;
|
|
21
|
+
focusConfirm?: boolean;
|
|
22
|
+
focusCancel?: boolean;
|
|
23
|
+
width?: string | number;
|
|
24
|
+
fullWidth?: boolean;
|
|
25
|
+
padding?: string | number;
|
|
26
|
+
background?: string;
|
|
27
|
+
customClass?: {
|
|
28
|
+
container?: string;
|
|
29
|
+
popup?: string;
|
|
30
|
+
header?: string;
|
|
31
|
+
title?: string;
|
|
32
|
+
closeButton?: string;
|
|
33
|
+
icon?: string;
|
|
34
|
+
image?: string;
|
|
35
|
+
content?: string;
|
|
36
|
+
input?: string;
|
|
37
|
+
actions?: string;
|
|
38
|
+
confirmButton?: string;
|
|
39
|
+
cancelButton?: string;
|
|
40
|
+
footer?: string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface NotificationProps {
|
|
44
|
+
title?: string;
|
|
45
|
+
text?: string;
|
|
46
|
+
type?: ModalType;
|
|
47
|
+
icon?: string | ReactNode;
|
|
48
|
+
html?: string | ReactNode;
|
|
49
|
+
timer?: number;
|
|
50
|
+
showCloseButton?: boolean;
|
|
51
|
+
clickToClose?: boolean;
|
|
52
|
+
width?: string | number;
|
|
53
|
+
fullWidth?: boolean;
|
|
54
|
+
padding?: string | number;
|
|
55
|
+
background?: string;
|
|
56
|
+
customClass?: {
|
|
57
|
+
container?: string;
|
|
58
|
+
popup?: string;
|
|
59
|
+
header?: string;
|
|
60
|
+
title?: string;
|
|
61
|
+
closeButton?: string;
|
|
62
|
+
icon?: string;
|
|
63
|
+
content?: string;
|
|
64
|
+
footer?: string;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
5
67
|
export interface BaseOptions {
|
|
6
68
|
showCloseIcon?: boolean;
|
|
7
69
|
className?: string;
|
|
@@ -17,12 +79,14 @@ export interface NotificationOptions extends BaseOptions {
|
|
|
17
79
|
autoCloseTime?: number;
|
|
18
80
|
}
|
|
19
81
|
export interface ModalConfig {
|
|
20
|
-
content
|
|
82
|
+
content?: ReactNode;
|
|
83
|
+
props?: ModalProps;
|
|
21
84
|
options?: ModalOptions;
|
|
22
85
|
mode: "modal";
|
|
23
86
|
}
|
|
24
87
|
export interface NotificationConfig {
|
|
25
|
-
content
|
|
88
|
+
content?: ReactNode;
|
|
89
|
+
props?: NotificationProps;
|
|
26
90
|
options?: NotificationOptions;
|
|
27
91
|
mode: "notification";
|
|
28
92
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility to manage the single modal root container
|
|
3
|
+
* Ensures only one instance of aark-react-modalify-root exists
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Gets or creates the modal root container
|
|
7
|
+
* Returns the same instance for both modals and notifications
|
|
8
|
+
*/
|
|
9
|
+
export declare const getModalRoot: () => HTMLElement;
|
|
10
|
+
/**
|
|
11
|
+
* Cleanup function to remove the modal root when no longer needed
|
|
12
|
+
* Should be called when the last modal/notification is closed
|
|
13
|
+
*/
|
|
14
|
+
export declare const cleanupModalRoot: () => void;
|
|
15
|
+
/**
|
|
16
|
+
* Check if modal root exists and has content
|
|
17
|
+
*/
|
|
18
|
+
export declare const hasActiveModals: () => boolean;
|
package/package.json
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aark-react-modalify",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
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",
|
|
7
7
|
"module": "dist/index.esm.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
|
-
"type": "module",
|
|
10
9
|
"exports": {
|
|
11
10
|
".": {
|
|
12
11
|
"types": "./dist/index.d.ts",
|
|
13
12
|
"import": "./dist/index.esm.js",
|
|
14
13
|
"require": "./dist/index.cjs.js"
|
|
15
14
|
},
|
|
16
|
-
"./styles": {
|
|
17
|
-
"types": "./dist/index-
|
|
18
|
-
"import": "./dist/index-
|
|
19
|
-
"require": "./dist/index-
|
|
20
|
-
}
|
|
15
|
+
"./no-styles": {
|
|
16
|
+
"types": "./dist/index-no-styles.d.ts",
|
|
17
|
+
"import": "./dist/index-no-styles.esm.js",
|
|
18
|
+
"require": "./dist/index-no-styles.cjs.js"
|
|
19
|
+
},
|
|
20
|
+
"./dist/aark-react-modalify.css": "./dist/aark-react-modalify.css",
|
|
21
|
+
"./css": "./dist/aark-react-modalify.css"
|
|
21
22
|
},
|
|
22
23
|
"files": [
|
|
23
24
|
"dist",
|
|
@@ -25,8 +26,9 @@
|
|
|
25
26
|
"LICENSE"
|
|
26
27
|
],
|
|
27
28
|
"scripts": {
|
|
28
|
-
"build": "npm run clean && npm run build:lib && npm run build:types",
|
|
29
|
+
"build": "npm run clean && npm run build:lib && npm run build:no-styles && npm run build:types",
|
|
29
30
|
"build:lib": "vite build --config vite.lib.config.ts",
|
|
31
|
+
"build:no-styles": "vite build --config vite.lib-no-styles.config.ts",
|
|
30
32
|
"build:types": "tsc --project tsconfig.build.json --emitDeclarationOnly",
|
|
31
33
|
"clean": "rimraf dist",
|
|
32
34
|
"dev": "vite",
|
|
@@ -60,23 +62,23 @@
|
|
|
60
62
|
"react-dom": ">=16.8.0"
|
|
61
63
|
},
|
|
62
64
|
"devDependencies": {
|
|
63
|
-
"@eslint/js": "^9.
|
|
64
|
-
"@types/node": "^24.
|
|
65
|
-
"@types/react": "^19.
|
|
66
|
-
"@types/react-dom": "^19.
|
|
67
|
-
"@vitejs/plugin-react": "^
|
|
68
|
-
"cssnano": "^7.1.
|
|
69
|
-
"eslint": "^9.
|
|
70
|
-
"eslint-plugin-react-hooks": "^
|
|
71
|
-
"eslint-plugin-react-refresh": "^0.4.
|
|
72
|
-
"globals": "^16.
|
|
73
|
-
"react": "^19.
|
|
74
|
-
"react-dom": "^19.
|
|
75
|
-
"rimraf": "^6.0
|
|
76
|
-
"terser": "^5.
|
|
77
|
-
"typescript": "~5.
|
|
78
|
-
"typescript-eslint": "^8.
|
|
79
|
-
"vite": "^7.
|
|
65
|
+
"@eslint/js": "^9.39.1",
|
|
66
|
+
"@types/node": "^24.10.1",
|
|
67
|
+
"@types/react": "^19.2.6",
|
|
68
|
+
"@types/react-dom": "^19.2.3",
|
|
69
|
+
"@vitejs/plugin-react": "^5.1.1",
|
|
70
|
+
"cssnano": "^7.1.2",
|
|
71
|
+
"eslint": "^9.39.1",
|
|
72
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
73
|
+
"eslint-plugin-react-refresh": "^0.4.24",
|
|
74
|
+
"globals": "^16.5.0",
|
|
75
|
+
"react": "^19.2.0",
|
|
76
|
+
"react-dom": "^19.2.0",
|
|
77
|
+
"rimraf": "^6.1.0",
|
|
78
|
+
"terser": "^5.44.1",
|
|
79
|
+
"typescript": "~5.9.3",
|
|
80
|
+
"typescript-eslint": "^8.47.0",
|
|
81
|
+
"vite": "^7.2.2"
|
|
80
82
|
},
|
|
81
83
|
"license": "MIT",
|
|
82
84
|
"author": "Mohammad Sumon",
|
package/dist/index.cjs.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict"
|
|
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)
|
|
4
|
-
break
|
|
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
|