@instincthub/react-ui 0.1.37 → 0.1.39

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.
@@ -207,3 +207,5 @@
207
207
  background-color: var(--DarkCyan);
208
208
  border-radius: 3px;
209
209
  }
210
+
211
+ /* Dark mode handled by CSS variable swap (--White / --Gunmetal / --Gray) */
@@ -206,3 +206,179 @@
206
206
  opacity: 1;
207
207
  }
208
208
  }
209
+
210
+ /* ==================
211
+ New Toast (ihub-toast)
212
+ ===================== */
213
+ .ihub-toast-container {
214
+ position: fixed;
215
+ top: 24px;
216
+ right: 24px;
217
+ z-index: 999999;
218
+ pointer-events: none;
219
+ }
220
+
221
+ /* Stack toasts vertically */
222
+ .ihub-toast-container ~ .ihub-toast-container {
223
+ top: auto;
224
+ }
225
+
226
+ .ihub-toast {
227
+ position: relative;
228
+ display: flex;
229
+ align-items: center;
230
+ min-width: 320px;
231
+ max-width: 480px;
232
+ padding: 14px 40px 14px 16px;
233
+ border-radius: 8px;
234
+ font-family: var(--Nunito, "Nunito", sans-serif);
235
+ font-size: 0.9375rem;
236
+ line-height: 1.4;
237
+ pointer-events: auto;
238
+ overflow: hidden;
239
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
240
+ }
241
+
242
+ .ihub-toast--success {
243
+ background-color: var(--White, #fff);
244
+ border-left: 4px solid var(--ViridianGreen, #00897b);
245
+ color: var(--Gunmetal, #2c3e50);
246
+ }
247
+
248
+ .ihub-toast--error {
249
+ background-color: var(--White, #fff);
250
+ border-left: 4px solid var(--Danger, #ea5f5e);
251
+ color: var(--Gunmetal, #2c3e50);
252
+ }
253
+
254
+ .ihub-toast-body {
255
+ display: flex;
256
+ align-items: center;
257
+ gap: 12px;
258
+ flex: 1;
259
+ min-width: 0;
260
+ }
261
+
262
+ .ihub-toast-icon {
263
+ width: 22px;
264
+ height: 22px;
265
+ flex-shrink: 0;
266
+ }
267
+
268
+ .ihub-toast-icon--success {
269
+ color: var(--ViridianGreen, #00897b);
270
+ }
271
+
272
+ .ihub-toast-icon--error {
273
+ color: var(--Danger, #ea5f5e);
274
+ }
275
+
276
+ .ihub-toast-message {
277
+ margin: 0;
278
+ font-weight: 500;
279
+ word-break: break-word;
280
+ }
281
+
282
+ .ihub-toast-close {
283
+ position: absolute;
284
+ top: 50%;
285
+ right: 12px;
286
+ transform: translateY(-50%);
287
+ background: none;
288
+ border: none;
289
+ cursor: pointer;
290
+ color: var(--Gunmetal, #2c3e50);
291
+ opacity: 0.5;
292
+ padding: 4px;
293
+ border-radius: 4px;
294
+ display: flex;
295
+ align-items: center;
296
+ justify-content: center;
297
+ transition: opacity 0.2s, background-color 0.2s;
298
+ }
299
+
300
+ .ihub-toast-close:hover {
301
+ opacity: 1;
302
+ background-color: rgba(0, 0, 0, 0.05);
303
+ }
304
+
305
+ /* Progress bar */
306
+ .ihub-toast-progress {
307
+ position: absolute;
308
+ bottom: 0;
309
+ left: 0;
310
+ height: 3px;
311
+ width: 100%;
312
+ animation: ihub-toast-countdown 8s linear forwards;
313
+ }
314
+
315
+ .ihub-toast-progress--success {
316
+ background-color: var(--ViridianGreen, #00897b);
317
+ }
318
+
319
+ .ihub-toast-progress--error {
320
+ background-color: var(--Danger, #ea5f5e);
321
+ }
322
+
323
+ @keyframes ihub-toast-countdown {
324
+ from {
325
+ width: 100%;
326
+ }
327
+ to {
328
+ width: 0%;
329
+ }
330
+ }
331
+
332
+ /* Slide in from right */
333
+ .ihub-toast-slide-in {
334
+ animation: ihub-toast-in 0.35s cubic-bezier(0.21, 1.02, 0.73, 1) forwards;
335
+ }
336
+
337
+ @keyframes ihub-toast-in {
338
+ from {
339
+ transform: translateX(120%);
340
+ opacity: 0;
341
+ }
342
+ to {
343
+ transform: translateX(0);
344
+ opacity: 1;
345
+ }
346
+ }
347
+
348
+ /* Slide out to right */
349
+ .ihub-toast-slide-out {
350
+ animation: ihub-toast-out 0.3s ease-in forwards;
351
+ }
352
+
353
+ @keyframes ihub-toast-out {
354
+ from {
355
+ transform: translateX(0);
356
+ opacity: 1;
357
+ }
358
+ to {
359
+ transform: translateX(120%);
360
+ opacity: 0;
361
+ }
362
+ }
363
+
364
+ /* Stacking — push down subsequent toasts */
365
+ .ihub-toast-container:nth-child(1 of .ihub-toast-container) { top: 24px; }
366
+ .ihub-toast-container:nth-child(2 of .ihub-toast-container) { top: 88px; }
367
+ .ihub-toast-container:nth-child(3 of .ihub-toast-container) { top: 152px; }
368
+ .ihub-toast-container:nth-child(4 of .ihub-toast-container) { top: 216px; }
369
+ .ihub-toast-container:nth-child(5 of .ihub-toast-container) { top: 280px; }
370
+
371
+ /* Dark mode handled by CSS variable swap (--White / --Gunmetal) */
372
+
373
+ /* Responsive */
374
+ @media (max-width: 576px) {
375
+ .ihub-toast-container {
376
+ right: 12px;
377
+ left: 12px;
378
+ }
379
+
380
+ .ihub-toast {
381
+ min-width: auto;
382
+ max-width: 100%;
383
+ }
384
+ }
@@ -64,7 +64,6 @@
64
64
  margin-left: auto;
65
65
  margin-right: auto;
66
66
  padding: 1.5rem 1rem;
67
- font-family: "Georgia", "Times New Roman", serif;
68
67
  }
69
68
 
70
69
  .ihub-content-viewer > * + * {
@@ -79,14 +79,19 @@
79
79
  margin-top: var(--ihub-te-paragraph-spacing);
80
80
  }
81
81
 
82
- /* Placeholder */
83
- .ihub-te-content p.is-editor-empty:first-child::before,
84
- .ihub-te-empty .ProseMirror p.is-editor-empty:first-child::before {
82
+ /* Placeholder — shown on any empty node with cursor (via Tiptap decoration) */
83
+ .ihub-te-content .is-empty[data-placeholder]::before {
85
84
  content: attr(data-placeholder);
86
85
  float: left;
87
- color: #adb5bd;
86
+ color: #9ca3af;
88
87
  pointer-events: none;
89
88
  height: 0;
89
+ font-style: normal;
90
+ font-weight: 400;
91
+ }
92
+
93
+ /* Slightly different style when entire editor is empty */
94
+ .ihub-te-content .is-empty.is-editor-empty[data-placeholder]::before {
90
95
  font-style: italic;
91
96
  }
92
97
 
@@ -115,6 +120,19 @@
115
120
  font-family: var(--ihub-te-ui-font);
116
121
  }
117
122
 
123
+ /* Underline */
124
+ .ihub-te-content u {
125
+ text-decoration: underline;
126
+ text-underline-offset: 3px;
127
+ text-decoration-color: var(--DarkCyan, #0891b2);
128
+ }
129
+
130
+ /* Strikethrough */
131
+ .ihub-te-content s {
132
+ text-decoration: line-through;
133
+ opacity: 0.7;
134
+ }
135
+
118
136
  /* Links */
119
137
  .ihub-te-link {
120
138
  color: var(--DarkCyan, #0891b2);
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_rollupPluginBabelHelpers.js"),t=require("react/jsx-runtime"),s=require("react"),a=require("@mui/icons-material/ExpandMore"),i=require("../lib/helpFunction.js"),r=require("../ui/viewer/ContentViewer.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=l(a);exports.default=function(a){var l=s.useState(!1),n=e.slicedToArray(l,2),o=n[0],c=n[1],d=s.useState("Choose..."),f=e.slicedToArray(d,2),p=f[0],m=f[1],h=s.useState([]),b=e.slicedToArray(h,2),j=b[0],x=b[1],v=s.useState(""),_=e.slicedToArray(v,2),N=_[0],y=_[1];s.useEffect(function(){var e=[];for(var t in a.options)a.options[t].id===a.defaultValue&&(m(a.options[t].title),y(a.options[t].id)),e.push(a.options[t]);x(e)},[a.options,a.defaultValue]),s.useEffect(function(){var t;if("object"===e.typeof(a.defaultValue)&&null!==(t=a.defaultValue)&&void 0!==t&&t.id)m(a.defaultValue.title),y(a.defaultValue.id);else if(a.defaultValue){var s=a.options.find(function(e){return e.id===a.defaultValue});null!=s&&s.id&&(m(s.title),y(s.id))}else m("Choose..."),y("")},[a.defaultValue,a.options]);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"ihub-select ".concat(a.err?"ihub-form-err":"").concat(a.className?" ".concat(a.className):""),style:{width:a.defaultWidth||"300px"},children:[t.jsxs("div",{className:"ihub-select__btn",onClick:function(){return 0!==a.status&&c(!o)},children:[t.jsxs("div",{className:0===a.status?"disabled":"",children:[t.jsx("input",{type:"text",className:"ihub-select__input",value:a.upperCases?String(N).toUpperCase():N||"",id:"id_"+a.name,name:a.name,required:a.required,"data-name":a.dataName||a.name,readOnly:!0}),t.jsx(r.default,{content:p||"...",showToolbar:!1})]}),a.label&&t.jsx("label",{className:"ihub-select__label",children:a.label}),t.jsx("div",{className:"search_btn",children:0===a.status?t.jsx("div",{className:"ihub-select__loader"}):t.jsx(u.default,{})})]}),o&&t.jsx("div",{className:"ihub-select__content",children:j.map(function(e,s){return t.jsx("div",{className:"ihub-select__item",onClick:function(){return function(e,t){m(t),y(e.id),c(!1),a.setValue&&a.setValue(e),a.setNameValue&&a.setNameValue(a.name,e),a.setObjects&&a.setObjects(e),a.setArrayProps&&a.setArrayProps(a.arrayProps||[],e),a.setCookies&&i.setCookie(a.setCookies,JSON.stringify(e),365)}(e,e.title)},children:e.title},s)})})]}),a.note&&t.jsx("p",{className:"ihub-input-notes",children:a.note}),a.error&&t.jsx("span",{className:"ihub-error-text",children:a.error})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_rollupPluginBabelHelpers.js"),t=require("react/jsx-runtime"),s=require("react"),a=require("@mui/icons-material/ExpandMore"),i=require("../lib/helpFunction.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=l(a);exports.default=function(a){var l=s.useState(!1),u=e.slicedToArray(l,2),n=u[0],o=u[1],c=s.useState("Choose..."),d=e.slicedToArray(c,2),f=d[0],p=d[1],m=s.useState([]),h=e.slicedToArray(m,2),b=h[0],j=h[1],x=s.useState(""),_=e.slicedToArray(x,2),v=_[0],N=_[1];s.useEffect(function(){var e=[];for(var t in a.options)a.options[t].id===a.defaultValue&&(p(a.options[t].title),N(a.options[t].id)),e.push(a.options[t]);j(e)},[a.options,a.defaultValue]),s.useEffect(function(){var t;if("object"===e.typeof(a.defaultValue)&&null!==(t=a.defaultValue)&&void 0!==t&&t.id)p(a.defaultValue.title),N(a.defaultValue.id);else if(a.defaultValue){var s=a.options.find(function(e){return e.id===a.defaultValue});null!=s&&s.id&&(p(s.title),N(s.id))}else p("Choose..."),N("")},[a.defaultValue,a.options]);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"ihub-select ".concat(a.err?"ihub-form-err":"").concat(a.className?" ".concat(a.className):""),style:{width:a.defaultWidth||"300px"},children:[t.jsxs("div",{className:"ihub-select__btn",onClick:function(){return 0!==a.status&&o(!n)},children:[t.jsxs("div",{className:0===a.status?"disabled":"",children:[t.jsx("input",{type:"text",className:"ihub-select__input",value:a.upperCases?String(v).toUpperCase():v||"",id:"id_"+a.name,name:a.name,required:a.required,"data-name":a.dataName||a.name,readOnly:!0}),t.jsx("p",{dangerouslySetInnerHTML:{__html:f||"..."}})]}),a.label&&t.jsx("label",{className:"ihub-select__label",children:a.label}),t.jsx("div",{className:"search_btn",children:0===a.status?t.jsx("div",{className:"ihub-select__loader"}):t.jsx(r.default,{})})]}),n&&t.jsx("div",{className:"ihub-select__content",children:b.map(function(e,s){return t.jsx("div",{className:"ihub-select__item",onClick:function(){return function(e,t){p(t),N(e.id),o(!1),a.setValue&&a.setValue(e),a.setNameValue&&a.setNameValue(a.name,e),a.setObjects&&a.setObjects(e),a.setArrayProps&&a.setArrayProps(a.arrayProps||[],e),a.setCookies&&i.setCookie(a.setCookies,JSON.stringify(e),365)}(e,e.title)},children:e.title},s)})})]}),a.note&&t.jsx("p",{className:"ihub-input-notes",children:a.note}),a.error&&t.jsx("span",{className:"ihub-error-text",children:a.error})]})};
2
2
  //# sourceMappingURL=FilterObjects.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=function(n){if(!n||n.length<3)return!1;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)},e=function(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200,t=200===e||201===e?"Awesome! The update was made.":500===e?"Sorry, the server can't process your request":"Hmmm..., Something went wrong. Try again",o=200===e||201===e?'<svg viewBox="0 0 24 24" style="color: var(--ViridianGreen); width:24px; height:24px;"><path fill="currentColor" d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>':'<svg viewBox="0 0 24 24" style="color: var(--Danger); width:24px; height:24px;"><path fill="currentColor" d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z"/></svg>',i=document.getElementById("openToast");i||((i=document.createElement("div")).id="openToast");var a='\n <div class="toast-wrapper">\n <div class="slide-in-top">\n <div class="align-text">\n <div class="valid_btn">\n '.concat(o,'\n <p class="').concat(200===e||201===e?"isDone":"isError",'">\n ').concat(n||t,'\n </p>\n </div>\n </div>\n <svg width="800px" height="800px" viewBox="-0.5 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg" \n class="close-btn" onclick="window.cleanupToast()">\n <path d="M3 21.32L21 3.32001" stroke="var(--Gunmetal)" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>\n <path d="M3 3.32001L21 21.32" stroke="var(--Gunmetal)" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n </div>\n </div>\n ');i.innerHTML=a,document.body.appendChild(i),window.cleanupToast=function(){var n;null===(n=i)||void 0===n||n.remove()},setTimeout(function(){window.cleanupToast()},1e4)};exports.getUserEmailInputModal=function(t){return new Promise(function(o){var i,a=document.getElementById("confirmModal");a||((a=document.createElement("div")).id="confirmModal");var d=function(){var n;null===(n=a)||void 0===n||n.remove()};window.handleCleanUpInput=function(){d(),o(void 0)},window.handleInput=function(e){var t=document.getElementById("proceedBtn");n(e.value)?(t&&(t.disabled=!1),i=e.value):(t&&(t.disabled=!0),i=void 0)},window.handleConfirm=function(){n(i)?(d(),o(i)):e("You need to enter a valid email!",400)};var l='\n <section id="myModal" class="modal">\n <div class="modal-content">\n <svg width="800px" height="800px" viewBox="-0.5 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg"\n class="ih_get_user_email_modal_close_btn" onclick="window.handleCleanUpInput()">\n <path d="M3 21.32L21 3.32001" stroke="var(--Gunmetal)" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>\n <path d="M3 3.32001L21 21.32" stroke="var(--Gunmetal)" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n <h4>Enrol for '.concat(t,'</h4>\n <p class="ihub-mt-3">Enter a valid Email Address</p>\n <input type="email" name="email" id="userInput" oninput="window.handleInput(this)" />\n <div class="action_btn ihub-mt-3">\n <button type="button" disabled id="proceedBtn" class="delete_btn important-btn" onclick="window.handleConfirm()">Proceed</button>\n </div>\n </div>\n </section>\n ');a.innerHTML=l,document.body.appendChild(a),a.addEventListener("click",function(n){var e=n.target;"myModal"!==e.id&&"confirmModal"!==e.id||(d(),o(void 0))})})},exports.openConfirmModal=function(n){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new Promise(function(t){var o=document.getElementById("confirmModal");o||((o=document.createElement("div")).id="confirmModal");var i='\n <section id="myModal" class="modal">\n <div class="modal-content">\n <span class="close" onclick="window.handleCancel()">×</span>\n <p class="'.concat(e?"something_bad_flagged":"something_bad",'">\n ').concat(e?"Unexpected things will happen if you dont read this!":"You are about to submit!","\n </p>\n <p>").concat(n||"Carefully read the instructions before making a decision. Ready? Hit the continue button!",'</p>\n <div class="mt-4">\n <button type="button" class="danger-btn d-inline-block" onclick="window.handleCancel()">Cancel</button>\n <button type="button" class="important-btn confirm-btn ihub-bg-dark-cyan" onclick="window.handleConfirm()">Ok</button>\n </div>\n </div>\n </section>\n ');o.innerHTML=i,document.body.appendChild(o);var a=function(){var n;null===(n=o)||void 0===n||n.remove()};window.handleCancel=function(){a(),t(!1),console.log("")},window.handleConfirm=function(){a(),t(!0)},o.addEventListener("click",function(n){var e=n.target;"myModal"!==e.id&&"confirmModal"!==e.id||a()})})},exports.openToast=e;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(t){if(!t||t.length<3)return!1;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)},e=0,n=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200,a=200===n||201===n,i=t||(a?"Awesome! The update was made.":500===n?"Sorry, the server can't process your request":"Hmmm..., Something went wrong. Try again"),o="ihub-toast-".concat(++e),r=document.createElement("div");r.id=o,r.className="ihub-toast-container";var d=a?"success":"error",s=document.createElement("div");s.className="ihub-toast ihub-toast--".concat(d," ihub-toast-slide-in");var c=document.createElement("div");c.className="ihub-toast-body";var l=document.createElementNS("http://www.w3.org/2000/svg","svg");l.setAttribute("viewBox","0 0 24 24"),l.setAttribute("class","ihub-toast-icon ihub-toast-icon--".concat(d));var u=document.createElementNS("http://www.w3.org/2000/svg","path");u.setAttribute("fill","currentColor"),u.setAttribute("d",a?"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z":"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z"),l.appendChild(u);var m=document.createElement("p");m.className="ihub-toast-message",m.textContent=i,c.appendChild(l),c.appendChild(m);var p=document.createElement("button");p.type="button",p.className="ihub-toast-close",p.setAttribute("aria-label","Close notification");var v=document.createElementNS("http://www.w3.org/2000/svg","svg");v.setAttribute("width","14"),v.setAttribute("height","14"),v.setAttribute("viewBox","0 0 24 24"),v.setAttribute("fill","none"),v.setAttribute("stroke","currentColor"),v.setAttribute("stroke-width","2"),v.setAttribute("stroke-linecap","round"),v.setAttribute("stroke-linejoin","round");var b=document.createElementNS("http://www.w3.org/2000/svg","line");b.setAttribute("x1","18"),b.setAttribute("y1","6"),b.setAttribute("x2","6"),b.setAttribute("y2","18");var h=document.createElementNS("http://www.w3.org/2000/svg","line");h.setAttribute("x1","6"),h.setAttribute("y1","6"),h.setAttribute("x2","18"),h.setAttribute("y2","18"),v.appendChild(b),v.appendChild(h),p.appendChild(v);var C=document.createElement("div");C.className="ihub-toast-progress ihub-toast-progress--".concat(d),s.appendChild(c),s.appendChild(p),s.appendChild(C),r.appendChild(s),document.body.appendChild(r);var E=function(){var t=document.getElementById(o);if(t){var e=t.querySelector(".ihub-toast");e?(e.classList.add("ihub-toast-slide-out"),e.addEventListener("animationend",function(){return t.remove()},{once:!0})):t.remove()}};p.addEventListener("click",E),setTimeout(E,8e3)};exports.getUserEmailInputModal=function(e){return new Promise(function(a){var i,o=document.getElementById("confirmModal");o||((o=document.createElement("div")).id="confirmModal");var r=function(){var t;null===(t=o)||void 0===t||t.remove()},d=document.createElement("section");d.id="myModal",d.className="modal";var s=document.createElement("div");s.className="modal-content";var c=document.createElementNS("http://www.w3.org/2000/svg","svg");c.setAttribute("width","24"),c.setAttribute("height","24"),c.setAttribute("viewBox","-0.5 0 25 25"),c.setAttribute("fill","none"),c.setAttribute("class","ih_get_user_email_modal_close_btn"),c.style.cursor="pointer";var l=document.createElementNS("http://www.w3.org/2000/svg","path");l.setAttribute("d","M3 21.32L21 3.32001"),l.setAttribute("stroke","var(--Gunmetal)"),l.setAttribute("stroke-width","1.5"),l.setAttribute("stroke-linecap","round"),l.setAttribute("stroke-linejoin","round");var u=document.createElementNS("http://www.w3.org/2000/svg","path");u.setAttribute("d","M3 3.32001L21 21.32"),u.setAttribute("stroke","var(--Gunmetal)"),u.setAttribute("stroke-width","1.5"),u.setAttribute("stroke-linecap","round"),u.setAttribute("stroke-linejoin","round"),c.appendChild(l),c.appendChild(u),c.addEventListener("click",function(){r(),a(void 0)});var m=document.createElement("h4");m.textContent="Enrol for ".concat(e);var p=document.createElement("p");p.className="ihub-mt-3",p.textContent="Enter a valid Email Address";var v=document.createElement("input");v.type="email",v.name="email",v.id="userInput";var b=document.createElement("div");b.className="action_btn ihub-mt-3";var h=document.createElement("button");h.type="button",h.disabled=!0,h.id="proceedBtn",h.className="delete_btn important-btn",h.textContent="Proceed",v.addEventListener("input",function(){t(v.value)?(h.disabled=!1,i=v.value):(h.disabled=!0,i=void 0)}),h.addEventListener("click",function(){t(i)?(r(),a(i)):n("You need to enter a valid email!",400)}),b.appendChild(h),s.appendChild(c),s.appendChild(m),s.appendChild(p),s.appendChild(v),s.appendChild(b),d.appendChild(s),o.textContent="",o.appendChild(d),document.body.appendChild(o),o.addEventListener("click",function(t){var e=t.target;"myModal"!==e.id&&"confirmModal"!==e.id||(r(),a(void 0))})})},exports.openConfirmModal=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new Promise(function(n){var a=document.getElementById("confirmModal");a||((a=document.createElement("div")).id="confirmModal");var i=e?"something_bad_flagged":"something_bad",o=e?"Unexpected things will happen if you don't read this!":"You are about to submit!",r=t||"Carefully read the instructions before making a decision. Ready? Hit the continue button!",d=document.createElement("section");d.id="myModal",d.className="modal";var s=document.createElement("div");s.className="modal-content";var c=document.createElement("span");c.className="close",c.textContent="×",c.addEventListener("click",function(){b(),n(!1)});var l=document.createElement("p");l.className=i,l.textContent=o;var u=document.createElement("p");u.textContent=r;var m=document.createElement("div");m.className="mt-4";var p=document.createElement("button");p.type="button",p.className="danger-btn d-inline-block",p.textContent="Cancel",p.addEventListener("click",function(){b(),n(!1)});var v=document.createElement("button");v.type="button",v.className="important-btn confirm-btn ihub-bg-dark-cyan",v.textContent="Ok",v.addEventListener("click",function(){b(),n(!0)}),m.appendChild(p),m.appendChild(v),s.appendChild(c),s.appendChild(l),s.appendChild(u),s.appendChild(m),d.appendChild(s),a.textContent="",a.appendChild(d),document.body.appendChild(a);var b=function(){var t;null===(t=a)||void 0===t||t.remove()};a.addEventListener("click",function(t){var e=t.target;"myModal"!==e.id&&"confirmModal"!==e.id||(b(),n(!1))})})},exports.openToast=n;
2
2
  //# sourceMappingURL=modals.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"modals.js","sources":["../../../../../src/components/lib/modals/modals.ts"],"sourcesContent":["import React from \"react\";\n\n// Type for status codes\ntype StatusCode = 200 | 201 | 400 | 500 | number;\n\n// Utility function to validate email\nconst isValidEmail = (input: string | undefined): boolean => {\n if (!input || input.length < 3) {\n return false;\n }\n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n return emailRegex.test(input);\n};\n\n// Declare global window interface extensions for event handlers\ndeclare global {\n interface Window {\n handleCancel: () => void;\n handleConfirm: () => void;\n cleanupToast: () => void;\n handleInput: (e: HTMLInputElement) => void;\n handleCleanUpInput: () => void;\n }\n}\n\n// Open a confirmation modal\nexport const openConfirmModal = (\n message: string,\n flag: boolean = false\n): Promise<boolean> => {\n return new Promise((resolve) => {\n let modalContainer = document.getElementById(\n \"confirmModal\"\n ) as HTMLDivElement | null;\n if (!modalContainer) {\n modalContainer = document.createElement(\"div\");\n modalContainer.id = \"confirmModal\";\n }\n\n const modalContent = `\n <section id=\"myModal\" class=\"modal\">\n <div class=\"modal-content\">\n <span class=\"close\" onclick=\"window.handleCancel()\">×</span>\n <p class=\"${flag ? \"something_bad_flagged\" : \"something_bad\"}\">\n ${\n flag\n ? \"Unexpected things will happen if you don’t read this!\"\n : \"You are about to submit!\"\n }\n </p>\n <p>${\n message ||\n \"Carefully read the instructions before making a decision. Ready? Hit the continue button!\"\n }</p>\n <div class=\"mt-4\">\n <button type=\"button\" class=\"danger-btn d-inline-block\" onclick=\"window.handleCancel()\">Cancel</button>\n <button type=\"button\" class=\"important-btn confirm-btn ihub-bg-dark-cyan\" onclick=\"window.handleConfirm()\">Ok</button>\n </div>\n </div>\n </section>\n `;\n\n modalContainer.innerHTML = modalContent;\n document.body.appendChild(modalContainer);\n\n const cleanup = () => {\n modalContainer?.remove();\n };\n\n window.handleCancel = () => {\n cleanup();\n resolve(false);\n console.log(\"\");\n };\n\n window.handleConfirm = () => {\n cleanup();\n resolve(true);\n };\n\n modalContainer.addEventListener(\"click\", (e: MouseEvent) => {\n const target = e.target as HTMLElement;\n if (target.id === \"myModal\" || target.id === \"confirmModal\") {\n cleanup();\n }\n });\n });\n};\n\n// Open a toast notification\nexport const openToast = (\n message?: React.ReactDOM | string,\n status: StatusCode = 200\n): void => {\n const msg =\n status === 200 || status === 201\n ? \"Awesome! The update was made.\"\n : status === 500\n ? \"Sorry, the server can't process your request\"\n : \"Hmmm..., Something went wrong. Try again\";\n\n const iconSvg =\n status === 200 || status === 201\n ? '<svg viewBox=\"0 0 24 24\" style=\"color: var(--ViridianGreen); width:24px; height:24px;\"><path fill=\"currentColor\" d=\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z\"/></svg>'\n : '<svg viewBox=\"0 0 24 24\" style=\"color: var(--Danger); width:24px; height:24px;\"><path fill=\"currentColor\" d=\"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z\"/></svg>';\n\n let modalContainer = document.getElementById(\n \"openToast\"\n ) as HTMLDivElement | null;\n if (!modalContainer) {\n modalContainer = document.createElement(\"div\");\n modalContainer.id = \"openToast\";\n }\n\n const modalContent = `\n <div class=\"toast-wrapper\">\n <div class=\"slide-in-top\">\n <div class=\"align-text\">\n <div class=\"valid_btn\">\n ${iconSvg}\n <p class=\"${\n status === 200 || status === 201 ? \"isDone\" : \"isError\"\n }\">\n ${message || msg}\n </p>\n </div>\n </div>\n <svg width=\"800px\" height=\"800px\" viewBox=\"-0.5 0 25 25\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" \n class=\"close-btn\" onclick=\"window.cleanupToast()\">\n <path d=\"M3 21.32L21 3.32001\" stroke=\"var(--Gunmetal)\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n <path d=\"M3 3.32001L21 21.32\" stroke=\"var(--Gunmetal)\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n </svg>\n </div>\n </div>\n `;\n\n modalContainer.innerHTML = modalContent;\n document.body.appendChild(modalContainer);\n\n window.cleanupToast = () => {\n modalContainer?.remove();\n };\n\n setTimeout(() => {\n window.cleanupToast();\n }, 10000);\n};\n\n// Open a modal to get user email input\nexport const getUserEmailInputModal = (\n title: string\n): Promise<string | undefined> => {\n return new Promise((resolve) => {\n let modalContainer = document.getElementById(\n \"confirmModal\"\n ) as HTMLDivElement | null;\n if (!modalContainer) {\n modalContainer = document.createElement(\"div\");\n modalContainer.id = \"confirmModal\";\n }\n let emailValue: string | undefined;\n\n const cleanup = () => {\n modalContainer?.remove();\n };\n\n window.handleCleanUpInput = () => {\n cleanup();\n resolve(undefined);\n };\n\n window.handleInput = (e: HTMLInputElement) => {\n const proceedBtn = document.getElementById(\n \"proceedBtn\"\n ) as HTMLButtonElement | null;\n\n if (isValidEmail(e.value)) {\n if (proceedBtn) proceedBtn.disabled = false;\n emailValue = e.value;\n } else {\n if (proceedBtn) proceedBtn.disabled = true;\n emailValue = undefined;\n }\n };\n\n window.handleConfirm = () => {\n if (isValidEmail(emailValue)) {\n cleanup();\n resolve(emailValue);\n } else {\n openToast(\"You need to enter a valid email!\", 400);\n }\n };\n\n const modalContent = `\n <section id=\"myModal\" class=\"modal\">\n <div class=\"modal-content\">\n <svg width=\"800px\" height=\"800px\" viewBox=\"-0.5 0 25 25\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"\n class=\"ih_get_user_email_modal_close_btn\" onclick=\"window.handleCleanUpInput()\">\n <path d=\"M3 21.32L21 3.32001\" stroke=\"var(--Gunmetal)\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n <path d=\"M3 3.32001L21 21.32\" stroke=\"var(--Gunmetal)\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n </svg>\n <h4>Enrol for ${title}</h4>\n <p class=\"ihub-mt-3\">Enter a valid Email Address</p>\n <input type=\"email\" name=\"email\" id=\"userInput\" oninput=\"window.handleInput(this)\" />\n <div class=\"action_btn ihub-mt-3\">\n <button type=\"button\" disabled id=\"proceedBtn\" class=\"delete_btn important-btn\" onclick=\"window.handleConfirm()\">Proceed</button>\n </div>\n </div>\n </section>\n `;\n\n modalContainer.innerHTML = modalContent;\n document.body.appendChild(modalContainer);\n\n modalContainer.addEventListener(\"click\", (e: MouseEvent) => {\n const target = e.target as HTMLElement;\n if (target.id === \"myModal\" || target.id === \"confirmModal\") {\n cleanup();\n resolve(undefined);\n }\n });\n });\n};\n"],"names":["isValidEmail","input","length","test","openToast","message","status","arguments","undefined","msg","iconSvg","modalContainer","document","getElementById","createElement","id","modalContent","concat","innerHTML","body","appendChild","window","cleanupToast","_modalContainer2","remove","setTimeout","title","Promise","resolve","emailValue","cleanup","_modalContainer3","handleCleanUpInput","handleInput","e","proceedBtn","value","disabled","handleConfirm","addEventListener","target","flag","_modalContainer","handleCancel","console","log"],"mappings":"oEAMA,IAAMA,EAAe,SAACC,GACpB,IAAKA,GAASA,EAAMC,OAAS,EAC3B,OAAO,EAGT,MADmB,6BACDC,KAAKF,EACzB,EA8EaG,EAAY,SACvBC,GAEQ,IADRC,EAAAC,UAAAL,OAAA,QAAAM,IAAAD,UAAA,GAAAA,UAAA,GAAqB,IAEfE,EACO,MAAXH,GAA6B,MAAXA,EACd,gCACW,MAAXA,EACA,+CACA,2CAEAI,EACO,MAAXJ,GAA6B,MAAXA,EACd,qPACA,wSAEFK,EAAiBC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B,QAAQ,SAACC,GAClB,IAAIjB,EAAiBC,SAASC,eAC5B,gBAEGF,KACHA,EAAiBC,SAASE,cAAc,QACzBC,GAAK,gBAGtB,IAAMC,oLAAYC,OAIAwB,EAAO,wBAA0B,gBAAexB,oBAAAA,OAExDwB,EACI,wDACA,2BACN,mCAAAxB,OAGAZ,GACA,4FAQP,yVAEDM,EAAeO,UAAYF,EAC3BJ,SAASO,KAAKC,YAAYT,GAE1B,IAAMmB,EAAU,WAAK,IAAAY,EACLA,QAAdA,EAAA/B,aAAc+B,GAAdA,EAAgBlB,UAGlBH,OAAOsB,aAAe,WACpBb,IACAF,GAAQ,GACRgB,QAAQC,IAAI,KAGdxB,OAAOiB,cAAgB,WACrBR,IACAF,GAAQ,IAGVjB,EAAe4B,iBAAiB,QAAS,SAACL,GACxC,IAAMM,EAASN,EAAEM,OACC,YAAdA,EAAOzB,IAAkC,iBAAdyB,EAAOzB,IACpCe,GAEJ,EACF,EACF"}
1
+ {"version":3,"file":"modals.js","sources":["../../../../../src/components/lib/modals/modals.ts"],"sourcesContent":["// css: /Users/noaholatoye/Documents/code_projects/npm_packages/instincthub-react-ui/src/assets/css/modals\nimport React from \"react\";\n\n// Type for status codes\ntype StatusCode = 200 | 201 | 400 | 500 | number;\n\n// Utility function to validate email\nconst isValidEmail = (input: string | undefined): boolean => {\n if (!input || input.length < 3) {\n return false;\n }\n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n return emailRegex.test(input);\n};\n\n// Declare global window interface extensions for event handlers\ndeclare global {\n interface Window {\n handleCancel: () => void;\n handleConfirm: () => void;\n cleanupToast: () => void;\n handleInput: (e: HTMLInputElement) => void;\n handleCleanUpInput: () => void;\n }\n}\n\n/**\n * Opens a confirmation modal that returns a promise resolving to the user's choice.\n *\n * @example\n * ```tsx\n * import { openConfirmModal } from \"@instincthub/react-ui/lib\";\n *\n * // Basic confirmation\n * const handleAction = async () => {\n * const confirmed = await openConfirmModal(\"Are you sure you want to proceed?\");\n * if (confirmed) {\n * // User clicked \"Ok\"\n * performAction();\n * }\n * };\n *\n * // With warning flag (red warning banner)\n * const handleDangerousAction = async () => {\n * const confirmed = await openConfirmModal(\n * \"This will permanently remove all data. Continue?\",\n * true // Shows red warning banner\n * );\n * if (confirmed) {\n * deleteAllData();\n * }\n * };\n *\n * // In a form submission flow\n * const handleSubmit = async (formData: FormData) => {\n * const confirmed = await openConfirmModal(\n * \"You are about to submit this form. Please review your entries.\"\n * );\n * if (confirmed) {\n * await submitForm(formData);\n * openToast(\"Form submitted successfully!\");\n * }\n * };\n * ```\n *\n * @param message - The confirmation message to display\n * @param flag - If true, shows a red warning banner instead of the default purple one\n * @returns Promise that resolves to `true` (Ok) or `false` (Cancel / overlay click)\n */\nexport const openConfirmModal = (\n message: string,\n flag: boolean = false\n): Promise<boolean> => {\n return new Promise((resolve) => {\n let modalContainer = document.getElementById(\n \"confirmModal\"\n ) as HTMLDivElement | null;\n if (!modalContainer) {\n modalContainer = document.createElement(\"div\");\n modalContainer.id = \"confirmModal\";\n }\n\n const warningClass = flag ? \"something_bad_flagged\" : \"something_bad\";\n const warningText = flag\n ? \"Unexpected things will happen if you don't read this!\"\n : \"You are about to submit!\";\n const bodyText =\n message ||\n \"Carefully read the instructions before making a decision. Ready? Hit the continue button!\";\n\n // Build modal using safe DOM methods\n const section = document.createElement(\"section\");\n section.id = \"myModal\";\n section.className = \"modal\";\n\n const contentDiv = document.createElement(\"div\");\n contentDiv.className = \"modal-content\";\n\n const closeSpan = document.createElement(\"span\");\n closeSpan.className = \"close\";\n closeSpan.textContent = \"\\u00D7\";\n closeSpan.addEventListener(\"click\", () => {\n cleanup();\n resolve(false);\n });\n\n const warningP = document.createElement(\"p\");\n warningP.className = warningClass;\n warningP.textContent = warningText;\n\n const bodyP = document.createElement(\"p\");\n bodyP.textContent = bodyText;\n\n const actionsDiv = document.createElement(\"div\");\n actionsDiv.className = \"mt-4\";\n\n const cancelBtn = document.createElement(\"button\");\n cancelBtn.type = \"button\";\n cancelBtn.className = \"danger-btn d-inline-block\";\n cancelBtn.textContent = \"Cancel\";\n cancelBtn.addEventListener(\"click\", () => {\n cleanup();\n resolve(false);\n });\n\n const okBtn = document.createElement(\"button\");\n okBtn.type = \"button\";\n okBtn.className = \"important-btn confirm-btn ihub-bg-dark-cyan\";\n okBtn.textContent = \"Ok\";\n okBtn.addEventListener(\"click\", () => {\n cleanup();\n resolve(true);\n });\n\n actionsDiv.appendChild(cancelBtn);\n actionsDiv.appendChild(okBtn);\n contentDiv.appendChild(closeSpan);\n contentDiv.appendChild(warningP);\n contentDiv.appendChild(bodyP);\n contentDiv.appendChild(actionsDiv);\n section.appendChild(contentDiv);\n\n // Clear and set content\n modalContainer.textContent = \"\";\n modalContainer.appendChild(section);\n document.body.appendChild(modalContainer);\n\n const cleanup = () => {\n modalContainer?.remove();\n };\n\n modalContainer.addEventListener(\"click\", (e: MouseEvent) => {\n const target = e.target as HTMLElement;\n if (target.id === \"myModal\" || target.id === \"confirmModal\") {\n cleanup();\n resolve(false);\n }\n });\n });\n};\n\n// Counter to stack multiple toasts\nlet toastCounter = 0;\n\n/**\n * Displays an auto-dismissing toast notification with status-based styling,\n * a countdown progress bar, and stacking support for multiple toasts.\n *\n * @example\n * ```tsx\n * import { openToast } from \"@instincthub/react-ui/lib\";\n *\n * // Success notifications\n * openToast(\"Profile updated successfully!\");\n * openToast(\"New item created!\", 201);\n *\n * // Error notifications\n * openToast(\"Please check your input.\", 400);\n * openToast(\"You don't have permission.\", 403);\n *\n * // Server error\n * openToast(\"Server error occurred.\", 500);\n *\n * // Default messages (no custom message)\n * openToast(); // \"Awesome! The update was made.\"\n * openToast(undefined, 400); // \"Hmmm..., Something went wrong. Try again\"\n * openToast(undefined, 500); // \"Sorry, the server can't process your request\"\n *\n * // In async operations\n * const handleSave = async () => {\n * try {\n * await saveData();\n * openToast(\"Data saved successfully!\");\n * } catch (error) {\n * openToast(\"Failed to save data.\", 500);\n * }\n * };\n *\n * // After form validation\n * if (!isValid) {\n * openToast(\"Please fill in all required fields.\", 400);\n * return;\n * }\n *\n * // After API delete\n * openToast(`${itemName} was successfully deleted.`);\n * ```\n *\n * @param message - Custom notification message. Falls back to a default based on status code.\n * @param status - HTTP-style status code for styling (default: 200).\n * - `200/201` → green success icon\n * - `400-499` → red error icon\n * - `500+` → red error icon\n */\nexport const openToast = (\n message?: React.ReactDOM | string,\n status: StatusCode = 200\n): void => {\n const isSuccess = status === 200 || status === 201;\n\n const msg = isSuccess\n ? \"Awesome! The update was made.\"\n : status === 500\n ? \"Sorry, the server can't process your request\"\n : \"Hmmm..., Something went wrong. Try again\";\n\n const displayMessage = (message as string) || msg;\n\n // Create a unique container per toast for stacking\n const toastId = `ihub-toast-${++toastCounter}`;\n const toastContainer = document.createElement(\"div\");\n toastContainer.id = toastId;\n toastContainer.className = \"ihub-toast-container\";\n\n // Build toast using safe DOM methods\n const variant = isSuccess ? \"success\" : \"error\";\n const toast = document.createElement(\"div\");\n toast.className = `ihub-toast ihub-toast--${variant} ihub-toast-slide-in`;\n\n // Toast body (icon + message)\n const body = document.createElement(\"div\");\n body.className = \"ihub-toast-body\";\n\n const iconSvg = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n iconSvg.setAttribute(\"viewBox\", \"0 0 24 24\");\n iconSvg.setAttribute(\"class\", `ihub-toast-icon ihub-toast-icon--${variant}`);\n const iconPath = document.createElementNS(\n \"http://www.w3.org/2000/svg\",\n \"path\"\n );\n iconPath.setAttribute(\"fill\", \"currentColor\");\n iconPath.setAttribute(\n \"d\",\n isSuccess\n ? \"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z\"\n : \"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z\"\n );\n iconSvg.appendChild(iconPath);\n\n const msgP = document.createElement(\"p\");\n msgP.className = \"ihub-toast-message\";\n msgP.textContent = displayMessage;\n\n body.appendChild(iconSvg);\n body.appendChild(msgP);\n\n // Close button\n const closeBtn = document.createElement(\"button\");\n closeBtn.type = \"button\";\n closeBtn.className = \"ihub-toast-close\";\n closeBtn.setAttribute(\"aria-label\", \"Close notification\");\n\n const closeSvg = document.createElementNS(\n \"http://www.w3.org/2000/svg\",\n \"svg\"\n );\n closeSvg.setAttribute(\"width\", \"14\");\n closeSvg.setAttribute(\"height\", \"14\");\n closeSvg.setAttribute(\"viewBox\", \"0 0 24 24\");\n closeSvg.setAttribute(\"fill\", \"none\");\n closeSvg.setAttribute(\"stroke\", \"currentColor\");\n closeSvg.setAttribute(\"stroke-width\", \"2\");\n closeSvg.setAttribute(\"stroke-linecap\", \"round\");\n closeSvg.setAttribute(\"stroke-linejoin\", \"round\");\n\n const line1 = document.createElementNS(\"http://www.w3.org/2000/svg\", \"line\");\n line1.setAttribute(\"x1\", \"18\");\n line1.setAttribute(\"y1\", \"6\");\n line1.setAttribute(\"x2\", \"6\");\n line1.setAttribute(\"y2\", \"18\");\n\n const line2 = document.createElementNS(\"http://www.w3.org/2000/svg\", \"line\");\n line2.setAttribute(\"x1\", \"6\");\n line2.setAttribute(\"y1\", \"6\");\n line2.setAttribute(\"x2\", \"18\");\n line2.setAttribute(\"y2\", \"18\");\n\n closeSvg.appendChild(line1);\n closeSvg.appendChild(line2);\n closeBtn.appendChild(closeSvg);\n\n // Progress bar\n const progressBar = document.createElement(\"div\");\n progressBar.className = `ihub-toast-progress ihub-toast-progress--${variant}`;\n\n // Assemble toast\n toast.appendChild(body);\n toast.appendChild(closeBtn);\n toast.appendChild(progressBar);\n toastContainer.appendChild(toast);\n document.body.appendChild(toastContainer);\n\n const cleanup = () => {\n const el = document.getElementById(toastId);\n if (!el) return;\n const toastEl = el.querySelector(\".ihub-toast\");\n if (toastEl) {\n toastEl.classList.add(\"ihub-toast-slide-out\");\n toastEl.addEventListener(\"animationend\", () => el.remove(), {\n once: true,\n });\n } else {\n el.remove();\n }\n };\n\n closeBtn.addEventListener(\"click\", cleanup);\n\n // Auto-dismiss after 8 seconds\n setTimeout(cleanup, 8000);\n};\n\n/**\n * Opens a modal dialog to collect a user's email address with built-in validation.\n *\n * @example\n * ```tsx\n * import { getUserEmailInputModal } from \"@instincthub/react-ui/lib\";\n *\n * // Collect email for course enrollment\n * const handleEnroll = async () => {\n * const email = await getUserEmailInputModal(\"Web Development Bootcamp\");\n * if (email) {\n * // User entered a valid email and clicked \"Proceed\"\n * await enrollUser(email, courseId);\n * openToast(\"Enrollment successful!\");\n * } else {\n * // User cancelled or closed the modal\n * console.log(\"Enrollment cancelled\");\n * }\n * };\n *\n * // Collect email for newsletter signup\n * const handleNewsletter = async () => {\n * const email = await getUserEmailInputModal(\"Weekly Newsletter\");\n * if (email) {\n * await subscribeToNewsletter(email);\n * }\n * };\n *\n * // Collect email before downloading a resource\n * const handleDownload = async () => {\n * const email = await getUserEmailInputModal(\"Free E-Book: React Patterns\");\n * if (email) {\n * await sendDownloadLink(email, resourceId);\n * openToast(\"Download link sent to your email!\", 200);\n * }\n * };\n * ```\n *\n * @param title - The title displayed in the modal (e.g. course name, resource name)\n * @returns Promise that resolves to the email string if valid, or `undefined` if cancelled\n */\nexport const getUserEmailInputModal = (\n title: string\n): Promise<string | undefined> => {\n return new Promise((resolve) => {\n let modalContainer = document.getElementById(\n \"confirmModal\"\n ) as HTMLDivElement | null;\n if (!modalContainer) {\n modalContainer = document.createElement(\"div\");\n modalContainer.id = \"confirmModal\";\n }\n let emailValue: string | undefined;\n\n const cleanup = () => {\n modalContainer?.remove();\n };\n\n // Build modal using safe DOM methods\n const section = document.createElement(\"section\");\n section.id = \"myModal\";\n section.className = \"modal\";\n\n const contentDiv = document.createElement(\"div\");\n contentDiv.className = \"modal-content\";\n\n // Close button SVG\n const closeSvg = document.createElementNS(\n \"http://www.w3.org/2000/svg\",\n \"svg\"\n );\n closeSvg.setAttribute(\"width\", \"24\");\n closeSvg.setAttribute(\"height\", \"24\");\n closeSvg.setAttribute(\"viewBox\", \"-0.5 0 25 25\");\n closeSvg.setAttribute(\"fill\", \"none\");\n closeSvg.setAttribute(\"class\", \"ih_get_user_email_modal_close_btn\");\n closeSvg.style.cursor = \"pointer\";\n\n const closePath1 = document.createElementNS(\n \"http://www.w3.org/2000/svg\",\n \"path\"\n );\n closePath1.setAttribute(\"d\", \"M3 21.32L21 3.32001\");\n closePath1.setAttribute(\"stroke\", \"var(--Gunmetal)\");\n closePath1.setAttribute(\"stroke-width\", \"1.5\");\n closePath1.setAttribute(\"stroke-linecap\", \"round\");\n closePath1.setAttribute(\"stroke-linejoin\", \"round\");\n\n const closePath2 = document.createElementNS(\n \"http://www.w3.org/2000/svg\",\n \"path\"\n );\n closePath2.setAttribute(\"d\", \"M3 3.32001L21 21.32\");\n closePath2.setAttribute(\"stroke\", \"var(--Gunmetal)\");\n closePath2.setAttribute(\"stroke-width\", \"1.5\");\n closePath2.setAttribute(\"stroke-linecap\", \"round\");\n closePath2.setAttribute(\"stroke-linejoin\", \"round\");\n\n closeSvg.appendChild(closePath1);\n closeSvg.appendChild(closePath2);\n closeSvg.addEventListener(\"click\", () => {\n cleanup();\n resolve(undefined);\n });\n\n const heading = document.createElement(\"h4\");\n heading.textContent = `Enrol for ${title}`;\n\n const instruction = document.createElement(\"p\");\n instruction.className = \"ihub-mt-3\";\n instruction.textContent = \"Enter a valid Email Address\";\n\n const emailInput = document.createElement(\"input\");\n emailInput.type = \"email\";\n emailInput.name = \"email\";\n emailInput.id = \"userInput\";\n\n const actionDiv = document.createElement(\"div\");\n actionDiv.className = \"action_btn ihub-mt-3\";\n\n const proceedBtn = document.createElement(\"button\");\n proceedBtn.type = \"button\";\n proceedBtn.disabled = true;\n proceedBtn.id = \"proceedBtn\";\n proceedBtn.className = \"delete_btn important-btn\";\n proceedBtn.textContent = \"Proceed\";\n\n emailInput.addEventListener(\"input\", () => {\n if (isValidEmail(emailInput.value)) {\n proceedBtn.disabled = false;\n emailValue = emailInput.value;\n } else {\n proceedBtn.disabled = true;\n emailValue = undefined;\n }\n });\n\n proceedBtn.addEventListener(\"click\", () => {\n if (isValidEmail(emailValue)) {\n cleanup();\n resolve(emailValue);\n } else {\n openToast(\"You need to enter a valid email!\", 400);\n }\n });\n\n actionDiv.appendChild(proceedBtn);\n contentDiv.appendChild(closeSvg);\n contentDiv.appendChild(heading);\n contentDiv.appendChild(instruction);\n contentDiv.appendChild(emailInput);\n contentDiv.appendChild(actionDiv);\n section.appendChild(contentDiv);\n\n modalContainer.textContent = \"\";\n modalContainer.appendChild(section);\n document.body.appendChild(modalContainer);\n\n modalContainer.addEventListener(\"click\", (e: MouseEvent) => {\n const target = e.target as HTMLElement;\n if (target.id === \"myModal\" || target.id === \"confirmModal\") {\n cleanup();\n resolve(undefined);\n }\n });\n });\n};\n"],"names":["isValidEmail","input","length","test","toastCounter","openToast","message","status","arguments","undefined","isSuccess","displayMessage","toastId","concat","toastContainer","document","createElement","id","className","variant","toast","body","iconSvg","createElementNS","setAttribute","iconPath","appendChild","msgP","textContent","closeBtn","type","closeSvg","line1","line2","progressBar","cleanup","el","getElementById","toastEl","querySelector","classList","add","addEventListener","remove","once","setTimeout","title","Promise","resolve","emailValue","modalContainer","_modalContainer2","section","contentDiv","style","cursor","closePath1","closePath2","heading","instruction","emailInput","name","actionDiv","proceedBtn","disabled","value","e","target","flag","warningClass","warningText","bodyText","closeSpan","warningP","bodyP","actionsDiv","cancelBtn","okBtn","_modalContainer"],"mappings":"oEAOA,IAAMA,EAAe,SAACC,GACpB,IAAKA,GAASA,EAAMC,OAAS,EAC3B,OAAO,EAGT,MADmB,6BACDC,KAAKF,EACzB,EAqJIG,EAAe,EAoDNC,EAAY,SACvBC,GAEQ,IADRC,EAAAC,UAAAN,OAAA,QAAAO,IAAAD,UAAA,GAAAA,UAAA,GAAqB,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B8C,EAAU1D,UAAY,4BACtB0D,EAAUhD,YAAc,SACxBgD,EAAUlC,iBAAiB,QAAS,WAClCP,IACAa,GAAQ,EACV,GAEA,IAAM6B,EAAQ9D,SAASC,cAAc,UACrC6D,EAAM/C,KAAO,SACb+C,EAAM3D,UAAY,8CAClB2D,EAAMjD,YAAc,KACpBiD,EAAMnC,iBAAiB,QAAS,WAC9BP,IACAa,GAAQ,EACV,GAEA2B,EAAWjD,YAAYkD,GACvBD,EAAWjD,YAAYmD,GACvBxB,EAAW3B,YAAY8C,GACvBnB,EAAW3B,YAAY+C,GACvBpB,EAAW3B,YAAYgD,GACvBrB,EAAW3B,YAAYiD,GACvBvB,EAAQ1B,YAAY2B,GAGpBH,EAAetB,YAAc,GAC7BsB,EAAexB,YAAY0B,GAC3BrC,SAASM,KAAKK,YAAYwB,GAE1B,IAAMf,EAAU,WAAK,IAAA2C,EACLA,QAAdA,EAAA5B,aAAc4B,GAAdA,EAAgBnC,UAGlBO,EAAeR,iBAAiB,QAAS,SAACwB,GACxC,IAAMC,EAASD,EAAEC,OACC,YAAdA,EAAOlD,IAAkC,iBAAdkD,EAAOlD,KACpCkB,IACAa,GAAQ,GAEZ,EACF,EACF"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_rollupPluginBabelHelpers.js"),t=require("react/jsx-runtime"),a=require("react"),o=require("../../../../../node_modules/.pnpm/@tiptap_react@2.27.1_@tiptap_core@2.27.1_@tiptap_pm@2.27.1__@tiptap_pm@2.27.1_react-dom_3687a02a33de69fe477ccd0d970063c0/node_modules/@tiptap/react/dist/index.js"),r=require("./types.js"),n=require("./hooks/useIHubEditor.js"),i=require("./hooks/useSlashCommands.js"),s=require("./hooks/useImageUpload.js"),d=require("./hooks/useMediaEmbed.js"),l=require("./components/BubbleToolbar.js"),u=require("./components/SlashCommandMenu.js"),c=require("./components/FloatingAddButton.js"),m=require("./components/TableToolbar.js"),p=require("./components/EditorFooter.js");exports.default=function(h){var f=h.name,b=void 0===f?"editor-content":f,j=h.label,v=h.content,x=void 0===v?"":v,g=h.placeholder,_=void 0===g?"Tell your story...":g,q=h.onChange,C=h.onBlur,E=h.required,y=void 0!==E&&E,S=h.charLimit,I=void 0===S?5e4:S,B=h.features,U=h.onImageUpload,k=h.className,T=void 0===k?"":k,F=h.minHeight,H=void 0===F?"400px":F,M=h.maxHeight,N=void 0===M?"80vh":M,A=h.lastUpdated,w=h.readOnly,L=void 0!==w&&w,O=h.extensions,R=void 0===O?[]:O,P=a.useMemo(function(){return e.objectSpread2(e.objectSpread2({},r.DEFAULT_FEATURES),B)},[B]),z=a.useState(x),D=e.slicedToArray(z,2),Y=D[0],G=D[1],J=i.default(),K=n.default({content:x,placeholder:_,charLimit:I,features:B,readOnly:L,onChange:function(e){G(e),null==q||q(e)},onBlur:C,additionalExtensions:R,onSlashCommandStart:J.onStart,onSlashCommandExit:J.onExit}),Q=s.default({editor:K,onImageUpload:U,enabled:P.imageUpload}).openFilePicker;d.default({editor:K,enabled:P.mediaEmbeds});var V=["ihub-te-wrapper",P.focusMode?"ihub-te-wrapper--focus":"",L?"ihub-te-wrapper--readonly":"",T].filter(Boolean).join(" "),W=a.useCallback(function(e){if(K&&!L){var t=e.target;if(t.closest(".ihub-te-content")){var a=t.closest(".ihub-te-content");if(a){var o=a.lastElementChild;if(o){var r=o.getBoundingClientRect();if(e.clientY>r.bottom){var n=K.state.doc.lastChild;n&&"paragraph"!==n.type.name?K.chain().focus("end").command(function(e){var t=e.tr;if(e.dispatch){var a=K.state.schema.nodes.paragraph.create();t.insert(t.doc.content.size,a)}return!0}).focus("end").run():K.commands.focus("end")}}}}else K.commands.focus("end")}},[K,L]);return K?t.jsxs("div",{className:V,children:[j&&t.jsxs("label",{htmlFor:b,className:"ihub-te-label",children:[j,y&&t.jsx("span",{className:"ihub-te-required",children:"*"})]}),t.jsxs("div",{className:"ihub-te-editor-area",style:{minHeight:H,maxHeight:N},onClick:W,children:[P.bubbleMenu&&!L&&t.jsx(l.default,{editor:K}),P.floatingAddButton&&!L&&t.jsx(c.default,{editor:K,onImageInsert:Q}),P.slashCommands&&J.isOpen&&t.jsx(u.default,{items:J.items,selectedIndex:J.selectedIndex,onSelect:J.selectItem,clientRect:J.clientRect}),t.jsx(o.EditorContent,{editor:K,className:"ihub-te-content-wrapper"}),P.tables&&!L&&t.jsx(m.default,{editor:K})]}),t.jsx("input",{type:"hidden",value:Y,name:b}),P.characterCount&&t.jsx(p.default,{editor:K,charLimit:I,lastUpdated:A})]}):null};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_rollupPluginBabelHelpers.js"),t=require("react/jsx-runtime"),a=require("react"),o=require("../../../../../node_modules/.pnpm/@tiptap_react@2.27.1_@tiptap_core@2.27.1_@tiptap_pm@2.27.1__@tiptap_pm@2.27.1_react-dom_3687a02a33de69fe477ccd0d970063c0/node_modules/@tiptap/react/dist/index.js"),r=require("./types.js"),i=require("./hooks/useIHubEditor.js"),n=require("./hooks/useSlashCommands.js"),s=require("./hooks/useImageUpload.js"),d=require("./hooks/useMediaEmbed.js"),l=require("./components/BubbleToolbar.js"),u=require("./components/SlashCommandMenu.js"),c=require("./components/FloatingAddButton.js"),m=require("./components/TableToolbar.js"),p=require("./components/EditorFooter.js");exports.default=function(h){var b=h.name,f=void 0===b?"editor-content":b,j=h.label,v=h.content,x=void 0===v?"":v,g=h.placeholder,_=void 0===g?"Tell your story...":g,q=h.onChange,C=h.onBlur,E=h.required,y=void 0!==E&&E,S=h.charLimit,I=void 0===S?5e4:S,k=h.features,B=h.onImageUpload,U=h.className,T=void 0===U?"":U,F=h.minHeight,H=void 0===F?"400px":F,M=h.maxHeight,N=void 0===M?"80vh":M,A=h.lastUpdated,w=h.readOnly,L=void 0!==w&&w,O=h.extensions,R=void 0===O?[]:O,P=a.useMemo(function(){return e.objectSpread2(e.objectSpread2({},r.DEFAULT_FEATURES),k)},[k]),z=a.useState(x),D=e.slicedToArray(z,2),Y=D[0],G=D[1],J=n.default(),K=i.default({content:x,placeholder:_,charLimit:I,features:k,readOnly:L,onChange:function(e){G(e),null==q||q(e)},onBlur:C,additionalExtensions:R,onSlashCommandStart:J.onStart,onSlashCommandExit:J.onExit}),Q=s.default({editor:K,onImageUpload:B,enabled:P.imageUpload}).openFilePicker;d.default({editor:K,enabled:P.mediaEmbeds});var V=["ihub-te-wrapper",P.focusMode?"ihub-te-wrapper--focus":"",L?"ihub-te-wrapper--readonly":"",T].filter(Boolean).join(" "),W=a.useCallback(function(e){if(K&&!L){var t=e.target;if(!t.closest(".ihub-te-bubble-menu, .ihub-te-bubble-toolbar, .ihub-te-link-popover"))if(t.closest(".ihub-te-content")){var a=t.closest(".ihub-te-content");if(a){var o=a.lastElementChild;if(o){var r=o.getBoundingClientRect();if(e.clientY>r.bottom){var i=K.state.doc.lastChild;i&&"paragraph"!==i.type.name?K.chain().focus("end").command(function(e){var t=e.tr;if(e.dispatch){var a=K.state.schema.nodes.paragraph.create();t.insert(t.doc.content.size,a)}return!0}).focus("end").run():K.commands.focus("end")}}}}else K.commands.focus("end")}},[K,L]);return K?t.jsxs("div",{className:V,children:[j&&t.jsxs("label",{htmlFor:f,className:"ihub-te-label",children:[j,y&&t.jsx("span",{className:"ihub-te-required",children:"*"})]}),t.jsxs("div",{className:"ihub-te-editor-area",style:{minHeight:H,maxHeight:N},onClick:W,children:[P.bubbleMenu&&!L&&t.jsx(l.default,{editor:K}),P.floatingAddButton&&!L&&t.jsx(c.default,{editor:K,onImageInsert:Q}),P.slashCommands&&J.isOpen&&t.jsx(u.default,{items:J.items,selectedIndex:J.selectedIndex,onSelect:J.selectItem,clientRect:J.clientRect}),t.jsx(o.EditorContent,{editor:K,className:"ihub-te-content-wrapper"}),P.tables&&!L&&t.jsx(m.default,{editor:K})]}),t.jsx("input",{type:"hidden",value:Y,name:f}),P.characterCount&&t.jsx(p.default,{editor:K,charLimit:I,lastUpdated:A})]}):null};
2
2
  //# sourceMappingURL=IHubTextEditor.js.map