react-confirm-lite 1.3.0 → 1.4.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/README.md CHANGED
@@ -27,14 +27,23 @@ pnpm add react-confirm-lite
27
27
 
28
28
  ## 🚀 Quick Start
29
29
 
30
- ### 1. Add the Container Component
30
+ ### Complete Example
31
31
 
32
- Place `<ConfirmContainer />` in your app (usually in root layout):
32
+ Place `<ConfirmContainer />` in your app (usually in root layout) and use it with `confirm`
33
33
 
34
34
  ```tsx
35
- import { ConfirmContainer } from 'react-confirm-lite';
35
+ import { ConfirmContainer, confirm } from 'react-confirm-lite';
36
36
 
37
37
  function App() {
38
+ async function handleAction() {
39
+ const result = await confirm('Are you sure?');
40
+
41
+ if (result) {
42
+ console.log('User confirmed!');
43
+ } else {
44
+ console.log('User cancelled!');
45
+ }
46
+ }
38
47
  return (
39
48
  <div>
40
49
  {/* Your app content */}
@@ -44,23 +53,17 @@ function App() {
44
53
  }
45
54
  ```
46
55
 
47
- ### 2. Use the Confirm Function
48
-
49
- Import and use `confirm()` anywhere in your app:
50
-
51
- ```tsx
52
- import { confirm } from 'react-confirm-lite';
56
+ ### Important
57
+ By default it shows the closest container to button to which you clicked to show the confirmation dialog but you are a programmer and you will try thing and sometimes you may use it in useEffect hook then in this case it will show the first rendered confirm container.
53
58
 
54
- async function handleAction() {
55
- const result = await confirm('Are you sure?');
56
-
57
- if (result) {
58
- console.log('User confirmed!');
59
- } else {
60
- console.log('User cancelled!');
61
- }
62
- }
59
+ If you want to show a specific container by confirm api no matters where it is then you can pass the id like this
60
+ ```jsx
61
+ // In confirm Api
62
+ confirm({id:'1' , message:'Are you sure?'})
63
+ // And in confirm Container
64
+ <ConfirmContainer id='1'/>
63
65
  ```
66
+ And make sure that not to pass same id to different `<ConfirmContainer />` In this way It will show both of these containers
64
67
 
65
68
  ## 🎯 Features
66
69
 
@@ -163,6 +166,7 @@ const result = await confirm({
163
166
 
164
167
  | Prop | Type | Default | Description |
165
168
  |------|------|---------|-------------|
169
+ |`id`|`string`| `random` | To show a specific container with a specific confirm() app |
166
170
  | `animation` | `AnimationType` | `'slide'` | Animation type (18 options) |
167
171
  | `animationDuration` | `number` | `300` | Base animation duration (ms) |
168
172
  | `animationDurationIn` | `number` | - | Enter animation duration |
@@ -383,6 +387,10 @@ const handleFlexibleDialog = async () => {
383
387
 
384
388
  ## 🚨 Troubleshooting
385
389
 
390
+ ### Multiple dialogs are showing?
391
+ - Make sure you are on version `>=1.4`
392
+ - Make sure you didn't pass same id to different `<ConfirmContainer />`
393
+
386
394
  ### Dialog not showing?
387
395
  - Make sure `<ConfirmContainer />` is mounted
388
396
  - Check it's not conditionally rendered
@@ -408,6 +416,9 @@ const handleFlexibleDialog = async () => {
408
416
  - Use `classes` prop to override styles
409
417
  - Check CSS specificity
410
418
 
419
+ You can also use it in TanStack with react easily
420
+
421
+
411
422
  ## 📱 Next.js Support
412
423
 
413
424
  ### App Router (Next.js 15+)
@@ -475,6 +486,207 @@ if (result === true) {
475
486
  - Zero configuration
476
487
  - Three return states (true/false/null)
477
488
 
489
+ # Contributing to react-confirm-lite
490
+
491
+ Thanks for your interest in contributing. This project is intentionally lightweight, so the contribution workflow is kept simple and explicit. Please read this fully before starting.
492
+
493
+ ---
494
+
495
+ ## 📦 Project Structure
496
+
497
+ ```
498
+ react-confirm-lite/
499
+ ├─ src/ # Library source code
500
+ ├─ dist/ # Built output (generated)
501
+ ├─ example/ # Local playground app (Vite + React)
502
+ ├─ CONTRIBUTING.md
503
+ ├─ README.md
504
+ ├─ package.json
505
+ ├─ tsup.config.ts
506
+ ```
507
+
508
+ * **src/** → where you make changes
509
+ * **dist/** → auto-generated by tsup (do not edit manually)
510
+ * **example/** → used to test changes locally
511
+
512
+ ---
513
+
514
+ ## 🧰 Prerequisites
515
+
516
+ * Node.js >= 18
517
+ * npm >= 9
518
+ * Basic familiarity with React + TypeScript
519
+
520
+ ---
521
+
522
+ ## 🚀 Local Development Setup
523
+
524
+ ### 1. Clone the repository
525
+
526
+ ```bash
527
+ git clone https://github.com/SaadNasir-git/react-confirm-lite.git
528
+ cd react-confirm-lite
529
+ ```
530
+
531
+ ### 2. Install dependencies (root)
532
+
533
+ ```bash
534
+ npm install
535
+ ```
536
+
537
+ ---
538
+
539
+ ## 🔁 Development Workflow (IMPORTANT)
540
+
541
+ This project uses **tsup watch mode** for live rebuilding.
542
+
543
+ ### Terminal 1 — Run library in watch mode
544
+
545
+ From the project root:
546
+
547
+ ```bash
548
+ npm run build:watch
549
+ ```
550
+
551
+ This will:
552
+
553
+ * Watch `src/` for changes
554
+ * Automatically rebuild `dist/`
555
+ * Re-run post-build steps when files change
556
+
557
+ ⚠️ Leave this terminal running.
558
+
559
+ ---
560
+
561
+ ### Terminal 2 — Run example app
562
+
563
+ ```bash
564
+ cd example
565
+ npm install
566
+ npm run dev
567
+ ```
568
+
569
+ Open the provided local URL in your browser.
570
+
571
+ ---
572
+
573
+ ## 🧪 How to Test Your Changes
574
+
575
+ 1. Modify files inside `src/`
576
+ 2. tsup automatically rebuilds the library
577
+ 3. Refresh the browser running the example app
578
+ 4. Verify behavior visually and via console logs
579
+
580
+ You **do not** need to:
581
+
582
+ * run `npm pack`
583
+ * reinstall the package
584
+ * publish to npm
585
+
586
+ This setup mirrors real-world library development.
587
+
588
+ ---
589
+
590
+ ## 🧠 What to Change (and What Not to)
591
+
592
+ ### ✅ You can change
593
+
594
+ * Logic in `src/`
595
+ * Types in `types.ts`
596
+ * Styles / animations
597
+ * README documentation
598
+
599
+ ### ❌ Do not change
600
+
601
+ * `dist/` files manually
602
+ * Version number (maintainer handles releases)
603
+ * Build configuration unless discussed
604
+
605
+ ---
606
+
607
+ ## 🧹 Code Style
608
+
609
+ * Use TypeScript types explicitly
610
+ * Avoid unnecessary abstractions
611
+ * Prefer clarity over cleverness
612
+ * Keep bundle size in mind
613
+
614
+ ---
615
+
616
+ ## 🐞 Reporting Bugs
617
+
618
+ When opening an issue, include:
619
+
620
+ * What you expected
621
+ * What actually happened
622
+ * Steps to reproduce
623
+ * Browser and React version
624
+
625
+ ---
626
+
627
+ ## 💡 Feature Requests
628
+
629
+ Feature requests are welcome, but keep in mind:
630
+
631
+ * This library aims to stay minimal
632
+ * Features should not add heavy dependencies
633
+ * API simplicity is a priority
634
+
635
+ ---
636
+
637
+ ## 🛠 Development & Contributing
638
+
639
+ If you want to contribute or modify the library locally, use the built-in example app and watch mode.
640
+
641
+ ### Local Development Setup
642
+
643
+ ```bash
644
+ git clone https://github.com/SaadNasir-git/react-confirm-lite.git
645
+ cd react-confirm-lite
646
+ npm install
647
+ ```
648
+
649
+ ### Run Library in Watch Mode
650
+
651
+ In the project root:
652
+
653
+ ```bash
654
+ npm run build:watch
655
+ ```
656
+
657
+ This watches the `src/` directory and automatically rebuilds `dist/` on every change.
658
+
659
+ ### Run Example App
660
+
661
+ In a second terminal:
662
+
663
+ ```bash
664
+ cd example
665
+ npm install
666
+ npm run dev
667
+ ```
668
+
669
+ Open the local URL shown by Vite. Any change you make in `src/` will be reflected after a browser refresh.
670
+
671
+ ### Notes
672
+
673
+ * Do **not** edit files inside `dist/` manually
674
+ * You do **not** need to run `npm pack` or reinstall the package
675
+ * Versioning and releases are handled by the maintainer
676
+
677
+ For more details, see **CONTRIBUTING.md**.
678
+
679
+ ---
680
+
681
+ ## 📄 License
682
+
683
+ By contributing, you agree that your contributions will be licensed under the MIT License.
684
+
685
+ ---
686
+
687
+ Thanks for contributing to **react-confirm-lite** 🙌
688
+
689
+
478
690
  ## 📄 License
479
691
 
480
692
  MIT License - free for personal and commercial use.
package/dist/index.d.ts CHANGED
@@ -12,7 +12,8 @@ type ConfirmClasses = {
12
12
  cancel?: string;
13
13
  ok?: string;
14
14
  };
15
- type ConfirmInput = string | {
15
+ type ConfirmInput = {
16
+ id?: string;
16
17
  title?: string;
17
18
  message: string;
18
19
  colorSchema?: ColorSchema;
@@ -20,6 +21,7 @@ type ConfirmInput = string | {
20
21
  cancelText?: string;
21
22
  };
22
23
  type ConfirmOptions = {
24
+ id: string;
23
25
  title: string;
24
26
  message: string;
25
27
  resolve: (value: boolean | null) => void;
@@ -70,9 +72,10 @@ type Props = {
70
72
  animationClass: string;
71
73
  animationStyle: CSSProperties;
72
74
  }) => ReactNode;
75
+ id?: string;
73
76
  };
74
- declare const ConfirmContainer: ({ classes, animationDuration, defaultColorSchema, closeOnEscape, closeOnClickOutside, animation, animationDurationIn, animationDurationOut, children }: Props) => string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
77
+ declare const ConfirmContainer: ({ classes, animationDuration, defaultColorSchema, closeOnEscape, closeOnClickOutside, animation, animationDurationIn, animationDurationOut, children, id }: Props) => react_jsx_runtime.JSX.Element;
75
78
 
76
- declare function confirm(input: ConfirmInput): Promise<boolean | null>;
79
+ declare function confirm(input: string | ConfirmInput): Promise<boolean | null>;
77
80
 
78
81
  export { type AnimationType, type ColorSchema, type ConfirmClasses, ConfirmContainer, type ConfirmInput, type ConfirmOptions, type animationPairs, confirm };
package/dist/index.js CHANGED
@@ -1,17 +1,31 @@
1
1
  'use client';
2
2
  import { useState, useRef, useEffect, useCallback } from 'react';
3
- import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
 
5
5
  // src/confirm_store.ts
6
+ var containerId = "";
6
7
  var confirms = [];
7
8
  var listeners = /* @__PURE__ */ new Set();
8
- function addAlert(input) {
9
+ var isActiveContainer = false;
10
+ var containers = [];
11
+ var activeContainerId = null;
12
+ function setIsContainerActive(value) {
13
+ isActiveContainer = value;
14
+ }
15
+ function getIsContainerActive() {
16
+ return isActiveContainer;
17
+ }
18
+ function setActiveContainer(id) {
19
+ activeContainerId = id;
20
+ }
21
+ function getActiveContainerId() {
22
+ return activeContainerId;
23
+ }
24
+ async function addAlert(input) {
9
25
  return new Promise((resolve) => {
10
- const alert = typeof input === "string" ? {
11
- title: "Confirm",
12
- message: input,
13
- resolve
14
- } : {
26
+ const alert = {
27
+ id: input.id || "",
28
+ // Keep the ID for container targeting
15
29
  title: input.title || "Confirm",
16
30
  message: input.message,
17
31
  okText: input.okText,
@@ -20,16 +34,25 @@ function addAlert(input) {
20
34
  resolve
21
35
  };
22
36
  confirms = [...confirms, alert];
37
+ if (input.id) {
38
+ setActiveContainer(input.id);
39
+ } else {
40
+ setActiveContainer(null);
41
+ }
23
42
  if (confirms.length === 1) {
24
43
  emit();
25
44
  }
26
45
  });
27
46
  }
28
- function closeAlert(result) {
47
+ async function closeAlert(result) {
29
48
  const alert = confirms[0];
49
+ containerId = "";
30
50
  if (!alert) return;
31
51
  alert.resolve(result);
32
52
  confirms = confirms.slice(1);
53
+ if (confirms.length === 0) {
54
+ setActiveContainer(null);
55
+ }
33
56
  emit();
34
57
  }
35
58
  function subscribe(listener) {
@@ -40,9 +63,43 @@ function subscribe(listener) {
40
63
  function emit() {
41
64
  listeners.forEach((listener) => listener(confirms));
42
65
  }
66
+ var EventListener = (e) => {
67
+ if (containers.length === 0) {
68
+ containers.push(document.querySelectorAll(".null-confirm-container"));
69
+ }
70
+ if (containers.length === 0) return;
71
+ let parentElement = e.view?.document.activeElement?.parentElement;
72
+ let container = parentElement?.querySelector(".null-confirm-container");
73
+ while (true) {
74
+ if (container?.id) {
75
+ break;
76
+ }
77
+ parentElement = parentElement?.parentElement;
78
+ container = parentElement?.querySelector(".null-confirm-container");
79
+ }
80
+ if (container?.id) {
81
+ containerId = container.id;
82
+ }
83
+ };
84
+ async function getElement() {
85
+ document.addEventListener("click", EventListener, { once: true });
86
+ await new Promise((resolve) => {
87
+ setTimeout(() => {
88
+ document.removeEventListener("click", EventListener);
89
+ resolve();
90
+ }, 0);
91
+ });
92
+ if (containerId === "") {
93
+ if (containers.length === 0) {
94
+ containers.push(document.querySelectorAll(".null-confirm-container"));
95
+ }
96
+ return containers[0][0].id;
97
+ }
98
+ return containerId;
99
+ }
43
100
 
44
101
  // src/confirm.css
45
- var confirm_default = "/* confirm.css */\n.alert-overlay {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 9999;\n display: flex;\n align-items: center;\n justify-content: center;\n backdrop-filter: blur(4px);\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',\n 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n animation: overlayFadeIn 0.3s ease-out forwards;\n}\n\n.alert-overlay-exit {\n animation: overlayFadeOut 0.3s ease-in forwards;\n}\n\n.alert-wrapper {\n width: 90%;\n max-width: 400px;\n border-radius: 12px;\n padding: 24px;\n box-shadow: \n 0 20px 25px -5px rgba(0, 0, 0, 0.1),\n 0 10px 10px -5px rgba(0, 0, 0, 0.04),\n 0 0 0 1px rgba(0, 0, 0, 0.05);\n animation: modalSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n transform: translateY(20px) scale(0.98);\n}\n\n.alert-wrapper-exit {\n animation: modalSlideDown 0.3s ease-in forwards;\n}\n\n.alert-title {\n font-size: 18px;\n font-weight: 600;\n line-height: 1.4;\n margin: 0 0 12px 0;\n}\n\n.alert-message {\n font-size: 14px;\n line-height: 1.5;\n margin: 0 0 24px 0;\n}\n\n.alert-buttons {\n display: flex;\n justify-content: flex-end;\n gap: 12px;\n margin-top: 8px;\n}\n\n.alert-button {\n padding: 10px 20px;\n border-radius: 8px;\n font-size: 14px;\n font-weight: 500;\n border: none;\n cursor: pointer;\n font-family: inherit;\n transition: all 0.2s ease;\n min-width: 80px;\n text-align: center;\n}\n\n.alert-button:focus {\n outline-offset: 2px;\n}\n\n.alert-button:active {\n transform: translateY(1px);\n}\n\n/* Default animations */\n.alert-wrapper-exit {\n animation: modalSlideDown 0.3s ease-in forwards;\n}\n\n/* Entrance Animation Classes */\n.alert-animate-fadeInScale {\n animation: fadeInScale 0.4s ease-out forwards;\n}\n\n.alert-animate-bounceIn {\n animation: bounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;\n}\n\n.alert-animate-flipIn {\n animation: flipIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;\n}\n\n.alert-animate-zoomIn {\n animation: zoomIn 0.3s ease-out forwards;\n}\n\n.alert-animate-rotateIn {\n animation: rotateIn 0.5s ease-out forwards;\n}\n\n.alert-animate-fadeInUp {\n animation: fadeInUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n}\n\n.alert-animate-dropIn {\n animation: dropIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;\n}\n\n.alert-animate-slideInRight {\n animation: slideInRight 0.4s ease-out forwards;\n}\n\n.alert-animate-slideInLeft {\n animation: slideInLeft 0.4s ease-out forwards;\n}\n\n.alert-animate-fadeInDown {\n animation: fadeInDown 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n}\n\n.alert-animate-slideDownIn {\n animation: slideDownIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n}\n\n.alert-animate-rotateInRight {\n animation: rotateInRight 0.5s ease-out forwards;\n}\n\n.alert-animate-zoomInSmall {\n animation: zoomInSmall 0.3s ease-out forwards;\n}\n\n.alert-animate-bounceInSmall {\n animation: bounceInSmall 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;\n}\n\n.alert-animate-fadeInBlur {\n animation: fadeInBlur 0.4s ease-out forwards;\n}\n\n.alert-animate-fadeInShrink {\n animation: fadeInShrink 0.3s ease-out forwards;\n}\n\n/* Exit Animation Classes */\n.alert-animate-fadeOutScale {\n animation: fadeOutScale 0.3s ease-in forwards;\n}\n\n.alert-animate-bounceOut {\n animation: bounceOut 0.4s ease-in forwards;\n}\n\n.alert-animate-zoomOut {\n animation: zoomOut 0.3s ease-in forwards;\n}\n\n.alert-animate-rotateOut {\n animation: rotateOut 0.3s ease-in forwards;\n}\n\n.alert-animate-fadeOutDown {\n animation: fadeOutDown 0.3s ease-in forwards;\n}\n\n.alert-animate-slideOutRight {\n animation: slideOutRight 0.3s ease-in forwards;\n}\n\n.alert-animate-slideOutLeft {\n animation: slideOutLeft 0.3s ease-in forwards;\n}\n\n.alert-animate-flipOut {\n animation: flipOut 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;\n}\n\n.alert-animate-dropOut {\n animation: dropOut 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;\n}\n\n.alert-animate-fadeOutUp {\n animation: fadeOutUp 0.3s ease-in forwards;\n}\n\n.alert-animate-slideUpOut {\n animation: slideUpOut 0.3s ease-in forwards;\n}\n\n.alert-animate-rotateOutLeft {\n animation: rotateOutLeft 0.3s ease-in forwards;\n}\n\n.alert-animate-zoomOutSmall {\n animation: zoomOutSmall 0.3s ease-in forwards;\n}\n\n.alert-animate-bounceOutSmall {\n animation: bounceOutSmall 0.4s ease-in forwards;\n}\n\n.alert-animate-fadeOutBlur {\n animation: fadeOutBlur 0.4s ease-in forwards;\n}\n\n.alert-animate-fadeOutShrink {\n animation: fadeOutShrink 0.3s ease-in forwards;\n}\n\n.alert-wrapper {\n width: 90%;\n max-width: 400px;\n border-radius: 12px;\n padding: 24px;\n box-shadow: \n 0 20px 25px -5px rgba(0, 0, 0, 0.1),\n 0 10px 10px -5px rgba(0, 0, 0, 0.04),\n 0 0 0 1px rgba(0, 0, 0, 0.05);\n}";
102
+ var confirm_default = "/* confirm.css */\n.alert-overlay {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 9999;\n display: flex;\n align-items: center;\n justify-content: center;\n backdrop-filter: blur(4px);\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',\n 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n animation: overlayFadeIn 0.3s ease-out forwards;\n}\n\n.alert-overlay-exit {\n animation: overlayFadeOut 0.3s ease-in forwards;\n}\n\n.alert-wrapper {\n width: 90%;\n max-width: 400px;\n border-radius: 12px;\n padding: 24px;\n box-shadow: \n 0 20px 25px -5px rgba(0, 0, 0, 0.1),\n 0 10px 10px -5px rgba(0, 0, 0, 0.04),\n 0 0 0 1px rgba(0, 0, 0, 0.05);\n animation: modalSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n transform: translateY(20px) scale(0.98);\n}\n\n.alert-wrapper-exit {\n animation: modalSlideDown 0.3s ease-in forwards;\n}\n\n.alert-title {\n font-size: 18px;\n font-weight: 600;\n line-height: 1.4;\n margin: 0 0 12px 0;\n}\n\n.alert-message {\n font-size: 14px;\n line-height: 1.5;\n margin: 0 0 24px 0;\n}\n\n.alert-buttons {\n display: flex;\n justify-content: flex-end;\n gap: 12px;\n margin-top: 8px;\n}\n\n.alert-button {\n padding: 10px 20px;\n border-radius: 8px;\n font-size: 14px;\n font-weight: 500;\n border: none;\n cursor: pointer;\n font-family: inherit;\n transition: all 0.2s ease;\n min-width: 80px;\n text-align: center;\n}\n\n.alert-button:focus {\n outline-offset: 2px;\n}\n\n.alert-button:active {\n transform: translateY(1px);\n}\n\n/* Default animations */\n.alert-wrapper-exit {\n animation: modalSlideDown 0.3s ease-in forwards;\n}\n\n/* Entrance Animation Classes */\n.alert-animate-fadeInScale {\n animation: fadeInScale 0.4s ease-out forwards;\n}\n\n.alert-animate-bounceIn {\n animation: bounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;\n}\n\n.alert-animate-flipIn {\n animation: flipIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;\n}\n\n.alert-animate-zoomIn {\n animation: zoomIn 0.3s ease-out forwards;\n}\n\n.alert-animate-rotateIn {\n animation: rotateIn 0.5s ease-out forwards;\n}\n\n.alert-animate-fadeInUp {\n animation: fadeInUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n}\n\n.alert-animate-dropIn {\n animation: dropIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;\n}\n\n.alert-animate-slideInRight {\n animation: slideInRight 0.4s ease-out forwards;\n}\n\n.alert-animate-slideInLeft {\n animation: slideInLeft 0.4s ease-out forwards;\n}\n\n.alert-animate-fadeInDown {\n animation: fadeInDown 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n}\n\n.alert-animate-slideDownIn {\n animation: slideDownIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n}\n\n.alert-animate-rotateInRight {\n animation: rotateInRight 0.5s ease-out forwards;\n}\n\n.alert-animate-zoomInSmall {\n animation: zoomInSmall 0.3s ease-out forwards;\n}\n\n.alert-animate-bounceInSmall {\n animation: bounceInSmall 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;\n}\n\n.alert-animate-fadeInBlur {\n animation: fadeInBlur 0.4s ease-out forwards;\n}\n\n.alert-animate-fadeInShrink {\n animation: fadeInShrink 0.3s ease-out forwards;\n}\n\n/* Exit Animation Classes */\n.alert-animate-fadeOutScale {\n animation: fadeOutScale 0.3s ease-in forwards;\n}\n\n.alert-animate-bounceOut {\n animation: bounceOut 0.4s ease-in forwards;\n}\n\n.alert-animate-zoomOut {\n animation: zoomOut 0.3s ease-in forwards;\n}\n\n.alert-animate-rotateOut {\n animation: rotateOut 0.3s ease-in forwards;\n}\n\n.alert-animate-fadeOutDown {\n animation: fadeOutDown 0.3s ease-in forwards;\n}\n\n.alert-animate-slideOutRight {\n animation: slideOutRight 0.3s ease-in forwards;\n}\n\n.alert-animate-slideOutLeft {\n animation: slideOutLeft 0.3s ease-in forwards;\n}\n\n.alert-animate-flipOut {\n animation: flipOut 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;\n}\n\n.alert-animate-dropOut {\n animation: dropOut 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;\n}\n\n.alert-animate-fadeOutUp {\n animation: fadeOutUp 0.3s ease-in forwards;\n}\n\n.alert-animate-slideUpOut {\n animation: slideUpOut 0.3s ease-in forwards;\n}\n\n.alert-animate-rotateOutLeft {\n animation: rotateOutLeft 0.3s ease-in forwards;\n}\n\n.alert-animate-zoomOutSmall {\n animation: zoomOutSmall 0.3s ease-in forwards;\n}\n\n.alert-animate-bounceOutSmall {\n animation: bounceOutSmall 0.4s ease-in forwards;\n}\n\n.alert-animate-fadeOutBlur {\n animation: fadeOutBlur 0.4s ease-in forwards;\n}\n\n.alert-animate-fadeOutShrink {\n animation: fadeOutShrink 0.3s ease-in forwards;\n}\n\n.alert-wrapper {\n width: 90%;\n max-width: 400px;\n border-radius: 12px;\n padding: 24px;\n box-shadow: \n 0 20px 25px -5px rgba(0, 0, 0, 0.1),\n 0 10px 10px -5px rgba(0, 0, 0, 0.04),\n 0 0 0 1px rgba(0, 0, 0, 0.05);\n}\n\n.null-confirm-container{\n width: 0;\n height: 0;\n opacity: 0;\n}";
46
103
 
47
104
  // src/animations.css
48
105
  var animations_default = "/* animations.css - Complete Animation Keyframes */\n\n/* Overlay Animations */\n@keyframes overlayFadeIn {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}\n\n@keyframes overlayFadeOut {\n from {\n opacity: 1;\n }\n to {\n opacity: 0;\n }\n}\n\n/* Default Modal Animations */\n@keyframes modalSlideUp {\n from {\n opacity: 0;\n transform: translateY(20px) scale(0.98);\n }\n to {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n}\n\n@keyframes modalSlideDown {\n from {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n to {\n opacity: 0;\n transform: translateY(20px) scale(0.98);\n }\n}\n\n/* Fade In/Out with Scale */\n@keyframes fadeInScale {\n from {\n opacity: 0;\n transform: scale(0.95);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n\n@keyframes fadeOutScale {\n from {\n opacity: 1;\n transform: scale(1);\n }\n to {\n opacity: 0;\n transform: scale(0.95);\n }\n}\n\n/* Slide In/Out from Right */\n@keyframes slideInRight {\n from {\n opacity: 0;\n transform: translateX(30px);\n }\n to {\n opacity: 1;\n transform: translateX(0);\n }\n}\n\n@keyframes slideOutRight {\n from {\n opacity: 1;\n transform: translateX(0);\n }\n to {\n opacity: 0;\n transform: translateX(30px);\n }\n}\n\n/* Slide In/Out from Left */\n@keyframes slideInLeft {\n from {\n opacity: 0;\n transform: translateX(-30px);\n }\n to {\n opacity: 1;\n transform: translateX(0);\n }\n}\n\n@keyframes slideOutLeft {\n from {\n opacity: 1;\n transform: translateX(0);\n }\n to {\n opacity: 0;\n transform: translateX(-30px);\n }\n}\n\n/* Bounce In/Out */\n@keyframes bounceIn {\n 0% {\n opacity: 0;\n transform: scale(0.3);\n }\n 50% {\n opacity: 1;\n transform: scale(1.05);\n }\n 70% {\n transform: scale(0.9);\n }\n 100% {\n transform: scale(1);\n }\n}\n\n@keyframes bounceOut {\n 20% {\n transform: scale(1.1);\n }\n 100% {\n opacity: 0;\n transform: scale(0.3);\n }\n}\n\n/* Small Bounce In/Out */\n@keyframes bounceInSmall {\n 0% {\n opacity: 0;\n transform: scale(0.8);\n }\n 50% {\n opacity: 1;\n transform: scale(1.05);\n }\n 70% {\n transform: scale(0.95);\n }\n 100% {\n transform: scale(1);\n }\n}\n\n@keyframes bounceOutSmall {\n 20% {\n transform: scale(1.05);\n }\n 100% {\n opacity: 0;\n transform: scale(0.8);\n }\n}\n\n/* Flip In/Out */\n@keyframes flipIn {\n 0% {\n opacity: 0;\n transform: perspective(400px) rotateY(90deg);\n }\n 100% {\n opacity: 1;\n transform: perspective(400px) rotateY(0deg);\n }\n}\n\n@keyframes flipOut {\n 0% {\n opacity: 1;\n transform: perspective(400px) rotateY(0deg);\n }\n 100% {\n opacity: 0;\n transform: perspective(400px) rotateY(90deg);\n }\n}\n\n/* Zoom In/Out */\n@keyframes zoomIn {\n from {\n opacity: 0;\n transform: scale(0.5);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n\n@keyframes zoomOut {\n from {\n opacity: 1;\n transform: scale(1);\n }\n to {\n opacity: 0;\n transform: scale(0.5);\n }\n}\n\n/* Small Zoom In/Out */\n@keyframes zoomInSmall {\n from {\n opacity: 0;\n transform: scale(0.8);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n\n@keyframes zoomOutSmall {\n from {\n opacity: 1;\n transform: scale(1);\n }\n to {\n opacity: 0;\n transform: scale(0.8);\n }\n}\n\n/* Rotate In/Out */\n@keyframes rotateIn {\n from {\n opacity: 0;\n transform: rotate(-15deg) scale(0.95);\n }\n to {\n opacity: 1;\n transform: rotate(0deg) scale(1);\n }\n}\n\n@keyframes rotateOut {\n from {\n opacity: 1;\n transform: rotate(0deg) scale(1);\n }\n to {\n opacity: 0;\n transform: rotate(15deg) scale(0.95);\n }\n}\n\n/* Rotate Right In/Left Out */\n@keyframes rotateInRight {\n from {\n opacity: 0;\n transform: rotate(15deg) scale(0.95);\n }\n to {\n opacity: 1;\n transform: rotate(0deg) scale(1);\n }\n}\n\n@keyframes rotateOutLeft {\n from {\n opacity: 1;\n transform: rotate(0deg) scale(1);\n }\n to {\n opacity: 0;\n transform: rotate(-15deg) scale(0.95);\n }\n}\n\n/* Fade Up In/Down Out */\n@keyframes fadeInUp {\n from {\n opacity: 0;\n transform: translateY(40px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@keyframes fadeOutDown {\n from {\n opacity: 1;\n transform: translateY(0);\n }\n to {\n opacity: 0;\n transform: translateY(40px);\n }\n}\n\n/* Fade Down In/Up Out */\n@keyframes fadeInDown {\n from {\n opacity: 0;\n transform: translateY(-40px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@keyframes fadeOutUp {\n from {\n opacity: 1;\n transform: translateY(0);\n }\n to {\n opacity: 0;\n transform: translateY(-40px);\n }\n}\n\n/* Drop In/Out (3D) */\n@keyframes dropIn {\n 0% {\n opacity: 0;\n transform: translateY(-100px) rotateX(90deg);\n }\n 70% {\n opacity: 1;\n transform: translateY(10px) rotateX(-10deg);\n }\n 100% {\n transform: translateY(0) rotateX(0deg);\n }\n}\n\n@keyframes dropOut {\n 0% {\n opacity: 1;\n transform: translateY(0) rotateX(0deg);\n }\n 30% {\n opacity: 1;\n transform: translateY(10px) rotateX(-10deg);\n }\n 100% {\n opacity: 0;\n transform: translateY(-100px) rotateX(90deg);\n }\n}\n\n/* Slide Up Out/Down In */\n@keyframes slideUpOut {\n from {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n to {\n opacity: 0;\n transform: translateY(-20px) scale(0.98);\n }\n}\n\n@keyframes slideDownIn {\n from {\n opacity: 0;\n transform: translateY(-20px) scale(0.98);\n }\n to {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n}\n\n/* Blur In/Out Effects */\n@keyframes fadeInBlur {\n from {\n opacity: 0;\n filter: blur(10px);\n }\n to {\n opacity: 1;\n filter: blur(0px);\n }\n}\n\n@keyframes fadeOutBlur {\n from {\n opacity: 1;\n filter: blur(0px);\n }\n to {\n opacity: 0;\n filter: blur(10px);\n }\n}\n\n/* Shrink In/Out Effects */\n@keyframes fadeInShrink {\n from {\n opacity: 0;\n transform: scale(1.2) translateY(20px);\n }\n to {\n opacity: 1;\n transform: scale(1) translateY(0);\n }\n}\n\n@keyframes fadeOutShrink {\n from {\n opacity: 1;\n transform: scale(1) translateY(0);\n }\n to {\n opacity: 0;\n transform: scale(0.8) translateY(20px);\n }\n}\n\n/* Background Blur Animations */\n@keyframes blurIn {\n from {\n backdrop-filter: blur(0px);\n }\n to {\n backdrop-filter: blur(4px);\n }\n}\n\n@keyframes blurOut {\n from {\n backdrop-filter: blur(4px);\n }\n to {\n backdrop-filter: blur(0px);\n }\n}\n\n/* Special Effects Animations */\n\n/* Shake Animation (for errors) */\n@keyframes shake {\n 0%, 100% {\n transform: translateX(0);\n }\n 10%, 30%, 50%, 70%, 90% {\n transform: translateX(-5px);\n }\n 20%, 40%, 60%, 80% {\n transform: translateX(5px);\n }\n}\n\n/* Pulse Animation (for emphasis) */\n@keyframes pulse {\n 0% {\n transform: scale(1);\n }\n 50% {\n transform: scale(1.05);\n }\n 100% {\n transform: scale(1);\n }\n}\n\n/* Button Hover Effects */\n@keyframes buttonHover {\n 0% {\n transform: translateY(0);\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\n }\n 50% {\n transform: translateY(-2px);\n box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);\n }\n 100% {\n transform: translateY(-1px);\n box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);\n }\n}\n\n/* Accessibility: Reduce motion */\n@media (prefers-reduced-motion: reduce) {\n .alert-overlay,\n .alert-wrapper,\n .alert-button {\n animation-duration: 0.01ms;\n animation-iteration-count: 1;\n transition-duration: 0.01ms;\n }\n \n .alert-overlay {\n animation: none;\n opacity: 1;\n }\n \n .alert-wrapper {\n animation: none;\n opacity: 1;\n transform: none;\n }\n}";
@@ -99,7 +156,8 @@ var ConfirmContainer = ({
99
156
  animation = "slide",
100
157
  animationDurationIn,
101
158
  animationDurationOut,
102
- children
159
+ children,
160
+ id
103
161
  }) => {
104
162
  const [alerts, setAlerts] = useState([]);
105
163
  const [isVisible, setIsVisible] = useState(false);
@@ -109,6 +167,8 @@ var ConfirmContainer = ({
109
167
  const overlayRef = useRef(null);
110
168
  const wrapperRef = useRef(null);
111
169
  const exitTimerRef = useRef(null);
170
+ const containerId2 = useRef(id || `confirm-${Date.now().toString()}`);
171
+ const nullElement = /* @__PURE__ */ jsx("div", { id: containerId2.current, className: "null-confirm-container" });
112
172
  useEffect(() => {
113
173
  subscribe((newAlerts) => {
114
174
  setAlerts(newAlerts);
@@ -119,13 +179,25 @@ var ConfirmContainer = ({
119
179
  }, []);
120
180
  useEffect(() => {
121
181
  if (alerts.length > 0 && !currentAlert && !isExiting) {
122
- setIsMounted(true);
123
- const newAlert = alerts[0];
124
- setCurrentAlert(newAlert);
125
- requestAnimationFrame(() => {
126
- setIsVisible(true);
127
- });
182
+ const nextAlert = alerts[0];
183
+ const shouldShowAlert = (
184
+ // Case 1: Alert has no ID (can be shown by any container)
185
+ !nextAlert.id || // Case 2: Alert has an ID that matches our container ID
186
+ nextAlert.id === containerId2.current || // Case 3: No container is currently active
187
+ !getActiveContainerId()
188
+ );
189
+ if (shouldShowAlert) {
190
+ const currentActive = getActiveContainerId();
191
+ if (!currentActive || currentActive === containerId2.current) {
192
+ setActiveContainer(containerId2.current);
193
+ setIsContainerActive(true);
194
+ setIsMounted(true);
195
+ setCurrentAlert(nextAlert);
196
+ setIsVisible(true);
197
+ }
198
+ }
128
199
  } else if (alerts.length === 0 && currentAlert && isVisible) {
200
+ console.log("Starting exit animation");
129
201
  setIsExiting(true);
130
202
  setIsVisible(false);
131
203
  if (exitTimerRef.current) {
@@ -133,11 +205,14 @@ var ConfirmContainer = ({
133
205
  }
134
206
  const exitDuration = animationDurationOut || animationDuration;
135
207
  exitTimerRef.current = setTimeout(() => {
208
+ console.log("Exit animation complete");
209
+ setIsContainerActive(false);
136
210
  setIsExiting(false);
137
211
  setCurrentAlert(null);
138
212
  setIsMounted(false);
139
213
  }, exitDuration);
140
- } else if (alerts.length > 0 && currentAlert && alerts[0] !== currentAlert) {
214
+ } else if (alerts.length > 0 && currentAlert && alerts[0].id !== currentAlert.id) {
215
+ console.log("Replacing with new alert");
141
216
  setIsExiting(true);
142
217
  setIsVisible(false);
143
218
  if (exitTimerRef.current) {
@@ -145,25 +220,29 @@ var ConfirmContainer = ({
145
220
  }
146
221
  const exitDuration = animationDurationOut || animationDuration;
147
222
  exitTimerRef.current = setTimeout(() => {
223
+ setIsContainerActive(false);
148
224
  setIsExiting(false);
149
- const newAlert = alerts[0];
150
- setCurrentAlert(newAlert);
151
- requestAnimationFrame(() => {
152
- setIsVisible(true);
153
- });
225
+ setCurrentAlert(null);
226
+ setIsMounted(false);
154
227
  }, exitDuration);
155
228
  }
156
229
  }, [alerts, currentAlert, animationDuration, animationDurationOut, isVisible]);
157
- useEffect(() => {
158
- return () => {
159
- if (exitTimerRef.current) {
160
- clearTimeout(exitTimerRef.current);
161
- }
162
- };
163
- }, []);
164
- const handleClose = useCallback((value) => {
165
- closeAlert(value);
166
- }, []);
230
+ const handleClose = useCallback(async (value) => {
231
+ if (!currentAlert || isExiting) return;
232
+ setIsExiting(true);
233
+ setIsVisible(false);
234
+ const exitDuration = animationDurationOut || animationDuration;
235
+ if (exitTimerRef.current) {
236
+ clearTimeout(exitTimerRef.current);
237
+ }
238
+ exitTimerRef.current = setTimeout(() => {
239
+ closeAlert(value);
240
+ setIsExiting(false);
241
+ setCurrentAlert(null);
242
+ setIsMounted(false);
243
+ setIsContainerActive(false);
244
+ }, exitDuration);
245
+ }, [currentAlert, isExiting, animationDuration, animationDurationOut]);
167
246
  const handleCancel = useCallback(() => {
168
247
  if (currentAlert && isVisible && !isExiting) {
169
248
  handleClose(false);
@@ -203,105 +282,125 @@ var ConfirmContainer = ({
203
282
  };
204
283
  }, [closeOnClickOutside, currentAlert, isVisible, isExiting, handleClose]);
205
284
  if (!isMounted && !isExiting) {
206
- return null;
285
+ return nullElement;
286
+ }
287
+ if (!currentAlert || !getIsContainerActive()) {
288
+ return nullElement;
207
289
  }
208
290
  const colorSchema = currentAlert?.colorSchema || defaultColorSchema;
209
291
  const schemaClass = `schema-${colorSchema}`;
210
292
  const animationStyle = {};
211
293
  const currentDuration = isVisible ? animationDurationIn || animationDuration : animationDurationOut || animationDuration;
212
- if (currentDuration && currentDuration !== 300) {
213
- animationStyle.animationDuration = `${currentDuration}ms`;
214
- }
294
+ animationStyle.animationDuration = `${currentDuration}ms`;
215
295
  animationStyle.animationFillMode = "forwards";
216
296
  const animationClass = isVisible ? animationPairs[animation].enter : animationPairs[animation].exit;
217
- if (children && currentAlert) {
218
- return children({
219
- isVisible: isVisible && !isExiting,
220
- confirm: currentAlert,
221
- handleCancel,
222
- handleOk,
223
- containerRef: wrapperRef,
224
- colorSchema,
225
- animationClass,
226
- animationStyle
227
- });
228
- }
229
- if (!currentAlert) {
230
- return null;
297
+ if (children && currentAlert && getActiveContainerId() === containerId2.current) {
298
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
299
+ nullElement,
300
+ children({
301
+ isVisible: isVisible && !isExiting,
302
+ confirm: currentAlert,
303
+ handleCancel,
304
+ handleOk,
305
+ containerRef: wrapperRef,
306
+ colorSchema,
307
+ animationClass,
308
+ animationStyle
309
+ })
310
+ ] });
231
311
  }
232
- return /* @__PURE__ */ jsx(
233
- "div",
234
- {
235
- ref: overlayRef,
236
- className: cx(
237
- "alert-overlay",
238
- !isVisible ? "alert-overlay-exit" : "",
239
- `${schemaClass}-overlay`,
240
- classes.overlay
241
- ),
242
- style: animationStyle,
243
- children: /* @__PURE__ */ jsxs(
244
- "div",
245
- {
246
- ref: wrapperRef,
247
- className: cx(
248
- "alert-wrapper",
249
- animationClass,
250
- `${schemaClass}-wrapper`,
251
- classes.wrapper
252
- ),
253
- style: animationStyle,
254
- children: [
255
- /* @__PURE__ */ jsx("h2", { className: cx(
256
- "alert-title",
257
- `${schemaClass}-title`,
258
- classes.title
259
- ), children: currentAlert.title }),
260
- /* @__PURE__ */ jsx("p", { className: cx(
261
- "alert-message",
262
- `${schemaClass}-message`,
263
- classes.message
264
- ), children: currentAlert.message }),
265
- /* @__PURE__ */ jsxs("div", { className: "alert-buttons", children: [
266
- /* @__PURE__ */ jsx(
267
- "button",
268
- {
269
- onClick: handleCancel,
270
- disabled: isExiting || !isVisible,
271
- className: cx(
272
- "alert-button alert-button-cancel",
273
- `${schemaClass}-cancel`,
274
- classes.button,
275
- classes.cancel
276
- ),
277
- children: currentAlert.cancelText || "Cancel"
278
- }
279
- ),
280
- /* @__PURE__ */ jsx(
281
- "button",
282
- {
283
- onClick: handleOk,
284
- disabled: isExiting || !isVisible,
285
- className: cx(
286
- "alert-button alert-button-ok",
287
- `${schemaClass}-ok`,
288
- classes.button,
289
- classes.ok
290
- ),
291
- children: currentAlert.okText || "OK"
292
- }
293
- )
294
- ] })
295
- ]
296
- }
297
- )
298
- }
299
- );
312
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
313
+ nullElement,
314
+ /* @__PURE__ */ jsx(
315
+ "div",
316
+ {
317
+ ref: overlayRef,
318
+ className: cx(
319
+ "alert-overlay",
320
+ !isVisible ? "alert-overlay-exit" : "",
321
+ `${schemaClass}-overlay`,
322
+ classes.overlay
323
+ ),
324
+ style: animationStyle,
325
+ children: /* @__PURE__ */ jsxs(
326
+ "div",
327
+ {
328
+ ref: wrapperRef,
329
+ className: cx(
330
+ "alert-wrapper",
331
+ animationClass,
332
+ `${schemaClass}-wrapper`,
333
+ classes.wrapper
334
+ ),
335
+ style: animationStyle,
336
+ children: [
337
+ /* @__PURE__ */ jsx("h2", { className: cx(
338
+ "alert-title",
339
+ `${schemaClass}-title`,
340
+ classes.title
341
+ ), children: currentAlert.title }),
342
+ /* @__PURE__ */ jsx("p", { className: cx(
343
+ "alert-message",
344
+ `${schemaClass}-message`,
345
+ classes.message
346
+ ), children: currentAlert.message }),
347
+ /* @__PURE__ */ jsxs("div", { className: "alert-buttons", children: [
348
+ /* @__PURE__ */ jsx(
349
+ "button",
350
+ {
351
+ onClick: handleCancel,
352
+ disabled: isExiting || !isVisible,
353
+ className: cx(
354
+ "alert-button alert-button-cancel",
355
+ `${schemaClass}-cancel`,
356
+ classes.button,
357
+ classes.cancel
358
+ ),
359
+ children: currentAlert.cancelText || "Cancel"
360
+ }
361
+ ),
362
+ /* @__PURE__ */ jsx(
363
+ "button",
364
+ {
365
+ onClick: handleOk,
366
+ disabled: isExiting || !isVisible,
367
+ className: cx(
368
+ "alert-button alert-button-ok",
369
+ `${schemaClass}-ok`,
370
+ classes.button,
371
+ classes.ok
372
+ ),
373
+ children: currentAlert.okText || "OK"
374
+ }
375
+ )
376
+ ] })
377
+ ]
378
+ }
379
+ )
380
+ }
381
+ )
382
+ ] });
300
383
  };
301
384
  var confirmContainer_default = ConfirmContainer;
302
385
 
303
386
  // src/confirm.ts
304
387
  async function confirm(input) {
388
+ if (typeof input === "string") {
389
+ const containerId2 = await getElement();
390
+ const result2 = await addAlert({
391
+ message: input,
392
+ id: containerId2
393
+ });
394
+ return result2;
395
+ }
396
+ if (!input.id) {
397
+ const containerId2 = await getElement();
398
+ const result2 = await addAlert({
399
+ ...input,
400
+ id: containerId2
401
+ });
402
+ return result2;
403
+ }
305
404
  const result = await addAlert(input);
306
405
  return result;
307
406
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/confirm_store.ts","../src/confirm.css","../src/animations.css","../src/colorSchemas.css","../src/bundle-css.ts","../src/confirmContainer.tsx","../src/confirm.ts"],"names":[],"mappings":";;;;AAIA,IAAI,WAA6B,EAAC;AAClC,IAAI,SAAA,uBAAgB,GAAA,EAAc;AAE3B,SAAS,SAAS,KAAA,EAA8C;AACrE,EAAA,OAAO,IAAI,OAAA,CAAQ,CAAC,OAAA,KAAY;AAC9B,IAAA,MAAM,KAAA,GACJ,OAAO,KAAA,KAAU,QAAA,GACb;AAAA,MACA,KAAA,EAAO,SAAA;AAAA,MACP,OAAA,EAAS,KAAA;AAAA,MACT;AAAA,KACF,GACE;AAAA,MACA,KAAA,EAAO,MAAM,KAAA,IAAS,SAAA;AAAA,MACtB,SAAS,KAAA,CAAM,OAAA;AAAA,MACf,QAAQ,KAAA,CAAM,MAAA;AAAA,MACd,YAAY,KAAA,CAAM,UAAA;AAAA,MAClB,aAAa,KAAA,CAAM,WAAA;AAAA,MACnB;AAAA,KACF;AAEJ,IAAA,QAAA,GAAW,CAAC,GAAG,QAAA,EAAU,KAAK,CAAA;AAE9B,IAAA,IAAI,QAAA,CAAS,WAAW,CAAA,EAAG;AACzB,MAAA,IAAA,EAAK;AAAA,IACP;AAAA,EACF,CAAC,CAAA;AACH;AAEO,SAAS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A,oBACA,GAAG,WAAW,CAAA,GAAA,CAAA;AAAA,oBACd,OAAA,CAAQ,MAAA;AAAA,oBACR,OAAA,CAAQ;AAAA,mBACV;AAAA,kBAEC,uBAAa,MAAA,IAAU;AAAA;AAAA;AAC1B,aAAA,EACF;AAAA;AAAA;AAAA;AACF;AAAA,GACF;AAEJ,CAAA;AAEA,IAAO,wBAAA,GAAQ;;;ACzSf,eAAsB,QAAQ,KAAA,EAA8C;AAC1E,EAAA,MAAM,MAAA,GAAS,MAAM,QAAA,CAAS,KAAK,CAAA;AACnC,EAAA,OAAO,MAAA;AACT","file":"index.js","sourcesContent":["import type { ConfirmOptions, ConfirmInput } from \"./types\";\n\ntype Listener = (alerts: ConfirmOptions[]) => void;\n\nlet confirms: ConfirmOptions[] = [];\nlet listeners = new Set<Listener>();\n\nexport function addAlert(input: ConfirmInput): Promise<boolean | null> {\n return new Promise((resolve) => {\n const alert: ConfirmOptions =\n typeof input === \"string\"\n ? {\n title: \"Confirm\",\n message: input,\n resolve\n }\n : {\n title: input.title || \"Confirm\",\n message: input.message,\n okText: input.okText,\n cancelText: input.cancelText,\n colorSchema: input.colorSchema,\n resolve\n };\n\n confirms = [...confirms, alert];\n \n if (confirms.length === 1) {\n emit();\n }\n });\n}\n\nexport function closeAlert(result: boolean | null) {\n const alert = confirms[0];\n if (!alert) return;\n\n // Resolve current alert\n alert.resolve(result);\n \n // Remove from queue\n confirms = confirms.slice(1);\n \n emit()\n}\n\nexport function subscribe(listener: Listener) {\n listeners.add(listener);\n listener(confirms);\n return () => listeners.delete(listener);\n}\n\nexport function emit() {\n listeners.forEach((listener) => listener(confirms));\n}","/* confirm.css */\n.alert-overlay {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 9999;\n display: flex;\n align-items: center;\n justify-content: center;\n backdrop-filter: blur(4px);\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',\n 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n animation: overlayFadeIn 0.3s ease-out forwards;\n}\n\n.alert-overlay-exit {\n animation: overlayFadeOut 0.3s ease-in forwards;\n}\n\n.alert-wrapper {\n width: 90%;\n max-width: 400px;\n border-radius: 12px;\n padding: 24px;\n box-shadow: \n 0 20px 25px -5px rgba(0, 0, 0, 0.1),\n 0 10px 10px -5px rgba(0, 0, 0, 0.04),\n 0 0 0 1px rgba(0, 0, 0, 0.05);\n animation: modalSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n transform: translateY(20px) scale(0.98);\n}\n\n.alert-wrapper-exit {\n animation: modalSlideDown 0.3s ease-in forwards;\n}\n\n.alert-title {\n font-size: 18px;\n font-weight: 600;\n line-height: 1.4;\n margin: 0 0 12px 0;\n}\n\n.alert-message {\n font-size: 14px;\n line-height: 1.5;\n margin: 0 0 24px 0;\n}\n\n.alert-buttons {\n display: flex;\n justify-content: flex-end;\n gap: 12px;\n margin-top: 8px;\n}\n\n.alert-button {\n padding: 10px 20px;\n border-radius: 8px;\n font-size: 14px;\n font-weight: 500;\n border: none;\n cursor: pointer;\n font-family: inherit;\n transition: all 0.2s ease;\n min-width: 80px;\n text-align: center;\n}\n\n.alert-button:focus {\n outline-offset: 2px;\n}\n\n.alert-button:active {\n transform: translateY(1px);\n}\n\n/* Default animations */\n.alert-wrapper-exit {\n animation: modalSlideDown 0.3s ease-in forwards;\n}\n\n/* Entrance Animation Classes */\n.alert-animate-fadeInScale {\n animation: fadeInScale 0.4s ease-out forwards;\n}\n\n.alert-animate-bounceIn {\n animation: bounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;\n}\n\n.alert-animate-flipIn {\n animation: flipIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;\n}\n\n.alert-animate-zoomIn {\n animation: zoomIn 0.3s ease-out forwards;\n}\n\n.alert-animate-rotateIn {\n animation: rotateIn 0.5s ease-out forwards;\n}\n\n.alert-animate-fadeInUp {\n animation: fadeInUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n}\n\n.alert-animate-dropIn {\n animation: dropIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;\n}\n\n.alert-animate-slideInRight {\n animation: slideInRight 0.4s ease-out forwards;\n}\n\n.alert-animate-slideInLeft {\n animation: slideInLeft 0.4s ease-out forwards;\n}\n\n.alert-animate-fadeInDown {\n animation: fadeInDown 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n}\n\n.alert-animate-slideDownIn {\n animation: slideDownIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n}\n\n.alert-animate-rotateInRight {\n animation: rotateInRight 0.5s ease-out forwards;\n}\n\n.alert-animate-zoomInSmall {\n animation: zoomInSmall 0.3s ease-out forwards;\n}\n\n.alert-animate-bounceInSmall {\n animation: bounceInSmall 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;\n}\n\n.alert-animate-fadeInBlur {\n animation: fadeInBlur 0.4s ease-out forwards;\n}\n\n.alert-animate-fadeInShrink {\n animation: fadeInShrink 0.3s ease-out forwards;\n}\n\n/* Exit Animation Classes */\n.alert-animate-fadeOutScale {\n animation: fadeOutScale 0.3s ease-in forwards;\n}\n\n.alert-animate-bounceOut {\n animation: bounceOut 0.4s ease-in forwards;\n}\n\n.alert-animate-zoomOut {\n animation: zoomOut 0.3s ease-in forwards;\n}\n\n.alert-animate-rotateOut {\n animation: rotateOut 0.3s ease-in forwards;\n}\n\n.alert-animate-fadeOutDown {\n animation: fadeOutDown 0.3s ease-in forwards;\n}\n\n.alert-animate-slideOutRight {\n animation: slideOutRight 0.3s ease-in forwards;\n}\n\n.alert-animate-slideOutLeft {\n animation: slideOutLeft 0.3s ease-in forwards;\n}\n\n.alert-animate-flipOut {\n animation: flipOut 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;\n}\n\n.alert-animate-dropOut {\n animation: dropOut 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;\n}\n\n.alert-animate-fadeOutUp {\n animation: fadeOutUp 0.3s ease-in forwards;\n}\n\n.alert-animate-slideUpOut {\n animation: slideUpOut 0.3s ease-in forwards;\n}\n\n.alert-animate-rotateOutLeft {\n animation: rotateOutLeft 0.3s ease-in forwards;\n}\n\n.alert-animate-zoomOutSmall {\n animation: zoomOutSmall 0.3s ease-in forwards;\n}\n\n.alert-animate-bounceOutSmall {\n animation: bounceOutSmall 0.4s ease-in forwards;\n}\n\n.alert-animate-fadeOutBlur {\n animation: fadeOutBlur 0.4s ease-in forwards;\n}\n\n.alert-animate-fadeOutShrink {\n animation: fadeOutShrink 0.3s ease-in forwards;\n}\n\n.alert-wrapper {\n width: 90%;\n max-width: 400px;\n border-radius: 12px;\n padding: 24px;\n box-shadow: \n 0 20px 25px -5px rgba(0, 0, 0, 0.1),\n 0 10px 10px -5px rgba(0, 0, 0, 0.04),\n 0 0 0 1px rgba(0, 0, 0, 0.05);\n}","/* animations.css - Complete Animation Keyframes */\n\n/* Overlay Animations */\n@keyframes overlayFadeIn {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}\n\n@keyframes overlayFadeOut {\n from {\n opacity: 1;\n }\n to {\n opacity: 0;\n }\n}\n\n/* Default Modal Animations */\n@keyframes modalSlideUp {\n from {\n opacity: 0;\n transform: translateY(20px) scale(0.98);\n }\n to {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n}\n\n@keyframes modalSlideDown {\n from {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n to {\n opacity: 0;\n transform: translateY(20px) scale(0.98);\n }\n}\n\n/* Fade In/Out with Scale */\n@keyframes fadeInScale {\n from {\n opacity: 0;\n transform: scale(0.95);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n\n@keyframes fadeOutScale {\n from {\n opacity: 1;\n transform: scale(1);\n }\n to {\n opacity: 0;\n transform: scale(0.95);\n }\n}\n\n/* Slide In/Out from Right */\n@keyframes slideInRight {\n from {\n opacity: 0;\n transform: translateX(30px);\n }\n to {\n opacity: 1;\n transform: translateX(0);\n }\n}\n\n@keyframes slideOutRight {\n from {\n opacity: 1;\n transform: translateX(0);\n }\n to {\n opacity: 0;\n transform: translateX(30px);\n }\n}\n\n/* Slide In/Out from Left */\n@keyframes slideInLeft {\n from {\n opacity: 0;\n transform: translateX(-30px);\n }\n to {\n opacity: 1;\n transform: translateX(0);\n }\n}\n\n@keyframes slideOutLeft {\n from {\n opacity: 1;\n transform: translateX(0);\n }\n to {\n opacity: 0;\n transform: translateX(-30px);\n }\n}\n\n/* Bounce In/Out */\n@keyframes bounceIn {\n 0% {\n opacity: 0;\n transform: scale(0.3);\n }\n 50% {\n opacity: 1;\n transform: scale(1.05);\n }\n 70% {\n transform: scale(0.9);\n }\n 100% {\n transform: scale(1);\n }\n}\n\n@keyframes bounceOut {\n 20% {\n transform: scale(1.1);\n }\n 100% {\n opacity: 0;\n transform: scale(0.3);\n }\n}\n\n/* Small Bounce In/Out */\n@keyframes bounceInSmall {\n 0% {\n opacity: 0;\n transform: scale(0.8);\n }\n 50% {\n opacity: 1;\n transform: scale(1.05);\n }\n 70% {\n transform: scale(0.95);\n }\n 100% {\n transform: scale(1);\n }\n}\n\n@keyframes bounceOutSmall {\n 20% {\n transform: scale(1.05);\n }\n 100% {\n opacity: 0;\n transform: scale(0.8);\n }\n}\n\n/* Flip In/Out */\n@keyframes flipIn {\n 0% {\n opacity: 0;\n transform: perspective(400px) rotateY(90deg);\n }\n 100% {\n opacity: 1;\n transform: perspective(400px) rotateY(0deg);\n }\n}\n\n@keyframes flipOut {\n 0% {\n opacity: 1;\n transform: perspective(400px) rotateY(0deg);\n }\n 100% {\n opacity: 0;\n transform: perspective(400px) rotateY(90deg);\n }\n}\n\n/* Zoom In/Out */\n@keyframes zoomIn {\n from {\n opacity: 0;\n transform: scale(0.5);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n\n@keyframes zoomOut {\n from {\n opacity: 1;\n transform: scale(1);\n }\n to {\n opacity: 0;\n transform: scale(0.5);\n }\n}\n\n/* Small Zoom In/Out */\n@keyframes zoomInSmall {\n from {\n opacity: 0;\n transform: scale(0.8);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n\n@keyframes zoomOutSmall {\n from {\n opacity: 1;\n transform: scale(1);\n }\n to {\n opacity: 0;\n transform: scale(0.8);\n }\n}\n\n/* Rotate In/Out */\n@keyframes rotateIn {\n from {\n opacity: 0;\n transform: rotate(-15deg) scale(0.95);\n }\n to {\n opacity: 1;\n transform: rotate(0deg) scale(1);\n }\n}\n\n@keyframes rotateOut {\n from {\n opacity: 1;\n transform: rotate(0deg) scale(1);\n }\n to {\n opacity: 0;\n transform: rotate(15deg) scale(0.95);\n }\n}\n\n/* Rotate Right In/Left Out */\n@keyframes rotateInRight {\n from {\n opacity: 0;\n transform: rotate(15deg) scale(0.95);\n }\n to {\n opacity: 1;\n transform: rotate(0deg) scale(1);\n }\n}\n\n@keyframes rotateOutLeft {\n from {\n opacity: 1;\n transform: rotate(0deg) scale(1);\n }\n to {\n opacity: 0;\n transform: rotate(-15deg) scale(0.95);\n }\n}\n\n/* Fade Up In/Down Out */\n@keyframes fadeInUp {\n from {\n opacity: 0;\n transform: translateY(40px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@keyframes fadeOutDown {\n from {\n opacity: 1;\n transform: translateY(0);\n }\n to {\n opacity: 0;\n transform: translateY(40px);\n }\n}\n\n/* Fade Down In/Up Out */\n@keyframes fadeInDown {\n from {\n opacity: 0;\n transform: translateY(-40px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@keyframes fadeOutUp {\n from {\n opacity: 1;\n transform: translateY(0);\n }\n to {\n opacity: 0;\n transform: translateY(-40px);\n }\n}\n\n/* Drop In/Out (3D) */\n@keyframes dropIn {\n 0% {\n opacity: 0;\n transform: translateY(-100px) rotateX(90deg);\n }\n 70% {\n opacity: 1;\n transform: translateY(10px) rotateX(-10deg);\n }\n 100% {\n transform: translateY(0) rotateX(0deg);\n }\n}\n\n@keyframes dropOut {\n 0% {\n opacity: 1;\n transform: translateY(0) rotateX(0deg);\n }\n 30% {\n opacity: 1;\n transform: translateY(10px) rotateX(-10deg);\n }\n 100% {\n opacity: 0;\n transform: translateY(-100px) rotateX(90deg);\n }\n}\n\n/* Slide Up Out/Down In */\n@keyframes slideUpOut {\n from {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n to {\n opacity: 0;\n transform: translateY(-20px) scale(0.98);\n }\n}\n\n@keyframes slideDownIn {\n from {\n opacity: 0;\n transform: translateY(-20px) scale(0.98);\n }\n to {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n}\n\n/* Blur In/Out Effects */\n@keyframes fadeInBlur {\n from {\n opacity: 0;\n filter: blur(10px);\n }\n to {\n opacity: 1;\n filter: blur(0px);\n }\n}\n\n@keyframes fadeOutBlur {\n from {\n opacity: 1;\n filter: blur(0px);\n }\n to {\n opacity: 0;\n filter: blur(10px);\n }\n}\n\n/* Shrink In/Out Effects */\n@keyframes fadeInShrink {\n from {\n opacity: 0;\n transform: scale(1.2) translateY(20px);\n }\n to {\n opacity: 1;\n transform: scale(1) translateY(0);\n }\n}\n\n@keyframes fadeOutShrink {\n from {\n opacity: 1;\n transform: scale(1) translateY(0);\n }\n to {\n opacity: 0;\n transform: scale(0.8) translateY(20px);\n }\n}\n\n/* Background Blur Animations */\n@keyframes blurIn {\n from {\n backdrop-filter: blur(0px);\n }\n to {\n backdrop-filter: blur(4px);\n }\n}\n\n@keyframes blurOut {\n from {\n backdrop-filter: blur(4px);\n }\n to {\n backdrop-filter: blur(0px);\n }\n}\n\n/* Special Effects Animations */\n\n/* Shake Animation (for errors) */\n@keyframes shake {\n 0%, 100% {\n transform: translateX(0);\n }\n 10%, 30%, 50%, 70%, 90% {\n transform: translateX(-5px);\n }\n 20%, 40%, 60%, 80% {\n transform: translateX(5px);\n }\n}\n\n/* Pulse Animation (for emphasis) */\n@keyframes pulse {\n 0% {\n transform: scale(1);\n }\n 50% {\n transform: scale(1.05);\n }\n 100% {\n transform: scale(1);\n }\n}\n\n/* Button Hover Effects */\n@keyframes buttonHover {\n 0% {\n transform: translateY(0);\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\n }\n 50% {\n transform: translateY(-2px);\n box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);\n }\n 100% {\n transform: translateY(-1px);\n box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);\n }\n}\n\n/* Accessibility: Reduce motion */\n@media (prefers-reduced-motion: reduce) {\n .alert-overlay,\n .alert-wrapper,\n .alert-button {\n animation-duration: 0.01ms;\n animation-iteration-count: 1;\n transition-duration: 0.01ms;\n }\n \n .alert-overlay {\n animation: none;\n opacity: 1;\n }\n \n .alert-wrapper {\n animation: none;\n opacity: 1;\n transform: none;\n }\n}","/* ========== LIGHT SCHEMA (Default) ========== */\n.schema-light-overlay {\n background-color: rgba(0, 0, 0, 0.5);\n}\n\n.schema-light-wrapper {\n background-color: #ffffff;\n color: #111827;\n}\n\n.schema-light-title {\n color: #111827;\n}\n\n.schema-light-message {\n color: #6b7280;\n}\n\n.schema-light-cancel {\n background-color: #f3f4f6;\n color: #374151;\n outline-color: #9ca3af;\n}\n\n.schema-light-cancel:hover {\n background-color: #e5e7eb;\n transform: translateY(-1px);\n}\n\n.schema-light-cancel:active {\n background-color: #d1d5db;\n}\n\n.schema-light-cancel-danger {\n background-color: #fee2e2;\n color: #991b1b;\n outline-color: #f87171;\n}\n\n.schema-light-cancel-danger:hover {\n background-color: #fecaca;\n}\n\n.schema-light-ok {\n background-color: #10b981;\n color: #ffffff;\n outline-color: #34d399;\n}\n\n.schema-light-ok:hover {\n background-color: #059669;\n transform: translateY(-1px);\n}\n\n.schema-light-ok:active {\n background-color: #047857;\n}\n\n.schema-light-ok-danger {\n background-color: #ef4444;\n color: #ffffff;\n outline-color: #f87171;\n}\n\n.schema-light-ok-danger:hover {\n background-color: #dc2626;\n}\n\n/* ========== DARK SCHEMA ========== */\n.schema-dark-overlay {\n background-color: rgba(0, 0, 0, 0.7);\n}\n\n.schema-dark-wrapper {\n background-color: #18181b;\n color: #f4f4f5;\n box-shadow: \n 0 20px 25px -5px rgba(0, 0, 0, 0.3),\n 0 10px 10px -5px rgba(0, 0, 0, 0.2),\n 0 0 0 1px rgba(255, 255, 255, 0.1);\n}\n\n.schema-dark-title {\n color: #f4f4f5;\n}\n\n.schema-dark-message {\n color: #a1a1aa;\n}\n\n.schema-dark-cancel {\n background-color: #27272a;\n color: #e4e4e7;\n outline-color: #71717a;\n}\n\n.schema-dark-cancel:hover {\n background-color: #3f3f46;\n transform: translateY(-1px);\n}\n\n.schema-dark-cancel:active {\n background-color: #52525b;\n}\n\n.schema-dark-cancel-danger {\n background-color: #7f1d1d;\n color: #fecaca;\n outline-color: #ef4444;\n}\n\n.schema-dark-cancel-danger:hover {\n background-color: #991b1b;\n}\n\n.schema-dark-ok {\n background-color: #10b981;\n color: #ffffff;\n outline-color: #34d399;\n}\n\n.schema-dark-ok:hover {\n background-color: #059669;\n transform: translateY(-1px);\n}\n\n.schema-dark-ok:active {\n background-color: #047857;\n}\n\n.schema-dark-ok-danger {\n background-color: #dc2626;\n color: #ffffff;\n outline-color: #ef4444;\n}\n\n.schema-dark-ok-danger:hover {\n background-color: #b91c1c;\n}\n\n/* ========== BLUE SCHEMA ========== */\n.schema-blue-overlay {\n background-color: rgba(59, 130, 246, 0.3);\n}\n\n.schema-blue-wrapper {\n background-color: #eff6ff;\n color: #1e3a8a;\n box-shadow: \n 0 20px 25px -5px rgba(59, 130, 246, 0.15),\n 0 10px 10px -5px rgba(59, 130, 246, 0.1),\n 0 0 0 1px rgba(59, 130, 246, 0.1);\n}\n\n.schema-blue-title {\n color: #1e3a8a;\n}\n\n.schema-blue-message {\n color: #3b82f6;\n}\n\n.schema-blue-cancel {\n background-color: #dbeafe;\n color: #1e40af;\n outline-color: #60a5fa;\n}\n\n.schema-blue-cancel:hover {\n background-color: #bfdbfe;\n transform: translateY(-1px);\n}\n\n.schema-blue-cancel:active {\n background-color: #93c5fd;\n}\n\n.schema-blue-cancel-danger {\n background-color: #fee2e2;\n color: #991b1b;\n outline-color: #f87171;\n}\n\n.schema-blue-ok {\n background-color: #3b82f6;\n color: #ffffff;\n outline-color: #60a5fa;\n}\n\n.schema-blue-ok:hover {\n background-color: #2563eb;\n transform: translateY(-1px);\n}\n\n.schema-blue-ok:active {\n background-color: #1d4ed8;\n}\n\n.schema-blue-ok-danger {\n background-color: #ef4444;\n color: #ffffff;\n outline-color: #f87171;\n}\n\n/* ========== RED SCHEMA ========== */\n.schema-red-overlay {\n background-color: rgba(220, 38, 38, 0.2);\n}\n\n.schema-red-wrapper {\n background-color: #fef2f2;\n color: #7f1d1d;\n box-shadow: \n 0 20px 25px -5px rgba(220, 38, 38, 0.15),\n 0 10px 10px -5px rgba(220, 38, 38, 0.1),\n 0 0 0 1px rgba(220, 38, 38, 0.1);\n}\n\n.schema-red-title {\n color: #7f1d1d;\n}\n\n.schema-red-message {\n color: #ef4444;\n}\n\n.schema-red-cancel {\n background-color: #fecaca;\n color: #991b1b;\n outline-color: #f87171;\n}\n\n.schema-red-cancel:hover {\n background-color: #fca5a5;\n transform: translateY(-1px);\n}\n\n.schema-red-cancel:active {\n background-color: #f87171;\n}\n\n.schema-red-ok {\n background-color: #dc2626;\n color: #ffffff;\n outline-color: #ef4444;\n}\n\n.schema-red-ok:hover {\n background-color: #b91c1c;\n transform: translateY(-1px);\n}\n\n.schema-red-ok:active {\n background-color: #991b1b;\n}\n\n.schema-red-ok-danger {\n background-color: #991b1b;\n color: #ffffff;\n outline-color: #dc2626;\n}\n\n/* ========== GREEN SCHEMA ========== */\n.schema-green-overlay {\n background-color: rgba(16, 185, 129, 0.2);\n}\n\n.schema-green-wrapper {\n background-color: #ecfdf5;\n color: #064e3b;\n box-shadow: \n 0 20px 25px -5px rgba(16, 185, 129, 0.15),\n 0 10px 10px -5px rgba(16, 185, 129, 0.1),\n 0 0 0 1px rgba(16, 185, 129, 0.1);\n}\n\n.schema-green-title {\n color: #064e3b;\n}\n\n.schema-green-message {\n color: #10b981;\n}\n\n.schema-green-cancel {\n background-color: #d1fae5;\n color: #047857;\n outline-color: #34d399;\n}\n\n.schema-green-cancel:hover {\n background-color: #a7f3d0;\n transform: translateY(-1px);\n}\n\n.schema-green-cancel:active {\n background-color: #6ee7b7;\n}\n\n.schema-green-cancel-danger {\n background-color: #fee2e2;\n color: #991b1b;\n outline-color: #f87171;\n}\n\n.schema-green-ok {\n background-color: #10b981;\n color: #ffffff;\n outline-color: #34d399;\n}\n\n.schema-green-ok:hover {\n background-color: #059669;\n transform: translateY(-1px);\n}\n\n.schema-green-ok:active {\n background-color: #047857;\n}\n\n.schema-green-ok-danger {\n background-color: #ef4444;\n color: #ffffff;\n outline-color: #f87171;\n}\n\n/* ========== PURPLE SCHEMA ========== */\n.schema-purple-overlay {\n background-color: rgba(139, 92, 246, 0.2);\n}\n\n.schema-purple-wrapper {\n background-color: #f5f3ff;\n color: #5b21b6;\n box-shadow: \n 0 20px 25px -5px rgba(139, 92, 246, 0.15),\n 0 10px 10px -5px rgba(139, 92, 246, 0.1),\n 0 0 0 1px rgba(139, 92, 246, 0.1);\n}\n\n.schema-purple-title {\n color: #5b21b6;\n}\n\n.schema-purple-message {\n color: #8b5cf6;\n}\n\n.schema-purple-cancel {\n background-color: #ede9fe;\n color: #6d28d9;\n outline-color: #a78bfa;\n}\n\n.schema-purple-cancel:hover {\n background-color: #ddd6fe;\n transform: translateY(-1px);\n}\n\n.schema-purple-cancel:active {\n background-color: #c4b5fd;\n}\n\n.schema-purple-cancel-danger {\n background-color: #fee2e2;\n color: #991b1b;\n outline-color: #f87171;\n}\n\n.schema-purple-ok {\n background-color: #8b5cf6;\n color: #ffffff;\n outline-color: #a78bfa;\n}\n\n.schema-purple-ok:hover {\n background-color: #7c3aed;\n transform: translateY(-1px);\n}\n\n.schema-purple-ok:active {\n background-color: #6d28d9;\n}\n\n.schema-purple-ok-danger {\n background-color: #ef4444;\n color: #ffffff;\n outline-color: #f87171;\n}\n","import confirmCSS from './confirm.css';\nimport animationsCSS from './animations.css';\nimport colorSchemasCSS from './colorSchemas.css';\n\n// Combine all CSS\nconst ALL_CSS = `${confirmCSS}\\n${animationsCSS}\\n${colorSchemasCSS}`;\n\nlet stylesInjected = false;\n\nexport function ensureStyles() {\n if (typeof document === 'undefined') {\n return; // Server-side rendering\n }\n \n if (stylesInjected) {\n return; // Already injected\n }\n \n // Create and inject style tag\n const style = document.createElement('style');\n style.setAttribute('data-react-confirm-lite', '');\n style.textContent = ALL_CSS;\n document.head.appendChild(style);\n \n stylesInjected = true;\n}","import React, { useEffect, useState, useCallback, useRef, type ReactNode, type CSSProperties } from \"react\";\nimport { subscribe, closeAlert } from \"./confirm_store\";\nimport type { ConfirmClasses, ConfirmOptions, ColorSchema, AnimationType, animationPairs } from \"./types\";\nimport \"./confirm.css\";\nimport './animations.css'\nimport './colorSchemas.css'\nimport { ensureStyles } from \"./bundle-css\";\n\nfunction cx(...classes: (string | undefined)[]) {\n return classes.filter(Boolean).join(\" \");\n}\n\nconst animationPairs = {\n slide: { enter: '', exit: 'alert-wrapper-exit' },\n fadeScale: { enter: 'alert-animate-fadeInScale', exit: 'alert-animate-fadeOutScale' },\n bounce: { enter: 'alert-animate-bounceIn', exit: 'alert-animate-bounceOut' },\n flip: { enter: 'alert-animate-flipIn', exit: 'alert-animate-flipOut' },\n zoom: { enter: 'alert-animate-zoomIn', exit: 'alert-animate-zoomOut' },\n rotate: { enter: 'alert-animate-rotateIn', exit: 'alert-animate-rotateOut' },\n fadeUp: { enter: 'alert-animate-fadeInUp', exit: 'alert-animate-fadeOutDown' },\n drop: { enter: 'alert-animate-dropIn', exit: 'alert-animate-dropOut' },\n slideRight: { enter: 'alert-animate-slideInRight', exit: 'alert-animate-slideOutLeft' },\n slideLeft: { enter: 'alert-animate-slideInLeft', exit: 'alert-animate-slideOutRight' },\n fadeDown: { enter: 'alert-animate-fadeInDown', exit: 'alert-animate-fadeOutUp' },\n slideVertical: { enter: 'alert-animate-slideDownIn', exit: 'alert-animate-slideUpOut' },\n rotateRight: { enter: 'alert-animate-rotateInRight', exit: 'alert-animate-rotateOutLeft' },\n zoomSmall: { enter: 'alert-animate-zoomInSmall', exit: 'alert-animate-zoomOutSmall' },\n bounceSmall: { enter: 'alert-animate-bounceInSmall', exit: 'alert-animate-bounceOutSmall' },\n fadeBlur: { enter: 'alert-animate-fadeInBlur', exit: 'alert-animate-fadeOutBlur' },\n fadeShrink: { enter: 'alert-animate-fadeInShrink', exit: 'alert-animate-fadeOutShrink' },\n} as const;\n\ntype Props = {\n classes?: ConfirmClasses;\n defaultColorSchema?: ColorSchema;\n closeOnEscape?: boolean;\n closeOnClickOutside?: boolean;\n animation?: AnimationType;\n animationDuration?: number;\n animationDurationIn?: number;\n animationDurationOut?: number;\n children?: (props: {\n isVisible: boolean;\n confirm: ConfirmOptions;\n handleCancel: () => void;\n handleOk: () => void;\n containerRef: React.RefObject<HTMLDivElement | null>;\n colorSchema: ColorSchema;\n animationClass: string;\n animationStyle: CSSProperties;\n }) => ReactNode;\n};\n\nconst ConfirmContainer = ({\n classes = {},\n animationDuration = 300,\n defaultColorSchema = 'dark',\n closeOnEscape = true,\n closeOnClickOutside = true,\n animation = 'slide',\n animationDurationIn,\n animationDurationOut,\n children\n}: Props) => {\n const [alerts, setAlerts] = useState<ConfirmOptions[]>([]);\n const [isVisible, setIsVisible] = useState(false);\n const [currentAlert, setCurrentAlert] = useState<ConfirmOptions | null>(null);\n const [isExiting, setIsExiting] = useState(false);\n const [isMounted, setIsMounted] = useState(false);\n const overlayRef = useRef<HTMLDivElement>(null);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const exitTimerRef = useRef<number | null>(null);\n\n useEffect(() => {\n subscribe((newAlerts) => {\n setAlerts(newAlerts);\n });\n }, []);\n\n useEffect(() => {\n ensureStyles()\n }, [])\n \n\n useEffect(() => {\n if (alerts.length > 0 && !currentAlert && !isExiting) {\n // New alert arriving - start mount sequence\n setIsMounted(true);\n const newAlert = alerts[0];\n setCurrentAlert(newAlert);\n requestAnimationFrame(() => {\n setIsVisible(true);\n });\n } else if (alerts.length === 0 && currentAlert && isVisible) {\n // Start exit animation\n setIsExiting(true);\n setIsVisible(false);\n\n // Clear any existing timer\n if (exitTimerRef.current) {\n clearTimeout(exitTimerRef.current);\n }\n\n // Keep component mounted until exit animation completes\n const exitDuration = animationDurationOut || animationDuration;\n exitTimerRef.current = setTimeout(() => {\n setIsExiting(false);\n setCurrentAlert(null);\n setIsMounted(false);\n }, exitDuration);\n } else if (alerts.length > 0 && currentAlert && alerts[0] !== currentAlert) {\n // Replacing current alert\n setIsExiting(true);\n setIsVisible(false);\n\n if (exitTimerRef.current) {\n clearTimeout(exitTimerRef.current);\n }\n\n const exitDuration = animationDurationOut || animationDuration;\n exitTimerRef.current = setTimeout(() => {\n setIsExiting(false);\n const newAlert = alerts[0];\n setCurrentAlert(newAlert);\n requestAnimationFrame(() => {\n setIsVisible(true);\n });\n }, exitDuration);\n }\n }, [alerts, currentAlert, animationDuration, animationDurationOut, isVisible]);\n\n useEffect(() => {\n return () => {\n if (exitTimerRef.current) {\n clearTimeout(exitTimerRef.current);\n }\n };\n }, []);\n\n const handleClose = useCallback((value: boolean | null) => {\n closeAlert(value);\n }, []);\n\n const handleCancel = useCallback(() => {\n if (currentAlert && isVisible && !isExiting) {\n handleClose(false);\n }\n }, [currentAlert, isVisible, isExiting, handleClose]);\n\n const handleOk = useCallback(() => {\n if (currentAlert && isVisible && !isExiting) {\n handleClose(true);\n }\n }, [currentAlert, isVisible, isExiting, handleClose]);\n\n const handleEscKey = useCallback((event: KeyboardEvent) => {\n if (event.key === 'Escape' && closeOnEscape && currentAlert && isVisible && !isExiting) {\n event.preventDefault();\n event.stopPropagation();\n handleClose(null);\n }\n }, [closeOnEscape, currentAlert, isVisible, isExiting, handleClose]);\n\n useEffect(() => {\n if (currentAlert && isVisible && !isExiting) {\n window.addEventListener('keydown', handleEscKey, { capture: true });\n }\n\n return () => {\n window.removeEventListener('keydown', handleEscKey, { capture: true });\n };\n }, [handleEscKey, currentAlert, isVisible, isExiting]);\n\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n if (wrapperRef.current &&\n !wrapperRef.current.contains(event.target as Node) &&\n closeOnClickOutside &&\n currentAlert &&\n isVisible &&\n !isExiting) {\n handleClose(null);\n }\n };\n\n if (currentAlert && isVisible && !isExiting) {\n document.addEventListener(\"mousedown\", handleClickOutside);\n }\n\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [closeOnClickOutside, currentAlert, isVisible, isExiting, handleClose]);\n\n // Don't render anything if not mounted and not exiting\n if (!isMounted && !isExiting) {\n return null;\n }\n\n const colorSchema = currentAlert?.colorSchema || defaultColorSchema;\n const schemaClass = `schema-${colorSchema}`;\n\n const animationStyle: CSSProperties = {};\n const currentDuration = isVisible\n ? (animationDurationIn || animationDuration)\n : (animationDurationOut || animationDuration);\n\n if (currentDuration && currentDuration !== 300) {\n animationStyle.animationDuration = `${currentDuration}ms`;\n }\n animationStyle.animationFillMode = 'forwards';\n\n const animationClass = isVisible\n ? animationPairs[animation as keyof animationPairs].enter\n : animationPairs[animation as keyof animationPairs].exit;\n\n // For children render\n if (children && currentAlert) {\n return children({\n isVisible: isVisible && !isExiting,\n confirm: currentAlert,\n handleCancel,\n handleOk,\n containerRef: wrapperRef,\n colorSchema,\n animationClass,\n animationStyle\n });\n }\n\n if (!currentAlert) {\n return null;\n }\n\n return (\n <div\n ref={overlayRef}\n className={cx(\n \"alert-overlay\",\n !isVisible ? \"alert-overlay-exit\" : '',\n `${schemaClass}-overlay`,\n classes.overlay\n )}\n style={animationStyle}\n >\n <div\n ref={wrapperRef}\n className={cx(\n \"alert-wrapper\",\n animationClass,\n `${schemaClass}-wrapper`,\n classes.wrapper\n )}\n style={animationStyle}\n >\n <h2 className={cx(\n \"alert-title\",\n `${schemaClass}-title`,\n classes.title\n )}>\n {currentAlert.title}\n </h2>\n <p className={cx(\n \"alert-message\",\n `${schemaClass}-message`,\n classes.message\n )}>\n {currentAlert.message}\n </p>\n <div className=\"alert-buttons\">\n <button\n onClick={handleCancel}\n disabled={isExiting || !isVisible}\n className={cx(\n \"alert-button alert-button-cancel\",\n `${schemaClass}-cancel`,\n classes.button,\n classes.cancel\n )}\n >\n {currentAlert.cancelText || 'Cancel'}\n </button>\n <button\n onClick={handleOk}\n disabled={isExiting || !isVisible}\n className={cx(\n 'alert-button alert-button-ok',\n `${schemaClass}-ok`,\n classes.button,\n classes.ok\n )}\n >\n {currentAlert.okText || 'OK'}\n </button>\n </div>\n </div>\n </div>\n );\n};\n\nexport default ConfirmContainer;","import { addAlert } from \"./confirm_store\";\nimport type { ConfirmInput } from \"./types\";\n\nexport async function confirm(input: ConfirmInput): Promise<boolean | null> {\n const result = await addAlert(input);\n return result;\n}"]}
1
+ {"version":3,"sources":["../src/confirm_store.ts","../src/confirm.css","../src/animations.css","../src/colorSchemas.css","../src/bundle-css.ts","../src/confirmContainer.tsx","../src/confirm.ts"],"names":["containerId","result"],"mappings":";;;;AAIA,IAAI,WAAA,GAAsB,EAAA;AAC1B,IAAI,WAA6B,EAAC;AAClC,IAAI,SAAA,uBAAgB,GAAA,EAAc;AAClC,IAAI,iBAAA,GAA6B,KAAA;AACjC,IAAM,aAAoC,EAAC;AAG3C,IAAI,iBAAA,GAAmC,IAAA;AAEhC,SAAS,qBAAqB,KAAA,EAAgB;AACnD,EAAA,iBAAA,GAAoB,KAAA;AACtB;AAEO,SAAS,oBAAA,GAAuB;AACrC,EAAA,OAAO,iBAAA;AACT;AAEO,SAAS,mBAAmB,EAAA,EAAmB;AACpD,EAAA,iBAAA,GAAoB,EAAA;AACtB;AAEO,SAAS,oBAAA,GAAsC;AACpD,EAAA,OAAO,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AAEA,IAAO,wBAAA,GAAQ;;;ACxVf,eAAsB,QAAQ,KAAA,EAAuD;AACnF,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,IAAA,MAAMA,YAAAA,GAAc,MAAM,UAAA,EAAW;AACrC,IAAA,MAAMC,OAAAA,GAAS,MAAM,QAAA,CAAS;AAAA,MAC5B,OAAA,EAAS,KAAA;AAAA,MACT,EAAA,EAAID;AAAA,KACL,CAAA;AACD,IAAA,OAAOC,OAAAA;AAAA,EACT;AAEA,EAAA,IAAI,CAAC,MAAM,EAAA,EAAI;AACb,IAAA,MAAMD,YAAAA,GAAc,MAAM,UAAA,EAAW;AACrC,IAAA,MAAMC,OAAAA,GAAS,MAAM,QAAA,CAAS;AAAA,MAC5B,GAAG,KAAA;AAAA,MACH,EAAA,EAAID;AAAA,KACL,CAAA;AACD,IAAA,OAAOC,OAAAA;AAAA,EACT;AAEA,EAAA,MAAM,MAAA,GAAS,MAAM,QAAA,CAAS,KAAK,CAAA;AACnC,EAAA,OAAO,MAAA;AACT","file":"index.js","sourcesContent":["import type { ConfirmOptions, ConfirmInput } from \"./types\";\n\ntype Listener = (alerts: ConfirmOptions[]) => void;\n\nlet containerId: string = '';\nlet confirms: ConfirmOptions[] = [];\nlet listeners = new Set<Listener>();\nlet isActiveContainer: boolean = false\nconst containers: NodeListOf<Element>[] = [];\n\n// Global lock - only ONE container can show alerts at a time\nlet activeContainerId: string | null = null;\n\nexport function setIsContainerActive(value: boolean) {\n isActiveContainer = value;\n}\n\nexport function getIsContainerActive() {\n return isActiveContainer;\n}\n\nexport function setActiveContainer(id: string | null) {\n activeContainerId = id;\n}\n\nexport function getActiveContainerId(): string | null {\n return activeContainerId;\n}\n\nexport async function addAlert(input: ConfirmInput): Promise<boolean | null> {\n return new Promise((resolve) => {\n const alert: ConfirmOptions = {\n id: input.id || '', // Keep the ID for container targeting\n title: input.title || \"Confirm\",\n message: input.message,\n okText: input.okText,\n cancelText: input.cancelText,\n colorSchema: input.colorSchema,\n resolve\n };\n\n confirms = [...confirms, alert];\n\n // If this alert has an ID, set it as the active container\n if (input.id) {\n setActiveContainer(input.id);\n }\n // If this alert doesn't have an ID, clear any active container\n // so any container can potentially show it\n else {\n setActiveContainer(null);\n }\n\n if (confirms.length === 1) {\n emit();\n }\n });\n}\n\nexport async function closeAlert(result: boolean | null) {\n const alert = confirms[0];\n containerId = '';\n if (!alert) return;\n\n // Resolve current alert\n alert.resolve(result);\n // Remove from queue\n confirms = confirms.slice(1);\n\n // If there are no more alerts, clear the active container\n if (confirms.length === 0) {\n setActiveContainer(null);\n }\n\n emit();\n}\n\nexport function subscribe(listener: Listener) {\n listeners.add(listener);\n listener(confirms);\n return () => listeners.delete(listener);\n}\n\nexport function emit() {\n listeners.forEach((listener) => listener(confirms));\n}\n\n\nconst EventListener = (e: PointerEvent) => {\n if (containers.length === 0) {\n containers.push(document.querySelectorAll('.null-confirm-container'));\n }\n if (containers.length === 0) return;\n\n let parentElement = e.view?.document.activeElement?.parentElement;\n let container = parentElement?.querySelector('.null-confirm-container');\n\n while (true) {\n if (container?.id) {\n break;\n }\n parentElement = parentElement?.parentElement;\n container = parentElement?.querySelector('.null-confirm-container');\n }\n\n if (container?.id) {\n containerId = container.id;\n }\n}\n\nexport async function getElement() {\n document.addEventListener('click', EventListener, { once: true })\n await new Promise<void>((resolve) => {\n setTimeout(() => {\n document.removeEventListener('click', EventListener)\n resolve()\n }, 0);\n })\n if (containerId === '') {\n if (containers.length === 0) {\n containers.push(document.querySelectorAll('.null-confirm-container'));\n }\n return containers[0][0].id\n }\n return containerId;\n}","/* confirm.css */\n.alert-overlay {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 9999;\n display: flex;\n align-items: center;\n justify-content: center;\n backdrop-filter: blur(4px);\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',\n 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n animation: overlayFadeIn 0.3s ease-out forwards;\n}\n\n.alert-overlay-exit {\n animation: overlayFadeOut 0.3s ease-in forwards;\n}\n\n.alert-wrapper {\n width: 90%;\n max-width: 400px;\n border-radius: 12px;\n padding: 24px;\n box-shadow: \n 0 20px 25px -5px rgba(0, 0, 0, 0.1),\n 0 10px 10px -5px rgba(0, 0, 0, 0.04),\n 0 0 0 1px rgba(0, 0, 0, 0.05);\n animation: modalSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n transform: translateY(20px) scale(0.98);\n}\n\n.alert-wrapper-exit {\n animation: modalSlideDown 0.3s ease-in forwards;\n}\n\n.alert-title {\n font-size: 18px;\n font-weight: 600;\n line-height: 1.4;\n margin: 0 0 12px 0;\n}\n\n.alert-message {\n font-size: 14px;\n line-height: 1.5;\n margin: 0 0 24px 0;\n}\n\n.alert-buttons {\n display: flex;\n justify-content: flex-end;\n gap: 12px;\n margin-top: 8px;\n}\n\n.alert-button {\n padding: 10px 20px;\n border-radius: 8px;\n font-size: 14px;\n font-weight: 500;\n border: none;\n cursor: pointer;\n font-family: inherit;\n transition: all 0.2s ease;\n min-width: 80px;\n text-align: center;\n}\n\n.alert-button:focus {\n outline-offset: 2px;\n}\n\n.alert-button:active {\n transform: translateY(1px);\n}\n\n/* Default animations */\n.alert-wrapper-exit {\n animation: modalSlideDown 0.3s ease-in forwards;\n}\n\n/* Entrance Animation Classes */\n.alert-animate-fadeInScale {\n animation: fadeInScale 0.4s ease-out forwards;\n}\n\n.alert-animate-bounceIn {\n animation: bounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;\n}\n\n.alert-animate-flipIn {\n animation: flipIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;\n}\n\n.alert-animate-zoomIn {\n animation: zoomIn 0.3s ease-out forwards;\n}\n\n.alert-animate-rotateIn {\n animation: rotateIn 0.5s ease-out forwards;\n}\n\n.alert-animate-fadeInUp {\n animation: fadeInUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n}\n\n.alert-animate-dropIn {\n animation: dropIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;\n}\n\n.alert-animate-slideInRight {\n animation: slideInRight 0.4s ease-out forwards;\n}\n\n.alert-animate-slideInLeft {\n animation: slideInLeft 0.4s ease-out forwards;\n}\n\n.alert-animate-fadeInDown {\n animation: fadeInDown 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n}\n\n.alert-animate-slideDownIn {\n animation: slideDownIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n}\n\n.alert-animate-rotateInRight {\n animation: rotateInRight 0.5s ease-out forwards;\n}\n\n.alert-animate-zoomInSmall {\n animation: zoomInSmall 0.3s ease-out forwards;\n}\n\n.alert-animate-bounceInSmall {\n animation: bounceInSmall 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;\n}\n\n.alert-animate-fadeInBlur {\n animation: fadeInBlur 0.4s ease-out forwards;\n}\n\n.alert-animate-fadeInShrink {\n animation: fadeInShrink 0.3s ease-out forwards;\n}\n\n/* Exit Animation Classes */\n.alert-animate-fadeOutScale {\n animation: fadeOutScale 0.3s ease-in forwards;\n}\n\n.alert-animate-bounceOut {\n animation: bounceOut 0.4s ease-in forwards;\n}\n\n.alert-animate-zoomOut {\n animation: zoomOut 0.3s ease-in forwards;\n}\n\n.alert-animate-rotateOut {\n animation: rotateOut 0.3s ease-in forwards;\n}\n\n.alert-animate-fadeOutDown {\n animation: fadeOutDown 0.3s ease-in forwards;\n}\n\n.alert-animate-slideOutRight {\n animation: slideOutRight 0.3s ease-in forwards;\n}\n\n.alert-animate-slideOutLeft {\n animation: slideOutLeft 0.3s ease-in forwards;\n}\n\n.alert-animate-flipOut {\n animation: flipOut 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;\n}\n\n.alert-animate-dropOut {\n animation: dropOut 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;\n}\n\n.alert-animate-fadeOutUp {\n animation: fadeOutUp 0.3s ease-in forwards;\n}\n\n.alert-animate-slideUpOut {\n animation: slideUpOut 0.3s ease-in forwards;\n}\n\n.alert-animate-rotateOutLeft {\n animation: rotateOutLeft 0.3s ease-in forwards;\n}\n\n.alert-animate-zoomOutSmall {\n animation: zoomOutSmall 0.3s ease-in forwards;\n}\n\n.alert-animate-bounceOutSmall {\n animation: bounceOutSmall 0.4s ease-in forwards;\n}\n\n.alert-animate-fadeOutBlur {\n animation: fadeOutBlur 0.4s ease-in forwards;\n}\n\n.alert-animate-fadeOutShrink {\n animation: fadeOutShrink 0.3s ease-in forwards;\n}\n\n.alert-wrapper {\n width: 90%;\n max-width: 400px;\n border-radius: 12px;\n padding: 24px;\n box-shadow: \n 0 20px 25px -5px rgba(0, 0, 0, 0.1),\n 0 10px 10px -5px rgba(0, 0, 0, 0.04),\n 0 0 0 1px rgba(0, 0, 0, 0.05);\n}\n\n.null-confirm-container{\n width: 0;\n height: 0;\n opacity: 0;\n}","/* animations.css - Complete Animation Keyframes */\n\n/* Overlay Animations */\n@keyframes overlayFadeIn {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}\n\n@keyframes overlayFadeOut {\n from {\n opacity: 1;\n }\n to {\n opacity: 0;\n }\n}\n\n/* Default Modal Animations */\n@keyframes modalSlideUp {\n from {\n opacity: 0;\n transform: translateY(20px) scale(0.98);\n }\n to {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n}\n\n@keyframes modalSlideDown {\n from {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n to {\n opacity: 0;\n transform: translateY(20px) scale(0.98);\n }\n}\n\n/* Fade In/Out with Scale */\n@keyframes fadeInScale {\n from {\n opacity: 0;\n transform: scale(0.95);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n\n@keyframes fadeOutScale {\n from {\n opacity: 1;\n transform: scale(1);\n }\n to {\n opacity: 0;\n transform: scale(0.95);\n }\n}\n\n/* Slide In/Out from Right */\n@keyframes slideInRight {\n from {\n opacity: 0;\n transform: translateX(30px);\n }\n to {\n opacity: 1;\n transform: translateX(0);\n }\n}\n\n@keyframes slideOutRight {\n from {\n opacity: 1;\n transform: translateX(0);\n }\n to {\n opacity: 0;\n transform: translateX(30px);\n }\n}\n\n/* Slide In/Out from Left */\n@keyframes slideInLeft {\n from {\n opacity: 0;\n transform: translateX(-30px);\n }\n to {\n opacity: 1;\n transform: translateX(0);\n }\n}\n\n@keyframes slideOutLeft {\n from {\n opacity: 1;\n transform: translateX(0);\n }\n to {\n opacity: 0;\n transform: translateX(-30px);\n }\n}\n\n/* Bounce In/Out */\n@keyframes bounceIn {\n 0% {\n opacity: 0;\n transform: scale(0.3);\n }\n 50% {\n opacity: 1;\n transform: scale(1.05);\n }\n 70% {\n transform: scale(0.9);\n }\n 100% {\n transform: scale(1);\n }\n}\n\n@keyframes bounceOut {\n 20% {\n transform: scale(1.1);\n }\n 100% {\n opacity: 0;\n transform: scale(0.3);\n }\n}\n\n/* Small Bounce In/Out */\n@keyframes bounceInSmall {\n 0% {\n opacity: 0;\n transform: scale(0.8);\n }\n 50% {\n opacity: 1;\n transform: scale(1.05);\n }\n 70% {\n transform: scale(0.95);\n }\n 100% {\n transform: scale(1);\n }\n}\n\n@keyframes bounceOutSmall {\n 20% {\n transform: scale(1.05);\n }\n 100% {\n opacity: 0;\n transform: scale(0.8);\n }\n}\n\n/* Flip In/Out */\n@keyframes flipIn {\n 0% {\n opacity: 0;\n transform: perspective(400px) rotateY(90deg);\n }\n 100% {\n opacity: 1;\n transform: perspective(400px) rotateY(0deg);\n }\n}\n\n@keyframes flipOut {\n 0% {\n opacity: 1;\n transform: perspective(400px) rotateY(0deg);\n }\n 100% {\n opacity: 0;\n transform: perspective(400px) rotateY(90deg);\n }\n}\n\n/* Zoom In/Out */\n@keyframes zoomIn {\n from {\n opacity: 0;\n transform: scale(0.5);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n\n@keyframes zoomOut {\n from {\n opacity: 1;\n transform: scale(1);\n }\n to {\n opacity: 0;\n transform: scale(0.5);\n }\n}\n\n/* Small Zoom In/Out */\n@keyframes zoomInSmall {\n from {\n opacity: 0;\n transform: scale(0.8);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n\n@keyframes zoomOutSmall {\n from {\n opacity: 1;\n transform: scale(1);\n }\n to {\n opacity: 0;\n transform: scale(0.8);\n }\n}\n\n/* Rotate In/Out */\n@keyframes rotateIn {\n from {\n opacity: 0;\n transform: rotate(-15deg) scale(0.95);\n }\n to {\n opacity: 1;\n transform: rotate(0deg) scale(1);\n }\n}\n\n@keyframes rotateOut {\n from {\n opacity: 1;\n transform: rotate(0deg) scale(1);\n }\n to {\n opacity: 0;\n transform: rotate(15deg) scale(0.95);\n }\n}\n\n/* Rotate Right In/Left Out */\n@keyframes rotateInRight {\n from {\n opacity: 0;\n transform: rotate(15deg) scale(0.95);\n }\n to {\n opacity: 1;\n transform: rotate(0deg) scale(1);\n }\n}\n\n@keyframes rotateOutLeft {\n from {\n opacity: 1;\n transform: rotate(0deg) scale(1);\n }\n to {\n opacity: 0;\n transform: rotate(-15deg) scale(0.95);\n }\n}\n\n/* Fade Up In/Down Out */\n@keyframes fadeInUp {\n from {\n opacity: 0;\n transform: translateY(40px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@keyframes fadeOutDown {\n from {\n opacity: 1;\n transform: translateY(0);\n }\n to {\n opacity: 0;\n transform: translateY(40px);\n }\n}\n\n/* Fade Down In/Up Out */\n@keyframes fadeInDown {\n from {\n opacity: 0;\n transform: translateY(-40px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@keyframes fadeOutUp {\n from {\n opacity: 1;\n transform: translateY(0);\n }\n to {\n opacity: 0;\n transform: translateY(-40px);\n }\n}\n\n/* Drop In/Out (3D) */\n@keyframes dropIn {\n 0% {\n opacity: 0;\n transform: translateY(-100px) rotateX(90deg);\n }\n 70% {\n opacity: 1;\n transform: translateY(10px) rotateX(-10deg);\n }\n 100% {\n transform: translateY(0) rotateX(0deg);\n }\n}\n\n@keyframes dropOut {\n 0% {\n opacity: 1;\n transform: translateY(0) rotateX(0deg);\n }\n 30% {\n opacity: 1;\n transform: translateY(10px) rotateX(-10deg);\n }\n 100% {\n opacity: 0;\n transform: translateY(-100px) rotateX(90deg);\n }\n}\n\n/* Slide Up Out/Down In */\n@keyframes slideUpOut {\n from {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n to {\n opacity: 0;\n transform: translateY(-20px) scale(0.98);\n }\n}\n\n@keyframes slideDownIn {\n from {\n opacity: 0;\n transform: translateY(-20px) scale(0.98);\n }\n to {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n}\n\n/* Blur In/Out Effects */\n@keyframes fadeInBlur {\n from {\n opacity: 0;\n filter: blur(10px);\n }\n to {\n opacity: 1;\n filter: blur(0px);\n }\n}\n\n@keyframes fadeOutBlur {\n from {\n opacity: 1;\n filter: blur(0px);\n }\n to {\n opacity: 0;\n filter: blur(10px);\n }\n}\n\n/* Shrink In/Out Effects */\n@keyframes fadeInShrink {\n from {\n opacity: 0;\n transform: scale(1.2) translateY(20px);\n }\n to {\n opacity: 1;\n transform: scale(1) translateY(0);\n }\n}\n\n@keyframes fadeOutShrink {\n from {\n opacity: 1;\n transform: scale(1) translateY(0);\n }\n to {\n opacity: 0;\n transform: scale(0.8) translateY(20px);\n }\n}\n\n/* Background Blur Animations */\n@keyframes blurIn {\n from {\n backdrop-filter: blur(0px);\n }\n to {\n backdrop-filter: blur(4px);\n }\n}\n\n@keyframes blurOut {\n from {\n backdrop-filter: blur(4px);\n }\n to {\n backdrop-filter: blur(0px);\n }\n}\n\n/* Special Effects Animations */\n\n/* Shake Animation (for errors) */\n@keyframes shake {\n 0%, 100% {\n transform: translateX(0);\n }\n 10%, 30%, 50%, 70%, 90% {\n transform: translateX(-5px);\n }\n 20%, 40%, 60%, 80% {\n transform: translateX(5px);\n }\n}\n\n/* Pulse Animation (for emphasis) */\n@keyframes pulse {\n 0% {\n transform: scale(1);\n }\n 50% {\n transform: scale(1.05);\n }\n 100% {\n transform: scale(1);\n }\n}\n\n/* Button Hover Effects */\n@keyframes buttonHover {\n 0% {\n transform: translateY(0);\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\n }\n 50% {\n transform: translateY(-2px);\n box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);\n }\n 100% {\n transform: translateY(-1px);\n box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);\n }\n}\n\n/* Accessibility: Reduce motion */\n@media (prefers-reduced-motion: reduce) {\n .alert-overlay,\n .alert-wrapper,\n .alert-button {\n animation-duration: 0.01ms;\n animation-iteration-count: 1;\n transition-duration: 0.01ms;\n }\n \n .alert-overlay {\n animation: none;\n opacity: 1;\n }\n \n .alert-wrapper {\n animation: none;\n opacity: 1;\n transform: none;\n }\n}","/* ========== LIGHT SCHEMA (Default) ========== */\n.schema-light-overlay {\n background-color: rgba(0, 0, 0, 0.5);\n}\n\n.schema-light-wrapper {\n background-color: #ffffff;\n color: #111827;\n}\n\n.schema-light-title {\n color: #111827;\n}\n\n.schema-light-message {\n color: #6b7280;\n}\n\n.schema-light-cancel {\n background-color: #f3f4f6;\n color: #374151;\n outline-color: #9ca3af;\n}\n\n.schema-light-cancel:hover {\n background-color: #e5e7eb;\n transform: translateY(-1px);\n}\n\n.schema-light-cancel:active {\n background-color: #d1d5db;\n}\n\n.schema-light-cancel-danger {\n background-color: #fee2e2;\n color: #991b1b;\n outline-color: #f87171;\n}\n\n.schema-light-cancel-danger:hover {\n background-color: #fecaca;\n}\n\n.schema-light-ok {\n background-color: #10b981;\n color: #ffffff;\n outline-color: #34d399;\n}\n\n.schema-light-ok:hover {\n background-color: #059669;\n transform: translateY(-1px);\n}\n\n.schema-light-ok:active {\n background-color: #047857;\n}\n\n.schema-light-ok-danger {\n background-color: #ef4444;\n color: #ffffff;\n outline-color: #f87171;\n}\n\n.schema-light-ok-danger:hover {\n background-color: #dc2626;\n}\n\n/* ========== DARK SCHEMA ========== */\n.schema-dark-overlay {\n background-color: rgba(0, 0, 0, 0.7);\n}\n\n.schema-dark-wrapper {\n background-color: #18181b;\n color: #f4f4f5;\n box-shadow: \n 0 20px 25px -5px rgba(0, 0, 0, 0.3),\n 0 10px 10px -5px rgba(0, 0, 0, 0.2),\n 0 0 0 1px rgba(255, 255, 255, 0.1);\n}\n\n.schema-dark-title {\n color: #f4f4f5;\n}\n\n.schema-dark-message {\n color: #a1a1aa;\n}\n\n.schema-dark-cancel {\n background-color: #27272a;\n color: #e4e4e7;\n outline-color: #71717a;\n}\n\n.schema-dark-cancel:hover {\n background-color: #3f3f46;\n transform: translateY(-1px);\n}\n\n.schema-dark-cancel:active {\n background-color: #52525b;\n}\n\n.schema-dark-cancel-danger {\n background-color: #7f1d1d;\n color: #fecaca;\n outline-color: #ef4444;\n}\n\n.schema-dark-cancel-danger:hover {\n background-color: #991b1b;\n}\n\n.schema-dark-ok {\n background-color: #10b981;\n color: #ffffff;\n outline-color: #34d399;\n}\n\n.schema-dark-ok:hover {\n background-color: #059669;\n transform: translateY(-1px);\n}\n\n.schema-dark-ok:active {\n background-color: #047857;\n}\n\n.schema-dark-ok-danger {\n background-color: #dc2626;\n color: #ffffff;\n outline-color: #ef4444;\n}\n\n.schema-dark-ok-danger:hover {\n background-color: #b91c1c;\n}\n\n/* ========== BLUE SCHEMA ========== */\n.schema-blue-overlay {\n background-color: rgba(59, 130, 246, 0.3);\n}\n\n.schema-blue-wrapper {\n background-color: #eff6ff;\n color: #1e3a8a;\n box-shadow: \n 0 20px 25px -5px rgba(59, 130, 246, 0.15),\n 0 10px 10px -5px rgba(59, 130, 246, 0.1),\n 0 0 0 1px rgba(59, 130, 246, 0.1);\n}\n\n.schema-blue-title {\n color: #1e3a8a;\n}\n\n.schema-blue-message {\n color: #3b82f6;\n}\n\n.schema-blue-cancel {\n background-color: #dbeafe;\n color: #1e40af;\n outline-color: #60a5fa;\n}\n\n.schema-blue-cancel:hover {\n background-color: #bfdbfe;\n transform: translateY(-1px);\n}\n\n.schema-blue-cancel:active {\n background-color: #93c5fd;\n}\n\n.schema-blue-cancel-danger {\n background-color: #fee2e2;\n color: #991b1b;\n outline-color: #f87171;\n}\n\n.schema-blue-ok {\n background-color: #3b82f6;\n color: #ffffff;\n outline-color: #60a5fa;\n}\n\n.schema-blue-ok:hover {\n background-color: #2563eb;\n transform: translateY(-1px);\n}\n\n.schema-blue-ok:active {\n background-color: #1d4ed8;\n}\n\n.schema-blue-ok-danger {\n background-color: #ef4444;\n color: #ffffff;\n outline-color: #f87171;\n}\n\n/* ========== RED SCHEMA ========== */\n.schema-red-overlay {\n background-color: rgba(220, 38, 38, 0.2);\n}\n\n.schema-red-wrapper {\n background-color: #fef2f2;\n color: #7f1d1d;\n box-shadow: \n 0 20px 25px -5px rgba(220, 38, 38, 0.15),\n 0 10px 10px -5px rgba(220, 38, 38, 0.1),\n 0 0 0 1px rgba(220, 38, 38, 0.1);\n}\n\n.schema-red-title {\n color: #7f1d1d;\n}\n\n.schema-red-message {\n color: #ef4444;\n}\n\n.schema-red-cancel {\n background-color: #fecaca;\n color: #991b1b;\n outline-color: #f87171;\n}\n\n.schema-red-cancel:hover {\n background-color: #fca5a5;\n transform: translateY(-1px);\n}\n\n.schema-red-cancel:active {\n background-color: #f87171;\n}\n\n.schema-red-ok {\n background-color: #dc2626;\n color: #ffffff;\n outline-color: #ef4444;\n}\n\n.schema-red-ok:hover {\n background-color: #b91c1c;\n transform: translateY(-1px);\n}\n\n.schema-red-ok:active {\n background-color: #991b1b;\n}\n\n.schema-red-ok-danger {\n background-color: #991b1b;\n color: #ffffff;\n outline-color: #dc2626;\n}\n\n/* ========== GREEN SCHEMA ========== */\n.schema-green-overlay {\n background-color: rgba(16, 185, 129, 0.2);\n}\n\n.schema-green-wrapper {\n background-color: #ecfdf5;\n color: #064e3b;\n box-shadow: \n 0 20px 25px -5px rgba(16, 185, 129, 0.15),\n 0 10px 10px -5px rgba(16, 185, 129, 0.1),\n 0 0 0 1px rgba(16, 185, 129, 0.1);\n}\n\n.schema-green-title {\n color: #064e3b;\n}\n\n.schema-green-message {\n color: #10b981;\n}\n\n.schema-green-cancel {\n background-color: #d1fae5;\n color: #047857;\n outline-color: #34d399;\n}\n\n.schema-green-cancel:hover {\n background-color: #a7f3d0;\n transform: translateY(-1px);\n}\n\n.schema-green-cancel:active {\n background-color: #6ee7b7;\n}\n\n.schema-green-cancel-danger {\n background-color: #fee2e2;\n color: #991b1b;\n outline-color: #f87171;\n}\n\n.schema-green-ok {\n background-color: #10b981;\n color: #ffffff;\n outline-color: #34d399;\n}\n\n.schema-green-ok:hover {\n background-color: #059669;\n transform: translateY(-1px);\n}\n\n.schema-green-ok:active {\n background-color: #047857;\n}\n\n.schema-green-ok-danger {\n background-color: #ef4444;\n color: #ffffff;\n outline-color: #f87171;\n}\n\n/* ========== PURPLE SCHEMA ========== */\n.schema-purple-overlay {\n background-color: rgba(139, 92, 246, 0.2);\n}\n\n.schema-purple-wrapper {\n background-color: #f5f3ff;\n color: #5b21b6;\n box-shadow: \n 0 20px 25px -5px rgba(139, 92, 246, 0.15),\n 0 10px 10px -5px rgba(139, 92, 246, 0.1),\n 0 0 0 1px rgba(139, 92, 246, 0.1);\n}\n\n.schema-purple-title {\n color: #5b21b6;\n}\n\n.schema-purple-message {\n color: #8b5cf6;\n}\n\n.schema-purple-cancel {\n background-color: #ede9fe;\n color: #6d28d9;\n outline-color: #a78bfa;\n}\n\n.schema-purple-cancel:hover {\n background-color: #ddd6fe;\n transform: translateY(-1px);\n}\n\n.schema-purple-cancel:active {\n background-color: #c4b5fd;\n}\n\n.schema-purple-cancel-danger {\n background-color: #fee2e2;\n color: #991b1b;\n outline-color: #f87171;\n}\n\n.schema-purple-ok {\n background-color: #8b5cf6;\n color: #ffffff;\n outline-color: #a78bfa;\n}\n\n.schema-purple-ok:hover {\n background-color: #7c3aed;\n transform: translateY(-1px);\n}\n\n.schema-purple-ok:active {\n background-color: #6d28d9;\n}\n\n.schema-purple-ok-danger {\n background-color: #ef4444;\n color: #ffffff;\n outline-color: #f87171;\n}\n","import confirmCSS from './confirm.css';\nimport animationsCSS from './animations.css';\nimport colorSchemasCSS from './colorSchemas.css';\n\n// Combine all CSS\nconst ALL_CSS = `${confirmCSS}\\n${animationsCSS}\\n${colorSchemasCSS}`;\n\nlet stylesInjected = false;\n\nexport function ensureStyles() {\n if (typeof document === 'undefined') {\n return; // Server-side rendering\n }\n \n if (stylesInjected) {\n return; // Already injected\n }\n \n // Create and inject style tag\n const style = document.createElement('style');\n style.setAttribute('data-react-confirm-lite', '');\n style.textContent = ALL_CSS;\n document.head.appendChild(style);\n \n stylesInjected = true;\n}","import React, { useEffect, useState, useCallback, useRef, type ReactNode, type CSSProperties } from \"react\";\nimport { subscribe, closeAlert, setActiveContainer, setIsContainerActive, getIsContainerActive, getActiveContainerId } from \"./confirm_store\";\nimport type { ConfirmClasses, ConfirmOptions, ColorSchema, AnimationType, animationPairs } from \"./types\";\nimport \"./confirm.css\";\nimport './animations.css'\nimport './colorSchemas.css'\nimport { ensureStyles } from \"./bundle-css\";\n\nfunction cx(...classes: (string | undefined)[]) {\n return classes.filter(Boolean).join(\" \");\n}\n\nconst animationPairs = {\n slide: { enter: '', exit: 'alert-wrapper-exit' },\n fadeScale: { enter: 'alert-animate-fadeInScale', exit: 'alert-animate-fadeOutScale' },\n bounce: { enter: 'alert-animate-bounceIn', exit: 'alert-animate-bounceOut' },\n flip: { enter: 'alert-animate-flipIn', exit: 'alert-animate-flipOut' },\n zoom: { enter: 'alert-animate-zoomIn', exit: 'alert-animate-zoomOut' },\n rotate: { enter: 'alert-animate-rotateIn', exit: 'alert-animate-rotateOut' },\n fadeUp: { enter: 'alert-animate-fadeInUp', exit: 'alert-animate-fadeOutDown' },\n drop: { enter: 'alert-animate-dropIn', exit: 'alert-animate-dropOut' },\n slideRight: { enter: 'alert-animate-slideInRight', exit: 'alert-animate-slideOutLeft' },\n slideLeft: { enter: 'alert-animate-slideInLeft', exit: 'alert-animate-slideOutRight' },\n fadeDown: { enter: 'alert-animate-fadeInDown', exit: 'alert-animate-fadeOutUp' },\n slideVertical: { enter: 'alert-animate-slideDownIn', exit: 'alert-animate-slideUpOut' },\n rotateRight: { enter: 'alert-animate-rotateInRight', exit: 'alert-animate-rotateOutLeft' },\n zoomSmall: { enter: 'alert-animate-zoomInSmall', exit: 'alert-animate-zoomOutSmall' },\n bounceSmall: { enter: 'alert-animate-bounceInSmall', exit: 'alert-animate-bounceOutSmall' },\n fadeBlur: { enter: 'alert-animate-fadeInBlur', exit: 'alert-animate-fadeOutBlur' },\n fadeShrink: { enter: 'alert-animate-fadeInShrink', exit: 'alert-animate-fadeOutShrink' },\n} as const;\n\ntype Props = {\n classes?: ConfirmClasses;\n defaultColorSchema?: ColorSchema;\n closeOnEscape?: boolean;\n closeOnClickOutside?: boolean;\n animation?: AnimationType;\n animationDuration?: number;\n animationDurationIn?: number;\n animationDurationOut?: number;\n children?: (props: {\n isVisible: boolean;\n confirm: ConfirmOptions;\n handleCancel: () => void;\n handleOk: () => void;\n containerRef: React.RefObject<HTMLDivElement | null>;\n colorSchema: ColorSchema;\n animationClass: string;\n animationStyle: CSSProperties;\n }) => ReactNode;\n id?: string;\n};\n\nconst ConfirmContainer = ({\n classes = {},\n animationDuration = 300,\n defaultColorSchema = 'dark',\n closeOnEscape = true,\n closeOnClickOutside = true,\n animation = 'slide',\n animationDurationIn,\n animationDurationOut,\n children,\n id\n}: Props) => {\n const [alerts, setAlerts] = useState<ConfirmOptions[]>([]);\n const [isVisible, setIsVisible] = useState(false);\n const [currentAlert, setCurrentAlert] = useState<ConfirmOptions | null>(null);\n const [isExiting, setIsExiting] = useState(false);\n const [isMounted, setIsMounted] = useState(false);\n const overlayRef = useRef<HTMLDivElement>(null);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const exitTimerRef = useRef<number | null>(null);\n const containerId = useRef(id || `confirm-${Date.now().toString()}`)\n const nullElement = <div id={containerId.current} className=\"null-confirm-container\"></div>\n\n useEffect(() => {\n subscribe((newAlerts) => {\n setAlerts(newAlerts);\n });\n }, []);\n\n useEffect(() => {\n ensureStyles()\n }, []);\n\n useEffect(() => {\n if (alerts.length > 0 && !currentAlert && !isExiting) {\n const nextAlert = alerts[0];\n\n // Check if we should show this alert\n const shouldShowAlert =\n // Case 1: Alert has no ID (can be shown by any container)\n !nextAlert.id ||\n // Case 2: Alert has an ID that matches our container ID\n nextAlert.id === containerId.current ||\n // Case 3: No container is currently active\n !getActiveContainerId();\n\n if (shouldShowAlert) {\n // Check if we can become active\n const currentActive = getActiveContainerId();\n\n if (!currentActive || currentActive === containerId.current) {\n setActiveContainer(containerId.current);\n setIsContainerActive(true);\n\n // Show the alert\n setIsMounted(true);\n setCurrentAlert(nextAlert);\n setIsVisible(true);\n }\n }\n }\n else if (alerts.length === 0 && currentAlert && isVisible) {\n // No more alerts, but we're showing one - start exit\n console.log(\"Starting exit animation\");\n setIsExiting(true);\n setIsVisible(false);\n\n if (exitTimerRef.current) {\n clearTimeout(exitTimerRef.current);\n }\n\n const exitDuration = animationDurationOut || animationDuration;\n exitTimerRef.current = setTimeout(() => {\n console.log(\"Exit animation complete\");\n setIsContainerActive(false);\n setIsExiting(false);\n setCurrentAlert(null);\n setIsMounted(false);\n }, exitDuration);\n }\n else if (alerts.length > 0 && currentAlert && alerts[0].id !== currentAlert.id) {\n // New alert with different ID is replacing current one\n console.log(\"Replacing with new alert\");\n setIsExiting(true);\n setIsVisible(false);\n\n if (exitTimerRef.current) {\n clearTimeout(exitTimerRef.current);\n }\n\n const exitDuration = animationDurationOut || animationDuration;\n exitTimerRef.current = setTimeout(() => {\n setIsContainerActive(false);\n setIsExiting(false);\n setCurrentAlert(null);\n setIsMounted(false);\n\n // The new alert will be picked up in the next render\n }, exitDuration);\n }\n }, [alerts, currentAlert, animationDuration, animationDurationOut, isVisible]);\n\n const handleClose = useCallback(async (value: boolean | null) => {\n if (!currentAlert || isExiting) return;\n\n // Start exit animation immediately\n setIsExiting(true);\n setIsVisible(false);\n\n // Delay the actual closeAlert call until animation completes\n const exitDuration = animationDurationOut || animationDuration;\n\n if (exitTimerRef.current) {\n clearTimeout(exitTimerRef.current);\n }\n\n exitTimerRef.current = setTimeout(() => {\n // Now call closeAlert which will resolve the promise\n closeAlert(value);\n\n // Reset state\n setIsExiting(false);\n setCurrentAlert(null);\n setIsMounted(false);\n setIsContainerActive(false);\n }, exitDuration);\n }, [currentAlert, isExiting, animationDuration, animationDurationOut]);\n\n const handleCancel = useCallback(() => {\n if (currentAlert && isVisible && !isExiting) {\n handleClose(false);\n }\n }, [currentAlert, isVisible, isExiting, handleClose]);\n\n const handleOk = useCallback(() => {\n if (currentAlert && isVisible && !isExiting) {\n handleClose(true);\n }\n }, [currentAlert, isVisible, isExiting, handleClose]);\n\n const handleEscKey = useCallback((event: KeyboardEvent) => {\n if (event.key === 'Escape' && closeOnEscape && currentAlert && isVisible && !isExiting) {\n event.preventDefault();\n event.stopPropagation();\n handleClose(null);\n }\n }, [closeOnEscape, currentAlert, isVisible, isExiting, handleClose]);\n\n useEffect(() => {\n if (currentAlert && isVisible && !isExiting) {\n window.addEventListener('keydown', handleEscKey, { capture: true });\n }\n\n return () => {\n window.removeEventListener('keydown', handleEscKey, { capture: true });\n };\n }, [handleEscKey, currentAlert, isVisible, isExiting]);\n\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n if (wrapperRef.current &&\n !wrapperRef.current.contains(event.target as Node) &&\n closeOnClickOutside &&\n currentAlert &&\n isVisible &&\n !isExiting) {\n handleClose(null);\n }\n };\n\n if (currentAlert && isVisible && !isExiting) {\n document.addEventListener(\"mousedown\", handleClickOutside);\n }\n\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [closeOnClickOutside, currentAlert, isVisible, isExiting, handleClose]);\n\n // Replace the render conditions with:\n if (!isMounted && !isExiting) {\n return nullElement;\n }\n\n if (!currentAlert || !getIsContainerActive()) {\n return nullElement;\n }\n\n // Always render if we have a current alert\n const colorSchema = currentAlert?.colorSchema || defaultColorSchema;\n const schemaClass = `schema-${colorSchema}`;\n\n const animationStyle: CSSProperties = {};\n const currentDuration = isVisible\n ? (animationDurationIn || animationDuration)\n : (animationDurationOut || animationDuration);\n\n animationStyle.animationDuration = `${currentDuration}ms`;\n animationStyle.animationFillMode = 'forwards';\n\n const animationClass = isVisible\n ? animationPairs[animation as keyof animationPairs].enter\n : animationPairs[animation as keyof animationPairs].exit;\n\n\n // For children render\n if (children && currentAlert && getActiveContainerId() === containerId.current) {\n return (\n <>\n {nullElement}\n {children({\n isVisible: isVisible && !isExiting,\n confirm: currentAlert,\n handleCancel,\n handleOk,\n containerRef: wrapperRef,\n colorSchema,\n animationClass,\n animationStyle\n })}\n </>\n )\n }\n\n return (\n <>\n {nullElement}\n <div\n ref={overlayRef}\n className={cx(\n \"alert-overlay\",\n !isVisible ? \"alert-overlay-exit\" : '',\n `${schemaClass}-overlay`,\n classes.overlay\n )}\n style={animationStyle}\n >\n <div\n ref={wrapperRef}\n className={cx(\n \"alert-wrapper\",\n animationClass,\n `${schemaClass}-wrapper`,\n classes.wrapper\n )}\n style={animationStyle}\n >\n <h2 className={cx(\n \"alert-title\",\n `${schemaClass}-title`,\n classes.title\n )}>\n {currentAlert.title}\n </h2>\n <p className={cx(\n \"alert-message\",\n `${schemaClass}-message`,\n classes.message\n )}>\n {currentAlert.message}\n </p>\n <div className=\"alert-buttons\">\n <button\n onClick={handleCancel}\n disabled={isExiting || !isVisible}\n className={cx(\n \"alert-button alert-button-cancel\",\n `${schemaClass}-cancel`,\n classes.button,\n classes.cancel\n )}\n >\n {currentAlert.cancelText || 'Cancel'}\n </button>\n <button\n onClick={handleOk}\n disabled={isExiting || !isVisible}\n className={cx(\n 'alert-button alert-button-ok',\n `${schemaClass}-ok`,\n classes.button,\n classes.ok\n )}\n >\n {currentAlert.okText || 'OK'}\n </button>\n </div>\n </div>\n </div>\n </>\n );\n};\n\nexport default ConfirmContainer;","import { addAlert, getElement } from \"./confirm_store\";\nimport type { ConfirmInput } from \"./types\";\n\nexport async function confirm(input: string | ConfirmInput): Promise<boolean | null> {\n if (typeof input === 'string') {\n const containerId = await getElement();\n const result = await addAlert({ \n message: input, \n id: containerId \n });\n return result;\n } \n \n if (!input.id) {\n const containerId = await getElement();\n const result = await addAlert({ \n ...input, \n id: containerId \n });\n return result;\n } \n \n const result = await addAlert(input);\n return result;\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-confirm-lite",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "A lightweight, promise-based confirm dialog for React, designed to be as easy to use as react-toastify, while remaining fully customizable.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -21,10 +21,11 @@
21
21
  },
22
22
  "homepage": "https://github.com/SaadNasir-git/react-confirm-lite#readme",
23
23
  "scripts": {
24
- "build": "tsup && cp LICENSE dist/",
25
- "clean": "rm -rf dist",
26
- "postbuild": "echo \"'use client';\" | cat - dist/index.js > temp && mv temp dist/index.js",
27
- "prepack": "npm run clean && npm run build"
24
+ "build": "tsup && cp LICENSE dist/",
25
+ "build:watch": "tsup --watch",
26
+ "clean": "rm -rf dist",
27
+ "postbuild": "echo \"'use client';\" | cat - dist/index.js > temp && mv temp dist/index.js",
28
+ "prepack": "npm run clean && npm run build"
28
29
  },
29
30
  "peerDependencies": {
30
31
  "react": ">=18",
@@ -38,5 +39,11 @@
38
39
  },
39
40
  "license": "MIT",
40
41
  "author": "Saad Nasir",
41
- "keywords": ["react-confirm" , "react-confirm-lite" , "react confirm lite" , "react confirm" , "confirm"]
42
+ "keywords": [
43
+ "react-confirm",
44
+ "react-confirm-lite",
45
+ "react confirm lite",
46
+ "react confirm",
47
+ "confirm"
48
+ ]
42
49
  }