@spscommerce/ds-web-components 5.21.2 → 5.21.5

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.
@@ -178,7 +178,7 @@
178
178
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
179
179
  * See the License for the specific language governing permissions and
180
180
  * limitations under the License.
181
- */c.applyAttr=de;c.applyProp=he;c.attributes=U;c.close=ye;var te=c.currentElement=mt,se=c.currentPointer=ft;c.open=Ne;var Nt=c.patch=Ce;c.patchInner=Ce;c.patchOuter=ct;c.skip=gt;var ne=c.skipNode=M;c.getKey=at;c.clearCache=ge;c.importNode=fe;c.isDataInitialized=it;c.notifications=B;c.symbols=V;var Ie=c.attr=wt,yt=c.elementClose=Pe;c.elementOpen=ee;var At=c.elementOpenEnd=St,Pt=c.elementOpenStart=Ct;c.elementVoid=_t;var It=c.text=xt;c.key=bt;function De(e){let t=se();return t instanceof Comment&&t.data!==e?t.data=e:(t=document.createComment(e),te().appendChild(t)),ne(),t}let Oe=T.noI18nI18n;function Dt(e){Oe=e}function Ot(){return Oe}const I=Symbol("ComponentMetadata"),b=Object.freeze({has(e,t){return Boolean(e[I]&&Object.prototype.hasOwnProperty.call(e[I],t))},add(e,t){e[I]?Object.assign(e[I],t):e[I]=t},get(e,t,s){return e[I]&&e[I][t]||s}}),Fe=Symbol("ds-web-components:pragma:listeners-attached"),Le="idom-pragma:content-begin",ie="idom-pragma:content-end";function ae(e){for(const t of e)if(typeof t=="function")t();else if(typeof t=="string")It(t);else if(t instanceof Set)ae(Array.from(t));else if(Array.isArray(t)&&t.length>0){let s=se();if(De(Le),s===null){const n=te();for(let i=0;i<t.length;i+=1)n.contains(t[i])||n.appendChild(t[i]),ne()}for(;s&&s.data!==ie;)ne(),s=se();De(ie)}}function r(e,t,...s){if(t){for(const n of Object.keys(t))if(n.toUpperCase()==="DATA-FRAGMENT")return()=>ae(s)}return()=>{Pt(e);const n=[];if(t)for(const a of Object.keys(t))a.toUpperCase()==="CLASSNAME"?Ie("class",t[a]):/^on[A-Z]/.test(a)?n.push(a):Ie(a,t[a]);At(e);const i=te();if(!i[Fe]){for(const a of n)i.addEventListener(a.substr(2).toLowerCase(),t[a]);i[Fe]=!0}ae(s),yt(e)}}function ke(e,t){customElements.get(e)||customElements.define(e,t)}function Ft(...e){for(const t of e)ke(b.get(t,"tag"),t)}function Lt(e){return function(...s){for(const n of s){const i=`${e}${b.get(n,"tag").substr(3)}`;ke(i,n)}}}const re=Symbol("Component Attribute Bindings"),D=Symbol("Component Class Bindings"),G=Symbol("Component Style Bindings"),kt={__initialized:!1,__observer:null,__queuedUpdate:null,__managedClasses:new Set,__updateHostBindings(){const e=this;for(const t of Object.keys(e[re]||{}))e.setAttribute(t,e[re][t]);for(const t of Object.keys(e[G]||{}))e.style[t]=e[G][t];for(const t of e.__managedClasses)e.classList.remove(t);for(const t of(e[D]||[]).filter(Boolean))e.__managedClasses.add(t),e.classList.add(t);for(const t of(e.getAttribute("classname")||"").split(/\w+/).filter(Boolean))e.classList.add(t)},__updateChildQueries(e){const t=this;for(const s of b.get(t.constructor,"childQueries",[]))if(!e||e&&s.refresh){const n=s.all?t.querySelectorAll:t.querySelector;t[s.key]=n.call(t,s.selector)}},__gatherChildren(){const e=this;let t=Array.from(e.childNodes),s=null,n=t.length;for(let i=0;i<t.length;i+=1){const a=t[i];a instanceof Comment&&(a.data===Le?s=i+1:a.data===ie&&(n=i-1))}if(s===null)for(const i of t)i.parentNode.removeChild(i);else t=t.slice(s,n);b.has(e.constructor,"contentProp")&&(e[b.get(e.constructor,"contentProp")]=t)},__startMutObs(){const e=this;e.__observer||(e.__observer=new MutationObserver(()=>{e.contentChangedCallback&&e.contentChangedCallback(),e.__gatherChildren(),e.update()})),e.__observer.observe(e,{childList:!0})},__stopMutObs(){const e=this;e.__observer&&e.__observer.disconnect()},__doRender(){const e=this;e.__stopMutObs(),Nt(e,e.render(Ot())),e.__startMutObs()},update(){const e=this;e.__initialized&&!e.__queuedUpdate&&(e.__queuedUpdate=window.requestAnimationFrame(()=>{e.__doRender(),setTimeout(()=>{e.__updateChildQueries(!0),e.__updateHostBindings()},0),e.__queuedUpdate=null}))},attributeChangedCallback(e,t,s){const n=this,i=s===""?!0:s;i!==t&&(n.__cbAttributeChanged&&n.__cbAttributeChanged(e,n[e],i),e!=="style"&&(n[e]=i),n.__initialized&&n.update())},connectedCallback(){const e=this;e.__cbConnected&&e.__cbConnected();const t=b.get(e.constructor,"eventListeners",[]);setTimeout(()=>{if(!e.__initialized){e.__gatherChildren();for(const[,s]of t)e[s]=e[s].bind(e);e.__initialized=!0}for(const[s,n]of t)e.addEventListener(s,e[n]);e.__doRender(),setTimeout(()=>{e.__updateChildQueries(),e.__updateHostBindings()},0)},0)},disconnectedCallback(){const e=this;e.__cbDisconnected&&e.__cbDisconnected();for(const[t,s]of b.get(e.constructor,"eventListeners",[]))e.removeEventListener(t,e[s]);e.__stopMutObs()}};function O(e){return t=>{b.add(t,e),Object.assign(t.prototype,{__cbAttributeChanged:t.prototype.attributeChangedCallback,__cbConnected:t.prototype.connectedCallback,__cbDisconnected:t.prototype.disconnectedCallback},kt)}}function X(){return(e,t)=>{b.add(e.constructor,{contentProp:t})}}function K(e){return(t,s)=>{Object.defineProperty(t,s,{get(){return Object.defineProperty(this,s,{value:{dispatch:n=>{const i=new CustomEvent(e||s,{detail:n});return this.dispatchEvent(i),i}}}),this[s]},configurable:!0})}}function j(e){return(t,s)=>{const n=b.get(t.constructor,"eventListeners",[]);n.push([e,s]),b.add(t.constructor,{eventListeners:n})}}function p(e){return(t,s)=>{const n=t.constructor,i=s.toLowerCase();if(n.observedAttributes=n.observedAttributes||["classname","className","style"],n.observedAttributes.push(s),n.observedAttributes.push(i),i!==s&&Object.defineProperty(t,s,{get(){return this[i]},set(a){this[i]=a}}),e){const a=Symbol.for(s);Object.defineProperty(t,i,{get(){return this[a]},set(o){let g=o;e===Boolean&&typeof o=="string"&&o.toLowerCase()==="false"?g=!1:g=e(o),this[a]=g}})}}}function Te(e,t,s){return(n,i)=>{const a=b.get(n.constructor,"childQueries",[]);a.push({key:i,selector:e,all:s,refresh:t.refresh}),b.add(n.constructor,{childQueries:a})}}function Q(e,t={}){return Te(e,t)}function Ue(e,t={}){return Te(e,t,!0)}function oe(){return(e,t)=>{const s=Symbol(t);Object.defineProperties(e,{[s]:{writable:!0,enumerable:!1,configurable:!1,value:e[t]},[t]:{get(){return this[s]},set(n){this[s]!==n&&(this[s]=n,this.update())}}})}}exports.MIMEType=void 0;(function(e){e["7Z"]="application/x-7z-compressed",e.AAC="audio/aac",e.ABW="application/x-abiword",e.ARC="application/octet-stream",e.AVI="video/x-msvideo",e.AZW="application/vnd.amazon.ebook",e.BIN="application/octet-stream",e.BMP="image/bmp",e.BZ="application/x-bzip",e.BZ2="application/x-bzip2",e.CSH="application/x-csh",e.CSS="text/css",e.CSV="text/csv,application/vnd.ms-excel",e.DOC="application/msword",e.DOCX="application/vnd.openxmlformats-officedocument.wordprocessingml.document",e.EOT="application/vnd.ms-fontobject",e.EPUB="application/epub+zip",e.ES="application/ecmascript",e.FLV="video/x-flv",e.GIF="image/gif",e.GZ="application/x-gzip",e.HTM="text/html",e.HTML="text/html",e.ICO="image/x-icon",e.ICS="text/calendar",e.JAR="application/java-archive",e.JPEG="image/jpeg",e.JPG="image/jpeg",e.JS="application/javascript",e.JSON="application/json",e.M3U="audio/x-mpequrl",e.MID="audio/midi",e.MIDI="audio/midi",e.MOV="video/quicktime",e.MP3="audio/mpeg3",e.MP4="video/mp4",e.MPEG="video/mpeg",e.MPKG="application/vnd.apple.installer+xml",e.ODP="application/vnd.oasis.opendocument.presentation",e.ODS="application/vnd.oasis.opendocument.spreadsheet",e.ODT="application/vnd.oasis.opendocument.text",e.OGA="audio/ogg",e.OGV="video/ogg",e.OGX="application/ogg",e.OTF="font/otf",e.PNG="image/png",e.PDF="application/pdf",e.PPT="application/vnd.ms-powerpoint",e.PPTX="application/vnd.openxmlformats-officedocument.presentationml.presentation",e.RAR="application/x-rar-compressed",e.RTF="application/rtf",e.SH="application/x-sh",e.SVG="image/svg+xml",e.SWF="application/x-shockwave-flash",e.TAR="application/x-tar",e.TIF="image/tiff",e.TIFF="image/tiff",e.TS="application/typescript",e.TTF="font/ttf",e.TXT="text/plain",e.VSD="application/vnd.visio",e.WAV="audio/wav",e.WEBA="audio/webm",e.WEBM="video/webm",e.WEBP="image/webp",e.WOFF="font/woff",e.WOFF2="font/woff2",e.XHTML="application/xhtml+xml",e.XLS="application/vnd.ms-excel",e.XLSX="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",e.XML="application/xml",e.XUL="application/vnd.mozilla.xul+xml",e.ZIP="application/zip"})(exports.MIMEType||(exports.MIMEType={}));var Tt=Object.defineProperty,Ut=Object.getOwnPropertyDescriptor,h=(e,t,s,n)=>{for(var i=n>1?void 0:n?Ut(t,s):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(n?o(t,s,i):o(i))||i);return n&&i&&Tt(t,s,i),i};const u="sps-file-upload";exports.SpsFileUploadComponent=class extends HTMLElement{constructor(){super();this.shown=!0,this.files=[],this.acceptMIMETypes=new Set,this.active=!1,this.error=!1,this.namesOfUnsupportedFiles=[],this.handleBrowseLinkClick=this.handleBrowseLinkClick.bind(this),this.handleDownloadButtonClick=this.handleDownloadButtonClick.bind(this),this.handleFileInputChange=this.handleFileInputChange.bind(this),this.dismiss=this.dismiss.bind(this)}get[D](){return[u,this.active&&`${u}--active`,this.error&&`${u}--error`,!this.shown&&`${u}--hidden`,this.mini&&`${u}--mini`,this.constrainContentWidth&&`${u}--constrained-content-width`]}connectedCallback(){this.description=this.description||(this.multiple?"Files":"File"),this.acceptExtensions&&this.processAcceptExtensions(this.acceptExtensions),this.maxSize&&this.parseAndValidateMaxSize(this.maxSize)}attributeChangedCallback(e,t,s){e==="acceptExtensions"&&this.processAcceptExtensions(s),e==="maxSize"&&this.parseAndValidateMaxSize(s)}dismiss(){this.dismissable&&(this.shown=!1,this.update(),this.dismissal.dispatch())}show(){this.dismissable&&(this.shown=!0,this.update())}render({t:e}){const t=this.error?T.SpsIcon.EXCLAMATION_CIRCLE:T.SpsIcon.UPLOAD_CLOUD,s=(this.multiple?e("design-system:fileUpload.instructions_plural"):e("design-system:fileUpload.instructions")).split("|");return r("div",{"data-fragment":!0},r("div",{className:`${u}__content`},this.processing?r("div",{"data-fragment":!0},r("i",{className:"sps-spinner sps-spinner--medium","aria-hidden":"true"}),r("div",{className:`${u}__instructions`},e("design-system:fileUpload.processing"))):r("div",{"data-fragment":!0},r("i",{className:`sps-icon sps-icon-${t} ${u}__icon-primary`,"aria-hidden":"true"}),r("div",{className:`${u}__title`},this.error?r("div",{"data-fragment":!0},e(this.namesOfUnsupportedFiles.length>1?"design-system:fileUpload.cancelled_plural":"design-system:fileUpload.cancelled")):r("div",{"data-fragment":!0},e("design-system:fileUpload.title",{description:this.description}))),this.error?r("div",{className:`${u}__errored-files`},new Set(this.namesOfUnsupportedFiles.map((n,i)=>{const a=Math.floor(n.length/2);return r("div",{className:`${u}__errored-filename`,key:n},r("span",{className:`${u}__errored-filename-segment`},n.substr(0,a)),r("div",{className:`${u}__errored-filename-segment`},r("span",null,n.substr(a))),i<this.namesOfUnsupportedFiles.length-1?",":"")}))):r("span",null),r("div",{className:`${u}__instructions`},r("div",{"data-fragment":!0},r("span",null,s[0]),r("a",{href:"",onClick:this.handleBrowseLinkClick},s[1]),r("span",null,s[2]))),r("div",{className:`${u}__requirements`},this.acceptExtensions?r("span",null,"("," ",e("design-system:fileUpload.acceptedTypes",{fileTypes:this.acceptExtensionsDescription})," ",")"):"",this.maxSize?r("span",null,"("," ",e("design-system:fileUpload.maximumSize",{size:this.maxSize})," ",")"):"",this.customRequirement?r("span",null," ",this.customRequirement," "):""),this.downloadLabel&&r("div",{className:`sps-button sps-button--link ${u}__download-button`,onClick:this.handleDownloadButtonClick},r("button",{type:"button"},r("i",{className:"sps-icon sps-icon-download-cloud","aria-hidden":"true"})," ",this.downloadLabel)))),this.dismissable&&!this.processing&&r("div",{className:`sps-button sps-button--icon ${u}__close-button`,onClick:this.dismiss},r("button",{type:"button",title:e("design-system:fileUpload.close")},r("i",{className:"sps-icon sps-icon-x","aria-hidden":"true"}))),r("form",null,r("input",{type:"file",accept:this.accept||"*/*",multiple:this.multiple||null,onChange:this.handleFileInputChange})))}parseAndValidateMaxSize(e){try{this.maxSizeBytes=l.parseFileSize(e)}catch{throw new Error(`Could not parse "${e}" as a file size.`)}}processAcceptExtensions(e){const s=(Array.isArray(e)?e:e.trim().split(/\s?,\s?/)).map(i=>i.replace(/^\./,"")),n=s.map(i=>`.${i}`.toLowerCase());this.acceptExtensionsDescription=n.map((i,a)=>a>0&&a===n.length-1?`or ${i}`:i).join(n.length>2?", ":" "),this.acceptMIMETypes.clear();for(const i of s)for(const a of exports.MIMEType[i.toUpperCase()].split(","))this.acceptMIMETypes.add(a);this.accept=n.concat(Array.from(this.acceptMIMETypes)).join(",")}selectFiles(e){this.namesOfUnsupportedFiles=[];const t=Array.from(e);for(const s of t)this.acceptExtensions&&!this.acceptMIMETypes.has(s.type)&&this.namesOfUnsupportedFiles.push(s.name),this.maxSize&&s.size>this.maxSizeBytes&&this.namesOfUnsupportedFiles.push(s.name);this.namesOfUnsupportedFiles.length?(this.error=!0,this.fileInput.value=null,this.update()):(this.files=t,this.selection.dispatch(t))}handleDragOver(e){e.preventDefault(),e.stopPropagation()}handleDragEnter(e){e.preventDefault(),this.active=!0,this.error=!1,this.update()}handleDragLeave(e){e.preventDefault(),this.active=!1,this.update()}handleDrop(e){e.preventDefault(),e.stopPropagation(),this.active=!1,e.dataTransfer.items?this.selectFiles(Array.from(e.dataTransfer.items).map(t=>t.getAsFile())):this.selectFiles(e.dataTransfer.files),this.update()}handleBrowseLinkClick(e){e.preventDefault(),this.error=!1,this.update(),this.fileInput.click()}handleDownloadButtonClick(){this.download.dispatch()}handleFileInputChange(e){e.stopPropagation(),this.selectFiles(e.target.files)}};exports.SpsFileUploadComponent.displayName=u;exports.SpsFileUploadComponent.props={description:"string",multiple:"boolean",dismissable:"boolean",processing:"boolean",mini:"boolean",downloadLabel:"string",acceptExtensions:"Array<string> | string",maxSize:"string",customRequirement:"string",selection:{event:!0,type:"CustomEvent<Array<File>>"},dismissal:{event:!0,type:"CustomEvent<void>"},download:{event:!0,type:"CustomEvent<void>"}};h([p()],exports.SpsFileUploadComponent.prototype,"description",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"multiple",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"shown",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"dismissable",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"processing",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"mini",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"constrainContentWidth",2);h([p()],exports.SpsFileUploadComponent.prototype,"downloadLabel",2);h([p()],exports.SpsFileUploadComponent.prototype,"acceptExtensions",2);h([p()],exports.SpsFileUploadComponent.prototype,"maxSize",2);h([p()],exports.SpsFileUploadComponent.prototype,"customRequirement",2);h([K()],exports.SpsFileUploadComponent.prototype,"selection",2);h([K()],exports.SpsFileUploadComponent.prototype,"dismissal",2);h([K()],exports.SpsFileUploadComponent.prototype,"download",2);h([Q("input[type='file']")],exports.SpsFileUploadComponent.prototype,"fileInput",2);h([j("dragover")],exports.SpsFileUploadComponent.prototype,"handleDragOver",1);h([j("dragenter")],exports.SpsFileUploadComponent.prototype,"handleDragEnter",1);h([j("dragleave")],exports.SpsFileUploadComponent.prototype,"handleDragLeave",1);h([j("drop")],exports.SpsFileUploadComponent.prototype,"handleDrop",1);exports.SpsFileUploadComponent=h([O({tag:u})],exports.SpsFileUploadComponent);const Ee={basic:{label:"Basic File Upload",description:l.code`
181
+ */c.applyAttr=de;c.applyProp=he;c.attributes=U;c.close=ye;var te=c.currentElement=mt,se=c.currentPointer=ft;c.open=Ne;var Nt=c.patch=Ce;c.patchInner=Ce;c.patchOuter=ct;c.skip=gt;var ne=c.skipNode=M;c.getKey=at;c.clearCache=ge;c.importNode=fe;c.isDataInitialized=it;c.notifications=B;c.symbols=V;var Ie=c.attr=wt,yt=c.elementClose=Pe;c.elementOpen=ee;var At=c.elementOpenEnd=St,Pt=c.elementOpenStart=Ct;c.elementVoid=_t;var It=c.text=xt;c.key=bt;function De(e){let t=se();return t instanceof Comment&&t.data!==e?t.data=e:(t=document.createComment(e),te().appendChild(t)),ne(),t}let Oe=T.noI18nI18n;function Dt(e){Oe=e}function Ot(){return Oe}const I=Symbol("ComponentMetadata"),b=Object.freeze({has(e,t){return Boolean(e[I]&&Object.prototype.hasOwnProperty.call(e[I],t))},add(e,t){e[I]?Object.assign(e[I],t):e[I]=t},get(e,t,s){return e[I]&&e[I][t]||s}}),Fe=Symbol("ds-web-components:pragma:listeners-attached"),Le="idom-pragma:content-begin",ie="idom-pragma:content-end";function ae(e){for(const t of e)if(typeof t=="function")t();else if(typeof t=="string")It(t);else if(t instanceof Set)ae(Array.from(t));else if(Array.isArray(t)&&t.length>0){let s=se();if(De(Le),s===null){const n=te();for(let i=0;i<t.length;i+=1)n.contains(t[i])||n.appendChild(t[i]),ne()}for(;s&&s.data!==ie;)ne(),s=se();De(ie)}}function r(e,t,...s){if(t){for(const n of Object.keys(t))if(n.toUpperCase()==="DATA-FRAGMENT")return()=>ae(s)}return()=>{Pt(e);const n=[];if(t)for(const a of Object.keys(t))a.toUpperCase()==="CLASSNAME"?Ie("class",t[a]):/^on[A-Z]/.test(a)?n.push(a):Ie(a,t[a]);At(e);const i=te();if(!i[Fe]){for(const a of n)i.addEventListener(a.substr(2).toLowerCase(),t[a]);i[Fe]=!0}ae(s),yt(e)}}function ke(e,t){customElements.get(e)||customElements.define(e,t)}function Ft(...e){for(const t of e)ke(b.get(t,"tag"),t)}function Lt(e){return function(...s){for(const n of s){const i=`${e}${b.get(n,"tag").substr(3)}`;ke(i,n)}}}const re=Symbol("Component Attribute Bindings"),D=Symbol("Component Class Bindings"),G=Symbol("Component Style Bindings"),kt={__initialized:!1,__observer:null,__queuedUpdate:null,__managedClasses:new Set,__updateHostBindings(){const e=this;for(const t of Object.keys(e[re]||{}))e.setAttribute(t,e[re][t]);for(const t of Object.keys(e[G]||{}))e.style[t]=e[G][t];for(const t of e.__managedClasses)e.classList.remove(t);for(const t of(e[D]||[]).filter(Boolean))e.__managedClasses.add(t),e.classList.add(t);for(const t of(e.getAttribute("classname")||"").split(/\w+/).filter(Boolean))e.classList.add(t)},__updateChildQueries(e){const t=this;for(const s of b.get(t.constructor,"childQueries",[]))if(!e||e&&s.refresh){const n=s.all?t.querySelectorAll:t.querySelector;t[s.key]=n.call(t,s.selector)}},__gatherChildren(){const e=this;let t=Array.from(e.childNodes),s=null,n=t.length;for(let i=0;i<t.length;i+=1){const a=t[i];a instanceof Comment&&(a.data===Le?s=i+1:a.data===ie&&(n=i-1))}if(s===null)for(const i of t)i.parentNode.removeChild(i);else t=t.slice(s,n);b.has(e.constructor,"contentProp")&&(e[b.get(e.constructor,"contentProp")]=t)},__startMutObs(){const e=this;e.__observer||(e.__observer=new MutationObserver(()=>{e.contentChangedCallback&&e.contentChangedCallback(),e.__gatherChildren(),e.update()})),e.__observer.observe(e,{childList:!0})},__stopMutObs(){const e=this;e.__observer&&e.__observer.disconnect()},__doRender(){const e=this;e.__stopMutObs(),Nt(e,e.render(Ot())),e.__startMutObs()},update(){const e=this;e.__initialized&&!e.__queuedUpdate&&(e.__queuedUpdate=window.requestAnimationFrame(()=>{e.__doRender(),setTimeout(()=>{e.__updateChildQueries(!0),e.__updateHostBindings()},0),e.__queuedUpdate=null}))},attributeChangedCallback(e,t,s){const n=this,i=s===""?!0:s;i!==t&&(n.__cbAttributeChanged&&n.__cbAttributeChanged(e,n[e],i),e!=="style"&&(n[e]=i),n.__initialized&&n.update())},connectedCallback(){const e=this;e.__cbConnected&&e.__cbConnected();const t=b.get(e.constructor,"eventListeners",[]);setTimeout(()=>{if(!e.__initialized){e.__gatherChildren();for(const[,s]of t)e[s]=e[s].bind(e);e.__initialized=!0}for(const[s,n]of t)e.addEventListener(s,e[n]);e.__doRender(),setTimeout(()=>{e.__updateChildQueries(),e.__updateHostBindings()},0)},0)},disconnectedCallback(){const e=this;e.__cbDisconnected&&e.__cbDisconnected();for(const[t,s]of b.get(e.constructor,"eventListeners",[]))e.removeEventListener(t,e[s]);e.__stopMutObs()}};function O(e){return t=>{b.add(t,e),Object.assign(t.prototype,{__cbAttributeChanged:t.prototype.attributeChangedCallback,__cbConnected:t.prototype.connectedCallback,__cbDisconnected:t.prototype.disconnectedCallback},kt)}}function X(){return(e,t)=>{b.add(e.constructor,{contentProp:t})}}function K(e){return(t,s)=>{Object.defineProperty(t,s,{get(){return Object.defineProperty(this,s,{value:{dispatch:n=>{const i=new CustomEvent(e||s,{detail:n});return this.dispatchEvent(i),i}}}),this[s]},configurable:!0})}}function j(e){return(t,s)=>{const n=b.get(t.constructor,"eventListeners",[]);n.push([e,s]),b.add(t.constructor,{eventListeners:n})}}function p(e){return(t,s)=>{const n=t.constructor,i=s.toLowerCase();if(n.observedAttributes=n.observedAttributes||["classname","className","style"],n.observedAttributes.push(s),n.observedAttributes.push(i),i!==s&&Object.defineProperty(t,s,{get(){return this[i]},set(a){this[i]=a}}),e){const a=Symbol.for(s);Object.defineProperty(t,i,{get(){return this[a]},set(o){let g=o;e===Boolean&&typeof o=="string"&&o.toLowerCase()==="false"?g=!1:g=e(o),this[a]=g}})}}}function Te(e,t,s){return(n,i)=>{const a=b.get(n.constructor,"childQueries",[]);a.push({key:i,selector:e,all:s,refresh:t.refresh}),b.add(n.constructor,{childQueries:a})}}function Q(e,t={}){return Te(e,t)}function Ue(e,t={}){return Te(e,t,!0)}function oe(){return(e,t)=>{const s=Symbol(t);Object.defineProperties(e,{[s]:{writable:!0,enumerable:!1,configurable:!1,value:e[t]},[t]:{get(){return this[s]},set(n){this[s]!==n&&(this[s]=n,this.update())}}})}}exports.MIMEType=void 0;(function(e){e["7Z"]="application/x-7z-compressed",e.AAC="audio/aac",e.ABW="application/x-abiword",e.ARC="application/octet-stream",e.AVI="video/x-msvideo",e.AZW="application/vnd.amazon.ebook",e.BIN="application/octet-stream",e.BMP="image/bmp",e.BZ="application/x-bzip",e.BZ2="application/x-bzip2",e.CSH="application/x-csh",e.CSS="text/css",e.CSV="text/csv,application/vnd.ms-excel",e.DOC="application/msword",e.DOCX="application/vnd.openxmlformats-officedocument.wordprocessingml.document",e.EOT="application/vnd.ms-fontobject",e.EPUB="application/epub+zip",e.ES="application/ecmascript",e.FLV="video/x-flv",e.GIF="image/gif",e.GZ="application/x-gzip",e.HTM="text/html",e.HTML="text/html",e.ICO="image/x-icon",e.ICS="text/calendar",e.JAR="application/java-archive",e.JPEG="image/jpeg",e.JPG="image/jpeg",e.JS="application/javascript",e.JSON="application/json",e.M3U="audio/x-mpequrl",e.MID="audio/midi",e.MIDI="audio/midi",e.MOV="video/quicktime",e.MP3="audio/mpeg3",e.MP4="video/mp4",e.MPEG="video/mpeg",e.MPKG="application/vnd.apple.installer+xml",e.ODP="application/vnd.oasis.opendocument.presentation",e.ODS="application/vnd.oasis.opendocument.spreadsheet",e.ODT="application/vnd.oasis.opendocument.text",e.OGA="audio/ogg",e.OGV="video/ogg",e.OGX="application/ogg",e.OTF="font/otf",e.PNG="image/png",e.PDF="application/pdf",e.PPT="application/vnd.ms-powerpoint",e.PPTX="application/vnd.openxmlformats-officedocument.presentationml.presentation",e.RAR="application/x-rar-compressed",e.RTF="application/rtf",e.SH="application/x-sh",e.SVG="image/svg+xml",e.SWF="application/x-shockwave-flash",e.TAR="application/x-tar",e.TIF="image/tiff",e.TIFF="image/tiff",e.TS="application/typescript",e.TTF="font/ttf",e.TXT="text/plain",e.VSD="application/vnd.visio",e.WAV="audio/wav",e.WEBA="audio/webm",e.WEBM="video/webm",e.WEBP="image/webp",e.WOFF="font/woff",e.WOFF2="font/woff2",e.XHTML="application/xhtml+xml",e.XLS="application/vnd.ms-excel",e.XLSX="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",e.XML="application/xml",e.XUL="application/vnd.mozilla.xul+xml",e.ZIP="application/zip"})(exports.MIMEType||(exports.MIMEType={}));var Tt=Object.defineProperty,Ut=Object.getOwnPropertyDescriptor,h=(e,t,s,n)=>{for(var i=n>1?void 0:n?Ut(t,s):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(n?o(t,s,i):o(i))||i);return n&&i&&Tt(t,s,i),i};const u="sps-file-upload";exports.SpsFileUploadComponent=class extends HTMLElement{constructor(){super();this.shown=!0,this.files=[],this.acceptMIMETypes=new Set,this.active=!1,this.error=!1,this.namesOfUnsupportedFiles=[],this.handleBrowseLinkClick=this.handleBrowseLinkClick.bind(this),this.handleDownloadButtonClick=this.handleDownloadButtonClick.bind(this),this.handleFileInputChange=this.handleFileInputChange.bind(this),this.dismiss=this.dismiss.bind(this)}get[D](){return[u,this.active&&`${u}--active`,this.error&&`${u}--error`,!this.shown&&`${u}--hidden`,this.mini&&`${u}--mini`,this.constrainContentWidth&&`${u}--constrained-content-width`]}connectedCallback(){this.description=this.description||(this.multiple?"Files":"File"),this.acceptExtensions&&this.processAcceptExtensions(this.acceptExtensions),this.maxSize&&this.parseAndValidateMaxSize(this.maxSize)}attributeChangedCallback(e,t,s){e==="acceptExtensions"&&this.processAcceptExtensions(s),e==="maxSize"&&this.parseAndValidateMaxSize(s)}dismiss(){this.dismissable&&(this.shown=!1,this.update(),this.dismissal.dispatch())}show(){this.dismissable&&(this.shown=!0,this.update())}render({t:e}){const t=this.error?T.SpsIcon.EXCLAMATION_CIRCLE:T.SpsIcon.UPLOAD_CLOUD,s=(this.multiple?e("design-system:fileUpload.instructions_plural"):e("design-system:fileUpload.instructions")).split("|");return r("div",{"data-fragment":!0},r("div",{className:`${u}__content`},this.processing?r("div",{"data-fragment":!0},r("i",{className:"sps-spinner sps-spinner--medium","aria-hidden":"true"}),r("div",{className:`${u}__instructions`},e("design-system:fileUpload.processing"))):r("div",{"data-fragment":!0},r("i",{className:`sps-icon sps-icon-${t} ${u}__icon-primary`,"aria-hidden":"true"}),r("div",{className:`${u}__title`},this.error?r("div",{"data-fragment":!0},e(this.namesOfUnsupportedFiles.length>1?"design-system:fileUpload.cancelled_plural":"design-system:fileUpload.cancelled")):r("div",{"data-fragment":!0},e("design-system:fileUpload.title",{description:this.description}))),this.error?r("div",{className:`${u}__errored-files`},new Set(this.namesOfUnsupportedFiles.map((n,i)=>{const a=Math.floor(n.length/2);return r("div",{className:`${u}__errored-filename`,key:n},r("span",{className:`${u}__errored-filename-segment`},n.substr(0,a)),r("div",{className:`${u}__errored-filename-segment`},r("span",null,n.substr(a))),i<this.namesOfUnsupportedFiles.length-1?",":"")}))):r("span",null),r("div",{className:`${u}__instructions`},r("div",{"data-fragment":!0},r("span",null,s[0]),r("a",{href:"",onClick:this.handleBrowseLinkClick},s[1]),r("span",null,s[2]))),r("div",{className:`${u}__requirements`},this.acceptExtensions?r("span",null,"("," ",e("design-system:fileUpload.acceptedTypes",{fileTypes:this.acceptExtensionsDescription})," ",")"):"",this.maxSize?r("span",null,"("," ",e("design-system:fileUpload.maximumSize",{size:this.maxSize})," ",")"):"",this.customRequirement?r("span",null," ",this.customRequirement," "):""),this.downloadLabel&&r("div",{className:`sps-button sps-button--link ${u}__download-button`,onClick:this.handleDownloadButtonClick},r("button",{type:"button"},r("i",{className:"sps-icon sps-icon-download-cloud","aria-hidden":"true"})," ",this.downloadLabel)))),this.dismissable&&!this.processing&&r("div",{className:`sps-button sps-button--icon ${u}__close-button`,onClick:this.dismiss},r("button",{type:"button",title:e("design-system:fileUpload.close")},r("i",{className:"sps-icon sps-icon-x","aria-hidden":"true"}))),r("form",null,r("input",{type:"file",accept:this.accept||"*/*",multiple:this.multiple||null,onChange:this.handleFileInputChange})))}parseAndValidateMaxSize(e){try{this.maxSizeBytes=l.parseFileSize(e)}catch{throw new Error(`Could not parse "${e}" as a file size.`)}}processAcceptExtensions(e){const s=(Array.isArray(e)?e:e.trim().split(/\s?,\s?/)).map(i=>i.replace(/^\./,"")),n=s.map(i=>`.${i}`.toLowerCase());this.acceptExtensionsDescription=n.map((i,a)=>a>0&&a===n.length-1?`or ${i}`:i).join(n.length>2?", ":" "),this.acceptMIMETypes.clear();for(const i of s)for(const a of exports.MIMEType[i.toUpperCase()].split(","))this.acceptMIMETypes.add(a);this.accept=n.concat(Array.from(this.acceptMIMETypes)).join(",")}selectFiles(e){this.namesOfUnsupportedFiles=[];const t=Array.from(e);for(const s of t)this.acceptExtensions&&!this.acceptMIMETypes.has(s.type)&&this.namesOfUnsupportedFiles.push(s.name),this.maxSize&&s.size>this.maxSizeBytes&&this.namesOfUnsupportedFiles.indexOf(s.name)===-1&&this.namesOfUnsupportedFiles.push(s.name);this.namesOfUnsupportedFiles.length?(this.error=!0,this.fileInput.value=null,this.update()):(this.files=t,this.selection.dispatch(t))}handleDragOver(e){e.preventDefault(),e.stopPropagation()}handleDragEnter(e){e.preventDefault(),this.active=!0,this.error=!1,this.update()}handleDragLeave(e){e.preventDefault(),this.active=!1,this.update()}handleDrop(e){e.preventDefault(),e.stopPropagation(),this.active=!1,e.dataTransfer.items?this.selectFiles(Array.from(e.dataTransfer.items).map(t=>t.getAsFile())):this.selectFiles(e.dataTransfer.files),this.update()}handleBrowseLinkClick(e){e.preventDefault(),this.error=!1,this.update(),this.fileInput.click()}handleDownloadButtonClick(){this.download.dispatch()}handleFileInputChange(e){e.stopPropagation(),this.selectFiles(e.target.files)}};exports.SpsFileUploadComponent.displayName=u;exports.SpsFileUploadComponent.props={description:"string",multiple:"boolean",dismissable:"boolean",processing:"boolean",mini:"boolean",downloadLabel:"string",acceptExtensions:"Array<string> | string",maxSize:"string",customRequirement:"string",selection:{event:!0,type:"CustomEvent<Array<File>>"},dismissal:{event:!0,type:"CustomEvent<void>"},download:{event:!0,type:"CustomEvent<void>"}};h([p()],exports.SpsFileUploadComponent.prototype,"description",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"multiple",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"shown",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"dismissable",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"processing",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"mini",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"constrainContentWidth",2);h([p()],exports.SpsFileUploadComponent.prototype,"downloadLabel",2);h([p()],exports.SpsFileUploadComponent.prototype,"acceptExtensions",2);h([p()],exports.SpsFileUploadComponent.prototype,"maxSize",2);h([p()],exports.SpsFileUploadComponent.prototype,"customRequirement",2);h([K()],exports.SpsFileUploadComponent.prototype,"selection",2);h([K()],exports.SpsFileUploadComponent.prototype,"dismissal",2);h([K()],exports.SpsFileUploadComponent.prototype,"download",2);h([Q("input[type='file']")],exports.SpsFileUploadComponent.prototype,"fileInput",2);h([j("dragover")],exports.SpsFileUploadComponent.prototype,"handleDragOver",1);h([j("dragenter")],exports.SpsFileUploadComponent.prototype,"handleDragEnter",1);h([j("dragleave")],exports.SpsFileUploadComponent.prototype,"handleDragLeave",1);h([j("drop")],exports.SpsFileUploadComponent.prototype,"handleDrop",1);exports.SpsFileUploadComponent=h([O({tag:u})],exports.SpsFileUploadComponent);const Ee={basic:{label:"Basic File Upload",description:l.code`
182
182
  <p>Simply allow the user to drag-and-drop or select either a single file or multiple files at once.</p>
183
183
  `,examples:{single:{description:"<p>Single file upload</p>",react:l.code`
184
184
  function Component() {
@@ -1451,7 +1451,7 @@ let SpsFileUploadComponent = class extends HTMLElement {
1451
1451
  if (this.acceptExtensions && !this.acceptMIMETypes.has(file.type)) {
1452
1452
  this.namesOfUnsupportedFiles.push(file.name);
1453
1453
  }
1454
- if (this.maxSize && file.size > this.maxSizeBytes) {
1454
+ if (this.maxSize && file.size > this.maxSizeBytes && this.namesOfUnsupportedFiles.indexOf(file.name) === -1) {
1455
1455
  this.namesOfUnsupportedFiles.push(file.name);
1456
1456
  }
1457
1457
  }
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spscommerce/ds-web-components",
3
3
  "description": "SPS Design System Native Web Components",
4
- "version": "5.21.2",
4
+ "version": "5.21.5",
5
5
  "author": "SPS Commerce",
6
6
  "license": "UNLICENSED",
7
7
  "repository": "https://github.com/spscommerce/design-system/tree/main/packages/@spscommerce/ds-web-components",
package/lib/index.cjs.js CHANGED
@@ -178,7 +178,7 @@
178
178
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
179
179
  * See the License for the specific language governing permissions and
180
180
  * limitations under the License.
181
- */c.applyAttr=de;c.applyProp=he;c.attributes=U;c.close=ye;var te=c.currentElement=mt,se=c.currentPointer=ft;c.open=Ne;var Nt=c.patch=Ce;c.patchInner=Ce;c.patchOuter=ct;c.skip=gt;var ne=c.skipNode=M;c.getKey=at;c.clearCache=ge;c.importNode=fe;c.isDataInitialized=it;c.notifications=B;c.symbols=V;var Ie=c.attr=wt,yt=c.elementClose=Pe;c.elementOpen=ee;var At=c.elementOpenEnd=St,Pt=c.elementOpenStart=Ct;c.elementVoid=_t;var It=c.text=xt;c.key=bt;function De(e){let t=se();return t instanceof Comment&&t.data!==e?t.data=e:(t=document.createComment(e),te().appendChild(t)),ne(),t}let Oe=T.noI18nI18n;function Dt(e){Oe=e}function Ot(){return Oe}const I=Symbol("ComponentMetadata"),b=Object.freeze({has(e,t){return Boolean(e[I]&&Object.prototype.hasOwnProperty.call(e[I],t))},add(e,t){e[I]?Object.assign(e[I],t):e[I]=t},get(e,t,s){return e[I]&&e[I][t]||s}}),Fe=Symbol("ds-web-components:pragma:listeners-attached"),Le="idom-pragma:content-begin",ie="idom-pragma:content-end";function ae(e){for(const t of e)if(typeof t=="function")t();else if(typeof t=="string")It(t);else if(t instanceof Set)ae(Array.from(t));else if(Array.isArray(t)&&t.length>0){let s=se();if(De(Le),s===null){const n=te();for(let i=0;i<t.length;i+=1)n.contains(t[i])||n.appendChild(t[i]),ne()}for(;s&&s.data!==ie;)ne(),s=se();De(ie)}}function r(e,t,...s){if(t){for(const n of Object.keys(t))if(n.toUpperCase()==="DATA-FRAGMENT")return()=>ae(s)}return()=>{Pt(e);const n=[];if(t)for(const a of Object.keys(t))a.toUpperCase()==="CLASSNAME"?Ie("class",t[a]):/^on[A-Z]/.test(a)?n.push(a):Ie(a,t[a]);At(e);const i=te();if(!i[Fe]){for(const a of n)i.addEventListener(a.substr(2).toLowerCase(),t[a]);i[Fe]=!0}ae(s),yt(e)}}function ke(e,t){customElements.get(e)||customElements.define(e,t)}function Ft(...e){for(const t of e)ke(b.get(t,"tag"),t)}function Lt(e){return function(...s){for(const n of s){const i=`${e}${b.get(n,"tag").substr(3)}`;ke(i,n)}}}const re=Symbol("Component Attribute Bindings"),D=Symbol("Component Class Bindings"),G=Symbol("Component Style Bindings"),kt={__initialized:!1,__observer:null,__queuedUpdate:null,__managedClasses:new Set,__updateHostBindings(){const e=this;for(const t of Object.keys(e[re]||{}))e.setAttribute(t,e[re][t]);for(const t of Object.keys(e[G]||{}))e.style[t]=e[G][t];for(const t of e.__managedClasses)e.classList.remove(t);for(const t of(e[D]||[]).filter(Boolean))e.__managedClasses.add(t),e.classList.add(t);for(const t of(e.getAttribute("classname")||"").split(/\w+/).filter(Boolean))e.classList.add(t)},__updateChildQueries(e){const t=this;for(const s of b.get(t.constructor,"childQueries",[]))if(!e||e&&s.refresh){const n=s.all?t.querySelectorAll:t.querySelector;t[s.key]=n.call(t,s.selector)}},__gatherChildren(){const e=this;let t=Array.from(e.childNodes),s=null,n=t.length;for(let i=0;i<t.length;i+=1){const a=t[i];a instanceof Comment&&(a.data===Le?s=i+1:a.data===ie&&(n=i-1))}if(s===null)for(const i of t)i.parentNode.removeChild(i);else t=t.slice(s,n);b.has(e.constructor,"contentProp")&&(e[b.get(e.constructor,"contentProp")]=t)},__startMutObs(){const e=this;e.__observer||(e.__observer=new MutationObserver(()=>{e.contentChangedCallback&&e.contentChangedCallback(),e.__gatherChildren(),e.update()})),e.__observer.observe(e,{childList:!0})},__stopMutObs(){const e=this;e.__observer&&e.__observer.disconnect()},__doRender(){const e=this;e.__stopMutObs(),Nt(e,e.render(Ot())),e.__startMutObs()},update(){const e=this;e.__initialized&&!e.__queuedUpdate&&(e.__queuedUpdate=window.requestAnimationFrame(()=>{e.__doRender(),setTimeout(()=>{e.__updateChildQueries(!0),e.__updateHostBindings()},0),e.__queuedUpdate=null}))},attributeChangedCallback(e,t,s){const n=this,i=s===""?!0:s;i!==t&&(n.__cbAttributeChanged&&n.__cbAttributeChanged(e,n[e],i),e!=="style"&&(n[e]=i),n.__initialized&&n.update())},connectedCallback(){const e=this;e.__cbConnected&&e.__cbConnected();const t=b.get(e.constructor,"eventListeners",[]);setTimeout(()=>{if(!e.__initialized){e.__gatherChildren();for(const[,s]of t)e[s]=e[s].bind(e);e.__initialized=!0}for(const[s,n]of t)e.addEventListener(s,e[n]);e.__doRender(),setTimeout(()=>{e.__updateChildQueries(),e.__updateHostBindings()},0)},0)},disconnectedCallback(){const e=this;e.__cbDisconnected&&e.__cbDisconnected();for(const[t,s]of b.get(e.constructor,"eventListeners",[]))e.removeEventListener(t,e[s]);e.__stopMutObs()}};function O(e){return t=>{b.add(t,e),Object.assign(t.prototype,{__cbAttributeChanged:t.prototype.attributeChangedCallback,__cbConnected:t.prototype.connectedCallback,__cbDisconnected:t.prototype.disconnectedCallback},kt)}}function X(){return(e,t)=>{b.add(e.constructor,{contentProp:t})}}function K(e){return(t,s)=>{Object.defineProperty(t,s,{get(){return Object.defineProperty(this,s,{value:{dispatch:n=>{const i=new CustomEvent(e||s,{detail:n});return this.dispatchEvent(i),i}}}),this[s]},configurable:!0})}}function j(e){return(t,s)=>{const n=b.get(t.constructor,"eventListeners",[]);n.push([e,s]),b.add(t.constructor,{eventListeners:n})}}function p(e){return(t,s)=>{const n=t.constructor,i=s.toLowerCase();if(n.observedAttributes=n.observedAttributes||["classname","className","style"],n.observedAttributes.push(s),n.observedAttributes.push(i),i!==s&&Object.defineProperty(t,s,{get(){return this[i]},set(a){this[i]=a}}),e){const a=Symbol.for(s);Object.defineProperty(t,i,{get(){return this[a]},set(o){let g=o;e===Boolean&&typeof o=="string"&&o.toLowerCase()==="false"?g=!1:g=e(o),this[a]=g}})}}}function Te(e,t,s){return(n,i)=>{const a=b.get(n.constructor,"childQueries",[]);a.push({key:i,selector:e,all:s,refresh:t.refresh}),b.add(n.constructor,{childQueries:a})}}function Q(e,t={}){return Te(e,t)}function Ue(e,t={}){return Te(e,t,!0)}function oe(){return(e,t)=>{const s=Symbol(t);Object.defineProperties(e,{[s]:{writable:!0,enumerable:!1,configurable:!1,value:e[t]},[t]:{get(){return this[s]},set(n){this[s]!==n&&(this[s]=n,this.update())}}})}}exports.MIMEType=void 0;(function(e){e["7Z"]="application/x-7z-compressed",e.AAC="audio/aac",e.ABW="application/x-abiword",e.ARC="application/octet-stream",e.AVI="video/x-msvideo",e.AZW="application/vnd.amazon.ebook",e.BIN="application/octet-stream",e.BMP="image/bmp",e.BZ="application/x-bzip",e.BZ2="application/x-bzip2",e.CSH="application/x-csh",e.CSS="text/css",e.CSV="text/csv,application/vnd.ms-excel",e.DOC="application/msword",e.DOCX="application/vnd.openxmlformats-officedocument.wordprocessingml.document",e.EOT="application/vnd.ms-fontobject",e.EPUB="application/epub+zip",e.ES="application/ecmascript",e.FLV="video/x-flv",e.GIF="image/gif",e.GZ="application/x-gzip",e.HTM="text/html",e.HTML="text/html",e.ICO="image/x-icon",e.ICS="text/calendar",e.JAR="application/java-archive",e.JPEG="image/jpeg",e.JPG="image/jpeg",e.JS="application/javascript",e.JSON="application/json",e.M3U="audio/x-mpequrl",e.MID="audio/midi",e.MIDI="audio/midi",e.MOV="video/quicktime",e.MP3="audio/mpeg3",e.MP4="video/mp4",e.MPEG="video/mpeg",e.MPKG="application/vnd.apple.installer+xml",e.ODP="application/vnd.oasis.opendocument.presentation",e.ODS="application/vnd.oasis.opendocument.spreadsheet",e.ODT="application/vnd.oasis.opendocument.text",e.OGA="audio/ogg",e.OGV="video/ogg",e.OGX="application/ogg",e.OTF="font/otf",e.PNG="image/png",e.PDF="application/pdf",e.PPT="application/vnd.ms-powerpoint",e.PPTX="application/vnd.openxmlformats-officedocument.presentationml.presentation",e.RAR="application/x-rar-compressed",e.RTF="application/rtf",e.SH="application/x-sh",e.SVG="image/svg+xml",e.SWF="application/x-shockwave-flash",e.TAR="application/x-tar",e.TIF="image/tiff",e.TIFF="image/tiff",e.TS="application/typescript",e.TTF="font/ttf",e.TXT="text/plain",e.VSD="application/vnd.visio",e.WAV="audio/wav",e.WEBA="audio/webm",e.WEBM="video/webm",e.WEBP="image/webp",e.WOFF="font/woff",e.WOFF2="font/woff2",e.XHTML="application/xhtml+xml",e.XLS="application/vnd.ms-excel",e.XLSX="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",e.XML="application/xml",e.XUL="application/vnd.mozilla.xul+xml",e.ZIP="application/zip"})(exports.MIMEType||(exports.MIMEType={}));var Tt=Object.defineProperty,Ut=Object.getOwnPropertyDescriptor,h=(e,t,s,n)=>{for(var i=n>1?void 0:n?Ut(t,s):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(n?o(t,s,i):o(i))||i);return n&&i&&Tt(t,s,i),i};const u="sps-file-upload";exports.SpsFileUploadComponent=class extends HTMLElement{constructor(){super();this.shown=!0,this.files=[],this.acceptMIMETypes=new Set,this.active=!1,this.error=!1,this.namesOfUnsupportedFiles=[],this.handleBrowseLinkClick=this.handleBrowseLinkClick.bind(this),this.handleDownloadButtonClick=this.handleDownloadButtonClick.bind(this),this.handleFileInputChange=this.handleFileInputChange.bind(this),this.dismiss=this.dismiss.bind(this)}get[D](){return[u,this.active&&`${u}--active`,this.error&&`${u}--error`,!this.shown&&`${u}--hidden`,this.mini&&`${u}--mini`,this.constrainContentWidth&&`${u}--constrained-content-width`]}connectedCallback(){this.description=this.description||(this.multiple?"Files":"File"),this.acceptExtensions&&this.processAcceptExtensions(this.acceptExtensions),this.maxSize&&this.parseAndValidateMaxSize(this.maxSize)}attributeChangedCallback(e,t,s){e==="acceptExtensions"&&this.processAcceptExtensions(s),e==="maxSize"&&this.parseAndValidateMaxSize(s)}dismiss(){this.dismissable&&(this.shown=!1,this.update(),this.dismissal.dispatch())}show(){this.dismissable&&(this.shown=!0,this.update())}render({t:e}){const t=this.error?T.SpsIcon.EXCLAMATION_CIRCLE:T.SpsIcon.UPLOAD_CLOUD,s=(this.multiple?e("design-system:fileUpload.instructions_plural"):e("design-system:fileUpload.instructions")).split("|");return r("div",{"data-fragment":!0},r("div",{className:`${u}__content`},this.processing?r("div",{"data-fragment":!0},r("i",{className:"sps-spinner sps-spinner--medium","aria-hidden":"true"}),r("div",{className:`${u}__instructions`},e("design-system:fileUpload.processing"))):r("div",{"data-fragment":!0},r("i",{className:`sps-icon sps-icon-${t} ${u}__icon-primary`,"aria-hidden":"true"}),r("div",{className:`${u}__title`},this.error?r("div",{"data-fragment":!0},e(this.namesOfUnsupportedFiles.length>1?"design-system:fileUpload.cancelled_plural":"design-system:fileUpload.cancelled")):r("div",{"data-fragment":!0},e("design-system:fileUpload.title",{description:this.description}))),this.error?r("div",{className:`${u}__errored-files`},new Set(this.namesOfUnsupportedFiles.map((n,i)=>{const a=Math.floor(n.length/2);return r("div",{className:`${u}__errored-filename`,key:n},r("span",{className:`${u}__errored-filename-segment`},n.substr(0,a)),r("div",{className:`${u}__errored-filename-segment`},r("span",null,n.substr(a))),i<this.namesOfUnsupportedFiles.length-1?",":"")}))):r("span",null),r("div",{className:`${u}__instructions`},r("div",{"data-fragment":!0},r("span",null,s[0]),r("a",{href:"",onClick:this.handleBrowseLinkClick},s[1]),r("span",null,s[2]))),r("div",{className:`${u}__requirements`},this.acceptExtensions?r("span",null,"("," ",e("design-system:fileUpload.acceptedTypes",{fileTypes:this.acceptExtensionsDescription})," ",")"):"",this.maxSize?r("span",null,"("," ",e("design-system:fileUpload.maximumSize",{size:this.maxSize})," ",")"):"",this.customRequirement?r("span",null," ",this.customRequirement," "):""),this.downloadLabel&&r("div",{className:`sps-button sps-button--link ${u}__download-button`,onClick:this.handleDownloadButtonClick},r("button",{type:"button"},r("i",{className:"sps-icon sps-icon-download-cloud","aria-hidden":"true"})," ",this.downloadLabel)))),this.dismissable&&!this.processing&&r("div",{className:`sps-button sps-button--icon ${u}__close-button`,onClick:this.dismiss},r("button",{type:"button",title:e("design-system:fileUpload.close")},r("i",{className:"sps-icon sps-icon-x","aria-hidden":"true"}))),r("form",null,r("input",{type:"file",accept:this.accept||"*/*",multiple:this.multiple||null,onChange:this.handleFileInputChange})))}parseAndValidateMaxSize(e){try{this.maxSizeBytes=l.parseFileSize(e)}catch{throw new Error(`Could not parse "${e}" as a file size.`)}}processAcceptExtensions(e){const s=(Array.isArray(e)?e:e.trim().split(/\s?,\s?/)).map(i=>i.replace(/^\./,"")),n=s.map(i=>`.${i}`.toLowerCase());this.acceptExtensionsDescription=n.map((i,a)=>a>0&&a===n.length-1?`or ${i}`:i).join(n.length>2?", ":" "),this.acceptMIMETypes.clear();for(const i of s)for(const a of exports.MIMEType[i.toUpperCase()].split(","))this.acceptMIMETypes.add(a);this.accept=n.concat(Array.from(this.acceptMIMETypes)).join(",")}selectFiles(e){this.namesOfUnsupportedFiles=[];const t=Array.from(e);for(const s of t)this.acceptExtensions&&!this.acceptMIMETypes.has(s.type)&&this.namesOfUnsupportedFiles.push(s.name),this.maxSize&&s.size>this.maxSizeBytes&&this.namesOfUnsupportedFiles.push(s.name);this.namesOfUnsupportedFiles.length?(this.error=!0,this.fileInput.value=null,this.update()):(this.files=t,this.selection.dispatch(t))}handleDragOver(e){e.preventDefault(),e.stopPropagation()}handleDragEnter(e){e.preventDefault(),this.active=!0,this.error=!1,this.update()}handleDragLeave(e){e.preventDefault(),this.active=!1,this.update()}handleDrop(e){e.preventDefault(),e.stopPropagation(),this.active=!1,e.dataTransfer.items?this.selectFiles(Array.from(e.dataTransfer.items).map(t=>t.getAsFile())):this.selectFiles(e.dataTransfer.files),this.update()}handleBrowseLinkClick(e){e.preventDefault(),this.error=!1,this.update(),this.fileInput.click()}handleDownloadButtonClick(){this.download.dispatch()}handleFileInputChange(e){e.stopPropagation(),this.selectFiles(e.target.files)}};exports.SpsFileUploadComponent.displayName=u;exports.SpsFileUploadComponent.props={description:"string",multiple:"boolean",dismissable:"boolean",processing:"boolean",mini:"boolean",downloadLabel:"string",acceptExtensions:"Array<string> | string",maxSize:"string",customRequirement:"string",selection:{event:!0,type:"CustomEvent<Array<File>>"},dismissal:{event:!0,type:"CustomEvent<void>"},download:{event:!0,type:"CustomEvent<void>"}};h([p()],exports.SpsFileUploadComponent.prototype,"description",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"multiple",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"shown",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"dismissable",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"processing",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"mini",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"constrainContentWidth",2);h([p()],exports.SpsFileUploadComponent.prototype,"downloadLabel",2);h([p()],exports.SpsFileUploadComponent.prototype,"acceptExtensions",2);h([p()],exports.SpsFileUploadComponent.prototype,"maxSize",2);h([p()],exports.SpsFileUploadComponent.prototype,"customRequirement",2);h([K()],exports.SpsFileUploadComponent.prototype,"selection",2);h([K()],exports.SpsFileUploadComponent.prototype,"dismissal",2);h([K()],exports.SpsFileUploadComponent.prototype,"download",2);h([Q("input[type='file']")],exports.SpsFileUploadComponent.prototype,"fileInput",2);h([j("dragover")],exports.SpsFileUploadComponent.prototype,"handleDragOver",1);h([j("dragenter")],exports.SpsFileUploadComponent.prototype,"handleDragEnter",1);h([j("dragleave")],exports.SpsFileUploadComponent.prototype,"handleDragLeave",1);h([j("drop")],exports.SpsFileUploadComponent.prototype,"handleDrop",1);exports.SpsFileUploadComponent=h([O({tag:u})],exports.SpsFileUploadComponent);const Ee={basic:{label:"Basic File Upload",description:l.code`
181
+ */c.applyAttr=de;c.applyProp=he;c.attributes=U;c.close=ye;var te=c.currentElement=mt,se=c.currentPointer=ft;c.open=Ne;var Nt=c.patch=Ce;c.patchInner=Ce;c.patchOuter=ct;c.skip=gt;var ne=c.skipNode=M;c.getKey=at;c.clearCache=ge;c.importNode=fe;c.isDataInitialized=it;c.notifications=B;c.symbols=V;var Ie=c.attr=wt,yt=c.elementClose=Pe;c.elementOpen=ee;var At=c.elementOpenEnd=St,Pt=c.elementOpenStart=Ct;c.elementVoid=_t;var It=c.text=xt;c.key=bt;function De(e){let t=se();return t instanceof Comment&&t.data!==e?t.data=e:(t=document.createComment(e),te().appendChild(t)),ne(),t}let Oe=T.noI18nI18n;function Dt(e){Oe=e}function Ot(){return Oe}const I=Symbol("ComponentMetadata"),b=Object.freeze({has(e,t){return Boolean(e[I]&&Object.prototype.hasOwnProperty.call(e[I],t))},add(e,t){e[I]?Object.assign(e[I],t):e[I]=t},get(e,t,s){return e[I]&&e[I][t]||s}}),Fe=Symbol("ds-web-components:pragma:listeners-attached"),Le="idom-pragma:content-begin",ie="idom-pragma:content-end";function ae(e){for(const t of e)if(typeof t=="function")t();else if(typeof t=="string")It(t);else if(t instanceof Set)ae(Array.from(t));else if(Array.isArray(t)&&t.length>0){let s=se();if(De(Le),s===null){const n=te();for(let i=0;i<t.length;i+=1)n.contains(t[i])||n.appendChild(t[i]),ne()}for(;s&&s.data!==ie;)ne(),s=se();De(ie)}}function r(e,t,...s){if(t){for(const n of Object.keys(t))if(n.toUpperCase()==="DATA-FRAGMENT")return()=>ae(s)}return()=>{Pt(e);const n=[];if(t)for(const a of Object.keys(t))a.toUpperCase()==="CLASSNAME"?Ie("class",t[a]):/^on[A-Z]/.test(a)?n.push(a):Ie(a,t[a]);At(e);const i=te();if(!i[Fe]){for(const a of n)i.addEventListener(a.substr(2).toLowerCase(),t[a]);i[Fe]=!0}ae(s),yt(e)}}function ke(e,t){customElements.get(e)||customElements.define(e,t)}function Ft(...e){for(const t of e)ke(b.get(t,"tag"),t)}function Lt(e){return function(...s){for(const n of s){const i=`${e}${b.get(n,"tag").substr(3)}`;ke(i,n)}}}const re=Symbol("Component Attribute Bindings"),D=Symbol("Component Class Bindings"),G=Symbol("Component Style Bindings"),kt={__initialized:!1,__observer:null,__queuedUpdate:null,__managedClasses:new Set,__updateHostBindings(){const e=this;for(const t of Object.keys(e[re]||{}))e.setAttribute(t,e[re][t]);for(const t of Object.keys(e[G]||{}))e.style[t]=e[G][t];for(const t of e.__managedClasses)e.classList.remove(t);for(const t of(e[D]||[]).filter(Boolean))e.__managedClasses.add(t),e.classList.add(t);for(const t of(e.getAttribute("classname")||"").split(/\w+/).filter(Boolean))e.classList.add(t)},__updateChildQueries(e){const t=this;for(const s of b.get(t.constructor,"childQueries",[]))if(!e||e&&s.refresh){const n=s.all?t.querySelectorAll:t.querySelector;t[s.key]=n.call(t,s.selector)}},__gatherChildren(){const e=this;let t=Array.from(e.childNodes),s=null,n=t.length;for(let i=0;i<t.length;i+=1){const a=t[i];a instanceof Comment&&(a.data===Le?s=i+1:a.data===ie&&(n=i-1))}if(s===null)for(const i of t)i.parentNode.removeChild(i);else t=t.slice(s,n);b.has(e.constructor,"contentProp")&&(e[b.get(e.constructor,"contentProp")]=t)},__startMutObs(){const e=this;e.__observer||(e.__observer=new MutationObserver(()=>{e.contentChangedCallback&&e.contentChangedCallback(),e.__gatherChildren(),e.update()})),e.__observer.observe(e,{childList:!0})},__stopMutObs(){const e=this;e.__observer&&e.__observer.disconnect()},__doRender(){const e=this;e.__stopMutObs(),Nt(e,e.render(Ot())),e.__startMutObs()},update(){const e=this;e.__initialized&&!e.__queuedUpdate&&(e.__queuedUpdate=window.requestAnimationFrame(()=>{e.__doRender(),setTimeout(()=>{e.__updateChildQueries(!0),e.__updateHostBindings()},0),e.__queuedUpdate=null}))},attributeChangedCallback(e,t,s){const n=this,i=s===""?!0:s;i!==t&&(n.__cbAttributeChanged&&n.__cbAttributeChanged(e,n[e],i),e!=="style"&&(n[e]=i),n.__initialized&&n.update())},connectedCallback(){const e=this;e.__cbConnected&&e.__cbConnected();const t=b.get(e.constructor,"eventListeners",[]);setTimeout(()=>{if(!e.__initialized){e.__gatherChildren();for(const[,s]of t)e[s]=e[s].bind(e);e.__initialized=!0}for(const[s,n]of t)e.addEventListener(s,e[n]);e.__doRender(),setTimeout(()=>{e.__updateChildQueries(),e.__updateHostBindings()},0)},0)},disconnectedCallback(){const e=this;e.__cbDisconnected&&e.__cbDisconnected();for(const[t,s]of b.get(e.constructor,"eventListeners",[]))e.removeEventListener(t,e[s]);e.__stopMutObs()}};function O(e){return t=>{b.add(t,e),Object.assign(t.prototype,{__cbAttributeChanged:t.prototype.attributeChangedCallback,__cbConnected:t.prototype.connectedCallback,__cbDisconnected:t.prototype.disconnectedCallback},kt)}}function X(){return(e,t)=>{b.add(e.constructor,{contentProp:t})}}function K(e){return(t,s)=>{Object.defineProperty(t,s,{get(){return Object.defineProperty(this,s,{value:{dispatch:n=>{const i=new CustomEvent(e||s,{detail:n});return this.dispatchEvent(i),i}}}),this[s]},configurable:!0})}}function j(e){return(t,s)=>{const n=b.get(t.constructor,"eventListeners",[]);n.push([e,s]),b.add(t.constructor,{eventListeners:n})}}function p(e){return(t,s)=>{const n=t.constructor,i=s.toLowerCase();if(n.observedAttributes=n.observedAttributes||["classname","className","style"],n.observedAttributes.push(s),n.observedAttributes.push(i),i!==s&&Object.defineProperty(t,s,{get(){return this[i]},set(a){this[i]=a}}),e){const a=Symbol.for(s);Object.defineProperty(t,i,{get(){return this[a]},set(o){let g=o;e===Boolean&&typeof o=="string"&&o.toLowerCase()==="false"?g=!1:g=e(o),this[a]=g}})}}}function Te(e,t,s){return(n,i)=>{const a=b.get(n.constructor,"childQueries",[]);a.push({key:i,selector:e,all:s,refresh:t.refresh}),b.add(n.constructor,{childQueries:a})}}function Q(e,t={}){return Te(e,t)}function Ue(e,t={}){return Te(e,t,!0)}function oe(){return(e,t)=>{const s=Symbol(t);Object.defineProperties(e,{[s]:{writable:!0,enumerable:!1,configurable:!1,value:e[t]},[t]:{get(){return this[s]},set(n){this[s]!==n&&(this[s]=n,this.update())}}})}}exports.MIMEType=void 0;(function(e){e["7Z"]="application/x-7z-compressed",e.AAC="audio/aac",e.ABW="application/x-abiword",e.ARC="application/octet-stream",e.AVI="video/x-msvideo",e.AZW="application/vnd.amazon.ebook",e.BIN="application/octet-stream",e.BMP="image/bmp",e.BZ="application/x-bzip",e.BZ2="application/x-bzip2",e.CSH="application/x-csh",e.CSS="text/css",e.CSV="text/csv,application/vnd.ms-excel",e.DOC="application/msword",e.DOCX="application/vnd.openxmlformats-officedocument.wordprocessingml.document",e.EOT="application/vnd.ms-fontobject",e.EPUB="application/epub+zip",e.ES="application/ecmascript",e.FLV="video/x-flv",e.GIF="image/gif",e.GZ="application/x-gzip",e.HTM="text/html",e.HTML="text/html",e.ICO="image/x-icon",e.ICS="text/calendar",e.JAR="application/java-archive",e.JPEG="image/jpeg",e.JPG="image/jpeg",e.JS="application/javascript",e.JSON="application/json",e.M3U="audio/x-mpequrl",e.MID="audio/midi",e.MIDI="audio/midi",e.MOV="video/quicktime",e.MP3="audio/mpeg3",e.MP4="video/mp4",e.MPEG="video/mpeg",e.MPKG="application/vnd.apple.installer+xml",e.ODP="application/vnd.oasis.opendocument.presentation",e.ODS="application/vnd.oasis.opendocument.spreadsheet",e.ODT="application/vnd.oasis.opendocument.text",e.OGA="audio/ogg",e.OGV="video/ogg",e.OGX="application/ogg",e.OTF="font/otf",e.PNG="image/png",e.PDF="application/pdf",e.PPT="application/vnd.ms-powerpoint",e.PPTX="application/vnd.openxmlformats-officedocument.presentationml.presentation",e.RAR="application/x-rar-compressed",e.RTF="application/rtf",e.SH="application/x-sh",e.SVG="image/svg+xml",e.SWF="application/x-shockwave-flash",e.TAR="application/x-tar",e.TIF="image/tiff",e.TIFF="image/tiff",e.TS="application/typescript",e.TTF="font/ttf",e.TXT="text/plain",e.VSD="application/vnd.visio",e.WAV="audio/wav",e.WEBA="audio/webm",e.WEBM="video/webm",e.WEBP="image/webp",e.WOFF="font/woff",e.WOFF2="font/woff2",e.XHTML="application/xhtml+xml",e.XLS="application/vnd.ms-excel",e.XLSX="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",e.XML="application/xml",e.XUL="application/vnd.mozilla.xul+xml",e.ZIP="application/zip"})(exports.MIMEType||(exports.MIMEType={}));var Tt=Object.defineProperty,Ut=Object.getOwnPropertyDescriptor,h=(e,t,s,n)=>{for(var i=n>1?void 0:n?Ut(t,s):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(n?o(t,s,i):o(i))||i);return n&&i&&Tt(t,s,i),i};const u="sps-file-upload";exports.SpsFileUploadComponent=class extends HTMLElement{constructor(){super();this.shown=!0,this.files=[],this.acceptMIMETypes=new Set,this.active=!1,this.error=!1,this.namesOfUnsupportedFiles=[],this.handleBrowseLinkClick=this.handleBrowseLinkClick.bind(this),this.handleDownloadButtonClick=this.handleDownloadButtonClick.bind(this),this.handleFileInputChange=this.handleFileInputChange.bind(this),this.dismiss=this.dismiss.bind(this)}get[D](){return[u,this.active&&`${u}--active`,this.error&&`${u}--error`,!this.shown&&`${u}--hidden`,this.mini&&`${u}--mini`,this.constrainContentWidth&&`${u}--constrained-content-width`]}connectedCallback(){this.description=this.description||(this.multiple?"Files":"File"),this.acceptExtensions&&this.processAcceptExtensions(this.acceptExtensions),this.maxSize&&this.parseAndValidateMaxSize(this.maxSize)}attributeChangedCallback(e,t,s){e==="acceptExtensions"&&this.processAcceptExtensions(s),e==="maxSize"&&this.parseAndValidateMaxSize(s)}dismiss(){this.dismissable&&(this.shown=!1,this.update(),this.dismissal.dispatch())}show(){this.dismissable&&(this.shown=!0,this.update())}render({t:e}){const t=this.error?T.SpsIcon.EXCLAMATION_CIRCLE:T.SpsIcon.UPLOAD_CLOUD,s=(this.multiple?e("design-system:fileUpload.instructions_plural"):e("design-system:fileUpload.instructions")).split("|");return r("div",{"data-fragment":!0},r("div",{className:`${u}__content`},this.processing?r("div",{"data-fragment":!0},r("i",{className:"sps-spinner sps-spinner--medium","aria-hidden":"true"}),r("div",{className:`${u}__instructions`},e("design-system:fileUpload.processing"))):r("div",{"data-fragment":!0},r("i",{className:`sps-icon sps-icon-${t} ${u}__icon-primary`,"aria-hidden":"true"}),r("div",{className:`${u}__title`},this.error?r("div",{"data-fragment":!0},e(this.namesOfUnsupportedFiles.length>1?"design-system:fileUpload.cancelled_plural":"design-system:fileUpload.cancelled")):r("div",{"data-fragment":!0},e("design-system:fileUpload.title",{description:this.description}))),this.error?r("div",{className:`${u}__errored-files`},new Set(this.namesOfUnsupportedFiles.map((n,i)=>{const a=Math.floor(n.length/2);return r("div",{className:`${u}__errored-filename`,key:n},r("span",{className:`${u}__errored-filename-segment`},n.substr(0,a)),r("div",{className:`${u}__errored-filename-segment`},r("span",null,n.substr(a))),i<this.namesOfUnsupportedFiles.length-1?",":"")}))):r("span",null),r("div",{className:`${u}__instructions`},r("div",{"data-fragment":!0},r("span",null,s[0]),r("a",{href:"",onClick:this.handleBrowseLinkClick},s[1]),r("span",null,s[2]))),r("div",{className:`${u}__requirements`},this.acceptExtensions?r("span",null,"("," ",e("design-system:fileUpload.acceptedTypes",{fileTypes:this.acceptExtensionsDescription})," ",")"):"",this.maxSize?r("span",null,"("," ",e("design-system:fileUpload.maximumSize",{size:this.maxSize})," ",")"):"",this.customRequirement?r("span",null," ",this.customRequirement," "):""),this.downloadLabel&&r("div",{className:`sps-button sps-button--link ${u}__download-button`,onClick:this.handleDownloadButtonClick},r("button",{type:"button"},r("i",{className:"sps-icon sps-icon-download-cloud","aria-hidden":"true"})," ",this.downloadLabel)))),this.dismissable&&!this.processing&&r("div",{className:`sps-button sps-button--icon ${u}__close-button`,onClick:this.dismiss},r("button",{type:"button",title:e("design-system:fileUpload.close")},r("i",{className:"sps-icon sps-icon-x","aria-hidden":"true"}))),r("form",null,r("input",{type:"file",accept:this.accept||"*/*",multiple:this.multiple||null,onChange:this.handleFileInputChange})))}parseAndValidateMaxSize(e){try{this.maxSizeBytes=l.parseFileSize(e)}catch{throw new Error(`Could not parse "${e}" as a file size.`)}}processAcceptExtensions(e){const s=(Array.isArray(e)?e:e.trim().split(/\s?,\s?/)).map(i=>i.replace(/^\./,"")),n=s.map(i=>`.${i}`.toLowerCase());this.acceptExtensionsDescription=n.map((i,a)=>a>0&&a===n.length-1?`or ${i}`:i).join(n.length>2?", ":" "),this.acceptMIMETypes.clear();for(const i of s)for(const a of exports.MIMEType[i.toUpperCase()].split(","))this.acceptMIMETypes.add(a);this.accept=n.concat(Array.from(this.acceptMIMETypes)).join(",")}selectFiles(e){this.namesOfUnsupportedFiles=[];const t=Array.from(e);for(const s of t)this.acceptExtensions&&!this.acceptMIMETypes.has(s.type)&&this.namesOfUnsupportedFiles.push(s.name),this.maxSize&&s.size>this.maxSizeBytes&&this.namesOfUnsupportedFiles.indexOf(s.name)===-1&&this.namesOfUnsupportedFiles.push(s.name);this.namesOfUnsupportedFiles.length?(this.error=!0,this.fileInput.value=null,this.update()):(this.files=t,this.selection.dispatch(t))}handleDragOver(e){e.preventDefault(),e.stopPropagation()}handleDragEnter(e){e.preventDefault(),this.active=!0,this.error=!1,this.update()}handleDragLeave(e){e.preventDefault(),this.active=!1,this.update()}handleDrop(e){e.preventDefault(),e.stopPropagation(),this.active=!1,e.dataTransfer.items?this.selectFiles(Array.from(e.dataTransfer.items).map(t=>t.getAsFile())):this.selectFiles(e.dataTransfer.files),this.update()}handleBrowseLinkClick(e){e.preventDefault(),this.error=!1,this.update(),this.fileInput.click()}handleDownloadButtonClick(){this.download.dispatch()}handleFileInputChange(e){e.stopPropagation(),this.selectFiles(e.target.files)}};exports.SpsFileUploadComponent.displayName=u;exports.SpsFileUploadComponent.props={description:"string",multiple:"boolean",dismissable:"boolean",processing:"boolean",mini:"boolean",downloadLabel:"string",acceptExtensions:"Array<string> | string",maxSize:"string",customRequirement:"string",selection:{event:!0,type:"CustomEvent<Array<File>>"},dismissal:{event:!0,type:"CustomEvent<void>"},download:{event:!0,type:"CustomEvent<void>"}};h([p()],exports.SpsFileUploadComponent.prototype,"description",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"multiple",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"shown",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"dismissable",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"processing",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"mini",2);h([p(Boolean)],exports.SpsFileUploadComponent.prototype,"constrainContentWidth",2);h([p()],exports.SpsFileUploadComponent.prototype,"downloadLabel",2);h([p()],exports.SpsFileUploadComponent.prototype,"acceptExtensions",2);h([p()],exports.SpsFileUploadComponent.prototype,"maxSize",2);h([p()],exports.SpsFileUploadComponent.prototype,"customRequirement",2);h([K()],exports.SpsFileUploadComponent.prototype,"selection",2);h([K()],exports.SpsFileUploadComponent.prototype,"dismissal",2);h([K()],exports.SpsFileUploadComponent.prototype,"download",2);h([Q("input[type='file']")],exports.SpsFileUploadComponent.prototype,"fileInput",2);h([j("dragover")],exports.SpsFileUploadComponent.prototype,"handleDragOver",1);h([j("dragenter")],exports.SpsFileUploadComponent.prototype,"handleDragEnter",1);h([j("dragleave")],exports.SpsFileUploadComponent.prototype,"handleDragLeave",1);h([j("drop")],exports.SpsFileUploadComponent.prototype,"handleDrop",1);exports.SpsFileUploadComponent=h([O({tag:u})],exports.SpsFileUploadComponent);const Ee={basic:{label:"Basic File Upload",description:l.code`
182
182
  <p>Simply allow the user to drag-and-drop or select either a single file or multiple files at once.</p>
183
183
  `,examples:{single:{description:"<p>Single file upload</p>",react:l.code`
184
184
  function Component() {
package/lib/index.es.js CHANGED
@@ -1451,7 +1451,7 @@ let SpsFileUploadComponent = class extends HTMLElement {
1451
1451
  if (this.acceptExtensions && !this.acceptMIMETypes.has(file.type)) {
1452
1452
  this.namesOfUnsupportedFiles.push(file.name);
1453
1453
  }
1454
- if (this.maxSize && file.size > this.maxSizeBytes) {
1454
+ if (this.maxSize && file.size > this.maxSizeBytes && this.namesOfUnsupportedFiles.indexOf(file.name) === -1) {
1455
1455
  this.namesOfUnsupportedFiles.push(file.name);
1456
1456
  }
1457
1457
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spscommerce/ds-web-components",
3
3
  "description": "SPS Design System Native Web Components",
4
- "version": "5.21.2",
4
+ "version": "5.21.5",
5
5
  "author": "SPS Commerce",
6
6
  "license": "UNLICENSED",
7
7
  "repository": "https://github.com/spscommerce/design-system/tree/main/packages/@spscommerce/ds-web-components",
@@ -16,12 +16,12 @@
16
16
  "incremental-dom": "^0.6.0"
17
17
  },
18
18
  "peerDependencies": {
19
- "@spscommerce/ds-shared": "5.21.2",
20
- "@spscommerce/utils": "5.21.2"
19
+ "@spscommerce/ds-shared": "5.21.5",
20
+ "@spscommerce/utils": "5.21.5"
21
21
  },
22
22
  "devDependencies": {
23
- "@spscommerce/ds-shared": "5.21.2",
24
- "@spscommerce/utils": "5.21.2"
23
+ "@spscommerce/ds-shared": "5.21.5",
24
+ "@spscommerce/utils": "5.21.5"
25
25
  },
26
26
  "scripts": {
27
27
  "build": "pnpm run build:js && pnpm run build:types && pnpm run build:create-dist && pnpm run build:copy-dist",