aark-react-modalify 1.2.2 → 1.3.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 +416 -225
- package/dist/aark-react-modalify.css +1 -1
- package/dist/index-no-styles.cjs.js +13 -1
- package/dist/index-no-styles.d.mts +189 -0
- package/dist/index-no-styles.d.ts +189 -0
- package/dist/index-no-styles.esm.js +13 -14
- package/dist/index.cjs.js +13 -51
- package/dist/index.d.mts +189 -0
- package/dist/index.d.ts +189 -9
- package/dist/index.esm.js +13 -62
- package/package.json +86 -92
- package/dist/components/Icon.d.ts +0 -18
- package/dist/components/Modal.d.ts +0 -9
- package/dist/components/ModalProvider.d.ts +0 -7
- package/dist/components/Notification.d.ts +0 -9
- package/dist/components/modals/StandardModal.d.ts +0 -8
- package/dist/components/modals/index.d.ts +0 -1
- package/dist/components/notifications/StandardNotification.d.ts +0 -8
- package/dist/components/notifications/index.d.ts +0 -1
- package/dist/hooks/useModal.d.ts +0 -10
- package/dist/logic/ModalManager.d.ts +0 -24
- package/dist/logic/ModalManagerNew.d.ts +0 -0
- package/dist/logic/aark.d.ts +0 -15
- package/dist/types/index.d.ts +0 -102
- package/dist/utils/inject-styles.d.ts +0 -4
- package/dist/utils/modal-css.d.ts +0 -1
- package/dist/utils/modal-root.d.ts +0 -18
- package/dist/utils/theme.d.ts +0 -40
- package/dist/vite.svg +0 -1
package/README.md
CHANGED
|
@@ -1,330 +1,521 @@
|
|
|
1
|
-
# AARK React Modalify
|
|
1
|
+
# AARK React Modalify
|
|
2
2
|
|
|
3
|
-
A lightweight, flexible React modal and notification library with TypeScript support. Features automatic DOM mounting, customizable styling
|
|
3
|
+
A lightweight, flexible React modal and notification library with TypeScript support. Features automatic DOM mounting, customizable styling via CSS variables, responsive size presets, and a simple imperative API.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/aark-react-modalify)
|
|
6
|
+
[](LICENSE)
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
- **TypeScript Support**: Full type safety out of the box
|
|
9
|
-
- **Dual API**: Component-based OR props-based configuration
|
|
10
|
-
- **Automatic CSS**: Styles included automatically or import separately
|
|
11
|
-
- **Portal Rendering**: Modals render outside your component tree
|
|
12
|
-
- **Accessibility**: Built-in keyboard navigation and focus management
|
|
13
|
-
- **Customizable**: CSS variables for complete theme control
|
|
14
|
-
- **Multiple Positions**: Various positioning options for modals and notifications
|
|
15
|
-
- **Animation Support**: Smooth fade and slide animations
|
|
16
|
-
- **Hook Integration**: useModal hook for advanced use cases
|
|
8
|
+
## Features
|
|
17
9
|
|
|
18
|
-
|
|
10
|
+
- **Zero runtime dependencies** — pure React + ReactDOM
|
|
11
|
+
- **TypeScript** — full type safety out of the box
|
|
12
|
+
- **Dual API** — pass raw JSX _or_ a plain props object
|
|
13
|
+
- **Size presets** — `sm / md / lg / xl / full` with explicit `width` / `maxWidth` override
|
|
14
|
+
- **Responsive** — adapts automatically on tablet and mobile
|
|
15
|
+
- **CSS variables** — theme every visual property without touching JS
|
|
16
|
+
- **Imperative** — call `aark.fire()` / `aark.notification()` anywhere, no context required
|
|
17
|
+
- **Portal rendering** — modal root managed automatically, no wrapping provider needed
|
|
18
|
+
- **Accessibility** — ESC key, overlay click, and focus management built in
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
19
23
|
|
|
20
24
|
```bash
|
|
25
|
+
# npm
|
|
21
26
|
npm install aark-react-modalify
|
|
27
|
+
|
|
28
|
+
# pnpm
|
|
29
|
+
pnpm add aark-react-modalify
|
|
30
|
+
|
|
31
|
+
# yarn
|
|
32
|
+
yarn add aark-react-modalify
|
|
22
33
|
```
|
|
23
34
|
|
|
24
|
-
|
|
35
|
+
**Peer dependencies:** `react >= 16.8.0`, `react-dom >= 16.8.0`
|
|
25
36
|
|
|
26
|
-
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
27
40
|
|
|
28
|
-
|
|
41
|
+
### Component-based (pass any JSX)
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
29
44
|
import { aark } from "aark-react-modalify";
|
|
30
45
|
|
|
31
46
|
function App() {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
return <button onClick={openModal}>Open Modal</button>;
|
|
47
|
+
const openModal = () => {
|
|
48
|
+
aark.fire(
|
|
49
|
+
<div>
|
|
50
|
+
<h2>Hello World!</h2>
|
|
51
|
+
<p>This is a simple modal.</p>
|
|
52
|
+
<button onClick={() => aark.close()}>Close</button>
|
|
53
|
+
</div>,
|
|
54
|
+
{ position: "center", showCloseIcon: true }
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return <button onClick={openModal}>Open Modal</button>;
|
|
47
59
|
}
|
|
48
60
|
```
|
|
49
61
|
|
|
50
|
-
### Props-
|
|
62
|
+
### Props-based (built-in styled templates)
|
|
51
63
|
|
|
52
|
-
```
|
|
64
|
+
```tsx
|
|
53
65
|
import { aark } from "aark-react-modalify";
|
|
54
66
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
timer: 3000,
|
|
70
|
-
});
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
return <button onClick={showConfirmation}>Delete Item</button>;
|
|
76
|
-
}
|
|
67
|
+
aark.fire({
|
|
68
|
+
title: "Delete Item",
|
|
69
|
+
text: "Are you sure you want to delete this item?",
|
|
70
|
+
type: "warning",
|
|
71
|
+
showCancelButton: true,
|
|
72
|
+
confirmText: "Yes, delete it!",
|
|
73
|
+
cancelText: "Cancel",
|
|
74
|
+
onConfirm: () => {
|
|
75
|
+
aark.notification(
|
|
76
|
+
{ title: "Deleted!", text: "The item has been deleted.", type: "success", timer: 3000 },
|
|
77
|
+
{ position: "top-right" }
|
|
78
|
+
);
|
|
79
|
+
},
|
|
80
|
+
});
|
|
77
81
|
```
|
|
78
82
|
|
|
79
|
-
|
|
83
|
+
> **Note:** `position` and other display options for notifications go in the **second argument** (`NotificationOptions`), not inside the props object.
|
|
80
84
|
|
|
81
|
-
|
|
85
|
+
---
|
|
82
86
|
|
|
83
|
-
|
|
87
|
+
## API Reference
|
|
84
88
|
|
|
85
|
-
|
|
89
|
+
### `aark.fire(content, options?)` — component-based modal
|
|
86
90
|
|
|
87
|
-
```
|
|
88
|
-
aark.fire(<YourComponent />, options);
|
|
91
|
+
```tsx
|
|
92
|
+
aark.fire(<YourComponent />, options?: ModalOptions);
|
|
89
93
|
```
|
|
90
94
|
|
|
91
|
-
|
|
95
|
+
### `aark.modal(content, options?)` — alias for `aark.fire`
|
|
92
96
|
|
|
93
|
-
```
|
|
94
|
-
aark.
|
|
95
|
-
title: "Modal Title",
|
|
96
|
-
text: "Modal content",
|
|
97
|
-
type: "info", // "success" | "error" | "warning" | "info" | "question"
|
|
98
|
-
showCancelButton: true,
|
|
99
|
-
confirmText: "OK",
|
|
100
|
-
cancelText: "Cancel",
|
|
101
|
-
onConfirm: () => {},
|
|
102
|
-
onCancel: () => {},
|
|
103
|
-
});
|
|
97
|
+
```tsx
|
|
98
|
+
aark.modal(<YourComponent />, options?: ModalOptions);
|
|
104
99
|
```
|
|
105
100
|
|
|
106
|
-
###
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
101
|
+
### `aark.fire(props, options?)` — props-based modal
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
aark.fire(
|
|
105
|
+
{
|
|
106
|
+
title?: string;
|
|
107
|
+
text?: string;
|
|
108
|
+
type?: "success" | "error" | "warning" | "info" | "question";
|
|
109
|
+
icon?: string | ReactNode;
|
|
110
|
+
html?: string | ReactNode; // string → dangerouslySetInnerHTML, ReactNode → rendered as JSX
|
|
111
|
+
confirmText?: string; // default: "OK"
|
|
112
|
+
cancelText?: string; // default: "Cancel"
|
|
113
|
+
showCancelButton?: boolean; // default: false
|
|
114
|
+
showConfirmButton?: boolean; // default: true
|
|
115
|
+
reverseButtons?: boolean; // swap confirm/cancel order
|
|
116
|
+
onConfirm?: () => void;
|
|
117
|
+
onCancel?: () => void;
|
|
118
|
+
width?: string | number; // e.g. "500px", "80%", 600
|
|
119
|
+
fullWidth?: boolean;
|
|
120
|
+
padding?: string | number;
|
|
121
|
+
customClass?: {
|
|
122
|
+
popup?: string;
|
|
123
|
+
header?: string;
|
|
124
|
+
title?: string;
|
|
125
|
+
icon?: string;
|
|
126
|
+
content?: string;
|
|
127
|
+
confirmButton?: string;
|
|
128
|
+
cancelButton?: string;
|
|
129
|
+
footer?: string;
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
options?: ModalOptions // position, size, showCloseIcon, etc.
|
|
133
|
+
);
|
|
114
134
|
```
|
|
115
135
|
|
|
116
|
-
|
|
136
|
+
### `aark.notification(content, options?)` — component-based notification
|
|
117
137
|
|
|
118
|
-
```
|
|
119
|
-
aark.notification(
|
|
120
|
-
title: "Notification Title",
|
|
121
|
-
text: "Notification message",
|
|
122
|
-
type: "success",
|
|
123
|
-
timer: 3000,
|
|
124
|
-
position: "top-right",
|
|
125
|
-
});
|
|
138
|
+
```tsx
|
|
139
|
+
aark.notification(<YourToast />, options?: NotificationOptions);
|
|
126
140
|
```
|
|
127
141
|
|
|
128
|
-
###
|
|
129
|
-
|
|
130
|
-
```
|
|
131
|
-
aark.
|
|
132
|
-
|
|
133
|
-
|
|
142
|
+
### `aark.notification(props, options?)` — props-based notification
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
aark.notification(
|
|
146
|
+
{
|
|
147
|
+
title?: string;
|
|
148
|
+
text?: string;
|
|
149
|
+
type?: "success" | "error" | "warning" | "info" | "question";
|
|
150
|
+
icon?: string | ReactNode;
|
|
151
|
+
html?: string | ReactNode; // string → dangerouslySetInnerHTML, ReactNode → rendered as JSX
|
|
152
|
+
timer?: number; // auto-close in ms (default: 5000)
|
|
153
|
+
showCloseButton?: boolean; // default: true
|
|
154
|
+
clickToClose?: boolean; // default: true
|
|
155
|
+
width?: string | number;
|
|
156
|
+
fullWidth?: boolean;
|
|
157
|
+
padding?: string | number;
|
|
158
|
+
customClass?: {
|
|
159
|
+
popup?: string;
|
|
160
|
+
header?: string;
|
|
161
|
+
title?: string;
|
|
162
|
+
icon?: string;
|
|
163
|
+
content?: string;
|
|
164
|
+
};
|
|
165
|
+
},
|
|
166
|
+
options?: NotificationOptions // position, autoCloseTime, showCloseIcon, etc.
|
|
167
|
+
);
|
|
134
168
|
```
|
|
135
169
|
|
|
136
|
-
|
|
170
|
+
### Other methods
|
|
137
171
|
|
|
138
|
-
|
|
172
|
+
```tsx
|
|
173
|
+
aark.close(); // close the current modal / notification
|
|
174
|
+
aark.closeAll(); // close everything
|
|
175
|
+
aark.isOpen(); // returns boolean
|
|
139
176
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
| `escapeKeyToClose` | `boolean` | `true` | Close on ESC key |
|
|
146
|
-
| `onOpen` | `() => void` | - | Called when modal opens |
|
|
147
|
-
| `onClose` | `() => void` | - | Called when modal closes |
|
|
177
|
+
// Theme shortcuts (same as the standalone imported functions)
|
|
178
|
+
aark.setTheme(theme); // same as setAarkModalTheme(theme)
|
|
179
|
+
aark.resetTheme(); // same as resetAarkModalTheme()
|
|
180
|
+
aark.getTheme(); // same as getAarkModalTheme()
|
|
181
|
+
```
|
|
148
182
|
|
|
149
|
-
|
|
183
|
+
---
|
|
150
184
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
|
156
|
-
|
|
|
157
|
-
| `position`
|
|
158
|
-
| `
|
|
185
|
+
## Configuration Options
|
|
186
|
+
|
|
187
|
+
### `ModalOptions`
|
|
188
|
+
|
|
189
|
+
| Option | Type | Default | Description |
|
|
190
|
+
| --------------------- | ---------------- | ---------- | ---------------------------------------- |
|
|
191
|
+
| `position` | `ModalPosition` | `"center"` | Where the modal appears |
|
|
192
|
+
| `size` | `ModalSize` | — | Preset max-width (`sm/md/lg/xl/full`) |
|
|
193
|
+
| `width` | `string\|number` | — | Explicit width, overrides `size` |
|
|
194
|
+
| `maxWidth` | `string\|number` | — | Explicit max-width, overrides `size` |
|
|
195
|
+
| `showCloseIcon` | `boolean` | `true` | Render the × close button |
|
|
196
|
+
| `className` | `string` | — | Extra class on the modal container |
|
|
197
|
+
| `overlayClassName` | `string` | — | Extra class on the backdrop |
|
|
198
|
+
| `preventOverlayClose` | `boolean` | `false` | Disable close on backdrop click |
|
|
199
|
+
| `preventEscClose` | `boolean` | `false` | Disable close on ESC key |
|
|
200
|
+
|
|
201
|
+
### `NotificationOptions`
|
|
202
|
+
|
|
203
|
+
| Option | Type | Default | Description |
|
|
204
|
+
| ----------------- | ---------------------- | ------------- | ------------------------------------ |
|
|
205
|
+
| `position` | `NotificationPosition` | `"top-right"` | Where the notification appears |
|
|
206
|
+
| `autoCloseTime` | `number` | `5000` | Auto-dismiss delay in ms |
|
|
207
|
+
| `showCloseIcon` | `boolean` | `true` | Render the × close button |
|
|
208
|
+
| `className` | `string` | — | Extra class on the notification |
|
|
209
|
+
| `preventEscClose` | `boolean` | `false` | Disable dismiss on ESC key |
|
|
210
|
+
|
|
211
|
+
### Size presets (`ModalSize`)
|
|
212
|
+
|
|
213
|
+
| Value | Max-width |
|
|
214
|
+
| ------ | ---------------- |
|
|
215
|
+
| `sm` | 400 px |
|
|
216
|
+
| `md` | 550 px |
|
|
217
|
+
| `lg` | 700 px (default) |
|
|
218
|
+
| `xl` | 900 px |
|
|
219
|
+
| `full` | 100 vw − 32 px |
|
|
220
|
+
|
|
221
|
+
```tsx
|
|
222
|
+
// Use a preset
|
|
223
|
+
aark.fire(<Content />, { size: "xl" });
|
|
224
|
+
|
|
225
|
+
// Or set exact dimensions
|
|
226
|
+
aark.fire(<Content />, { width: "80%", maxWidth: "900px" });
|
|
227
|
+
```
|
|
159
228
|
|
|
160
|
-
### Position
|
|
229
|
+
### Position types
|
|
161
230
|
|
|
162
|
-
```
|
|
231
|
+
```ts
|
|
163
232
|
type ModalPosition =
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
| "bottom-left"
|
|
170
|
-
| "bottom-right";
|
|
233
|
+
| "center"
|
|
234
|
+
| "top-center"
|
|
235
|
+
| "top-right"
|
|
236
|
+
| "bottom-center"
|
|
237
|
+
| "bottom-right";
|
|
171
238
|
|
|
172
239
|
type NotificationPosition =
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
240
|
+
| "top-left"
|
|
241
|
+
| "top-center"
|
|
242
|
+
| "top-right"
|
|
243
|
+
| "bottom-left"
|
|
244
|
+
| "bottom-center"
|
|
245
|
+
| "bottom-right";
|
|
179
246
|
```
|
|
180
247
|
|
|
181
|
-
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Customization
|
|
182
251
|
|
|
183
|
-
### CSS
|
|
252
|
+
### CSS variables (full list with defaults)
|
|
253
|
+
|
|
254
|
+
Override any of these in your global CSS to theme the library without touching JS:
|
|
184
255
|
|
|
185
256
|
```css
|
|
186
257
|
:root {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
258
|
+
/* Overlay */
|
|
259
|
+
--aark-modal-overlay-bg: rgba(0, 0, 0, 0.5);
|
|
260
|
+
--aark-modal-overlay-blur: 0px;
|
|
261
|
+
|
|
262
|
+
/* Modal */
|
|
263
|
+
--aark-modal-bg: #fff;
|
|
264
|
+
--aark-modal-radius: 8px;
|
|
265
|
+
--aark-modal-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
|
|
266
|
+
--aark-modal-pad: 16px;
|
|
267
|
+
--aark-modal-max-width: 700px;
|
|
268
|
+
--aark-modal-z: 9999;
|
|
269
|
+
|
|
270
|
+
/* Close button */
|
|
271
|
+
--aark-close-color: #666;
|
|
272
|
+
--aark-close-hover: #f5f5f5;
|
|
273
|
+
--aark-close-hover-color: #333;
|
|
274
|
+
--aark-close-focus-outline: 2px solid #007bff;
|
|
275
|
+
|
|
276
|
+
/* Notification */
|
|
277
|
+
--aark-notification-bg: #fff;
|
|
278
|
+
--aark-notification-radius: 8px;
|
|
279
|
+
--aark-notification-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
280
|
+
--aark-notification-pad: 16px;
|
|
281
|
+
--aark-notification-z: 10000;
|
|
282
|
+
|
|
283
|
+
/* Animation */
|
|
284
|
+
--aark-anim: 0.2s;
|
|
201
285
|
}
|
|
202
286
|
```
|
|
203
287
|
|
|
204
|
-
###
|
|
288
|
+
### `setAarkModalTheme(theme)` — apply theme via JS
|
|
289
|
+
|
|
290
|
+
All properties are optional. Only the ones you pass are changed.
|
|
291
|
+
|
|
292
|
+
```tsx
|
|
293
|
+
import { setAarkModalTheme } from "aark-react-modalify";
|
|
294
|
+
// or: aark.setTheme({ ... })
|
|
295
|
+
|
|
296
|
+
setAarkModalTheme({
|
|
297
|
+
// Overlay
|
|
298
|
+
overlayBackground: "rgba(0, 0, 0, 0.7)",
|
|
299
|
+
overlayBlur: "4px",
|
|
300
|
+
|
|
301
|
+
// Modal
|
|
302
|
+
modalBackground: "#1f2937",
|
|
303
|
+
modalBorderRadius: "12px",
|
|
304
|
+
modalShadow: "0 20px 60px rgba(0, 0, 0, 0.4)",
|
|
305
|
+
modalPadding: "24px",
|
|
306
|
+
modalMaxWidth: "600px",
|
|
307
|
+
modalZIndex: 9999,
|
|
308
|
+
|
|
309
|
+
// Close button
|
|
310
|
+
closeButtonColor: "#9ca3af",
|
|
311
|
+
closeButtonHoverBackground: "rgba(255,255,255,0.1)",
|
|
312
|
+
closeButtonHoverColor: "#fff",
|
|
313
|
+
|
|
314
|
+
// Notification
|
|
315
|
+
notificationBackground: "#111827",
|
|
316
|
+
notificationBorderRadius: "8px",
|
|
317
|
+
notificationShadow: "0 4px 20px rgba(0,0,0,0.3)",
|
|
318
|
+
notificationPadding: "12px 16px",
|
|
319
|
+
notificationZIndex: 10000,
|
|
320
|
+
|
|
321
|
+
// Animation
|
|
322
|
+
animationDuration: "0.3s",
|
|
323
|
+
});
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### `resetAarkModalTheme()` — restore defaults
|
|
327
|
+
|
|
328
|
+
```tsx
|
|
329
|
+
import { resetAarkModalTheme } from "aark-react-modalify";
|
|
330
|
+
// or: aark.resetTheme()
|
|
331
|
+
|
|
332
|
+
resetAarkModalTheme();
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### `getAarkModalTheme()` — read current values
|
|
205
336
|
|
|
206
|
-
|
|
337
|
+
```tsx
|
|
338
|
+
import { getAarkModalTheme } from "aark-react-modalify";
|
|
339
|
+
// or: aark.getTheme()
|
|
207
340
|
|
|
208
|
-
|
|
341
|
+
const theme = getAarkModalTheme();
|
|
342
|
+
console.log(theme.modalBackground); // e.g. "#fff"
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
---
|
|
346
|
+
|
|
347
|
+
## CSS Import Options
|
|
348
|
+
|
|
349
|
+
**Option 1 — Automatic (default)**
|
|
350
|
+
|
|
351
|
+
```tsx
|
|
209
352
|
import { aark } from "aark-react-modalify";
|
|
210
|
-
// CSS is
|
|
353
|
+
// CSS is bundled and injected automatically
|
|
211
354
|
```
|
|
212
355
|
|
|
213
|
-
**Option 2
|
|
356
|
+
**Option 2 — Manual (no-styles build)**
|
|
357
|
+
|
|
358
|
+
Useful if you want full control over when/how the CSS is loaded:
|
|
214
359
|
|
|
215
|
-
```
|
|
360
|
+
```tsx
|
|
216
361
|
import { aark } from "aark-react-modalify/no-styles";
|
|
217
362
|
import "aark-react-modalify/css";
|
|
363
|
+
// or: import "aark-react-modalify/dist/aark-react-modalify.css";
|
|
218
364
|
```
|
|
219
365
|
|
|
220
|
-
|
|
366
|
+
---
|
|
367
|
+
|
|
368
|
+
## Advanced Usage
|
|
369
|
+
|
|
370
|
+
### `useModal` hook
|
|
221
371
|
|
|
222
|
-
|
|
372
|
+
Subscribe to modal state changes anywhere in your component tree:
|
|
223
373
|
|
|
224
|
-
```
|
|
225
|
-
import { useModal } from "aark-react-modalify";
|
|
374
|
+
```tsx
|
|
375
|
+
import { aark, useModal } from "aark-react-modalify";
|
|
226
376
|
|
|
227
377
|
function MyComponent() {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
);
|
|
378
|
+
const { isOpen, config } = useModal();
|
|
379
|
+
// config.mode === "modal" | "notification"
|
|
380
|
+
|
|
381
|
+
return (
|
|
382
|
+
<div>
|
|
383
|
+
<button onClick={() => aark.fire(<div>Content</div>, { position: "center" })}>
|
|
384
|
+
Open
|
|
385
|
+
</button>
|
|
386
|
+
{isOpen && <p>A {config?.mode} is currently open</p>}
|
|
387
|
+
</div>
|
|
388
|
+
);
|
|
240
389
|
}
|
|
241
390
|
```
|
|
242
391
|
|
|
243
|
-
|
|
392
|
+
`useModal` returns:
|
|
244
393
|
|
|
245
|
-
|
|
246
|
-
|
|
394
|
+
| Property | Type | Description |
|
|
395
|
+
|----------|------|-------------|
|
|
396
|
+
| `isOpen` | `boolean` | Whether a modal/notification is currently showing |
|
|
397
|
+
| `config` | `ComponentConfig \| null` | Current config object including `mode`, `content`, `props`, `options` |
|
|
398
|
+
| `close` | `() => void` | Close the current modal/notification |
|
|
247
399
|
|
|
248
|
-
|
|
249
|
-
setAarkModalTheme({
|
|
250
|
-
modalBg: "#1f2937",
|
|
251
|
-
modalRadius: "12px",
|
|
252
|
-
animationDuration: "0.3s",
|
|
253
|
-
});
|
|
400
|
+
### Manual component integration
|
|
254
401
|
|
|
255
|
-
|
|
256
|
-
|
|
402
|
+
If you need to manage rendering yourself:
|
|
403
|
+
|
|
404
|
+
```tsx
|
|
405
|
+
import { Modal, Notification, ModalProvider } from "aark-react-modalify";
|
|
257
406
|
```
|
|
258
407
|
|
|
259
|
-
|
|
408
|
+
---
|
|
409
|
+
|
|
410
|
+
## Examples
|
|
260
411
|
|
|
261
|
-
### Success
|
|
412
|
+
### Success modal
|
|
262
413
|
|
|
263
|
-
```
|
|
414
|
+
```tsx
|
|
264
415
|
aark.fire({
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
416
|
+
title: "Saved!",
|
|
417
|
+
text: "Your changes have been saved successfully.",
|
|
418
|
+
type: "success",
|
|
419
|
+
confirmText: "Great!",
|
|
269
420
|
});
|
|
270
421
|
```
|
|
271
422
|
|
|
272
|
-
### Confirmation
|
|
423
|
+
### Confirmation dialog
|
|
273
424
|
|
|
274
|
-
```
|
|
425
|
+
```tsx
|
|
275
426
|
aark.fire({
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
427
|
+
title: "Delete Item",
|
|
428
|
+
text: "This action cannot be undone.",
|
|
429
|
+
type: "warning",
|
|
430
|
+
showCancelButton: true,
|
|
431
|
+
confirmText: "Yes, delete it!",
|
|
432
|
+
cancelText: "Cancel",
|
|
433
|
+
onConfirm: () => console.log("deleted"),
|
|
283
434
|
});
|
|
284
435
|
```
|
|
285
436
|
|
|
286
|
-
###
|
|
437
|
+
### Notification with position
|
|
287
438
|
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
439
|
+
```tsx
|
|
440
|
+
// position goes in options (second argument), not inside the props
|
|
441
|
+
aark.notification(
|
|
442
|
+
{ title: "Error", text: "Something went wrong.", type: "error", timer: 4000 },
|
|
443
|
+
{ position: "top-right" }
|
|
444
|
+
);
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
### Component-based notification
|
|
448
|
+
|
|
449
|
+
```tsx
|
|
450
|
+
aark.notification(
|
|
451
|
+
<div style={{ padding: "1rem" }}>Custom toast content</div>,
|
|
452
|
+
{ position: "bottom-right", autoCloseTime: 3000 }
|
|
453
|
+
);
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
### Large custom modal
|
|
457
|
+
|
|
458
|
+
```tsx
|
|
459
|
+
aark.fire(<Dashboard />, {
|
|
460
|
+
size: "xl",
|
|
461
|
+
showCloseIcon: true,
|
|
462
|
+
preventOverlayClose: true,
|
|
463
|
+
});
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
### Modal with exact dimensions
|
|
467
|
+
|
|
468
|
+
```tsx
|
|
469
|
+
aark.fire(<MyForm />, {
|
|
470
|
+
width: "600px",
|
|
471
|
+
maxWidth: "90vw",
|
|
472
|
+
position: "top-center",
|
|
294
473
|
});
|
|
295
474
|
```
|
|
296
475
|
|
|
297
|
-
|
|
476
|
+
### Dark theme
|
|
298
477
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
- ✅ **Next.js** - Works with both App and Pages router
|
|
302
|
-
- ✅ **Webpack** - CSS automatically bundled
|
|
303
|
-
- ✅ **Parcel** - Styles processed automatically
|
|
478
|
+
```tsx
|
|
479
|
+
import { setAarkModalTheme } from "aark-react-modalify";
|
|
304
480
|
|
|
305
|
-
|
|
481
|
+
setAarkModalTheme({
|
|
482
|
+
modalBackground: "#1f2937",
|
|
483
|
+
modalBorderRadius: "12px",
|
|
484
|
+
overlayBackground: "rgba(0, 0, 0, 0.8)",
|
|
485
|
+
overlayBlur: "4px",
|
|
486
|
+
notificationBackground: "#111827",
|
|
487
|
+
animationDuration: "0.3s",
|
|
488
|
+
});
|
|
489
|
+
```
|
|
306
490
|
|
|
307
|
-
|
|
308
|
-
- **CSS**: ~9 kB (minified)
|
|
309
|
-
- **Total**: ~25 kB
|
|
310
|
-
- **Gzipped**: ~8 kB (estimated)
|
|
491
|
+
---
|
|
311
492
|
|
|
312
|
-
##
|
|
493
|
+
## Framework Compatibility
|
|
313
494
|
|
|
314
|
-
|
|
|
315
|
-
|
|
|
316
|
-
|
|
|
317
|
-
|
|
|
318
|
-
|
|
|
319
|
-
|
|
|
495
|
+
| Framework | Support |
|
|
496
|
+
| ---------------------------- | ------- |
|
|
497
|
+
| Vite | ✅ |
|
|
498
|
+
| Next.js (App + Pages router) | ✅ |
|
|
499
|
+
| Create React App | ✅ |
|
|
500
|
+
| Webpack | ✅ |
|
|
501
|
+
| Parcel | ✅ |
|
|
320
502
|
|
|
321
|
-
|
|
503
|
+
---
|
|
504
|
+
|
|
505
|
+
## Bundle Size
|
|
322
506
|
|
|
323
|
-
|
|
507
|
+
| Asset | Size (minified) |
|
|
508
|
+
| ---------- | --------------- |
|
|
509
|
+
| JavaScript | ~16 kB |
|
|
510
|
+
| CSS | ~5 kB |
|
|
511
|
+
| **Total** | **~21 kB** |
|
|
512
|
+
| Gzipped | ~7 kB (est.) |
|
|
513
|
+
|
|
514
|
+
---
|
|
324
515
|
|
|
325
|
-
##
|
|
516
|
+
## License
|
|
326
517
|
|
|
327
|
-
|
|
518
|
+
MIT — see [LICENSE](LICENSE) for details.
|
|
328
519
|
|
|
329
520
|
---
|
|
330
521
|
|