basecoat-css 0.2.4 → 0.2.7
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/dist/basecoat.cdn.css +80 -13
- package/dist/basecoat.cdn.min.css +1 -1
- package/dist/basecoat.css +17 -9
- package/dist/js/all.js +97 -34
- package/dist/js/all.min.js +1 -1
- package/dist/js/dropdown-menu.js +34 -8
- package/dist/js/dropdown-menu.min.js +1 -1
- package/dist/js/popover.js +1 -0
- package/dist/js/popover.min.js +1 -1
- package/dist/js/select.js +59 -26
- package/dist/js/select.min.js +1 -1
- package/dist/js/sidebar.js +1 -0
- package/dist/js/sidebar.min.js +1 -1
- package/dist/js/tabs.js +1 -0
- package/dist/js/tabs.min.js +1 -1
- package/dist/js/toast.js +1 -0
- package/dist/js/toast.min.js +1 -1
- package/package.json +1 -1
package/dist/js/select.js
CHANGED
|
@@ -20,6 +20,26 @@
|
|
|
20
20
|
let visibleOptions = [...options];
|
|
21
21
|
let activeIndex = -1;
|
|
22
22
|
|
|
23
|
+
const setActiveOption = (index) => {
|
|
24
|
+
if (activeIndex > -1 && options[activeIndex]) {
|
|
25
|
+
options[activeIndex].classList.remove('active');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
activeIndex = index;
|
|
29
|
+
|
|
30
|
+
if (activeIndex > -1) {
|
|
31
|
+
const activeOption = options[activeIndex];
|
|
32
|
+
activeOption.classList.add('active');
|
|
33
|
+
if (activeOption.id) {
|
|
34
|
+
trigger.setAttribute('aria-activedescendant', activeOption.id);
|
|
35
|
+
} else {
|
|
36
|
+
trigger.removeAttribute('aria-activedescendant');
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
trigger.removeAttribute('aria-activedescendant');
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
23
43
|
const hasTransition = () => {
|
|
24
44
|
const style = getComputedStyle(popover);
|
|
25
45
|
return parseFloat(style.transitionDuration) > 0 || parseFloat(style.transitionDelay) > 0;
|
|
@@ -54,9 +74,7 @@
|
|
|
54
74
|
if (focusOnTrigger) trigger.focus();
|
|
55
75
|
popover.setAttribute('aria-hidden', 'true');
|
|
56
76
|
trigger.setAttribute('aria-expanded', 'false');
|
|
57
|
-
|
|
58
|
-
if (activeIndex > -1) options[activeIndex]?.classList.remove('active');
|
|
59
|
-
activeIndex = -1;
|
|
77
|
+
setActiveOption(-1);
|
|
60
78
|
}
|
|
61
79
|
|
|
62
80
|
const selectOption = (option) => {
|
|
@@ -75,15 +93,24 @@
|
|
|
75
93
|
selectComponent.dispatchEvent(event);
|
|
76
94
|
};
|
|
77
95
|
|
|
96
|
+
const selectByValue = (value) => {
|
|
97
|
+
const option = options.find(opt => opt.dataset.value === value);
|
|
98
|
+
if (option) {
|
|
99
|
+
updateValue(option);
|
|
100
|
+
|
|
101
|
+
const event = new CustomEvent('change', {
|
|
102
|
+
detail: { value: option.dataset.value },
|
|
103
|
+
bubbles: true
|
|
104
|
+
});
|
|
105
|
+
selectComponent.dispatchEvent(event);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
78
109
|
if (filter) {
|
|
79
110
|
const filterOptions = () => {
|
|
80
111
|
const searchTerm = filter.value.trim().toLowerCase();
|
|
81
112
|
|
|
82
|
-
|
|
83
|
-
options[activeIndex].classList.remove('active');
|
|
84
|
-
trigger.removeAttribute('aria-activedescendant');
|
|
85
|
-
activeIndex = -1;
|
|
86
|
-
}
|
|
113
|
+
setActiveOption(-1);
|
|
87
114
|
|
|
88
115
|
visibleOptions = [];
|
|
89
116
|
options.forEach(option => {
|
|
@@ -160,21 +187,31 @@
|
|
|
160
187
|
}
|
|
161
188
|
|
|
162
189
|
if (nextVisibleIndex !== currentVisibleIndex) {
|
|
163
|
-
if (currentVisibleIndex > -1) {
|
|
164
|
-
visibleOptions[currentVisibleIndex].classList.remove('active');
|
|
165
|
-
}
|
|
166
|
-
|
|
167
190
|
const newActiveOption = visibleOptions[nextVisibleIndex];
|
|
168
|
-
|
|
169
|
-
activeIndex = options.indexOf(newActiveOption);
|
|
170
|
-
|
|
171
|
-
if (newActiveOption.id) {
|
|
172
|
-
trigger.setAttribute('aria-activedescendant', newActiveOption.id);
|
|
173
|
-
}
|
|
191
|
+
setActiveOption(options.indexOf(newActiveOption));
|
|
174
192
|
newActiveOption.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
|
|
175
193
|
}
|
|
176
194
|
};
|
|
177
195
|
|
|
196
|
+
listbox.addEventListener('mousemove', (event) => {
|
|
197
|
+
const option = event.target.closest('[role="option"]');
|
|
198
|
+
if (option && visibleOptions.includes(option)) {
|
|
199
|
+
const index = options.indexOf(option);
|
|
200
|
+
if (index !== activeIndex) {
|
|
201
|
+
setActiveOption(index);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
listbox.addEventListener('mouseleave', () => {
|
|
207
|
+
const selectedOption = listbox.querySelector('[role="option"][aria-selected="true"]');
|
|
208
|
+
if (selectedOption) {
|
|
209
|
+
setActiveOption(options.indexOf(selectedOption));
|
|
210
|
+
} else {
|
|
211
|
+
setActiveOption(-1);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
178
215
|
trigger.addEventListener('keydown', handleKeyNavigation);
|
|
179
216
|
if (filter) {
|
|
180
217
|
filter.addEventListener('keydown', handleKeyNavigation);
|
|
@@ -200,14 +237,7 @@
|
|
|
200
237
|
|
|
201
238
|
const selectedOption = listbox.querySelector('[role="option"][aria-selected="true"]');
|
|
202
239
|
if (selectedOption) {
|
|
203
|
-
|
|
204
|
-
options[activeIndex]?.classList.remove('active');
|
|
205
|
-
}
|
|
206
|
-
activeIndex = options.indexOf(selectedOption);
|
|
207
|
-
selectedOption.classList.add('active');
|
|
208
|
-
if (selectedOption.id) {
|
|
209
|
-
trigger.setAttribute('aria-activedescendant', selectedOption.id);
|
|
210
|
-
}
|
|
240
|
+
setActiveOption(options.indexOf(selectedOption));
|
|
211
241
|
selectedOption.scrollIntoView({ block: 'nearest' });
|
|
212
242
|
}
|
|
213
243
|
};
|
|
@@ -241,7 +271,10 @@
|
|
|
241
271
|
});
|
|
242
272
|
|
|
243
273
|
popover.setAttribute('aria-hidden', 'true');
|
|
274
|
+
|
|
275
|
+
selectComponent.selectByValue = selectByValue;
|
|
244
276
|
selectComponent.dataset.selectInitialized = true;
|
|
277
|
+
selectComponent.dispatchEvent(new CustomEvent('basecoat:initialized'));
|
|
245
278
|
};
|
|
246
279
|
|
|
247
280
|
document.querySelectorAll('div.select:not([data-select-initialized])').forEach(initSelect);
|
package/dist/js/select.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{const e=e=>{const t=e.querySelector(":scope > button"),a=t.querySelector(":scope > span"),
|
|
1
|
+
(()=>{const e=e=>{const t=e.querySelector(":scope > button"),a=t.querySelector(":scope > span"),n=e.querySelector(":scope > [data-popover]"),i=n.querySelector('[role="listbox"]'),r=e.querySelector(':scope > input[type="hidden"]'),o=e.querySelector('header input[type="text"]');if(!(t&&n&&i&&r)){const a=[];return t||a.push("trigger"),n||a.push("popover"),i||a.push("listbox"),r||a.push("input"),void console.error(`Select component initialisation failed. Missing element(s): ${a.join(", ")}`,e)}const s=Array.from(i.querySelectorAll('[role="option"]'));let d=[...s],c=-1;const l=e=>{if(c>-1&&s[c]&&s[c].classList.remove("active"),c=e,c>-1){const e=s[c];e.classList.add("active"),e.id?t.setAttribute("aria-activedescendant",e.id):t.removeAttribute("aria-activedescendant")}else t.removeAttribute("aria-activedescendant")},u=()=>{const e=getComputedStyle(n);return parseFloat(e.transitionDuration)>0||parseFloat(e.transitionDelay)>0},v=e=>{e&&(a.innerHTML=e.dataset.label||e.innerHTML,r.value=e.dataset.value,i.querySelector('[role="option"][aria-selected="true"]')?.removeAttribute("aria-selected"),e.setAttribute("aria-selected","true"))},p=(e=!0)=>{if("true"!==n.getAttribute("aria-hidden")){if(o){const e=()=>{o.value="",d=[...s],s.forEach((e=>e.setAttribute("aria-hidden","false")))};u()?n.addEventListener("transitionend",e,{once:!0}):e()}e&&t.focus(),n.setAttribute("aria-hidden","true"),t.setAttribute("aria-expanded","false"),l(-1)}},b=t=>{if(!t)return;null!=t.dataset.value&&v(t),p();const a=new CustomEvent("change",{detail:{value:t.dataset.value},bubbles:!0});e.dispatchEvent(a)};if(o){const e=()=>{const e=o.value.trim().toLowerCase();l(-1),d=[],s.forEach((t=>{const a=(t.dataset.label||t.textContent).trim().toLowerCase().includes(e);t.setAttribute("aria-hidden",String(!a)),a&&d.push(t)}))};o.addEventListener("input",e)}let f=s.find((e=>e.dataset.value===r.value));!f&&s.length>0&&(f=s[0]),v(f);const E=e=>{const a="false"===n.getAttribute("aria-hidden");if(!["ArrowDown","ArrowUp","Enter","Home","End","Escape"].includes(e.key))return;if(!a)return void("Enter"!==e.key&&"Escape"!==e.key&&(e.preventDefault(),t.click()));if(e.preventDefault(),"Escape"===e.key)return void p();if("Enter"===e.key)return void(c>-1&&b(s[c]));if(0===d.length)return;const i=c>-1?d.indexOf(s[c]):-1;let r=i;switch(e.key){case"ArrowDown":i<d.length-1&&(r=i+1);break;case"ArrowUp":i>0?r=i-1:-1===i&&(r=0);break;case"Home":r=0;break;case"End":r=d.length-1}if(r!==i){const e=d[r];l(s.indexOf(e)),e.scrollIntoView({block:"nearest",behavior:"smooth"})}};i.addEventListener("mousemove",(e=>{const t=e.target.closest('[role="option"]');if(t&&d.includes(t)){const e=s.indexOf(t);e!==c&&l(e)}})),i.addEventListener("mouseleave",(()=>{const e=i.querySelector('[role="option"][aria-selected="true"]');l(e?s.indexOf(e):-1)})),t.addEventListener("keydown",E),o&&o.addEventListener("keydown",E);t.addEventListener("click",(()=>{"true"===t.getAttribute("aria-expanded")?p():(()=>{document.dispatchEvent(new CustomEvent("basecoat:popover",{detail:{source:e}})),o&&(u()?n.addEventListener("transitionend",(()=>{o.focus()}),{once:!0}):o.focus()),n.setAttribute("aria-hidden","false"),t.setAttribute("aria-expanded","true");const a=i.querySelector('[role="option"][aria-selected="true"]');a&&(l(s.indexOf(a)),a.scrollIntoView({block:"nearest"}))})()})),i.addEventListener("click",(e=>{const t=e.target.closest('[role="option"]');t&&b(t)})),document.addEventListener("click",(t=>{e.contains(t.target)||p(!1)})),document.addEventListener("basecoat:popover",(t=>{t.detail.source!==e&&p(!1)})),n.setAttribute("aria-hidden","true"),e.selectByValue=t=>{const a=s.find((e=>e.dataset.value===t));if(a){v(a);const t=new CustomEvent("change",{detail:{value:a.dataset.value},bubbles:!0});e.dispatchEvent(t)}},e.dataset.selectInitialized=!0,e.dispatchEvent(new CustomEvent("basecoat:initialized"))};document.querySelectorAll("div.select:not([data-select-initialized])").forEach(e);new MutationObserver((t=>{t.forEach((t=>{t.addedNodes.forEach((t=>{t.nodeType===Node.ELEMENT_NODE&&(t.matches("div.select:not([data-select-initialized])")&&e(t),t.querySelectorAll("div.select:not([data-select-initialized])").forEach(e))}))}))})).observe(document.body,{childList:!0,subtree:!0})})();
|
package/dist/js/sidebar.js
CHANGED
|
@@ -95,6 +95,7 @@
|
|
|
95
95
|
updateState();
|
|
96
96
|
updateCurrentPageLinks();
|
|
97
97
|
sidebarComponent.dataset.sidebarInitialized = true;
|
|
98
|
+
sidebarComponent.dispatchEvent(new CustomEvent('basecoat:initialized'));
|
|
98
99
|
};
|
|
99
100
|
|
|
100
101
|
document.querySelectorAll('.sidebar:not([data-sidebar-initialized])').forEach(initSidebar);
|
package/dist/js/sidebar.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{if(!window.history.__basecoatPatched){const e=window.history.pushState;window.history.pushState=function(...t){e.apply(this,t),window.dispatchEvent(new Event("basecoat:locationchange"))};const t=window.history.replaceState;window.history.replaceState=function(...e){t.apply(this,e),window.dispatchEvent(new Event("basecoat:locationchange"))},window.history.__basecoatPatched=!0}const e=e=>{const t="false"!==e.dataset.initialOpen,a="true"===e.dataset.initialMobileOpen,i=parseInt(e.dataset.breakpoint)||768;let n=i>0?window.innerWidth>=i?t:a:t;const o=()=>{const t=window.location.pathname.replace(/\/$/,"");e.querySelectorAll("a").forEach((e=>{if(e.hasAttribute("data-ignore-current"))return;new URL(e.href).pathname.replace(/\/$/,"")===t?e.setAttribute("aria-current","page"):e.removeAttribute("aria-current")}))},
|
|
1
|
+
(()=>{if(!window.history.__basecoatPatched){const e=window.history.pushState;window.history.pushState=function(...t){e.apply(this,t),window.dispatchEvent(new Event("basecoat:locationchange"))};const t=window.history.replaceState;window.history.replaceState=function(...e){t.apply(this,e),window.dispatchEvent(new Event("basecoat:locationchange"))},window.history.__basecoatPatched=!0}const e=e=>{const t="false"!==e.dataset.initialOpen,a="true"===e.dataset.initialMobileOpen,i=parseInt(e.dataset.breakpoint)||768;let n=i>0?window.innerWidth>=i?t:a:t;const o=()=>{const t=window.location.pathname.replace(/\/$/,"");e.querySelectorAll("a").forEach((e=>{if(e.hasAttribute("data-ignore-current"))return;new URL(e.href).pathname.replace(/\/$/,"")===t?e.setAttribute("aria-current","page"):e.removeAttribute("aria-current")}))},d=()=>{e.setAttribute("aria-hidden",!n),n?e.removeAttribute("inert"):e.setAttribute("inert","")},r=e=>{n=e,d()},c=e.id;document.addEventListener("basecoat:sidebar",(e=>{if(!e.detail?.id||e.detail.id===c)switch(e.detail?.action){case"open":r(!0);break;case"close":r(!1);break;default:r(!n)}})),e.addEventListener("click",(t=>{const a=t.target,n=e.querySelector("nav");if(window.innerWidth<i&&a.closest("a, button")&&!a.closest("[data-keep-mobile-sidebar-open]"))return document.activeElement&&document.activeElement.blur(),void r(!1);(a===e||n&&!n.contains(a))&&(document.activeElement&&document.activeElement.blur(),r(!1))})),window.addEventListener("popstate",o),window.addEventListener("basecoat:locationchange",o),d(),o(),e.dataset.sidebarInitialized=!0,e.dispatchEvent(new CustomEvent("basecoat:initialized"))};document.querySelectorAll(".sidebar:not([data-sidebar-initialized])").forEach(e);new MutationObserver((t=>{t.forEach((t=>{t.addedNodes.forEach((t=>{t.nodeType===Node.ELEMENT_NODE&&(t.matches(".sidebar:not([data-sidebar-initialized])")&&e(t),t.querySelectorAll(".sidebar:not([data-sidebar-initialized])").forEach(e))}))}))})).observe(document.body,{childList:!0,subtree:!0})})();
|
package/dist/js/tabs.js
CHANGED
package/dist/js/tabs.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{const e=e=>{const t=e.querySelector('[role="tablist"]');if(!t)return;const a=Array.from(t.querySelectorAll('[role="tab"]')),r=a.map((e=>document.getElementById(e.getAttribute("aria-controls")))).filter(Boolean),n=e=>{a.forEach(((e,t)=>{e.setAttribute("aria-selected","false"),e.setAttribute("tabindex","-1"),r[t]&&(r[t].hidden=!0)})),e.setAttribute("aria-selected","true"),e.setAttribute("tabindex","0");const t=document.getElementById(e.getAttribute("aria-controls"));t&&(t.hidden=!1)};t.addEventListener("click",(e=>{const t=e.target.closest('[role="tab"]');t&&n(t)})),t.addEventListener("keydown",(e=>{const t=e.target;if(!a.includes(t))return;let r;const
|
|
1
|
+
(()=>{const e=e=>{const t=e.querySelector('[role="tablist"]');if(!t)return;const a=Array.from(t.querySelectorAll('[role="tab"]')),r=a.map((e=>document.getElementById(e.getAttribute("aria-controls")))).filter(Boolean),n=e=>{a.forEach(((e,t)=>{e.setAttribute("aria-selected","false"),e.setAttribute("tabindex","-1"),r[t]&&(r[t].hidden=!0)})),e.setAttribute("aria-selected","true"),e.setAttribute("tabindex","0");const t=document.getElementById(e.getAttribute("aria-controls"));t&&(t.hidden=!1)};t.addEventListener("click",(e=>{const t=e.target.closest('[role="tab"]');t&&n(t)})),t.addEventListener("keydown",(e=>{const t=e.target;if(!a.includes(t))return;let r;const i=a.indexOf(t);switch(e.key){case"ArrowRight":r=a[(i+1)%a.length];break;case"ArrowLeft":r=a[(i-1+a.length)%a.length];break;case"Home":r=a[0];break;case"End":r=a[a.length-1];break;default:return}e.preventDefault(),n(r),r.focus()})),e.dataset.tabsInitialized=!0,e.dispatchEvent(new CustomEvent("basecoat:initialized"))};document.querySelectorAll(".tabs:not([data-tabs-initialized])").forEach(e);new MutationObserver((t=>{t.forEach((t=>{t.addedNodes.forEach((t=>{t.nodeType===Node.ELEMENT_NODE&&(t.matches(".tabs:not([data-tabs-initialized])")&&e(t),t.querySelectorAll(".tabs:not([data-tabs-initialized])").forEach(e))}))}))})).observe(document.body,{childList:!0,subtree:!0})})();
|
package/dist/js/toast.js
CHANGED
package/dist/js/toast.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{let t;const e=new WeakMap;let n=!1;const o={success:'<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>',error:'<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>',info:'<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>',warning:'<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>'};function i(e){e.dataset.toasterInitialized||(t=e,t.addEventListener("mouseenter",r),t.addEventListener("mouseleave",s),t.addEventListener("click",(t=>{const e=t.target.closest(".toast footer a"),n=t.target.closest(".toast footer button");(e||n)&&d(t.target.closest(".toast"))})),t.querySelectorAll(".toast:not([data-toast-initialized])").forEach(a),t.dataset.toasterInitialized="true")}function a(t){if(t.dataset.toastInitialized)return;const o=parseInt(t.dataset.duration),i=-1!==o?o||("error"===t.dataset.category?5e3:3e3):-1,a={remainingTime:i,timeoutId:null,startTime:null};-1!==i&&(n?a.timeoutId=null:(a.startTime=Date.now(),a.timeoutId=setTimeout((()=>d(t)),i))),e.set(t,a),t.dataset.toastInitialized="true"}function r(){n||(n=!0,t.querySelectorAll('.toast:not([aria-hidden="true"])').forEach((t=>{if(!e.has(t))return;const n=e.get(t);n.timeoutId&&(clearTimeout(n.timeoutId),n.timeoutId=null,n.remainingTime-=Date.now()-n.startTime)})))}function s(){n&&(n=!1,t.querySelectorAll('.toast:not([aria-hidden="true"])').forEach((t=>{if(!e.has(t))return;const n=e.get(t);-1===n.remainingTime||n.timeoutId||(n.remainingTime>0?(n.startTime=Date.now(),n.timeoutId=setTimeout((()=>d(t)),n.remainingTime)):d(t))})))}function d(t){if(!e.has(t))return;const n=e.get(t);clearTimeout(n.timeoutId),e.delete(t),document.activeElement&&document.activeElement.blur(),t.setAttribute("aria-hidden","true"),t.addEventListener("transitionend",(()=>t.remove()),{once:!0})}const c=document.getElementById("toaster");c&&i(c),document.addEventListener("basecoat:toast",(e=>{if(!t)return void console.error("Cannot create toast: toaster container not found on page.");const n=function(t){const{category:e="info",title:n,description:i,action:a,cancel:r,duration:s,icon:d}=t,c=d||e&&o[e]||"",l=n?`<h2>${n}</h2>`:"",u=i?`<p>${i}</p>`:"",h=a?.href?`<a href="${a.href}" class="btn" data-toast-action>${a.label}</a>`:a?.onclick?`<button type="button" class="btn" data-toast-action onclick="${a.onclick}">${a.label}</button>`:"",m=r?`<button type="button" class="btn-outline h-6 text-xs px-2.5 rounded-sm" data-toast-cancel onclick="${r?.onclick}">${r.label}</button>`:"",g=`\n <div\n class="toast"\n role="${"error"===e?"alert":"status"}"\n aria-atomic="true"\n ${e?`data-category="${e}"`:""}\n ${void 0!==s?`data-duration="${s}"`:""}\n >\n <div class="toast-content">\n ${c}\n <section>\n ${l}\n ${u}\n </section>\n ${h||m?`<footer>${h}${m}</footer>`:""}\n </div>\n </div>\n </div>\n `,v=document.createElement("template");return v.innerHTML=g.trim(),v.content.firstChild}(e.detail?.config||{});t.appendChild(n)}));new MutationObserver((e=>{e.forEach((e=>{e.addedNodes.forEach((e=>{e.nodeType===Node.ELEMENT_NODE&&(e.matches("#toaster")&&i(e),t&&e.matches(".toast:not([data-toast-initialized])")&&a(e))}))}))})).observe(document.body,{childList:!0,subtree:!0})})();
|
|
1
|
+
(()=>{let t;const e=new WeakMap;let n=!1;const o={success:'<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>',error:'<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>',info:'<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>',warning:'<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>'};function i(e){e.dataset.toasterInitialized||(t=e,t.addEventListener("mouseenter",r),t.addEventListener("mouseleave",s),t.addEventListener("click",(t=>{const e=t.target.closest(".toast footer a"),n=t.target.closest(".toast footer button");(e||n)&&d(t.target.closest(".toast"))})),t.querySelectorAll(".toast:not([data-toast-initialized])").forEach(a),t.dataset.toasterInitialized="true",t.dispatchEvent(new CustomEvent("basecoat:initialized")))}function a(t){if(t.dataset.toastInitialized)return;const o=parseInt(t.dataset.duration),i=-1!==o?o||("error"===t.dataset.category?5e3:3e3):-1,a={remainingTime:i,timeoutId:null,startTime:null};-1!==i&&(n?a.timeoutId=null:(a.startTime=Date.now(),a.timeoutId=setTimeout((()=>d(t)),i))),e.set(t,a),t.dataset.toastInitialized="true"}function r(){n||(n=!0,t.querySelectorAll('.toast:not([aria-hidden="true"])').forEach((t=>{if(!e.has(t))return;const n=e.get(t);n.timeoutId&&(clearTimeout(n.timeoutId),n.timeoutId=null,n.remainingTime-=Date.now()-n.startTime)})))}function s(){n&&(n=!1,t.querySelectorAll('.toast:not([aria-hidden="true"])').forEach((t=>{if(!e.has(t))return;const n=e.get(t);-1===n.remainingTime||n.timeoutId||(n.remainingTime>0?(n.startTime=Date.now(),n.timeoutId=setTimeout((()=>d(t)),n.remainingTime)):d(t))})))}function d(t){if(!e.has(t))return;const n=e.get(t);clearTimeout(n.timeoutId),e.delete(t),document.activeElement&&document.activeElement.blur(),t.setAttribute("aria-hidden","true"),t.addEventListener("transitionend",(()=>t.remove()),{once:!0})}const c=document.getElementById("toaster");c&&i(c),document.addEventListener("basecoat:toast",(e=>{if(!t)return void console.error("Cannot create toast: toaster container not found on page.");const n=function(t){const{category:e="info",title:n,description:i,action:a,cancel:r,duration:s,icon:d}=t,c=d||e&&o[e]||"",l=n?`<h2>${n}</h2>`:"",u=i?`<p>${i}</p>`:"",h=a?.href?`<a href="${a.href}" class="btn" data-toast-action>${a.label}</a>`:a?.onclick?`<button type="button" class="btn" data-toast-action onclick="${a.onclick}">${a.label}</button>`:"",m=r?`<button type="button" class="btn-outline h-6 text-xs px-2.5 rounded-sm" data-toast-cancel onclick="${r?.onclick}">${r.label}</button>`:"",g=`\n <div\n class="toast"\n role="${"error"===e?"alert":"status"}"\n aria-atomic="true"\n ${e?`data-category="${e}"`:""}\n ${void 0!==s?`data-duration="${s}"`:""}\n >\n <div class="toast-content">\n ${c}\n <section>\n ${l}\n ${u}\n </section>\n ${h||m?`<footer>${h}${m}</footer>`:""}\n </div>\n </div>\n </div>\n `,v=document.createElement("template");return v.innerHTML=g.trim(),v.content.firstChild}(e.detail?.config||{});t.appendChild(n)}));new MutationObserver((e=>{e.forEach((e=>{e.addedNodes.forEach((e=>{e.nodeType===Node.ELEMENT_NODE&&(e.matches("#toaster")&&i(e),t&&e.matches(".toast:not([data-toast-initialized])")&&a(e))}))}))})).observe(document.body,{childList:!0,subtree:!0})})();
|