diff --git a/docs/assets/spirit-web-chunk.0a1b4526.js b/docs/assets/spirit-web-chunk.55cab3a8.js similarity index 72% rename from docs/assets/spirit-web-chunk.0a1b4526.js rename to docs/assets/spirit-web-chunk.55cab3a8.js index c378064a8a..c0b2810016 100644 --- a/docs/assets/spirit-web-chunk.0a1b4526.js +++ b/docs/assets/spirit-web-chunk.55cab3a8.js @@ -1 +1 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function e(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function i(r){if(r.ep)return;r.ep=!0;const n=e(r);fetch(r.href,n)}})();const m=new Map,P={set(s,t,e){m.has(s)||m.set(s,new Map);const i=m.get(s);if(!i.has(t)&&i.size!==0){console.error(`Spirit do not allow more than one instance per element. Bound instance: ${Array.from(i.keys())[0]}.`);return}i.set(t,e)},get(s,t){return m.has(s)&&m.get(s).get(t)||null},remove(s,t){if(!m.has(s))return;const e=m.get(s);e.delete(t),e.size===0&&m.delete(s)}},It=(s,t,e)=>{s&&s.addEventListener(t,e,{passive:!1})},Mt=(s,t,e)=>s.removeEventListener(t,e),a={on(s,t,e){It(s,t,e)},off(s,t,e){Mt(s,t,e)},trigger(s,t,e){if(typeof t!="string"||!s)return null;const i=!0,r=new Event(t,{bubbles:i,cancelable:!0});if(typeof e<"u")for(const n of Object.keys(e))Object.defineProperty(r,n,{get(){return e[n]}});return s.dispatchEvent(r),r}},h={findAll(s,t=document.documentElement){return[].concat(...Element.prototype.querySelectorAll.call(t,s))},findOne(s,t=document.documentElement){return Element.prototype.querySelector.call(t,s)}},_=s=>!s||typeof s!="object"?!1:typeof s.nodeType<"u",O=s=>_(s)?s:typeof s=="string"&&s.length>0?document.querySelector(s):null,vt=(s,t="target")=>{var r;const e=s,i=(r=e==null?void 0:e.dataset)!=null&&r.spiritTarget?O(s.dataset.spiritTarget):null;return t==="target"?i:e},Rt=s=>s==null?void 0:s.getAttribute("data-spirit-target"),F=s=>{const t=Rt(s);return t?document.querySelector(t):null},Nt="data-spirit-toggle",xt="data-spirit-dismiss",St=(s,t,e,i,r="target")=>{a.on(s,"click",function(){const o=vt(O(this),r);t.getOrCreateInstance(o)[e](o,i)})},Pt=(s,t)=>{t.getOrCreateInstance(s)},G=(s,t,e,i="toggle",r="target")=>{const n=t.NAME;a.on(window,"DOMContentLoaded",o=>{h.findAll(`[${s}="${n}"]`).forEach(l=>{e(l,t,i,o,r)})})},S=(s,t="toggle",e="target")=>{G(Nt,s,St,t,e)},wt=(s,t="dismiss",e="target")=>{G(xt,s,St,t,e)},y=(s,t="toggle")=>{G(Nt,s,Pt,t)},Ft=(s,t)=>!t.composedPath().includes(s);function X(s){if(s==="true")return!0;if(s==="false")return!1;if(s===Number(s).toString())return Number(s);if(s===""||s==="null")return null;if(typeof s!="string")return s;try{return JSON.parse(decodeURIComponent(s))}catch{return s}}function V(s){return s.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}const J={setDataAttribute(s,t,e){s.setAttribute(`data-spirit-${V(t)}`,e)},removeDataAttribute(s,t){s.removeAttribute(`data-spirit-${V(t)}`)},getDataAttributes(s){if(!s)return{};const t={},e=Object.keys(s.dataset).filter(i=>i.startsWith("spirit")&&!i.startsWith("spiritConfig"));for(const i of e){let r=i.replace(/^spirit/,"");r=r.charAt(0).toLowerCase()+r.slice(1,r.length),t[r]=X(s.dataset[i])}return t},getDataAttribute(s,t){return X(s.getAttribute(`data-spirit-${V(t)}`))}},Vt=s=>s==null?`${s}`:Object.prototype.toString.call(s).match(/\s([a-z]+)/i)[1].toLowerCase();class Ht{static get Default(){return{}}static get DefaultType(){return{}}static get NAME(){throw new Error('You have to implement the static method "NAME", for each component!')}getConfig(t){const e=this.mergeConfigObj(t);return this.typeCheckConfig(e),e}mergeConfigObj(t,e){const i=_(e)?J.getDataAttribute(e,"config"):{};return{...this.constructor.Default,...typeof i=="object"?i:{},..._(e)?J.getDataAttributes(e):{},...typeof t=="object"?t:{}}}typeCheckConfig(t,e=this.constructor.DefaultType){for(const[i,r]of Object.entries(e)){const n=t==null?void 0:t[i],o=_(n)?"element":Vt(n);if(!new RegExp(r).test(o))throw new TypeError(`${this.constructor.NAME.toUpperCase()}: Option "${i}" provided type "${o}" but expected type "${r}".`)}}}const tt=(s,t)=>{let e,i=!1;return r=>{i||(i=!0,e&&clearTimeout(e),e=setTimeout(()=>{s(r),i=!1},t))}},Qt=(s,t,e)=>{const i=new FileReader;i.onload=r=>{const n=new Image;n.onload=()=>{const o=document.createElement("canvas"),l=o.getContext("2d");o.width=t,o.height=n.height/n.width*t,l==null||l.drawImage(n,0,0,o.width,o.height);const c=o.toDataURL("image/jpeg",.8);e(c)},r.target&&r.target.result&&(n.src=r.target.result.toString())},i.readAsDataURL(s)},Ut=s=>{a.trigger(s,"transitionend")},kt=s=>{if(!s)return 0;let{transitionDuration:t,transitionDelay:e}=window.getComputedStyle(s);const i=Number.parseFloat(t),r=Number.parseFloat(e);return!i&&!r?0:([t]=t.split(","),[e]=e.split(","),(Number.parseFloat(t)+Number.parseFloat(e))*1e3)},et=(s,t=[],e=s)=>typeof s=="function"?s(...t):e,b=(s,t,e=!0)=>{if(!e){et(t);return}const i=5,r=kt(s)+i;let n=!1;const o=l=>{l.target===s&&(n=!0,s.removeEventListener("transitionend",o),et(t))};s.addEventListener("transitionend",o),setTimeout(()=>{n||Ut(s)},r)},Bt="dialog[open]",H="is-scrolling-disabled";class Lt{constructor(t,e,i){this.target=t,this.element=e||document.body,this.selector=i||Bt,this.offsetY=0}disableScroll(){if(this.element.classList.contains(H))return;const e=(this.element.tagName==="BODY"?window.innerWidth:this.element.offsetWidth)-this.element.clientWidth;this.offsetY=window.scrollY,this.element.style.paddingRight=`${e}px`,this.element.style.top=`-${this.offsetY}px`,this.element.classList.add(H)}enableScroll(){const t=h.findAll(this.selector);this.target&&t.length===0&&b(this.target,()=>{this.element.style.paddingRight="",this.element.style.top="",this.element.classList.remove(H),window.scrollTo(0,this.offsetY)})}}class f extends Ht{constructor(t,e){super(),this.element=O(t),this.NAME="",this.config=this.getConfig(e),P.set(this.element,this.constructor.INSTANCE_KEY,this)}dispose(){P.remove(this.element,this.constructor.INSTANCE_KEY);for(const t of Object.getOwnPropertyNames(this))this[t]=null}getConfig(t){const e=this.mergeConfigObj(t,this.element);return this.typeCheckConfig(e),e}static get NAME(){return""}static getInstance(t){return P.get(O(t),this.INSTANCE_KEY)}static getOrCreateInstance(t,e={}){return this.getInstance(t)||this.createInstance(t,e)}static createInstance(t,e){return new this(t,typeof e=="object"?e:null)}static get INSTANCE_KEY(){return`spirit.${this.NAME}`}static get DATA_KEY(){return`${this.NAME}`}static get EVENT_KEY(){return`.${this.DATA_KEY}`}static eventName(t){return`${t}${this.EVENT_KEY}`}}const Wt="autoResize",zt="resize",Q=400;class Yt extends f{constructor(t,e){super(t,e),this.adjustHeight=()=>{const i=parseFloat(getComputedStyle(this.input).getPropertyValue("border-top-width"))||0,r=parseFloat(getComputedStyle(this.input).getPropertyValue("border-bottom-width"))||0,n=i+r;this.input.style.height="auto",this.input.style.overflow="auto";const o=this.input.scrollHeight+n;this.input.style.height=`${o{r.setAttribute(Kt,this.meta.id),r.setAttribute(U,String(t)),this.meta.hideOnCollapse&&t&&(r.remove(),this.appendNodeToParent(),this.onDestroy())};this.state.open=t,e.length===1?i(this.element):e.map(r=>i(r))}updateCollapsibleElement(t=this.state.open){var e;this.target&&(t||this.adjustCollapsibleChildrenHeight(),this.adjustCollapsibleElementHeight(t),this.state.init&&((e=this.target)==null||e.classList.add(it)),b(this.target,()=>{var i,r,n,o;(i=this.target)==null||i.classList.remove(it),(r=this.target)==null||r.classList.toggle(Zt,t),t?(n=this.target)==null||n.setAttribute("style","height: 100%"):(o=this.target)==null||o.style.removeProperty("height")}))}show(){this.hideParentSiblings(this.element),a.trigger(this.target,Xt),this.updateTriggerElement(!0),this.updateCollapsibleElement(!0),this.target&&b(this.target,()=>{a.trigger(this.target,nt)})}hide(){a.trigger(this.target,jt),this.updateTriggerElement(!1),this.updateCollapsibleElement(!1),this.target&&b(this.target,()=>{a.trigger(this.target,rt)})}toggle(){this.state.open?this.hide():this.show()}initEvents(){const t=h.findAll(`[${k}="${this.meta.id}"]`);t.length===1?a.on(this.element,"click",()=>this.toggle()):t.forEach(e=>a.on(e,"click",()=>this.toggle()))}destroyEvents(){const t=h.findAll(`[${k}="${this.meta.id}"]`);t.length===1?a.off(this.element,"click",()=>this.toggle()):t.forEach(e=>a.off(e,"click",()=>this.toggle()))}onDestroy(){this.destroyEvents()}init(){this.updateTriggerElement(),this.updateCollapsibleElement(),this.initEvents(),this.state.init=!0}}y(Z);const Dt="dropdown",Jt=`${Dt}`,I=`.${Jt}`,te=`hide${I}`,ee=`hidden${I}`,ie=`show${I}`,se=`shown${I}`,re="aria-expanded",ne="aria-controls",oe="DropdownWrapper",ae="is-expanded",le="is-open";class he extends f{constructor(t,e){super(t,e),this.autoCloseHandler=i=>{const r=this.target&&Ft(this.target,i);i.target&&r&&this.hide()},this.target=h.findOne(`${this.element.dataset.spiritTarget}`),this.reference=this.findReferenceElement(),this.state={open:!1},this.options={autoClose:!0}}static get NAME(){return Dt}getOptions(){var r;const t={...this.options},e=(r=this.element)==null?void 0:r.dataset,i=e==null?void 0:e.spiritAutoclose;return i&&(t.autoClose=!i),t}findReferenceElement(){let t=this.element;const{reference:e}=this.element.dataset;return e&&(e==="parent"&&this.element.parentElement&&this.element.parentElement.classList.contains(oe)?t=this.element.parentElement:e.match(/(#)/g)&&(t=h.findOne(e))),t}updateTriggerElement(t=this.state.open){this.element.classList.toggle(ae,t),this.element.setAttribute(re,t),this.element.setAttribute(ne,this.element.dataset.spiritTarget)}updateTargetElement(t=this.state.open){var e;(e=this.target)==null||e.classList.toggle(le,t)}show(){this.state.open=!0,this.target&&a.trigger(this.target,ie),this.updateTriggerElement(),this.updateTargetElement(),setTimeout(()=>{this.target&&a.trigger(this.target,se),this.getOptions().autoClose&&a.on(document,"click",this.autoCloseHandler)},0)}hide(){this.state.open=!1,this.target&&a.trigger(this.target,te),this.updateTriggerElement(),this.updateTargetElement(),a.off(document,"click",this.autoCloseHandler),setTimeout(()=>{this.target&&a.trigger(this.target,ee)},0)}toggle(){this.state.open?this.hide():this.show()}}S(he,"toggle","trigger");const Ct="fileUploader",w=`.${Ct}`,ce=`queueFile${w}`,de=`queuedFile${w}`,ue=`unqueueFile${w}`,pe=`unqueuedFile${w}`,B=`error${w}`,ge="has-drag-and-drop",ot="is-dragging",Ee="d-none",fe="is-disabled",at="has-danger",me='[data-spirit-element="wrapper"]',Ae='[data-spirit-element="input"]',Te='[data-spirit-element="list"]',Ne='[data-spirit-element="dropZone"]',Se='[data-spirit-snippet="item"]',T="data-spirit-populate-field",lt='[data-spirit-element="attachment-image"]',ht="data-spirit-dismiss",_t="validation_text",ct=`[data-spirit-element="${_t}"]`,we=1e7,Le=10,D={errorMaxFileSize:"The file size limit has been exceeded",errorFileDuplicity:"This file already exists in the queue",errorMaxUploadedFiles:"You have exceeded the number of files allowed in the queue",errorFileNotSupported:"is not a supported file. Please ensure you are uploading a supported file format."},De=54,Ce=500,bt=class N extends f{constructor(t,e){var i,r,n,o,l,c,E,p,u,d;super(t,e),this.wrapper=h.findOne(me,t),this.inputElement=h.findOne(Ae,t),this.listElement=h.findOne(Te,t),this.dropZone=h.findOne(Ne,t),this.isDragAndDropSupported="draggable"in document.createElement("span"),this.fileSizeLimit=(i=this.wrapper)!=null&&i.dataset.spiritMaxFileSize?Number((r=this.wrapper)==null?void 0:r.dataset.spiritMaxFileSize):we,this.fileQueueLimit=(n=this.wrapper)!=null&&n.dataset.spiritFileQueueLimit?Number((o=this.wrapper)==null?void 0:o.dataset.spiritFileQueueLimit):Le,this.queueLimitBehavior=(l=this.wrapper)!=null&&l.dataset.spiritQueueLimitBehavior?(c=this.wrapper)==null?void 0:c.dataset.spiritQueueLimitBehavior:"none",this.errors={},this.errors.errorMaxFileSize=this.element.dataset.spiritMessageMaxfilesize??D.errorMaxFileSize,this.errors.errorFileDuplicity=this.element.dataset.spiritMessageDuplicity??D.errorFileDuplicity,this.errors.errorMaxUploadedFiles=this.element.dataset.spiritMessageMaxuploadedfiles??D.errorMaxUploadedFiles,this.errors.errorFileNotSupported=this.element.dataset.spiritMessageUnsupported??D.errorFileNotSupported,this.inputName=((E=this.inputElement)==null?void 0:E.name)||"attachment",this.isMultiple=(p=this.inputElement)==null?void 0:p.multiple,this.accept=(u=this.inputElement)==null?void 0:u.accept,this.isDragging=!1,this.fileQueue=new Map,this.instanceUid=N.getUid(),this.isDisabled=((d=this.inputElement)==null?void 0:d.disabled)||!1,this.init()}static get NAME(){return Ct}get getFileQueue(){return this.fileQueue}clearFileQueue(){var t;for(this.fileQueue.clear();(t=this.listElement)!=null&&t.firstChild;)this.listElement.removeChild(this.listElement.firstChild)}static getUid(){return Math.random().toString(36).slice(-6)}getUpdatedFileName(t){return`file_${this.instanceUid}_${t.replace(/[^a-zA-Z0-9]/g,"")}`}dragReset(){var t;this.isDragging=!1,(t=this.wrapper)==null||t.classList.remove(ot)}checkAllowedFileSize(t){if(t.size>this.fileSizeLimit)throw new Error(`${t.name}: ${this.errors.errorMaxFileSize}`)}checkFileQueueDuplicity(t){if(this.fileQueue.has(this.getUpdatedFileName(t.name)))throw new Error(`${t.name}: ${this.errors.errorFileDuplicity}`)}checkQueueLimit(){if(this.fileQueue.size>=this.fileQueueLimit)throw new Error(this.errors.errorMaxUploadedFiles)}checkAllowedFileType(t){var o,l;const e=(o=t.name.split(".").pop())==null?void 0:o.toLowerCase(),i=t.type;let r;if(!!(this.accept===""||this.accept==="*"||this.accept==="*/*"))r=!0;else{const c=(l=this.accept)==null?void 0:l.replace(/ /g,"").split(","),E=c==null?void 0:c.filter(u=>u.match(/\./g)),p=c==null?void 0:c.filter(u=>u.match(/\//g));E==null||E.forEach(u=>{const d=u.replace(".","").replace("*","");e.match(d)&&(r=!0)}),p==null||p.forEach(u=>{const d=u.replace("*","");i.match(d)&&(r=!0)})}if(!r)throw new Error(`${t.name}: ${this.errors.errorFileNotSupported}`)}updateNameAttribute(){var t,e;this.fileQueue.size>0?(t=this.inputElement)==null||t.removeAttribute("name"):(e=this.inputElement)==null||e.setAttribute("name",this.inputName)}updateDropZoneVisibility(){if(this.queueLimitBehavior==="none")return;const t=this.queueLimitBehavior==="hide"?Ee:fe;setTimeout(()=>{var e;(e=this.wrapper)==null||e.classList.toggle(t,this.fileQueue.size===this.fileQueueLimit),this.inputElement.disabled=this.fileQueue.size===this.fileQueueLimit},0)}createAttachmentElement(){const t=document.createElement("input");return t.setAttribute("type","file"),t.setAttribute("name",`${this.inputName}[]`),t.setAttribute("hidden",""),t}static createValidationTextElement(){const t=document.createElement("ul");return t.dataset.spiritElement=_t,t}static isValidationTextInElement(t,e){const i=e.getElementsByTagName("li");return!!Array.from(i).filter(n=>{var o;return(o=n.textContent)==null?void 0:o.includes(t)}).length}getValidationTextElement(t){const e=document.createElement("li");e.appendChild(document.createTextNode(t));let i=h.findOne(ct,this.wrapper);return i||(i=N.createValidationTextElement()),!N.isValidationTextInElement(t,i)&&i.appendChild(e),i}getAttachmentElement(t,e){var L,q;const i=h.findOne(Se,this.element),r=i==null?void 0:i.content.cloneNode(!0);if(!r)return null;const n=new DataTransfer;n.items.add(t);const o=this.createAttachmentElement();o.files=n.files;const l=r.querySelector(`[${T}="item"]`),c=r.querySelector(`[${T}="name"]`),E=r.querySelector(`[${T}="button"]`),p=!!((L=l==null?void 0:l.dataset)!=null&&L.spiritImagepreview),u=l==null?void 0:l.querySelector("svg"),d=l==null?void 0:l.querySelector(lt),x=t.type.includes("image");return p&&x?(u==null||u.remove(),(q=d==null?void 0:d.querySelector("img"))==null||q.setAttribute("alt",t.name),Qt(t,Ce,$t=>{var j;return(j=d==null?void 0:d.querySelector("img"))==null?void 0:j.setAttribute("src",$t)})):d==null||d.remove(),l.appendChild(o),l.setAttribute("id",e),c.appendChild(document.createTextNode(t.name)),E.setAttribute(ht,e),l.removeAttribute(T),c.removeAttribute(T),E.removeAttribute(T),r.children.item(0)}createAttachmentEvents(t){const e=h.findOne(`[${ht}="${t}"]`);e&&a.on(e,"click",i=>{var n,o;i.preventDefault();const r=(o=(n=i.target)==null?void 0:n.dataset)==null?void 0:o.spiritDismiss;r&&this.removeFromQueue(r)})}appendToList(t,e){if(!this.listElement)return;this.isMultiple||this.clearFileQueue();const i=this.getUpdatedFileName(t.name),r=this.getAttachmentElement(t,i);if(!r)return;const n={file:t};e&&(n.meta=e),this.fileQueue.set(i,n),this.listElement.appendChild(r),this.createAttachmentEvents(i),this.dragReset()}addToQueue(t,e,i){try{a.trigger(this.wrapper,ce,{fileQueue:this.fileQueue,currentFile:t}),this.checkAllowedFileType(t),this.checkAllowedFileSize(t),this.checkFileQueueDuplicity(t),this.checkQueueLimit(),this.appendToList(t,e),this.updateDropZoneVisibility(),this.updateNameAttribute(),i&&i(this.getUpdatedFileName(t.name),t,e),a.trigger(this.wrapper,de,{fileQueue:this.fileQueue,currentFile:t})}catch(r){a.trigger(this.wrapper,B,{validationText:r.message})}}updateQueue(t,e,i,r){if(this.fileQueue.has(t)){const n={file:e};i&&(n.meta=i),this.fileQueue.set(t,n);const o=h.findOne(`#${t} ${lt} img`);if(i&&o&&N.isCoordsInMeta(i)){const l=De,c=parseInt(i.cropWidth,10),E=parseInt(i.cropHeight,10);let p;E>c?p=l/c:p=l/E;const u=Math.round(parseInt(i.x,10)*p),d=Math.round(parseInt(i.y,10)*p),x=Math.round(parseInt(i.originalWidth,10)*p),L=Math.round(parseInt(i.originalHeight,10)*p);o==null||o.style.setProperty("--file-uploader-attachment-image-top",`-${d}px`),o==null||o.style.setProperty("--file-uploader-attachment-image-left",`-${u}px`),o==null||o.style.setProperty("--file-uploader-attachment-image-width",`${x}px`),o==null||o.style.setProperty("--file-uploader-attachment-image-height",`${L}px`)}r&&r(t,e,i)}}removeFromQueue(t,e){if(this.fileQueue.has(t)){a.trigger(this.wrapper,ue,{fileQueue:this.fileQueue,currentFile:t});const i=h.findOne(`#${t}`);this.fileQueue.delete(t),i==null||i.remove(),this.updateDropZoneVisibility(),this.updateNameAttribute(),this.removeValidationWError(),e&&e(t),a.trigger(this.wrapper,pe,{fileQueue:this.fileQueue,currentFile:t})}}getFileFromQueue(t){return this.fileQueue.get(t)}onChange(t,e){const{target:i}=t,r=i.files?[...i.files]:[];let n=0,o;n+=this.fileQueue.size,r.forEach(l=>{n{i.value="",i.blur()},0)}static onDragOver(t){t.preventDefault()}onDragEnter(){var t;this.isDragging=!0,(t=this.wrapper)==null||t.classList.add(ot)}onDragLeave(){this.dragReset()}onDrop(t){var r,n,o;if(t.preventDefault(),this.isDisabled)return;const e=Array.from(((r=t==null?void 0:t.dataTransfer)==null?void 0:r.items)||[]),i=Array.from(((n=t==null?void 0:t.dataTransfer)==null?void 0:n.files)||[]);!this.isMultiple&&(e.length>1||i.length>1),(o=t==null?void 0:t.dataTransfer)!=null&&o.items?e.forEach(l=>{if(l.kind==="file"){const c=l.getAsFile();c&&this.addToQueue(c)}}):i.forEach(l=>{this.addToQueue(l)})}removeValidationWError(){var t;(t=h.findOne(ct,this.wrapper))==null||t.remove(),this.wrapper.classList.remove(at)}onClick(){this.removeValidationWError()}onValidationError(t){this.wrapper.classList.add(at),this.wrapper.append(this.getValidationTextElement(t.validationText))}addEventListeners(){a.on(this.inputElement,"click",this.onClick.bind(this)),a.on(this.inputElement,"change",this.onChange.bind(this)),a.on(this.wrapper,B,this.onValidationError.bind(this)),this.isDragAndDropSupported&&this.dropZone&&(a.on(this.dropZone,"dragover",N.onDragOver.bind(this)),a.on(this.dropZone,"dragenter",this.onDragEnter.bind(this)),a.on(this.dropZone,"dragleave",this.onDragLeave.bind(this)),a.on(this.dropZone,"drop",this.onDrop.bind(this)))}init(){var t;this.addEventListeners(),this.isDragAndDropSupported&&((t=this.wrapper)==null||t.classList.add(ge))}};bt.isCoordsInMeta=s=>["x","y","cropWidth","cropHeight","originalWidth","originalHeight"].every(t=>s[t]!=null);let _e=bt;y(_e);const be="modal",dt='[data-spirit-toggle="modal"]';class Oe extends f{constructor(t,e){super(t,e),this.isShown=!1,this.isTouchDevice="ontouchstart"in window||navigator.maxTouchPoints>0,this.scrollControl=new Lt(t)}static get NAME(){return be}onClick(t){(t.target===this.element||t.target.dataset.spiritDismiss)&&(t.preventDefault(),t.stopPropagation(),(!t.target.dataset.spiritCloseOnBackdropClick||t.target.dataset.spiritCloseOnBackdropClick==="true")&&this.hide(t))}onDialogClose(t){t.defaultPrevented||(this.hide(t),t.preventDefault())}addEventListeners(){a.on(this.element,"close",t=>this.onDialogClose(t)),this.isTouchDevice?a.on(window,"touchstart",t=>this.onClick(t)):a.on(window,"click",t=>this.onClick(t))}removeEventListeners(){a.off(this.element,"close",t=>this.onDialogClose(t)),this.isTouchDevice?a.off(window,"touchstart",t=>this.onClick(t)):a.off(window,"click",t=>this.onClick(t))}show(){var e;if(this.isShown)return;const t=h.findOne(dt,this.element);t==null||t.setAttribute("aria-expanded","true"),(e=this.element)==null||e.showModal(),this.addEventListeners(),this.isShown=!0,this.scrollControl.disableScroll()}hide(t){var r;let e;(r=t==null?void 0:t.target)!=null&&r.dataset?t.target.dataset.spiritTarget?e=h.findOne(t.target.dataset.spiritTarget):e=t.target:e=this.element;const i=h.findOne(dt,this.element);typeof e.close=="function"&&e.close(),i==null||i.setAttribute("aria-expanded","false"),this.removeEventListeners(),this.isShown=!1,this.scrollControl.enableScroll()}toggle(t,e){if(!t){console.warn('👻 Boo…! Target modal pane does not exist. Maybe you forgot to prefix the "data-spirit-target" selector with "#"? ');return}this.isShown?this.hide(e):this.show()}}S(Oe);const ye=0,$e="768px",Ie="1280px",Me={mobile:ye,tablet:$e,desktop:Ie},ve="offcanvas",Re="offcanvas",M=`.${Re}`,xe=`show${M}`,Pe=`shown${M}`,Fe=`hide${M}`,Ve=`hidden${M}`,He=parseInt(Me.desktop,10),ut="is-open",Qe="--spirit-breakpoint-desktop",Ue={breakpointDesktop:He},ke={breakpointDesktop:"number"};class Ot extends f{constructor(t,e){const i=t;super(i,e),this.isShown=!1,this.scrollControl=new Lt(t),this.breakpoint=this.getBreakpoint()}static get Default(){return Ue}static get DefaultType(){return ke}static get NAME(){return ve}getBreakpoint(){var t;return parseInt(getComputedStyle(document.documentElement).getPropertyValue(Qe),10)||((t=this.config)==null?void 0:t.breakpointDesktop)}onClick(t){(t.target===this.element||t.target.dataset.spiritDismiss)&&(t.preventDefault(),t.stopPropagation(),this.hide())}onWindowResize(t){t.target.innerWidth>=this.breakpoint&&this.hide()}onDialogClose(t){t.defaultPrevented||(this.hide(),t.preventDefault())}addEventListeners(){a.on(this.element,"close",t=>this.onDialogClose(t)),a.on(window,"resize",t=>this.onWindowResize(t)),a.on(window,"click",t=>this.onClick(t))}removeEventListeners(){a.off(this.element,"close",t=>this.onDialogClose(t)),a.off(window,"resize",t=>this.onWindowResize(t)),a.off(window,"click",t=>this.onClick(t))}show(t){if(this.isShown)return;const e=a.trigger(this.element,xe,{relatedTarget:t});e!=null&&e.defaultPrevented||(this.element.classList.add(ut),this.element.showModal(),t.setAttribute("aria-expanded","true"),this.element.setAttribute("aria-modal","true"),this.element.setAttribute("role","dialog"),this.addEventListeners(),this.isShown=!0,a.trigger(this.element,Pe,{relatedTarget:t}),this.scrollControl.disableScroll())}hide(){if(!this.isShown)return;const t=a.trigger(this.element,Fe);t!=null&&t.defaultPrevented||(this.element.classList.remove(ut),this.element.close(),this.element.removeAttribute("aria-modal"),this.element.removeAttribute("role"),this.removeEventListeners(),this.isShown=!1,a.trigger(this.element,Ve),this.scrollControl.enableScroll())}toggle(t){if(!t){console.warn('👻 Boo…! Target dialog does not exist. Maybe you forgot to prefix the "data-spirit-target" selector with "#"? ');return}this.isShown?this.hide():this.show(t)}}S(Ot);wt(Ot,"hide");const Be="password",pt="aria-pressed",gt="aria-label",Et="input";class We extends f{constructor(t,e){super(t,e),this.isShown=!1}static get NAME(){return Be}show(t){var e;t.setAttribute(pt,"true"),t.setAttribute(gt,"Hide password"),(e=h.findOne(Et,t.parentElement))==null||e.setAttribute("type","text"),this.isShown=!0}hide(t){var e;t.setAttribute(pt,"false"),t.setAttribute(gt,"Show password"),(e=h.findOne(Et,t.parentElement))==null||e.setAttribute("type","password"),this.isShown=!1}toggle(t){this.isShown?this.hide(t):this.show(t)}}S(We,"toggle","trigger");const C={LEFT:"left",RIGHT:"right",TOP:"top",BOTTOM:"bottom"},K={HORIZONTAL:"horizontal",VERTICAL:"vertical"},ze="scrollView",ft=50,Ye=K.VERTICAL,Ke='[data-spirit-element="viewport"]',Ge='[data-spirit-element="content"]',mt="is-scrolled-at-start",At="is-scrolled-at-end",Ze="resize",qe="scroll",Tt=1;class je extends f{constructor(t,e){var i;super(t,e),this.getElementsPositionDifference=()=>{const r=this.content.getBoundingClientRect(),n=this.viewport.getBoundingClientRect();return{bottom:r.bottom-n.bottom,left:r.left-n.left,right:r.right-n.right,top:r.top-n.top}},this.handleScrollViewState=()=>{this.currentPosition=this.getElementsPositionDifference();const r=this.currentPosition[this.scrollPositionStart]<=-1*Tt,n=this.currentPosition[this.scrollPositionEnd]>=Tt;r!==this.isScrolledAtStart&&(this.isScrolledAtStart=r),n!==this.isScrolledAtEnd&&(this.isScrolledAtEnd=n),r?this.element.classList.add(mt):this.element.classList.remove(mt),n?this.element.classList.add(At):this.element.classList.remove(At)},this.currentPosition={bottom:0,left:0,right:0,top:0},this.direction=(i=this.element.dataset)!=null&&i.spiritDirection?String(this.element.dataset.spiritDirection):Ye,this.content=h.findOne(Ge,this.element),this.viewport=h.findOne(Ke,this.element),this.scrollPositionStart=this.direction===K.HORIZONTAL?C.LEFT:C.TOP,this.scrollPositionEnd=this.direction===K.HORIZONTAL?C.RIGHT:C.BOTTOM,this.isScrolledAtStart=!1,this.isScrolledAtEnd=!1,this.init()}static get NAME(){return ze}static get DATA_KEY(){return`${this.NAME}`}addEventListeners(){a.on(this.viewport,qe,tt(this.handleScrollViewState,ft)),a.on(window,Ze,tt(this.handleScrollViewState,ft))}init(){this.addEventListeners(),this.handleScrollViewState()}}y(je);const yt="tabs",Xe="tabs",v=`.${Xe}`,Je=`hide${v}`,ti=`hidden${v}`,ei=`show${v}`,ii=`shown${v}`,W="is-selected",si='[role="tablist"]',ri='[role="presentation"]',ni='[role="tab"]',oi=`[data-spirit-toggle="${yt}"]`,z=`${ni}, ${oi}`;class g extends f{constructor(t,e){super(t,e),this.parent=this.element.closest(si),this.parent&&g.setInitialAttributes(this.parent,this.getChildren())}static get NAME(){return yt}show(){const t=this.element;if(g.isElementActive(t))return;const e=this.getActiveElem(),i=e?a.trigger(e,Je,{relatedTarget:t}):null;a.trigger(t,ei,{relatedTarget:e}).defaultPrevented||i&&i.defaultPrevented||(this.deactivate(e,t),this.activate(t,e))}activate(t,e){t&&(t.classList.add(W),this.activate(F(t)),t.removeAttribute("tabindex"),t.setAttribute("aria-selected","true"),a.trigger(t,ii,{relatedTarget:e}))}deactivate(t,e){t&&(t.classList.remove(W),this.deactivate(F(t)),t.setAttribute("aria-selected","false"),t.setAttribute("tabindex","-1"),a.trigger(t,ti,{relatedTarget:e}))}getChildren(){return h.findAll(z,this.parent)}getActiveElem(){return this.getChildren().find(t=>g.isElementActive(t))||null}static setInitialAttributes(t,e){g.setAttributeIfNotExists(t,"role","tablist");for(const i of e)g.setInitialAttributesOnChild(i)}static setInitialAttributesOnChild(t){const e=g.getInnerElement(t),i=g.isElementActive(e),r=g.getOuterElement(e);e==null||e.setAttribute("aria-selected",i.toString()),r!==e&&g.setAttributeIfNotExists(r,"role","presentation"),e&&!i&&e.setAttribute("tabindex","-1"),g.setAttributeIfNotExists(e,"role","tab"),g.setInitialAttributesOnTargetPanel(e)}static setInitialAttributesOnTargetPanel(t){const e=F(t);e&&(g.setAttributeIfNotExists(e,"role","tabpanel"),t!=null&&t.id&&g.setAttributeIfNotExists(e,"aria-labelledby",`#${t.id}`))}static setAttributeIfNotExists(t,e,i){t&&!t.hasAttribute(e)&&t.setAttribute(e,i)}static isElementActive(t){return t!==null&&t.classList.contains(W)}static getInnerElement(t){return t!=null&&t.matches(z)?t:h.findOne(z,t)}static getOuterElement(t){return(t==null?void 0:t.closest(ri))||t}}S(g,"show","trigger");const ai="tooltip",li="tooltip",R=`.${li}`,hi=`hide${R}`,ci=`hidden${R}`,di=`show${R}`,ui=`shown${R}`,pi="is-visible",Y="is-hidden";class A extends f{constructor(t,e){super(t,e),this.tip=this.getTipElement()}static get NAME(){return ai}toggle(){this.isShown()?this.hide():this.show()}show(){var e,i;if(((i=(e=this.element)==null?void 0:e.style)==null?void 0:i.display)==="none")throw new Error("Please use show on elements without `display: none`");if(!a.trigger(this.element,A.eventName(di)).defaultPrevented){if(this.element.setAttribute("aria-describedby",this.tip.getAttribute("id")),this.tip.classList.remove(Y),"ontouchstart"in document.documentElement)for(const r of[].concat(...document.body.children))a.on(r,"mouseover",null);a.trigger(this.element,A.eventName(ui))}}hide(){if(!(!this.isShown()||a.trigger(this.element,A.eventName(hi)).defaultPrevented)){if(this.tip.classList.add(Y),"ontouchstart"in document.documentElement)for(const e of[].concat(...document.body.children))a.off(e,"mouseover",null);this.element.removeAttribute("aria-describedby"),a.trigger(this.element,A.eventName(ci))}}isShown(){var t,e;return this.tip&&(((t=this.tip.classList)==null?void 0:t.contains(pi))||!((e=this.tip.classList)!=null&&e.contains(Y)))}getTipElement(){var t,e,i;return this.tip||(this.tip=h.findOne((e=(t=this.element)==null?void 0:t.dataset)==null?void 0:e.spiritTarget)||this.element||((i=this.element)==null?void 0:i.parentElement)),this.tip}}S(A,"toggle");wt(A,"hide");export{_e as F,Oe as M,A as T}; +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function e(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function i(r){if(r.ep)return;r.ep=!0;const n=e(r);fetch(r.href,n)}})();const m=new Map,P={set(s,t,e){m.has(s)||m.set(s,new Map);const i=m.get(s);if(!i.has(t)&&i.size!==0){console.error(`Spirit do not allow more than one instance per element. Bound instance: ${Array.from(i.keys())[0]}.`);return}i.set(t,e)},get(s,t){return m.has(s)&&m.get(s).get(t)||null},remove(s,t){if(!m.has(s))return;const e=m.get(s);e.delete(t),e.size===0&&m.delete(s)}},It=(s,t,e)=>{s&&s.addEventListener(t,e,{passive:!1})},Mt=(s,t,e)=>s.removeEventListener(t,e),a={on(s,t,e){It(s,t,e)},off(s,t,e){Mt(s,t,e)},trigger(s,t,e){if(typeof t!="string"||!s)return null;const i=!0,r=new Event(t,{bubbles:i,cancelable:!0});if(typeof e<"u")for(const n of Object.keys(e))Object.defineProperty(r,n,{get(){return e[n]}});return s.dispatchEvent(r),r}},h={findAll(s,t=document.documentElement){return[].concat(...Element.prototype.querySelectorAll.call(t,s))},findOne(s,t=document.documentElement){return Element.prototype.querySelector.call(t,s)}},_=s=>!s||typeof s!="object"?!1:typeof s.nodeType<"u",O=s=>_(s)?s:typeof s=="string"&&s.length>0?document.querySelector(s):null,vt=(s,t="target")=>{var r;const e=s,i=(r=e==null?void 0:e.dataset)!=null&&r.spiritTarget?O(s.dataset.spiritTarget):null;return t==="target"?i:e},Rt=s=>s==null?void 0:s.getAttribute("data-spirit-target"),F=s=>{const t=Rt(s);return t?document.querySelector(t):null},Nt="data-spirit-toggle",xt="data-spirit-dismiss",St=(s,t,e,i,r="target")=>{a.on(s,"click",function(){const o=vt(O(this),r);t.getOrCreateInstance(o)[e](o,i)})},Pt=(s,t)=>{t.getOrCreateInstance(s)},G=(s,t,e,i="toggle",r="target")=>{const n=t.NAME;a.on(window,"DOMContentLoaded",o=>{h.findAll(`[${s}="${n}"]`).forEach(l=>{e(l,t,i,o,r)})})},S=(s,t="toggle",e="target")=>{G(Nt,s,St,t,e)},wt=(s,t="dismiss",e="target")=>{G(xt,s,St,t,e)},$=(s,t="toggle")=>{G(Nt,s,Pt,t)},Ft=(s,t)=>!t.composedPath().includes(s);function X(s){if(s==="true")return!0;if(s==="false")return!1;if(s===Number(s).toString())return Number(s);if(s===""||s==="null")return null;if(typeof s!="string")return s;try{return JSON.parse(decodeURIComponent(s))}catch{return s}}function V(s){return s.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}const J={setDataAttribute(s,t,e){s.setAttribute(`data-spirit-${V(t)}`,e)},removeDataAttribute(s,t){s.removeAttribute(`data-spirit-${V(t)}`)},getDataAttributes(s){if(!s)return{};const t={},e=Object.keys(s.dataset).filter(i=>i.startsWith("spirit")&&!i.startsWith("spiritConfig"));for(const i of e){let r=i.replace(/^spirit/,"");r=r.charAt(0).toLowerCase()+r.slice(1,r.length),t[r]=X(s.dataset[i])}return t},getDataAttribute(s,t){return X(s.getAttribute(`data-spirit-${V(t)}`))}},Vt=s=>s==null?`${s}`:Object.prototype.toString.call(s).match(/\s([a-z]+)/i)[1].toLowerCase();class Ht{static get Default(){return{}}static get DefaultType(){return{}}static get NAME(){throw new Error('You have to implement the static method "NAME", for each component!')}getConfig(t){const e=this.mergeConfigObj(t);return this.typeCheckConfig(e),e}mergeConfigObj(t,e){const i=_(e)?J.getDataAttribute(e,"config"):{};return{...this.constructor.Default,...typeof i=="object"?i:{},..._(e)?J.getDataAttributes(e):{},...typeof t=="object"?t:{}}}typeCheckConfig(t,e=this.constructor.DefaultType){for(const[i,r]of Object.entries(e)){const n=t==null?void 0:t[i],o=_(n)?"element":Vt(n);if(!new RegExp(r).test(o))throw new TypeError(`${this.constructor.NAME.toUpperCase()}: Option "${i}" provided type "${o}" but expected type "${r}".`)}}}const tt=(s,t)=>{let e,i=!1;return r=>{i||(i=!0,e&&clearTimeout(e),e=setTimeout(()=>{s(r),i=!1},t))}},Qt=(s,t,e)=>{const i=new FileReader;i.onload=r=>{const n=new Image;n.onload=()=>{const o=document.createElement("canvas"),l=o.getContext("2d");o.width=t,o.height=n.height/n.width*t,l==null||l.drawImage(n,0,0,o.width,o.height);const c=o.toDataURL("image/jpeg",.8);e(c)},r.target&&r.target.result&&(n.src=r.target.result.toString())},i.readAsDataURL(s)},Ut=s=>{a.trigger(s,"transitionend")},kt=s=>{if(!s)return 0;let{transitionDuration:t,transitionDelay:e}=window.getComputedStyle(s);const i=Number.parseFloat(t),r=Number.parseFloat(e);return!i&&!r?0:([t]=t.split(","),[e]=e.split(","),(Number.parseFloat(t)+Number.parseFloat(e))*1e3)},et=(s,t=[],e=s)=>typeof s=="function"?s(...t):e,b=(s,t,e=!0)=>{if(!e){et(t);return}const i=5,r=kt(s)+i;let n=!1;const o=l=>{l.target===s&&(n=!0,s.removeEventListener("transitionend",o),et(t))};s.addEventListener("transitionend",o),setTimeout(()=>{n||Ut(s)},r)},Bt="dialog[open]",H="is-scrolling-disabled";class Lt{constructor(t,e,i){this.target=t,this.element=e||document.body,this.selector=i||Bt,this.offsetY=0}disableScroll(){if(this.element.classList.contains(H))return;const e=(this.element.tagName==="BODY"?window.innerWidth:this.element.offsetWidth)-this.element.clientWidth;this.offsetY=window.scrollY,this.element.style.paddingRight=`${e}px`,this.element.style.top=`-${this.offsetY}px`,this.element.classList.add(H)}enableScroll(){const t=h.findAll(this.selector);this.target&&t.length===0&&b(this.target,()=>{this.element.style.paddingRight="",this.element.style.top="",this.element.classList.remove(H),window.scrollTo(0,this.offsetY)})}}class f extends Ht{constructor(t,e){super(),this.element=O(t),this.NAME="",this.config=this.getConfig(e),P.set(this.element,this.constructor.INSTANCE_KEY,this)}dispose(){P.remove(this.element,this.constructor.INSTANCE_KEY);for(const t of Object.getOwnPropertyNames(this))this[t]=null}getConfig(t){const e=this.mergeConfigObj(t,this.element);return this.typeCheckConfig(e),e}static get NAME(){return""}static getInstance(t){return P.get(O(t),this.INSTANCE_KEY)}static getOrCreateInstance(t,e={}){return this.getInstance(t)||this.createInstance(t,e)}static createInstance(t,e){return new this(t,typeof e=="object"?e:null)}static get INSTANCE_KEY(){return`spirit.${this.NAME}`}static get DATA_KEY(){return`${this.NAME}`}static get EVENT_KEY(){return`.${this.DATA_KEY}`}static eventName(t){return`${t}${this.EVENT_KEY}`}}const Wt="autoResize",zt="resize",Q=400;class Yt extends f{constructor(t,e){super(t,e),this.adjustHeight=()=>{const i=parseFloat(getComputedStyle(this.input).getPropertyValue("border-top-width"))||0,r=parseFloat(getComputedStyle(this.input).getPropertyValue("border-bottom-width"))||0,n=i+r;this.input.style.height="auto",this.input.style.overflow="auto";const o=this.input.scrollHeight+n;this.input.style.height=`${o{r.setAttribute(Kt,this.meta.id),r.setAttribute(U,String(t)),this.meta.hideOnCollapse&&t&&(r.remove(),this.appendNodeToParent(),this.onDestroy())};this.state.open=t,e.length===1?i(this.element):e.map(r=>i(r))}updateCollapsibleElement(t=this.state.open){var e;this.target&&(t||this.adjustCollapsibleChildrenHeight(),this.adjustCollapsibleElementHeight(t),this.state.init&&((e=this.target)==null||e.classList.add(it)),b(this.target,()=>{var i,r,n,o;(i=this.target)==null||i.classList.remove(it),(r=this.target)==null||r.classList.toggle(Zt,t),t?(n=this.target)==null||n.setAttribute("style","height: 100%"):(o=this.target)==null||o.style.removeProperty("height")}))}show(){this.hideParentSiblings(this.element),a.trigger(this.target,Xt),this.updateTriggerElement(!0),this.updateCollapsibleElement(!0),this.target&&b(this.target,()=>{a.trigger(this.target,nt)})}hide(){a.trigger(this.target,jt),this.updateTriggerElement(!1),this.updateCollapsibleElement(!1),this.target&&b(this.target,()=>{a.trigger(this.target,rt)})}toggle(){this.state.open?this.hide():this.show()}initEvents(){const t=h.findAll(`[${k}="${this.meta.id}"]`);t.length===1?a.on(this.element,"click",()=>this.toggle()):t.forEach(e=>a.on(e,"click",()=>this.toggle()))}destroyEvents(){const t=h.findAll(`[${k}="${this.meta.id}"]`);t.length===1?a.off(this.element,"click",()=>this.toggle()):t.forEach(e=>a.off(e,"click",()=>this.toggle()))}onDestroy(){this.destroyEvents()}init(){this.updateTriggerElement(),this.updateCollapsibleElement(),this.initEvents(),this.state.init=!0}}$(Z);const Dt="dropdown",Jt=`${Dt}`,I=`.${Jt}`,te=`hide${I}`,ee=`hidden${I}`,ie=`show${I}`,se=`shown${I}`,re="aria-expanded",ne="aria-controls",oe="DropdownWrapper",ae="is-expanded",le="is-open";class he extends f{constructor(t,e){super(t,e),this.autoCloseHandler=i=>{const r=this.target&&Ft(this.target,i);i.target&&r&&this.hide()},this.target=h.findOne(`${this.element.dataset.spiritTarget}`),this.reference=this.findReferenceElement(),this.state={open:!1},this.options={autoClose:!0}}static get NAME(){return Dt}getOptions(){var r;const t={...this.options},e=(r=this.element)==null?void 0:r.dataset,i=e==null?void 0:e.spiritAutoclose;return i&&(t.autoClose=!i),t}findReferenceElement(){let t=this.element;const{reference:e}=this.element.dataset;return e&&(e==="parent"&&this.element.parentElement&&this.element.parentElement.classList.contains(oe)?t=this.element.parentElement:e.match(/(#)/g)&&(t=h.findOne(e))),t}updateTriggerElement(t=this.state.open){this.element.classList.toggle(ae,t),this.element.setAttribute(re,t),this.element.setAttribute(ne,this.element.dataset.spiritTarget)}updateTargetElement(t=this.state.open){var e;(e=this.target)==null||e.classList.toggle(le,t)}show(){this.state.open=!0,this.target&&a.trigger(this.target,ie),this.updateTriggerElement(),this.updateTargetElement(),setTimeout(()=>{this.target&&a.trigger(this.target,se),this.getOptions().autoClose&&a.on(document,"click",this.autoCloseHandler)},0)}hide(){this.state.open=!1,this.target&&a.trigger(this.target,te),this.updateTriggerElement(),this.updateTargetElement(),a.off(document,"click",this.autoCloseHandler),setTimeout(()=>{this.target&&a.trigger(this.target,ee)},0)}toggle(){this.state.open?this.hide():this.show()}}S(he,"toggle","trigger");const Ct="fileUploader",w=`.${Ct}`,ce=`queueFile${w}`,de=`queuedFile${w}`,ue=`unqueueFile${w}`,pe=`unqueuedFile${w}`,B=`error${w}`,ge="has-drag-and-drop",ot="is-dragging",Ee="d-none",fe="is-disabled",at="has-danger",me='[data-spirit-element="wrapper"]',Ae='[data-spirit-element="input"]',Te='[data-spirit-element="list"]',Ne='[data-spirit-element="dropZone"]',Se='[data-spirit-snippet="item"]',T="data-spirit-populate-field",lt='[data-spirit-element="attachment-image"]',ht="data-spirit-dismiss",_t="validation_text",ct=`[data-spirit-element="${_t}"]`,we=1e7,Le=10,D={errorMaxFileSize:"The file size limit has been exceeded",errorFileDuplicity:"This file already exists in the queue",errorMaxUploadedFiles:"You have exceeded the number of files allowed in the queue",errorFileNotSupported:"is not a supported file. Please ensure you are uploading a supported file format."},De=54,Ce=500,bt=class N extends f{constructor(t,e){var i,r,n,o,l,c,E,p,u,d;super(t,e),this.wrapper=h.findOne(me,t),this.inputElement=h.findOne(Ae,t),this.listElement=h.findOne(Te,t),this.dropZone=h.findOne(Ne,t),this.isDragAndDropSupported="draggable"in document.createElement("span"),this.fileSizeLimit=(i=this.wrapper)!=null&&i.dataset.spiritMaxFileSize?Number((r=this.wrapper)==null?void 0:r.dataset.spiritMaxFileSize):we,this.fileQueueLimit=(n=this.wrapper)!=null&&n.dataset.spiritFileQueueLimit?Number((o=this.wrapper)==null?void 0:o.dataset.spiritFileQueueLimit):Le,this.queueLimitBehavior=(l=this.wrapper)!=null&&l.dataset.spiritQueueLimitBehavior?(c=this.wrapper)==null?void 0:c.dataset.spiritQueueLimitBehavior:"none",this.errors={},this.errors.errorMaxFileSize=this.element.dataset.spiritMessageMaxfilesize??D.errorMaxFileSize,this.errors.errorFileDuplicity=this.element.dataset.spiritMessageDuplicity??D.errorFileDuplicity,this.errors.errorMaxUploadedFiles=this.element.dataset.spiritMessageMaxuploadedfiles??D.errorMaxUploadedFiles,this.errors.errorFileNotSupported=this.element.dataset.spiritMessageUnsupported??D.errorFileNotSupported,this.inputName=((E=this.inputElement)==null?void 0:E.name)||"attachment",this.isMultiple=(p=this.inputElement)==null?void 0:p.multiple,this.accept=(u=this.inputElement)==null?void 0:u.accept,this.isDragging=!1,this.fileQueue=new Map,this.instanceUid=N.getUid(),this.isDisabled=((d=this.inputElement)==null?void 0:d.disabled)||!1,this.init()}static get NAME(){return Ct}get getFileQueue(){return this.fileQueue}clearFileQueue(){var t;for(this.fileQueue.clear();(t=this.listElement)!=null&&t.firstChild;)this.listElement.removeChild(this.listElement.firstChild)}static getUid(){return Math.random().toString(36).slice(-6)}getUpdatedFileName(t){return`file_${this.instanceUid}_${t.replace(/[^a-zA-Z0-9]/g,"")}`}dragReset(){var t;this.isDragging=!1,(t=this.wrapper)==null||t.classList.remove(ot)}checkAllowedFileSize(t){if(t.size>this.fileSizeLimit)throw new Error(`${t.name}: ${this.errors.errorMaxFileSize}`)}checkFileQueueDuplicity(t){if(this.fileQueue.has(this.getUpdatedFileName(t.name)))throw new Error(`${t.name}: ${this.errors.errorFileDuplicity}`)}checkQueueLimit(){if(this.fileQueue.size>=this.fileQueueLimit)throw new Error(this.errors.errorMaxUploadedFiles)}checkAllowedFileType(t){var o,l;const e=(o=t.name.split(".").pop())==null?void 0:o.toLowerCase(),i=t.type;let r;if(!!(this.accept===""||this.accept==="*"||this.accept==="*/*"))r=!0;else{const c=(l=this.accept)==null?void 0:l.replace(/ /g,"").split(","),E=c==null?void 0:c.filter(u=>u.match(/\./g)),p=c==null?void 0:c.filter(u=>u.match(/\//g));E==null||E.forEach(u=>{const d=u.replace(".","").replace("*","");e.match(d)&&(r=!0)}),p==null||p.forEach(u=>{const d=u.replace("*","");i.match(d)&&(r=!0)})}if(!r)throw new Error(`${t.name}: ${this.errors.errorFileNotSupported}`)}updateNameAttribute(){var t,e;this.fileQueue.size>0?(t=this.inputElement)==null||t.removeAttribute("name"):(e=this.inputElement)==null||e.setAttribute("name",this.inputName)}updateDropZoneVisibility(){if(this.queueLimitBehavior==="none")return;const t=this.queueLimitBehavior==="hide"?Ee:fe;setTimeout(()=>{var e;(e=this.wrapper)==null||e.classList.toggle(t,this.fileQueue.size===this.fileQueueLimit),this.inputElement.disabled=this.fileQueue.size===this.fileQueueLimit},0)}createAttachmentElement(){const t=document.createElement("input");return t.setAttribute("type","file"),t.setAttribute("name",`${this.inputName}[]`),t.setAttribute("hidden",""),t}static createValidationTextElement(){const t=document.createElement("ul");return t.dataset.spiritElement=_t,t}static isValidationTextInElement(t,e){const i=e.getElementsByTagName("li");return!!Array.from(i).filter(n=>{var o;return(o=n.textContent)==null?void 0:o.includes(t)}).length}getValidationTextElement(t){const e=document.createElement("li");e.appendChild(document.createTextNode(t));let i=h.findOne(ct,this.wrapper);return i||(i=N.createValidationTextElement()),!N.isValidationTextInElement(t,i)&&i.appendChild(e),i}getAttachmentElement(t,e){var L,q;const i=h.findOne(Se,this.element),r=i==null?void 0:i.content.cloneNode(!0);if(!r)return null;const n=new DataTransfer;n.items.add(t);const o=this.createAttachmentElement();o.files=n.files;const l=r.querySelector(`[${T}="item"]`),c=r.querySelector(`[${T}="name"]`),E=r.querySelector(`[${T}="button"]`),p=!!((L=l==null?void 0:l.dataset)!=null&&L.spiritImagepreview),u=l==null?void 0:l.querySelector("svg"),d=l==null?void 0:l.querySelector(lt),x=t.type.includes("image");return p&&x?(u==null||u.remove(),(q=d==null?void 0:d.querySelector("img"))==null||q.setAttribute("alt",t.name),Qt(t,Ce,yt=>{var j;return(j=d==null?void 0:d.querySelector("img"))==null?void 0:j.setAttribute("src",yt)})):d==null||d.remove(),l.appendChild(o),l.setAttribute("id",e),c.appendChild(document.createTextNode(t.name)),E.setAttribute(ht,e),l.removeAttribute(T),c.removeAttribute(T),E.removeAttribute(T),r.children.item(0)}createAttachmentEvents(t){const e=h.findOne(`[${ht}="${t}"]`);e&&a.on(e,"click",i=>{var n,o;i.preventDefault();const r=(o=(n=i.target)==null?void 0:n.dataset)==null?void 0:o.spiritDismiss;r&&this.removeFromQueue(r)})}appendToList(t,e){if(!this.listElement)return;this.isMultiple||this.clearFileQueue();const i=this.getUpdatedFileName(t.name),r=this.getAttachmentElement(t,i);if(!r)return;const n={file:t};e&&(n.meta=e),this.fileQueue.set(i,n),this.listElement.appendChild(r),this.createAttachmentEvents(i),this.dragReset()}addToQueue(t,e,i){try{a.trigger(this.wrapper,ce,{fileQueue:this.fileQueue,currentFile:t}),this.checkAllowedFileType(t),this.checkAllowedFileSize(t),this.checkFileQueueDuplicity(t),this.checkQueueLimit(),this.appendToList(t,e),this.updateDropZoneVisibility(),this.updateNameAttribute(),i&&i(this.getUpdatedFileName(t.name),t,e),a.trigger(this.wrapper,de,{fileQueue:this.fileQueue,currentFile:t})}catch(r){a.trigger(this.wrapper,B,{validationText:r.message})}}updateQueue(t,e,i,r){if(this.fileQueue.has(t)){const n={file:e};i&&(n.meta=i),this.fileQueue.set(t,n);const o=h.findOne(`#${t} ${lt} img`);if(i&&o&&N.isCoordsInMeta(i)){const l=De,c=parseInt(i.cropWidth,10),E=parseInt(i.cropHeight,10);let p;E>c?p=l/c:p=l/E;const u=Math.round(parseInt(i.x,10)*p),d=Math.round(parseInt(i.y,10)*p),x=Math.round(parseInt(i.originalWidth,10)*p),L=Math.round(parseInt(i.originalHeight,10)*p);o==null||o.style.setProperty("--file-uploader-attachment-image-top",`-${d}px`),o==null||o.style.setProperty("--file-uploader-attachment-image-left",`-${u}px`),o==null||o.style.setProperty("--file-uploader-attachment-image-width",`${x}px`),o==null||o.style.setProperty("--file-uploader-attachment-image-height",`${L}px`)}r&&r(t,e,i)}}removeFromQueue(t,e){if(this.fileQueue.has(t)){a.trigger(this.wrapper,ue,{fileQueue:this.fileQueue,currentFile:t});const i=h.findOne(`#${t}`);this.fileQueue.delete(t),i==null||i.remove(),this.updateDropZoneVisibility(),this.updateNameAttribute(),this.removeValidationWError(),e&&e(t),a.trigger(this.wrapper,pe,{fileQueue:this.fileQueue,currentFile:t})}}getFileFromQueue(t){return this.fileQueue.get(t)}onChange(t,e){const{target:i}=t,r=i.files?[...i.files]:[];let n=0,o;n+=this.fileQueue.size,r.forEach(l=>{n{i.value="",i.blur()},0)}static onDragOver(t){t.preventDefault()}onDragEnter(){var t;this.isDragging=!0,(t=this.wrapper)==null||t.classList.add(ot)}onDragLeave(){this.dragReset()}onDrop(t){var r,n,o;if(t.preventDefault(),this.isDisabled)return;const e=Array.from(((r=t==null?void 0:t.dataTransfer)==null?void 0:r.items)||[]),i=Array.from(((n=t==null?void 0:t.dataTransfer)==null?void 0:n.files)||[]);!this.isMultiple&&(e.length>1||i.length>1),(o=t==null?void 0:t.dataTransfer)!=null&&o.items?e.forEach(l=>{if(l.kind==="file"){const c=l.getAsFile();c&&this.addToQueue(c)}}):i.forEach(l=>{this.addToQueue(l)})}removeValidationWError(){var t;(t=h.findOne(ct,this.wrapper))==null||t.remove(),this.wrapper.classList.remove(at)}onClick(){this.removeValidationWError()}onValidationError(t){this.wrapper.classList.add(at),this.wrapper.append(this.getValidationTextElement(t.validationText))}addEventListeners(){a.on(this.inputElement,"click",this.onClick.bind(this)),a.on(this.inputElement,"change",this.onChange.bind(this)),a.on(this.wrapper,B,this.onValidationError.bind(this)),this.isDragAndDropSupported&&this.dropZone&&(a.on(this.dropZone,"dragover",N.onDragOver.bind(this)),a.on(this.dropZone,"dragenter",this.onDragEnter.bind(this)),a.on(this.dropZone,"dragleave",this.onDragLeave.bind(this)),a.on(this.dropZone,"drop",this.onDrop.bind(this)))}init(){var t;this.addEventListeners(),this.isDragAndDropSupported&&((t=this.wrapper)==null||t.classList.add(ge))}};bt.isCoordsInMeta=s=>["x","y","cropWidth","cropHeight","originalWidth","originalHeight"].every(t=>s[t]!=null);let _e=bt;$(_e);const be="modal",dt='[data-spirit-toggle="modal"]';class Oe extends f{constructor(t,e){super(t,e),this.isShown=!1,this.isTouchDevice="ontouchstart"in window||navigator.maxTouchPoints>0,this.scrollControl=new Lt(t)}static get NAME(){return be}onClick(t){(t.target===this.element||t.target.dataset.spiritDismiss)&&(t.preventDefault(),t.stopPropagation(),(!t.target.dataset.spiritCloseOnBackdropClick||t.target.dataset.spiritCloseOnBackdropClick==="true")&&this.hide(t))}onDialogClose(t){t.defaultPrevented||(this.hide(t),t.preventDefault())}addEventListeners(){a.on(this.element,"close",t=>this.onDialogClose(t)),this.isTouchDevice?a.on(window,"touchstart",t=>this.onClick(t)):a.on(window,"click",t=>this.onClick(t))}removeEventListeners(){a.off(this.element,"close",t=>this.onDialogClose(t)),this.isTouchDevice?a.off(window,"touchstart",t=>this.onClick(t)):a.off(window,"click",t=>this.onClick(t))}show(){var e;if(this.isShown)return;const t=h.findOne(dt,this.element);t==null||t.setAttribute("aria-expanded","true"),(e=this.element)==null||e.showModal(),this.addEventListeners(),this.isShown=!0,this.scrollControl.disableScroll()}hide(t){var r;let e;(r=t==null?void 0:t.target)!=null&&r.dataset?t.target.dataset.spiritTarget?e=h.findOne(t.target.dataset.spiritTarget):e=t.target:e=this.element;const i=h.findOne(dt,this.element);typeof e.close=="function"&&e.close(),i==null||i.setAttribute("aria-expanded","false"),this.removeEventListeners(),this.isShown=!1,this.scrollControl.enableScroll()}toggle(t,e){t&&(this.isShown?this.hide(e):this.show())}}S(Oe);const $e=0,ye="768px",Ie="1280px",Me={mobile:$e,tablet:ye,desktop:Ie},ve="offcanvas",Re="offcanvas",M=`.${Re}`,xe=`show${M}`,Pe=`shown${M}`,Fe=`hide${M}`,Ve=`hidden${M}`,He=parseInt(Me.desktop,10),ut="is-open",Qe="--spirit-breakpoint-desktop",Ue={breakpointDesktop:He},ke={breakpointDesktop:"number"};class Ot extends f{constructor(t,e){const i=t;super(i,e),this.isShown=!1,this.scrollControl=new Lt(t),this.breakpoint=this.getBreakpoint()}static get Default(){return Ue}static get DefaultType(){return ke}static get NAME(){return ve}getBreakpoint(){var t;return parseInt(getComputedStyle(document.documentElement).getPropertyValue(Qe),10)||((t=this.config)==null?void 0:t.breakpointDesktop)}onClick(t){(t.target===this.element||t.target.dataset.spiritDismiss)&&(t.preventDefault(),t.stopPropagation(),this.hide())}onWindowResize(t){t.target.innerWidth>=this.breakpoint&&this.hide()}onDialogClose(t){t.defaultPrevented||(this.hide(),t.preventDefault())}addEventListeners(){a.on(this.element,"close",t=>this.onDialogClose(t)),a.on(window,"resize",t=>this.onWindowResize(t)),a.on(window,"click",t=>this.onClick(t))}removeEventListeners(){a.off(this.element,"close",t=>this.onDialogClose(t)),a.off(window,"resize",t=>this.onWindowResize(t)),a.off(window,"click",t=>this.onClick(t))}show(t){if(this.isShown)return;const e=a.trigger(this.element,xe,{relatedTarget:t});e!=null&&e.defaultPrevented||(this.element.classList.add(ut),this.element.showModal(),t.setAttribute("aria-expanded","true"),this.element.setAttribute("aria-modal","true"),this.element.setAttribute("role","dialog"),this.addEventListeners(),this.isShown=!0,a.trigger(this.element,Pe,{relatedTarget:t}),this.scrollControl.disableScroll())}hide(){if(!this.isShown)return;const t=a.trigger(this.element,Fe);t!=null&&t.defaultPrevented||(this.element.classList.remove(ut),this.element.close(),this.element.removeAttribute("aria-modal"),this.element.removeAttribute("role"),this.removeEventListeners(),this.isShown=!1,a.trigger(this.element,Ve),this.scrollControl.enableScroll())}toggle(t){t&&(this.isShown?this.hide():this.show(t))}}S(Ot);wt(Ot,"hide");const Be="password",pt="aria-pressed",gt="aria-label",Et="input";class We extends f{constructor(t,e){super(t,e),this.isShown=!1}static get NAME(){return Be}show(t){var e;t.setAttribute(pt,"true"),t.setAttribute(gt,"Hide password"),(e=h.findOne(Et,t.parentElement))==null||e.setAttribute("type","text"),this.isShown=!0}hide(t){var e;t.setAttribute(pt,"false"),t.setAttribute(gt,"Show password"),(e=h.findOne(Et,t.parentElement))==null||e.setAttribute("type","password"),this.isShown=!1}toggle(t){this.isShown?this.hide(t):this.show(t)}}S(We,"toggle","trigger");const C={LEFT:"left",RIGHT:"right",TOP:"top",BOTTOM:"bottom"},K={HORIZONTAL:"horizontal",VERTICAL:"vertical"},ze="scrollView",ft=50,Ye=K.VERTICAL,Ke='[data-spirit-element="viewport"]',Ge='[data-spirit-element="content"]',mt="is-scrolled-at-start",At="is-scrolled-at-end",Ze="resize",qe="scroll",Tt=1;class je extends f{constructor(t,e){var i;super(t,e),this.getElementsPositionDifference=()=>{const r=this.content.getBoundingClientRect(),n=this.viewport.getBoundingClientRect();return{bottom:r.bottom-n.bottom,left:r.left-n.left,right:r.right-n.right,top:r.top-n.top}},this.handleScrollViewState=()=>{this.currentPosition=this.getElementsPositionDifference();const r=this.currentPosition[this.scrollPositionStart]<=-1*Tt,n=this.currentPosition[this.scrollPositionEnd]>=Tt;r!==this.isScrolledAtStart&&(this.isScrolledAtStart=r),n!==this.isScrolledAtEnd&&(this.isScrolledAtEnd=n),r?this.element.classList.add(mt):this.element.classList.remove(mt),n?this.element.classList.add(At):this.element.classList.remove(At)},this.currentPosition={bottom:0,left:0,right:0,top:0},this.direction=(i=this.element.dataset)!=null&&i.spiritDirection?String(this.element.dataset.spiritDirection):Ye,this.content=h.findOne(Ge,this.element),this.viewport=h.findOne(Ke,this.element),this.scrollPositionStart=this.direction===K.HORIZONTAL?C.LEFT:C.TOP,this.scrollPositionEnd=this.direction===K.HORIZONTAL?C.RIGHT:C.BOTTOM,this.isScrolledAtStart=!1,this.isScrolledAtEnd=!1,this.init()}static get NAME(){return ze}static get DATA_KEY(){return`${this.NAME}`}addEventListeners(){a.on(this.viewport,qe,tt(this.handleScrollViewState,ft)),a.on(window,Ze,tt(this.handleScrollViewState,ft))}init(){this.addEventListeners(),this.handleScrollViewState()}}$(je);const $t="tabs",Xe="tabs",v=`.${Xe}`,Je=`hide${v}`,ti=`hidden${v}`,ei=`show${v}`,ii=`shown${v}`,W="is-selected",si='[role="tablist"]',ri='[role="presentation"]',ni='[role="tab"]',oi=`[data-spirit-toggle="${$t}"]`,z=`${ni}, ${oi}`;class g extends f{constructor(t,e){super(t,e),this.parent=this.element.closest(si),this.parent&&g.setInitialAttributes(this.parent,this.getChildren())}static get NAME(){return $t}show(){const t=this.element;if(g.isElementActive(t))return;const e=this.getActiveElem(),i=e?a.trigger(e,Je,{relatedTarget:t}):null;a.trigger(t,ei,{relatedTarget:e}).defaultPrevented||i&&i.defaultPrevented||(this.deactivate(e,t),this.activate(t,e))}activate(t,e){t&&(t.classList.add(W),this.activate(F(t)),t.removeAttribute("tabindex"),t.setAttribute("aria-selected","true"),a.trigger(t,ii,{relatedTarget:e}))}deactivate(t,e){t&&(t.classList.remove(W),this.deactivate(F(t)),t.setAttribute("aria-selected","false"),t.setAttribute("tabindex","-1"),a.trigger(t,ti,{relatedTarget:e}))}getChildren(){return h.findAll(z,this.parent)}getActiveElem(){return this.getChildren().find(t=>g.isElementActive(t))||null}static setInitialAttributes(t,e){g.setAttributeIfNotExists(t,"role","tablist");for(const i of e)g.setInitialAttributesOnChild(i)}static setInitialAttributesOnChild(t){const e=g.getInnerElement(t),i=g.isElementActive(e),r=g.getOuterElement(e);e==null||e.setAttribute("aria-selected",i.toString()),r!==e&&g.setAttributeIfNotExists(r,"role","presentation"),e&&!i&&e.setAttribute("tabindex","-1"),g.setAttributeIfNotExists(e,"role","tab"),g.setInitialAttributesOnTargetPanel(e)}static setInitialAttributesOnTargetPanel(t){const e=F(t);e&&(g.setAttributeIfNotExists(e,"role","tabpanel"),t!=null&&t.id&&g.setAttributeIfNotExists(e,"aria-labelledby",`#${t.id}`))}static setAttributeIfNotExists(t,e,i){t&&!t.hasAttribute(e)&&t.setAttribute(e,i)}static isElementActive(t){return t!==null&&t.classList.contains(W)}static getInnerElement(t){return t!=null&&t.matches(z)?t:h.findOne(z,t)}static getOuterElement(t){return(t==null?void 0:t.closest(ri))||t}}S(g,"show","trigger");const ai="tooltip",li="tooltip",R=`.${li}`,hi=`hide${R}`,ci=`hidden${R}`,di=`show${R}`,ui=`shown${R}`,pi="is-visible",Y="is-hidden";class A extends f{constructor(t,e){super(t,e),this.tip=this.getTipElement()}static get NAME(){return ai}toggle(){this.isShown()?this.hide():this.show()}show(){var e,i;if(((i=(e=this.element)==null?void 0:e.style)==null?void 0:i.display)==="none")throw new Error("Please use show on elements without `display: none`");if(!a.trigger(this.element,A.eventName(di)).defaultPrevented){if(this.element.setAttribute("aria-describedby",this.tip.getAttribute("id")),this.tip.classList.remove(Y),"ontouchstart"in document.documentElement)for(const r of[].concat(...document.body.children))a.on(r,"mouseover",null);a.trigger(this.element,A.eventName(ui))}}hide(){if(!(!this.isShown()||a.trigger(this.element,A.eventName(hi)).defaultPrevented)){if(this.tip.classList.add(Y),"ontouchstart"in document.documentElement)for(const e of[].concat(...document.body.children))a.off(e,"mouseover",null);this.element.removeAttribute("aria-describedby"),a.trigger(this.element,A.eventName(ci))}}isShown(){var t,e;return this.tip&&(((t=this.tip.classList)==null?void 0:t.contains(pi))||!((e=this.tip.classList)!=null&&e.contains(Y)))}getTipElement(){var t,e,i;return this.tip||(this.tip=h.findOne((e=(t=this.element)==null?void 0:t.dataset)==null?void 0:e.spiritTarget)||this.element||((i=this.element)==null?void 0:i.parentElement)),this.tip}}S(A,"toggle");wt(A,"hide");export{_e as F,Oe as M,A as T}; diff --git a/docs/assets/spirit-web-entry.0b281737.js b/docs/assets/spirit-web-entry.66933efc.js similarity index 97% rename from docs/assets/spirit-web-entry.0b281737.js rename to docs/assets/spirit-web-entry.66933efc.js index 956a5c2295..918431e21b 100644 --- a/docs/assets/spirit-web-entry.0b281737.js +++ b/docs/assets/spirit-web-entry.66933efc.js @@ -1 +1 @@ -import{M,F as I}from"./spirit-web-chunk.0a1b4526.js";window.addEventListener("DOMContentLoaded",()=>{let t;const l=document.getElementById("example_image_preview"),s=new M(l),u=l.querySelector("[data-example-content]"),y=l.querySelector('[data-element="cancel"]'),c=document.getElementById("example_customImagePreview"),a=I.getInstance(c),m=i=>i.type.split("/")[0]==="image",h=i=>{if(m(i)){const r=new FileReader;r.readAsDataURL(i),r.onloadend=()=>{const g=r.result;localStorage.setItem("image",g),u.innerHTML=`${i.name}`,s.show()}}},p=()=>{a.removeFromQueue(a.getUpdatedFileName(t.name)),v()},v=()=>{s.hide(),u.innerHTML="",t=void 0};y.addEventListener("click",p),c.addEventListener("queuedFile.fileUploader",i=>{t=i.currentFile,h(t)})});window.addEventListener("DOMContentLoaded",()=>{let t;const l=document.getElementById("example_modal_data"),s=new M(l),u=l.querySelector("[data-example-content]"),y=l.querySelector('[data-element="cancel"]'),c=document.getElementById("example_customMetaData"),a=I.getInstance(c);let m=!1;const h=e=>e.type.split("/")[0]==="image",p=(e,d,o)=>{const n=document.querySelector("#FileUploaderListWithMetaData"),L=a.getUpdatedFileName(d.name),F=n==null?void 0:n.querySelector(`input[name="attachments_${L}_meta"]`);if(o)if(F)F.value=JSON.stringify(o);else{const f=document.createElement("input");f.setAttribute("type","hidden"),f.setAttribute("name",`attachments_${L}_meta`),f.setAttribute("value",JSON.stringify(o)),n==null||n.appendChild(f)}o||F&&F.remove()},v=e=>{var d;(d=document.querySelector(`input[name="attachments_${e}_meta"]`))==null||d.remove()},i=(e,d)=>{if(h(e)){const o=new FileReader;o.readAsDataURL(e),o.onloadend=()=>{const n=o.result;localStorage.setItem("image",n),u.innerHTML=`${e.name}`,s.show()}}a.updateQueue(a.getUpdatedFileName(e.name),e,d,p)},r=e=>{const d=e.target.closest("li").id,o=m?{x:30,y:30,cropWidth:150,cropHeight:150,originalWidth:560,originalHeight:330}:{x:22,y:0,cropWidth:110,cropHeight:100,originalWidth:560,originalHeight:330};m=!m;const n=a.getFileFromQueue(d).file;a.updateQueue(d,n,o,p)};moduleFunctions.customEdit=r;const g=()=>{a.removeFromQueue(a.getUpdatedFileName(t.name)),U()},U=()=>{s.hide(),u.innerHTML="",t=void 0};y.addEventListener("click",g),c.addEventListener("queuedFile.fileUploader",e=>{t=e.currentFile,i(t)}),c.addEventListener("unqueuedFile.fileUploader",e=>{v(e.currentFile)}),c.addEventListener("editFile.fileUploader",e=>{r(e.currentFile)})});const w=document.querySelector("#form-example"),q=document.querySelector("#example-composition"),E=I.createInstance(q);w.addEventListener("submit",t=>{t.preventDefault();const l=new FormData(w);console.log("form element",w),console.log("form data",l),console.log("file queue",E.getFileQueue),setTimeout(()=>{E.clearFileQueue(),console.log("file queue after submit",E.getFileQueue)},250)}); +import{M,F as I}from"./spirit-web-chunk.55cab3a8.js";window.addEventListener("DOMContentLoaded",()=>{let t;const l=document.getElementById("example_image_preview"),s=new M(l),u=l.querySelector("[data-example-content]"),y=l.querySelector('[data-element="cancel"]'),c=document.getElementById("example_customImagePreview"),a=I.getInstance(c),m=i=>i.type.split("/")[0]==="image",h=i=>{if(m(i)){const r=new FileReader;r.readAsDataURL(i),r.onloadend=()=>{const g=r.result;localStorage.setItem("image",g),u.innerHTML=`${i.name}`,s.show()}}},p=()=>{a.removeFromQueue(a.getUpdatedFileName(t.name)),v()},v=()=>{s.hide(),u.innerHTML="",t=void 0};y.addEventListener("click",p),c.addEventListener("queuedFile.fileUploader",i=>{t=i.currentFile,h(t)})});window.addEventListener("DOMContentLoaded",()=>{let t;const l=document.getElementById("example_modal_data"),s=new M(l),u=l.querySelector("[data-example-content]"),y=l.querySelector('[data-element="cancel"]'),c=document.getElementById("example_customMetaData"),a=I.getInstance(c);let m=!1;const h=e=>e.type.split("/")[0]==="image",p=(e,d,o)=>{const n=document.querySelector("#FileUploaderListWithMetaData"),L=a.getUpdatedFileName(d.name),F=n==null?void 0:n.querySelector(`input[name="attachments_${L}_meta"]`);if(o)if(F)F.value=JSON.stringify(o);else{const f=document.createElement("input");f.setAttribute("type","hidden"),f.setAttribute("name",`attachments_${L}_meta`),f.setAttribute("value",JSON.stringify(o)),n==null||n.appendChild(f)}o||F&&F.remove()},v=e=>{var d;(d=document.querySelector(`input[name="attachments_${e}_meta"]`))==null||d.remove()},i=(e,d)=>{if(h(e)){const o=new FileReader;o.readAsDataURL(e),o.onloadend=()=>{const n=o.result;localStorage.setItem("image",n),u.innerHTML=`${e.name}`,s.show()}}a.updateQueue(a.getUpdatedFileName(e.name),e,d,p)},r=e=>{const d=e.target.closest("li").id,o=m?{x:30,y:30,cropWidth:150,cropHeight:150,originalWidth:560,originalHeight:330}:{x:22,y:0,cropWidth:110,cropHeight:100,originalWidth:560,originalHeight:330};m=!m;const n=a.getFileFromQueue(d).file;a.updateQueue(d,n,o,p)};moduleFunctions.customEdit=r;const g=()=>{a.removeFromQueue(a.getUpdatedFileName(t.name)),U()},U=()=>{s.hide(),u.innerHTML="",t=void 0};y.addEventListener("click",g),c.addEventListener("queuedFile.fileUploader",e=>{t=e.currentFile,i(t)}),c.addEventListener("unqueuedFile.fileUploader",e=>{v(e.currentFile)}),c.addEventListener("editFile.fileUploader",e=>{r(e.currentFile)})});const w=document.querySelector("#form-example"),q=document.querySelector("#example-composition"),E=I.createInstance(q);w.addEventListener("submit",t=>{t.preventDefault();const l=new FormData(w);console.log("form element",w),console.log("form data",l),console.log("file queue",E.getFileQueue),setTimeout(()=>{E.clearFileQueue(),console.log("file queue after submit",E.getFileQueue)},250)}); diff --git a/docs/assets/spirit-web-entry.afcf2fc9.js b/docs/assets/spirit-web-entry.cb2a8db1.js similarity index 96% rename from docs/assets/spirit-web-entry.afcf2fc9.js rename to docs/assets/spirit-web-entry.cb2a8db1.js index 6308fb23c4..8284b2ef9d 100644 --- a/docs/assets/spirit-web-entry.afcf2fc9.js +++ b/docs/assets/spirit-web-entry.cb2a8db1.js @@ -1 +1 @@ -import{T as h}from"./spirit-web-chunk.0a1b4526.js";import{autoUpdate as I,computePosition as b,offset as E,flip as x,shift as v,limitShift as S,size as B,arrow as P}from"https://cdn.skypack.dev/@floating-ui/dom@1.5.3";const $=document.getElementById("my-dismissible-tooltip2"),n=new h($);window.localStorage.getItem("my-tooltip")||n.show();document.getElementById("my-dismissible-button").addEventListener("click",()=>{n.show(),window.localStorage.removeItem("my-tooltip")});document.getElementById("my-dismissible-tooltip2-button").addEventListener("click",()=>{n.hide(),window.localStorage.setItem("my-tooltip",!0)});const p=document.getElementById("my-button"),t=document.getElementById("my-advanced-tooltip"),c=document.getElementById("my-advanced-select"),a=document.getElementById("my-advanced-viewport"),O=document.getElementById("my-advanced-content"),o=t.querySelector('[data-spirit-element="arrow"]'),f=window.getComputedStyle(t),r=parseInt(f.maxWidth,10),T=parseInt(f.getPropertyValue("--tooltip-offset"),10),W=parseInt(window.getComputedStyle(o).getPropertyValue("--tooltip-arrow-corner-offset"),10);function y(){b(p,t,{placement:t.dataset.spiritPlacement,middleware:[E(T),x({crossAxis:!1}),v({limiter:S({offset:({rects:e})=>({mainAxis:e.reference.height})})}),B({apply({availableWidth:e}){Object.assign(t.style,{maxWidth:`${r{Object.assign(t.style,{top:`${g}px`,left:`${e}px`});const u=l.split("-")[0],i={top:"bottom",right:"left",bottom:"top",left:"right"}[u];if(s.arrow){const w=i==="top"||i==="bottom"?o.offsetHeight:(o.offsetHeight+o.offsetWidth)/2,{x:d,y:m}=s.arrow;Object.assign(o.style,{left:d!=null?`${d}px`:"",top:m!=null?`${m}px`:"",bottom:"",right:"",[i]:`-${w}px`})}t.dataset.spiritPlacement=l})}window.onload=()=>{a.scrollLeft=(O.offsetWidth-a.offsetWidth)/2};I(p,t,y);c.addEventListener("change",()=>{t.dataset.spiritPlacement=c.value,y()}); +import{T as h}from"./spirit-web-chunk.55cab3a8.js";import{autoUpdate as I,computePosition as b,offset as E,flip as x,shift as v,limitShift as S,size as B,arrow as P}from"https://cdn.skypack.dev/@floating-ui/dom@1.5.3";const $=document.getElementById("my-dismissible-tooltip2"),n=new h($);window.localStorage.getItem("my-tooltip")||n.show();document.getElementById("my-dismissible-button").addEventListener("click",()=>{n.show(),window.localStorage.removeItem("my-tooltip")});document.getElementById("my-dismissible-tooltip2-button").addEventListener("click",()=>{n.hide(),window.localStorage.setItem("my-tooltip",!0)});const p=document.getElementById("my-button"),t=document.getElementById("my-advanced-tooltip"),c=document.getElementById("my-advanced-select"),a=document.getElementById("my-advanced-viewport"),O=document.getElementById("my-advanced-content"),o=t.querySelector('[data-spirit-element="arrow"]'),f=window.getComputedStyle(t),r=parseInt(f.maxWidth,10),T=parseInt(f.getPropertyValue("--tooltip-offset"),10),W=parseInt(window.getComputedStyle(o).getPropertyValue("--tooltip-arrow-corner-offset"),10);function y(){b(p,t,{placement:t.dataset.spiritPlacement,middleware:[E(T),x({crossAxis:!1}),v({limiter:S({offset:({rects:e})=>({mainAxis:e.reference.height})})}),B({apply({availableWidth:e}){Object.assign(t.style,{maxWidth:`${r{Object.assign(t.style,{top:`${g}px`,left:`${e}px`});const u=l.split("-")[0],i={top:"bottom",right:"left",bottom:"top",left:"right"}[u];if(s.arrow){const w=i==="top"||i==="bottom"?o.offsetHeight:(o.offsetHeight+o.offsetWidth)/2,{x:d,y:m}=s.arrow;Object.assign(o.style,{left:d!=null?`${d}px`:"",top:m!=null?`${m}px`:"",bottom:"",right:"",[i]:`-${w}px`})}t.dataset.spiritPlacement=l})}window.onload=()=>{a.scrollLeft=(O.offsetWidth-a.offsetWidth)/2};I(p,t,y);c.addEventListener("change",()=>{t.dataset.spiritPlacement=c.value,y()}); diff --git a/docs/index.html b/docs/index.html index 3d5756928a..d177dd1811 100644 --- a/docs/index.html +++ b/docs/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/icons/index.html b/docs/src/icons/index.html index e2b69912ca..ad20039ceb 100644 --- a/docs/src/icons/index.html +++ b/docs/src/icons/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/Accordion/index.html b/docs/src/scss/components/Accordion/index.html index 299e301b73..0bbb0a7bbf 100644 --- a/docs/src/scss/components/Accordion/index.html +++ b/docs/src/scss/components/Accordion/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/Alert/index.html b/docs/src/scss/components/Alert/index.html index 523eb9e503..16f1c0a59d 100644 --- a/docs/src/scss/components/Alert/index.html +++ b/docs/src/scss/components/Alert/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/Breadcrumbs/index.html b/docs/src/scss/components/Breadcrumbs/index.html index c20829884b..d600357b41 100644 --- a/docs/src/scss/components/Breadcrumbs/index.html +++ b/docs/src/scss/components/Breadcrumbs/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/Button/index.html b/docs/src/scss/components/Button/index.html index 6c3da78170..8a31eeb509 100644 --- a/docs/src/scss/components/Button/index.html +++ b/docs/src/scss/components/Button/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/Checkbox/index.html b/docs/src/scss/components/Checkbox/index.html index 6919972e8c..22f428fe4e 100644 --- a/docs/src/scss/components/Checkbox/index.html +++ b/docs/src/scss/components/Checkbox/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/Collapse/index.html b/docs/src/scss/components/Collapse/index.html index ced4a59350..787bd91fc8 100644 --- a/docs/src/scss/components/Collapse/index.html +++ b/docs/src/scss/components/Collapse/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/Container/index.html b/docs/src/scss/components/Container/index.html index 598e40acb0..e2eef981ae 100644 --- a/docs/src/scss/components/Container/index.html +++ b/docs/src/scss/components/Container/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/Dropdown/index.html b/docs/src/scss/components/Dropdown/index.html index d209cf62fc..bddf10e150 100644 --- a/docs/src/scss/components/Dropdown/index.html +++ b/docs/src/scss/components/Dropdown/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/FieldGroup/index.html b/docs/src/scss/components/FieldGroup/index.html index 9d96dbc6cd..618ea47e94 100644 --- a/docs/src/scss/components/FieldGroup/index.html +++ b/docs/src/scss/components/FieldGroup/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/FileUploader/index.html b/docs/src/scss/components/FileUploader/index.html index b1eeae4e10..2f4ae548c9 100644 --- a/docs/src/scss/components/FileUploader/index.html +++ b/docs/src/scss/components/FileUploader/index.html @@ -18,8 +18,8 @@ - - + + diff --git a/docs/src/scss/components/Grid/index.html b/docs/src/scss/components/Grid/index.html index d91ad68539..7a4c6cd427 100644 --- a/docs/src/scss/components/Grid/index.html +++ b/docs/src/scss/components/Grid/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/Header/index.html b/docs/src/scss/components/Header/index.html index b55e47eb1f..c80844cef3 100644 --- a/docs/src/scss/components/Header/index.html +++ b/docs/src/scss/components/Header/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/Item/index.html b/docs/src/scss/components/Item/index.html index 578d538e59..60d679a8ca 100644 --- a/docs/src/scss/components/Item/index.html +++ b/docs/src/scss/components/Item/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/Modal/index.html b/docs/src/scss/components/Modal/index.html index e88abb1fa2..f6df1db426 100644 --- a/docs/src/scss/components/Modal/index.html +++ b/docs/src/scss/components/Modal/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/Pagination/index.html b/docs/src/scss/components/Pagination/index.html index 49692a3072..a72a1bdd9d 100644 --- a/docs/src/scss/components/Pagination/index.html +++ b/docs/src/scss/components/Pagination/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/Pill/index.html b/docs/src/scss/components/Pill/index.html index 2a8d3bb227..898f646610 100644 --- a/docs/src/scss/components/Pill/index.html +++ b/docs/src/scss/components/Pill/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/Radio/index.html b/docs/src/scss/components/Radio/index.html index 78031f1790..7de3c12e1c 100644 --- a/docs/src/scss/components/Radio/index.html +++ b/docs/src/scss/components/Radio/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/ScrollView/index.html b/docs/src/scss/components/ScrollView/index.html index d0a20db831..1c057fb447 100644 --- a/docs/src/scss/components/ScrollView/index.html +++ b/docs/src/scss/components/ScrollView/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/Select/index.html b/docs/src/scss/components/Select/index.html index c570f4f6a6..87bb32cc5c 100644 --- a/docs/src/scss/components/Select/index.html +++ b/docs/src/scss/components/Select/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/Spinner/index.html b/docs/src/scss/components/Spinner/index.html index b3150d3125..5cd83c7408 100644 --- a/docs/src/scss/components/Spinner/index.html +++ b/docs/src/scss/components/Spinner/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/Stack/index.html b/docs/src/scss/components/Stack/index.html index 17d66650d6..3aee364cfe 100644 --- a/docs/src/scss/components/Stack/index.html +++ b/docs/src/scss/components/Stack/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/Tabs/index.html b/docs/src/scss/components/Tabs/index.html index 7c0dde2e2d..54d9b5e1ce 100644 --- a/docs/src/scss/components/Tabs/index.html +++ b/docs/src/scss/components/Tabs/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/Tag/index.html b/docs/src/scss/components/Tag/index.html index df187c77f4..ebf799e39d 100644 --- a/docs/src/scss/components/Tag/index.html +++ b/docs/src/scss/components/Tag/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/TextArea/index.html b/docs/src/scss/components/TextArea/index.html index 0dc7750885..f53966877d 100644 --- a/docs/src/scss/components/TextArea/index.html +++ b/docs/src/scss/components/TextArea/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/TextField/index.html b/docs/src/scss/components/TextField/index.html index 35f338aa74..3904fdbc75 100644 --- a/docs/src/scss/components/TextField/index.html +++ b/docs/src/scss/components/TextField/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/components/Tooltip/index.html b/docs/src/scss/components/Tooltip/index.html index d301616786..47de9942a5 100644 --- a/docs/src/scss/components/Tooltip/index.html +++ b/docs/src/scss/components/Tooltip/index.html @@ -18,8 +18,8 @@ - - + + diff --git a/docs/src/scss/helpers/accessibility/index.html b/docs/src/scss/helpers/accessibility/index.html index 080d76dd83..9dd3329aa0 100644 --- a/docs/src/scss/helpers/accessibility/index.html +++ b/docs/src/scss/helpers/accessibility/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/helpers/animations/index.html b/docs/src/scss/helpers/animations/index.html index 29763d7c18..549463094d 100644 --- a/docs/src/scss/helpers/animations/index.html +++ b/docs/src/scss/helpers/animations/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/helpers/breakout/index.html b/docs/src/scss/helpers/breakout/index.html index 66648dac5d..d79718bed9 100644 --- a/docs/src/scss/helpers/breakout/index.html +++ b/docs/src/scss/helpers/breakout/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/helpers/images/index.html b/docs/src/scss/helpers/images/index.html index ad3ade70e7..b663b96b00 100644 --- a/docs/src/scss/helpers/images/index.html +++ b/docs/src/scss/helpers/images/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/helpers/index.html b/docs/src/scss/helpers/index.html index 4c3bd5be66..8950b6412f 100644 --- a/docs/src/scss/helpers/index.html +++ b/docs/src/scss/helpers/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/helpers/links/index.html b/docs/src/scss/helpers/links/index.html index 7ffc7c8874..5f01e2c5ec 100644 --- a/docs/src/scss/helpers/links/index.html +++ b/docs/src/scss/helpers/links/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/helpers/lists/index.html b/docs/src/scss/helpers/lists/index.html index bbe1951068..7984c492ea 100644 --- a/docs/src/scss/helpers/lists/index.html +++ b/docs/src/scss/helpers/lists/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/helpers/scroll-control/index.html b/docs/src/scss/helpers/scroll-control/index.html index e1a1f7296d..ce45aff85f 100644 --- a/docs/src/scss/helpers/scroll-control/index.html +++ b/docs/src/scss/helpers/scroll-control/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/helpers/text/index.html b/docs/src/scss/helpers/text/index.html index 9be901d563..e0e703b165 100644 --- a/docs/src/scss/helpers/text/index.html +++ b/docs/src/scss/helpers/text/index.html @@ -18,7 +18,7 @@ - + diff --git a/docs/src/scss/helpers/typography/index.html b/docs/src/scss/helpers/typography/index.html index d6296d4ce8..c3c73c6158 100644 --- a/docs/src/scss/helpers/typography/index.html +++ b/docs/src/scss/helpers/typography/index.html @@ -18,7 +18,7 @@ - +