customizable-toast-notification 3.4.0 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -21,23 +21,28 @@ A **lightweight**, **zero-dependency** toast notification library for modern Jav
21
21
 
22
22
  ### NPM/Yarn
23
23
 
24
+ ```bash
24
25
  npm install customizable-toast-notification
26
+ ```
25
27
 
26
28
  or
27
- yarn add customizable-toast-notification
28
29
 
29
- text
30
+ ```bash
31
+ yarn add customizable-toast-notification
32
+ ```
30
33
 
31
34
  ### CDN (UMD Build)
32
35
 
36
+ ```bash
33
37
  <script src="https://cdn.jsdelivr.net/npm/customizable-toast-notification@latest/dist/index.umd.js"></script>
34
-
35
- text
38
+ ```
36
39
 
37
40
  ## 🚀 Quick Start
38
41
 
39
42
  ### ES Modules
40
43
 
44
+ ```json
45
+
41
46
  import { createToast, setDefaultColors, setDefaultMessages } from 'customizable-toast-notification';
42
47
 
43
48
  // Simple usage
@@ -47,13 +52,16 @@ type: "success",
47
52
  duration: 3000
48
53
  });
49
54
 
50
- text
55
+ ```
51
56
 
52
57
  ### CDN/Browser
53
58
 
54
- <script src="https://cdn.jsdelivr.net/npm/customizable-toast-notification@latest/dist/index.umd.js"></script> <script> customizableToast.createToast({ message: "Hello from CDN!", type: "success", position: "top-right" }); </script>
59
+ ```json
60
+
61
+ <script src="https://cdn.jsdelivr.net/npm/customizable-toast-notification@latest/dist/index.umd.js"></script>
62
+ <script> customizableToast.createToast({ message: "Hello from CDN!", type: "success", position: "top-right" }); </script>
55
63
 
56
- text
64
+ ```
57
65
 
58
66
  ## 📖 API Reference
59
67
 
@@ -81,11 +89,17 @@ Creates and displays a toast notification.
81
89
 
82
90
  #### Position Options
83
91
 
92
+ ```josn
93
+
84
94
  - `"top-left"`, `"top-right"`, `"top-center"`
85
95
  - `"bottom-left"`, `"bottom-right"`, `"bottom-center"`
86
96
 
97
+ ```
98
+
87
99
  ### `setDefaultColors(colors)`
88
100
 
101
+ ```json
102
+
89
103
  Configure default colors for toast types.
90
104
 
91
105
  setDefaultColors({
@@ -95,10 +109,11 @@ warning: "#f59e0b",
95
109
  info: "#3b82f6"
96
110
  });
97
111
 
98
- text
112
+ ```
99
113
 
100
114
  ### `setDefaultMessages(messages)`
101
115
 
116
+ ```json
102
117
  Configure default messages for toast types.
103
118
 
104
119
  setDefaultMessages({
@@ -108,12 +123,13 @@ warning: "Please check your input!",
108
123
  info: "Here's some information!"
109
124
  });
110
125
 
111
- text
126
+ ```
112
127
 
113
128
  ## 💡 Examples
114
129
 
115
130
  ### Basic Toast Types
116
131
 
132
+ ```json
117
133
  // Success
118
134
  createToast({ type: "success", message: "Data saved!" });
119
135
 
@@ -126,10 +142,11 @@ createToast({ type: "warning", message: "Please confirm!" });
126
142
  // Info
127
143
  createToast({ type: "info", message: "New update available!" });
128
144
 
129
- text
145
+ ```
130
146
 
131
147
  ### Advanced Customization
132
148
 
149
+ ```json
133
150
  createToast({
134
151
  message: "File uploading...",
135
152
  type: "info",
@@ -145,8 +162,6 @@ animationDuration: "0.8s",
145
162
  animationEasing: "ease-out"
146
163
  });
147
164
 
148
- text
149
-
150
165
  ### App-wide Configuration
151
166
 
152
167
  // Set your brand colors once
@@ -168,7 +183,7 @@ info: "💡 Info! Here's a tip."
168
183
  // Now just use types throughout your app
169
184
  createToast({ type: "success" }); // Uses your custom colors & messages
170
185
 
171
- text
186
+ ```
172
187
 
173
188
  ## 🛡️ Reliability Features
174
189
 
@@ -200,12 +215,14 @@ Exciting times ahead! Looking for sponsors and eager to explore new collaboratio
200
215
 
201
216
  ### Development Setup
202
217
 
218
+ ```bash
219
+
203
220
  git clone https://github.com/sammy-cool/customizable-toast-notification.git
204
221
  cd customizable-toast-notification
205
222
  npm install
206
223
  npm run build
207
224
 
208
- text
225
+ ```
209
226
 
210
227
  ## 📄 License
211
228
 
