@zauru-sdk/components 6.18.1 → 6.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/build/assets/Alerts.stories-Dw0Ct9vA.js +1 -0
- package/build/assets/Button-YPU2MaHD.js +1 -0
- package/build/assets/Button.stories-CP6jmzaX.js +1 -0
- package/build/assets/Card.stories-DbFqLafy.js +1 -0
- package/build/assets/Container.stories-BhnM3_6Y.js +1 -0
- package/build/assets/Form.stories-BNB6SmSx.js +1 -0
- package/build/assets/Icons-BxLN_JWC.js +10 -0
- package/build/assets/Labels.stories-Fah6wLSi.js +1 -0
- package/build/assets/Matrix.stories-Dc3-VDms.js +1 -0
- package/build/assets/Modal.stories-D7kIP3bJ.js +1 -0
- package/build/assets/NavBar.stories-DuIgKZkc.js +1 -0
- package/build/assets/SidePanel.stories-Xsm8Md4K.js +1 -0
- package/build/assets/Tab.stories-RKI0m-pt.js +365 -0
- package/build/assets/Table.stories-CGj0WWPk.js +416 -0
- package/build/assets/Titles.stories-CPIRDaJs.js +1 -0
- package/build/assets/Tooltip.stories-D8M6F7St.js +1 -0
- package/build/assets/activestorage.esm-ByWQ3T27.js +1 -0
- package/build/assets/axe-sLlwVNub.js +30 -0
- package/build/assets/components-FzdPzEyL.js +46 -0
- package/build/assets/favicon-gjFwcFbF.svg +22 -0
- package/build/assets/index-CraKZ-Fr.css +1 -0
- package/build/assets/index-DUSjZECW.js +152 -0
- package/build/assets/index-DonOhaBM.js +1 -0
- package/build/assets/manifest-B-VxemCC.webmanifest +7 -0
- package/build/assets/proxy-BETbFm71.js +9 -0
- package/build/assets/touch-icon-ByyUZD7t.png +0 -0
- package/build/index.html +28 -0
- package/build/meta.json +416 -0
- package/dist/Matrix/CheckMatrixCards.d.ts +27 -0
- package/dist/Matrix/ResponsiveCheckMatrix.d.ts +7 -0
- package/dist/Matrix/index.d.ts +2 -0
- package/dist/SidePanel/index.d.ts +4 -2
- package/dist/esm/Matrix/CheckMatrixCards.js +26 -0
- package/dist/esm/Matrix/ResponsiveCheckMatrix.js +11 -0
- package/dist/esm/Matrix/index.js +2 -0
- package/dist/esm/SidePanel/index.js +53 -10
- package/dist/esm/index.js +1 -0
- package/dist/index.d.ts +1 -0
- package/package.json +9 -9
- package/src/Matrix/CheckMatrixCards.tsx +138 -0
- package/src/Matrix/ResponsiveCheckMatrix.tsx +32 -0
- package/src/Matrix/index.ts +2 -0
- package/src/SidePanel/index.tsx +101 -12
- package/src/index.ts +1 -0
- package/stories/Matrix.stories.tsx +75 -0
- package/stories/SidePanel.stories.tsx +21 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as t}from"./index-DUSjZECW.js";const n=({texto:e})=>t.jsx("div",{className:"mb-1",children:t.jsx("h1",{className:"text-4xl font-bold leading-normal mt-0 mb-2 text-zinc-800",children:e})}),s=({texto:e})=>t.jsx("div",{className:"py-1 ",children:t.jsx("h2",{className:"text-2xl font-bold leading-normal mt-0 mb-2 text-zinc-800",children:e})}),l=({texto:e})=>t.jsx("div",{className:"py-1 ",children:t.jsx("h3",{className:"text-xl leading-normal mt-0 mb-2 text-zinc-800",children:e})}),c=()=>t.jsxs("div",{className:"space-y-3",children:[t.jsx(n,{texto:"Título H1"}),t.jsx(s,{texto:"Título H2"}),t.jsx(l,{texto:"Título H3"})]});typeof window<"u"&&window.document&&window.document.createElement&&document.documentElement.setAttribute("data-storyloaded","");export{c as Hierarchy};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as l,j as t}from"./index-DUSjZECW.js";import{B as a}from"./Button-YPU2MaHD.js";const n=({children:e,text:o})=>{const[s,r]=l.useState(!1);return t.jsxs("div",{className:"relative inline-block",children:[t.jsx("div",{onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:e}),s&&t.jsxs("div",{className:"absolute z-10 bg-gray-700 text-white px-2 py-1 rounded-md bottom-full left-1/2 transform -translate-x-1/2",style:{whiteSpace:"nowrap",height:"2rem"},children:[o,t.jsx("div",{className:"absolute top-full left-1/2 transform -translate-x-1/2",style:{width:"0",height:"0",borderTop:"6px solid transparent",borderLeft:"6px solid transparent",borderRight:"6px solid transparent",borderBottom:"6px solid gray"}})]})]})},i=e=>{const{children:o,text:s}=e;return t.jsxs("div",{className:"group relative inline-block",children:[o,t.jsx("div",{className:"pointer-events-none absolute left-1/2 -translate-x-1/2 bottom-full mb-2 opacity-0 transition-opacity duration-300 group-hover:opacity-100",children:t.jsxs("div",{className:"relative bg-black text-white text-sm rounded py-1 px-2 text-wrap w-40",children:[s,t.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 border-4 border-transparent border-t-black"})]})})]})},c=()=>t.jsx(n,{text:"Ayuda contextual",children:t.jsx(a,{title:"Pasa el mouse",type:"button"})}),u=()=>t.jsx(i,{text:"Texto largo que se envuelve en el globo de ayuda.",children:t.jsx(a,{title:"Con tooltip CSS",type:"button"})});typeof window<"u"&&window.document&&window.document.createElement&&document.documentElement.setAttribute("data-storyloaded","");export{u as CssTooltip,c as HoverTooltip};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var C={exports:{}};(function(h,n){(function(o){h.exports=o()})((function(o){var f=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function u(a,s){var e=a[0],t=a[1],i=a[2],r=a[3];e+=(t&i|~t&r)+s[0]-680876936|0,e=(e<<7|e>>>25)+t|0,r+=(e&t|~e&i)+s[1]-389564586|0,r=(r<<12|r>>>20)+e|0,i+=(r&e|~r&t)+s[2]+606105819|0,i=(i<<17|i>>>15)+r|0,t+=(i&r|~i&e)+s[3]-1044525330|0,t=(t<<22|t>>>10)+i|0,e+=(t&i|~t&r)+s[4]-176418897|0,e=(e<<7|e>>>25)+t|0,r+=(e&t|~e&i)+s[5]+1200080426|0,r=(r<<12|r>>>20)+e|0,i+=(r&e|~r&t)+s[6]-1473231341|0,i=(i<<17|i>>>15)+r|0,t+=(i&r|~i&e)+s[7]-45705983|0,t=(t<<22|t>>>10)+i|0,e+=(t&i|~t&r)+s[8]+1770035416|0,e=(e<<7|e>>>25)+t|0,r+=(e&t|~e&i)+s[9]-1958414417|0,r=(r<<12|r>>>20)+e|0,i+=(r&e|~r&t)+s[10]-42063|0,i=(i<<17|i>>>15)+r|0,t+=(i&r|~i&e)+s[11]-1990404162|0,t=(t<<22|t>>>10)+i|0,e+=(t&i|~t&r)+s[12]+1804603682|0,e=(e<<7|e>>>25)+t|0,r+=(e&t|~e&i)+s[13]-40341101|0,r=(r<<12|r>>>20)+e|0,i+=(r&e|~r&t)+s[14]-1502002290|0,i=(i<<17|i>>>15)+r|0,t+=(i&r|~i&e)+s[15]+1236535329|0,t=(t<<22|t>>>10)+i|0,e+=(t&r|i&~r)+s[1]-165796510|0,e=(e<<5|e>>>27)+t|0,r+=(e&i|t&~i)+s[6]-1069501632|0,r=(r<<9|r>>>23)+e|0,i+=(r&t|e&~t)+s[11]+643717713|0,i=(i<<14|i>>>18)+r|0,t+=(i&e|r&~e)+s[0]-373897302|0,t=(t<<20|t>>>12)+i|0,e+=(t&r|i&~r)+s[5]-701558691|0,e=(e<<5|e>>>27)+t|0,r+=(e&i|t&~i)+s[10]+38016083|0,r=(r<<9|r>>>23)+e|0,i+=(r&t|e&~t)+s[15]-660478335|0,i=(i<<14|i>>>18)+r|0,t+=(i&e|r&~e)+s[4]-405537848|0,t=(t<<20|t>>>12)+i|0,e+=(t&r|i&~r)+s[9]+568446438|0,e=(e<<5|e>>>27)+t|0,r+=(e&i|t&~i)+s[14]-1019803690|0,r=(r<<9|r>>>23)+e|0,i+=(r&t|e&~t)+s[3]-187363961|0,i=(i<<14|i>>>18)+r|0,t+=(i&e|r&~e)+s[8]+1163531501|0,t=(t<<20|t>>>12)+i|0,e+=(t&r|i&~r)+s[13]-1444681467|0,e=(e<<5|e>>>27)+t|0,r+=(e&i|t&~i)+s[2]-51403784|0,r=(r<<9|r>>>23)+e|0,i+=(r&t|e&~t)+s[7]+1735328473|0,i=(i<<14|i>>>18)+r|0,t+=(i&e|r&~e)+s[12]-1926607734|0,t=(t<<20|t>>>12)+i|0,e+=(t^i^r)+s[5]-378558|0,e=(e<<4|e>>>28)+t|0,r+=(e^t^i)+s[8]-2022574463|0,r=(r<<11|r>>>21)+e|0,i+=(r^e^t)+s[11]+1839030562|0,i=(i<<16|i>>>16)+r|0,t+=(i^r^e)+s[14]-35309556|0,t=(t<<23|t>>>9)+i|0,e+=(t^i^r)+s[1]-1530992060|0,e=(e<<4|e>>>28)+t|0,r+=(e^t^i)+s[4]+1272893353|0,r=(r<<11|r>>>21)+e|0,i+=(r^e^t)+s[7]-155497632|0,i=(i<<16|i>>>16)+r|0,t+=(i^r^e)+s[10]-1094730640|0,t=(t<<23|t>>>9)+i|0,e+=(t^i^r)+s[13]+681279174|0,e=(e<<4|e>>>28)+t|0,r+=(e^t^i)+s[0]-358537222|0,r=(r<<11|r>>>21)+e|0,i+=(r^e^t)+s[3]-722521979|0,i=(i<<16|i>>>16)+r|0,t+=(i^r^e)+s[6]+76029189|0,t=(t<<23|t>>>9)+i|0,e+=(t^i^r)+s[9]-640364487|0,e=(e<<4|e>>>28)+t|0,r+=(e^t^i)+s[12]-421815835|0,r=(r<<11|r>>>21)+e|0,i+=(r^e^t)+s[15]+530742520|0,i=(i<<16|i>>>16)+r|0,t+=(i^r^e)+s[2]-995338651|0,t=(t<<23|t>>>9)+i|0,e+=(i^(t|~r))+s[0]-198630844|0,e=(e<<6|e>>>26)+t|0,r+=(t^(e|~i))+s[7]+1126891415|0,r=(r<<10|r>>>22)+e|0,i+=(e^(r|~t))+s[14]-1416354905|0,i=(i<<15|i>>>17)+r|0,t+=(r^(i|~e))+s[5]-57434055|0,t=(t<<21|t>>>11)+i|0,e+=(i^(t|~r))+s[12]+1700485571|0,e=(e<<6|e>>>26)+t|0,r+=(t^(e|~i))+s[3]-1894986606|0,r=(r<<10|r>>>22)+e|0,i+=(e^(r|~t))+s[10]-1051523|0,i=(i<<15|i>>>17)+r|0,t+=(r^(i|~e))+s[1]-2054922799|0,t=(t<<21|t>>>11)+i|0,e+=(i^(t|~r))+s[8]+1873313359|0,e=(e<<6|e>>>26)+t|0,r+=(t^(e|~i))+s[15]-30611744|0,r=(r<<10|r>>>22)+e|0,i+=(e^(r|~t))+s[6]-1560198380|0,i=(i<<15|i>>>17)+r|0,t+=(r^(i|~e))+s[13]+1309151649|0,t=(t<<21|t>>>11)+i|0,e+=(i^(t|~r))+s[4]-145523070|0,e=(e<<6|e>>>26)+t|0,r+=(t^(e|~i))+s[11]-1120210379|0,r=(r<<10|r>>>22)+e|0,i+=(e^(r|~t))+s[2]+718787259|0,i=(i<<15|i>>>17)+r|0,t+=(r^(i|~e))+s[9]-343485551|0,t=(t<<21|t>>>11)+i|0,a[0]=e+a[0]|0,a[1]=t+a[1]|0,a[2]=i+a[2]|0,a[3]=r+a[3]|0}function p(a){var s=[],e;for(e=0;e<64;e+=4)s[e>>2]=a.charCodeAt(e)+(a.charCodeAt(e+1)<<8)+(a.charCodeAt(e+2)<<16)+(a.charCodeAt(e+3)<<24);return s}function d(a){var s=[],e;for(e=0;e<64;e+=4)s[e>>2]=a[e]+(a[e+1]<<8)+(a[e+2]<<16)+(a[e+3]<<24);return s}function b(a){var s=a.length,e=[1732584193,-271733879,-1732584194,271733878],t,i,r,c,y,g;for(t=64;t<=s;t+=64)u(e,p(a.substring(t-64,t)));for(a=a.substring(t-64),i=a.length,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<i;t+=1)r[t>>2]|=a.charCodeAt(t)<<(t%4<<3);if(r[t>>2]|=128<<(t%4<<3),t>55)for(u(e,r),t=0;t<16;t+=1)r[t]=0;return c=s*8,c=c.toString(16).match(/(.*?)(.{0,8})$/),y=parseInt(c[2],16),g=parseInt(c[1],16)||0,r[14]=y,r[15]=g,u(e,r),e}function L(a){var s=a.length,e=[1732584193,-271733879,-1732584194,271733878],t,i,r,c,y,g;for(t=64;t<=s;t+=64)u(e,d(a.subarray(t-64,t)));for(a=t-64<s?a.subarray(t-64):new Uint8Array(0),i=a.length,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<i;t+=1)r[t>>2]|=a[t]<<(t%4<<3);if(r[t>>2]|=128<<(t%4<<3),t>55)for(u(e,r),t=0;t<16;t+=1)r[t]=0;return c=s*8,c=c.toString(16).match(/(.*?)(.{0,8})$/),y=parseInt(c[2],16),g=parseInt(c[1],16)||0,r[14]=y,r[15]=g,u(e,r),e}function F(a){var s="",e;for(e=0;e<4;e+=1)s+=f[a>>e*8+4&15]+f[a>>e*8&15];return s}function m(a){var s;for(s=0;s<a.length;s+=1)a[s]=F(a[s]);return a.join("")}m(b("hello")),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function a(s,e){return s=s|0||0,s<0?Math.max(s+e,0):Math.min(s,e)}ArrayBuffer.prototype.slice=function(s,e){var t=this.byteLength,i=a(s,t),r=t,c,y,g,B;return e!==o&&(r=a(e,t)),i>r?new ArrayBuffer(0):(c=r-i,y=new ArrayBuffer(c),g=new Uint8Array(y),B=new Uint8Array(this,i,c),g.set(B),y)}})();function E(a){return/[\u0080-\uFFFF]/.test(a)&&(a=unescape(encodeURIComponent(a))),a}function I(a,s){var e=a.length,t=new ArrayBuffer(e),i=new Uint8Array(t),r;for(r=0;r<e;r+=1)i[r]=a.charCodeAt(r);return s?i:t}function H(a){return String.fromCharCode.apply(null,new Uint8Array(a))}function M(a,s,e){var t=new Uint8Array(a.byteLength+s.byteLength);return t.set(new Uint8Array(a)),t.set(new Uint8Array(s),a.byteLength),t}function A(a){var s=[],e=a.length,t;for(t=0;t<e-1;t+=2)s.push(parseInt(a.substr(t,2),16));return String.fromCharCode.apply(String,s)}function l(){this.reset()}return l.prototype.append=function(a){return this.appendBinary(E(a)),this},l.prototype.appendBinary=function(a){this._buff+=a,this._length+=a.length;var s=this._buff.length,e;for(e=64;e<=s;e+=64)u(this._hash,p(this._buff.substring(e-64,e)));return this._buff=this._buff.substring(e-64),this},l.prototype.end=function(a){var s=this._buff,e=s.length,t,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r;for(t=0;t<e;t+=1)i[t>>2]|=s.charCodeAt(t)<<(t%4<<3);return this._finish(i,e),r=m(this._hash),a&&(r=A(r)),this.reset(),r},l.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},l.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},l.prototype.setState=function(a){return this._buff=a.buff,this._length=a.length,this._hash=a.hash,this},l.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},l.prototype._finish=function(a,s){var e=s,t,i,r;if(a[e>>2]|=128<<(e%4<<3),e>55)for(u(this._hash,a),e=0;e<16;e+=1)a[e]=0;t=this._length*8,t=t.toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(t[2],16),r=parseInt(t[1],16)||0,a[14]=i,a[15]=r,u(this._hash,a)},l.hash=function(a,s){return l.hashBinary(E(a),s)},l.hashBinary=function(a,s){var e=b(a),t=m(e);return s?A(t):t},l.ArrayBuffer=function(){this.reset()},l.ArrayBuffer.prototype.append=function(a){var s=M(this._buff.buffer,a),e=s.length,t;for(this._length+=a.byteLength,t=64;t<=e;t+=64)u(this._hash,d(s.subarray(t-64,t)));return this._buff=t-64<e?new Uint8Array(s.buffer.slice(t-64)):new Uint8Array(0),this},l.ArrayBuffer.prototype.end=function(a){var s=this._buff,e=s.length,t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],i,r;for(i=0;i<e;i+=1)t[i>>2]|=s[i]<<(i%4<<3);return this._finish(t,e),r=m(this._hash),a&&(r=A(r)),this.reset(),r},l.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},l.ArrayBuffer.prototype.getState=function(){var a=l.prototype.getState.call(this);return a.buff=H(a.buff),a},l.ArrayBuffer.prototype.setState=function(a){return a.buff=I(a.buff,!0),l.prototype.setState.call(this,a)},l.ArrayBuffer.prototype.destroy=l.prototype.destroy,l.ArrayBuffer.prototype._finish=l.prototype._finish,l.ArrayBuffer.hash=function(a,s){var e=L(new Uint8Array(a)),t=m(e);return s?A(t):t},l}))})(C);var T=C.exports;const $=File.prototype.slice||File.prototype.mozSlice||File.prototype.webkitSlice;class v{static create(n,o){new v(n).create(o)}constructor(n){this.file=n,this.chunkSize=2097152,this.chunkCount=Math.ceil(this.file.size/this.chunkSize),this.chunkIndex=0}create(n){this.callback=n,this.md5Buffer=new T.ArrayBuffer,this.fileReader=new FileReader,this.fileReader.addEventListener("load",(o=>this.fileReaderDidLoad(o))),this.fileReader.addEventListener("error",(o=>this.fileReaderDidError(o))),this.readNextChunk()}fileReaderDidLoad(n){if(this.md5Buffer.append(n.target.result),!this.readNextChunk()){const o=this.md5Buffer.end(!0),f=btoa(o);this.callback(null,f)}}fileReaderDidError(n){this.callback(`Error reading ${this.file.name}`)}readNextChunk(){if(this.chunkIndex<this.chunkCount||this.chunkIndex==0&&this.chunkCount==0){const n=this.chunkIndex*this.chunkSize,o=Math.min(n+this.chunkSize,this.file.size),f=$.call(this.file,n,o);return this.fileReader.readAsArrayBuffer(f),this.chunkIndex++,!0}else return!1}}function z(h){const n=R(document.head,`meta[name="${h}"]`);if(n)return n.getAttribute("content")}function N(h,n){typeof h=="string"&&(n=h,h=document);const o=h.querySelectorAll(n);return D(o)}function R(h,n){return typeof h=="string"&&(n=h,h=document),h.querySelector(n)}function w(h,n,o={}){const{disabled:f}=h,{bubbles:u,cancelable:p,detail:d}=o,b=document.createEvent("Event");b.initEvent(n,u||!0,p||!0),b.detail=d||{};try{h.disabled=!1,h.dispatchEvent(b)}finally{h.disabled=f}return b}function D(h){return Array.isArray(h)?h:Array.from?Array.from(h):[].slice.call(h)}class W{constructor(n,o,f,u={}){this.file=n,this.attributes={filename:n.name,content_type:n.type||"application/octet-stream",byte_size:n.size,checksum:o},this.xhr=new XMLHttpRequest,this.xhr.open("POST",f,!0),this.xhr.responseType="json",this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.setRequestHeader("Accept","application/json"),this.xhr.setRequestHeader("X-Requested-With","XMLHttpRequest"),Object.keys(u).forEach((d=>{this.xhr.setRequestHeader(d,u[d])}));const p=z("csrf-token");p!=null&&this.xhr.setRequestHeader("X-CSRF-Token",p),this.xhr.addEventListener("load",(d=>this.requestDidLoad(d))),this.xhr.addEventListener("error",(d=>this.requestDidError(d)))}get status(){return this.xhr.status}get response(){const{responseType:n,response:o}=this.xhr;return n=="json"?o:JSON.parse(o)}create(n){this.callback=n,this.xhr.send(JSON.stringify({blob:this.attributes}))}requestDidLoad(n){if(this.status>=200&&this.status<300){const{response:o}=this,{direct_upload:f}=o;delete o.direct_upload,this.attributes=o,this.directUploadData=f,this.callback(null,this.toJSON())}else this.requestDidError(n)}requestDidError(n){this.callback(`Error creating Blob for "${this.file.name}". Status: ${this.status}`)}toJSON(){const n={};for(const o in this.attributes)n[o]=this.attributes[o];return n}}class X{constructor(n){this.blob=n,this.file=n.file;const{url:o,headers:f}=n.directUploadData;this.xhr=new XMLHttpRequest,this.xhr.open("PUT",o,!0),this.xhr.responseType="text";for(const u in f)this.xhr.setRequestHeader(u,f[u]);this.xhr.addEventListener("load",(u=>this.requestDidLoad(u))),this.xhr.addEventListener("error",(u=>this.requestDidError(u)))}create(n){this.callback=n,this.xhr.send(this.file.slice())}requestDidLoad(n){const{status:o,response:f}=this.xhr;o>=200&&o<300?this.callback(null,f):this.requestDidError(n)}requestDidError(n){this.callback(`Error storing "${this.file.name}". Status: ${this.xhr.status}`)}}let O=0;class j{constructor(n,o,f,u={}){this.id=++O,this.file=n,this.url=o,this.delegate=f,this.customHeaders=u}create(n){v.create(this.file,((o,f)=>{if(o){n(o);return}const u=new W(this.file,f,this.url,this.customHeaders);x(this.delegate,"directUploadWillCreateBlobWithXHR",u.xhr),u.create((p=>{if(p)n(p);else{const d=new X(u);x(this.delegate,"directUploadWillStoreFileWithXHR",d.xhr),d.create((b=>{b?n(b):n(null,u.toJSON())}))}}))}))}}function x(h,n,...o){if(h&&typeof h[n]=="function")return h[n](...o)}class J{constructor(n,o){this.input=n,this.file=o,this.directUpload=new j(this.file,this.url,this),this.dispatch("initialize")}start(n){const o=document.createElement("input");o.type="hidden",o.name=this.input.name,this.input.insertAdjacentElement("beforebegin",o),this.dispatch("start"),this.directUpload.create(((f,u)=>{f?(o.parentNode.removeChild(o),this.dispatchError(f)):o.value=u.signed_id,this.dispatch("end"),n(f)}))}uploadRequestDidProgress(n){const o=n.loaded/n.total*100;o&&this.dispatch("progress",{progress:o})}get url(){return this.input.getAttribute("data-direct-upload-url")}dispatch(n,o={}){return o.file=this.file,o.id=this.directUpload.id,w(this.input,`direct-upload:${n}`,{detail:o})}dispatchError(n){this.dispatch("error",{error:n}).defaultPrevented||alert(n)}directUploadWillCreateBlobWithXHR(n){this.dispatch("before-blob-request",{xhr:n})}directUploadWillStoreFileWithXHR(n){this.dispatch("before-storage-request",{xhr:n}),n.upload.addEventListener("progress",(o=>this.uploadRequestDidProgress(o)))}}const P="input[type=file][data-direct-upload-url]:not([disabled])";class V{constructor(n){this.form=n,this.inputs=N(n,P).filter((o=>o.files.length))}start(n){const o=this.createDirectUploadControllers(),f=()=>{const u=o.shift();u?u.start((p=>{p?(n(p),this.dispatch("end")):f()})):(n(),this.dispatch("end"))};this.dispatch("start"),f()}createDirectUploadControllers(){const n=[];return this.inputs.forEach((o=>{D(o.files).forEach((f=>{const u=new J(o,f);n.push(u)}))})),n}dispatch(n,o={}){return w(this.form,`direct-uploads:${n}`,{detail:o})}}const _="data-direct-uploads-processing",S=new WeakMap;let U=!1;function G(){U||(U=!0,document.addEventListener("click",Q,!0),document.addEventListener("submit",Y,!0),document.addEventListener("ajax:before",Z))}function Q(h){const n=h.target.closest("button, input");n&&n.type==="submit"&&n.form&&S.set(n.form,n)}function Y(h){q(h)}function Z(h){h.target.tagName=="FORM"&&q(h)}function q(h){const n=h.target;if(n.hasAttribute(_)){h.preventDefault();return}const o=new V(n),{inputs:f}=o;f.length&&(h.preventDefault(),n.setAttribute(_,""),f.forEach(k),o.start((u=>{n.removeAttribute(_),u?f.forEach(tt):K(n)})))}function K(h){let n=S.get(h)||R(h,"input[type=submit], button[type=submit]");if(n){const{disabled:o}=n;n.disabled=!1,n.focus(),n.click(),n.disabled=o}else n=document.createElement("input"),n.type="submit",n.style.display="none",h.appendChild(n),n.click(),h.removeChild(n);S.delete(h)}function k(h){h.disabled=!0}function tt(h){h.disabled=!1}function et(){window.ActiveStorage&&G()}setTimeout(et,1);export{j as DirectUpload,J as DirectUploadController,V as DirectUploadsController,w as dispatchEvent,G as start};
|