@mux/mux-uploader-react
Advanced tools
Comparing version 0.1.0-canary.4-df8c8fd to 0.1.0-canary.5-94d000a
@@ -228,3 +228,3 @@ var et=Object.create;var se=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var nt=Object.getOwnPropertyNames;var rt=Object.getPrototypeOf,ot=Object.prototype.hasOwnProperty;var Le=e=>se(e,"__esModule",{value:!0});var st=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),it=(e,t)=>{Le(e);for(var r in t)se(e,r,{get:t[r],enumerable:!0})},at=(e,t,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of nt(t))!ot.call(e,o)&&o!=="default"&&se(e,o,{get:()=>t[o],enumerable:!(r=tt(t,o))||r.enumerable});return e},z=e=>at(Le(se(e!=null?et(rt(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var Se=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var _e=(e,t,r)=>(Se(e,t,"read from private field"),r?r.call(e):t.get(e)),Be=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Ue=(e,t,r,o)=>(Se(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r);var Fe=st((ee,he)=>{(function(e,t){typeof ee=="object"&&typeof he=="object"?he.exports=t():typeof define=="function"&&define.amd?define([],t):typeof ee=="object"?ee.UpChunk=t():e.UpChunk=t()})(ee,function(){return function(e){var t={};function r(o){if(t[o])return t[o].exports;var a=t[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(o,a,p){r.o(o,a)||Object.defineProperty(o,a,{enumerable:!0,get:p})},r.r=function(o){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})},r.t=function(o,a){if(1&a&&(o=r(o)),8&a||4&a&&typeof o=="object"&&o&&o.__esModule)return o;var p=Object.create(null);if(r.r(p),Object.defineProperty(p,"default",{enumerable:!0,value:o}),2&a&&typeof o!="string")for(var T in o)r.d(p,T,function(R){return o[R]}.bind(null,T));return p},r.n=function(o){var a=o&&o.__esModule?function(){return o.default}:function(){return o};return r.d(a,"a",a),a},r.o=function(o,a){return Object.prototype.hasOwnProperty.call(o,a)},r.p="",r(r.s=1)}([function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch{typeof window=="object"&&(r=window)}e.exports=r},function(e,t,r){"use strict";var o=this&&this.__assign||function(){return(o=Object.assign||function(f){for(var n,l=1,b=arguments.length;l<b;l++)for(var E in n=arguments[l])Object.prototype.hasOwnProperty.call(n,E)&&(f[E]=n[E]);return f}).apply(this,arguments)};t.__esModule=!0,t.createUpload=t.UpChunk=void 0;var a=r(2),p=r(4),T=[200,201,202,204,308],R=[408,502,503,504],v=function(){function f(n){var l=this;this.endpoint=n.endpoint,this.file=n.file,this.headers=n.headers||{},this.method=n.method||"PUT",this.chunkSize=n.chunkSize||30720,this.attempts=n.attempts||5,this.delayBeforeAttempt=n.delayBeforeAttempt||1,this.maxFileBytes=1024*(n.maxFileSize||0),this.chunkCount=0,this.chunkByteSize=1024*this.chunkSize,this.totalChunks=Math.ceil(this.file.size/this.chunkByteSize),this.attemptCount=0,this.offline=!1,this.paused=!1,this.success=!1,this.reader=new FileReader,this.eventTarget=new a.EventTarget,this.validateOptions(),this.getEndpoint().then(function(){return l.sendChunks()}),typeof window!="undefined"&&(window.addEventListener("online",function(){l.offline&&(l.offline=!1,l.dispatch("online"),l.sendChunks())}),window.addEventListener("offline",function(){l.offline=!0,l.dispatch("offline")}))}return f.prototype.on=function(n,l){this.eventTarget.addEventListener(n,l)},f.prototype.abort=function(){var n;this.pause(),(n=this.currentXhr)===null||n===void 0||n.abort()},f.prototype.pause=function(){this.paused=!0},f.prototype.resume=function(){this.paused&&(this.paused=!1,this.sendChunks())},f.prototype.dispatch=function(n,l){var b=new CustomEvent(n,{detail:l});this.eventTarget.dispatchEvent(b)},f.prototype.validateOptions=function(){if(!this.endpoint||typeof this.endpoint!="function"&&typeof this.endpoint!="string")throw new TypeError("endpoint must be defined as a string or a function that returns a promise");if(!(this.file instanceof File))throw new TypeError("file must be a File object");if(this.headers&&typeof this.headers!="object")throw new TypeError("headers must be null or an object");if(this.chunkSize&&(typeof this.chunkSize!="number"||this.chunkSize<=0||this.chunkSize%256!=0))throw new TypeError("chunkSize must be a positive number in multiples of 256");if(this.maxFileBytes>0&&this.maxFileBytes<this.file.size)throw new Error("file size exceeds maximum (".concat(this.file.size," > ").concat(this.maxFileBytes,")"));if(this.attempts&&(typeof this.attempts!="number"||this.attempts<=0))throw new TypeError("retries must be a positive number");if(this.delayBeforeAttempt&&(typeof this.delayBeforeAttempt!="number"||this.delayBeforeAttempt<0))throw new TypeError("delayBeforeAttempt must be a positive number")},f.prototype.getEndpoint=function(){var n=this;return typeof this.endpoint=="string"?(this.endpointValue=this.endpoint,Promise.resolve(this.endpoint)):this.endpoint(this.file).then(function(l){return n.endpointValue=l,n.endpointValue})},f.prototype.getChunk=function(){var n=this;return new Promise(function(l){var b=n.totalChunks===1?n.file.size:n.chunkByteSize,E=b*n.chunkCount;n.reader.onload=function(){n.reader.result!==null&&(n.chunk=new Blob([n.reader.result],{type:"application/octet-stream"})),l()},n.reader.readAsArrayBuffer(n.file.slice(E,E+b))})},f.prototype.xhrPromise=function(n){var l=this,b=function(E){E.upload.onprogress=function(x){var w,y=100/l.totalChunks,A=y*l.file.size,d=y*l.chunkCount,j=x.loaded/((w=x.total)!==null&&w!==void 0?w:A)*y;l.dispatch("progress",Math.min(d+j,100))}};return new Promise(function(E,x){l.currentXhr=(0,p.default)(o(o({},n),{beforeSend:b}),function(w,y){return l.currentXhr=void 0,w?x(w):E(y)})})},f.prototype.sendChunk=function(){var n=this.chunkCount*this.chunkByteSize,l=n+this.chunk.size-1,b=o(o({},this.headers),{"Content-Type":this.file.type,"Content-Range":"bytes ".concat(n,"-").concat(l,"/").concat(this.file.size)});return this.dispatch("attempt",{chunkNumber:this.chunkCount,chunkSize:this.chunk.size}),this.xhrPromise({headers:b,url:this.endpointValue,method:this.method,body:this.chunk})},f.prototype.manageRetries=function(){var n=this;if(this.attemptCount<this.attempts)return setTimeout(function(){return n.sendChunks()},1e3*this.delayBeforeAttempt),void this.dispatch("attemptFailure",{message:"An error occured uploading chunk ".concat(this.chunkCount,". ").concat(this.attempts-this.attemptCount," retries left."),chunkNumber:this.chunkCount,attemptsLeft:this.attempts-this.attemptCount});this.dispatch("error",{message:"An error occured uploading chunk ".concat(this.chunkCount,". No more retries, stopping upload"),chunk:this.chunkCount,attempts:this.attemptCount})},f.prototype.sendChunks=function(){var n=this;this.paused||this.offline||this.success||this.getChunk().then(function(){return n.attemptCount=n.attemptCount+1,n.sendChunk()}).then(function(l){if(T.includes(l.statusCode)){n.dispatch("chunkSuccess",{chunk:n.chunkCount,attempts:n.attemptCount,response:l}),n.attemptCount=0,n.chunkCount=n.chunkCount+1,n.chunkCount<n.totalChunks?n.sendChunks():(n.success=!0,n.dispatch("success"));var b=100*(n.chunkCount/n.totalChunks*n.file.size)/n.file.size;n.dispatch("progress",b)}else if(R.includes(l.statusCode)){if(n.paused||n.offline)return;n.manageRetries()}else{if(n.paused||n.offline)return;n.dispatch("error",{message:"Server responded with ".concat(l.statusCode,". Stopping upload."),chunkNumber:n.chunkCount,attempts:n.attemptCount})}}).catch(function(l){n.paused||n.offline||n.manageRetries()})},f}();t.UpChunk=v,t.createUpload=function(f){return new v(f)}},function(e,t,r){"use strict";(function(o,a){function p(s,i,...u){if(!s)throw new TypeError(T(i,u))}function T(s,i){let u=0;return s.replace(/%[os]/gu,()=>R(i[u++]))}function R(s){return typeof s!="object"||s===null?String(s):Object.prototype.toString.call(s)}let v;Object.defineProperty(t,"__esModule",{value:!0});let f=typeof window!="undefined"?window:typeof self!="undefined"?self:a!==void 0?a:typeof globalThis!="undefined"?globalThis:void 0,n;class l{constructor(i,u){this.code=i,this.message=u}warn(...i){var u;try{if(n)return void n({...this,args:i});let c=((u=new Error().stack)!==null&&u!==void 0?u:"").replace(/^(?:.+?\n){2}/gu,` | ||
</div> | ||
`;var ae={BAR:"bar",RADIAL:"radial"},lt=e=>`${Math.floor(e)}%`,ct=e=>{var t;return Number((t=e.svgCircle)==null?void 0:t.getAttribute("r"))},te=e=>ct(e)*2*Math.PI,pt="Media upload progress bar",Ve=["Enter"," "],qe=class extends HTMLElement{constructor(){super();var e,t,r,o,a,p,T,R,v,f,n;this.handleFilePickerButtonClick=this.handleFilePickerButtonClick.bind(this);let l=this.attachShadow({mode:"open"}),b=Xe.content.cloneNode(!0);l.appendChild(b),this.filePickerButton=(e=this.shadowRoot)==null?void 0:e.querySelector("slot[name=upload-button] > *"),this.svgCircle=(t=this.shadowRoot)==null?void 0:t.querySelector("circle"),this.progressBar=(r=this.shadowRoot)==null?void 0:r.getElementById("progress-bar"),this.uploadPercentage=(o=this.shadowRoot)==null?void 0:o.getElementById("upload-status"),this.statusMessage=(a=this.shadowRoot)==null?void 0:a.getElementById("status-message"),this.retryButton=(p=this.shadowRoot)==null?void 0:p.getElementById("retry-button"),this.srOnlyText=(T=this.shadowRoot)==null?void 0:T.getElementById("sr-only"),(R=this.progressBar)==null||R.setAttribute("aria-description",pt),(v=this.hiddenFileInput)==null||v.addEventListener("change",E=>{var x,w;let y=(w=(x=this.hiddenFileInput)==null?void 0:x.files)==null?void 0:w[0];y&&this.dispatchEvent(new CustomEvent("file-ready",{composed:!0,bubbles:!0,detail:y}))}),(n=(f=this.shadowRoot)==null?void 0:f.querySelector("slot[name=upload-button]"))==null||n.addEventListener("slotchange",()=>{var E,x;this.filePickerButton=(x=(E=this.shadowRoot)==null?void 0:E.querySelector("slot[name=upload-button]"))==null?void 0:x.assignedNodes()[0]})}connectedCallback(){this.setDefaultType(),this.setupRetry(),this.addEventListener("file-ready",this.handleUpload)}disconnectedCallback(){this.removeEventListener("file-ready",this.handleUpload,!1)}get filePickerButton(){return this._filePickerButton}set filePickerButton(e){e!==this._filePickerButton&&(this._filePickerButton&&this._filePickerButton.removeEventListener("click",this.handleFilePickerButtonClick),this._filePickerButton=e,this._filePickerButton&&this._filePickerButton.addEventListener("click",this.handleFilePickerButtonClick))}get hiddenFileInput(){var e;return(e=this.shadowRoot)==null?void 0:e.querySelector("#hidden-file-input")}handleFilePickerButtonClick(e){this.hiddenFileInput.click()}get url(){return this.getAttribute("url")}set url(e){this.setAttribute("url",e)}get formatProgress(){var e;return(e=this._formatProgress)!=null?e:lt}set formatProgress(e){this._formatProgress=e}setDefaultType(){let e=this.getAttribute("type");e||this.setAttribute("type",ae.BAR),e===ae.RADIAL&&this.svgCircle&&(this.svgCircle.style.strokeDasharray=`${te(this)} ${te(this)}`,this.svgCircle.style.strokeDashoffset=`${te(this)}`)}setupRetry(){var e;(e=this.retryButton)==null||e.addEventListener("click",()=>{this.resetState()});let t=r=>{let{key:o}=r;if(!Ve.includes(o)){this.removeEventListener("keyup",t);return}this.resetState()};this.addEventListener("keydown",r=>{let{metaKey:o,altKey:a,key:p}=r;if(o||a||!Ve.includes(p)){this.removeEventListener("keyup",t);return}this.addEventListener("keyup",t)})}resetState(){this.removeAttribute("upload-error"),this.removeAttribute("upload-in-progress"),this.statusMessage&&(this.statusMessage.innerHTML=""),this.uploadPercentage&&(this.uploadPercentage.innerHTML="")}setProgress(e){var t;switch(this.uploadPercentage&&(this.uploadPercentage.innerHTML=this.formatProgress(e)),(t=this.progressBar)==null||t.setAttribute("aria-valuenow",`${Math.floor(e)}`),this.getAttribute("type")){case ae.BAR:this.progressBar&&(this.progressBar.style.width=`${e}%`);case ae.RADIAL:if(this.svgCircle){let r=te(this)-e/100*te(this);this.svgCircle.style.strokeDashoffset=r.toString()}}}handleUpload(e){var t;let r=this.url;if(r)this.statusMessage&&(this.statusMessage.innerHTML="");else{let a="No url attribute specified -- cannot handleUpload";this.statusMessage&&(this.statusMessage.innerHTML=a),console.error(a)}if(this.statusMessage&&(this.removeAttribute("upload-error"),this.statusMessage.innerHTML=""),!r)return;this.setAttribute("upload-in-progress",""),(t=this.progressBar)==null||t.focus();let o=(0,ze.createUpload)({endpoint:r,file:e.detail});o.on("error",a=>{let p="An error has occurred";this.setAttribute("upload-error",""),this.statusMessage&&(this.statusMessage.innerHTML=p),console.error(a.detail.message),this.dispatchEvent(new CustomEvent("error",a))}),o.on("progress",a=>{this.setProgress(a.detail),this.dispatchEvent(new CustomEvent("progress",a))}),o.on("success",a=>{let p="Upload complete!";this.statusMessage&&(this.statusMessage.innerHTML=p),this.srOnlyText&&(this.srOnlyText.innerHTML=p),console.info(p),this.dispatchEvent(new CustomEvent("success",a))})}};globalThis.customElements.get("mux-uploader")||(globalThis.customElements.define("mux-uploader",qe),globalThis.MuxUploaderElement=qe);var ne=z(require("react"));var We={className:"class",classname:"class",htmlFor:"for",crossOrigin:"crossorigin",viewBox:"viewBox",playsInline:"playsinline",autoPlay:"autoplay"},dt=e=>e==null,ht=(e,t)=>dt(t)?!1:e in t,ft=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),gt=(e,t)=>{if(!(typeof t=="boolean"&&!t)){if(ht(e,We))return We[e];if(typeof t!=null)return/[A-Z]/.test(e)?ft(e):e}};var mt=(e,t)=>typeof e=="boolean"?"":e,ue=(e={})=>Object.entries(e).reduce((t,[r,o])=>{let a=gt(r,o);if(!a)return t;let p=mt(o,r);return t[a]=p,t},{});var Ge=z(require("react"));var le=z(require("react")),ce=(...e)=>{let t=(0,le.useRef)(null);return(0,le.useEffect)(()=>{e.forEach(r=>{!r||(typeof r=="function"?r(t.current):r.current=t.current)})},[e]),t};var bt=ne.default.forwardRef(({children:e,...t},r)=>ne.default.createElement("mux-uploader-drop",ue({...t,ref:r}),e)),yt=ne.default.forwardRef((e,t)=>{let r=(0,Ge.useRef)(null),o=ce(r,t);return ne.default.createElement(bt,{ref:o,...e})}),$e=yt;var Ze=z(require("react"));var Ye=z(require("react")),vt=Object.prototype.hasOwnProperty,Et=(e,t)=>{if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.some((a,p)=>t[p]===a);let r=Object.keys(e),o=Object.keys(t);if(r.length!==o.length)return!1;for(let a=0;a<r.length;a++)if(!vt.call(t,r[a])||!Object.is(e[r[a]],t[r[a]]))return!1;return!0},Tt=(e,t,r)=>!Et(t,e[r]),wt=(e,t,r)=>{e[r]=t},kt=(e,t,r,o=wt,a=Tt)=>(0,Ye.useEffect)(()=>{let p=r==null?void 0:r.current;!p||!a(p,t,e)||o(p,t,e)},[r==null?void 0:r.current,t]),Ke=kt;var Rt=X.default.forwardRef(({children:e,...t},r)=>X.default.createElement("mux-uploader",ue({...t,ref:r}),e)),fe=(e,t,r)=>(0,X.useEffect)(()=>{let o=t==null?void 0:t.current;if(!(!o||!r))return o.addEventListener(e,r),()=>{o.removeEventListener(e,r)}},[t==null?void 0:t.current,r]),xt=(e,t)=>{let{onError:r,onProgress:o,onSuccess:a,formatProgress:p,...T}=t;return Ke("formatProgress",p,e),fe("error",e,r),fe("progress",e,o),fe("success",e,a),[T]},Pt=X.default.forwardRef((e,t)=>{let r=(0,Ze.useRef)(null),o=ce(r,t),[a]=xt(r,e);return X.default.createElement(Rt,{ref:o,...a})});var Ct=Pt; | ||
`;var ae={BAR:"bar",RADIAL:"radial"},lt=e=>`${Math.floor(e)}%`,ct=e=>{var t;return Number((t=e.svgCircle)==null?void 0:t.getAttribute("r"))},te=e=>ct(e)*2*Math.PI,pt="Media upload progress bar",Ve=["Enter"," "],qe=class extends HTMLElement{constructor(){super();var e,t,r,o,a,p,T,R,v,f,n;this.handleFilePickerButtonClick=this.handleFilePickerButtonClick.bind(this);let l=this.attachShadow({mode:"open"}),b=Xe.content.cloneNode(!0);l.appendChild(b),this.filePickerButton=(e=this.shadowRoot)==null?void 0:e.querySelector("slot[name=upload-button] > *"),this.svgCircle=(t=this.shadowRoot)==null?void 0:t.querySelector("circle"),this.progressBar=(r=this.shadowRoot)==null?void 0:r.getElementById("progress-bar"),this.uploadPercentage=(o=this.shadowRoot)==null?void 0:o.getElementById("upload-status"),this.statusMessage=(a=this.shadowRoot)==null?void 0:a.getElementById("status-message"),this.retryButton=(p=this.shadowRoot)==null?void 0:p.getElementById("retry-button"),this.srOnlyText=(T=this.shadowRoot)==null?void 0:T.getElementById("sr-only"),(R=this.progressBar)==null||R.setAttribute("aria-description",pt),(v=this.hiddenFileInput)==null||v.addEventListener("change",E=>{var x,w;let y=(w=(x=this.hiddenFileInput)==null?void 0:x.files)==null?void 0:w[0];y&&this.dispatchEvent(new CustomEvent("file-ready",{composed:!0,bubbles:!0,detail:y}))}),(n=(f=this.shadowRoot)==null?void 0:f.querySelector("slot[name=upload-button]"))==null||n.addEventListener("slotchange",()=>{var E,x;this.filePickerButton=(x=(E=this.shadowRoot)==null?void 0:E.querySelector("slot[name=upload-button]"))==null?void 0:x.assignedNodes()[0]})}connectedCallback(){this.setDefaultType(),this.setupRetry(),this.addEventListener("file-ready",this.handleUpload)}disconnectedCallback(){this.removeEventListener("file-ready",this.handleUpload,!1)}get filePickerButton(){return this._filePickerButton}set filePickerButton(e){e!==this._filePickerButton&&(this._filePickerButton&&this._filePickerButton.removeEventListener("click",this.handleFilePickerButtonClick),this._filePickerButton=e,this._filePickerButton&&this._filePickerButton.addEventListener("click",this.handleFilePickerButtonClick))}get hiddenFileInput(){var e;return(e=this.shadowRoot)==null?void 0:e.querySelector("#hidden-file-input")}handleFilePickerButtonClick(e){this.hiddenFileInput.click()}get url(){return this.getAttribute("url")}set url(e){this.setAttribute("url",e)}get formatProgress(){var e;return(e=this._formatProgress)!=null?e:lt}set formatProgress(e){this._formatProgress=e}setDefaultType(){let e=this.getAttribute("type");e||this.setAttribute("type",ae.BAR),e===ae.RADIAL&&this.svgCircle&&(this.svgCircle.style.strokeDasharray=`${te(this)} ${te(this)}`,this.svgCircle.style.strokeDashoffset=`${te(this)}`)}setupRetry(){var e;(e=this.retryButton)==null||e.addEventListener("click",()=>{this.resetState()});let t=r=>{let{key:o}=r;if(!Ve.includes(o)){this.removeEventListener("keyup",t);return}this.resetState()};this.addEventListener("keydown",r=>{let{metaKey:o,altKey:a,key:p}=r;if(o||a||!Ve.includes(p)){this.removeEventListener("keyup",t);return}this.addEventListener("keyup",t)})}resetState(){this.removeAttribute("upload-error"),this.removeAttribute("upload-in-progress"),this.hiddenFileInput.value="",this.statusMessage&&(this.statusMessage.innerHTML=""),this.uploadPercentage&&(this.uploadPercentage.innerHTML="")}setProgress(e){var t;switch(this.uploadPercentage&&(this.uploadPercentage.innerHTML=this.formatProgress(e)),(t=this.progressBar)==null||t.setAttribute("aria-valuenow",`${Math.floor(e)}`),this.getAttribute("type")){case ae.BAR:this.progressBar&&(this.progressBar.style.width=`${e}%`);case ae.RADIAL:if(this.svgCircle){let r=te(this)-e/100*te(this);this.svgCircle.style.strokeDashoffset=r.toString()}}}handleUpload(e){var t;let r=this.url;if(r)this.removeAttribute("upload-error"),this.statusMessage&&(this.statusMessage.innerHTML="");else{let a="No url attribute specified -- cannot handleUpload";this.statusMessage&&(this.statusMessage.innerHTML=a),this.setAttribute("upload-error",""),console.error(a);return}this.setAttribute("upload-in-progress",""),(t=this.progressBar)==null||t.focus();let o=(0,ze.createUpload)({endpoint:r,file:e.detail});o.on("error",a=>{let p="An error has occurred";this.setAttribute("upload-error",""),this.statusMessage&&(this.statusMessage.innerHTML=p),console.error(a.detail.message),this.dispatchEvent(new CustomEvent("error",a))}),o.on("progress",a=>{this.setProgress(a.detail),this.dispatchEvent(new CustomEvent("progress",a))}),o.on("success",a=>{let p="Upload complete!";this.statusMessage&&(this.statusMessage.innerHTML=p),this.srOnlyText&&(this.srOnlyText.innerHTML=p),console.info(p),this.dispatchEvent(new CustomEvent("success",a))})}};globalThis.customElements.get("mux-uploader")||(globalThis.customElements.define("mux-uploader",qe),globalThis.MuxUploaderElement=qe);var ne=z(require("react"));var We={className:"class",classname:"class",htmlFor:"for",crossOrigin:"crossorigin",viewBox:"viewBox",playsInline:"playsinline",autoPlay:"autoplay"},dt=e=>e==null,ht=(e,t)=>dt(t)?!1:e in t,ft=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),gt=(e,t)=>{if(!(typeof t=="boolean"&&!t)){if(ht(e,We))return We[e];if(typeof t!=null)return/[A-Z]/.test(e)?ft(e):e}};var mt=(e,t)=>typeof e=="boolean"?"":e,ue=(e={})=>Object.entries(e).reduce((t,[r,o])=>{let a=gt(r,o);if(!a)return t;let p=mt(o,r);return t[a]=p,t},{});var Ge=z(require("react"));var le=z(require("react")),ce=(...e)=>{let t=(0,le.useRef)(null);return(0,le.useEffect)(()=>{e.forEach(r=>{!r||(typeof r=="function"?r(t.current):r.current=t.current)})},[e]),t};var bt=ne.default.forwardRef(({children:e,...t},r)=>ne.default.createElement("mux-uploader-drop",ue({...t,ref:r}),e)),yt=ne.default.forwardRef((e,t)=>{let r=(0,Ge.useRef)(null),o=ce(r,t);return ne.default.createElement(bt,{ref:o,...e})}),$e=yt;var Ze=z(require("react"));var Ye=z(require("react")),vt=Object.prototype.hasOwnProperty,Et=(e,t)=>{if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.some((a,p)=>t[p]===a);let r=Object.keys(e),o=Object.keys(t);if(r.length!==o.length)return!1;for(let a=0;a<r.length;a++)if(!vt.call(t,r[a])||!Object.is(e[r[a]],t[r[a]]))return!1;return!0},Tt=(e,t,r)=>!Et(t,e[r]),wt=(e,t,r)=>{e[r]=t},kt=(e,t,r,o=wt,a=Tt)=>(0,Ye.useEffect)(()=>{let p=r==null?void 0:r.current;!p||!a(p,t,e)||o(p,t,e)},[r==null?void 0:r.current,t]),Ke=kt;var Rt=X.default.forwardRef(({children:e,...t},r)=>X.default.createElement("mux-uploader",ue({...t,ref:r}),e)),fe=(e,t,r)=>(0,X.useEffect)(()=>{let o=t==null?void 0:t.current;if(!(!o||!r))return o.addEventListener(e,r),()=>{o.removeEventListener(e,r)}},[t==null?void 0:t.current,r]),xt=(e,t)=>{let{onError:r,onProgress:o,onSuccess:a,formatProgress:p,...T}=t;return Ke("formatProgress",p,e),fe("error",e,r),fe("progress",e,o),fe("success",e,a),[T]},Pt=X.default.forwardRef((e,t)=>{let r=(0,Ze.useRef)(null),o=ce(r,t),[a]=xt(r,e);return X.default.createElement(Rt,{ref:o,...a})});var Ct=Pt; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@mux/mux-uploader-react", | ||
"version": "0.1.0-canary.4-df8c8fd", | ||
"version": "0.1.0-canary.5-94d000a", | ||
"type": "commonjs", | ||
@@ -5,0 +5,0 @@ "description": "An uploader element for React that handles Mux Direct Uploads and a visual progress bar for you", |
Sorry, the diff of this file is not supported yet
200176