package/dist/index.cjs ADDED
@@ -0,0 +1,16 @@
1
+ /*!
2
+ * Customizable Toast Notifications 3.5.1
3
+ * Build: 2025-08-27 18:05:24
4
+ * Cache-Buster: 1756317924370
5
+ * Author: Priyanshu Patel
6
+ * Email: priyanshu.alt191@gmail.com
7
+ * License: Apache-2.0
8
+ * Dependencies: None
9
+ * Created: July 31, 2024
10
+ * A lightweight and fully customizable toast notification library
11
+ * designed for seamless integration with any JavaScript or framework-based UI.
12
+ * Supports flexible positioning, theming, icons, animations, and timing options
13
+ * out of the box — with zero dependencies.
14
+ */
15
+ "use strict";async function t(t){return`${t}-${Date.now()}-${Math.floor(1e5*Math.random())}`}async function e(t){try{let e=document.getElementById(`toast-container-${t}`);return e||(e=document.createElement("div"),e.id=`toast-container-${t}`,e.style.position="fixed",e.style.zIndex="9999",await async function(t,e){t.style.top="auto",t.style.bottom="auto",t.style.left="auto",t.style.right="auto",t.style.transform="none",e.includes("bottom")?t.style.bottom="10px":e.includes("top")&&(t.style.top="10px"),e.includes("right")?t.style.right="10px":e.includes("left")?t.style.left="10px":e.includes("center")&&(t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)")}(e,t),await async function(t,e){if(!t||!e)return!1;try{return t.contains(e)||t.appendChild(e),!0}catch(n){try{return t.insertAdjacentElement("beforeend",e),!0}catch(n){try{if(t===document.body)return e.style.position="fixed",e.style.top="10px",e.style.right="10px",e.style.zIndex="99999",document.body.insertAdjacentHTML("beforeend",e.outerHTML||""),!0}catch(t){return!1}}}return!1}(document.body,e)),e}catch(t){return document.body}}function n(t,e,n){const o=function(t){try{if("number"==typeof t&&t>0)return t;if("string"==typeof t){if(t.endsWith("s")&&!t.endsWith("ms")){const e=1e3*parseFloat(t);return e>0?e:500}const e=parseFloat(t);return e>0?e:500}}catch(t){}return 500}(e.animationDuration);Object.assign(t.style,{background:e.backgroundColor||e.color||"#333",color:e.textColor||"white",padding:"12px 20px",marginBottom:"10px",borderRadius:"5px",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",minWidth:"250px",maxWidth:"400px",opacity:"0",position:"relative",transition:`opacity ${o||"0.5s"} ${e.animationEasing||"ease"}, transform ${o||"0.5s"} ${e.animationEasing||"ease"}`,transform:"translateY(20px)",zIndex:"9999"}),t._animationDuration=o;const r=document.createElement("span");r.textContent=e.message||"Notification",r.style.flex="1",t.appendChild(r),e.showCloseButton&&function(t,e,n){const o=document.createElement("button");o.innerHTML="&times;",Object.assign(o.style,{background:"none",border:"none",color:e.textColor||"white",fontSize:"18px",marginLeft:"10px",cursor:"pointer"}),o.onclick=()=>n(t),t.appendChild(o),t._cleanupCloseButton=()=>{o.onclick=null}}(t,e,n),e.showProgressBar&&function(t,e){const n=document.createElement("div");Object.assign(n.style,{position:"absolute",left:"0",height:e.progressHeight||"4px",background:e.progressColor||"rgba(255, 255, 255, 0.3)",width:"100%",transition:`width ${e.duration||1800}ms linear`,["top"===e.progressPosition?"top":"bottom"]:"0"}),t.appendChild(n),setTimeout(()=>{!function(t){try{return t?.offsetWidth||0}catch(t){return 0}}(n),n.style.width="0%"},100)}(t,e),function(t){setTimeout(()=>{t.style.opacity="1",t.style.transform="translateY(0)"},50)}(t)}function o(t,e){try{const n=document.createElement("div");return n.id=`emergency-${Date.now()}`,n.innerHTML=`\n <div style="\n background: #333 !important;\n color: white !important;\n padding: 10px 15px !important;\n position: fixed !important;\n top: 20px !important;\n right: 20px !important;\n z-index: 99999 !important;\n border-radius: 3px !important;\n max-width: 250px !important;\n word-wrap: break-word !important;\n font-family: Arial, sans-serif !important;\n font-size: 14px !important;\n box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;\n cursor: pointer !important;\n " onclick="this.parentNode.removeChild(this)">\n ${t.message||"Emergency Toast Creation Showing!"}\n <span style="float: right; margin-left: 10px; font-weight: bold;">&times;</span>\n </div>\n `,n._animationDuration=500,n._isEmergencyToast=!0,setTimeout(()=>{try{n.parentNode&&n.parentNode.removeChild(n),e(n)}catch(t){}},t.duration||1800),n}catch(n){return setTimeout(()=>{try{alert(t.message||"Toast Creation Failed!"),e(null)}catch(t){e(null)}},100),null}}async function r(e,r){let a;if(!document.querySelector('[id^="toast-container-"]'))return null;try{return a=await async function(e,n){try{if(!e||!n)throw new Error("tagName and prefix is required");const o=document.createElement(e);return o.id=t(n),o}catch(e){try{const e="div",n="fallback",o=document.createElement(e);return o.id=t(n),o.setAttribute("data-original-tag",e),o}catch(t){}}}("div","toast"),n(a,e,r),a}catch(t){return o(e,r),a}}Object.defineProperty(exports,"__esModule",{value:!0});let a=[],i=[];async function s(t){try{const n=await e(t.position),o=await r(t,c);if(!o)throw new Error("Toast element creation failed!");a.push(o),n.id.includes("toast-container-")&&n.appendChild(o);const s="number"==typeof t.duration&&t.duration>0?t.duration+2:1800,l=await async function(t,e){return setTimeout(()=>{t()},e)}(()=>c(o),s);return void i.push(l)}catch(e){const n=document.querySelector('[id^="toast-container-"]'),r=o(t,c);return void(n&&n?.id?.includes("toast-container-")?n.appendChild(r):alert(e.substring(0,200)))}}async function c(t){if(a.length>0){const e=a.indexOf(t);-1!==e&&a.splice(e,1)}await async function(t){if(!t)return!0;try{if(t?.parentNode?.id.includes("toast-container-"))return t.parentNode.removeChild(t),!0}catch(e){try{if(t.remove)return t.remove(),!0}catch(e){try{return t.style.display="none",t.style.opacity="0",t.style.pointerEvents="none",t.style.position="absolute",t.style.left="-9999px",!0}catch(t){return!1}}}return!0}(t)}let l={success:"#28a745",error:"#dc3545",warning:"#ffc107",info:"#17a2b8"},u={success:"Operation completed successfully!",error:"Something went wrong!",warning:"Warning message!",info:"Information message!"};async function d(t={}){try{const e=await async function(t){const e={duration:1800,position:"bottom-right",type:"info",backgroundColor:void 0,textColor:"white",showCloseButton:!1,animationDuration:"0.5s",animationEasing:"ease",showProgressBar:!1,progressColor:void 0,progressHeight:"4px",progressPosition:"bottom"};let n={...e};t&&"object"==typeof t&&!Array.isArray(t)&&(Object.keys(e).forEach(e=>{t.hasOwnProperty(e)&&(n[e]=t[e])}),void 0===t.message&&"undefined"===t.message||(n.message=t.message));try{!n.backgroundColor&&n.type&&l[n.type]&&(n.backgroundColor=l[n.type]),!n.message&&n.type&&u[n.type]&&(n.message=u[n.type])}catch(t){}n.message&&"string"==typeof n.message||(n.message="No Message Provided!");return n}(t);await s(e)}catch(e){const n="string"==typeof t?.message?`${t.message.substring(0,200)} toast creation failed!`:"Toast creation failed!";alert(n)}}function p(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(l={...l,...t})}catch(t){}}function y(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(u={...u,...t})}catch(t){}}try{"undefined"!=typeof window&&(window.customizableToast={createToast:d,setDefaultColors:p,setDefaultMessages:y})}catch(t){}exports.createToast=d,exports.noop=function(){c(document.querySelector('[id^="toast-"]:not([id*="container"])'))},exports.setDefaultColors=p,exports.setDefaultMessages=y;
16
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/utils/id.js","../src/components/ToastContainer.js","../src/utils/position.js","../src/utils/dom.js","../src/components/toast-utils.js","../src/components/Toast.js","../src/components/ToastManager.js","../src/index.js"],"sourcesContent":["// src/utils/id.js\r\n\"use strict\";\r\n\r\n/**\r\n * Generate unique ID for DOM elements to avoid conflicts\r\n * @param {string} prefix - Optional prefix for ID\r\n * @returns {string} Unique ID\r\n */\r\nexport async function generateUniqueId(prefix) {\r\n return `${prefix}-${Date.now()}-${Math.floor(Math.random() * 100000)}`;\r\n}\r\n","// src/components/ToastContainer.js //# Container logic\r\n\"use strict\";\r\n\r\nimport { setPosition } from \"../utils/position.js\";\r\nimport { appendChild } from \"../utils/dom.js\";\r\n\r\n/**\r\n * Create toast container with error handling\r\n * @param {string} position - Toast position\r\n * @returns {HTMLElement} Toast container element\r\n */\r\nexport async function createToastContainer(position) {\r\n try {\r\n let toastContainer = document.getElementById(`toast-container-${position}`);\r\n\r\n if (!toastContainer) {\r\n toastContainer = document.createElement(\"div\");\r\n toastContainer.id = `toast-container-${position}`;\r\n toastContainer.style.position = \"fixed\";\r\n toastContainer.style.zIndex = \"9999\";\r\n await setPosition(toastContainer, position);\r\n await appendChild(document.body, toastContainer);\r\n }\r\n\r\n return toastContainer;\r\n } catch (error) {\r\n console.error(\"Failed to create toast container:\", error);\r\n // Fallback: return body element\r\n return document.body;\r\n }\r\n}\r\n","// src/utils/position.js\r\n\"use strict\";\r\n\r\n/**\r\n * Set position for toast container (EXACT same logic as original)\r\n * @param {HTMLElement} container - Toast container element\r\n * @param {string} position - Position string\r\n */\r\nexport async function setPosition(container, position) {\r\n // Reset all position properties first\r\n container.style.top = \"auto\";\r\n container.style.bottom = \"auto\";\r\n container.style.left = \"auto\";\r\n container.style.right = \"auto\";\r\n container.style.transform = \"none\";\r\n\r\n if (position.includes(\"bottom\")) {\r\n container.style.bottom = \"10px\";\r\n } else if (position.includes(\"top\")) {\r\n container.style.top = \"10px\";\r\n }\r\n\r\n if (position.includes(\"right\")) {\r\n container.style.right = \"10px\";\r\n } else if (position.includes(\"left\")) {\r\n container.style.left = \"10px\";\r\n } else if (position.includes(\"center\")) {\r\n container.style.top = \"50%\";\r\n container.style.left = \"50%\";\r\n container.style.transform = \"translate(-50%, -50%)\";\r\n }\r\n}\r\n","// src/utils/dom.js\r\n\"use strict\";\r\n\r\nimport { generateUniqueId } from \"./id.js\";\r\n\r\n/**\r\n * Multi-layer fallback DOM element creation\r\n */\r\nexport async function createElementWithId(tagName, prefix) {\r\n // PRIMARY: Standard createElement\r\n try {\r\n if (!tagName || !prefix) throw new Error(`tagName and prefix is required`);\r\n\r\n const el = document.createElement(tagName);\r\n el.id = generateUniqueId(prefix);\r\n return el;\r\n } catch (error) {\r\n console.warn(`Primary createElement failed for`, error);\r\n\r\n // FALLBACK-A: Try div as alternative\r\n try {\r\n const fallbackTag = \"div\";\r\n const fallbackPrefix = \"fallback\";\r\n const fallbackEl = document.createElement(fallbackTag);\r\n fallbackEl.id = generateUniqueId(fallbackPrefix);\r\n fallbackEl.setAttribute(\"data-original-tag\", fallbackTag);\r\n return fallbackEl;\r\n } catch (fallbackError) {\r\n console.error(\"All DOM creation methods failed:\", fallbackError);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Multi-strategy appendChild with graceful degradation\r\n */\r\nexport async function appendChild(parent, child) {\r\n if (!parent || !child) return false;\r\n\r\n // PRIMARY: Standard appendChild\r\n try {\r\n if (!parent.contains(child)) {\r\n parent.appendChild(child);\r\n return true;\r\n }\r\n return true;\r\n } catch (error) {\r\n console.warn(\"Primary appendChild failed:\", error);\r\n\r\n // FALLBACK-A: insertAdjacentElement\r\n try {\r\n parent.insertAdjacentElement(\"beforeend\", child);\r\n return true;\r\n } catch (fallbackError) {\r\n console.warn(\"Fallback appendChild failed:\", fallbackError);\r\n\r\n // FALLBACK-B: Manual positioning\r\n try {\r\n if (parent === document.body) {\r\n child.style.position = \"fixed\";\r\n child.style.top = \"10px\";\r\n child.style.right = \"10px\";\r\n child.style.zIndex = \"99999\";\r\n document.body.insertAdjacentHTML(\"beforeend\", child.outerHTML || \"\");\r\n return true;\r\n }\r\n } catch (emergencyError) {\r\n console.error(\"All append strategies failed:\", emergencyError);\r\n return false;\r\n }\r\n }\r\n }\r\n return false;\r\n}\r\n\r\n/**\r\n * Safe element removal with multiple strategies\r\n */\r\nexport async function removeElement(el) {\r\n if (!el) return true;\r\n\r\n // PRIMARY: parentNode.removeChild\r\n try {\r\n if (el?.parentNode?.id.includes(\"toast-container-\")) {\r\n el.parentNode.removeChild(el);\r\n return true;\r\n }\r\n } catch (error) {\r\n console.warn(\"Primary removal failed:\", error);\r\n\r\n // FALLBACK-A: element.remove()\r\n try {\r\n if (el.remove) {\r\n el.remove();\r\n return true;\r\n }\r\n } catch (fallbackError) {\r\n console.warn(\"Fallback removal failed:\", fallbackError);\r\n\r\n // FALLBACK-B: Hide instead of remove\r\n try {\r\n el.style.display = \"none\";\r\n el.style.opacity = \"0\";\r\n el.style.pointerEvents = \"none\";\r\n el.style.position = \"absolute\";\r\n el.style.left = \"-9999px\";\r\n return true;\r\n } catch (hideError) {\r\n console.error(\"All removal strategies failed:\", hideError);\r\n return false;\r\n }\r\n }\r\n }\r\n return true;\r\n}\r\n\r\n/**\r\n * Animation duration parser with fallbacks\r\n */\r\nexport function parseAnimationDuration(duration) {\r\n // PRIMARY: Parse provided duration\r\n try {\r\n if (typeof duration === \"number\" && duration > 0) return duration;\r\n if (typeof duration === \"string\") {\r\n if (duration.endsWith(\"s\") && !duration.endsWith(\"ms\")) {\r\n const parsed = parseFloat(duration) * 1000;\r\n return parsed > 0 ? parsed : 500;\r\n }\r\n const parsed = parseFloat(duration);\r\n return parsed > 0 ? parsed : 500;\r\n }\r\n } catch (error) {\r\n console.warn(\"Duration parsing failed:\", error);\r\n }\r\n\r\n // FALLBACK: Safe default\r\n return 500;\r\n}\r\n\r\n/**\r\n * Force reflow with error protection\r\n */\r\nexport function forceReflow(el) {\r\n try {\r\n return el?.offsetWidth || 0;\r\n } catch (error) {\r\n console.warn(\"Force reflow failed:\", error);\r\n return 0;\r\n }\r\n}\r\n\r\n/**\r\n * Query selector shortcut with optional root.\r\n * @param {string} selector\r\n * @param {Document|HTMLElement} [root=document]\r\n * @returns {Element|null}\r\n */\r\nexport function query(selector, root = document) {\r\n return root.querySelector(selector);\r\n}\r\n","\"use strict\";\r\n\r\nimport { forceReflow, parseAnimationDuration } from \"../utils/dom.js\";\r\n\r\n/**\r\n * Create close button for toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport function createCloseButton(toast, options, onClose) {\r\n const closeButton = document.createElement(\"button\");\r\n closeButton.innerHTML = \"&times;\";\r\n Object.assign(closeButton.style, {\r\n background: \"none\",\r\n border: \"none\",\r\n color: options.textColor || \"white\",\r\n fontSize: \"18px\",\r\n marginLeft: \"10px\",\r\n cursor: \"pointer\",\r\n });\r\n\r\n closeButton.onclick = () => onClose(toast);\r\n toast.appendChild(closeButton);\r\n\r\n toast._cleanupCloseButton = () => {\r\n closeButton.onclick = null;\r\n };\r\n}\r\n\r\n/**\r\n * Create progress bar for toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n */\r\nexport function createProgressBar(toast, options) {\r\n const progressBar = document.createElement(\"div\");\r\n Object.assign(progressBar.style, {\r\n position: \"absolute\",\r\n left: \"0\",\r\n height: options.progressHeight || \"4px\",\r\n background: options.progressColor || \"rgba(255, 255, 255, 0.3)\",\r\n width: \"100%\",\r\n transition: `width ${options.duration || 1800}ms linear`,\r\n [options.progressPosition === \"top\" ? \"top\" : \"bottom\"]: \"0\",\r\n });\r\n\r\n toast.appendChild(progressBar);\r\n\r\n setTimeout(() => {\r\n forceReflow(progressBar);\r\n progressBar.style.width = \"0%\";\r\n }, 100);\r\n}\r\n\r\n/**\r\n * Run toast fade-in animation\r\n * @param {HTMLElement} toast - Toast element\r\n */\r\nexport function runToastAnimation(toast) {\r\n setTimeout(() => {\r\n toast.style.opacity = \"1\";\r\n toast.style.transform = \"translateY(0)\";\r\n }, 50);\r\n}\r\n\r\n/**\r\n * Apply rich styling to toast element\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport function applyRichStyling(toast, options, onClose) {\r\n const animDurationMs = parseAnimationDuration(options.animationDuration);\r\n\r\n // Apply full styling\r\n Object.assign(toast.style, {\r\n background: options.backgroundColor || options.color || \"#333\",\r\n color: options.textColor || \"white\",\r\n padding: \"12px 20px\",\r\n marginBottom: \"10px\",\r\n borderRadius: \"5px\",\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n justifyContent: \"space-between\",\r\n boxShadow: \"0 4px 6px rgba(0, 0, 0, 0.1)\",\r\n minWidth: \"250px\",\r\n maxWidth: \"400px\",\r\n opacity: \"0\",\r\n position: \"relative\",\r\n transition: `opacity ${animDurationMs || \"0.5s\"} ${\r\n options.animationEasing || \"ease\"\r\n }, transform ${animDurationMs || \"0.5s\"} ${\r\n options.animationEasing || \"ease\"\r\n }`,\r\n transform: \"translateY(20px)\",\r\n zIndex: \"9999\",\r\n });\r\n\r\n toast._animationDuration = animDurationMs;\r\n\r\n // Message span\r\n const messageSpan = document.createElement(\"span\");\r\n messageSpan.textContent = options.message || \"Notification\";\r\n messageSpan.style.flex = \"1\";\r\n toast.appendChild(messageSpan);\r\n\r\n // Close button\r\n if (options.showCloseButton) {\r\n createCloseButton(toast, options, onClose);\r\n }\r\n\r\n // Progress bar\r\n if (options.showProgressBar) {\r\n createProgressBar(toast, options);\r\n }\r\n\r\n // Animation\r\n runToastAnimation(toast);\r\n}\r\n\r\n/**\r\n * Create basic fallback toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport function createBasicToast(toast, options, onClose) {\r\n // Basic styling only\r\n Object.assign(toast.style, {\r\n background: \"#333\",\r\n color: \"white\",\r\n padding: \"10px 15px\",\r\n margin: \"10px\",\r\n borderRadius: \"3px\",\r\n position: \"fixed\",\r\n top: \"20px\",\r\n right: \"20px\",\r\n zIndex: \"99999\",\r\n maxWidth: \"300px\",\r\n wordWrap: \"break-word\",\r\n });\r\n\r\n toast.textContent = options.message || \"Notification\";\r\n\r\n if (options.showCloseButton) {\r\n toast.style.cursor = \"pointer\";\r\n toast.onclick = () => onClose(toast);\r\n }\r\n\r\n toast._animationDuration = 500;\r\n}\r\n\r\n/**\r\n * Emergency toast as last resort\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport function createEmergencyToast(options, onClose) {\r\n try {\r\n // Create emergency div\r\n const emergency = document.createElement(\"div\");\r\n emergency.id = `emergency-${Date.now()}`;\r\n emergency.innerHTML = `\r\n <div style=\"\r\n background: #333 !important;\r\n color: white !important;\r\n padding: 10px 15px !important;\r\n position: fixed !important;\r\n top: 20px !important;\r\n right: 20px !important;\r\n z-index: 99999 !important;\r\n border-radius: 3px !important;\r\n max-width: 250px !important;\r\n word-wrap: break-word !important;\r\n font-family: Arial, sans-serif !important;\r\n font-size: 14px !important;\r\n box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;\r\n cursor: pointer !important;\r\n \" onclick=\"this.parentNode.removeChild(this)\">\r\n ${options.message || \"Emergency Toast Creation Showing!\"}\r\n <span style=\"float: right; margin-left: 10px; font-weight: bold;\">&times;</span>\r\n </div>\r\n `;\r\n\r\n emergency._animationDuration = 500;\r\n emergency._isEmergencyToast = true;\r\n\r\n // Auto remove\r\n setTimeout(() => {\r\n try {\r\n if (emergency.parentNode) {\r\n emergency.parentNode.removeChild(emergency);\r\n }\r\n onClose(emergency);\r\n } catch (error) {\r\n console.warn(\"Emergency cleanup failed:\", error);\r\n }\r\n }, options.duration || 1800);\r\n\r\n return emergency;\r\n } catch (emergencyError) {\r\n console.error(\"Emergency toast creation failed:\", emergencyError);\r\n\r\n // ULTIMATE FALLBACK: Alert\r\n setTimeout(() => {\r\n try {\r\n alert(options.message || \"Toast Creation Failed!\");\r\n onClose(null);\r\n } catch (alertError) {\r\n console.error(\"Ultimate fallback failed:\", alertError);\r\n onClose(null);\r\n }\r\n }, 100);\r\n\r\n return null;\r\n }\r\n}\r\n\r\nexport async function safeSetTimeout(fn, delay) {\r\n const id = setTimeout(() => {\r\n console.warn(\"Timer fired after\", delay, \"ms\");\r\n fn();\r\n }, delay);\r\n\r\n console.warn(\"Timer scheduled with id:\", id, \"delay:\", delay);\r\n return id;\r\n}\r\n","// src/components/Toast.js //# Single responsibility\r\n\"use strict\";\r\n\r\nimport { createElementWithId } from \"../utils/dom.js\";\r\nimport { applyRichStyling, createEmergencyToast } from \"./toast-utils.js\";\r\n\r\n/**\r\n * Multi-layer toast creation with satellite-grade fallbacks\r\n * @param {Object} options - Toast configuration options\r\n * @param {Function} onClose - Callback when toast closes\r\n * @returns {HTMLElement} Toast element\r\n */\r\nexport async function createToastElement(options, onClose) {\r\n let toastContainer = document.querySelector('[id^=\"toast-container-\"]');\r\n if (!toastContainer) return null;\r\n\r\n let toast;\r\n const tagName = \"div\";\r\n const prefix = \"toast\";\r\n\r\n // PRIMARY: Full-featured toast\r\n try {\r\n toast = await createElementWithId(tagName, prefix);\r\n applyRichStyling(toast, options, onClose);\r\n return toast;\r\n } catch (error) {\r\n console.warn(\"error:\", error);\r\n createEmergencyToast(options, onClose);\r\n return toast;\r\n }\r\n}\r\n","// src/components/ToastManager.js //# State management\r\n\"use strict\";\r\n\r\nimport { createToastContainer } from \"./ToastContainer.js\";\r\nimport { createToastElement } from \"./Toast.js\";\r\nimport { removeElement } from \"../utils/dom.js\";\r\nimport { createEmergencyToast, safeSetTimeout } from \"./toast-utils.js\";\r\n\r\n// State management with fallback tracking\r\nlet isToastShowing = false;\r\nlet emergencyCleanupScheduled = false;\r\nlet currentToast = [];\r\nlet emergencyTimeouts = [];\r\n\r\n/**\r\n * Show toast with comprehensive fallback system\r\n */\r\nexport async function showToast(options) {\r\n // PRIMARY: Full toast system\r\n try {\r\n const container = await createToastContainer(options.position);\r\n const toast = await createToastElement(options, closeToast);\r\n\r\n if (!toast) {\r\n throw new Error(\"Toast element creation failed!\");\r\n }\r\n\r\n currentToast.push(toast);\r\n\r\n // Append to container\r\n if (container.id.includes(\"toast-container-\")) {\r\n container.appendChild(toast);\r\n }\r\n\r\n // Schedule auto-dismiss\r\n const cleanUpTime =\r\n typeof options.duration === \"number\" && options.duration > 0\r\n ? options.duration + 2\r\n : 1800; //safety margin\r\n const dismissTimeout = await safeSetTimeout(\r\n () => closeToast(toast),\r\n cleanUpTime\r\n );\r\n emergencyTimeouts.push(dismissTimeout);\r\n return;\r\n } catch (primaryError) {\r\n console.warn(\r\n \"Primary toast system failed showing emergency toast:\",\r\n primaryError\r\n );\r\n const elContainer = document.querySelector('[id^=\"toast-container-\"]');\r\n const emergencyToast = createEmergencyToast(options, closeToast);\r\n elContainer && elContainer?.id?.includes(\"toast-container-\")\r\n ? elContainer.appendChild(emergencyToast)\r\n : alert(primaryError.substring(0, 200));\r\n return;\r\n }\r\n}\r\n\r\n/**\r\n * Create simple toast for fallback\r\n */\r\nfunction createSimpleToast(options) {\r\n const simple = document.createElement(\"div\");\r\n simple.style.cssText = `\r\n position: fixed !important;\r\n top: 20px !important;\r\n right: 20px !important;\r\n background: #333 !important;\r\n color: white !important;\r\n padding: 12px 20px !important;\r\n border-radius: 5px !important;\r\n z-index: 99999 !important;\r\n max-width: 300px !important;\r\n font-family: Arial, sans-serif !important;\r\n cursor: pointer !important;\r\n `;\r\n simple.textContent = options.message || \"Created Simple Toast!\";\r\n simple.onclick = () => closeToast(simple);\r\n return simple;\r\n}\r\n\r\n/**\r\n * Close toast with multi-strategy cleanup\r\n */\r\nexport async function closeToast(toast) {\r\n if (currentToast.length > 0) {\r\n const index = currentToast.indexOf(toast);\r\n if (index !== -1) {\r\n currentToast.splice(index, 1);\r\n }\r\n }\r\n await removeElement(toast);\r\n}\r\n\r\n/**\r\n * Perform comprehensive cleanup\r\n */\r\nasync function performCleanup(toast) {\r\n try {\r\n // Cleanup event listeners\r\n if (toast._cleanupCloseButton) {\r\n toast._cleanupCloseButton();\r\n }\r\n\r\n // Remove from DOM\r\n removeElement(toast);\r\n\r\n // Reset state\r\n resetToastState();\r\n } catch (error) {\r\n console.error(\"Cleanup failed:\", error);\r\n forceEmergencyCleanup();\r\n }\r\n}\r\n\r\n/**\r\n * Reset all toast state\r\n */\r\nfunction resetToastState() {\r\n isToastShowing = false;\r\n currentToast = [];\r\n\r\n // Clear all timeouts\r\n emergencyTimeouts.forEach((id) => {\r\n try {\r\n clearTimeout(id);\r\n } catch (error) {\r\n console.warn(\"Timeout clear failed:\", error);\r\n }\r\n });\r\n emergencyTimeouts.pop();\r\n emergencyCleanupScheduled = false;\r\n}\r\n\r\n/**\r\n * Schedule emergency cleanup\r\n */\r\nfunction scheduleEmergencyCleanup(duration) {\r\n const cleanUpTime = typeof duration === \"number\" ? duration + 2 : 1800; //safety margin\r\n const emergencyTimeout = setTimeout(() => {\r\n console.warn(\"Emergency cleanup triggered\");\r\n forceEmergencyCleanup();\r\n }, cleanUpTime);\r\n\r\n emergencyTimeouts.push(emergencyTimeout);\r\n}\r\n\r\n/**\r\n * Force emergency cleanup of everything\r\n */\r\nasync function forceEmergencyCleanup() {\r\n try {\r\n // Remove current toast\r\n if (currentToast) {\r\n removeElement(currentToast);\r\n }\r\n\r\n // Clean up any orphaned toast elements\r\n const orphanedToasts = document.querySelectorAll(\r\n '[id^=\"toast-\"]:not([id*=\"container\"]), [id*=\"emergency\"]'\r\n );\r\n orphanedToasts.forEach((element) => {\r\n try {\r\n removeElement(element);\r\n } catch (error) {\r\n console.warn(\"Orphaned element cleanup failed:\", error);\r\n }\r\n });\r\n\r\n // Reset all state\r\n resetToastState();\r\n } catch (error) {\r\n console.error(\"Force cleanup failed:\", error);\r\n // Final state reset\r\n isToastShowing = false;\r\n currentToast = [];\r\n }\r\n}\r\n","// src/index.js\r\n/**\r\n * @fileoverview A simple toast notification library for any JavaScript framework.\r\n * @name Customizable Toast Notifications\r\n * @author Priyanshu Patel\r\n * @version __VERSION__\r\n * @build Production\r\n * @license Apache-2.0\r\n * @depends None\r\n * @description A lightweight and fully customizable toast notification library\r\n * designed for seamless integration with any JavaScript or framework-based UI.\r\n * Supports flexible positioning, theming, icons, animations, and timing options\r\n * out of the box — with zero dependencies.\r\n * Author: Priyanshu Patel\r\n * Email: priyanshu.alt191@gmail.com\r\n * Created: July 31, 2024\r\n * License: Apache-2.0\r\n * Dependencies: None\r\n */\r\n\r\n\"use strict\";\r\n\r\nimport { closeToast, showToast } from \"./components/ToastManager.js\";\r\n\r\n// Protected state with fallbacks\r\nlet defaultColors = {\r\n success: \"#28a745\",\r\n error: \"#dc3545\",\r\n warning: \"#ffc107\",\r\n info: \"#17a2b8\",\r\n};\r\n\r\nlet defaultMessages = {\r\n success: \"Operation completed successfully!\",\r\n error: \"Something went wrong!\",\r\n warning: \"Warning message!\",\r\n info: \"Information message!\",\r\n};\r\n\r\n/**\r\n * Create toast with satellite-grade reliability\r\n */\r\nasync function createToast(options = {}) {\r\n try {\r\n // Input sanitization and validation\r\n const sanitizedOptions = await sanitizeToastOptions(options);\r\n\r\n // Call main toast system\r\n await showToast(sanitizedOptions);\r\n } catch (error) {\r\n console.error(\"CreateToast failed:\", error);\r\n\r\n // ULTIMATE FALLBACK: Browser alert with sanitized message\r\n const safeMessage =\r\n typeof options?.message === \"string\"\r\n ? `${options.message.substring(0, 200)} toast creation failed!`\r\n : \"Toast creation failed!\";\r\n\r\n alert(safeMessage);\r\n }\r\n}\r\n\r\n// Params sanitization and validation for toast creation\r\nasync function sanitizeToastOptions(options) {\r\n const defaults = {\r\n duration: 1800,\r\n position: \"bottom-right\",\r\n type: \"info\",\r\n backgroundColor: undefined,\r\n textColor: \"white\",\r\n showCloseButton: false,\r\n animationDuration: \"0.5s\",\r\n animationEasing: \"ease\",\r\n showProgressBar: false,\r\n progressColor: undefined,\r\n progressHeight: \"4px\",\r\n progressPosition: \"bottom\",\r\n };\r\n\r\n // Start with safe defaults\r\n let final = { ...defaults };\r\n\r\n // Merge user options safely\r\n if (options && typeof options === \"object\" && !Array.isArray(options)) {\r\n Object.keys(defaults).forEach((key) => {\r\n if (options.hasOwnProperty(key)) {\r\n final[key] = options[key];\r\n }\r\n });\r\n\r\n // Handle message separately\r\n if (options.message !== undefined || options.message !== \"undefined\") {\r\n final.message = options.message;\r\n }\r\n }\r\n\r\n // Validate and apply defaults\r\n try {\r\n if (!final.backgroundColor && final.type && defaultColors[final.type]) {\r\n final.backgroundColor = defaultColors[final.type];\r\n }\r\n\r\n if (!final.message && final.type && defaultMessages[final.type]) {\r\n final.message = defaultMessages[final.type];\r\n }\r\n } catch (error) {\r\n console.warn(\"Option processing failed:\", error);\r\n }\r\n\r\n // Final safety checks\r\n if (!final.message || typeof final.message !== \"string\") {\r\n final.message = \"No Message Provided!\";\r\n }\r\n\r\n // should dlt if (typeof final.duration !== \"number\" || final.duration < 100) {\r\n // final.duration = defaults.duration;\r\n // }\r\n\r\n return final;\r\n}\r\n\r\n/**\r\n * Set default colors with validation\r\n */\r\nfunction setDefaultColors(colors) {\r\n try {\r\n if (colors && typeof colors === \"object\" && !Array.isArray(colors)) {\r\n defaultColors = { ...defaultColors, ...colors };\r\n }\r\n } catch (error) {\r\n console.error(\"setDefaultColors failed:\", error);\r\n }\r\n}\r\n\r\n/**\r\n * Set default messages with validation\r\n */\r\nfunction setDefaultMessages(messages) {\r\n try {\r\n if (messages && typeof messages === \"object\" && !Array.isArray(messages)) {\r\n defaultMessages = { ...defaultMessages, ...messages };\r\n }\r\n } catch (error) {\r\n console.error(\"setDefaultMessages failed:\", error);\r\n }\r\n}\r\n\r\nfunction noop() {\r\n const toast = document.querySelector('[id^=\"toast-\"]:not([id*=\"container\"])');\r\n closeToast(toast);\r\n}\r\n\r\n// Module exports\r\nexport { createToast, setDefaultColors, setDefaultMessages, noop };\r\n\r\n// Global assignment with protection\r\ntry {\r\n // UMD/Global support\r\n if (typeof window !== \"undefined\") {\r\n window.customizableToast = {\r\n createToast,\r\n setDefaultColors,\r\n setDefaultMessages,\r\n };\r\n }\r\n} catch (error) {\r\n console.error(\"Global assignment failed:\", error);\r\n}\r\n"],"names":["async","generateUniqueId","prefix","Date","now","Math","floor","random","createToastContainer","position","toastContainer","document","getElementById","createElement","id","style","zIndex","container","top","bottom","left","right","transform","includes","setPosition","parent","child","contains","appendChild","error","insertAdjacentElement","fallbackError","body","insertAdjacentHTML","outerHTML","emergencyError","applyRichStyling","toast","options","onClose","animDurationMs","duration","endsWith","parsed","parseFloat","parseAnimationDuration","animationDuration","Object","assign","background","backgroundColor","color","textColor","padding","marginBottom","borderRadius","display","alignItems","justifyContent","boxShadow","minWidth","maxWidth","opacity","transition","animationEasing","_animationDuration","messageSpan","textContent","message","flex","showCloseButton","closeButton","innerHTML","border","fontSize","marginLeft","cursor","onclick","_cleanupCloseButton","createCloseButton","showProgressBar","progressBar","height","progressHeight","progressColor","width","progressPosition","setTimeout","el","offsetWidth","forceReflow","createProgressBar","runToastAnimation","createEmergencyToast","emergency","_isEmergencyToast","parentNode","removeChild","alert","alertError","createToastElement","querySelector","tagName","Error","fallbackTag","fallbackPrefix","fallbackEl","setAttribute","createElementWithId","currentToast","emergencyTimeouts","showToast","closeToast","push","cleanUpTime","dismissTimeout","fn","delay","safeSetTimeout","primaryError","elContainer","emergencyToast","substring","length","index","indexOf","splice","remove","pointerEvents","hideError","removeElement","defaultColors","success","warning","info","defaultMessages","createToast","sanitizedOptions","defaults","type","undefined","final","Array","isArray","keys","forEach","key","hasOwnProperty","sanitizeToastOptions","safeMessage","setDefaultColors","colors","setDefaultMessages","messages","window","customizableToast"],"mappings":";;;;;;;;;;;;;;aAQOA,eAAeC,EAAiBC,GACrC,MAAO,GAAGA,KAAUC,KAAKC,SAASC,KAAKC,MAAsB,IAAhBD,KAAKE,WACpD,CCCOP,eAAeQ,EAAqBC,GACzC,IACE,IAAIC,EAAiBC,SAASC,eAAe,mBAAmBH,KAWhE,OATKC,IACHA,EAAiBC,SAASE,cAAc,OACxCH,EAAeI,GAAK,mBAAmBL,IACvCC,EAAeK,MAAMN,SAAW,QAChCC,EAAeK,MAAMC,OAAS,aCX7BhB,eAA2BiB,EAAWR,GAE3CQ,EAAUF,MAAMG,IAAM,OACtBD,EAAUF,MAAMI,OAAS,OACzBF,EAAUF,MAAMK,KAAO,OACvBH,EAAUF,MAAMM,MAAQ,OACxBJ,EAAUF,MAAMO,UAAY,OAExBb,EAASc,SAAS,UACpBN,EAAUF,MAAMI,OAAS,OAChBV,EAASc,SAAS,SAC3BN,EAAUF,MAAMG,IAAM,QAGpBT,EAASc,SAAS,SACpBN,EAAUF,MAAMM,MAAQ,OACfZ,EAASc,SAAS,QAC3BN,EAAUF,MAAMK,KAAO,OACdX,EAASc,SAAS,YAC3BN,EAAUF,MAAMG,IAAM,MACtBD,EAAUF,MAAMK,KAAO,MACvBH,EAAUF,MAAMO,UAAY,wBAEhC,CDXYE,CAAYd,EAAgBD,SEgBjCT,eAA2ByB,EAAQC,GACx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B,IACMA,GAA4B,iBAAXA,IAAwBT,MAAMC,QAAQQ,KACzDpB,EAAgB,IAAKA,KAAkBoB,GAE1C,CAAC,MAAO1H,GAER,CACH,CAKA,SAAS2H,EAAmBC,GAC1B,IACMA,GAAgC,iBAAbA,IAA0BX,MAAMC,QAAQU,KAC7DlB,EAAkB,IAAKA,KAAoBkB,GAE9C,CAAC,MAAO5H,GAER,CACH,CAWA,IAEwB,oBAAX6H,SACTA,OAAOC,kBAAoB,CACzBnB,cACAc,mBACAE,sBAGN,CAAE,MAAO3H,GAET,oCApBA,WAEEmF,EADcrG,SAAS0F,cAAc,yCAEvC"}
@@ -1,13 +1,16 @@
1
1
  /*!
2
- * Customizable Toast Notifications 3.4.0
3
- * Build: 2025-07-19 18:22:36
4
- * Cache-Buster: 1752949356123
2
+ * Customizable Toast Notifications 3.5.1
3
+ * Build: 2025-08-27 18:05:24
4
+ * Cache-Buster: 1756317924370
5
5
  * Author: Priyanshu Patel
6
6
  * Email: priyanshu.alt191@gmail.com
7
7
  * License: Apache-2.0
8
8
  * Dependencies: None
9
9
  * Created: July 31, 2024
10
- * A lightweight toast notification library for any JavaScript framework
10
+ * A lightweight and fully customizable toast notification library
11
+ * designed for seamless integration with any JavaScript or framework-based UI.
12
+ * Supports flexible positioning, theming, icons, animations, and timing options
13
+ * out of the box — with zero dependencies.
11
14
  */
12
- function t(t="toast"){return`${t}-${Date.now()}-${Math.floor(1e5*Math.random())}`}function e(t){if(!t)return!0;try{if(t.parentNode)return t.parentNode.removeChild(t),!0}catch(e){try{if(t.remove)return t.remove(),!0}catch(e){try{return t.style.display="none",t.style.opacity="0",t.style.pointerEvents="none",t.style.position="absolute",t.style.left="-9999px",!0}catch(t){return!1}}}return!0}function n(t){try{let e=document.getElementById(`toast-container-${t}`);return e||(e=document.createElement("div"),e.id=`toast-container-${t}`,e.style.position="fixed",e.style.zIndex="9999",function(t,e){t.style.top="auto",t.style.bottom="auto",t.style.left="auto",t.style.right="auto",t.style.transform="none",e.includes("bottom")?t.style.bottom="10px":e.includes("top")&&(t.style.top="10px"),e.includes("right")?t.style.right="10px":e.includes("left")?t.style.left="10px":e.includes("center")&&(t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)")}(e,t),function(t,e){if(!t||!e)return!1;try{return t.contains(e)||t.appendChild(e),!0}catch(n){try{return t.insertAdjacentElement("beforeend",e),!0}catch(n){try{if(t===document.body)return e.style.position="fixed",e.style.top="10px",e.style.right="10px",e.style.zIndex="99999",document.body.insertAdjacentHTML("beforeend",e.outerHTML||""),!0}catch(t){return!1}}}}(document.body,e)),e}catch(t){return document.body}}function o(t,e,n){const o=function(t){try{if("number"==typeof t&&t>0)return t;if("string"==typeof t){if(t.endsWith("s")&&!t.endsWith("ms")){const e=1e3*parseFloat(t);return e>0?e:500}const e=parseFloat(t);return e>0?e:500}}catch(t){}return 500}(e.animationDuration||"0.5s");Object.assign(t.style,{background:e.backgroundColor||e.color||"#333",color:e.textColor||"white",padding:"12px 20px",marginBottom:"10px",borderRadius:"5px",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",minWidth:"250px",maxWidth:"400px",opacity:"0",position:"relative",transition:`opacity ${e.animationDuration||"0.5s"} ${e.animationEasing||"ease"}, transform ${e.animationDuration||"0.5s"} ${e.animationEasing||"ease"}`,transform:"translateY(20px)",zIndex:"9999"}),t._animationDuration=o;const r=document.createElement("span");r.textContent=e.message||"Notification",r.style.flex="1",t.appendChild(r),e.showCloseButton&&function(t,e,n){const o=document.createElement("button");o.innerHTML="&times;",Object.assign(o.style,{background:"none",border:"none",color:e.textColor||"white",fontSize:"18px",marginLeft:"10px",cursor:"pointer"}),o.onclick=()=>n(t),t.appendChild(o),t._cleanupCloseButton=()=>{o.onclick=null}}(t,e,n),e.showProgressBar&&function(t,e){const n=document.createElement("div");Object.assign(n.style,{position:"absolute",left:"0",height:e.progressHeight||"4px",background:e.progressColor||"rgba(255, 255, 255, 0.3)",width:"100%",transition:`width ${e.duration||3e3}ms linear`,["top"===e.progressPosition?"top":"bottom"]:"0"}),t.appendChild(n),setTimeout(()=>{!function(t){try{return t?.offsetWidth||0}catch(t){return 0}}(n),n.style.width="0%"},100)}(t,e),function(t){setTimeout(()=>{t.style.opacity="1",t.style.transform="translateY(0)"},50)}(t)}function r(e,n){let r,i=!1;try{r=function(e,n){try{const o=document.createElement(e);return o.id=t(n),o}catch(o){try{const o=document.createElement("div");return o.id=t(n||"fallback"),o.setAttribute("data-original-tag",e),o}catch(e){return{id:t(n||"emergency"),style:{},appendChild:()=>{},setAttribute:()=>{},innerHTML:"",textContent:"",onclick:null,_isEmergencyElement:!0}}}}("div","toast"),r._isEmergencyElement&&(i=!0)}catch(t){i=!0,r={id:`emergency-toast-${Date.now()}`,style:{},appendChild:()=>{},innerHTML:"",textContent:"",_isEmergencyElement:!0}}if(!i)try{return o(r,e,n),r}catch(t){i=!0}if(i&&!r._isEmergencyElement)try{return function(t,e,n){Object.assign(t.style,{background:"#333",color:"white",padding:"10px 15px",margin:"10px",borderRadius:"3px",position:"fixed",top:"20px",right:"20px",zIndex:"99999",maxWidth:"300px",wordWrap:"break-word"}),t.textContent=e.message||"Notification",e.showCloseButton&&(t.style.cursor="pointer",t.onclick=()=>n(t)),t._animationDuration=500}(r,e,n),r}catch(t){}return function(t,e){try{const n=document.createElement("div");return n.id=`emergency-${Date.now()}`,n.innerHTML=`\n <div style="\n background: #333 !important;\n color: white !important;\n padding: 10px 15px !important;\n position: fixed !important;\n top: 20px !important;\n right: 20px !important;\n z-index: 99999 !important;\n border-radius: 3px !important;\n max-width: 250px !important;\n word-wrap: break-word !important;\n font-family: Arial, sans-serif !important;\n font-size: 14px !important;\n box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;\n cursor: pointer !important;\n " onclick="this.parentNode.removeChild(this)">\n ${t.message||"Notification"}\n <span style="float: right; margin-left: 10px; font-weight: bold;">&times;</span>\n </div>\n `,n._animationDuration=500,n._isEmergencyToast=!0,setTimeout(()=>{try{n.parentNode&&n.parentNode.removeChild(n),e(n)}catch(t){}},t.duration||3e3),n}catch(n){return setTimeout(()=>{try{alert(t.message||"Toast Notification"),e(null)}catch(t){e(null)}},100),null}}(e,n)}let i=!1,a=null,s=new Set,c=!1;function l(t){if(!i){i=!0;try{const e=n(t.position),o=r(t,p);if(!o)throw new Error("Toast creation returned null");a=o,e.appendChild?e.appendChild(o):document.body.appendChild(o);const i=setTimeout(()=>{p(o)},t.duration||3e3);return s.add(i),void function(t){if(c)return;c=!0;const e=setTimeout(()=>{m()},2.5*t);s.add(e)}(t.duration||3e3)}catch(t){}try{const e=function(t){const e=document.createElement("div");return e.style.cssText="\n position: fixed !important;\n top: 20px !important;\n right: 20px !important;\n background: #333 !important;\n color: white !important;\n padding: 12px 20px !important;\n border-radius: 5px !important;\n z-index: 99999 !important;\n max-width: 300px !important;\n font-family: Arial, sans-serif !important;\n cursor: pointer !important;\n ",e.textContent=t.message||"Notification",e.onclick=()=>p(e),e}(t);return a=e,document.body.appendChild(e),void setTimeout(()=>{p(e)},t.duration||3e3)}catch(t){}try{alert(t.message||"Notification"),i=!1}catch(t){i=!1}}}function p(t){try{if(!t)return void d();if(t.style&&!t._isEmergencyToast){t.style.opacity="0",t.style.transform="translateY(-20px)";const e=t._animationDuration||500;setTimeout(()=>{u(t)},e)}else u(t)}catch(t){m()}}function u(t){try{t._cleanupCloseButton&&t._cleanupCloseButton(),e(t),d()}catch(t){m()}}function d(){i=!1,a=null,s.forEach(t=>{try{clearTimeout(t)}catch(t){}}),s.clear(),c=!1}function m(){try{a&&e(a);document.querySelectorAll('[id*="toast"], [id*="emergency"]').forEach(t=>{try{e(t)}catch(t){}}),d()}catch(t){i=!1,a=null}}let y={success:"#28a745",error:"#dc3545",warning:"#ffc107",info:"#17a2b8"},f={success:"Operation completed successfully!",error:"Something went wrong!",warning:"Warning message!",info:"Information message!"};function h(t={}){try{const e=function(t){const e={duration:3e3,position:"bottom-right",type:"info",backgroundColor:void 0,textColor:"white",showCloseButton:!1,animationDuration:"0.5s",animationEasing:"ease",showProgressBar:!1,progressColor:void 0,progressHeight:"4px",progressPosition:"bottom"};let n={...e};t&&"object"==typeof t&&!Array.isArray(t)&&(Object.keys(e).forEach(e=>{t.hasOwnProperty(e)&&(n[e]=t[e])}),void 0!==t.message&&(n.message=t.message));try{!n.backgroundColor&&n.type&&y[n.type]&&(n.backgroundColor=y[n.type]),!n.message&&n.type&&f[n.type]&&(n.message=f[n.type])}catch(t){}n.message&&"string"==typeof n.message||(n.message="Notification");("number"!=typeof n.duration||n.duration<100)&&(n.duration=3e3);return n}(t);l(e)}catch(e){const n="string"==typeof t?.message?t.message.substring(0,200):"Toast notification failed";try{alert(n)}catch(t){}}}function g(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(y={...y,...t})}catch(t){}}function x(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(f={...f,...t})}catch(t){}}try{"undefined"!=typeof window&&(window.customizableToast={createToast:h,setDefaultColors:g,setDefaultMessages:x})}catch(t){}export{h as createToast,g as setDefaultColors,x as setDefaultMessages};
15
+ async function t(t){return`${t}-${Date.now()}-${Math.floor(1e5*Math.random())}`}async function e(t){try{let e=document.getElementById(`toast-container-${t}`);return e||(e=document.createElement("div"),e.id=`toast-container-${t}`,e.style.position="fixed",e.style.zIndex="9999",await async function(t,e){t.style.top="auto",t.style.bottom="auto",t.style.left="auto",t.style.right="auto",t.style.transform="none",e.includes("bottom")?t.style.bottom="10px":e.includes("top")&&(t.style.top="10px"),e.includes("right")?t.style.right="10px":e.includes("left")?t.style.left="10px":e.includes("center")&&(t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)")}(e,t),await async function(t,e){if(!t||!e)return!1;try{return t.contains(e)||t.appendChild(e),!0}catch(n){try{return t.insertAdjacentElement("beforeend",e),!0}catch(n){try{if(t===document.body)return e.style.position="fixed",e.style.top="10px",e.style.right="10px",e.style.zIndex="99999",document.body.insertAdjacentHTML("beforeend",e.outerHTML||""),!0}catch(t){return!1}}}return!1}(document.body,e)),e}catch(t){return document.body}}function n(t,e,n){const o=function(t){try{if("number"==typeof t&&t>0)return t;if("string"==typeof t){if(t.endsWith("s")&&!t.endsWith("ms")){const e=1e3*parseFloat(t);return e>0?e:500}const e=parseFloat(t);return e>0?e:500}}catch(t){}return 500}(e.animationDuration);Object.assign(t.style,{background:e.backgroundColor||e.color||"#333",color:e.textColor||"white",padding:"12px 20px",marginBottom:"10px",borderRadius:"5px",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",minWidth:"250px",maxWidth:"400px",opacity:"0",position:"relative",transition:`opacity ${o||"0.5s"} ${e.animationEasing||"ease"}, transform ${o||"0.5s"} ${e.animationEasing||"ease"}`,transform:"translateY(20px)",zIndex:"9999"}),t._animationDuration=o;const r=document.createElement("span");r.textContent=e.message||"Notification",r.style.flex="1",t.appendChild(r),e.showCloseButton&&function(t,e,n){const o=document.createElement("button");o.innerHTML="&times;",Object.assign(o.style,{background:"none",border:"none",color:e.textColor||"white",fontSize:"18px",marginLeft:"10px",cursor:"pointer"}),o.onclick=()=>n(t),t.appendChild(o),t._cleanupCloseButton=()=>{o.onclick=null}}(t,e,n),e.showProgressBar&&function(t,e){const n=document.createElement("div");Object.assign(n.style,{position:"absolute",left:"0",height:e.progressHeight||"4px",background:e.progressColor||"rgba(255, 255, 255, 0.3)",width:"100%",transition:`width ${e.duration||1800}ms linear`,["top"===e.progressPosition?"top":"bottom"]:"0"}),t.appendChild(n),setTimeout(()=>{!function(t){try{return t?.offsetWidth||0}catch(t){return 0}}(n),n.style.width="0%"},100)}(t,e),function(t){setTimeout(()=>{t.style.opacity="1",t.style.transform="translateY(0)"},50)}(t)}function o(t,e){try{const n=document.createElement("div");return n.id=`emergency-${Date.now()}`,n.innerHTML=`\n <div style="\n background: #333 !important;\n color: white !important;\n padding: 10px 15px !important;\n position: fixed !important;\n top: 20px !important;\n right: 20px !important;\n z-index: 99999 !important;\n border-radius: 3px !important;\n max-width: 250px !important;\n word-wrap: break-word !important;\n font-family: Arial, sans-serif !important;\n font-size: 14px !important;\n box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;\n cursor: pointer !important;\n " onclick="this.parentNode.removeChild(this)">\n ${t.message||"Emergency Toast Creation Showing!"}\n <span style="float: right; margin-left: 10px; font-weight: bold;">&times;</span>\n </div>\n `,n._animationDuration=500,n._isEmergencyToast=!0,setTimeout(()=>{try{n.parentNode&&n.parentNode.removeChild(n),e(n)}catch(t){}},t.duration||1800),n}catch(n){return setTimeout(()=>{try{alert(t.message||"Toast Creation Failed!"),e(null)}catch(t){e(null)}},100),null}}async function r(e,r){let a;if(!document.querySelector('[id^="toast-container-"]'))return null;try{return a=await async function(e,n){try{if(!e||!n)throw new Error("tagName and prefix is required");const o=document.createElement(e);return o.id=t(n),o}catch(e){try{const e="div",n="fallback",o=document.createElement(e);return o.id=t(n),o.setAttribute("data-original-tag",e),o}catch(t){}}}("div","toast"),n(a,e,r),a}catch(t){return o(e,r),a}}let a=[],i=[];async function s(t){try{const n=await e(t.position),o=await r(t,c);if(!o)throw new Error("Toast element creation failed!");a.push(o),n.id.includes("toast-container-")&&n.appendChild(o);const s="number"==typeof t.duration&&t.duration>0?t.duration+2:1800,l=await async function(t,e){return setTimeout(()=>{t()},e)}(()=>c(o),s);return void i.push(l)}catch(e){const n=document.querySelector('[id^="toast-container-"]'),r=o(t,c);return void(n&&n?.id?.includes("toast-container-")?n.appendChild(r):alert(e.substring(0,200)))}}async function c(t){if(a.length>0){const e=a.indexOf(t);-1!==e&&a.splice(e,1)}await async function(t){if(!t)return!0;try{if(t?.parentNode?.id.includes("toast-container-"))return t.parentNode.removeChild(t),!0}catch(e){try{if(t.remove)return t.remove(),!0}catch(e){try{return t.style.display="none",t.style.opacity="0",t.style.pointerEvents="none",t.style.position="absolute",t.style.left="-9999px",!0}catch(t){return!1}}}return!0}(t)}let l={success:"#28a745",error:"#dc3545",warning:"#ffc107",info:"#17a2b8"},u={success:"Operation completed successfully!",error:"Something went wrong!",warning:"Warning message!",info:"Information message!"};async function d(t={}){try{const e=await async function(t){const e={duration:1800,position:"bottom-right",type:"info",backgroundColor:void 0,textColor:"white",showCloseButton:!1,animationDuration:"0.5s",animationEasing:"ease",showProgressBar:!1,progressColor:void 0,progressHeight:"4px",progressPosition:"bottom"};let n={...e};t&&"object"==typeof t&&!Array.isArray(t)&&(Object.keys(e).forEach(e=>{t.hasOwnProperty(e)&&(n[e]=t[e])}),void 0===t.message&&"undefined"===t.message||(n.message=t.message));try{!n.backgroundColor&&n.type&&l[n.type]&&(n.backgroundColor=l[n.type]),!n.message&&n.type&&u[n.type]&&(n.message=u[n.type])}catch(t){}n.message&&"string"==typeof n.message||(n.message="No Message Provided!");return n}(t);await s(e)}catch(e){const n="string"==typeof t?.message?`${t.message.substring(0,200)} toast creation failed!`:"Toast creation failed!";alert(n)}}function p(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(l={...l,...t})}catch(t){}}function y(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(u={...u,...t})}catch(t){}}function m(){c(document.querySelector('[id^="toast-"]:not([id*="container"])'))}try{"undefined"!=typeof window&&(window.customizableToast={createToast:d,setDefaultColors:p,setDefaultMessages:y})}catch(t){}export{d as createToast,m as noop,p as setDefaultColors,y as setDefaultMessages};
13
16
  //# sourceMappingURL=index.esm.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.mjs","sources":["../src/utils/id.js","../src/utils/dom.js","../src/components/ToastContainer.js","../src/utils/position.js","../src/components/toast-utils.js","../src/components/Toast.js","../src/components/ToastManager.js","../src/index.js"],"sourcesContent":["// src/utils/id.js\r\n\"use strict\";\r\n\r\n/**\r\n * Generate unique ID for DOM elements to avoid conflicts\r\n * @param {string} prefix - Optional prefix for ID\r\n * @returns {string} Unique ID\r\n */\r\nexport function generateUniqueId(prefix = \"toast\") {\r\n return `${prefix}-${Date.now()}-${Math.floor(Math.random() * 100000)}`;\r\n}\r\n","// src/utils/dom.js\r\n\"use strict\";\r\n\r\nimport { generateUniqueId } from \"./id.js\";\r\n\r\n/**\r\n * Multi-layer fallback DOM element creation\r\n */\r\nexport function createElementWithId(tagName, prefix) {\r\n // PRIMARY: Standard createElement\r\n try {\r\n const el = document.createElement(tagName);\r\n el.id = generateUniqueId(prefix);\r\n return el;\r\n } catch (error) {\r\n console.warn(`Primary createElement failed for ${tagName}:`, error);\r\n\r\n // FALLBACK-A: Try div as alternative\r\n try {\r\n const fallbackEl = document.createElement(\"div\");\r\n fallbackEl.id = generateUniqueId(prefix || \"fallback\");\r\n fallbackEl.setAttribute(\"data-original-tag\", tagName);\r\n return fallbackEl;\r\n } catch (fallbackError) {\r\n console.error(\"All DOM creation methods failed:\", fallbackError);\r\n\r\n // FALLBACK-B: Return minimal object that won't crash\r\n return {\r\n id: generateUniqueId(prefix || \"emergency\"),\r\n style: {},\r\n appendChild: () => {},\r\n setAttribute: () => {},\r\n innerHTML: \"\",\r\n textContent: \"\",\r\n onclick: null,\r\n _isEmergencyElement: true,\r\n };\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Multi-strategy appendChild with graceful degradation\r\n */\r\nexport function appendChild(parent, child) {\r\n if (!parent || !child) return false;\r\n\r\n // PRIMARY: Standard appendChild\r\n try {\r\n if (!parent.contains(child)) {\r\n parent.appendChild(child);\r\n return true;\r\n }\r\n return true;\r\n } catch (error) {\r\n console.warn(\"Primary appendChild failed:\", error);\r\n\r\n // FALLBACK-A: insertAdjacentElement\r\n try {\r\n parent.insertAdjacentElement(\"beforeend\", child);\r\n return true;\r\n } catch (fallbackError) {\r\n console.warn(\"Fallback appendChild failed:\", fallbackError);\r\n\r\n // FALLBACK-B: Manual positioning\r\n try {\r\n if (parent === document.body) {\r\n child.style.position = \"fixed\";\r\n child.style.top = \"10px\";\r\n child.style.right = \"10px\";\r\n child.style.zIndex = \"99999\";\r\n document.body.insertAdjacentHTML(\"beforeend\", child.outerHTML || \"\");\r\n return true;\r\n }\r\n } catch (emergencyError) {\r\n console.error(\"All append strategies failed:\", emergencyError);\r\n return false;\r\n }\r\n }\r\n }\r\n return false;\r\n}\r\n\r\n/**\r\n * Safe element removal with multiple strategies\r\n */\r\nexport function removeElement(el) {\r\n if (!el) return true;\r\n\r\n // PRIMARY: parentNode.removeChild\r\n try {\r\n if (el.parentNode) {\r\n el.parentNode.removeChild(el);\r\n return true;\r\n }\r\n } catch (error) {\r\n console.warn(\"Primary removal failed:\", error);\r\n\r\n // FALLBACK-A: element.remove()\r\n try {\r\n if (el.remove) {\r\n el.remove();\r\n return true;\r\n }\r\n } catch (fallbackError) {\r\n console.warn(\"Fallback removal failed:\", fallbackError);\r\n\r\n // FALLBACK-B: Hide instead of remove\r\n try {\r\n el.style.display = \"none\";\r\n el.style.opacity = \"0\";\r\n el.style.pointerEvents = \"none\";\r\n el.style.position = \"absolute\";\r\n el.style.left = \"-9999px\";\r\n return true;\r\n } catch (hideError) {\r\n console.error(\"All removal strategies failed:\", hideError);\r\n return false;\r\n }\r\n }\r\n }\r\n return true;\r\n}\r\n\r\n/**\r\n * Animation duration parser with fallbacks\r\n */\r\nexport function parseAnimationDuration(duration) {\r\n // PRIMARY: Parse provided duration\r\n try {\r\n if (typeof duration === \"number\" && duration > 0) return duration;\r\n if (typeof duration === \"string\") {\r\n if (duration.endsWith(\"s\") && !duration.endsWith(\"ms\")) {\r\n const parsed = parseFloat(duration) * 1000;\r\n return parsed > 0 ? parsed : 500;\r\n }\r\n const parsed = parseFloat(duration);\r\n return parsed > 0 ? parsed : 500;\r\n }\r\n } catch (error) {\r\n console.warn(\"Duration parsing failed:\", error);\r\n }\r\n\r\n // FALLBACK: Safe default\r\n return 500;\r\n}\r\n\r\n/**\r\n * Force reflow with error protection\r\n */\r\nexport function forceReflow(el) {\r\n try {\r\n return el?.offsetWidth || 0;\r\n } catch (error) {\r\n console.warn(\"Force reflow failed:\", error);\r\n return 0;\r\n }\r\n}\r\n\r\n/**\r\n * Query selector shortcut with optional root.\r\n * @param {string} selector\r\n * @param {Document|HTMLElement} [root=document]\r\n * @returns {Element|null}\r\n */\r\nexport function query(selector, root = document) {\r\n return root.querySelector(selector);\r\n}\r\n","// src/components/ToastContainer.js //# Container logic\r\n\"use strict\";\r\n\r\nimport { setPosition } from \"../utils/position.js\";\r\nimport { appendChild } from \"../utils/dom.js\";\r\n\r\n/**\r\n * Create toast container with error handling\r\n * @param {string} position - Toast position\r\n * @returns {HTMLElement} Toast container element\r\n */\r\nexport function createToastContainer(position) {\r\n try {\r\n let toastContainer = document.getElementById(`toast-container-${position}`);\r\n\r\n if (!toastContainer) {\r\n toastContainer = document.createElement(\"div\");\r\n toastContainer.id = `toast-container-${position}`;\r\n toastContainer.style.position = \"fixed\";\r\n toastContainer.style.zIndex = \"9999\";\r\n setPosition(toastContainer, position);\r\n appendChild(document.body, toastContainer);\r\n }\r\n\r\n return toastContainer;\r\n } catch (error) {\r\n console.error(\"Failed to create toast container:\", error);\r\n // Fallback: return body element\r\n return document.body;\r\n }\r\n}\r\n","// src/utils/position.js\r\n\"use strict\";\r\n\r\n/**\r\n * Set position for toast container (EXACT same logic as original)\r\n * @param {HTMLElement} container - Toast container element\r\n * @param {string} position - Position string\r\n */\r\nexport function setPosition(container, position) {\r\n // Reset all position properties first\r\n container.style.top = \"auto\";\r\n container.style.bottom = \"auto\";\r\n container.style.left = \"auto\";\r\n container.style.right = \"auto\";\r\n container.style.transform = \"none\";\r\n\r\n if (position.includes(\"bottom\")) {\r\n container.style.bottom = \"10px\";\r\n } else if (position.includes(\"top\")) {\r\n container.style.top = \"10px\";\r\n }\r\n\r\n if (position.includes(\"right\")) {\r\n container.style.right = \"10px\";\r\n } else if (position.includes(\"left\")) {\r\n container.style.left = \"10px\";\r\n } else if (position.includes(\"center\")) {\r\n container.style.top = \"50%\";\r\n container.style.left = \"50%\";\r\n container.style.transform = \"translate(-50%, -50%)\";\r\n }\r\n}\r\n","\"use strict\";\r\n\r\nimport { forceReflow, parseAnimationDuration } from \"../utils/dom.js\";\r\n\r\n/**\r\n * Create close button for toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport function createCloseButton(toast, options, onClose) {\r\n const closeButton = document.createElement(\"button\");\r\n closeButton.innerHTML = \"&times;\";\r\n Object.assign(closeButton.style, {\r\n background: \"none\",\r\n border: \"none\",\r\n color: options.textColor || \"white\",\r\n fontSize: \"18px\",\r\n marginLeft: \"10px\",\r\n cursor: \"pointer\",\r\n });\r\n\r\n closeButton.onclick = () => onClose(toast);\r\n toast.appendChild(closeButton);\r\n\r\n toast._cleanupCloseButton = () => {\r\n closeButton.onclick = null;\r\n };\r\n}\r\n\r\n/**\r\n * Create progress bar for toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n */\r\nexport function createProgressBar(toast, options) {\r\n const progressBar = document.createElement(\"div\");\r\n Object.assign(progressBar.style, {\r\n position: \"absolute\",\r\n left: \"0\",\r\n height: options.progressHeight || \"4px\",\r\n background: options.progressColor || \"rgba(255, 255, 255, 0.3)\",\r\n width: \"100%\",\r\n transition: `width ${options.duration || 3000}ms linear`,\r\n [options.progressPosition === \"top\" ? \"top\" : \"bottom\"]: \"0\",\r\n });\r\n\r\n toast.appendChild(progressBar);\r\n\r\n setTimeout(() => {\r\n forceReflow(progressBar);\r\n progressBar.style.width = \"0%\";\r\n }, 100);\r\n}\r\n\r\n/**\r\n * Run toast fade-in animation\r\n * @param {HTMLElement} toast - Toast element\r\n */\r\nexport function runToastAnimation(toast) {\r\n setTimeout(() => {\r\n toast.style.opacity = \"1\";\r\n toast.style.transform = \"translateY(0)\";\r\n }, 50);\r\n}\r\n\r\n/**\r\n * Apply rich styling to toast element\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport function applyRichStyling(toast, options, onClose) {\r\n const animDurationMs = parseAnimationDuration(\r\n options.animationDuration || \"0.5s\"\r\n );\r\n\r\n // Apply full styling\r\n Object.assign(toast.style, {\r\n background: options.backgroundColor || options.color || \"#333\",\r\n color: options.textColor || \"white\",\r\n padding: \"12px 20px\",\r\n marginBottom: \"10px\",\r\n borderRadius: \"5px\",\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n justifyContent: \"space-between\",\r\n boxShadow: \"0 4px 6px rgba(0, 0, 0, 0.1)\",\r\n minWidth: \"250px\",\r\n maxWidth: \"400px\",\r\n opacity: \"0\",\r\n position: \"relative\",\r\n transition: `opacity ${options.animationDuration || \"0.5s\"} ${\r\n options.animationEasing || \"ease\"\r\n }, transform ${options.animationDuration || \"0.5s\"} ${\r\n options.animationEasing || \"ease\"\r\n }`,\r\n transform: \"translateY(20px)\",\r\n zIndex: \"9999\",\r\n });\r\n\r\n toast._animationDuration = animDurationMs;\r\n\r\n // Message span\r\n const messageSpan = document.createElement(\"span\");\r\n messageSpan.textContent = options.message || \"Notification\";\r\n messageSpan.style.flex = \"1\";\r\n toast.appendChild(messageSpan);\r\n\r\n // Close button\r\n if (options.showCloseButton) {\r\n createCloseButton(toast, options, onClose);\r\n }\r\n\r\n // Progress bar\r\n if (options.showProgressBar) {\r\n createProgressBar(toast, options);\r\n }\r\n\r\n // Animation\r\n runToastAnimation(toast);\r\n}\r\n\r\n/**\r\n * Create basic fallback toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport function createBasicToast(toast, options, onClose) {\r\n // Basic styling only\r\n Object.assign(toast.style, {\r\n background: \"#333\",\r\n color: \"white\",\r\n padding: \"10px 15px\",\r\n margin: \"10px\",\r\n borderRadius: \"3px\",\r\n position: \"fixed\",\r\n top: \"20px\",\r\n right: \"20px\",\r\n zIndex: \"99999\",\r\n maxWidth: \"300px\",\r\n wordWrap: \"break-word\",\r\n });\r\n\r\n toast.textContent = options.message || \"Notification\";\r\n\r\n if (options.showCloseButton) {\r\n toast.style.cursor = \"pointer\";\r\n toast.onclick = () => onClose(toast);\r\n }\r\n\r\n toast._animationDuration = 500;\r\n}\r\n\r\n/**\r\n * Emergency toast as last resort\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport function createEmergencyToast(options, onClose) {\r\n try {\r\n // Create emergency div\r\n const emergency = document.createElement(\"div\");\r\n emergency.id = `emergency-${Date.now()}`;\r\n emergency.innerHTML = `\r\n <div style=\"\r\n background: #333 !important;\r\n color: white !important;\r\n padding: 10px 15px !important;\r\n position: fixed !important;\r\n top: 20px !important;\r\n right: 20px !important;\r\n z-index: 99999 !important;\r\n border-radius: 3px !important;\r\n max-width: 250px !important;\r\n word-wrap: break-word !important;\r\n font-family: Arial, sans-serif !important;\r\n font-size: 14px !important;\r\n box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;\r\n cursor: pointer !important;\r\n \" onclick=\"this.parentNode.removeChild(this)\">\r\n ${options.message || \"Notification\"}\r\n <span style=\"float: right; margin-left: 10px; font-weight: bold;\">&times;</span>\r\n </div>\r\n `;\r\n\r\n emergency._animationDuration = 500;\r\n emergency._isEmergencyToast = true;\r\n\r\n // Auto remove\r\n setTimeout(() => {\r\n try {\r\n if (emergency.parentNode) {\r\n emergency.parentNode.removeChild(emergency);\r\n }\r\n onClose(emergency);\r\n } catch (error) {\r\n console.warn(\"Emergency cleanup failed:\", error);\r\n }\r\n }, options.duration || 3000);\r\n\r\n return emergency;\r\n } catch (emergencyError) {\r\n console.error(\"Emergency toast creation failed:\", emergencyError);\r\n\r\n // ULTIMATE FALLBACK: Alert\r\n setTimeout(() => {\r\n try {\r\n alert(options.message || \"Toast Notification\");\r\n onClose(null);\r\n } catch (alertError) {\r\n console.error(\"Ultimate fallback failed:\", alertError);\r\n onClose(null);\r\n }\r\n }, 100);\r\n\r\n return null;\r\n }\r\n}\r\n","// src/components/Toast.js //# Single responsibility\r\n\"use strict\";\r\n\r\nimport { createElementWithId } from \"../utils/dom.js\";\r\nimport {\r\n applyRichStyling,\r\n createBasicToast,\r\n createEmergencyToast,\r\n} from \"./toast-utils.js\";\r\n\r\n/**\r\n * Multi-layer toast creation with satellite-grade fallbacks\r\n * @param {Object} options - Toast configuration options\r\n * @param {Function} onClose - Callback when toast closes\r\n * @returns {HTMLElement} Toast element\r\n */\r\nexport function createToastElement(options, onClose) {\r\n let toast;\r\n let isEmergencyMode = false;\r\n\r\n // PRIMARY: Full-featured toast\r\n try {\r\n toast = createElementWithId(\"div\", \"toast\");\r\n\r\n if (toast._isEmergencyElement) {\r\n isEmergencyMode = true;\r\n console.warn(\"Toast created in emergency mode\");\r\n }\r\n } catch (error) {\r\n console.error(\"Toast creation failed:\", error);\r\n isEmergencyMode = true;\r\n // FALLBACK: Basic object structure\r\n toast = {\r\n id: `emergency-toast-${Date.now()}`,\r\n style: {},\r\n appendChild: () => {},\r\n innerHTML: \"\",\r\n textContent: \"\",\r\n _isEmergencyElement: true,\r\n };\r\n }\r\n\r\n // PRIMARY: Rich styling and features\r\n if (!isEmergencyMode) {\r\n try {\r\n applyRichStyling(toast, options, onClose);\r\n return toast;\r\n } catch (stylingError) {\r\n console.warn(\r\n \"Rich toast styling failed, switching to basic mode:\",\r\n stylingError\r\n );\r\n isEmergencyMode = true;\r\n }\r\n }\r\n\r\n // FALLBACK-A: Basic functional toast\r\n if (isEmergencyMode && !toast._isEmergencyElement) {\r\n try {\r\n createBasicToast(toast, options, onClose);\r\n return toast;\r\n } catch (basicError) {\r\n console.error(\"Basic toast creation failed:\", basicError);\r\n }\r\n }\r\n\r\n // FALLBACK-B: Emergency notification system\r\n return createEmergencyToast(options, onClose);\r\n}\r\n","// src/components/ToastManager.js //# State management\r\n\"use strict\";\r\n\r\nimport { createToastContainer } from \"./ToastContainer.js\";\r\nimport { createToastElement } from \"./Toast.js\";\r\nimport { removeElement } from \"../utils/dom.js\";\r\n\r\n// State management with fallback tracking\r\nlet isToastShowing = false;\r\nlet currentToast = null;\r\nlet emergencyTimeouts = new Set();\r\nlet emergencyCleanupScheduled = false;\r\n\r\n/**\r\n * Show toast with comprehensive fallback system\r\n */\r\nexport function showToast(options) {\r\n // Prevent multiple toasts (original behavior)\r\n if (isToastShowing) {\r\n console.warn(\"Toast already showing, ignoring request\");\r\n return;\r\n }\r\n\r\n isToastShowing = true;\r\n\r\n // PRIMARY: Full toast system\r\n try {\r\n const container = createToastContainer(options.position);\r\n const toast = createToastElement(options, closeToast);\r\n\r\n if (!toast) {\r\n throw new Error(\"Toast creation returned null\");\r\n }\r\n\r\n currentToast = toast;\r\n\r\n // Append to container\r\n if (container.appendChild) {\r\n container.appendChild(toast);\r\n } else {\r\n // Container is emergency fallback\r\n document.body.appendChild(toast);\r\n }\r\n\r\n // Schedule auto-dismiss\r\n const dismissTimeout = setTimeout(() => {\r\n closeToast(toast);\r\n }, options.duration || 3000);\r\n\r\n emergencyTimeouts.add(dismissTimeout);\r\n\r\n // Emergency cleanup backup\r\n scheduleEmergencyCleanup(options.duration || 3000);\r\n\r\n return;\r\n } catch (primaryError) {\r\n console.warn(\"Primary toast system failed:\", primaryError);\r\n }\r\n\r\n // FALLBACK-A: Direct body placement\r\n try {\r\n const simpleToast = createSimpleToast(options);\r\n currentToast = simpleToast;\r\n document.body.appendChild(simpleToast);\r\n\r\n setTimeout(() => {\r\n closeToast(simpleToast);\r\n }, options.duration || 3000);\r\n\r\n return;\r\n } catch (fallbackError) {\r\n console.warn(\"Fallback toast failed:\", fallbackError);\r\n }\r\n\r\n // FALLBACK-B: Browser alert\r\n try {\r\n alert(options.message || \"Notification\");\r\n isToastShowing = false;\r\n } catch (alertError) {\r\n console.error(\"All toast systems failed:\", alertError);\r\n isToastShowing = false;\r\n }\r\n}\r\n\r\n/**\r\n * Create simple toast for fallback\r\n */\r\nfunction createSimpleToast(options) {\r\n const simple = document.createElement(\"div\");\r\n simple.style.cssText = `\r\n position: fixed !important;\r\n top: 20px !important;\r\n right: 20px !important;\r\n background: #333 !important;\r\n color: white !important;\r\n padding: 12px 20px !important;\r\n border-radius: 5px !important;\r\n z-index: 99999 !important;\r\n max-width: 300px !important;\r\n font-family: Arial, sans-serif !important;\r\n cursor: pointer !important;\r\n `;\r\n simple.textContent = options.message || \"Notification\";\r\n simple.onclick = () => closeToast(simple);\r\n return simple;\r\n}\r\n\r\n/**\r\n * Close toast with multi-strategy cleanup\r\n */\r\nfunction closeToast(toast) {\r\n try {\r\n if (!toast) {\r\n resetToastState();\r\n return;\r\n }\r\n\r\n // Animation if supported\r\n if (toast.style && !toast._isEmergencyToast) {\r\n toast.style.opacity = \"0\";\r\n toast.style.transform = \"translateY(-20px)\";\r\n\r\n const animDuration = toast._animationDuration || 500;\r\n setTimeout(() => {\r\n performCleanup(toast);\r\n }, animDuration);\r\n } else {\r\n // Immediate cleanup for emergency toasts\r\n performCleanup(toast);\r\n }\r\n } catch (error) {\r\n console.error(\"Close toast failed:\", error);\r\n forceEmergencyCleanup();\r\n }\r\n}\r\n\r\n/**\r\n * Perform comprehensive cleanup\r\n */\r\nfunction performCleanup(toast) {\r\n try {\r\n // Cleanup event listeners\r\n if (toast._cleanupCloseButton) {\r\n toast._cleanupCloseButton();\r\n }\r\n\r\n // Remove from DOM\r\n removeElement(toast);\r\n\r\n // Reset state\r\n resetToastState();\r\n } catch (error) {\r\n console.error(\"Cleanup failed:\", error);\r\n forceEmergencyCleanup();\r\n }\r\n}\r\n\r\n/**\r\n * Reset all toast state\r\n */\r\nfunction resetToastState() {\r\n isToastShowing = false;\r\n currentToast = null;\r\n\r\n // Clear all timeouts\r\n emergencyTimeouts.forEach((id) => {\r\n try {\r\n clearTimeout(id);\r\n } catch (error) {\r\n console.warn(\"Timeout clear failed:\", error);\r\n }\r\n });\r\n emergencyTimeouts.clear();\r\n emergencyCleanupScheduled = false;\r\n}\r\n\r\n/**\r\n * Schedule emergency cleanup\r\n */\r\nfunction scheduleEmergencyCleanup(duration) {\r\n if (emergencyCleanupScheduled) return;\r\n\r\n emergencyCleanupScheduled = true;\r\n const emergencyTimeout = setTimeout(() => {\r\n console.warn(\"Emergency cleanup triggered\");\r\n forceEmergencyCleanup();\r\n }, duration * 2.5); // 2.5x safety margin\r\n\r\n emergencyTimeouts.add(emergencyTimeout);\r\n}\r\n\r\n/**\r\n * Force emergency cleanup of everything\r\n */\r\nfunction forceEmergencyCleanup() {\r\n try {\r\n // Remove current toast\r\n if (currentToast) {\r\n removeElement(currentToast);\r\n }\r\n\r\n // Clean up any orphaned toast elements\r\n const orphanedToasts = document.querySelectorAll(\r\n '[id*=\"toast\"], [id*=\"emergency\"]'\r\n );\r\n orphanedToasts.forEach((element) => {\r\n try {\r\n removeElement(element);\r\n } catch (error) {\r\n console.warn(\"Orphaned element cleanup failed:\", error);\r\n }\r\n });\r\n\r\n // Reset all state\r\n resetToastState();\r\n } catch (error) {\r\n console.error(\"Force cleanup failed:\", error);\r\n // Final state reset\r\n isToastShowing = false;\r\n currentToast = null;\r\n }\r\n}\r\n","// src/index.js\r\n/**\r\n * @fileoverview A simple toast notification library for any JavaScript framework.\r\n * @name Customizable Toast Notifications\r\n * @author Priyanshu Patel\r\n * @version __VERSION__\r\n * @build Production\r\n * @license Apache-2.0\r\n * @depends None\r\n * @description A lightweight and fully customizable toast notification library\r\n * designed for seamless integration with any JavaScript or framework-based UI.\r\n * Supports flexible positioning, theming, icons, animations, and timing options\r\n * out of the box — with zero dependencies.\r\n * Author: Priyanshu Patel\r\n * Email: priyanshu.alt191@gmail.com\r\n * Created: July 31, 2024\r\n * License: Apache-2.0\r\n * Dependencies: None\r\n */\r\n\r\n\"use strict\";\r\n\r\nimport { showToast } from \"./components/ToastManager.js\";\r\n\r\n// Protected state with fallbacks\r\nlet defaultColors = {\r\n success: \"#28a745\",\r\n error: \"#dc3545\",\r\n warning: \"#ffc107\",\r\n info: \"#17a2b8\",\r\n};\r\n\r\nlet defaultMessages = {\r\n success: \"Operation completed successfully!\",\r\n error: \"Something went wrong!\",\r\n warning: \"Warning message!\",\r\n info: \"Information message!\",\r\n};\r\n\r\n/**\r\n * Create toast with satellite-grade reliability\r\n */\r\nfunction createToast(options = {}) {\r\n try {\r\n // Input sanitization and validation\r\n const sanitizedOptions = sanitizeToastOptions(options);\r\n\r\n // Call main toast system\r\n showToast(sanitizedOptions);\r\n } catch (error) {\r\n console.error(\"CreateToast failed:\", error);\r\n\r\n // ULTIMATE FALLBACK: Browser alert with sanitized message\r\n const safeMessage =\r\n typeof options?.message === \"string\"\r\n ? options.message.substring(0, 200)\r\n : \"Toast notification failed\";\r\n\r\n try {\r\n alert(safeMessage);\r\n } catch (alertError) {\r\n console.error(\"Ultimate fallback failed:\", alertError);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Sanitize and normalize toast options\r\n */\r\nfunction sanitizeToastOptions(options) {\r\n const defaults = {\r\n duration: 3000,\r\n position: \"bottom-right\",\r\n type: \"info\",\r\n backgroundColor: undefined,\r\n textColor: \"white\",\r\n showCloseButton: false,\r\n animationDuration: \"0.5s\",\r\n animationEasing: \"ease\",\r\n showProgressBar: false,\r\n progressColor: undefined,\r\n progressHeight: \"4px\",\r\n progressPosition: \"bottom\",\r\n };\r\n\r\n // Start with safe defaults\r\n let final = { ...defaults };\r\n\r\n // Merge user options safely\r\n if (options && typeof options === \"object\" && !Array.isArray(options)) {\r\n Object.keys(defaults).forEach((key) => {\r\n if (options.hasOwnProperty(key)) {\r\n final[key] = options[key];\r\n }\r\n });\r\n\r\n // Handle message separately\r\n if (options.message !== undefined) {\r\n final.message = options.message;\r\n }\r\n }\r\n\r\n // Validate and apply defaults\r\n try {\r\n if (!final.backgroundColor && final.type && defaultColors[final.type]) {\r\n final.backgroundColor = defaultColors[final.type];\r\n }\r\n\r\n if (!final.message && final.type && defaultMessages[final.type]) {\r\n final.message = defaultMessages[final.type];\r\n }\r\n } catch (error) {\r\n console.warn(\"Option processing failed:\", error);\r\n }\r\n\r\n // Final safety checks\r\n if (!final.message || typeof final.message !== \"string\") {\r\n final.message = \"Notification\";\r\n }\r\n\r\n if (typeof final.duration !== \"number\" || final.duration < 100) {\r\n final.duration = 3000;\r\n }\r\n\r\n return final;\r\n}\r\n\r\n/**\r\n * Set default colors with validation\r\n */\r\nfunction setDefaultColors(colors) {\r\n try {\r\n if (colors && typeof colors === \"object\" && !Array.isArray(colors)) {\r\n defaultColors = { ...defaultColors, ...colors };\r\n }\r\n } catch (error) {\r\n console.error(\"setDefaultColors failed:\", error);\r\n }\r\n}\r\n\r\n/**\r\n * Set default messages with validation\r\n */\r\nfunction setDefaultMessages(messages) {\r\n try {\r\n if (messages && typeof messages === \"object\" && !Array.isArray(messages)) {\r\n defaultMessages = { ...defaultMessages, ...messages };\r\n }\r\n } catch (error) {\r\n console.error(\"setDefaultMessages failed:\", error);\r\n }\r\n}\r\n\r\n// Module exports\r\nexport { createToast, setDefaultColors, setDefaultMessages };\r\n\r\n// Global assignment with protection\r\ntry {\r\n // UMD/Global support\r\n if (typeof window !== \"undefined\") {\r\n window.customizableToast = {\r\n createToast,\r\n setDefaultColors,\r\n setDefaultMessages,\r\n };\r\n }\r\n} catch (error) {\r\n console.error(\"Global assignment failed:\", error);\r\n}\r\n"],"names":["generateUniqueId","prefix","Date","now","Math","floor","random","removeElement","el","parentNode","removeChild","error","remove","fallbackError","style","display","opacity","pointerEvents","position","left","hideError","createToastContainer","toastContainer","document","getElementById","createElement","id","zIndex","container","top","bottom","right","transform","includes","setPosition","parent","child","contains","appendChild","insertAdjacentElement","body","insertAdjacentHTML","outerHTML","emergencyError","applyRichStyling","toast","options","onClose","animDurationMs","duration","endsWith","parsed","parseFloat","parseAnimationDuration","animationDuration","Object","assign","background","backgroundColor","color","textColor","padding","marginBottom","borderRadius","alignItems","justifyContent","boxShadow","minWidth","maxWidth","transition","animationEasing","_animationDuration","messageSpan","textContent","message","flex","showCloseButton","closeButton","innerHTML","border","fontSize","marginLeft","cursor","onclick","_cleanupCloseButton","createCloseButton","showProgressBar","progressBar","height","progressHeight","progressColor","width","progressPosition","setTimeout","offsetWidth","forceReflow","createProgressBar","runToastAnimation","createToastElement","isEmergencyMode","tagName","fallbackEl","setAttribute","_isEmergencyElement","createElementWithId","stylingError","margin","wordWrap","createBasicToast","basicError","emergency","_isEmergencyToast","alert","alertError","createEmergencyToast","isToastShowing","currentToast","emergencyTimeouts","Set","emergencyCleanupScheduled","showToast","closeToast","Error","dismissTimeout","add","emergencyTimeout","forceEmergencyCleanup","scheduleEmergencyCleanup","primaryError","simpleToast","simple","cssText","createSimpleToast","resetToastState","animDuration","performCleanup","forEach","clearTimeout","clear","querySelectorAll","element","defaultColors","success","warning","info","defaultMessages","createToast","sanitizedOptions","defaults","type","undefined","final","Array","isArray","keys","key","hasOwnProperty","sanitizeToastOptions","safeMessage","substring","setDefaultColors","colors","setDefaultMessages","messages","window","customizableToast"],"mappings":";;;;;;;;;;;AAQO,SAASA,EAAiBC,EAAS,SACxC,MAAO,GAAGA,KAAUC,KAAKC,SAASC,KAAKC,MAAsB,IAAhBD,KAAKE,WACpD,CC4EO,SAASC,EAAcC,GAC5B,IAAKA,EAAI,OAAO,EAGhB,IACE,GAAIA,EAAGC,WAEL,OADAD,EAAGC,WAAWC,YAAYF,IACnB,CAEV,CAAC,MAAOG,GAIP,IACE,GAAIH,EAAGI,OAEL,OADAJ,EAAGI,UACI,CAEV,CAAC,MAAOC,GAIP,IAME,OALAL,EAAGM,MAAMC,QAAU,OACnBP,EAAGM,MAAME,QAAU,IACnBR,EAAGM,MAAMG,cAAgB,OACzBT,EAAGM,MAAMI,SAAW,WACpBV,EAAGM,MAAMK,KAAO,WACT,CACR,CAAC,MAAOC,GAEP,OAAO,CACR,CACF,CACF,CACD,OAAO,CACT,CC/GO,SAASC,EAAqBH,GACnC,IACE,IAAII,EAAiBC,SAASC,eAAe,mBAAmBN,KAWhE,OATKI,IACHA,EAAiBC,SAASE,cAAc,OACxCH,EAAeI,GAAK,mBAAmBR,IACvCI,EAAeR,MAAMI,SAAW,QAChCI,EAAeR,MAAMa,OAAS,OCX7B,SAAqBC,EAAWV,GAErC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U5B,EAAQ4B,UAK5B,KACO6E,EAAM7F,iBAAmB6F,EAAMF,MAAQR,EAAcU,EAAMF,QAC9DE,EAAM7F,gBAAkBmF,EAAcU,EAAMF,QAGzCE,EAAM7E,SAAW6E,EAAMF,MAAQJ,EAAgBM,EAAMF,QACxDE,EAAM7E,QAAUuE,EAAgBM,EAAMF,MAEzC,CAAC,MAAO1I,GAER,CAGI4I,EAAM7E,SAAoC,iBAAlB6E,EAAM7E,UACjC6E,EAAM7E,QAAU,iBAGY,iBAAnB6E,EAAMtG,UAAyBsG,EAAMtG,SAAW,OACzDsG,EAAMtG,SAAW,KAGnB,OAAOsG,CACT,CAhF6BM,CAAqB/G,GAG9C0E,EAAU2B,EACX,CAAC,MAAOxI,GAIP,MAAMmJ,EACwB,iBAArBhH,GAAS4B,QACZ5B,EAAQ4B,QAAQqF,UAAU,EAAG,KAC7B,4BAEN,IACE/C,MAAM8C,EACP,CAAC,MAAO7C,GAER,CACF,CACH,CAkEA,SAAS+C,EAAiBC,GACxB,IACMA,GAA4B,iBAAXA,IAAwBT,MAAMC,QAAQQ,KACzDpB,EAAgB,IAAKA,KAAkBoB,GAE1C,CAAC,MAAOtJ,GAER,CACH,CAKA,SAASuJ,EAAmBC,GAC1B,IACMA,GAAgC,iBAAbA,IAA0BX,MAAMC,QAAQU,KAC7DlB,EAAkB,IAAKA,KAAoBkB,GAE9C,CAAC,MAAOxJ,GAER,CACH,CAMA,IAEwB,oBAAXyJ,SACTA,OAAOC,kBAAoB,CACzBnB,cACAc,mBACAE,sBAGN,CAAE,MAAOvJ,GAET"}
1
+ {"version":3,"file":"index.esm.mjs","sources":["../src/utils/id.js","../src/components/ToastContainer.js","../src/utils/position.js","../src/utils/dom.js","../src/components/toast-utils.js","../src/components/Toast.js","../src/components/ToastManager.js","../src/index.js"],"sourcesContent":["// src/utils/id.js\r\n\"use strict\";\r\n\r\n/**\r\n * Generate unique ID for DOM elements to avoid conflicts\r\n * @param {string} prefix - Optional prefix for ID\r\n * @returns {string} Unique ID\r\n */\r\nexport async function generateUniqueId(prefix) {\r\n return `${prefix}-${Date.now()}-${Math.floor(Math.random() * 100000)}`;\r\n}\r\n","// src/components/ToastContainer.js //# Container logic\r\n\"use strict\";\r\n\r\nimport { setPosition } from \"../utils/position.js\";\r\nimport { appendChild } from \"../utils/dom.js\";\r\n\r\n/**\r\n * Create toast container with error handling\r\n * @param {string} position - Toast position\r\n * @returns {HTMLElement} Toast container element\r\n */\r\nexport async function createToastContainer(position) {\r\n try {\r\n let toastContainer = document.getElementById(`toast-container-${position}`);\r\n\r\n if (!toastContainer) {\r\n toastContainer = document.createElement(\"div\");\r\n toastContainer.id = `toast-container-${position}`;\r\n toastContainer.style.position = \"fixed\";\r\n toastContainer.style.zIndex = \"9999\";\r\n await setPosition(toastContainer, position);\r\n await appendChild(document.body, toastContainer);\r\n }\r\n\r\n return toastContainer;\r\n } catch (error) {\r\n console.error(\"Failed to create toast container:\", error);\r\n // Fallback: return body element\r\n return document.body;\r\n }\r\n}\r\n","// src/utils/position.js\r\n\"use strict\";\r\n\r\n/**\r\n * Set position for toast container (EXACT same logic as original)\r\n * @param {HTMLElement} container - Toast container element\r\n * @param {string} position - Position string\r\n */\r\nexport async function setPosition(container, position) {\r\n // Reset all position properties first\r\n container.style.top = \"auto\";\r\n container.style.bottom = \"auto\";\r\n container.style.left = \"auto\";\r\n container.style.right = \"auto\";\r\n container.style.transform = \"none\";\r\n\r\n if (position.includes(\"bottom\")) {\r\n container.style.bottom = \"10px\";\r\n } else if (position.includes(\"top\")) {\r\n container.style.top = \"10px\";\r\n }\r\n\r\n if (position.includes(\"right\")) {\r\n container.style.right = \"10px\";\r\n } else if (position.includes(\"left\")) {\r\n container.style.left = \"10px\";\r\n } else if (position.includes(\"center\")) {\r\n container.style.top = \"50%\";\r\n container.style.left = \"50%\";\r\n container.style.transform = \"translate(-50%, -50%)\";\r\n }\r\n}\r\n","// src/utils/dom.js\r\n\"use strict\";\r\n\r\nimport { generateUniqueId } from \"./id.js\";\r\n\r\n/**\r\n * Multi-layer fallback DOM element creation\r\n */\r\nexport async function createElementWithId(tagName, prefix) {\r\n // PRIMARY: Standard createElement\r\n try {\r\n if (!tagName || !prefix) throw new Error(`tagName and prefix is required`);\r\n\r\n const el = document.createElement(tagName);\r\n el.id = generateUniqueId(prefix);\r\n return el;\r\n } catch (error) {\r\n console.warn(`Primary createElement failed for`, error);\r\n\r\n // FALLBACK-A: Try div as alternative\r\n try {\r\n const fallbackTag = \"div\";\r\n const fallbackPrefix = \"fallback\";\r\n const fallbackEl = document.createElement(fallbackTag);\r\n fallbackEl.id = generateUniqueId(fallbackPrefix);\r\n fallbackEl.setAttribute(\"data-original-tag\", fallbackTag);\r\n return fallbackEl;\r\n } catch (fallbackError) {\r\n console.error(\"All DOM creation methods failed:\", fallbackError);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Multi-strategy appendChild with graceful degradation\r\n */\r\nexport async function appendChild(parent, child) {\r\n if (!parent || !child) return false;\r\n\r\n // PRIMARY: Standard appendChild\r\n try {\r\n if (!parent.contains(child)) {\r\n parent.appendChild(child);\r\n return true;\r\n }\r\n return true;\r\n } catch (error) {\r\n console.warn(\"Primary appendChild failed:\", error);\r\n\r\n // FALLBACK-A: insertAdjacentElement\r\n try {\r\n parent.insertAdjacentElement(\"beforeend\", child);\r\n return true;\r\n } catch (fallbackError) {\r\n console.warn(\"Fallback appendChild failed:\", fallbackError);\r\n\r\n // FALLBACK-B: Manual positioning\r\n try {\r\n if (parent === document.body) {\r\n child.style.position = \"fixed\";\r\n child.style.top = \"10px\";\r\n child.style.right = \"10px\";\r\n child.style.zIndex = \"99999\";\r\n document.body.insertAdjacentHTML(\"beforeend\", child.outerHTML || \"\");\r\n return true;\r\n }\r\n } catch (emergencyError) {\r\n console.error(\"All append strategies failed:\", emergencyError);\r\n return false;\r\n }\r\n }\r\n }\r\n return false;\r\n}\r\n\r\n/**\r\n * Safe element removal with multiple strategies\r\n */\r\nexport async function removeElement(el) {\r\n if (!el) return true;\r\n\r\n // PRIMARY: parentNode.removeChild\r\n try {\r\n if (el?.parentNode?.id.includes(\"toast-container-\")) {\r\n el.parentNode.removeChild(el);\r\n return true;\r\n }\r\n } catch (error) {\r\n console.warn(\"Primary removal failed:\", error);\r\n\r\n // FALLBACK-A: element.remove()\r\n try {\r\n if (el.remove) {\r\n el.remove();\r\n return true;\r\n }\r\n } catch (fallbackError) {\r\n console.warn(\"Fallback removal failed:\", fallbackError);\r\n\r\n // FALLBACK-B: Hide instead of remove\r\n try {\r\n el.style.display = \"none\";\r\n el.style.opacity = \"0\";\r\n el.style.pointerEvents = \"none\";\r\n el.style.position = \"absolute\";\r\n el.style.left = \"-9999px\";\r\n return true;\r\n } catch (hideError) {\r\n console.error(\"All removal strategies failed:\", hideError);\r\n return false;\r\n }\r\n }\r\n }\r\n return true;\r\n}\r\n\r\n/**\r\n * Animation duration parser with fallbacks\r\n */\r\nexport function parseAnimationDuration(duration) {\r\n // PRIMARY: Parse provided duration\r\n try {\r\n if (typeof duration === \"number\" && duration > 0) return duration;\r\n if (typeof duration === \"string\") {\r\n if (duration.endsWith(\"s\") && !duration.endsWith(\"ms\")) {\r\n const parsed = parseFloat(duration) * 1000;\r\n return parsed > 0 ? parsed : 500;\r\n }\r\n const parsed = parseFloat(duration);\r\n return parsed > 0 ? parsed : 500;\r\n }\r\n } catch (error) {\r\n console.warn(\"Duration parsing failed:\", error);\r\n }\r\n\r\n // FALLBACK: Safe default\r\n return 500;\r\n}\r\n\r\n/**\r\n * Force reflow with error protection\r\n */\r\nexport function forceReflow(el) {\r\n try {\r\n return el?.offsetWidth || 0;\r\n } catch (error) {\r\n console.warn(\"Force reflow failed:\", error);\r\n return 0;\r\n }\r\n}\r\n\r\n/**\r\n * Query selector shortcut with optional root.\r\n * @param {string} selector\r\n * @param {Document|HTMLElement} [root=document]\r\n * @returns {Element|null}\r\n */\r\nexport function query(selector, root = document) {\r\n return root.querySelector(selector);\r\n}\r\n","\"use strict\";\r\n\r\nimport { forceReflow, parseAnimationDuration } from \"../utils/dom.js\";\r\n\r\n/**\r\n * Create close button for toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport function createCloseButton(toast, options, onClose) {\r\n const closeButton = document.createElement(\"button\");\r\n closeButton.innerHTML = \"&times;\";\r\n Object.assign(closeButton.style, {\r\n background: \"none\",\r\n border: \"none\",\r\n color: options.textColor || \"white\",\r\n fontSize: \"18px\",\r\n marginLeft: \"10px\",\r\n cursor: \"pointer\",\r\n });\r\n\r\n closeButton.onclick = () => onClose(toast);\r\n toast.appendChild(closeButton);\r\n\r\n toast._cleanupCloseButton = () => {\r\n closeButton.onclick = null;\r\n };\r\n}\r\n\r\n/**\r\n * Create progress bar for toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n */\r\nexport function createProgressBar(toast, options) {\r\n const progressBar = document.createElement(\"div\");\r\n Object.assign(progressBar.style, {\r\n position: \"absolute\",\r\n left: \"0\",\r\n height: options.progressHeight || \"4px\",\r\n background: options.progressColor || \"rgba(255, 255, 255, 0.3)\",\r\n width: \"100%\",\r\n transition: `width ${options.duration || 1800}ms linear`,\r\n [options.progressPosition === \"top\" ? \"top\" : \"bottom\"]: \"0\",\r\n });\r\n\r\n toast.appendChild(progressBar);\r\n\r\n setTimeout(() => {\r\n forceReflow(progressBar);\r\n progressBar.style.width = \"0%\";\r\n }, 100);\r\n}\r\n\r\n/**\r\n * Run toast fade-in animation\r\n * @param {HTMLElement} toast - Toast element\r\n */\r\nexport function runToastAnimation(toast) {\r\n setTimeout(() => {\r\n toast.style.opacity = \"1\";\r\n toast.style.transform = \"translateY(0)\";\r\n }, 50);\r\n}\r\n\r\n/**\r\n * Apply rich styling to toast element\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport function applyRichStyling(toast, options, onClose) {\r\n const animDurationMs = parseAnimationDuration(options.animationDuration);\r\n\r\n // Apply full styling\r\n Object.assign(toast.style, {\r\n background: options.backgroundColor || options.color || \"#333\",\r\n color: options.textColor || \"white\",\r\n padding: \"12px 20px\",\r\n marginBottom: \"10px\",\r\n borderRadius: \"5px\",\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n justifyContent: \"space-between\",\r\n boxShadow: \"0 4px 6px rgba(0, 0, 0, 0.1)\",\r\n minWidth: \"250px\",\r\n maxWidth: \"400px\",\r\n opacity: \"0\",\r\n position: \"relative\",\r\n transition: `opacity ${animDurationMs || \"0.5s\"} ${\r\n options.animationEasing || \"ease\"\r\n }, transform ${animDurationMs || \"0.5s\"} ${\r\n options.animationEasing || \"ease\"\r\n }`,\r\n transform: \"translateY(20px)\",\r\n zIndex: \"9999\",\r\n });\r\n\r\n toast._animationDuration = animDurationMs;\r\n\r\n // Message span\r\n const messageSpan = document.createElement(\"span\");\r\n messageSpan.textContent = options.message || \"Notification\";\r\n messageSpan.style.flex = \"1\";\r\n toast.appendChild(messageSpan);\r\n\r\n // Close button\r\n if (options.showCloseButton) {\r\n createCloseButton(toast, options, onClose);\r\n }\r\n\r\n // Progress bar\r\n if (options.showProgressBar) {\r\n createProgressBar(toast, options);\r\n }\r\n\r\n // Animation\r\n runToastAnimation(toast);\r\n}\r\n\r\n/**\r\n * Create basic fallback toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport function createBasicToast(toast, options, onClose) {\r\n // Basic styling only\r\n Object.assign(toast.style, {\r\n background: \"#333\",\r\n color: \"white\",\r\n padding: \"10px 15px\",\r\n margin: \"10px\",\r\n borderRadius: \"3px\",\r\n position: \"fixed\",\r\n top: \"20px\",\r\n right: \"20px\",\r\n zIndex: \"99999\",\r\n maxWidth: \"300px\",\r\n wordWrap: \"break-word\",\r\n });\r\n\r\n toast.textContent = options.message || \"Notification\";\r\n\r\n if (options.showCloseButton) {\r\n toast.style.cursor = \"pointer\";\r\n toast.onclick = () => onClose(toast);\r\n }\r\n\r\n toast._animationDuration = 500;\r\n}\r\n\r\n/**\r\n * Emergency toast as last resort\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport function createEmergencyToast(options, onClose) {\r\n try {\r\n // Create emergency div\r\n const emergency = document.createElement(\"div\");\r\n emergency.id = `emergency-${Date.now()}`;\r\n emergency.innerHTML = `\r\n <div style=\"\r\n background: #333 !important;\r\n color: white !important;\r\n padding: 10px 15px !important;\r\n position: fixed !important;\r\n top: 20px !important;\r\n right: 20px !important;\r\n z-index: 99999 !important;\r\n border-radius: 3px !important;\r\n max-width: 250px !important;\r\n word-wrap: break-word !important;\r\n font-family: Arial, sans-serif !important;\r\n font-size: 14px !important;\r\n box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;\r\n cursor: pointer !important;\r\n \" onclick=\"this.parentNode.removeChild(this)\">\r\n ${options.message || \"Emergency Toast Creation Showing!\"}\r\n <span style=\"float: right; margin-left: 10px; font-weight: bold;\">&times;</span>\r\n </div>\r\n `;\r\n\r\n emergency._animationDuration = 500;\r\n emergency._isEmergencyToast = true;\r\n\r\n // Auto remove\r\n setTimeout(() => {\r\n try {\r\n if (emergency.parentNode) {\r\n emergency.parentNode.removeChild(emergency);\r\n }\r\n onClose(emergency);\r\n } catch (error) {\r\n console.warn(\"Emergency cleanup failed:\", error);\r\n }\r\n }, options.duration || 1800);\r\n\r\n return emergency;\r\n } catch (emergencyError) {\r\n console.error(\"Emergency toast creation failed:\", emergencyError);\r\n\r\n // ULTIMATE FALLBACK: Alert\r\n setTimeout(() => {\r\n try {\r\n alert(options.message || \"Toast Creation Failed!\");\r\n onClose(null);\r\n } catch (alertError) {\r\n console.error(\"Ultimate fallback failed:\", alertError);\r\n onClose(null);\r\n }\r\n }, 100);\r\n\r\n return null;\r\n }\r\n}\r\n\r\nexport async function safeSetTimeout(fn, delay) {\r\n const id = setTimeout(() => {\r\n console.warn(\"Timer fired after\", delay, \"ms\");\r\n fn();\r\n }, delay);\r\n\r\n console.warn(\"Timer scheduled with id:\", id, \"delay:\", delay);\r\n return id;\r\n}\r\n","// src/components/Toast.js //# Single responsibility\r\n\"use strict\";\r\n\r\nimport { createElementWithId } from \"../utils/dom.js\";\r\nimport { applyRichStyling, createEmergencyToast } from \"./toast-utils.js\";\r\n\r\n/**\r\n * Multi-layer toast creation with satellite-grade fallbacks\r\n * @param {Object} options - Toast configuration options\r\n * @param {Function} onClose - Callback when toast closes\r\n * @returns {HTMLElement} Toast element\r\n */\r\nexport async function createToastElement(options, onClose) {\r\n let toastContainer = document.querySelector('[id^=\"toast-container-\"]');\r\n if (!toastContainer) return null;\r\n\r\n let toast;\r\n const tagName = \"div\";\r\n const prefix = \"toast\";\r\n\r\n // PRIMARY: Full-featured toast\r\n try {\r\n toast = await createElementWithId(tagName, prefix);\r\n applyRichStyling(toast, options, onClose);\r\n return toast;\r\n } catch (error) {\r\n console.warn(\"error:\", error);\r\n createEmergencyToast(options, onClose);\r\n return toast;\r\n }\r\n}\r\n","// src/components/ToastManager.js //# State management\r\n\"use strict\";\r\n\r\nimport { createToastContainer } from \"./ToastContainer.js\";\r\nimport { createToastElement } from \"./Toast.js\";\r\nimport { removeElement } from \"../utils/dom.js\";\r\nimport { createEmergencyToast, safeSetTimeout } from \"./toast-utils.js\";\r\n\r\n// State management with fallback tracking\r\nlet isToastShowing = false;\r\nlet emergencyCleanupScheduled = false;\r\nlet currentToast = [];\r\nlet emergencyTimeouts = [];\r\n\r\n/**\r\n * Show toast with comprehensive fallback system\r\n */\r\nexport async function showToast(options) {\r\n // PRIMARY: Full toast system\r\n try {\r\n const container = await createToastContainer(options.position);\r\n const toast = await createToastElement(options, closeToast);\r\n\r\n if (!toast) {\r\n throw new Error(\"Toast element creation failed!\");\r\n }\r\n\r\n currentToast.push(toast);\r\n\r\n // Append to container\r\n if (container.id.includes(\"toast-container-\")) {\r\n container.appendChild(toast);\r\n }\r\n\r\n // Schedule auto-dismiss\r\n const cleanUpTime =\r\n typeof options.duration === \"number\" && options.duration > 0\r\n ? options.duration + 2\r\n : 1800; //safety margin\r\n const dismissTimeout = await safeSetTimeout(\r\n () => closeToast(toast),\r\n cleanUpTime\r\n );\r\n emergencyTimeouts.push(dismissTimeout);\r\n return;\r\n } catch (primaryError) {\r\n console.warn(\r\n \"Primary toast system failed showing emergency toast:\",\r\n primaryError\r\n );\r\n const elContainer = document.querySelector('[id^=\"toast-container-\"]');\r\n const emergencyToast = createEmergencyToast(options, closeToast);\r\n elContainer && elContainer?.id?.includes(\"toast-container-\")\r\n ? elContainer.appendChild(emergencyToast)\r\n : alert(primaryError.substring(0, 200));\r\n return;\r\n }\r\n}\r\n\r\n/**\r\n * Create simple toast for fallback\r\n */\r\nfunction createSimpleToast(options) {\r\n const simple = document.createElement(\"div\");\r\n simple.style.cssText = `\r\n position: fixed !important;\r\n top: 20px !important;\r\n right: 20px !important;\r\n background: #333 !important;\r\n color: white !important;\r\n padding: 12px 20px !important;\r\n border-radius: 5px !important;\r\n z-index: 99999 !important;\r\n max-width: 300px !important;\r\n font-family: Arial, sans-serif !important;\r\n cursor: pointer !important;\r\n `;\r\n simple.textContent = options.message || \"Created Simple Toast!\";\r\n simple.onclick = () => closeToast(simple);\r\n return simple;\r\n}\r\n\r\n/**\r\n * Close toast with multi-strategy cleanup\r\n */\r\nexport async function closeToast(toast) {\r\n if (currentToast.length > 0) {\r\n const index = currentToast.indexOf(toast);\r\n if (index !== -1) {\r\n currentToast.splice(index, 1);\r\n }\r\n }\r\n await removeElement(toast);\r\n}\r\n\r\n/**\r\n * Perform comprehensive cleanup\r\n */\r\nasync function performCleanup(toast) {\r\n try {\r\n // Cleanup event listeners\r\n if (toast._cleanupCloseButton) {\r\n toast._cleanupCloseButton();\r\n }\r\n\r\n // Remove from DOM\r\n removeElement(toast);\r\n\r\n // Reset state\r\n resetToastState();\r\n } catch (error) {\r\n console.error(\"Cleanup failed:\", error);\r\n forceEmergencyCleanup();\r\n }\r\n}\r\n\r\n/**\r\n * Reset all toast state\r\n */\r\nfunction resetToastState() {\r\n isToastShowing = false;\r\n currentToast = [];\r\n\r\n // Clear all timeouts\r\n emergencyTimeouts.forEach((id) => {\r\n try {\r\n clearTimeout(id);\r\n } catch (error) {\r\n console.warn(\"Timeout clear failed:\", error);\r\n }\r\n });\r\n emergencyTimeouts.pop();\r\n emergencyCleanupScheduled = false;\r\n}\r\n\r\n/**\r\n * Schedule emergency cleanup\r\n */\r\nfunction scheduleEmergencyCleanup(duration) {\r\n const cleanUpTime = typeof duration === \"number\" ? duration + 2 : 1800; //safety margin\r\n const emergencyTimeout = setTimeout(() => {\r\n console.warn(\"Emergency cleanup triggered\");\r\n forceEmergencyCleanup();\r\n }, cleanUpTime);\r\n\r\n emergencyTimeouts.push(emergencyTimeout);\r\n}\r\n\r\n/**\r\n * Force emergency cleanup of everything\r\n */\r\nasync function forceEmergencyCleanup() {\r\n try {\r\n // Remove current toast\r\n if (currentToast) {\r\n removeElement(currentToast);\r\n }\r\n\r\n // Clean up any orphaned toast elements\r\n const orphanedToasts = document.querySelectorAll(\r\n '[id^=\"toast-\"]:not([id*=\"container\"]), [id*=\"emergency\"]'\r\n );\r\n orphanedToasts.forEach((element) => {\r\n try {\r\n removeElement(element);\r\n } catch (error) {\r\n console.warn(\"Orphaned element cleanup failed:\", error);\r\n }\r\n });\r\n\r\n // Reset all state\r\n resetToastState();\r\n } catch (error) {\r\n console.error(\"Force cleanup failed:\", error);\r\n // Final state reset\r\n isToastShowing = false;\r\n currentToast = [];\r\n }\r\n}\r\n","// src/index.js\r\n/**\r\n * @fileoverview A simple toast notification library for any JavaScript framework.\r\n * @name Customizable Toast Notifications\r\n * @author Priyanshu Patel\r\n * @version __VERSION__\r\n * @build Production\r\n * @license Apache-2.0\r\n * @depends None\r\n * @description A lightweight and fully customizable toast notification library\r\n * designed for seamless integration with any JavaScript or framework-based UI.\r\n * Supports flexible positioning, theming, icons, animations, and timing options\r\n * out of the box — with zero dependencies.\r\n * Author: Priyanshu Patel\r\n * Email: priyanshu.alt191@gmail.com\r\n * Created: July 31, 2024\r\n * License: Apache-2.0\r\n * Dependencies: None\r\n */\r\n\r\n\"use strict\";\r\n\r\nimport { closeToast, showToast } from \"./components/ToastManager.js\";\r\n\r\n// Protected state with fallbacks\r\nlet defaultColors = {\r\n success: \"#28a745\",\r\n error: \"#dc3545\",\r\n warning: \"#ffc107\",\r\n info: \"#17a2b8\",\r\n};\r\n\r\nlet defaultMessages = {\r\n success: \"Operation completed successfully!\",\r\n error: \"Something went wrong!\",\r\n warning: \"Warning message!\",\r\n info: \"Information message!\",\r\n};\r\n\r\n/**\r\n * Create toast with satellite-grade reliability\r\n */\r\nasync function createToast(options = {}) {\r\n try {\r\n // Input sanitization and validation\r\n const sanitizedOptions = await sanitizeToastOptions(options);\r\n\r\n // Call main toast system\r\n await showToast(sanitizedOptions);\r\n } catch (error) {\r\n console.error(\"CreateToast failed:\", error);\r\n\r\n // ULTIMATE FALLBACK: Browser alert with sanitized message\r\n const safeMessage =\r\n typeof options?.message === \"string\"\r\n ? `${options.message.substring(0, 200)} toast creation failed!`\r\n : \"Toast creation failed!\";\r\n\r\n alert(safeMessage);\r\n }\r\n}\r\n\r\n// Params sanitization and validation for toast creation\r\nasync function sanitizeToastOptions(options) {\r\n const defaults = {\r\n duration: 1800,\r\n position: \"bottom-right\",\r\n type: \"info\",\r\n backgroundColor: undefined,\r\n textColor: \"white\",\r\n showCloseButton: false,\r\n animationDuration: \"0.5s\",\r\n animationEasing: \"ease\",\r\n showProgressBar: false,\r\n progressColor: undefined,\r\n progressHeight: \"4px\",\r\n progressPosition: \"bottom\",\r\n };\r\n\r\n // Start with safe defaults\r\n let final = { ...defaults };\r\n\r\n // Merge user options safely\r\n if (options && typeof options === \"object\" && !Array.isArray(options)) {\r\n Object.keys(defaults).forEach((key) => {\r\n if (options.hasOwnProperty(key)) {\r\n final[key] = options[key];\r\n }\r\n });\r\n\r\n // Handle message separately\r\n if (options.message !== undefined || options.message !== \"undefined\") {\r\n final.message = options.message;\r\n }\r\n }\r\n\r\n // Validate and apply defaults\r\n try {\r\n if (!final.backgroundColor && final.type && defaultColors[final.type]) {\r\n final.backgroundColor = defaultColors[final.type];\r\n }\r\n\r\n if (!final.message && final.type && defaultMessages[final.type]) {\r\n final.message = defaultMessages[final.type];\r\n }\r\n } catch (error) {\r\n console.warn(\"Option processing failed:\", error);\r\n }\r\n\r\n // Final safety checks\r\n if (!final.message || typeof final.message !== \"string\") {\r\n final.message = \"No Message Provided!\";\r\n }\r\n\r\n // should dlt if (typeof final.duration !== \"number\" || final.duration < 100) {\r\n // final.duration = defaults.duration;\r\n // }\r\n\r\n return final;\r\n}\r\n\r\n/**\r\n * Set default colors with validation\r\n */\r\nfunction setDefaultColors(colors) {\r\n try {\r\n if (colors && typeof colors === \"object\" && !Array.isArray(colors)) {\r\n defaultColors = { ...defaultColors, ...colors };\r\n }\r\n } catch (error) {\r\n console.error(\"setDefaultColors failed:\", error);\r\n }\r\n}\r\n\r\n/**\r\n * Set default messages with validation\r\n */\r\nfunction setDefaultMessages(messages) {\r\n try {\r\n if (messages && typeof messages === \"object\" && !Array.isArray(messages)) {\r\n defaultMessages = { ...defaultMessages, ...messages };\r\n }\r\n } catch (error) {\r\n console.error(\"setDefaultMessages failed:\", error);\r\n }\r\n}\r\n\r\nfunction noop() {\r\n const toast = document.querySelector('[id^=\"toast-\"]:not([id*=\"container\"])');\r\n closeToast(toast);\r\n}\r\n\r\n// Module exports\r\nexport { createToast, setDefaultColors, setDefaultMessages, noop };\r\n\r\n// Global assignment with protection\r\ntry {\r\n // UMD/Global support\r\n if (typeof window !== \"undefined\") {\r\n window.customizableToast = {\r\n createToast,\r\n setDefaultColors,\r\n setDefaultMessages,\r\n };\r\n }\r\n} catch (error) {\r\n console.error(\"Global assignment failed:\", error);\r\n}\r\n"],"names":["async","generateUniqueId","prefix","Date","now","Math","floor","random","createToastContainer","position","toastContainer","document","getElementById","createElement","id","style","zIndex","container","top","bottom","left","right","transform","includes","setPosition","parent","child","contains","appendChild","error","insertAdjacentElement","fallbackError","body","insertAdjacentHTML","outerHTML","emergencyError","applyRichStyling","toast","options","onClose","animDurationMs","duration","endsWith","parsed","parseFloat","parseAnimationDuration","animationDuration","Object","assign","background","backgroundColor","color","textColor","padding","marginBottom","borderRadius","display","alignItems","justifyContent","boxShadow","minWidth","maxWidth","opacity","transition","animationEasing","_animationDuration","messageSpan","textContent","message","flex","showCloseButton","closeButton","innerHTML","border","fontSize","marginLeft","cursor","onclick","_cleanupCloseButton","createCloseButton","showProgressBar","progressBar","height","progressHeight","progressColor","width","progressPosition","setTimeout","el","offsetWidth","forceReflow","createProgressBar","runToastAnimation","createEmergencyToast","emergency","_isEmergencyToast","parentNode","removeChild","alert","alertError","createToastElement","querySelector","tagName","Error","fallbackTag","fallbackPrefix","fallbackEl","setAttribute","createElementWithId","currentToast","emergencyTimeouts","showToast","closeToast","push","cleanUpTime","dismissTimeout","fn","delay","safeSetTimeout","primaryError","elContainer","emergencyToast","substring","length","index","indexOf","splice","remove","pointerEvents","hideError","removeElement","defaultColors","success","warning","info","defaultMessages","createToast","sanitizedOptions","defaults","type","undefined","final","Array","isArray","keys","forEach","key","hasOwnProperty","sanitizeToastOptions","safeMessage","setDefaultColors","colors","setDefaultMessages","messages","noop","window","customizableToast"],"mappings":";;;;;;;;;;;;;;AAQOA,eAAeC,EAAiBC,GACrC,MAAO,GAAGA,KAAUC,KAAKC,SAASC,KAAKC,MAAsB,IAAhBD,KAAKE,WACpD,CCCOP,eAAeQ,EAAqBC,GACzC,IACE,IAAIC,EAAiBC,SAASC,eAAe,mBAAmBH,KAWhE,OATKC,IACHA,EAAiBC,SAASE,cAAc,OACxCH,EAAeI,GAAK,mBAAmBL,IACvCC,EAAeK,MAAMN,SAAW,QAChCC,EAAeK,MAAMC,OAAS,aCX7BhB,eAA2BiB,EAAWR,GAE3CQ,EAAUF,MAAMG,IAAM,OACtBD,EAAUF,MAA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AC9DE,EAAM3F,gBAAkBiF,EAAcU,EAAMF,QAGzCE,EAAMzE,SAAWyE,EAAMF,MAAQJ,EAAgBM,EAAMF,QACxDE,EAAMzE,QAAUmE,EAAgBM,EAAMF,MAEzC,CAAC,MAAO9G,GAER,CAGIgH,EAAMzE,SAAoC,iBAAlByE,EAAMzE,UACjCyE,EAAMzE,QAAU,wBAOlB,OAAOyE,CACT,CA1EmCO,CAAqB9G,SAG9CyE,EAAU0B,EACjB,CAAC,MAAO5G,GAIP,MAAMwH,EACwB,iBAArB/G,GAAS8B,QACZ,GAAG9B,EAAQ8B,QAAQsD,UAAU,EAAG,8BAChC,yBAENxB,MAAMmD,EACP,CACH,CAgEA,SAASC,EAAiBC,GACxB,IACMA,GAA4B,iBAAXA,IAAwBT,MAAMC,QAAQQ,KACzDpB,EAAgB,IAAKA,KAAkBoB,GAE1C,CAAC,MAAO1H,GAER,CACH,CAKA,SAAS2H,EAAmBC,GAC1B,IACMA,GAAgC,iBAAbA,IAA0BX,MAAMC,QAAQU,KAC7DlB,EAAkB,IAAKA,KAAoBkB,GAE9C,CAAC,MAAO5H,GAER,CACH,CAEA,SAAS6H,IAEP1C,EADcrG,SAAS0F,cAAc,yCAEvC,CAMA,IAEwB,oBAAXsD,SACTA,OAAOC,kBAAoB,CACzBpB,cACAc,mBACAE,sBAGN,CAAE,MAAO3H,GAET"}
package/dist/index.umd.js CHANGED
@@ -1,13 +1,16 @@
1
1
  /*!
2
- * Customizable Toast Notifications 3.4.0
3
- * Build: 2025-07-19 18:22:36
4
- * Cache-Buster: 1752949356123
2
+ * Customizable Toast Notifications 3.5.1
3
+ * Build: 2025-08-27 18:05:24
4
+ * Cache-Buster: 1756317924370
5
5
  * Author: Priyanshu Patel
6
6
  * Email: priyanshu.alt191@gmail.com
7
7
  * License: Apache-2.0
8
8
  * Dependencies: None
9
9
  * Created: July 31, 2024
10
- * A lightweight toast notification library for any JavaScript framework
10
+ * A lightweight and fully customizable toast notification library
11
+ * designed for seamless integration with any JavaScript or framework-based UI.
12
+ * Supports flexible positioning, theming, icons, animations, and timing options
13
+ * out of the box — with zero dependencies.
11
14
  */
12
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).customizableToast={})}(this,function(t){"use strict";function e(t="toast"){return`${t}-${Date.now()}-${Math.floor(1e5*Math.random())}`}function n(t){if(!t)return!0;try{if(t.parentNode)return t.parentNode.removeChild(t),!0}catch(e){try{if(t.remove)return t.remove(),!0}catch(e){try{return t.style.display="none",t.style.opacity="0",t.style.pointerEvents="none",t.style.position="absolute",t.style.left="-9999px",!0}catch(t){return!1}}}return!0}function o(t){try{let e=document.getElementById(`toast-container-${t}`);return e||(e=document.createElement("div"),e.id=`toast-container-${t}`,e.style.position="fixed",e.style.zIndex="9999",function(t,e){t.style.top="auto",t.style.bottom="auto",t.style.left="auto",t.style.right="auto",t.style.transform="none",e.includes("bottom")?t.style.bottom="10px":e.includes("top")&&(t.style.top="10px"),e.includes("right")?t.style.right="10px":e.includes("left")?t.style.left="10px":e.includes("center")&&(t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)")}(e,t),function(t,e){if(!t||!e)return!1;try{return t.contains(e)||t.appendChild(e),!0}catch(n){try{return t.insertAdjacentElement("beforeend",e),!0}catch(n){try{if(t===document.body)return e.style.position="fixed",e.style.top="10px",e.style.right="10px",e.style.zIndex="99999",document.body.insertAdjacentHTML("beforeend",e.outerHTML||""),!0}catch(t){return!1}}}}(document.body,e)),e}catch(t){return document.body}}function r(t,e,n){const o=function(t){try{if("number"==typeof t&&t>0)return t;if("string"==typeof t){if(t.endsWith("s")&&!t.endsWith("ms")){const e=1e3*parseFloat(t);return e>0?e:500}const e=parseFloat(t);return e>0?e:500}}catch(t){}return 500}(e.animationDuration||"0.5s");Object.assign(t.style,{background:e.backgroundColor||e.color||"#333",color:e.textColor||"white",padding:"12px 20px",marginBottom:"10px",borderRadius:"5px",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",minWidth:"250px",maxWidth:"400px",opacity:"0",position:"relative",transition:`opacity ${e.animationDuration||"0.5s"} ${e.animationEasing||"ease"}, transform ${e.animationDuration||"0.5s"} ${e.animationEasing||"ease"}`,transform:"translateY(20px)",zIndex:"9999"}),t._animationDuration=o;const r=document.createElement("span");r.textContent=e.message||"Notification",r.style.flex="1",t.appendChild(r),e.showCloseButton&&function(t,e,n){const o=document.createElement("button");o.innerHTML="&times;",Object.assign(o.style,{background:"none",border:"none",color:e.textColor||"white",fontSize:"18px",marginLeft:"10px",cursor:"pointer"}),o.onclick=()=>n(t),t.appendChild(o),t._cleanupCloseButton=()=>{o.onclick=null}}(t,e,n),e.showProgressBar&&function(t,e){const n=document.createElement("div");Object.assign(n.style,{position:"absolute",left:"0",height:e.progressHeight||"4px",background:e.progressColor||"rgba(255, 255, 255, 0.3)",width:"100%",transition:`width ${e.duration||3e3}ms linear`,["top"===e.progressPosition?"top":"bottom"]:"0"}),t.appendChild(n),setTimeout(()=>{!function(t){try{return t?.offsetWidth||0}catch(t){return 0}}(n),n.style.width="0%"},100)}(t,e),function(t){setTimeout(()=>{t.style.opacity="1",t.style.transform="translateY(0)"},50)}(t)}function i(t,n){let o,i=!1;try{o=function(t,n){try{const o=document.createElement(t);return o.id=e(n),o}catch(o){try{const o=document.createElement("div");return o.id=e(n||"fallback"),o.setAttribute("data-original-tag",t),o}catch(t){return{id:e(n||"emergency"),style:{},appendChild:()=>{},setAttribute:()=>{},innerHTML:"",textContent:"",onclick:null,_isEmergencyElement:!0}}}}("div","toast"),o._isEmergencyElement&&(i=!0)}catch(t){i=!0,o={id:`emergency-toast-${Date.now()}`,style:{},appendChild:()=>{},innerHTML:"",textContent:"",_isEmergencyElement:!0}}if(!i)try{return r(o,t,n),o}catch(t){i=!0}if(i&&!o._isEmergencyElement)try{return function(t,e,n){Object.assign(t.style,{background:"#333",color:"white",padding:"10px 15px",margin:"10px",borderRadius:"3px",position:"fixed",top:"20px",right:"20px",zIndex:"99999",maxWidth:"300px",wordWrap:"break-word"}),t.textContent=e.message||"Notification",e.showCloseButton&&(t.style.cursor="pointer",t.onclick=()=>n(t)),t._animationDuration=500}(o,t,n),o}catch(t){}return function(t,e){try{const n=document.createElement("div");return n.id=`emergency-${Date.now()}`,n.innerHTML=`\n <div style="\n background: #333 !important;\n color: white !important;\n padding: 10px 15px !important;\n position: fixed !important;\n top: 20px !important;\n right: 20px !important;\n z-index: 99999 !important;\n border-radius: 3px !important;\n max-width: 250px !important;\n word-wrap: break-word !important;\n font-family: Arial, sans-serif !important;\n font-size: 14px !important;\n box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;\n cursor: pointer !important;\n " onclick="this.parentNode.removeChild(this)">\n ${t.message||"Notification"}\n <span style="float: right; margin-left: 10px; font-weight: bold;">&times;</span>\n </div>\n `,n._animationDuration=500,n._isEmergencyToast=!0,setTimeout(()=>{try{n.parentNode&&n.parentNode.removeChild(n),e(n)}catch(t){}},t.duration||3e3),n}catch(n){return setTimeout(()=>{try{alert(t.message||"Toast Notification"),e(null)}catch(t){e(null)}},100),null}}(t,n)}let a=!1,s=null,c=new Set,l=!1;function u(t){if(!a){a=!0;try{const e=o(t.position),n=i(t,d);if(!n)throw new Error("Toast creation returned null");s=n,e.appendChild?e.appendChild(n):document.body.appendChild(n);const r=setTimeout(()=>{d(n)},t.duration||3e3);return c.add(r),void function(t){if(l)return;l=!0;const e=setTimeout(()=>{y()},2.5*t);c.add(e)}(t.duration||3e3)}catch(t){}try{const e=function(t){const e=document.createElement("div");return e.style.cssText="\n position: fixed !important;\n top: 20px !important;\n right: 20px !important;\n background: #333 !important;\n color: white !important;\n padding: 12px 20px !important;\n border-radius: 5px !important;\n z-index: 99999 !important;\n max-width: 300px !important;\n font-family: Arial, sans-serif !important;\n cursor: pointer !important;\n ",e.textContent=t.message||"Notification",e.onclick=()=>d(e),e}(t);return s=e,document.body.appendChild(e),void setTimeout(()=>{d(e)},t.duration||3e3)}catch(t){}try{alert(t.message||"Notification"),a=!1}catch(t){a=!1}}}function d(t){try{if(!t)return void m();if(t.style&&!t._isEmergencyToast){t.style.opacity="0",t.style.transform="translateY(-20px)";const e=t._animationDuration||500;setTimeout(()=>{p(t)},e)}else p(t)}catch(t){y()}}function p(t){try{t._cleanupCloseButton&&t._cleanupCloseButton(),n(t),m()}catch(t){y()}}function m(){a=!1,s=null,c.forEach(t=>{try{clearTimeout(t)}catch(t){}}),c.clear(),l=!1}function y(){try{s&&n(s);document.querySelectorAll('[id*="toast"], [id*="emergency"]').forEach(t=>{try{n(t)}catch(t){}}),m()}catch(t){a=!1,s=null}}let f={success:"#28a745",error:"#dc3545",warning:"#ffc107",info:"#17a2b8"},h={success:"Operation completed successfully!",error:"Something went wrong!",warning:"Warning message!",info:"Information message!"};function g(t={}){try{const e=function(t){const e={duration:3e3,position:"bottom-right",type:"info",backgroundColor:void 0,textColor:"white",showCloseButton:!1,animationDuration:"0.5s",animationEasing:"ease",showProgressBar:!1,progressColor:void 0,progressHeight:"4px",progressPosition:"bottom"};let n={...e};t&&"object"==typeof t&&!Array.isArray(t)&&(Object.keys(e).forEach(e=>{t.hasOwnProperty(e)&&(n[e]=t[e])}),void 0!==t.message&&(n.message=t.message));try{!n.backgroundColor&&n.type&&f[n.type]&&(n.backgroundColor=f[n.type]),!n.message&&n.type&&h[n.type]&&(n.message=h[n.type])}catch(t){}n.message&&"string"==typeof n.message||(n.message="Notification");("number"!=typeof n.duration||n.duration<100)&&(n.duration=3e3);return n}(t);u(e)}catch(e){const n="string"==typeof t?.message?t.message.substring(0,200):"Toast notification failed";try{alert(n)}catch(t){}}}function x(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(f={...f,...t})}catch(t){}}function b(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(h={...h,...t})}catch(t){}}try{"undefined"!=typeof window&&(window.customizableToast={createToast:g,setDefaultColors:x,setDefaultMessages:b})}catch(t){}t.createToast=g,t.setDefaultColors=x,t.setDefaultMessages=b,Object.defineProperty(t,"__esModule",{value:!0})});
15
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).customizableToast={})}(this,function(t){"use strict";async function e(t){return`${t}-${Date.now()}-${Math.floor(1e5*Math.random())}`}async function n(t){try{let e=document.getElementById(`toast-container-${t}`);return e||(e=document.createElement("div"),e.id=`toast-container-${t}`,e.style.position="fixed",e.style.zIndex="9999",await async function(t,e){t.style.top="auto",t.style.bottom="auto",t.style.left="auto",t.style.right="auto",t.style.transform="none",e.includes("bottom")?t.style.bottom="10px":e.includes("top")&&(t.style.top="10px"),e.includes("right")?t.style.right="10px":e.includes("left")?t.style.left="10px":e.includes("center")&&(t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)")}(e,t),await async function(t,e){if(!t||!e)return!1;try{return t.contains(e)||t.appendChild(e),!0}catch(n){try{return t.insertAdjacentElement("beforeend",e),!0}catch(n){try{if(t===document.body)return e.style.position="fixed",e.style.top="10px",e.style.right="10px",e.style.zIndex="99999",document.body.insertAdjacentHTML("beforeend",e.outerHTML||""),!0}catch(t){return!1}}}return!1}(document.body,e)),e}catch(t){return document.body}}function o(t,e,n){const o=function(t){try{if("number"==typeof t&&t>0)return t;if("string"==typeof t){if(t.endsWith("s")&&!t.endsWith("ms")){const e=1e3*parseFloat(t);return e>0?e:500}const e=parseFloat(t);return e>0?e:500}}catch(t){}return 500}(e.animationDuration);Object.assign(t.style,{background:e.backgroundColor||e.color||"#333",color:e.textColor||"white",padding:"12px 20px",marginBottom:"10px",borderRadius:"5px",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",minWidth:"250px",maxWidth:"400px",opacity:"0",position:"relative",transition:`opacity ${o||"0.5s"} ${e.animationEasing||"ease"}, transform ${o||"0.5s"} ${e.animationEasing||"ease"}`,transform:"translateY(20px)",zIndex:"9999"}),t._animationDuration=o;const r=document.createElement("span");r.textContent=e.message||"Notification",r.style.flex="1",t.appendChild(r),e.showCloseButton&&function(t,e,n){const o=document.createElement("button");o.innerHTML="&times;",Object.assign(o.style,{background:"none",border:"none",color:e.textColor||"white",fontSize:"18px",marginLeft:"10px",cursor:"pointer"}),o.onclick=()=>n(t),t.appendChild(o),t._cleanupCloseButton=()=>{o.onclick=null}}(t,e,n),e.showProgressBar&&function(t,e){const n=document.createElement("div");Object.assign(n.style,{position:"absolute",left:"0",height:e.progressHeight||"4px",background:e.progressColor||"rgba(255, 255, 255, 0.3)",width:"100%",transition:`width ${e.duration||1800}ms linear`,["top"===e.progressPosition?"top":"bottom"]:"0"}),t.appendChild(n),setTimeout(()=>{!function(t){try{return t?.offsetWidth||0}catch(t){return 0}}(n),n.style.width="0%"},100)}(t,e),function(t){setTimeout(()=>{t.style.opacity="1",t.style.transform="translateY(0)"},50)}(t)}function r(t,e){try{const n=document.createElement("div");return n.id=`emergency-${Date.now()}`,n.innerHTML=`\n <div style="\n background: #333 !important;\n color: white !important;\n padding: 10px 15px !important;\n position: fixed !important;\n top: 20px !important;\n right: 20px !important;\n z-index: 99999 !important;\n border-radius: 3px !important;\n max-width: 250px !important;\n word-wrap: break-word !important;\n font-family: Arial, sans-serif !important;\n font-size: 14px !important;\n box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;\n cursor: pointer !important;\n " onclick="this.parentNode.removeChild(this)">\n ${t.message||"Emergency Toast Creation Showing!"}\n <span style="float: right; margin-left: 10px; font-weight: bold;">&times;</span>\n </div>\n `,n._animationDuration=500,n._isEmergencyToast=!0,setTimeout(()=>{try{n.parentNode&&n.parentNode.removeChild(n),e(n)}catch(t){}},t.duration||1800),n}catch(n){return setTimeout(()=>{try{alert(t.message||"Toast Creation Failed!"),e(null)}catch(t){e(null)}},100),null}}async function i(t,n){let i;if(!document.querySelector('[id^="toast-container-"]'))return null;try{return i=await async function(t,n){try{if(!t||!n)throw new Error("tagName and prefix is required");const o=document.createElement(t);return o.id=e(n),o}catch(t){try{const t="div",n="fallback",o=document.createElement(t);return o.id=e(n),o.setAttribute("data-original-tag",t),o}catch(t){}}}("div","toast"),o(i,t,n),i}catch(e){return r(t,n),i}}let a=[],s=[];async function c(t){try{const e=await n(t.position),o=await i(t,l);if(!o)throw new Error("Toast element creation failed!");a.push(o),e.id.includes("toast-container-")&&e.appendChild(o);const r="number"==typeof t.duration&&t.duration>0?t.duration+2:1800,c=await async function(t,e){return setTimeout(()=>{t()},e)}(()=>l(o),r);return void s.push(c)}catch(e){const n=document.querySelector('[id^="toast-container-"]'),o=r(t,l);return void(n&&n?.id?.includes("toast-container-")?n.appendChild(o):alert(e.substring(0,200)))}}async function l(t){if(a.length>0){const e=a.indexOf(t);-1!==e&&a.splice(e,1)}await async function(t){if(!t)return!0;try{if(t?.parentNode?.id.includes("toast-container-"))return t.parentNode.removeChild(t),!0}catch(e){try{if(t.remove)return t.remove(),!0}catch(e){try{return t.style.display="none",t.style.opacity="0",t.style.pointerEvents="none",t.style.position="absolute",t.style.left="-9999px",!0}catch(t){return!1}}}return!0}(t)}let u={success:"#28a745",error:"#dc3545",warning:"#ffc107",info:"#17a2b8"},d={success:"Operation completed successfully!",error:"Something went wrong!",warning:"Warning message!",info:"Information message!"};async function p(t={}){try{const e=await async function(t){const e={duration:1800,position:"bottom-right",type:"info",backgroundColor:void 0,textColor:"white",showCloseButton:!1,animationDuration:"0.5s",animationEasing:"ease",showProgressBar:!1,progressColor:void 0,progressHeight:"4px",progressPosition:"bottom"};let n={...e};t&&"object"==typeof t&&!Array.isArray(t)&&(Object.keys(e).forEach(e=>{t.hasOwnProperty(e)&&(n[e]=t[e])}),void 0===t.message&&"undefined"===t.message||(n.message=t.message));try{!n.backgroundColor&&n.type&&u[n.type]&&(n.backgroundColor=u[n.type]),!n.message&&n.type&&d[n.type]&&(n.message=d[n.type])}catch(t){}n.message&&"string"==typeof n.message||(n.message="No Message Provided!");return n}(t);await c(e)}catch(e){const n="string"==typeof t?.message?`${t.message.substring(0,200)} toast creation failed!`:"Toast creation failed!";alert(n)}}function y(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(u={...u,...t})}catch(t){}}function m(t){try{t&&"object"==typeof t&&!Array.isArray(t)&&(d={...d,...t})}catch(t){}}try{"undefined"!=typeof window&&(window.customizableToast={createToast:p,setDefaultColors:y,setDefaultMessages:m})}catch(t){}t.createToast=p,t.noop=function(){l(document.querySelector('[id^="toast-"]:not([id*="container"])'))},t.setDefaultColors=y,t.setDefaultMessages=m,Object.defineProperty(t,"__esModule",{value:!0})});
13
16
  //# sourceMappingURL=index.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/utils/id.js","../src/utils/dom.js","../src/components/ToastContainer.js","../src/utils/position.js","../src/components/toast-utils.js","../src/components/Toast.js","../src/components/ToastManager.js","../src/index.js"],"sourcesContent":["// src/utils/id.js\r\n\"use strict\";\r\n\r\n/**\r\n * Generate unique ID for DOM elements to avoid conflicts\r\n * @param {string} prefix - Optional prefix for ID\r\n * @returns {string} Unique ID\r\n */\r\nexport function generateUniqueId(prefix = \"toast\") {\r\n return `${prefix}-${Date.now()}-${Math.floor(Math.random() * 100000)}`;\r\n}\r\n","// src/utils/dom.js\r\n\"use strict\";\r\n\r\nimport { generateUniqueId } from \"./id.js\";\r\n\r\n/**\r\n * Multi-layer fallback DOM element creation\r\n */\r\nexport function createElementWithId(tagName, prefix) {\r\n // PRIMARY: Standard createElement\r\n try {\r\n const el = document.createElement(tagName);\r\n el.id = generateUniqueId(prefix);\r\n return el;\r\n } catch (error) {\r\n console.warn(`Primary createElement failed for ${tagName}:`, error);\r\n\r\n // FALLBACK-A: Try div as alternative\r\n try {\r\n const fallbackEl = document.createElement(\"div\");\r\n fallbackEl.id = generateUniqueId(prefix || \"fallback\");\r\n fallbackEl.setAttribute(\"data-original-tag\", tagName);\r\n return fallbackEl;\r\n } catch (fallbackError) {\r\n console.error(\"All DOM creation methods failed:\", fallbackError);\r\n\r\n // FALLBACK-B: Return minimal object that won't crash\r\n return {\r\n id: generateUniqueId(prefix || \"emergency\"),\r\n style: {},\r\n appendChild: () => {},\r\n setAttribute: () => {},\r\n innerHTML: \"\",\r\n textContent: \"\",\r\n onclick: null,\r\n _isEmergencyElement: true,\r\n };\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Multi-strategy appendChild with graceful degradation\r\n */\r\nexport function appendChild(parent, child) {\r\n if (!parent || !child) return false;\r\n\r\n // PRIMARY: Standard appendChild\r\n try {\r\n if (!parent.contains(child)) {\r\n parent.appendChild(child);\r\n return true;\r\n }\r\n return true;\r\n } catch (error) {\r\n console.warn(\"Primary appendChild failed:\", error);\r\n\r\n // FALLBACK-A: insertAdjacentElement\r\n try {\r\n parent.insertAdjacentElement(\"beforeend\", child);\r\n return true;\r\n } catch (fallbackError) {\r\n console.warn(\"Fallback appendChild failed:\", fallbackError);\r\n\r\n // FALLBACK-B: Manual positioning\r\n try {\r\n if (parent === document.body) {\r\n child.style.position = \"fixed\";\r\n child.style.top = \"10px\";\r\n child.style.right = \"10px\";\r\n child.style.zIndex = \"99999\";\r\n document.body.insertAdjacentHTML(\"beforeend\", child.outerHTML || \"\");\r\n return true;\r\n }\r\n } catch (emergencyError) {\r\n console.error(\"All append strategies failed:\", emergencyError);\r\n return false;\r\n }\r\n }\r\n }\r\n return false;\r\n}\r\n\r\n/**\r\n * Safe element removal with multiple strategies\r\n */\r\nexport function removeElement(el) {\r\n if (!el) return true;\r\n\r\n // PRIMARY: parentNode.removeChild\r\n try {\r\n if (el.parentNode) {\r\n el.parentNode.removeChild(el);\r\n return true;\r\n }\r\n } catch (error) {\r\n console.warn(\"Primary removal failed:\", error);\r\n\r\n // FALLBACK-A: element.remove()\r\n try {\r\n if (el.remove) {\r\n el.remove();\r\n return true;\r\n }\r\n } catch (fallbackError) {\r\n console.warn(\"Fallback removal failed:\", fallbackError);\r\n\r\n // FALLBACK-B: Hide instead of remove\r\n try {\r\n el.style.display = \"none\";\r\n el.style.opacity = \"0\";\r\n el.style.pointerEvents = \"none\";\r\n el.style.position = \"absolute\";\r\n el.style.left = \"-9999px\";\r\n return true;\r\n } catch (hideError) {\r\n console.error(\"All removal strategies failed:\", hideError);\r\n return false;\r\n }\r\n }\r\n }\r\n return true;\r\n}\r\n\r\n/**\r\n * Animation duration parser with fallbacks\r\n */\r\nexport function parseAnimationDuration(duration) {\r\n // PRIMARY: Parse provided duration\r\n try {\r\n if (typeof duration === \"number\" && duration > 0) return duration;\r\n if (typeof duration === \"string\") {\r\n if (duration.endsWith(\"s\") && !duration.endsWith(\"ms\")) {\r\n const parsed = parseFloat(duration) * 1000;\r\n return parsed > 0 ? parsed : 500;\r\n }\r\n const parsed = parseFloat(duration);\r\n return parsed > 0 ? parsed : 500;\r\n }\r\n } catch (error) {\r\n console.warn(\"Duration parsing failed:\", error);\r\n }\r\n\r\n // FALLBACK: Safe default\r\n return 500;\r\n}\r\n\r\n/**\r\n * Force reflow with error protection\r\n */\r\nexport function forceReflow(el) {\r\n try {\r\n return el?.offsetWidth || 0;\r\n } catch (error) {\r\n console.warn(\"Force reflow failed:\", error);\r\n return 0;\r\n }\r\n}\r\n\r\n/**\r\n * Query selector shortcut with optional root.\r\n * @param {string} selector\r\n * @param {Document|HTMLElement} [root=document]\r\n * @returns {Element|null}\r\n */\r\nexport function query(selector, root = document) {\r\n return root.querySelector(selector);\r\n}\r\n","// src/components/ToastContainer.js //# Container logic\r\n\"use strict\";\r\n\r\nimport { setPosition } from \"../utils/position.js\";\r\nimport { appendChild } from \"../utils/dom.js\";\r\n\r\n/**\r\n * Create toast container with error handling\r\n * @param {string} position - Toast position\r\n * @returns {HTMLElement} Toast container element\r\n */\r\nexport function createToastContainer(position) {\r\n try {\r\n let toastContainer = document.getElementById(`toast-container-${position}`);\r\n\r\n if (!toastContainer) {\r\n toastContainer = document.createElement(\"div\");\r\n toastContainer.id = `toast-container-${position}`;\r\n toastContainer.style.position = \"fixed\";\r\n toastContainer.style.zIndex = \"9999\";\r\n setPosition(toastContainer, position);\r\n appendChild(document.body, toastContainer);\r\n }\r\n\r\n return toastContainer;\r\n } catch (error) {\r\n console.error(\"Failed to create toast container:\", error);\r\n // Fallback: return body element\r\n return document.body;\r\n }\r\n}\r\n","// src/utils/position.js\r\n\"use strict\";\r\n\r\n/**\r\n * Set position for toast container (EXACT same logic as original)\r\n * @param {HTMLElement} container - Toast container element\r\n * @param {string} position - Position string\r\n */\r\nexport function setPosition(container, position) {\r\n // Reset all position properties first\r\n container.style.top = \"auto\";\r\n container.style.bottom = \"auto\";\r\n container.style.left = \"auto\";\r\n container.style.right = \"auto\";\r\n container.style.transform = \"none\";\r\n\r\n if (position.includes(\"bottom\")) {\r\n container.style.bottom = \"10px\";\r\n } else if (position.includes(\"top\")) {\r\n container.style.top = \"10px\";\r\n }\r\n\r\n if (position.includes(\"right\")) {\r\n container.style.right = \"10px\";\r\n } else if (position.includes(\"left\")) {\r\n container.style.left = \"10px\";\r\n } else if (position.includes(\"center\")) {\r\n container.style.top = \"50%\";\r\n container.style.left = \"50%\";\r\n container.style.transform = \"translate(-50%, -50%)\";\r\n }\r\n}\r\n","\"use strict\";\r\n\r\nimport { forceReflow, parseAnimationDuration } from \"../utils/dom.js\";\r\n\r\n/**\r\n * Create close button for toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport function createCloseButton(toast, options, onClose) {\r\n const closeButton = document.createElement(\"button\");\r\n closeButton.innerHTML = \"&times;\";\r\n Object.assign(closeButton.style, {\r\n background: \"none\",\r\n border: \"none\",\r\n color: options.textColor || \"white\",\r\n fontSize: \"18px\",\r\n marginLeft: \"10px\",\r\n cursor: \"pointer\",\r\n });\r\n\r\n closeButton.onclick = () => onClose(toast);\r\n toast.appendChild(closeButton);\r\n\r\n toast._cleanupCloseButton = () => {\r\n closeButton.onclick = null;\r\n };\r\n}\r\n\r\n/**\r\n * Create progress bar for toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n */\r\nexport function createProgressBar(toast, options) {\r\n const progressBar = document.createElement(\"div\");\r\n Object.assign(progressBar.style, {\r\n position: \"absolute\",\r\n left: \"0\",\r\n height: options.progressHeight || \"4px\",\r\n background: options.progressColor || \"rgba(255, 255, 255, 0.3)\",\r\n width: \"100%\",\r\n transition: `width ${options.duration || 3000}ms linear`,\r\n [options.progressPosition === \"top\" ? \"top\" : \"bottom\"]: \"0\",\r\n });\r\n\r\n toast.appendChild(progressBar);\r\n\r\n setTimeout(() => {\r\n forceReflow(progressBar);\r\n progressBar.style.width = \"0%\";\r\n }, 100);\r\n}\r\n\r\n/**\r\n * Run toast fade-in animation\r\n * @param {HTMLElement} toast - Toast element\r\n */\r\nexport function runToastAnimation(toast) {\r\n setTimeout(() => {\r\n toast.style.opacity = \"1\";\r\n toast.style.transform = \"translateY(0)\";\r\n }, 50);\r\n}\r\n\r\n/**\r\n * Apply rich styling to toast element\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport function applyRichStyling(toast, options, onClose) {\r\n const animDurationMs = parseAnimationDuration(\r\n options.animationDuration || \"0.5s\"\r\n );\r\n\r\n // Apply full styling\r\n Object.assign(toast.style, {\r\n background: options.backgroundColor || options.color || \"#333\",\r\n color: options.textColor || \"white\",\r\n padding: \"12px 20px\",\r\n marginBottom: \"10px\",\r\n borderRadius: \"5px\",\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n justifyContent: \"space-between\",\r\n boxShadow: \"0 4px 6px rgba(0, 0, 0, 0.1)\",\r\n minWidth: \"250px\",\r\n maxWidth: \"400px\",\r\n opacity: \"0\",\r\n position: \"relative\",\r\n transition: `opacity ${options.animationDuration || \"0.5s\"} ${\r\n options.animationEasing || \"ease\"\r\n }, transform ${options.animationDuration || \"0.5s\"} ${\r\n options.animationEasing || \"ease\"\r\n }`,\r\n transform: \"translateY(20px)\",\r\n zIndex: \"9999\",\r\n });\r\n\r\n toast._animationDuration = animDurationMs;\r\n\r\n // Message span\r\n const messageSpan = document.createElement(\"span\");\r\n messageSpan.textContent = options.message || \"Notification\";\r\n messageSpan.style.flex = \"1\";\r\n toast.appendChild(messageSpan);\r\n\r\n // Close button\r\n if (options.showCloseButton) {\r\n createCloseButton(toast, options, onClose);\r\n }\r\n\r\n // Progress bar\r\n if (options.showProgressBar) {\r\n createProgressBar(toast, options);\r\n }\r\n\r\n // Animation\r\n runToastAnimation(toast);\r\n}\r\n\r\n/**\r\n * Create basic fallback toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport function createBasicToast(toast, options, onClose) {\r\n // Basic styling only\r\n Object.assign(toast.style, {\r\n background: \"#333\",\r\n color: \"white\",\r\n padding: \"10px 15px\",\r\n margin: \"10px\",\r\n borderRadius: \"3px\",\r\n position: \"fixed\",\r\n top: \"20px\",\r\n right: \"20px\",\r\n zIndex: \"99999\",\r\n maxWidth: \"300px\",\r\n wordWrap: \"break-word\",\r\n });\r\n\r\n toast.textContent = options.message || \"Notification\";\r\n\r\n if (options.showCloseButton) {\r\n toast.style.cursor = \"pointer\";\r\n toast.onclick = () => onClose(toast);\r\n }\r\n\r\n toast._animationDuration = 500;\r\n}\r\n\r\n/**\r\n * Emergency toast as last resort\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport function createEmergencyToast(options, onClose) {\r\n try {\r\n // Create emergency div\r\n const emergency = document.createElement(\"div\");\r\n emergency.id = `emergency-${Date.now()}`;\r\n emergency.innerHTML = `\r\n <div style=\"\r\n background: #333 !important;\r\n color: white !important;\r\n padding: 10px 15px !important;\r\n position: fixed !important;\r\n top: 20px !important;\r\n right: 20px !important;\r\n z-index: 99999 !important;\r\n border-radius: 3px !important;\r\n max-width: 250px !important;\r\n word-wrap: break-word !important;\r\n font-family: Arial, sans-serif !important;\r\n font-size: 14px !important;\r\n box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;\r\n cursor: pointer !important;\r\n \" onclick=\"this.parentNode.removeChild(this)\">\r\n ${options.message || \"Notification\"}\r\n <span style=\"float: right; margin-left: 10px; font-weight: bold;\">&times;</span>\r\n </div>\r\n `;\r\n\r\n emergency._animationDuration = 500;\r\n emergency._isEmergencyToast = true;\r\n\r\n // Auto remove\r\n setTimeout(() => {\r\n try {\r\n if (emergency.parentNode) {\r\n emergency.parentNode.removeChild(emergency);\r\n }\r\n onClose(emergency);\r\n } catch (error) {\r\n console.warn(\"Emergency cleanup failed:\", error);\r\n }\r\n }, options.duration || 3000);\r\n\r\n return emergency;\r\n } catch (emergencyError) {\r\n console.error(\"Emergency toast creation failed:\", emergencyError);\r\n\r\n // ULTIMATE FALLBACK: Alert\r\n setTimeout(() => {\r\n try {\r\n alert(options.message || \"Toast Notification\");\r\n onClose(null);\r\n } catch (alertError) {\r\n console.error(\"Ultimate fallback failed:\", alertError);\r\n onClose(null);\r\n }\r\n }, 100);\r\n\r\n return null;\r\n }\r\n}\r\n","// src/components/Toast.js //# Single responsibility\r\n\"use strict\";\r\n\r\nimport { createElementWithId } from \"../utils/dom.js\";\r\nimport {\r\n applyRichStyling,\r\n createBasicToast,\r\n createEmergencyToast,\r\n} from \"./toast-utils.js\";\r\n\r\n/**\r\n * Multi-layer toast creation with satellite-grade fallbacks\r\n * @param {Object} options - Toast configuration options\r\n * @param {Function} onClose - Callback when toast closes\r\n * @returns {HTMLElement} Toast element\r\n */\r\nexport function createToastElement(options, onClose) {\r\n let toast;\r\n let isEmergencyMode = false;\r\n\r\n // PRIMARY: Full-featured toast\r\n try {\r\n toast = createElementWithId(\"div\", \"toast\");\r\n\r\n if (toast._isEmergencyElement) {\r\n isEmergencyMode = true;\r\n console.warn(\"Toast created in emergency mode\");\r\n }\r\n } catch (error) {\r\n console.error(\"Toast creation failed:\", error);\r\n isEmergencyMode = true;\r\n // FALLBACK: Basic object structure\r\n toast = {\r\n id: `emergency-toast-${Date.now()}`,\r\n style: {},\r\n appendChild: () => {},\r\n innerHTML: \"\",\r\n textContent: \"\",\r\n _isEmergencyElement: true,\r\n };\r\n }\r\n\r\n // PRIMARY: Rich styling and features\r\n if (!isEmergencyMode) {\r\n try {\r\n applyRichStyling(toast, options, onClose);\r\n return toast;\r\n } catch (stylingError) {\r\n console.warn(\r\n \"Rich toast styling failed, switching to basic mode:\",\r\n stylingError\r\n );\r\n isEmergencyMode = true;\r\n }\r\n }\r\n\r\n // FALLBACK-A: Basic functional toast\r\n if (isEmergencyMode && !toast._isEmergencyElement) {\r\n try {\r\n createBasicToast(toast, options, onClose);\r\n return toast;\r\n } catch (basicError) {\r\n console.error(\"Basic toast creation failed:\", basicError);\r\n }\r\n }\r\n\r\n // FALLBACK-B: Emergency notification system\r\n return createEmergencyToast(options, onClose);\r\n}\r\n","// src/components/ToastManager.js //# State management\r\n\"use strict\";\r\n\r\nimport { createToastContainer } from \"./ToastContainer.js\";\r\nimport { createToastElement } from \"./Toast.js\";\r\nimport { removeElement } from \"../utils/dom.js\";\r\n\r\n// State management with fallback tracking\r\nlet isToastShowing = false;\r\nlet currentToast = null;\r\nlet emergencyTimeouts = new Set();\r\nlet emergencyCleanupScheduled = false;\r\n\r\n/**\r\n * Show toast with comprehensive fallback system\r\n */\r\nexport function showToast(options) {\r\n // Prevent multiple toasts (original behavior)\r\n if (isToastShowing) {\r\n console.warn(\"Toast already showing, ignoring request\");\r\n return;\r\n }\r\n\r\n isToastShowing = true;\r\n\r\n // PRIMARY: Full toast system\r\n try {\r\n const container = createToastContainer(options.position);\r\n const toast = createToastElement(options, closeToast);\r\n\r\n if (!toast) {\r\n throw new Error(\"Toast creation returned null\");\r\n }\r\n\r\n currentToast = toast;\r\n\r\n // Append to container\r\n if (container.appendChild) {\r\n container.appendChild(toast);\r\n } else {\r\n // Container is emergency fallback\r\n document.body.appendChild(toast);\r\n }\r\n\r\n // Schedule auto-dismiss\r\n const dismissTimeout = setTimeout(() => {\r\n closeToast(toast);\r\n }, options.duration || 3000);\r\n\r\n emergencyTimeouts.add(dismissTimeout);\r\n\r\n // Emergency cleanup backup\r\n scheduleEmergencyCleanup(options.duration || 3000);\r\n\r\n return;\r\n } catch (primaryError) {\r\n console.warn(\"Primary toast system failed:\", primaryError);\r\n }\r\n\r\n // FALLBACK-A: Direct body placement\r\n try {\r\n const simpleToast = createSimpleToast(options);\r\n currentToast = simpleToast;\r\n document.body.appendChild(simpleToast);\r\n\r\n setTimeout(() => {\r\n closeToast(simpleToast);\r\n }, options.duration || 3000);\r\n\r\n return;\r\n } catch (fallbackError) {\r\n console.warn(\"Fallback toast failed:\", fallbackError);\r\n }\r\n\r\n // FALLBACK-B: Browser alert\r\n try {\r\n alert(options.message || \"Notification\");\r\n isToastShowing = false;\r\n } catch (alertError) {\r\n console.error(\"All toast systems failed:\", alertError);\r\n isToastShowing = false;\r\n }\r\n}\r\n\r\n/**\r\n * Create simple toast for fallback\r\n */\r\nfunction createSimpleToast(options) {\r\n const simple = document.createElement(\"div\");\r\n simple.style.cssText = `\r\n position: fixed !important;\r\n top: 20px !important;\r\n right: 20px !important;\r\n background: #333 !important;\r\n color: white !important;\r\n padding: 12px 20px !important;\r\n border-radius: 5px !important;\r\n z-index: 99999 !important;\r\n max-width: 300px !important;\r\n font-family: Arial, sans-serif !important;\r\n cursor: pointer !important;\r\n `;\r\n simple.textContent = options.message || \"Notification\";\r\n simple.onclick = () => closeToast(simple);\r\n return simple;\r\n}\r\n\r\n/**\r\n * Close toast with multi-strategy cleanup\r\n */\r\nfunction closeToast(toast) {\r\n try {\r\n if (!toast) {\r\n resetToastState();\r\n return;\r\n }\r\n\r\n // Animation if supported\r\n if (toast.style && !toast._isEmergencyToast) {\r\n toast.style.opacity = \"0\";\r\n toast.style.transform = \"translateY(-20px)\";\r\n\r\n const animDuration = toast._animationDuration || 500;\r\n setTimeout(() => {\r\n performCleanup(toast);\r\n }, animDuration);\r\n } else {\r\n // Immediate cleanup for emergency toasts\r\n performCleanup(toast);\r\n }\r\n } catch (error) {\r\n console.error(\"Close toast failed:\", error);\r\n forceEmergencyCleanup();\r\n }\r\n}\r\n\r\n/**\r\n * Perform comprehensive cleanup\r\n */\r\nfunction performCleanup(toast) {\r\n try {\r\n // Cleanup event listeners\r\n if (toast._cleanupCloseButton) {\r\n toast._cleanupCloseButton();\r\n }\r\n\r\n // Remove from DOM\r\n removeElement(toast);\r\n\r\n // Reset state\r\n resetToastState();\r\n } catch (error) {\r\n console.error(\"Cleanup failed:\", error);\r\n forceEmergencyCleanup();\r\n }\r\n}\r\n\r\n/**\r\n * Reset all toast state\r\n */\r\nfunction resetToastState() {\r\n isToastShowing = false;\r\n currentToast = null;\r\n\r\n // Clear all timeouts\r\n emergencyTimeouts.forEach((id) => {\r\n try {\r\n clearTimeout(id);\r\n } catch (error) {\r\n console.warn(\"Timeout clear failed:\", error);\r\n }\r\n });\r\n emergencyTimeouts.clear();\r\n emergencyCleanupScheduled = false;\r\n}\r\n\r\n/**\r\n * Schedule emergency cleanup\r\n */\r\nfunction scheduleEmergencyCleanup(duration) {\r\n if (emergencyCleanupScheduled) return;\r\n\r\n emergencyCleanupScheduled = true;\r\n const emergencyTimeout = setTimeout(() => {\r\n console.warn(\"Emergency cleanup triggered\");\r\n forceEmergencyCleanup();\r\n }, duration * 2.5); // 2.5x safety margin\r\n\r\n emergencyTimeouts.add(emergencyTimeout);\r\n}\r\n\r\n/**\r\n * Force emergency cleanup of everything\r\n */\r\nfunction forceEmergencyCleanup() {\r\n try {\r\n // Remove current toast\r\n if (currentToast) {\r\n removeElement(currentToast);\r\n }\r\n\r\n // Clean up any orphaned toast elements\r\n const orphanedToasts = document.querySelectorAll(\r\n '[id*=\"toast\"], [id*=\"emergency\"]'\r\n );\r\n orphanedToasts.forEach((element) => {\r\n try {\r\n removeElement(element);\r\n } catch (error) {\r\n console.warn(\"Orphaned element cleanup failed:\", error);\r\n }\r\n });\r\n\r\n // Reset all state\r\n resetToastState();\r\n } catch (error) {\r\n console.error(\"Force cleanup failed:\", error);\r\n // Final state reset\r\n isToastShowing = false;\r\n currentToast = null;\r\n }\r\n}\r\n","// src/index.js\r\n/**\r\n * @fileoverview A simple toast notification library for any JavaScript framework.\r\n * @name Customizable Toast Notifications\r\n * @author Priyanshu Patel\r\n * @version __VERSION__\r\n * @build Production\r\n * @license Apache-2.0\r\n * @depends None\r\n * @description A lightweight and fully customizable toast notification library\r\n * designed for seamless integration with any JavaScript or framework-based UI.\r\n * Supports flexible positioning, theming, icons, animations, and timing options\r\n * out of the box — with zero dependencies.\r\n * Author: Priyanshu Patel\r\n * Email: priyanshu.alt191@gmail.com\r\n * Created: July 31, 2024\r\n * License: Apache-2.0\r\n * Dependencies: None\r\n */\r\n\r\n\"use strict\";\r\n\r\nimport { showToast } from \"./components/ToastManager.js\";\r\n\r\n// Protected state with fallbacks\r\nlet defaultColors = {\r\n success: \"#28a745\",\r\n error: \"#dc3545\",\r\n warning: \"#ffc107\",\r\n info: \"#17a2b8\",\r\n};\r\n\r\nlet defaultMessages = {\r\n success: \"Operation completed successfully!\",\r\n error: \"Something went wrong!\",\r\n warning: \"Warning message!\",\r\n info: \"Information message!\",\r\n};\r\n\r\n/**\r\n * Create toast with satellite-grade reliability\r\n */\r\nfunction createToast(options = {}) {\r\n try {\r\n // Input sanitization and validation\r\n const sanitizedOptions = sanitizeToastOptions(options);\r\n\r\n // Call main toast system\r\n showToast(sanitizedOptions);\r\n } catch (error) {\r\n console.error(\"CreateToast failed:\", error);\r\n\r\n // ULTIMATE FALLBACK: Browser alert with sanitized message\r\n const safeMessage =\r\n typeof options?.message === \"string\"\r\n ? options.message.substring(0, 200)\r\n : \"Toast notification failed\";\r\n\r\n try {\r\n alert(safeMessage);\r\n } catch (alertError) {\r\n console.error(\"Ultimate fallback failed:\", alertError);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Sanitize and normalize toast options\r\n */\r\nfunction sanitizeToastOptions(options) {\r\n const defaults = {\r\n duration: 3000,\r\n position: \"bottom-right\",\r\n type: \"info\",\r\n backgroundColor: undefined,\r\n textColor: \"white\",\r\n showCloseButton: false,\r\n animationDuration: \"0.5s\",\r\n animationEasing: \"ease\",\r\n showProgressBar: false,\r\n progressColor: undefined,\r\n progressHeight: \"4px\",\r\n progressPosition: \"bottom\",\r\n };\r\n\r\n // Start with safe defaults\r\n let final = { ...defaults };\r\n\r\n // Merge user options safely\r\n if (options && typeof options === \"object\" && !Array.isArray(options)) {\r\n Object.keys(defaults).forEach((key) => {\r\n if (options.hasOwnProperty(key)) {\r\n final[key] = options[key];\r\n }\r\n });\r\n\r\n // Handle message separately\r\n if (options.message !== undefined) {\r\n final.message = options.message;\r\n }\r\n }\r\n\r\n // Validate and apply defaults\r\n try {\r\n if (!final.backgroundColor && final.type && defaultColors[final.type]) {\r\n final.backgroundColor = defaultColors[final.type];\r\n }\r\n\r\n if (!final.message && final.type && defaultMessages[final.type]) {\r\n final.message = defaultMessages[final.type];\r\n }\r\n } catch (error) {\r\n console.warn(\"Option processing failed:\", error);\r\n }\r\n\r\n // Final safety checks\r\n if (!final.message || typeof final.message !== \"string\") {\r\n final.message = \"Notification\";\r\n }\r\n\r\n if (typeof final.duration !== \"number\" || final.duration < 100) {\r\n final.duration = 3000;\r\n }\r\n\r\n return final;\r\n}\r\n\r\n/**\r\n * Set default colors with validation\r\n */\r\nfunction setDefaultColors(colors) {\r\n try {\r\n if (colors && typeof colors === \"object\" && !Array.isArray(colors)) {\r\n defaultColors = { ...defaultColors, ...colors };\r\n }\r\n } catch (error) {\r\n console.error(\"setDefaultColors failed:\", error);\r\n }\r\n}\r\n\r\n/**\r\n * Set default messages with validation\r\n */\r\nfunction setDefaultMessages(messages) {\r\n try {\r\n if (messages && typeof messages === \"object\" && !Array.isArray(messages)) {\r\n defaultMessages = { ...defaultMessages, ...messages };\r\n }\r\n } catch (error) {\r\n console.error(\"setDefaultMessages failed:\", error);\r\n }\r\n}\r\n\r\n// Module exports\r\nexport { createToast, setDefaultColors, setDefaultMessages };\r\n\r\n// Global assignment with protection\r\ntry {\r\n // UMD/Global support\r\n if (typeof window !== \"undefined\") {\r\n window.customizableToast = {\r\n createToast,\r\n setDefaultColors,\r\n setDefaultMessages,\r\n };\r\n }\r\n} catch (error) {\r\n console.error(\"Global assignment failed:\", error);\r\n}\r\n"],"names":["generateUniqueId","prefix","Date","now","Math","floor","random","removeElement","el","parentNode","removeChild","error","remove","fallbackError","style","display","opacity","pointerEvents","position","left","hideError","createToastContainer","toastContainer","document","getElementById","createElement","id","zIndex","container","top","bottom","right","transform","includes","setPosition","parent","child","contains","appendChild","insertAdjacentElement","body","insertAdjacentHTML","outerHTML","emergencyError","applyRichStyling","toast","options","onClose","animDurationMs","duration","endsWith","parsed","parseFloat","parseAnimationDuration","animationDuration","Object","assign","background","backgroundColor","color","textColor","padding","marginBottom","borderRadius","alignItems","justifyContent","boxShadow","minWidth","maxWidth","transition","animationEasing","_animationDuration","messageSpan","textContent","message","flex","showCloseButton","closeButton","innerHTML","border","fontSize","marginLeft","cursor","onclick","_cleanupCloseButton","createCloseButton","showProgressBar","progressBar","height","progressHeight","progressColor","width","progressPosition","setTimeout","offsetWidth","forceReflow","createProgressBar","runToastAnimation","createToastElement","isEmergencyMode","tagName","fallbackEl","setAttribute","_isEmergencyElement","createElementWithId","stylingError","margin","wordWrap","createBasicToast","basicError","emergency","_isEmergencyToast","alert","alertError","createEmergencyToast","isToastShowing","currentToast","emergencyTimeouts","Set","emergencyCleanupScheduled","showToast","closeToast","Error","dismissTimeout","add","emergencyTimeout","forceEmergencyCleanup","scheduleEmergencyCleanup","primaryError","simpleToast","simple","cssText","createSimpleToast","resetToastState","animDuration","performCleanup","forEach","clearTimeout","clear","querySelectorAll","element","defaultColors","success","warning","info","defaultMessages","createToast","sanitizedOptions","defaults","type","undefined","final","Array","isArray","keys","key","hasOwnProperty","sanitizeToastOptions","safeMessage","substring","setDefaultColors","colors","setDefaultMessages","messages","window","customizableToast"],"mappings":";;;;;;;;;;;wPAQO,SAASA,EAAiBC,EAAS,SACxC,MAAO,GAAGA,KAAUC,KAAKC,SAASC,KAAKC,MAAsB,IAAhBD,KAAKE,WACpD,CC4EO,SAASC,EAAcC,GAC5B,IAAKA,EAAI,OAAO,EAGhB,IACE,GAAIA,EAAGC,WAEL,OADAD,EAAGC,WAAWC,YAAYF,IACnB,CAEV,CAAC,MAAOG,GAIP,IACE,GAAIH,EAAGI,OAEL,OADAJ,EAAGI,UACI,CAEV,CAAC,MAAOC,GAIP,IAME,OALAL,EAAGM,MAAMC,QAAU,OACnBP,EAAGM,MAAME,QAAU,IACnBR,EAAGM,MAAMG,cAAgB,OACzBT,EAAGM,MAAMI,SAAW,WACpBV,EAAGM,MAAMK,KAAO,WACT,CACR,CAAC,MAAOC,GAEP,OAAO,CACR,CACF,CACF,CACD,OAAO,CACT,CC/GO,SAASC,EAAqBH,GACnC,IACE,IAAII,EAAiBC,SAASC,eAAe,mBAAmBN,KAWhE,OATKI,IACHA,EAAiBC,SAASE,cAAc,OACxCH,EAAeI,GAAK,mBAAmBR,IACvCI,EAAeR,MAAMI,SAAW,QAChCI,EAAeR,MAAMa,OAAS,OCX7B,SAAqBC,EAAWV,GAErCU,EAAUd,MAAMe,IAAM,OACtBD,EAAUd,MAAMgB,OAAS,OACzBF,EAAUd,MAAMK,KAAO,OACvBS,EAAUd,MAAMiB,MAAQ,OACxBH,EAAUd,MAAMkB,UAAY,OAExBd,EAASe,SAAS,UACpBL,EAAUd,MAAMgB,OAAS,OAChBZ,EAASe,SAAS,SAC3BL,EAAUd,MAAMe,IAAM,QAGpBX,EAASe,SAAS,SACpBL,EAAUd,MAAMiB,MAAQ,OACfb,EAASe,SAAS,QAC3BL,EAAUd,MAAMK,KAAO,OACdD,EAASe,SAAS,YAC3BL,EAAUd,MAAMe,IAAM,MACtBD,EAAUd,MAAMK,KAAO,MACvBS,EAAUd,MAAMkB,UAAY,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B,EACX,CAAC,MAAOxI,GAIP,MAAMmJ,EACwB,iBAArBhH,GAAS4B,QACZ5B,EAAQ4B,QAAQqF,UAAU,EAAG,KAC7B,4BAEN,IACE/C,MAAM8C,EACP,CAAC,MAAO7C,GAER,CACF,CACH,CAkEA,SAAS+C,EAAiBC,GACxB,IACMA,GAA4B,iBAAXA,IAAwBT,MAAMC,QAAQQ,KACzDpB,EAAgB,IAAKA,KAAkBoB,GAE1C,CAAC,MAAOtJ,GAER,CACH,CAKA,SAASuJ,EAAmBC,GAC1B,IACMA,GAAgC,iBAAbA,IAA0BX,MAAMC,QAAQU,KAC7DlB,EAAkB,IAAKA,KAAoBkB,GAE9C,CAAC,MAAOxJ,GAER,CACH,CAMA,IAEwB,oBAAXyJ,SACTA,OAAOC,kBAAoB,CACzBnB,cACAc,mBACAE,sBAGN,CAAE,MAAOvJ,GAET"}
1
+ {"version":3,"file":"index.umd.js","sources":["../src/utils/id.js","../src/components/ToastContainer.js","../src/utils/position.js","../src/utils/dom.js","../src/components/toast-utils.js","../src/components/Toast.js","../src/components/ToastManager.js","../src/index.js"],"sourcesContent":["// src/utils/id.js\r\n\"use strict\";\r\n\r\n/**\r\n * Generate unique ID for DOM elements to avoid conflicts\r\n * @param {string} prefix - Optional prefix for ID\r\n * @returns {string} Unique ID\r\n */\r\nexport async function generateUniqueId(prefix) {\r\n return `${prefix}-${Date.now()}-${Math.floor(Math.random() * 100000)}`;\r\n}\r\n","// src/components/ToastContainer.js //# Container logic\r\n\"use strict\";\r\n\r\nimport { setPosition } from \"../utils/position.js\";\r\nimport { appendChild } from \"../utils/dom.js\";\r\n\r\n/**\r\n * Create toast container with error handling\r\n * @param {string} position - Toast position\r\n * @returns {HTMLElement} Toast container element\r\n */\r\nexport async function createToastContainer(position) {\r\n try {\r\n let toastContainer = document.getElementById(`toast-container-${position}`);\r\n\r\n if (!toastContainer) {\r\n toastContainer = document.createElement(\"div\");\r\n toastContainer.id = `toast-container-${position}`;\r\n toastContainer.style.position = \"fixed\";\r\n toastContainer.style.zIndex = \"9999\";\r\n await setPosition(toastContainer, position);\r\n await appendChild(document.body, toastContainer);\r\n }\r\n\r\n return toastContainer;\r\n } catch (error) {\r\n console.error(\"Failed to create toast container:\", error);\r\n // Fallback: return body element\r\n return document.body;\r\n }\r\n}\r\n","// src/utils/position.js\r\n\"use strict\";\r\n\r\n/**\r\n * Set position for toast container (EXACT same logic as original)\r\n * @param {HTMLElement} container - Toast container element\r\n * @param {string} position - Position string\r\n */\r\nexport async function setPosition(container, position) {\r\n // Reset all position properties first\r\n container.style.top = \"auto\";\r\n container.style.bottom = \"auto\";\r\n container.style.left = \"auto\";\r\n container.style.right = \"auto\";\r\n container.style.transform = \"none\";\r\n\r\n if (position.includes(\"bottom\")) {\r\n container.style.bottom = \"10px\";\r\n } else if (position.includes(\"top\")) {\r\n container.style.top = \"10px\";\r\n }\r\n\r\n if (position.includes(\"right\")) {\r\n container.style.right = \"10px\";\r\n } else if (position.includes(\"left\")) {\r\n container.style.left = \"10px\";\r\n } else if (position.includes(\"center\")) {\r\n container.style.top = \"50%\";\r\n container.style.left = \"50%\";\r\n container.style.transform = \"translate(-50%, -50%)\";\r\n }\r\n}\r\n","// src/utils/dom.js\r\n\"use strict\";\r\n\r\nimport { generateUniqueId } from \"./id.js\";\r\n\r\n/**\r\n * Multi-layer fallback DOM element creation\r\n */\r\nexport async function createElementWithId(tagName, prefix) {\r\n // PRIMARY: Standard createElement\r\n try {\r\n if (!tagName || !prefix) throw new Error(`tagName and prefix is required`);\r\n\r\n const el = document.createElement(tagName);\r\n el.id = generateUniqueId(prefix);\r\n return el;\r\n } catch (error) {\r\n console.warn(`Primary createElement failed for`, error);\r\n\r\n // FALLBACK-A: Try div as alternative\r\n try {\r\n const fallbackTag = \"div\";\r\n const fallbackPrefix = \"fallback\";\r\n const fallbackEl = document.createElement(fallbackTag);\r\n fallbackEl.id = generateUniqueId(fallbackPrefix);\r\n fallbackEl.setAttribute(\"data-original-tag\", fallbackTag);\r\n return fallbackEl;\r\n } catch (fallbackError) {\r\n console.error(\"All DOM creation methods failed:\", fallbackError);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Multi-strategy appendChild with graceful degradation\r\n */\r\nexport async function appendChild(parent, child) {\r\n if (!parent || !child) return false;\r\n\r\n // PRIMARY: Standard appendChild\r\n try {\r\n if (!parent.contains(child)) {\r\n parent.appendChild(child);\r\n return true;\r\n }\r\n return true;\r\n } catch (error) {\r\n console.warn(\"Primary appendChild failed:\", error);\r\n\r\n // FALLBACK-A: insertAdjacentElement\r\n try {\r\n parent.insertAdjacentElement(\"beforeend\", child);\r\n return true;\r\n } catch (fallbackError) {\r\n console.warn(\"Fallback appendChild failed:\", fallbackError);\r\n\r\n // FALLBACK-B: Manual positioning\r\n try {\r\n if (parent === document.body) {\r\n child.style.position = \"fixed\";\r\n child.style.top = \"10px\";\r\n child.style.right = \"10px\";\r\n child.style.zIndex = \"99999\";\r\n document.body.insertAdjacentHTML(\"beforeend\", child.outerHTML || \"\");\r\n return true;\r\n }\r\n } catch (emergencyError) {\r\n console.error(\"All append strategies failed:\", emergencyError);\r\n return false;\r\n }\r\n }\r\n }\r\n return false;\r\n}\r\n\r\n/**\r\n * Safe element removal with multiple strategies\r\n */\r\nexport async function removeElement(el) {\r\n if (!el) return true;\r\n\r\n // PRIMARY: parentNode.removeChild\r\n try {\r\n if (el?.parentNode?.id.includes(\"toast-container-\")) {\r\n el.parentNode.removeChild(el);\r\n return true;\r\n }\r\n } catch (error) {\r\n console.warn(\"Primary removal failed:\", error);\r\n\r\n // FALLBACK-A: element.remove()\r\n try {\r\n if (el.remove) {\r\n el.remove();\r\n return true;\r\n }\r\n } catch (fallbackError) {\r\n console.warn(\"Fallback removal failed:\", fallbackError);\r\n\r\n // FALLBACK-B: Hide instead of remove\r\n try {\r\n el.style.display = \"none\";\r\n el.style.opacity = \"0\";\r\n el.style.pointerEvents = \"none\";\r\n el.style.position = \"absolute\";\r\n el.style.left = \"-9999px\";\r\n return true;\r\n } catch (hideError) {\r\n console.error(\"All removal strategies failed:\", hideError);\r\n return false;\r\n }\r\n }\r\n }\r\n return true;\r\n}\r\n\r\n/**\r\n * Animation duration parser with fallbacks\r\n */\r\nexport function parseAnimationDuration(duration) {\r\n // PRIMARY: Parse provided duration\r\n try {\r\n if (typeof duration === \"number\" && duration > 0) return duration;\r\n if (typeof duration === \"string\") {\r\n if (duration.endsWith(\"s\") && !duration.endsWith(\"ms\")) {\r\n const parsed = parseFloat(duration) * 1000;\r\n return parsed > 0 ? parsed : 500;\r\n }\r\n const parsed = parseFloat(duration);\r\n return parsed > 0 ? parsed : 500;\r\n }\r\n } catch (error) {\r\n console.warn(\"Duration parsing failed:\", error);\r\n }\r\n\r\n // FALLBACK: Safe default\r\n return 500;\r\n}\r\n\r\n/**\r\n * Force reflow with error protection\r\n */\r\nexport function forceReflow(el) {\r\n try {\r\n return el?.offsetWidth || 0;\r\n } catch (error) {\r\n console.warn(\"Force reflow failed:\", error);\r\n return 0;\r\n }\r\n}\r\n\r\n/**\r\n * Query selector shortcut with optional root.\r\n * @param {string} selector\r\n * @param {Document|HTMLElement} [root=document]\r\n * @returns {Element|null}\r\n */\r\nexport function query(selector, root = document) {\r\n return root.querySelector(selector);\r\n}\r\n","\"use strict\";\r\n\r\nimport { forceReflow, parseAnimationDuration } from \"../utils/dom.js\";\r\n\r\n/**\r\n * Create close button for toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport function createCloseButton(toast, options, onClose) {\r\n const closeButton = document.createElement(\"button\");\r\n closeButton.innerHTML = \"&times;\";\r\n Object.assign(closeButton.style, {\r\n background: \"none\",\r\n border: \"none\",\r\n color: options.textColor || \"white\",\r\n fontSize: \"18px\",\r\n marginLeft: \"10px\",\r\n cursor: \"pointer\",\r\n });\r\n\r\n closeButton.onclick = () => onClose(toast);\r\n toast.appendChild(closeButton);\r\n\r\n toast._cleanupCloseButton = () => {\r\n closeButton.onclick = null;\r\n };\r\n}\r\n\r\n/**\r\n * Create progress bar for toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n */\r\nexport function createProgressBar(toast, options) {\r\n const progressBar = document.createElement(\"div\");\r\n Object.assign(progressBar.style, {\r\n position: \"absolute\",\r\n left: \"0\",\r\n height: options.progressHeight || \"4px\",\r\n background: options.progressColor || \"rgba(255, 255, 255, 0.3)\",\r\n width: \"100%\",\r\n transition: `width ${options.duration || 1800}ms linear`,\r\n [options.progressPosition === \"top\" ? \"top\" : \"bottom\"]: \"0\",\r\n });\r\n\r\n toast.appendChild(progressBar);\r\n\r\n setTimeout(() => {\r\n forceReflow(progressBar);\r\n progressBar.style.width = \"0%\";\r\n }, 100);\r\n}\r\n\r\n/**\r\n * Run toast fade-in animation\r\n * @param {HTMLElement} toast - Toast element\r\n */\r\nexport function runToastAnimation(toast) {\r\n setTimeout(() => {\r\n toast.style.opacity = \"1\";\r\n toast.style.transform = \"translateY(0)\";\r\n }, 50);\r\n}\r\n\r\n/**\r\n * Apply rich styling to toast element\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport function applyRichStyling(toast, options, onClose) {\r\n const animDurationMs = parseAnimationDuration(options.animationDuration);\r\n\r\n // Apply full styling\r\n Object.assign(toast.style, {\r\n background: options.backgroundColor || options.color || \"#333\",\r\n color: options.textColor || \"white\",\r\n padding: \"12px 20px\",\r\n marginBottom: \"10px\",\r\n borderRadius: \"5px\",\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n justifyContent: \"space-between\",\r\n boxShadow: \"0 4px 6px rgba(0, 0, 0, 0.1)\",\r\n minWidth: \"250px\",\r\n maxWidth: \"400px\",\r\n opacity: \"0\",\r\n position: \"relative\",\r\n transition: `opacity ${animDurationMs || \"0.5s\"} ${\r\n options.animationEasing || \"ease\"\r\n }, transform ${animDurationMs || \"0.5s\"} ${\r\n options.animationEasing || \"ease\"\r\n }`,\r\n transform: \"translateY(20px)\",\r\n zIndex: \"9999\",\r\n });\r\n\r\n toast._animationDuration = animDurationMs;\r\n\r\n // Message span\r\n const messageSpan = document.createElement(\"span\");\r\n messageSpan.textContent = options.message || \"Notification\";\r\n messageSpan.style.flex = \"1\";\r\n toast.appendChild(messageSpan);\r\n\r\n // Close button\r\n if (options.showCloseButton) {\r\n createCloseButton(toast, options, onClose);\r\n }\r\n\r\n // Progress bar\r\n if (options.showProgressBar) {\r\n createProgressBar(toast, options);\r\n }\r\n\r\n // Animation\r\n runToastAnimation(toast);\r\n}\r\n\r\n/**\r\n * Create basic fallback toast\r\n * @param {HTMLElement} toast - Toast element\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport function createBasicToast(toast, options, onClose) {\r\n // Basic styling only\r\n Object.assign(toast.style, {\r\n background: \"#333\",\r\n color: \"white\",\r\n padding: \"10px 15px\",\r\n margin: \"10px\",\r\n borderRadius: \"3px\",\r\n position: \"fixed\",\r\n top: \"20px\",\r\n right: \"20px\",\r\n zIndex: \"99999\",\r\n maxWidth: \"300px\",\r\n wordWrap: \"break-word\",\r\n });\r\n\r\n toast.textContent = options.message || \"Notification\";\r\n\r\n if (options.showCloseButton) {\r\n toast.style.cursor = \"pointer\";\r\n toast.onclick = () => onClose(toast);\r\n }\r\n\r\n toast._animationDuration = 500;\r\n}\r\n\r\n/**\r\n * Emergency toast as last resort\r\n * @param {Object} options - Toast options\r\n * @param {Function} onClose - Close callback\r\n */\r\nexport function createEmergencyToast(options, onClose) {\r\n try {\r\n // Create emergency div\r\n const emergency = document.createElement(\"div\");\r\n emergency.id = `emergency-${Date.now()}`;\r\n emergency.innerHTML = `\r\n <div style=\"\r\n background: #333 !important;\r\n color: white !important;\r\n padding: 10px 15px !important;\r\n position: fixed !important;\r\n top: 20px !important;\r\n right: 20px !important;\r\n z-index: 99999 !important;\r\n border-radius: 3px !important;\r\n max-width: 250px !important;\r\n word-wrap: break-word !important;\r\n font-family: Arial, sans-serif !important;\r\n font-size: 14px !important;\r\n box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;\r\n cursor: pointer !important;\r\n \" onclick=\"this.parentNode.removeChild(this)\">\r\n ${options.message || \"Emergency Toast Creation Showing!\"}\r\n <span style=\"float: right; margin-left: 10px; font-weight: bold;\">&times;</span>\r\n </div>\r\n `;\r\n\r\n emergency._animationDuration = 500;\r\n emergency._isEmergencyToast = true;\r\n\r\n // Auto remove\r\n setTimeout(() => {\r\n try {\r\n if (emergency.parentNode) {\r\n emergency.parentNode.removeChild(emergency);\r\n }\r\n onClose(emergency);\r\n } catch (error) {\r\n console.warn(\"Emergency cleanup failed:\", error);\r\n }\r\n }, options.duration || 1800);\r\n\r\n return emergency;\r\n } catch (emergencyError) {\r\n console.error(\"Emergency toast creation failed:\", emergencyError);\r\n\r\n // ULTIMATE FALLBACK: Alert\r\n setTimeout(() => {\r\n try {\r\n alert(options.message || \"Toast Creation Failed!\");\r\n onClose(null);\r\n } catch (alertError) {\r\n console.error(\"Ultimate fallback failed:\", alertError);\r\n onClose(null);\r\n }\r\n }, 100);\r\n\r\n return null;\r\n }\r\n}\r\n\r\nexport async function safeSetTimeout(fn, delay) {\r\n const id = setTimeout(() => {\r\n console.warn(\"Timer fired after\", delay, \"ms\");\r\n fn();\r\n }, delay);\r\n\r\n console.warn(\"Timer scheduled with id:\", id, \"delay:\", delay);\r\n return id;\r\n}\r\n","// src/components/Toast.js //# Single responsibility\r\n\"use strict\";\r\n\r\nimport { createElementWithId } from \"../utils/dom.js\";\r\nimport { applyRichStyling, createEmergencyToast } from \"./toast-utils.js\";\r\n\r\n/**\r\n * Multi-layer toast creation with satellite-grade fallbacks\r\n * @param {Object} options - Toast configuration options\r\n * @param {Function} onClose - Callback when toast closes\r\n * @returns {HTMLElement} Toast element\r\n */\r\nexport async function createToastElement(options, onClose) {\r\n let toastContainer = document.querySelector('[id^=\"toast-container-\"]');\r\n if (!toastContainer) return null;\r\n\r\n let toast;\r\n const tagName = \"div\";\r\n const prefix = \"toast\";\r\n\r\n // PRIMARY: Full-featured toast\r\n try {\r\n toast = await createElementWithId(tagName, prefix);\r\n applyRichStyling(toast, options, onClose);\r\n return toast;\r\n } catch (error) {\r\n console.warn(\"error:\", error);\r\n createEmergencyToast(options, onClose);\r\n return toast;\r\n }\r\n}\r\n","// src/components/ToastManager.js //# State management\r\n\"use strict\";\r\n\r\nimport { createToastContainer } from \"./ToastContainer.js\";\r\nimport { createToastElement } from \"./Toast.js\";\r\nimport { removeElement } from \"../utils/dom.js\";\r\nimport { createEmergencyToast, safeSetTimeout } from \"./toast-utils.js\";\r\n\r\n// State management with fallback tracking\r\nlet isToastShowing = false;\r\nlet emergencyCleanupScheduled = false;\r\nlet currentToast = [];\r\nlet emergencyTimeouts = [];\r\n\r\n/**\r\n * Show toast with comprehensive fallback system\r\n */\r\nexport async function showToast(options) {\r\n // PRIMARY: Full toast system\r\n try {\r\n const container = await createToastContainer(options.position);\r\n const toast = await createToastElement(options, closeToast);\r\n\r\n if (!toast) {\r\n throw new Error(\"Toast element creation failed!\");\r\n }\r\n\r\n currentToast.push(toast);\r\n\r\n // Append to container\r\n if (container.id.includes(\"toast-container-\")) {\r\n container.appendChild(toast);\r\n }\r\n\r\n // Schedule auto-dismiss\r\n const cleanUpTime =\r\n typeof options.duration === \"number\" && options.duration > 0\r\n ? options.duration + 2\r\n : 1800; //safety margin\r\n const dismissTimeout = await safeSetTimeout(\r\n () => closeToast(toast),\r\n cleanUpTime\r\n );\r\n emergencyTimeouts.push(dismissTimeout);\r\n return;\r\n } catch (primaryError) {\r\n console.warn(\r\n \"Primary toast system failed showing emergency toast:\",\r\n primaryError\r\n );\r\n const elContainer = document.querySelector('[id^=\"toast-container-\"]');\r\n const emergencyToast = createEmergencyToast(options, closeToast);\r\n elContainer && elContainer?.id?.includes(\"toast-container-\")\r\n ? elContainer.appendChild(emergencyToast)\r\n : alert(primaryError.substring(0, 200));\r\n return;\r\n }\r\n}\r\n\r\n/**\r\n * Create simple toast for fallback\r\n */\r\nfunction createSimpleToast(options) {\r\n const simple = document.createElement(\"div\");\r\n simple.style.cssText = `\r\n position: fixed !important;\r\n top: 20px !important;\r\n right: 20px !important;\r\n background: #333 !important;\r\n color: white !important;\r\n padding: 12px 20px !important;\r\n border-radius: 5px !important;\r\n z-index: 99999 !important;\r\n max-width: 300px !important;\r\n font-family: Arial, sans-serif !important;\r\n cursor: pointer !important;\r\n `;\r\n simple.textContent = options.message || \"Created Simple Toast!\";\r\n simple.onclick = () => closeToast(simple);\r\n return simple;\r\n}\r\n\r\n/**\r\n * Close toast with multi-strategy cleanup\r\n */\r\nexport async function closeToast(toast) {\r\n if (currentToast.length > 0) {\r\n const index = currentToast.indexOf(toast);\r\n if (index !== -1) {\r\n currentToast.splice(index, 1);\r\n }\r\n }\r\n await removeElement(toast);\r\n}\r\n\r\n/**\r\n * Perform comprehensive cleanup\r\n */\r\nasync function performCleanup(toast) {\r\n try {\r\n // Cleanup event listeners\r\n if (toast._cleanupCloseButton) {\r\n toast._cleanupCloseButton();\r\n }\r\n\r\n // Remove from DOM\r\n removeElement(toast);\r\n\r\n // Reset state\r\n resetToastState();\r\n } catch (error) {\r\n console.error(\"Cleanup failed:\", error);\r\n forceEmergencyCleanup();\r\n }\r\n}\r\n\r\n/**\r\n * Reset all toast state\r\n */\r\nfunction resetToastState() {\r\n isToastShowing = false;\r\n currentToast = [];\r\n\r\n // Clear all timeouts\r\n emergencyTimeouts.forEach((id) => {\r\n try {\r\n clearTimeout(id);\r\n } catch (error) {\r\n console.warn(\"Timeout clear failed:\", error);\r\n }\r\n });\r\n emergencyTimeouts.pop();\r\n emergencyCleanupScheduled = false;\r\n}\r\n\r\n/**\r\n * Schedule emergency cleanup\r\n */\r\nfunction scheduleEmergencyCleanup(duration) {\r\n const cleanUpTime = typeof duration === \"number\" ? duration + 2 : 1800; //safety margin\r\n const emergencyTimeout = setTimeout(() => {\r\n console.warn(\"Emergency cleanup triggered\");\r\n forceEmergencyCleanup();\r\n }, cleanUpTime);\r\n\r\n emergencyTimeouts.push(emergencyTimeout);\r\n}\r\n\r\n/**\r\n * Force emergency cleanup of everything\r\n */\r\nasync function forceEmergencyCleanup() {\r\n try {\r\n // Remove current toast\r\n if (currentToast) {\r\n removeElement(currentToast);\r\n }\r\n\r\n // Clean up any orphaned toast elements\r\n const orphanedToasts = document.querySelectorAll(\r\n '[id^=\"toast-\"]:not([id*=\"container\"]), [id*=\"emergency\"]'\r\n );\r\n orphanedToasts.forEach((element) => {\r\n try {\r\n removeElement(element);\r\n } catch (error) {\r\n console.warn(\"Orphaned element cleanup failed:\", error);\r\n }\r\n });\r\n\r\n // Reset all state\r\n resetToastState();\r\n } catch (error) {\r\n console.error(\"Force cleanup failed:\", error);\r\n // Final state reset\r\n isToastShowing = false;\r\n currentToast = [];\r\n }\r\n}\r\n","// src/index.js\r\n/**\r\n * @fileoverview A simple toast notification library for any JavaScript framework.\r\n * @name Customizable Toast Notifications\r\n * @author Priyanshu Patel\r\n * @version __VERSION__\r\n * @build Production\r\n * @license Apache-2.0\r\n * @depends None\r\n * @description A lightweight and fully customizable toast notification library\r\n * designed for seamless integration with any JavaScript or framework-based UI.\r\n * Supports flexible positioning, theming, icons, animations, and timing options\r\n * out of the box — with zero dependencies.\r\n * Author: Priyanshu Patel\r\n * Email: priyanshu.alt191@gmail.com\r\n * Created: July 31, 2024\r\n * License: Apache-2.0\r\n * Dependencies: None\r\n */\r\n\r\n\"use strict\";\r\n\r\nimport { closeToast, showToast } from \"./components/ToastManager.js\";\r\n\r\n// Protected state with fallbacks\r\nlet defaultColors = {\r\n success: \"#28a745\",\r\n error: \"#dc3545\",\r\n warning: \"#ffc107\",\r\n info: \"#17a2b8\",\r\n};\r\n\r\nlet defaultMessages = {\r\n success: \"Operation completed successfully!\",\r\n error: \"Something went wrong!\",\r\n warning: \"Warning message!\",\r\n info: \"Information message!\",\r\n};\r\n\r\n/**\r\n * Create toast with satellite-grade reliability\r\n */\r\nasync function createToast(options = {}) {\r\n try {\r\n // Input sanitization and validation\r\n const sanitizedOptions = await sanitizeToastOptions(options);\r\n\r\n // Call main toast system\r\n await showToast(sanitizedOptions);\r\n } catch (error) {\r\n console.error(\"CreateToast failed:\", error);\r\n\r\n // ULTIMATE FALLBACK: Browser alert with sanitized message\r\n const safeMessage =\r\n typeof options?.message === \"string\"\r\n ? `${options.message.substring(0, 200)} toast creation failed!`\r\n : \"Toast creation failed!\";\r\n\r\n alert(safeMessage);\r\n }\r\n}\r\n\r\n// Params sanitization and validation for toast creation\r\nasync function sanitizeToastOptions(options) {\r\n const defaults = {\r\n duration: 1800,\r\n position: \"bottom-right\",\r\n type: \"info\",\r\n backgroundColor: undefined,\r\n textColor: \"white\",\r\n showCloseButton: false,\r\n animationDuration: \"0.5s\",\r\n animationEasing: \"ease\",\r\n showProgressBar: false,\r\n progressColor: undefined,\r\n progressHeight: \"4px\",\r\n progressPosition: \"bottom\",\r\n };\r\n\r\n // Start with safe defaults\r\n let final = { ...defaults };\r\n\r\n // Merge user options safely\r\n if (options && typeof options === \"object\" && !Array.isArray(options)) {\r\n Object.keys(defaults).forEach((key) => {\r\n if (options.hasOwnProperty(key)) {\r\n final[key] = options[key];\r\n }\r\n });\r\n\r\n // Handle message separately\r\n if (options.message !== undefined || options.message !== \"undefined\") {\r\n final.message = options.message;\r\n }\r\n }\r\n\r\n // Validate and apply defaults\r\n try {\r\n if (!final.backgroundColor && final.type && defaultColors[final.type]) {\r\n final.backgroundColor = defaultColors[final.type];\r\n }\r\n\r\n if (!final.message && final.type && defaultMessages[final.type]) {\r\n final.message = defaultMessages[final.type];\r\n }\r\n } catch (error) {\r\n console.warn(\"Option processing failed:\", error);\r\n }\r\n\r\n // Final safety checks\r\n if (!final.message || typeof final.message !== \"string\") {\r\n final.message = \"No Message Provided!\";\r\n }\r\n\r\n // should dlt if (typeof final.duration !== \"number\" || final.duration < 100) {\r\n // final.duration = defaults.duration;\r\n // }\r\n\r\n return final;\r\n}\r\n\r\n/**\r\n * Set default colors with validation\r\n */\r\nfunction setDefaultColors(colors) {\r\n try {\r\n if (colors && typeof colors === \"object\" && !Array.isArray(colors)) {\r\n defaultColors = { ...defaultColors, ...colors };\r\n }\r\n } catch (error) {\r\n console.error(\"setDefaultColors failed:\", error);\r\n }\r\n}\r\n\r\n/**\r\n * Set default messages with validation\r\n */\r\nfunction setDefaultMessages(messages) {\r\n try {\r\n if (messages && typeof messages === \"object\" && !Array.isArray(messages)) {\r\n defaultMessages = { ...defaultMessages, ...messages };\r\n }\r\n } catch (error) {\r\n console.error(\"setDefaultMessages failed:\", error);\r\n }\r\n}\r\n\r\nfunction noop() {\r\n const toast = document.querySelector('[id^=\"toast-\"]:not([id*=\"container\"])');\r\n closeToast(toast);\r\n}\r\n\r\n// Module exports\r\nexport { createToast, setDefaultColors, setDefaultMessages, noop };\r\n\r\n// Global assignment with protection\r\ntry {\r\n // UMD/Global support\r\n if (typeof window !== \"undefined\") {\r\n window.customizableToast = {\r\n createToast,\r\n setDefaultColors,\r\n setDefaultMessages,\r\n };\r\n }\r\n} catch (error) {\r\n console.error(\"Global assignment failed:\", error);\r\n}\r\n"],"names":["async","generateUniqueId","prefix","Date","now","Math","floor","random","createToastContainer","position","toastContainer","document","getElementById","createElement","id","style","zIndex","container","top","bottom","left","right","transform","includes","setPosition","parent","child","contains","appendChild","error","insertAdjacentElement","fallbackError","body","insertAdjacentHTML","outerHTML","emergencyError","applyRichStyling","toast","options","onClose","animDurationMs","duration","endsWith","parsed","parseFloat","parseAnimationDuration","animationDuration","Object","assign","background","backgroundColor","color","textColor","padding","marginBottom","borderRadius","display","alignItems","justifyContent","boxShadow","minWidth","maxWidth","opacity","transition","animationEasing","_animationDuration","messageSpan","textContent","message","flex","showCloseButton","closeButton","innerHTML","border","fontSize","marginLeft","cursor","onclick","_cleanupCloseButton","createCloseButton","showProgressBar","progressBar","height","progressHeight","progressColor","width","progressPosition","setTimeout","el","offsetWidth","forceReflow","createProgressBar","runToastAnimation","createEmergencyToast","emergency","_isEmergencyToast","parentNode","removeChild","alert","alertError","createToastElement","querySelector","tagName","Error","fallbackTag","fallbackPrefix","fallbackEl","setAttribute","createElementWithId","currentToast","emergencyTimeouts","showToast","closeToast","push","cleanUpTime","dismissTimeout","fn","delay","safeSetTimeout","primaryError","elContainer","emergencyToast","substring","length","index","indexOf","splice","remove","pointerEvents","hideError","removeElement","defaultColors","success","warning","info","defaultMessages","createToast","sanitizedOptions","defaults","type","undefined","final","Array","isArray","keys","forEach","key","hasOwnProperty","sanitizeToastOptions","safeMessage","setDefaultColors","colors","setDefaultMessages","messages","window","customizableToast"],"mappings":";;;;;;;;;;;;;;wPAQOA,eAAeC,EAAiBC,GACrC,MAAO,GAAGA,KAAUC,KAAKC,SAASC,KAAKC,MAAsB,IAAhBD,KAAKE,WACpD,CCCOP,eAAeQ,EAAqBC,GACzC,IACE,IAAIC,EAAiBC,SAASC,eAAe,mBAAmBH,KAWhE,OATKC,IACHA,EAAiBC,SAASE,cAAc,OACxCH,EAAeI,GAAK,mBAAmBL,IACvCC,EAAeK,MAAMN,SAAW,QAChCC,EAAeK,MAAMC,OAAS,aCX7BhB,eAA2BiB,EAAWR,GAE3CQ,EAAUF,MAAMG,IAAM,OACtBD,EAAUF,MAAMI,OAAS,OACzBF,EAAUF,MAAMK,KAAO,OACvBH,EAAUF,MAAMM,MAAQ,OACxBJ,EAAUF,MAAMO,UAAY,OAExBb,EAASc,SAAS,UACpBN,EAAUF,MAAMI,OAAS,OAChBV,EAASc,SAAS,SAC3BN,EAAUF,MAAMG,IAAM,QAGpBT,EAASc,SAAS,SACpBN,EAAUF,MAAMM,MAAQ,OACfZ,EAASc,SAAS,QAC3BN,EAAUF,MAAMK,KAAO,OACdX,EAASc,SAAS,YAC3BN,EAAUF,MAAMG,IAAM,MACtBD,EAAUF,MAAMK,KAAO,MACvBH,EAAUF,MAAMO,UAAY,wBAEhC,CDXYE,CAAYd,EAAgBD,SEgBjCT,eAA2ByB,E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iBC,GACxB,IACMA,GAA4B,iBAAXA,IAAwBT,MAAMC,QAAQQ,KACzDpB,EAAgB,IAAKA,KAAkBoB,GAE1C,CAAC,MAAO1H,GAER,CACH,CAKA,SAAS2H,EAAmBC,GAC1B,IACMA,GAAgC,iBAAbA,IAA0BX,MAAMC,QAAQU,KAC7DlB,EAAkB,IAAKA,KAAoBkB,GAE9C,CAAC,MAAO5H,GAER,CACH,CAWA,IAEwB,oBAAX6H,SACTA,OAAOC,kBAAoB,CACzBnB,cACAc,mBACAE,sBAGN,CAAE,MAAO3H,GAET,wBApBA,WAEEmF,EADcrG,SAAS0F,cAAc,yCAEvC"}
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "customizable-toast-notification",
3
- "version": "3.4.0",
3
+ "version": "3.5.1",
4
4
  "description": "A lightweight, zero-dependency toast notification library for modern JavaScript applications with production-grade reliability and comprehensive system mechanisms",
5
- "type": "module",
6
5
  "main": "dist/index.cjs",
7
6
  "module": "dist/index.esm.mjs",
8
7
  "unpkg": "dist/index.umd.js",
@@ -14,8 +13,18 @@
14
13
  },
15
14
  "scripts": {
16
15
  "postinstall": "node postinstall.js",
17
- "build": "rollup -c",
18
- "test": "echo \"Error: no test specified\" && exit 1"
16
+ "prepublishOnly": "npm run build",
17
+ "test": "jest",
18
+ "test:raw": "jest",
19
+ "test:watch": "jest --watch",
20
+ "test:coverage": "jest --coverage",
21
+ "e2e:firstbrowser:initialization": "npx playwright install",
22
+ "test:e2e": "playwright test",
23
+ "test:e2e:ui": "playwright test --ui",
24
+ "test:e2e:headed": "playwright test --headed",
25
+ "test:all": "npm run test && npm run playwright test",
26
+ "test:ci": "jest --coverage --ci --watchAll=true",
27
+ "build": "rollup -c"
19
28
  },
20
29
  "keywords": [
21
30
  "javascript",
@@ -80,6 +89,7 @@
80
89
  "@rollup/plugin-replace": "^6.0.1",
81
90
  "@rollup/plugin-terser": "^0.4.4",
82
91
  "autoprefixer": "^10.4.21",
92
+ "jsdom": "^26.1.0",
83
93
  "postcss": "^8.5.6",
84
94
  "postcss-import": "^16.1.1",
85
95
  "rollup": "^2.78.0",