wulf.js 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +217 -11
- package/changelog.md +50 -0
- package/dist/anchor.esm.js +9 -0
- package/dist/anchor.esm.js.map +7 -0
- package/dist/anchor.global.js +695 -0
- package/dist/anchor.global.js.map +7 -0
- package/dist/anchor.global.min.js +6 -0
- package/dist/anchor.global.min.js.map +7 -0
- package/dist/autosize.css +1 -0
- package/dist/autosize.css.map +7 -0
- package/dist/autosize.esm.js +10 -0
- package/dist/autosize.esm.js.map +7 -0
- package/dist/autosize.global.js +657 -0
- package/dist/autosize.global.js.map +7 -0
- package/dist/autosize.global.min.js +6 -0
- package/dist/autosize.global.min.js.map +7 -0
- package/dist/autosize.layered.css +1 -0
- package/dist/autosize.layered.css.map +7 -0
- package/dist/chunks/chunk-22AIMRD5.js +119 -0
- package/dist/chunks/chunk-22AIMRD5.js.map +7 -0
- package/dist/chunks/chunk-5N2IRGDM.js +766 -0
- package/dist/chunks/chunk-5N2IRGDM.js.map +7 -0
- package/dist/chunks/chunk-72FVCNNZ.js +863 -0
- package/dist/chunks/chunk-72FVCNNZ.js.map +7 -0
- package/dist/chunks/chunk-AXZYYW7H.js +865 -0
- package/dist/chunks/chunk-AXZYYW7H.js.map +7 -0
- package/dist/chunks/chunk-CM3SBIVQ.js +1116 -0
- package/dist/chunks/chunk-CM3SBIVQ.js.map +7 -0
- package/dist/chunks/chunk-H4GRLGQ3.js +578 -0
- package/dist/chunks/chunk-H4GRLGQ3.js.map +7 -0
- package/dist/chunks/chunk-ITRU2RFV.js +1195 -0
- package/dist/chunks/chunk-ITRU2RFV.js.map +7 -0
- package/dist/chunks/chunk-NLUQZEL4.js +1029 -0
- package/dist/chunks/chunk-NLUQZEL4.js.map +7 -0
- package/dist/chunks/chunk-QV46A7FV.js +197 -0
- package/dist/chunks/chunk-QV46A7FV.js.map +7 -0
- package/dist/chunks/chunk-SXLUXN6W.js +612 -0
- package/dist/chunks/chunk-SXLUXN6W.js.map +7 -0
- package/dist/chunks/chunk-T2H4EJCW.js +621 -0
- package/dist/chunks/chunk-T2H4EJCW.js.map +7 -0
- package/dist/chunks/chunk-TILLYEF2.js +6044 -0
- package/dist/chunks/chunk-TILLYEF2.js.map +7 -0
- package/dist/chunks/chunk-VJO22BAT.js +72 -0
- package/dist/chunks/chunk-VJO22BAT.js.map +7 -0
- package/dist/chunks/chunk-ZGUU6DMM.js +77 -0
- package/dist/chunks/chunk-ZGUU6DMM.js.map +7 -0
- package/dist/focus-trap.esm.js +6 -594
- package/dist/focus-trap.esm.js.map +3 -3
- package/dist/focus-trap.global.js +176 -61
- package/dist/focus-trap.global.js.map +3 -3
- package/dist/focus-trap.global.min.js +4 -4
- package/dist/focus-trap.global.min.js.map +4 -4
- package/dist/index.esm.js +79 -10448
- package/dist/index.esm.js.map +4 -4
- package/dist/index.global.js +3660 -202
- package/dist/index.global.js.map +4 -4
- package/dist/index.global.min.js +6 -3
- package/dist/index.global.min.js.map +4 -4
- package/dist/mask.esm.js +16 -6094
- package/dist/mask.esm.js.map +4 -4
- package/dist/mask.global.js +44 -55
- package/dist/mask.global.js.map +3 -3
- package/dist/mask.global.min.js +3 -3
- package/dist/mask.global.min.js.map +4 -4
- package/dist/masonry.esm.js +15 -1158
- package/dist/masonry.esm.js.map +4 -4
- package/dist/masonry.global.js +84 -94
- package/dist/masonry.global.js.map +3 -3
- package/dist/masonry.global.min.js +4 -4
- package/dist/masonry.global.min.js.map +4 -4
- package/dist/scroll.css +1 -1
- package/dist/scroll.css.map +2 -2
- package/dist/scroll.esm.js +14 -1252
- package/dist/scroll.esm.js.map +3 -3
- package/dist/scroll.global.js +64 -58
- package/dist/scroll.global.js.map +3 -3
- package/dist/scroll.global.min.js +3 -3
- package/dist/scroll.global.min.js.map +4 -4
- package/dist/scroll.layered.css +1 -1
- package/dist/scroll.layered.css.map +2 -2
- package/dist/shortcut.esm.js +6 -901
- package/dist/shortcut.esm.js.map +4 -4
- package/dist/shortcut.global.js +43 -36
- package/dist/shortcut.global.js.map +3 -3
- package/dist/shortcut.global.min.js +6 -3
- package/dist/shortcut.global.min.js.map +4 -4
- package/dist/size-report.json +319 -0
- package/dist/sortable.css +1 -0
- package/dist/sortable.css.map +7 -0
- package/dist/sortable.esm.js +22 -0
- package/dist/sortable.esm.js.map +7 -0
- package/dist/sortable.global.js +1477 -0
- package/dist/sortable.global.js.map +7 -0
- package/dist/sortable.global.min.js +6 -0
- package/dist/sortable.global.min.js.map +7 -0
- package/dist/sortable.layered.css +1 -0
- package/dist/sortable.layered.css.map +7 -0
- package/dist/sri-manifest.json +64 -0
- package/dist/toast.css +1 -1
- package/dist/toast.css.map +2 -2
- package/dist/toast.esm.js +19 -1208
- package/dist/toast.esm.js.map +3 -3
- package/dist/toast.global.js +314 -111
- package/dist/toast.global.js.map +3 -3
- package/dist/toast.global.min.js +3 -3
- package/dist/toast.global.min.js.map +4 -4
- package/dist/toast.layered.css +1 -1
- package/dist/toast.layered.css.map +2 -2
- package/dist/types/anchor/Anchor.d.ts +41 -0
- package/dist/types/anchor/index.d.ts +3 -0
- package/dist/types/anchor/types.d.ts +115 -0
- package/dist/types/autosize/Autosize.d.ts +71 -0
- package/dist/types/autosize/index.d.ts +3 -0
- package/dist/types/autosize/types.d.ts +66 -0
- package/dist/types/common/AuditableComponent.d.ts +1 -1
- package/dist/types/common/registry.d.ts +40 -0
- package/dist/types/focus-trap/FocusTrap.d.ts +3 -1
- package/dist/types/index.d.ts +13 -1
- package/dist/types/scroll/types.d.ts +6 -0
- package/dist/types/shortcut/ShortcutManager.d.ts +2 -0
- package/dist/types/shortcut/types.d.ts +5 -0
- package/dist/types/sortable/Sortable.d.ts +75 -0
- package/dist/types/sortable/i18n/en.d.ts +2 -0
- package/dist/types/sortable/i18n/fr.d.ts +2 -0
- package/dist/types/sortable/i18n/index.d.ts +9 -0
- package/dist/types/sortable/i18n/types.d.ts +15 -0
- package/dist/types/sortable/index.d.ts +4 -0
- package/dist/types/sortable/types.d.ts +112 -0
- package/dist/types/toast/Toast.d.ts +6 -1
- package/dist/types/toast/ToastInstance.d.ts +7 -0
- package/dist/types/toast/ToastManager.d.ts +2 -2
- package/dist/types/toast/types.d.ts +27 -1
- package/dist/types/undo/UndoManager.d.ts +112 -0
- package/dist/types/undo/i18n/en.d.ts +2 -0
- package/dist/types/undo/i18n/fr.d.ts +2 -0
- package/dist/types/undo/i18n/index.d.ts +9 -0
- package/dist/types/undo/i18n/types.d.ts +6 -0
- package/dist/types/undo/index.d.ts +5 -0
- package/dist/types/undo/types.d.ts +106 -0
- package/dist/undo.esm.js +23 -0
- package/dist/undo.esm.js.map +7 -0
- package/dist/undo.global.js +1029 -0
- package/dist/undo.global.js.map +7 -0
- package/dist/undo.global.min.js +6 -0
- package/dist/undo.global.min.js.map +7 -0
- package/package.json +54 -5
package/dist/toast.global.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var __WulfIIFE=(()=>{var
|
|
1
|
+
"use strict";var __WulfIIFE=(()=>{var L=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var Q=(a,e)=>{for(var t in e)L(a,t,{get:e[t],enumerable:!0})},X=(a,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Z(e))!J.call(a,i)&&i!==t&&L(a,i,{get:()=>e[i],enumerable:!(s=q(e,i))||s.enumerable});return a};var ee=a=>X(L({},"__esModule",{value:!0}),a);var le={};Q(le,{LocalizedComponent:()=>v,Toast:()=>P,ToastInstance:()=>A,ToastManager:()=>T,createI18nManager:()=>M,default:()=>ae,isSafeCssValue:()=>C,toastEn:()=>S,toastFr:()=>k,toastI18n:()=>m});var te=new Set(["__proto__","constructor","prototype"]);function w(a){return!!a&&!te.has(a)}function E(a){let e=String(a??"").trim().toLowerCase().replace(/_/g,"-");return w(e)?e:""}function ie(a){let e=a.indexOf("-"),t=e>0?a.slice(0,e):null;return t&&w(t)?t:null}function p(a,e){if(!e||typeof e!="object")return a;for(let t of Object.keys(e))w(String(t))&&Object.hasOwn(e,t)&&e[t]!==void 0&&(a[t]=e[t]);return a}function M(a,e){let t=E(a)||"fr",s=Object.create(null);for(let[r,l]of Object.entries(e)){let u=E(r);u&&(s[u]=p(Object.create(null),l))}let i=t,n=Object.create(null);for(let[r,l]of Object.entries(s))n[r]=p(Object.create(null),l);let o=Object.create(null);function c(){let r=[];if(w(i)){let u=n[i];u&&r.push(u)}let l=ie(i);return l&&n[l]&&r.push(n[l]),r}return{setLocale(r){if(r&&typeof r=="string"&&r.trim()){let l=E(r);l&&(i=l)}},getLocale(){return i},registerLocale(r,l){if(!r||typeof r!="string"||!r.trim()||!l)return;let u=E(r);if(!u)return;let d=p(Object.create(null),n[u]);n[u]=p(d,l)},setI18n(r){if(!r||typeof r!="object")return;let l=p(Object.create(null),o);o=p(l,r)},t(r,l){if(!w(String(r)))return"";if(l&&typeof l=="object"&&Object.hasOwn(l,r)&&l[r]!==void 0)return String(l[r]);if(o[r]!==void 0)return String(o[r]);for(let d of c())if(d[r]!==void 0)return String(d[r]);let u=n[t]||s[t];return u&&u[r]!==void 0?String(u[r]):String(r)},getAll(r){let l={},u=n[t]||s[t];p(l,u);let d=c().reverse();for(let f of d)p(l,f);return p(l,o),p(l,r),l},reset(){i=t,o=Object.create(null),n=Object.create(null);for(let[r,l]of Object.entries(s))n[r]=p(Object.create(null),l)}}}var b=class{getAuditDisableHint(){return"Passez { audit: false } dans les options pour d\xE9sactiver cet avertissement"}runAuditWarning(e=!0){if(!e)return[];let t=this.audit();return t.length>0&&typeof console<"u"&&typeof console.warn=="function"&&console.warn(`[${this.getAuditPrefix()}] Audit d'accessibilit\xE9 \u2014 ${t.length} contrainte(s) manquante(s) sur ${this.getAuditTargetLabel()} :
|
|
2
2
|
`+t.map(s=>` - ${s}`).join(`
|
|
3
3
|
`)+`
|
|
4
|
-
(${this.getAuditDisableHint()})`),t}checkAriaIdReferences(e,t,s,n=!1){let i=e.getAttribute(t)?.trim();if(!i)return!1;let a=e.ownerDocument||document,c=typeof e.getRootNode=="function"?e.getRootNode():a,o=i.split(/\s+/).filter(Boolean),l=o.map(d=>typeof ShadowRoot<"u"&&c instanceof ShadowRoot?c.getElementById(d):a.getElementById(d));return o.length>0&&l.every(d=>!!d)?n&&!l.some(f=>f?(f.textContent?.trim()||f.getAttribute("aria-label")?.trim()||"").length>0:!1)?(s.push(`Attribut ${t}="${i}" invalide : l'\xE9l\xE9ment cible ne contient aucun texte accessible.`),!1):!0:(s.push(`Attribut ${t}="${i}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`),!1)}};var y=class extends v{static _i18n;static setLocale(e){this._i18n&&this._i18n.setLocale(e)}static getLocale(){return this._i18n?this._i18n.getLocale():""}static registerLocale(e,t){this._i18n&&this._i18n.registerLocale(e,t)}static setI18n(e){this._i18n&&this._i18n.setI18n(e)}static getI18n(){return this._i18n?this._i18n.getAll():{}}static resetI18n(){this._i18n&&this._i18n.reset()}static t(e,t){return this._i18n?this._i18n.t(e,t):String(e)}i18nOverrides;constructor(e){super(),this.i18nOverrides=e}t(e){let t=this.constructor;return t._i18n?t._i18n.t(e,this.i18nOverrides):String(e)}};var R={closeButton:"Fermer la notification",notificationsRegion:"Notifications"};var S={closeButton:"Close notification",notificationsRegion:"Notifications"};var m=k("fr",{fr:R,en:S});var G=1,F=5e3,U=/^(?:#[0-9a-f]{3,8}|(?:rgb|rgba|hsl|hsla|oklch|oklab|lch|lab)\([^;{}<>\\]+\)|[a-z]{3,20})$/i;function I(r){if(!r||typeof r!="string"||r.length>128)return!1;let e=r.trim();return!e||/[\u0000-\u001F\u007F;{}<>\\]|(?:url|image-set|-webkit-image-set|image|src|expression|attr|env|var)\s*\(/i.test(e)?!1:typeof CSS<"u"&&typeof CSS.supports=="function"?CSS.supports("color",e)||CSS.supports("background-color",e):U.test(e)}function Y(r){return r.slice(0,128).trim().split(/\s+/).filter(e=>/^[a-zA-Z0-9_-]+$/.test(e)&&!e.startsWith("wulf-toast")).slice(0,8).join(" ")}var A=class extends v{id;options;element;_isClosed=!1;_isFinalized=!1;closePromise=null;timerId=null;remainingTime=0;hasDuration=!1;timerStartTime=0;isPausedByHover=!1;isPausedByFocus=!1;isPausedByVisibility=!1;isPendingFocusDismiss=!1;previousActiveElement=null;eventsAbortController=new AbortController;disposeAbortController=new AbortController;onDismissCallback;constructor(e,t){super(),this.id=`wulf-toast-${G++}`,this.options=Object.freeze({...e}),this.onDismissCallback=t,this.previousActiveElement=T();let s=e.duration===void 0?F:e.duration;typeof s=="number"&&Number.isFinite(s)&&s>0?(this.remainingTime=Math.min(s,2147483647),this.hasDuration=!0):(this.remainingTime=0,this.hasDuration=!1),this.element=this.createDOM(),this.bindEvents(),this.runAuditWarning(e.audit!==!1)}get isClosed(){return this._isClosed}getPreviousActiveElement(){return this.previousActiveElement}audit(){let e=[],t=!!(this.options.title&&this.options.title.trim().length>0),s=!!(this.options.message&&this.options.message.trim().length>0);!t&&!s&&e.push("Contenu textuel vide : d\xE9finissez au moins un title ou un message pour que le lecteur d'\xE9cran puisse annoncer la notification (WCAG 4.1.3).");let n=this.options.duration===void 0?F:this.options.duration;typeof n=="number"&&n>0&&n<5e3&&e.push(`Dur\xE9e d'affichage trop courte (duration: ${n}ms) : pr\xE9voyez au moins 5000ms ou duration: false pour laisser le temps de lecture aux utilisateurs (WCAG 2.2.1).`);let i=this.options.closable??!0;return(n===!1||typeof n=="number"&&n<=0)&&!i&&e.push("Notification persistante impossible \xE0 fermer au clavier : activez closable: true lorsque duration est d\xE9sactiv\xE9 (WCAG 2.1.1)."),e}getAuditPrefix(){return"Wulf.Toast"}getAuditTargetLabel(){return`#${this.id}`}createDOM(){let e=document.createElement("div");if(e.id=this.id,e.className="wulf-toast",e.setAttribute("data-toast-role",this.options.role==="alert"?"alert":"status"),this.options.backgroundColor&&I(this.options.backgroundColor)&&e.style.setProperty("--wulf-toast-bg",this.options.backgroundColor.trim()),this.options.titleColor&&I(this.options.titleColor)&&e.style.setProperty("--wulf-toast-title-color",this.options.titleColor.trim()),this.options.textColor&&I(this.options.textColor)&&e.style.setProperty("--wulf-toast-text-color",this.options.textColor.trim()),this.options.iconColor&&I(this.options.iconColor)&&e.style.setProperty("--wulf-toast-icon-color",this.options.iconColor.trim()),this.options.closeButtonColor&&I(this.options.closeButtonColor)&&e.style.setProperty("--wulf-toast-close-color",this.options.closeButtonColor.trim()),this.options.icon&&typeof this.options.icon=="string"&&this.options.icon.trim()!==""){let i=Y(this.options.icon);if(i){let a=document.createElement("span");a.className=`wulf-toast-icon ${i}`,a.setAttribute("aria-hidden","true"),e.appendChild(a)}}let t=document.createElement("div"),s=!!(this.options.onClick||this.options.closeOnClick);if(t.className=s?"wulf-toast-content wulf-toast-content--interactive":"wulf-toast-content",s&&(t.setAttribute("role","button"),t.setAttribute("tabindex","0"),t.addEventListener("keydown",i=>{L(i)||(i.key==="Enter"?(i.preventDefault(),i.stopPropagation(),t.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0}))):i.key===" "&&(i.preventDefault(),i.stopPropagation()))},{signal:this.eventsAbortController.signal}),t.addEventListener("keyup",i=>{i.key===" "&&(i.preventDefault(),i.stopPropagation(),t.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0})))},{signal:this.eventsAbortController.signal})),this.options.title&&this.options.title.trim()!==""){let i=document.createElement("div");i.className="wulf-toast-title",this.appendTextWithLineBreaks(i,this.options.title),t.appendChild(i)}if(this.options.message&&this.options.message.trim()!==""){let i=document.createElement("div");i.className="wulf-toast-message",this.appendTextWithLineBreaks(i,this.options.message),t.appendChild(i)}if(e.appendChild(t),this.options.closable??!0){let i=document.createElement("button");i.type="button",i.className="wulf-toast-close",i.setAttribute("aria-label",m.t("closeButton",this.options.i18n));let a=document.createElement("span");a.className="wulf-toast-close-icon",a.setAttribute("aria-hidden","true"),a.textContent="\xD7",i.appendChild(a),i.addEventListener("click",c=>{c.stopPropagation(),this.close("close-button")},{signal:this.eventsAbortController.signal}),e.appendChild(i)}if(this.options.progressBar&&this.remainingTime>0){e.style.setProperty("--wulf-toast-duration",`${this.remainingTime}ms`);let i=document.createElement("div");i.className="wulf-toast-progress",i.setAttribute("aria-hidden","true"),e.appendChild(i)}return e}appendTextWithLineBreaks(e,t){w(String(t??""),4096).split(/\r\n|\r|\n/).slice(0,100).forEach((i,a)=>{a>0&&e.appendChild(document.createElement("br")),e.appendChild(document.createTextNode(i))})}bindEvents(){let{signal:e}=this.eventsAbortController;this.element.addEventListener("click",t=>{if(this.options.onClick)try{this.options.onClick(this,t)}catch(s){console.error("[Wulf.Toast] Erreur dans le callback onClick:",s)}this.options.closeOnClick&&this.close("toast-click")},{signal:e}),this.element.addEventListener("mouseenter",()=>this.pauseTimer("hover"),{signal:e}),this.element.addEventListener("mouseleave",()=>this.resumeTimer("hover"),{signal:e}),this.element.addEventListener("focusin",()=>this.pauseTimer("focus"),{signal:e}),this.element.addEventListener("focusout",t=>{let s=t.relatedTarget;if(!(s&&this.element.contains(s))){if(this.isPendingFocusDismiss&&!this._isClosed){this.isPendingFocusDismiss=!1,this.close("timeout");return}this.resumeTimer("focus")}},{signal:e}),this.element.addEventListener("keydown",t=>{if(t.key==="Escape"&&(this.options.closable??!0)){if(L(t))return;t.stopPropagation(),this.close("close-button")}},{signal:e}),typeof document<"u"&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.pauseTimer("visibility"):this.resumeTimer("visibility")},{signal:e})}get isPaused(){return this.isPausedByHover||this.isPausedByFocus||this.isPausedByVisibility}startTimer(){if(!(this._isClosed||this.remainingTime<=0||this.isPaused)){if(typeof document<"u"&&document.visibilityState==="hidden"){this.isPausedByVisibility=!0,this.element.classList.add("is-paused");return}this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),this.timerStartTime=performance.now(),this.timerId=window.setTimeout(()=>{this.timerId=null;let e=T();if(e&&this.element.contains(e)){this.isPendingFocusDismiss=!0;return}this.close("timeout")},this.remainingTime)}}pauseTimer(e="interaction"){if(this._isClosed||!this.hasDuration||this.remainingTime<=0)return;let t=this.isPaused;if(e==="visibility"?this.isPausedByVisibility=!0:e==="focus"?this.isPausedByFocus=!0:this.isPausedByHover=!0,!t){if(this.timerId!==null){window.clearTimeout(this.timerId),this.timerId=null;let s=performance.now()-this.timerStartTime;this.remainingTime=Math.max(0,this.remainingTime-s)}this.element.classList.add("is-paused")}}resumeTimer(e="interaction"){if(!(this._isClosed||!this.hasDuration)){if(e==="visibility")this.isPausedByVisibility=!1;else if(e==="focus")this.isPausedByFocus=!1;else if(e==="hover"){this.isPausedByHover=!1;let t=T();t&&this.element.contains(t)&&(this.isPausedByFocus=!0)}else this.isPausedByHover=!1,this.isPausedByFocus=!1;if(!this.isPaused){if(this.element.classList.remove("is-paused"),this.remainingTime<=0){this.close("timeout");return}this.startTimer()}}}finalizeDismiss(e){if(!this._isFinalized&&(this._isFinalized=!0,this.eventsAbortController.abort(),this.onDismissCallback&&this.onDismissCallback(this,e),this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.options.onClose))try{this.options.onClose(this,e)}catch(t){console.error("[Wulf.Toast] Erreur dans le callback onClose:",t)}}destroyImmediate(e="replace"){this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),this.disposeAbortController.abort(),this.finalizeDismiss(e)}close(e="programmatic",t=!1){return this._isClosed?this.closePromise??Promise.resolve():(this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),this.eventsAbortController.abort(),this.element.classList.add(t?"wulf-toast-hiding-fast":"wulf-toast-hiding"),M()?(this.finalizeDismiss(e),this.closePromise=Promise.resolve(),this.closePromise):(this.closePromise=B(this.element,t?90:300,this.disposeAbortController.signal).then(()=>{this.disposeAbortController.signal.aborted||this.finalizeDismiss(e)}),this.closePromise))}};var Z=new Set(["top-left","top-center","top-right","bottom-left","bottom-center","bottom-right"]);function _(r){return r&&Z.has(r)?r:"top-right"}var J='button:not([disabled]), [href], [tabindex]:not([tabindex="-1"])',g=class r{static instance=null;containers=new Map;containerBaseLabels=new WeakMap;activeToasts=new Map;announcerEl=null;politeRegion=null;assertiveRegion=null;announceTimers=[];politeAnnounceTimerId=null;assertiveAnnounceTimerId=null;politeClearTimerId=null;assertiveClearTimerId=null;lastPoliteText="";lastAssertiveText="";announcerToggle=!1;isPopoverOpen(e){try{if(e.matches(":popover-open"))return!0}catch{}return e.classList.contains(":popover-open")}replaceTokens=new Map;pendingReplacements=new Set;constructor(){}static getInstance(){return r.instance||(r.instance=new r),r.instance}add(e){let t=_(e.options.position),s=this.activeToasts.get(t);s||(s=[],this.activeToasts.set(t,s));let n=e.options.maxToasts,i=typeof n=="number"&&Number.isFinite(n)&&n>0?Math.min(50,Math.max(1,Math.floor(n))):5;if(e.options.replace&&s.length>0){let a=[...s],c=(this.replaceTokens.get(t)||0)+1;this.replaceTokens.set(t,c),this.pendingReplacements.add(t);let o=a.map(l=>l.close("replace",!0));Promise.all(o).then(()=>{if(this.pendingReplacements.delete(t),this.replaceTokens.get(t)!==c){e.destroyImmediate("replace");return}this.mountToast(e,t,i)});return}if(this.pendingReplacements.has(t)&&(this.replaceTokens.set(t,(this.replaceTokens.get(t)||0)+1),this.pendingReplacements.delete(t)),s.length>=i){let a=s.length-i+1,c=s.splice(0,a);for(let o of c)o.close("max-limit",!0)}this.mountToast(e,t,i)}mountToast(e,t,s=5){if(e.isClosed)return;let n=e.options.useTopLayer??!0,i=this.getOrCreateContainer(t,e,n),a=this.activeToasts.get(t);a||(a=[],this.activeToasts.set(t,a));let c=s+10;if(i.children.length>=c){let o=Array.from(i.children);for(let l of o){if(i.children.length<c)break;(l.classList.contains("wulf-toast-hiding")||l.classList.contains("wulf-toast-hiding-fast"))&&l.remove()}}if(n&&typeof i.showPopover=="function"&&i.getAttribute("popover")==="manual")try{let o=i;this.isPopoverOpen(i)||o.showPopover()}catch{i.removeAttribute("popover")}if(i.appendChild(e.element),a.push(e),this.announce(e),e.options.onOpen)try{e.options.onOpen(e)}catch(o){console.error("[Wulf.Toast] Erreur dans le callback onOpen:",o)}e.startTimer()}announce(e){let t=[e.options.title,e.options.message].filter(h=>typeof h=="string"&&h.trim().length>0).map(h=>w(h,512).trim()).filter(Boolean);if(t.length===0)return;let s=t.join(". "),n=s.length>512?`${s.slice(0,509)}...`:s,i=e.options.role==="alert",a=document;if(typeof a.ariaNotify=="function")try{a.ariaNotify(n,{priority:i?"high":"normal"});return}catch{}let c=!this.announcerEl||!this.announcerEl.isConnected;this.ensureAnnouncer();let o=i?this.assertiveRegion:this.politeRegion;if(!o)return;i?(this.assertiveAnnounceTimerId!==null&&(window.clearTimeout(this.assertiveAnnounceTimerId),this.assertiveAnnounceTimerId=null),this.assertiveClearTimerId!==null&&(window.clearTimeout(this.assertiveClearTimerId),this.assertiveClearTimerId=null)):(this.politeAnnounceTimerId!==null&&(window.clearTimeout(this.politeAnnounceTimerId),this.politeAnnounceTimerId=null),this.politeClearTimerId!==null&&(window.clearTimeout(this.politeClearTimerId),this.politeClearTimerId=null)),o.textContent="";let l=i?this.lastAssertiveText:this.lastPoliteText,u=n;n===l?(this.announcerToggle=!this.announcerToggle,u=this.announcerToggle?`${n}\xA0`:n):this.announcerToggle=!1,i?this.lastAssertiveText=n:this.lastPoliteText=n;let d=c?120:50,f=window.setTimeout(()=>{let h=this.announceTimers.indexOf(f);if(h!==-1&&this.announceTimers.splice(h,1),i?this.assertiveAnnounceTimerId=null:this.politeAnnounceTimerId=null,o.isConnected){o.textContent=u;let P=window.setTimeout(()=>{let O=this.announceTimers.indexOf(P);O!==-1&&this.announceTimers.splice(O,1),o.isConnected&&o.textContent===u&&(o.textContent="")},4e3);this.announceTimers.push(P),i?this.assertiveClearTimerId=P:this.politeClearTimerId=P}},d);this.announceTimers.push(f),i?this.assertiveAnnounceTimerId=f:this.politeAnnounceTimerId=f}ensureAnnouncer(){if(this.announcerEl&&document.body.contains(this.announcerEl))return;let e=document.createElement("div");e.className="wulf-toast-announcer",e.setAttribute("data-wulf-toast-announcer","true");let t=document.createElement("div");t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true");let s=document.createElement("div");s.setAttribute("role","alert"),s.setAttribute("aria-live","assertive"),s.setAttribute("aria-atomic","true"),e.appendChild(t),e.appendChild(s),document.body.appendChild(e),this.announcerEl=e,this.politeRegion=t,this.assertiveRegion=s}handleFocusHandoff(e,t){let s=T();if(!s||!e.element.contains(s))return;for(let i=t.length-1;i>=0;i--){let a=t[i];if(a===e||a.isClosed||!a.element.isConnected)continue;let c=a.element.querySelector(J);if(c){c.focus({preventScroll:!0});return}}let n=e.getPreviousActiveElement();if(n&&n.isConnected&&typeof n.focus=="function"&&!n.disabled&&!n.hidden&&!n.closest("[hidden]")&&!n.closest("[inert]")&&n.getAttribute("aria-hidden")!=="true"&&(n.tabIndex>=0||n.getAttribute("tabindex")!==null)){let i=n;if(typeof i.checkVisibility=="function"&&!i.checkVisibility({checkOpacity:!1,checkVisibilityCSS:!0,visibilityProperty:!0}))return;try{n.focus()}catch{}}}remove(e,t){let s=_(e.options.position),n=this.activeToasts.get(s);if(n){let i=n.indexOf(e);if(i!==-1&&n.splice(i,1),this.handleFocusHandoff(e,n),e.element.parentNode&&e.element.parentNode.removeChild(e.element),n.length===0&&!this.pendingReplacements.has(s)){let a=this.containers.get(s);a&&(!a.firstChild||a.children.length===0)&&(this.disposeContainer(a),this.containers.delete(s),this.activeToasts.delete(s),this.syncContainerRegionLabels())}}else e.element.parentNode&&e.element.parentNode.removeChild(e.element)}disposeContainer(e){try{let t=e;typeof t.hidePopover=="function"&&this.isPopoverOpen(e)&&t.hidePopover()}catch{}e.parentNode&&e.parentNode.removeChild(e)}clearAll(e){let t=[];if(e){this.replaceTokens.set(e,(this.replaceTokens.get(e)||0)+1),this.pendingReplacements.delete(e);let s=this.activeToasts.get(e);if(s&&s.length>0){let n=[...s];for(let i of n)t.push(i.close("programmatic"))}else{let n=this.containers.get(e);n&&(!n.firstChild||n.children.length===0)&&(this.disposeContainer(n),this.containers.delete(e),this.activeToasts.delete(e),this.syncContainerRegionLabels())}}else{for(let n of this.replaceTokens.keys())this.replaceTokens.set(n,(this.replaceTokens.get(n)||0)+1);this.pendingReplacements.clear();for(let n of this.announceTimers)window.clearTimeout(n);this.announceTimers=[],this.politeAnnounceTimerId=null,this.assertiveAnnounceTimerId=null,this.politeClearTimerId=null,this.assertiveClearTimerId=null;let s=new Set([...Array.from(this.containers.keys()),...Array.from(this.activeToasts.keys())]);for(let n of s)t.push(this.clearAll(n))}return Promise.all(t).then(()=>{if(!e){for(let[s,n]of Array.from(this.containers.entries()))(!n.firstChild||n.children.length===0)&&(this.disposeContainer(n),this.containers.delete(s),this.activeToasts.delete(s));this.syncContainerRegionLabels()}})}destroy(){for(let e of this.announceTimers)window.clearTimeout(e);this.announceTimers=[],this.politeAnnounceTimerId=null,this.assertiveAnnounceTimerId=null,this.politeClearTimerId=null,this.assertiveClearTimerId=null;for(let e of Array.from(this.activeToasts.values()))for(let t of[...e])t.destroyImmediate("programmatic");for(let e of Array.from(this.containers.values()))this.disposeContainer(e);this.containers.clear(),this.activeToasts.clear(),this.replaceTokens.clear(),this.pendingReplacements.clear(),this.announcerEl&&(this.announcerEl.remove(),this.announcerEl=null,this.politeRegion=null,this.assertiveRegion=null),r.instance=null}syncContainerRegionLabels(){let e=this.containers.size>1;for(let[t,s]of this.containers.entries()){let n=this.containerBaseLabels.get(s)||m.t("notificationsRegion");s.setAttribute("aria-label",e?`${n} (${t})`:n)}}getOrCreateContainer(e,t,s){let n=this.containers.get(e);if(!n||!document.body.contains(n)){n=document.createElement("div"),n.className=`wulf-toast-container wulf-toast-${e}`,n.setAttribute("role","region");let i=m.t("notificationsRegion",t.options.i18n);this.containerBaseLabels.set(n,i),n.setAttribute("aria-label",i),s&&typeof n.showPopover=="function"&&n.setAttribute("popover","manual"),document.body.appendChild(n),this.containers.set(e,n),this.syncContainerRegionLabels()}return n}};var b=class extends y{static _i18n=m;static i18n=m;audit(){return[]}getAuditPrefix(){return"Wulf.Toast"}getAuditTargetLabel(){return"Toast"}static show(e={}){let t=g.getInstance(),s=new A(e,(n,i)=>{t.remove(n,i)});return t.add(s),s}static clearAll(e){return g.getInstance().clearAll(e)}static destroy(){g.getInstance().destroy()}};var Q=b,D=N();D&&(D.Toast=Object.assign(b,{Toast:b,i18n:m}));return V(X);})();
|
|
5
|
-
if (typeof window !== "undefined") { var __w = window.Wulf; if (!__w || typeof __w !== "object" || (typeof Node !== "undefined" && __w instanceof Node) || (typeof HTMLCollection !== "undefined" && __w instanceof HTMLCollection)) { __w = {}; window.Wulf = __w; } if (typeof __WulfIIFE !== "undefined" && __WulfIIFE) { for (var k in
|
|
4
|
+
(${this.getAuditDisableHint()})`),t}checkAriaIdReferences(e,t,s,i=!1){let n=e.getAttribute(t)?.trim();if(!n)return!1;let o=e.ownerDocument||document,c=typeof e.getRootNode=="function"?e.getRootNode():o,r=n.split(/\s+/).filter(Boolean),l=r.map(d=>typeof ShadowRoot<"u"&&c instanceof ShadowRoot?c.getElementById(d):o.getElementById(d));return r.length>0&&l.every(d=>!!d)?i&&!l.some(f=>f?(f.textContent?.trim()||f.getAttribute("aria-label")?.trim()||"").length>0:!1)?(s.push(`Attribut ${t}="${n}" invalide : l'\xE9l\xE9ment cible ne contient aucun texte accessible.`),!1):!0:(s.push(`Attribut ${t}="${n}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`),!1)}};var v=class extends b{static _i18n;static setLocale(e){this._i18n&&this._i18n.setLocale(e)}static getLocale(){return this._i18n?this._i18n.getLocale():""}static registerLocale(e,t){this._i18n&&this._i18n.registerLocale(e,t)}static setI18n(e){this._i18n&&this._i18n.setI18n(e)}static getI18n(){return this._i18n?this._i18n.getAll():{}}static resetI18n(){this._i18n&&this._i18n.reset()}static t(e,t){return this._i18n?this._i18n.t(e,t):String(e)}i18nOverrides;constructor(e){super(),this.i18nOverrides=e}t(e){let t=this.constructor;return t._i18n?t._i18n.t(e,this.i18nOverrides):String(e)}};var k={closeButton:"Fermer la notification",notificationsRegion:"Notifications"};var S={closeButton:"Close notification",notificationsRegion:"Notifications"};var m=M("fr",{fr:k,en:S});function g(a,e=4096){let t=Math.max(0,e);return String(a??"").slice(0,t).replace(/[\u061C\u200B-\u200F\u202A-\u202E\u2066-\u2069\uFEFF]/g,"")}function y(a){if(typeof document>"u")return null;let e=(a??document).activeElement;for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e&&typeof e.focus=="function"?e:null}function O(a){return!!(a.isComposing||a.key==="Process"||a.key==="Enter"&&a.keyCode===229)}function R(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function D(a,e,t){let s=Number.isFinite(e)?Math.min(e,6e4):300;if(t?.aborted||s<=0||R())return Promise.resolve();let i=typeof a.getAnimations=="function"?a.getAnimations().filter(n=>{if(n.playState!=="running")return!1;let o=n.effect?.getComputedTiming?.();return o?Number.isFinite(o.endTime):!0}):[];return i.length===0?Promise.resolve():new Promise(n=>{let o=!1,c=null,r=()=>{o||(o=!0,c!==null&&(clearTimeout(c),c=null),t?.removeEventListener("abort",r),n())};t?.addEventListener("abort",r,{once:!0}),c=setTimeout(r,s),Promise.allSettled(i.map(l=>l.finished)).then(r)})}var ne=1,H=5e3,se=/^(?:#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})|(?:rgb|rgba|hsl|hsla|oklch|oklab|lch|lab)\(\s*(?:[+-]?(?:\d+\.?\d*|\.\d+)(?:%|deg|rad|grad|turn)?|none)(?:\s*[,/\s]\s*(?:[+-]?(?:\d+\.?\d*|\.\d+)(?:%|deg|rad|grad|turn)?|none)){2,3}\s*\)|[a-z]{3,20})$/i;function C(a){if(!a||typeof a!="string"||a.length>128)return!1;let e=a.trim();return!e||/[\u0000-\u001F\u007F;{}<>\\]|(?:url|image-set|-webkit-image-set|image|src|expression|attr|env|var)\s*\(/i.test(e)?!1:typeof CSS<"u"&&typeof CSS.supports=="function"?CSS.supports("color",e)||CSS.supports("background-color",e):se.test(e)}function oe(a){return a.slice(0,128).trim().split(/\s+/).filter(e=>/^[a-zA-Z0-9_-]+$/.test(e)&&!e.startsWith("wulf-toast")).slice(0,8).join(" ")}var A=class extends b{id;options;element;_isClosed=!1;_isFinalized=!1;closePromise=null;timerId=null;remainingTime=0;hasDuration=!1;timerStartTime=0;isPausedByHover=!1;isPausedByFocus=!1;isPausedByVisibility=!1;isPendingFocusDismiss=!1;actionPending=!1;previousActiveElement=null;eventsAbortController=new AbortController;disposeAbortController=new AbortController;onDismissCallback;constructor(e,t){if(super(),typeof document>"u")throw new Error("[Wulf.Toast] Impossible d'instancier une notification Toast sans environnement DOM (document).");this.id=`wulf-toast-${ne++}`,this.options=Object.freeze({...e}),this.onDismissCallback=t,this.previousActiveElement=y();let s=e.duration===void 0?H:e.duration;typeof s=="number"&&Number.isFinite(s)&&s>0?(this.remainingTime=Math.min(s,2147483647),this.hasDuration=!0):(this.remainingTime=0,this.hasDuration=!1),this.element=this.createDOM(),this.bindEvents(),this.runAuditWarning(e.audit!==!1)}get isClosed(){return this._isClosed}getPreviousActiveElement(){return this.previousActiveElement}audit(){let e=[],t=!!(this.options.title&&this.options.title.trim().length>0),s=!!(this.options.message&&this.options.message.trim().length>0);!t&&!s&&e.push("Contenu textuel vide : d\xE9finissez au moins un title ou un message pour que le lecteur d'\xE9cran puisse annoncer la notification (WCAG 4.1.3).");let i=this.options.duration===void 0?H:this.options.duration;typeof i=="number"&&i>0&&i<5e3&&e.push(`Dur\xE9e d'affichage trop courte (duration: ${i}ms) : pr\xE9voyez au moins 5000ms ou duration: false pour laisser le temps de lecture aux utilisateurs (WCAG 2.2.1).`);let n=this.options.closable??!0;return(i===!1||typeof i=="number"&&i<=0)&&!n&&e.push("Notification persistante impossible \xE0 fermer au clavier : activez closable: true lorsque duration est d\xE9sactiv\xE9 (WCAG 2.1.1)."),this.options.action&&(g(String(this.options.action.label??""),128).trim()||e.push("Bouton d'action invalide : action.label doit contenir un texte non vide (WCAG 4.1.2).")),e}getAuditPrefix(){return"Wulf.Toast"}getAuditTargetLabel(){return`#${this.id}`}createDOM(){let e=document.createElement("div");if(e.id=this.id,e.className="wulf-toast",e.setAttribute("data-toast-role",this.options.role==="alert"?"alert":"status"),this.options.backgroundColor&&C(this.options.backgroundColor)&&e.style.setProperty("--wulf-toast-bg",this.options.backgroundColor.trim()),this.options.titleColor&&C(this.options.titleColor)&&e.style.setProperty("--wulf-toast-title-color",this.options.titleColor.trim()),this.options.textColor&&C(this.options.textColor)&&e.style.setProperty("--wulf-toast-text-color",this.options.textColor.trim()),this.options.iconColor&&C(this.options.iconColor)&&e.style.setProperty("--wulf-toast-icon-color",this.options.iconColor.trim()),this.options.closeButtonColor&&C(this.options.closeButtonColor)&&e.style.setProperty("--wulf-toast-close-color",this.options.closeButtonColor.trim()),this.options.icon&&typeof this.options.icon=="string"&&this.options.icon.trim()!==""){let o=oe(this.options.icon);if(o){let c=document.createElement("span");c.className=`wulf-toast-icon ${o}`,c.setAttribute("aria-hidden","true"),e.appendChild(c)}}let t=document.createElement("div"),s=!!(this.options.onClick||this.options.closeOnClick);if(t.className=s?"wulf-toast-content wulf-toast-content--interactive":"wulf-toast-content",s&&(t.setAttribute("role","button"),t.setAttribute("tabindex","0"),t.addEventListener("keydown",o=>{O(o)||(o.key==="Enter"?(o.preventDefault(),o.stopPropagation(),t.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0}))):o.key===" "&&(o.preventDefault(),o.stopPropagation()))},{signal:this.eventsAbortController.signal}),t.addEventListener("keyup",o=>{o.key===" "&&(o.preventDefault(),o.stopPropagation(),t.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0})))},{signal:this.eventsAbortController.signal})),this.options.title&&this.options.title.trim()!==""){let o=document.createElement("div");o.className="wulf-toast-title",this.appendTextWithLineBreaks(o,this.options.title),t.appendChild(o)}if(this.options.message&&this.options.message.trim()!==""){let o=document.createElement("div");o.className="wulf-toast-message",this.appendTextWithLineBreaks(o,this.options.message),t.appendChild(o)}e.appendChild(t);let i=this.options.action;if(i&&typeof i.onClick=="function"){let o=g(String(i.label??""),128).trim();if(o){let c=document.createElement("button");if(c.type="button",c.className="wulf-toast-action",c.textContent=o,typeof i.ariaLabel=="string"){let l=g(i.ariaLabel,256).trim();l&&c.setAttribute("aria-label",l)}let r=()=>{this.actionPending=!1,this._isClosed||(c.disabled=!1,c.removeAttribute("aria-busy"))};c.addEventListener("click",l=>{if(l.stopPropagation(),this._isClosed||this.actionPending)return;this.actionPending=!0,c.disabled=!0,c.setAttribute("aria-busy","true");let u=i.closeOnClick!==!1;try{let d=i.onClick(this,l);d&&typeof d.then=="function"?d.then(()=>{u&&!this._isClosed?this.close("action"):r()},f=>{console.error("[Wulf.Toast] Erreur dans action.onClick:",f),r()}):u&&!this._isClosed?this.close("action"):r()}catch(d){console.error("[Wulf.Toast] Erreur dans action.onClick:",d),r()}},{signal:this.eventsAbortController.signal}),e.appendChild(c)}}if(this.options.closable??!0){let o=document.createElement("button");o.type="button",o.className="wulf-toast-close",o.setAttribute("aria-label",m.t("closeButton",this.options.i18n));let c=document.createElement("span");c.className="wulf-toast-close-icon",c.setAttribute("aria-hidden","true"),c.textContent="\xD7",o.appendChild(c),o.addEventListener("click",r=>{r.stopPropagation(),this.close("close-button")},{signal:this.eventsAbortController.signal}),e.appendChild(o)}if(this.options.progressBar&&this.remainingTime>0){e.style.setProperty("--wulf-toast-duration",`${this.remainingTime}ms`);let o=document.createElement("div");o.className="wulf-toast-progress",o.setAttribute("aria-hidden","true"),e.appendChild(o)}return e}appendTextWithLineBreaks(e,t){g(String(t??""),4096).split(/\r\n|\r|\n/).slice(0,100).forEach((n,o)=>{o>0&&e.appendChild(document.createElement("br")),e.appendChild(document.createTextNode(n))})}bindEvents(){let{signal:e}=this.eventsAbortController;this.element.addEventListener("click",t=>{if(this.options.onClick)try{this.options.onClick(this,t)}catch(s){console.error("[Wulf.Toast] Erreur dans le callback onClick:",s)}this.options.closeOnClick&&this.close("toast-click")},{signal:e}),this.element.addEventListener("mouseenter",()=>this.pauseTimer("hover"),{signal:e}),this.element.addEventListener("mouseleave",()=>this.resumeTimer("hover"),{signal:e}),this.element.addEventListener("focusin",()=>this.pauseTimer("focus"),{signal:e}),this.element.addEventListener("focusout",t=>{let s=t.relatedTarget;if(!(s&&this.element.contains(s))){if(this.isPendingFocusDismiss&&!this._isClosed){this.isPendingFocusDismiss=!1,this.close("timeout");return}this.resumeTimer("focus")}},{signal:e}),this.element.addEventListener("keydown",t=>{if(t.key==="Escape"&&(this.options.closable??!0)){if(O(t))return;t.stopPropagation(),this.close("close-button")}},{signal:e}),typeof document<"u"&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.pauseTimer("visibility"):this.resumeTimer("visibility")},{signal:e})}get isPaused(){return this.isPausedByHover||this.isPausedByFocus||this.isPausedByVisibility}startTimer(){if(!(this._isClosed||this.remainingTime<=0||this.isPaused)){if(typeof document<"u"&&document.visibilityState==="hidden"){this.isPausedByVisibility=!0,this.element.classList.add("is-paused");return}this.timerId!==null&&(typeof window<"u"&&window.clearTimeout(this.timerId),this.timerId=null),!(typeof window>"u")&&(this.timerStartTime=typeof performance<"u"?performance.now():Date.now(),this.timerId=window.setTimeout(()=>{this.timerId=null;let e=y();if(e&&this.element.contains(e)){this.isPendingFocusDismiss=!0;return}this.close("timeout")},this.remainingTime))}}pauseTimer(e="interaction"){if(this._isClosed||!this.hasDuration||this.remainingTime<=0)return;let t=this.isPaused;if(e==="visibility"?this.isPausedByVisibility=!0:e==="focus"?this.isPausedByFocus=!0:this.isPausedByHover=!0,!t){if(this.timerId!==null){typeof window<"u"&&window.clearTimeout(this.timerId),this.timerId=null;let i=(typeof performance<"u"?performance.now():Date.now())-this.timerStartTime;this.remainingTime=Math.max(0,this.remainingTime-i)}this.element.classList.add("is-paused")}}resumeTimer(e="interaction"){if(!(this._isClosed||!this.hasDuration)){if(e==="visibility")this.isPausedByVisibility=!1;else if(e==="focus")this.isPausedByFocus=!1;else if(e==="hover"){this.isPausedByHover=!1;let t=y();t&&this.element.contains(t)&&(this.isPausedByFocus=!0)}else this.isPausedByHover=!1,this.isPausedByFocus=!1;if(!this.isPaused){if(this.element.classList.remove("is-paused"),this.remainingTime<=0){this.close("timeout");return}this.startTimer()}}}finalizeDismiss(e){if(!this._isFinalized&&(this._isFinalized=!0,this.eventsAbortController.abort(),this.onDismissCallback&&this.onDismissCallback(this,e),this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.options.onClose))try{this.options.onClose(this,e)}catch(t){console.error("[Wulf.Toast] Erreur dans le callback onClose:",t)}}destroyImmediate(e="replace"){this._isClosed=!0,this.timerId!==null&&(typeof window<"u"&&window.clearTimeout(this.timerId),this.timerId=null),this.disposeAbortController.abort(),this.finalizeDismiss(e)}close(e="programmatic",t=!1){return this._isClosed?this.closePromise??Promise.resolve():(this._isClosed=!0,this.timerId!==null&&(typeof window<"u"&&window.clearTimeout(this.timerId),this.timerId=null),this.eventsAbortController.abort(),this.element.classList.add(t?"wulf-toast-hiding-fast":"wulf-toast-hiding"),R()?(this.finalizeDismiss(e),this.closePromise=Promise.resolve(),this.closePromise):(this.closePromise=D(this.element,t?90:300,this.disposeAbortController.signal).then(()=>{this.disposeAbortController.signal.aborted||this.finalizeDismiss(e)}),this.closePromise))}};var ke=Symbol.for("wulf.focusTrap.stack.v1"),W=Symbol.for("wulf.toast.manager.v1"),j=Symbol.for("wulf.toast.containers.v1"),$=Symbol.for("wulf.toast.announcers.v1");function _(){return typeof globalThis>"u"?null:globalThis}function z(){let a=_();return a?a[W]??null:null}function B(a){let e=_();e&&(e[W]=a)}function x(a){if(typeof WeakSet>"u")return null;let e=_();if(!e)return null;let t=e[a];return t instanceof WeakSet||(t=new WeakSet,e[a]=t),t}function K(a){x(j)?.add(a)}function N(a){x(j)?.delete(a)}function V(a){x($)?.add(a)}function G(a){x($)?.delete(a)}var Y=new Set(["top-left","top-center","top-right","bottom-left","bottom-center","bottom-right"]);function U(a){return a&&Y.has(a)?a:"top-right"}var re='button:not([disabled]), [href], [tabindex]:not([tabindex="-1"])',T=class a{containers=new Map;containerBaseLabels=new WeakMap;activeToasts=new Map;announcerEl=null;politeRegion=null;assertiveRegion=null;announceTimers=[];politeAnnounceTimerId=null;assertiveAnnounceTimerId=null;politeClearTimerId=null;assertiveClearTimerId=null;lastPoliteText="";lastAssertiveText="";announcerToggle=!1;isPopoverOpen(e){try{if(e.matches(":popover-open"))return!0}catch{}return e.classList.contains(":popover-open")}replaceTokens=new Map;pendingReplacements=new Set;constructor(){}static getInstance(){let e=z();return e||(e=new a,B(e)),e}getContainerKey(e,t){return`${e}:${t?"top":"fixed"}`}add(e){if(typeof document>"u"||typeof window>"u")return;let t=U(e.options.position),s=this.activeToasts.get(t);s||(s=[],this.activeToasts.set(t,s));let i=e.options.maxToasts,n=typeof i=="number"&&Number.isFinite(i)&&i>0?Math.min(50,Math.max(1,Math.floor(i))):5;if(e.options.replace&&s.length>0){let o=[...s],c=(this.replaceTokens.get(t)||0)+1;this.replaceTokens.set(t,c),this.pendingReplacements.add(t);let r=o.map(l=>l.close("replace",!0));Promise.all(r).then(()=>{if(this.pendingReplacements.delete(t),this.replaceTokens.get(t)!==c){e.destroyImmediate("replace");return}this.mountToast(e,t,n)});return}if(this.pendingReplacements.has(t)&&(this.replaceTokens.set(t,(this.replaceTokens.get(t)||0)+1),this.pendingReplacements.delete(t)),s.length>=n){let o=s.length-n+1,c=s.splice(0,o);for(let r of c)r.close("max-limit",!0)}this.mountToast(e,t,n)}mountToast(e,t,s=5){if(e.isClosed||typeof document>"u")return;let i=e.options.useTopLayer??!0,n=this.getOrCreateContainer(t,e,i),o=this.activeToasts.get(t);o||(o=[],this.activeToasts.set(t,o));let c=s+10;if(n.children.length>=c){let r=Array.from(n.children);for(let l of r){if(n.children.length<c)break;(l.classList.contains("wulf-toast-hiding")||l.classList.contains("wulf-toast-hiding-fast"))&&l.remove()}}if(i&&typeof n.showPopover=="function"&&n.getAttribute("popover")==="manual")try{let r=n;this.isPopoverOpen(n)||r.showPopover()}catch{n.removeAttribute("popover")}if(n.appendChild(e.element),o.push(e),this.announce(e),e.options.onOpen)try{e.options.onOpen(e)}catch(r){console.error("[Wulf.Toast] Erreur dans le callback onOpen:",r)}e.startTimer()}announce(e){if(typeof document>"u"||typeof window>"u")return;let t=[e.options.title,e.options.message].filter(h=>typeof h=="string"&&h.trim().length>0).map(h=>g(h,512).trim()).filter(Boolean);if(t.length===0)return;let s=t.join(". "),i=s.length>512?`${s.slice(0,509)}...`:s,n=e.options.role==="alert",o=document;if(typeof o.ariaNotify=="function")try{o.ariaNotify(i,{priority:n?"high":"normal"});return}catch{}let c=!this.announcerEl||!this.announcerEl.isConnected;this.ensureAnnouncer();let r=n?this.assertiveRegion:this.politeRegion;if(!r)return;n?(this.assertiveAnnounceTimerId!==null&&(window.clearTimeout(this.assertiveAnnounceTimerId),this.assertiveAnnounceTimerId=null),this.assertiveClearTimerId!==null&&(window.clearTimeout(this.assertiveClearTimerId),this.assertiveClearTimerId=null)):(this.politeAnnounceTimerId!==null&&(window.clearTimeout(this.politeAnnounceTimerId),this.politeAnnounceTimerId=null),this.politeClearTimerId!==null&&(window.clearTimeout(this.politeClearTimerId),this.politeClearTimerId=null)),r.textContent="";let l=n?this.lastAssertiveText:this.lastPoliteText,u=i;i===l?(this.announcerToggle=!this.announcerToggle,u=this.announcerToggle?`${i}\xA0`:i):this.announcerToggle=!1,n?this.lastAssertiveText=i:this.lastPoliteText=i;let d=c?120:50,f=window.setTimeout(()=>{let h=this.announceTimers.indexOf(f);if(h!==-1&&this.announceTimers.splice(h,1),n?this.assertiveAnnounceTimerId=null:this.politeAnnounceTimerId=null,r.isConnected){r.textContent=u;let I=window.setTimeout(()=>{let F=this.announceTimers.indexOf(I);F!==-1&&this.announceTimers.splice(F,1),r.isConnected&&r.textContent===u&&(r.textContent="")},4e3);this.announceTimers.push(I),n?this.assertiveClearTimerId=I:this.politeClearTimerId=I}},d);this.announceTimers.push(f),n?this.assertiveAnnounceTimerId=f:this.politeAnnounceTimerId=f}ensureAnnouncer(){if(typeof document>"u"||!document.body||this.announcerEl&&document.body.contains(this.announcerEl))return;let e=document.createElement("div");e.className="wulf-toast-announcer",e.setAttribute("data-wulf-toast-announcer","true"),V(e);let t=document.createElement("div");t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true");let s=document.createElement("div");s.setAttribute("role","alert"),s.setAttribute("aria-live","assertive"),s.setAttribute("aria-atomic","true"),e.appendChild(t),e.appendChild(s),document.body.appendChild(e),this.announcerEl=e,this.politeRegion=t,this.assertiveRegion=s}handleFocusHandoff(e,t){let s=y();if(!s||!e.element.contains(s))return;for(let n=t.length-1;n>=0;n--){let o=t[n];if(o===e||o.isClosed||!o.element.isConnected)continue;let c=o.element.querySelector(re);if(c){c.focus({preventScroll:!0});return}}let i=e.getPreviousActiveElement();if(i&&i.isConnected&&typeof i.focus=="function"&&!i.disabled&&!i.hidden&&!i.closest("[hidden]")&&!i.closest("[inert]")&&i.getAttribute("aria-hidden")!=="true"&&(i.tabIndex>=0||i.getAttribute("tabindex")!==null)){let n=i;if(typeof n.checkVisibility=="function"&&!n.checkVisibility({checkOpacity:!1,checkVisibilityCSS:!0,visibilityProperty:!0}))return;try{i.focus()}catch{}}}remove(e,t){let s=U(e.options.position),i=this.activeToasts.get(s),n=e.options.useTopLayer??!0,o=this.getContainerKey(s,n),c=e.element.parentElement;if(i){let r=i.indexOf(e);r!==-1&&i.splice(r,1),this.handleFocusHandoff(e,i),e.element.parentNode&&e.element.parentNode.removeChild(e.element);let l=this.containers.get(o)||(c instanceof HTMLElement?c:void 0);if(l&&(!l.firstChild||l.children.length===0)){for(let[u,d]of Array.from(this.containers.entries()))d===l&&this.containers.delete(u);this.disposeContainer(l),this.syncContainerRegionLabels()}if(i.length===0&&!this.pendingReplacements.has(s)){for(let u of[!0,!1]){let d=this.getContainerKey(s,u),f=this.containers.get(d);f&&(!f.firstChild||f.children.length===0)&&(this.disposeContainer(f),this.containers.delete(d))}this.activeToasts.delete(s),this.syncContainerRegionLabels()}}else e.element.parentNode&&e.element.parentNode.removeChild(e.element)}disposeContainer(e){N(e);try{let t=e;typeof t.hidePopover=="function"&&this.isPopoverOpen(e)&&t.hidePopover()}catch{}e.parentNode&&e.parentNode.removeChild(e)}clearAll(e){if(typeof document>"u"||typeof window>"u")return Promise.resolve();let t=[];if(e){this.replaceTokens.set(e,(this.replaceTokens.get(e)||0)+1),this.pendingReplacements.delete(e);let s=this.activeToasts.get(e);if(s&&s.length>0){let i=[...s];for(let n of i)t.push(n.close("programmatic"))}else{let i=!1;for(let n of[!0,!1]){let o=this.getContainerKey(e,n),c=this.containers.get(o);c&&(!c.firstChild||c.children.length===0)&&(this.disposeContainer(c),this.containers.delete(o),i=!0)}this.activeToasts.delete(e),i&&this.syncContainerRegionLabels()}}else{for(let i of this.replaceTokens.keys())this.replaceTokens.set(i,(this.replaceTokens.get(i)||0)+1);this.pendingReplacements.clear();for(let i of this.announceTimers)window.clearTimeout(i);this.announceTimers=[],this.politeAnnounceTimerId=null,this.assertiveAnnounceTimerId=null,this.politeClearTimerId=null,this.assertiveClearTimerId=null;let s=new Set(Array.from(this.activeToasts.keys()));for(let i of this.containers.keys()){let n=i.slice(0,i.lastIndexOf(":"));Y.has(n)&&s.add(n)}for(let i of s)t.push(this.clearAll(i))}return Promise.all(t).then(()=>{if(!e){for(let[s,i]of Array.from(this.containers.entries()))(!i.firstChild||i.children.length===0)&&(this.disposeContainer(i),this.containers.delete(s));this.activeToasts.clear(),this.syncContainerRegionLabels()}})}destroy(){if(typeof window<"u")for(let e of this.announceTimers)window.clearTimeout(e);this.announceTimers=[],this.politeAnnounceTimerId=null,this.assertiveAnnounceTimerId=null,this.politeClearTimerId=null,this.assertiveClearTimerId=null;for(let e of Array.from(this.activeToasts.values()))for(let t of[...e])t.destroyImmediate("programmatic");for(let e of Array.from(this.containers.values()))this.disposeContainer(e);this.containers.clear(),this.activeToasts.clear(),this.replaceTokens.clear(),this.pendingReplacements.clear(),this.announcerEl&&(G(this.announcerEl),this.announcerEl.remove(),this.announcerEl=null,this.politeRegion=null,this.assertiveRegion=null),B(null)}syncContainerRegionLabels(){let e=this.containers.size>1;for(let[t,s]of this.containers.entries()){let i=this.containerBaseLabels.get(s)||m.t("notificationsRegion"),n=t.slice(0,t.lastIndexOf(":"));s.setAttribute("aria-label",e?`${i} (${n})`:i)}}getOrCreateContainer(e,t,s){let i=this.getContainerKey(e,s),n=this.containers.get(i);if(!n||!document.body.contains(n)){n&&N(n),n=document.createElement("div"),n.className=`wulf-toast-container wulf-toast-${e}`,n.setAttribute("role","region");let o=m.t("notificationsRegion",t.options.i18n);this.containerBaseLabels.set(n,o),n.setAttribute("aria-label",o),s&&typeof n.showPopover=="function"&&n.setAttribute("popover","manual"),K(n),document.body.appendChild(n),this.containers.set(i,n),this.syncContainerRegionLabels()}return n}};var P=class a extends v{static _i18n=m;static i18n=m;audit(){return[]}getAuditPrefix(){return"Wulf.Toast"}getAuditTargetLabel(){return"Toast"}static show(e={}){let t=T.getInstance(),s=new A(e,(i,n)=>{t.remove(i,n)});return t.add(s),s}static async promise(e,t){let s=(r,l)=>{let u;if(typeof r=="function")try{u=r(l)}catch(d){return console.error("[Wulf.Toast] Erreur lors de la r\xE9solution du message Toast.promise:",d),{}}else u=r;return typeof u=="string"?{message:u}:u&&typeof u=="object"?{...u}:{}},i=t.baseOptions?{...t.baseOptions}:{},n=s(t.loading,void 0),o=a.show({...i,duration:!1,closable:!0,role:"status",...n,replace:!1}),c=typeof e=="function"?Promise.resolve().then(()=>e()):Promise.resolve(e);try{let r=await c;await o.close("replace",!0);let l=s(t.success,r);return a.show({...i,role:"status",...l,replace:!1}),r}catch(r){await o.close("replace",!0);let l=s(t.error,r);throw a.show({...i,role:"alert",...l,replace:!1}),r}}static clearAll(e){return T.getInstance().clearAll(e)}static destroy(){T.getInstance().destroy()}};var ae=P;return ee(le);})();
|
|
5
|
+
if (typeof window !== "undefined") { var __w = window.Wulf; if (!__w || typeof __w !== "object" || (typeof Node !== "undefined" && __w instanceof Node) || (typeof HTMLCollection !== "undefined" && __w instanceof HTMLCollection)) { __w = {}; window.Wulf = __w; } var __set = function(obj, key, val) { try { Object.defineProperty(obj, key, { value: val, writable: true, configurable: true, enumerable: true }); } catch (_) { try { obj[key] = val; } catch (__) {} } }; if (typeof __WulfIIFE !== "undefined" && __WulfIIFE) { var __e = __WulfIIFE; var __skip = ["__proto__","constructor","prototype"]; for (var k in __e) { if (Object.hasOwn(__e, k) && __skip.indexOf(k) === -1 && __w[k] === undefined) { __set(__w, k, __e[k]); } } if (__e.Toast) __set(__w, "Toast", Object.assign(__e.Toast, { Toast: __e.Toast, ToastInstance: __e.ToastInstance, ToastManager: __e.ToastManager, i18n: __e.toastI18n })); }}
|
|
6
6
|
//# sourceMappingURL=toast.global.min.js.map
|