@jinntec/jinntap 1.32.0 → 1.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,33 @@
1
- class l extends HTMLElement {
1
+ function g(h, e = {}) {
2
+ const { confirmLabel: o = "OK", cancelLabel: i = "Cancel", type: n = "info", nohtml: t = !1 } = e;
3
+ return new Promise((a) => {
4
+ document.dispatchEvent(
5
+ new CustomEvent("jinn-toast", {
6
+ detail: {
7
+ message: h,
8
+ type: n,
9
+ nohtml: t,
10
+ sticky: !0,
11
+ confirm: {
12
+ confirmLabel: o,
13
+ cancelLabel: i,
14
+ onConfirm: () => a(!0),
15
+ onCancel: () => a(!1)
16
+ }
17
+ }
18
+ })
19
+ );
20
+ });
21
+ }
22
+ class v extends HTMLElement {
2
23
  constructor() {
3
24
  super(), this.duration = 3e3, this.stickyDuration = 3e4;
4
25
  }
5
26
  static get observedAttributes() {
6
27
  return ["duration"];
7
28
  }
8
- attributeChangedCallback(t, a, i) {
9
- t === "duration" && (this.duration = parseInt(i) || 3e3);
29
+ attributeChangedCallback(e, o, i) {
30
+ e === "duration" && (this.duration = parseInt(i) || 3e3);
10
31
  }
11
32
  connectedCallback() {
12
33
  this.render(), this.setupEventListeners();
@@ -46,10 +67,53 @@ class l extends HTMLElement {
46
67
  width: min-content;
47
68
  }
48
69
 
49
- jinn-toast .jinn-toast.sticky {
70
+ jinn-toast .jinn-toast.sticky,
71
+ jinn-toast .jinn-toast.confirm {
50
72
  pointer-events: auto;
51
73
  }
52
74
 
75
+ jinn-toast .jinn-toast.confirm {
76
+ padding-bottom: 0.75rem;
77
+ }
78
+
79
+ jinn-toast .jinn-toast-body {
80
+ padding-right: 1.25rem;
81
+ }
82
+
83
+ jinn-toast .jinn-toast-actions {
84
+ display: flex;
85
+ justify-content: flex-end;
86
+ gap: 0.5rem;
87
+ margin-top: 0.75rem;
88
+ }
89
+
90
+ jinn-toast .jinn-toast-action {
91
+ border: 1px solid rgba(255, 255, 255, 0.35);
92
+ border-radius: 4px;
93
+ background: rgba(255, 255, 255, 0.12);
94
+ color: inherit;
95
+ cursor: pointer;
96
+ font: inherit;
97
+ font-size: 0.875rem;
98
+ line-height: 1.2;
99
+ padding: 0.35rem 0.75rem;
100
+ }
101
+
102
+ jinn-toast .jinn-toast-action:hover {
103
+ background: rgba(255, 255, 255, 0.22);
104
+ }
105
+
106
+ jinn-toast .jinn-toast-action.primary {
107
+ background: rgba(255, 255, 255, 0.92);
108
+ border-color: transparent;
109
+ color: #1a1816;
110
+ font-weight: 600;
111
+ }
112
+
113
+ jinn-toast .jinn-toast.warn .jinn-toast-action.primary {
114
+ color: #1a1816;
115
+ }
116
+
53
117
  jinn-toast .close-button {
54
118
  position: absolute;
55
119
  top: 4px;
@@ -91,53 +155,91 @@ class l extends HTMLElement {
91
155
  `;
92
156
  }
93
157
  setupEventListeners() {
94
- document.addEventListener("jinn-toast", (t) => {
95
- this.showToast(
96
- t.detail.message,
97
- t.detail.type || "info",
98
- t.detail.nohtml || !1,
99
- t.detail.sticky || !1
100
- );
158
+ document.addEventListener("jinn-toast", (e) => {
159
+ const { message: o, type: i, nohtml: n, sticky: t, confirm: a } = e.detail;
160
+ a ? this.showConfirmToast(o, i || "info", n || !1, a) : this.showToast(o, i || "info", n || !1, t || !1);
101
161
  });
102
162
  }
103
- showToast(t, a, i = !1, e = !1) {
104
- const n = document.createElement("div");
105
- n.className = `jinn-toast ${a} ${e ? "sticky" : ""}`;
106
- const s = () => {
107
- n.classList.remove("show"), setTimeout(() => {
108
- r.removeChild(n);
163
+ /**
164
+ * @param {string|Node|((close: () => void) => Node)} message
165
+ * @param {string} type
166
+ * @param {boolean} nohtml
167
+ * @param {boolean} sticky
168
+ */
169
+ showToast(e, o, i = !1, n = !1) {
170
+ const t = document.createElement("div");
171
+ t.className = `jinn-toast ${o} ${n ? "sticky" : ""}`;
172
+ const a = () => {
173
+ t.classList.remove("show"), setTimeout(() => {
174
+ r.removeChild(t);
109
175
  }, 300);
110
176
  };
111
- if (typeof t == "string")
112
- i ? n.textContent = t : n.innerHTML = t;
113
- else if (t instanceof Node)
114
- n.appendChild(t);
115
- else if (typeof t == "function") {
116
- const o = t(s);
117
- if (o instanceof Node)
118
- n.appendChild(o);
119
- else {
120
- console.warn("Function message did not return a valid Node.");
121
- return;
122
- }
123
- } else {
124
- console.warn("Invalid message type for toast. Expected string, Node, or function.");
125
- return;
126
- }
127
- if (e) {
128
- const o = document.createElement("button");
129
- o.className = "close-button", o.innerHTML = `
177
+ if (this._setToastContent(t, e, i, a), n) {
178
+ const s = document.createElement("button");
179
+ s.className = "close-button", s.innerHTML = `
130
180
  <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x" viewBox="0 0 16 16">
131
181
  <path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708"/>
132
182
  </svg>
133
- `, o.addEventListener("click", s), n.appendChild(o);
183
+ `, s.addEventListener("click", a), t.appendChild(s);
134
184
  }
135
185
  const r = this.querySelector(".jinn-toast-container");
136
- r.appendChild(n), n.offsetHeight, n.classList.add("show"), e || setTimeout(s, this.duration);
186
+ r.appendChild(t), t.offsetHeight, t.classList.add("show"), n || setTimeout(a, this.duration);
187
+ }
188
+ /**
189
+ * @param {string|Node|((close: () => void) => Node)} message
190
+ * @param {string} type
191
+ * @param {boolean} nohtml
192
+ * @param {{ confirmLabel?: string, cancelLabel?: string, onConfirm?: () => void, onCancel?: () => void }} confirm
193
+ */
194
+ showConfirmToast(e, o, i, n) {
195
+ const t = document.createElement("div");
196
+ t.className = `jinn-toast confirm ${o}`;
197
+ let a = !1;
198
+ const r = (b) => {
199
+ var j, f;
200
+ a || (a = !0, b ? (j = n.onConfirm) == null || j.call(n) : (f = n.onCancel) == null || f.call(n), s());
201
+ }, s = () => {
202
+ t.classList.remove("show"), setTimeout(() => {
203
+ m.removeChild(t);
204
+ }, 300);
205
+ }, u = document.createElement("div");
206
+ u.className = "jinn-toast-body", this._setToastContent(u, e, i, s), t.appendChild(u);
207
+ const d = document.createElement("div");
208
+ d.className = "jinn-toast-actions";
209
+ const c = document.createElement("button");
210
+ c.type = "button", c.className = "jinn-toast-action", c.textContent = n.cancelLabel || "Cancel", c.addEventListener("click", () => r(!1));
211
+ const l = document.createElement("button");
212
+ l.type = "button", l.className = "jinn-toast-action primary", l.textContent = n.confirmLabel || "OK", l.addEventListener("click", () => r(!0)), d.appendChild(c), d.appendChild(l), t.appendChild(d);
213
+ const p = document.createElement("button");
214
+ p.className = "close-button", p.innerHTML = `
215
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x" viewBox="0 0 16 16">
216
+ <path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708"/>
217
+ </svg>
218
+ `, p.addEventListener("click", () => r(!1)), t.appendChild(p);
219
+ const m = this.querySelector(".jinn-toast-container");
220
+ m.appendChild(t), t.offsetHeight, t.classList.add("show");
221
+ }
222
+ /**
223
+ * @param {HTMLElement} target
224
+ * @param {string|Node|((close: () => void) => Node)} message
225
+ * @param {boolean} nohtml
226
+ * @param {() => void} closeToast
227
+ */
228
+ _setToastContent(e, o, i, n) {
229
+ if (typeof o == "string")
230
+ i ? e.textContent = o : e.innerHTML = o;
231
+ else if (o instanceof Node)
232
+ e.appendChild(o);
233
+ else if (typeof o == "function") {
234
+ const t = o(n);
235
+ t instanceof Node ? e.appendChild(t) : console.warn("Function message did not return a valid Node.");
236
+ } else
237
+ console.warn("Invalid message type for toast. Expected string, Node, or function.");
137
238
  }
138
239
  }
139
- customElements.get("jinn-toast") || customElements.define("jinn-toast", l);
240
+ customElements.get("jinn-toast") || customElements.define("jinn-toast", v);
140
241
  export {
141
- l as JinnToast
242
+ v as JinnToast,
243
+ g as jinnToastConfirm
142
244
  };
143
245
  //# sourceMappingURL=jinn-toast.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"jinn-toast.es.js","sources":["../src/components/jinn-toast.js"],"sourcesContent":["export class JinnToast extends HTMLElement {\n constructor() {\n super();\n this.duration = 3000; // Default duration in milliseconds\n this.stickyDuration = 30000; // Default sticky duration in milliseconds\n }\n\n static get observedAttributes() {\n return ['duration'];\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n if (name === 'duration') {\n this.duration = parseInt(newValue) || 3000;\n }\n }\n\n connectedCallback() {\n this.render();\n this.setupEventListeners();\n }\n\n render() {\n this.innerHTML = `\n <style>\n jinn-toast .jinn-toast-container {\n position: fixed;\n bottom: 20px;\n right: 20px;\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n z-index: var(--jinn-toast-z-index, 1000);\n }\n\n jinn-toast .jinn-toast {\n padding: 12px 24px;\n margin: 8px 0;\n border-radius: 4px;\n color: var(--jinn-toast-color, #F0F0F0);\n opacity: 0;\n transform: translateY(20px);\n transition: opacity 0.3s, transform 0.3s;\n max-width: var(--jinn-toast-max-width, 30vw);\n word-wrap: break-word;\n pointer-events: none;\n position: relative;\n }\n\n jinn-toast .jinn-toast p {\n color: var(--jinn-toast-color, #F0F0F0);\n }\n\n jinn-toast .jinn-toast input {\n width: min-content;\n }\n\n jinn-toast .jinn-toast.sticky {\n pointer-events: auto;\n }\n\n jinn-toast .close-button {\n position: absolute;\n top: 4px;\n right: 4px;\n background: none;\n border: none;\n color: inherit;\n cursor: pointer;\n font-size: 16px;\n line-height: 1;\n padding: 4px;\n opacity: 0.7;\n transition: opacity 0.2s;\n }\n\n jinn-toast .close-button:hover {\n opacity: 1;\n }\n\n jinn-toast .jinn-toast.show {\n opacity: 1;\n transform: translateY(0);\n }\n\n jinn-toast .jinn-toast.error {\n background-color: var(--jinn-toast-error-color, #EE402E);\n }\n\n jinn-toast .jinn-toast.warn {\n background-color: var(--jinn-toast-warn-color, #FF9500);\n color: #000;\n }\n\n jinn-toast .jinn-toast.info {\n background-color: var(--jinn-toast-info-color, #33790F);\n }\n </style>\n <div class=\"jinn-toast-container\"></div>\n `;\n }\n\n setupEventListeners() {\n document.addEventListener('jinn-toast', (event) => {\n this.showToast(\n event.detail.message,\n event.detail.type || 'info',\n event.detail.nohtml || false,\n event.detail.sticky || false,\n );\n });\n }\n\n showToast(message, type, nohtml = false, sticky = false) {\n const toast = document.createElement('div');\n toast.className = `jinn-toast ${type} ${sticky ? 'sticky' : ''}`;\n\n const closeToast = () => {\n toast.classList.remove('show');\n setTimeout(() => {\n container.removeChild(toast);\n }, 300);\n };\n\n if (typeof message === 'string') {\n if (nohtml) {\n toast.textContent = message;\n } else {\n toast.innerHTML = message;\n }\n } else if (message instanceof Node) {\n toast.appendChild(message);\n } else if (typeof message === 'function') {\n const content = message(closeToast);\n if (content instanceof Node) {\n toast.appendChild(content);\n } else {\n console.warn('Function message did not return a valid Node.');\n return;\n }\n } else {\n console.warn('Invalid message type for toast. Expected string, Node, or function.');\n return;\n }\n\n if (sticky) {\n const closeButton = document.createElement('button');\n closeButton.className = 'close-button';\n closeButton.innerHTML = `\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"currentColor\" class=\"bi bi-x\" viewBox=\"0 0 16 16\">\n <path d=\"M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708\"/>\n </svg>\n `;\n closeButton.addEventListener('click', closeToast);\n toast.appendChild(closeButton);\n }\n\n const container = this.querySelector('.jinn-toast-container');\n container.appendChild(toast);\n\n // Trigger reflow to enable animation\n toast.offsetHeight;\n toast.classList.add('show');\n\n if (!sticky) {\n setTimeout(closeToast, this.duration);\n }\n }\n}\n\nif (!customElements.get('jinn-toast')) {\n customElements.define('jinn-toast', JinnToast);\n}\n"],"names":["JinnToast","name","oldValue","newValue","event","message","type","nohtml","sticky","toast","closeToast","container","content","closeButton"],"mappings":"AAAO,MAAMA,UAAkB,YAAY;AAAA,EACvC,cAAc;AACV,UAAK,GACL,KAAK,WAAW,KAChB,KAAK,iBAAiB;AAAA,EAC1B;AAAA,EAEA,WAAW,qBAAqB;AAC5B,WAAO,CAAC,UAAU;AAAA,EACtB;AAAA,EAEA,yBAAyBC,GAAMC,GAAUC,GAAU;AAC/C,IAAIF,MAAS,eACT,KAAK,WAAW,SAASE,CAAQ,KAAK;AAAA,EAE9C;AAAA,EAEA,oBAAoB;AAChB,SAAK,OAAM,GACX,KAAK,oBAAmB;AAAA,EAC5B;AAAA,EAEA,SAAS;AACL,SAAK,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA6ErB;AAAA,EAEA,sBAAsB;AAClB,aAAS,iBAAiB,cAAc,CAACC,MAAU;AAC/C,WAAK;AAAA,QACDA,EAAM,OAAO;AAAA,QACbA,EAAM,OAAO,QAAQ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
+ {"version":3,"file":"jinn-toast.es.js","sources":["../src/components/jinn-toast.js"],"sourcesContent":["/**\n * Show a sticky toast with confirm/cancel actions.\n *\n * @param {string|Node|((close: () => void) => Node)} message\n * @param {object} [options]\n * @param {string} [options.confirmLabel='OK']\n * @param {string} [options.cancelLabel='Cancel']\n * @param {string} [options.type='info']\n * @param {boolean} [options.nohtml=false]\n * @returns {Promise<boolean>} Resolves to `true` on confirm, `false` on cancel/close\n */\nexport function jinnToastConfirm(message, options = {}) {\n const { confirmLabel = 'OK', cancelLabel = 'Cancel', type = 'info', nohtml = false } = options;\n\n return new Promise((resolve) => {\n document.dispatchEvent(\n new CustomEvent('jinn-toast', {\n detail: {\n message,\n type,\n nohtml,\n sticky: true,\n confirm: {\n confirmLabel,\n cancelLabel,\n onConfirm: () => resolve(true),\n onCancel: () => resolve(false),\n },\n },\n }),\n );\n });\n}\n\nexport class JinnToast extends HTMLElement {\n constructor() {\n super();\n this.duration = 3000; // Default duration in milliseconds\n this.stickyDuration = 30000; // Default sticky duration in milliseconds\n }\n\n static get observedAttributes() {\n return ['duration'];\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n if (name === 'duration') {\n this.duration = parseInt(newValue) || 3000;\n }\n }\n\n connectedCallback() {\n this.render();\n this.setupEventListeners();\n }\n\n render() {\n this.innerHTML = `\n <style>\n jinn-toast .jinn-toast-container {\n position: fixed;\n bottom: 20px;\n right: 20px;\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n z-index: var(--jinn-toast-z-index, 1000);\n }\n\n jinn-toast .jinn-toast {\n padding: 12px 24px;\n margin: 8px 0;\n border-radius: 4px;\n color: var(--jinn-toast-color, #F0F0F0);\n opacity: 0;\n transform: translateY(20px);\n transition: opacity 0.3s, transform 0.3s;\n max-width: var(--jinn-toast-max-width, 30vw);\n word-wrap: break-word;\n pointer-events: none;\n position: relative;\n }\n\n jinn-toast .jinn-toast p {\n color: var(--jinn-toast-color, #F0F0F0);\n }\n\n jinn-toast .jinn-toast input {\n width: min-content;\n }\n\n jinn-toast .jinn-toast.sticky,\n jinn-toast .jinn-toast.confirm {\n pointer-events: auto;\n }\n\n jinn-toast .jinn-toast.confirm {\n padding-bottom: 0.75rem;\n }\n\n jinn-toast .jinn-toast-body {\n padding-right: 1.25rem;\n }\n\n jinn-toast .jinn-toast-actions {\n display: flex;\n justify-content: flex-end;\n gap: 0.5rem;\n margin-top: 0.75rem;\n }\n\n jinn-toast .jinn-toast-action {\n border: 1px solid rgba(255, 255, 255, 0.35);\n border-radius: 4px;\n background: rgba(255, 255, 255, 0.12);\n color: inherit;\n cursor: pointer;\n font: inherit;\n font-size: 0.875rem;\n line-height: 1.2;\n padding: 0.35rem 0.75rem;\n }\n\n jinn-toast .jinn-toast-action:hover {\n background: rgba(255, 255, 255, 0.22);\n }\n\n jinn-toast .jinn-toast-action.primary {\n background: rgba(255, 255, 255, 0.92);\n border-color: transparent;\n color: #1a1816;\n font-weight: 600;\n }\n\n jinn-toast .jinn-toast.warn .jinn-toast-action.primary {\n color: #1a1816;\n }\n\n jinn-toast .close-button {\n position: absolute;\n top: 4px;\n right: 4px;\n background: none;\n border: none;\n color: inherit;\n cursor: pointer;\n font-size: 16px;\n line-height: 1;\n padding: 4px;\n opacity: 0.7;\n transition: opacity 0.2s;\n }\n\n jinn-toast .close-button:hover {\n opacity: 1;\n }\n\n jinn-toast .jinn-toast.show {\n opacity: 1;\n transform: translateY(0);\n }\n\n jinn-toast .jinn-toast.error {\n background-color: var(--jinn-toast-error-color, #EE402E);\n }\n\n jinn-toast .jinn-toast.warn {\n background-color: var(--jinn-toast-warn-color, #FF9500);\n color: #000;\n }\n\n jinn-toast .jinn-toast.info {\n background-color: var(--jinn-toast-info-color, #33790F);\n }\n </style>\n <div class=\"jinn-toast-container\"></div>\n `;\n }\n\n setupEventListeners() {\n document.addEventListener('jinn-toast', (event) => {\n const { message, type, nohtml, sticky, confirm } = event.detail;\n if (confirm) {\n this.showConfirmToast(message, type || 'info', nohtml || false, confirm);\n } else {\n this.showToast(message, type || 'info', nohtml || false, sticky || false);\n }\n });\n }\n\n /**\n * @param {string|Node|((close: () => void) => Node)} message\n * @param {string} type\n * @param {boolean} nohtml\n * @param {boolean} sticky\n */\n showToast(message, type, nohtml = false, sticky = false) {\n const toast = document.createElement('div');\n toast.className = `jinn-toast ${type} ${sticky ? 'sticky' : ''}`;\n\n const closeToast = () => {\n toast.classList.remove('show');\n setTimeout(() => {\n container.removeChild(toast);\n }, 300);\n };\n\n this._setToastContent(toast, message, nohtml, closeToast);\n\n if (sticky) {\n const closeButton = document.createElement('button');\n closeButton.className = 'close-button';\n closeButton.innerHTML = `\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"currentColor\" class=\"bi bi-x\" viewBox=\"0 0 16 16\">\n <path d=\"M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708\"/>\n </svg>\n `;\n closeButton.addEventListener('click', closeToast);\n toast.appendChild(closeButton);\n }\n\n const container = this.querySelector('.jinn-toast-container');\n container.appendChild(toast);\n\n // Trigger reflow to enable animation\n toast.offsetHeight;\n toast.classList.add('show');\n\n if (!sticky) {\n setTimeout(closeToast, this.duration);\n }\n }\n\n /**\n * @param {string|Node|((close: () => void) => Node)} message\n * @param {string} type\n * @param {boolean} nohtml\n * @param {{ confirmLabel?: string, cancelLabel?: string, onConfirm?: () => void, onCancel?: () => void }} confirm\n */\n showConfirmToast(message, type, nohtml, confirm) {\n const toast = document.createElement('div');\n toast.className = `jinn-toast confirm ${type}`;\n\n let settled = false;\n const settle = (confirmed) => {\n if (settled) {\n return;\n }\n settled = true;\n if (confirmed) {\n confirm.onConfirm?.();\n } else {\n confirm.onCancel?.();\n }\n closeToast();\n };\n\n const closeToast = () => {\n toast.classList.remove('show');\n setTimeout(() => {\n container.removeChild(toast);\n }, 300);\n };\n\n const body = document.createElement('div');\n body.className = 'jinn-toast-body';\n this._setToastContent(body, message, nohtml, closeToast);\n toast.appendChild(body);\n\n const actions = document.createElement('div');\n actions.className = 'jinn-toast-actions';\n\n const cancelButton = document.createElement('button');\n cancelButton.type = 'button';\n cancelButton.className = 'jinn-toast-action';\n cancelButton.textContent = confirm.cancelLabel || 'Cancel';\n cancelButton.addEventListener('click', () => settle(false));\n\n const confirmButton = document.createElement('button');\n confirmButton.type = 'button';\n confirmButton.className = 'jinn-toast-action primary';\n confirmButton.textContent = confirm.confirmLabel || 'OK';\n confirmButton.addEventListener('click', () => settle(true));\n\n actions.appendChild(cancelButton);\n actions.appendChild(confirmButton);\n toast.appendChild(actions);\n\n const closeButton = document.createElement('button');\n closeButton.className = 'close-button';\n closeButton.innerHTML = `\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"currentColor\" class=\"bi bi-x\" viewBox=\"0 0 16 16\">\n <path d=\"M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708\"/>\n </svg>\n `;\n closeButton.addEventListener('click', () => settle(false));\n toast.appendChild(closeButton);\n\n const container = this.querySelector('.jinn-toast-container');\n container.appendChild(toast);\n\n toast.offsetHeight;\n toast.classList.add('show');\n }\n\n /**\n * @param {HTMLElement} target\n * @param {string|Node|((close: () => void) => Node)} message\n * @param {boolean} nohtml\n * @param {() => void} closeToast\n */\n _setToastContent(target, message, nohtml, closeToast) {\n if (typeof message === 'string') {\n if (nohtml) {\n target.textContent = message;\n } else {\n target.innerHTML = message;\n }\n } else if (message instanceof Node) {\n target.appendChild(message);\n } else if (typeof message === 'function') {\n const content = message(closeToast);\n if (content instanceof Node) {\n target.appendChild(content);\n } else {\n console.warn('Function message did not return a valid Node.');\n }\n } else {\n console.warn('Invalid message type for toast. Expected string, Node, or function.');\n }\n }\n}\n\nif (!customElements.get('jinn-toast')) {\n customElements.define('jinn-toast', JinnToast);\n}\n"],"names":["jinnToastConfirm","message","options","confirmLabel","cancelLabel","type","nohtml","resolve","JinnToast","name","oldValue","newValue","event","sticky","confirm","toast","closeToast","container","closeButton","settled","settle","confirmed","_a","_b","body","actions","cancelButton","confirmButton","target","content"],"mappings":"AAWO,SAASA,EAAiBC,GAASC,IAAU,IAAI;AACpD,QAAM,EAAE,cAAAC,IAAe,MAAM,aAAAC,IAAc,UAAU,MAAAC,IAAO,QAAQ,QAAAC,IAAS,GAAK,IAAKJ;AAEvF,SAAO,IAAI,QAAQ,CAACK,MAAY;AAC5B,aAAS;AAAA,MACL,IAAI,YAAY,cAAc;AAAA,QAC1B,QAAQ;AAAA,UACJ,SAAAN;AAAA,UACA,MAAAI;AAAA,UACA,QAAAC;AAAA,UACA,QAAQ;AAAA,UACR,SAAS;AAAA,YACL,cAAAH;AAAA,YACA,aAAAC;AAAA,YACA,WAAW,MAAMG,EAAQ,EAAI;AAAA,YAC7B,UAAU,MAAMA,EAAQ,EAAK;AAAA,UACrD;AAAA,QACA;AAAA,MACA,CAAa;AAAA,IACb;AAAA,EACI,CAAC;AACL;AAEO,MAAMC,UAAkB,YAAY;AAAA,EACvC,cAAc;AACV,UAAK,GACL,KAAK,WAAW,KAChB,KAAK,iBAAiB;AAAA,EAC1B;AAAA,EAEA,WAAW,qBAAqB;AAC5B,WAAO,CAAC,UAAU;AAAA,EACtB;AAAA,EAEA,yBAAyBC,GAAMC,GAAUC,GAAU;AAC/C,IAAIF,MAAS,eACT,KAAK,WAAW,SAASE,CAAQ,KAAK;AAAA,EAE9C;AAAA,EAEA,oBAAoB;AAChB,SAAK,OAAM,GACX,KAAK,oBAAmB;AAAA,EAC5B;AAAA,EAEA,SAAS;AACL,SAAK,YAAY;AAAA;AAAA;AAAA;A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