@randstad-uca/design-system 1.0.90 → 1.0.91

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/dist/index.js CHANGED
@@ -2907,7 +2907,7 @@ function j(t,e){return(e,i,o)=>((t,e,i)=>(i.configurable=!0,i.enumerable=!0,Refl
2907
2907
  </button>
2908
2908
  `:null}
2909
2909
  </div>
2910
- `}};s([L({type:Array}),n("design:type",Array)],pt.prototype,"tabs",void 0),s([L({type:String}),n("design:type",String)],pt.prototype,"selected",void 0),s([B(),n("design:type",String)],pt.prototype,"internalSelected",void 0),s([B(),n("design:type",Object)],pt.prototype,"showPrev",void 0),s([B(),n("design:type",Object)],pt.prototype,"showNext",void 0),pt=s([a("tabs-bar")],pt);let ut=class extends P{constructor(){super(...arguments),this.files=[],this.simulatedDelay=0,this.showAlertInError=!1,this.typeTextFile="",this.loading=!1,this.progress=0,this.errorTextMessage=null,this.isMultiple=!1,this.TEXT_SNACKBAR_ERROR_TYPE=t=>`El formato del archivo ${this.isMultiple?t:""} no es válido`,this.TEXT_SNACKBAR_ERROR_SIZE=(t,e)=>`El archivo ${this.isMultiple?t:""} es muy grande. Máximo ${e}`,this.TEXT_SNACKBAR_ERROR_DELETE=t=>`Tu ${this.typeTextFile?this.typeTextFile:"file"===t?"archivo":"imagen"} fue ${"file"===t?"eliminado":"eliminada"}`}showSnackbar(t,e=5e3,i){const o=document.querySelector("randstad-snackbar");o?(o.type=i,o.icon="error"===i?"warning":"check",o.message=t,o.open=!0,clearTimeout(o.timer),o.timer=setTimeout((()=>o.open=!1),e)):console.warn("randstad-snackbar component not found in the DOM. Cannot show alert.")}baseGetTextMaxFileSize(t){const e=1048576;if(t>=e){return`${parseFloat((t/e).toPrecision(3)).toString()} MB`}return`${Math.round(t/1024)} KB`}getReadableFileTypes(t,e){const i=t.map((t=>e[t]||t));if(i.length<=1)return i.join("");const o=i.pop();return`${i.join(", ")} y ${o}`}validateFiles(t,e,i,o,r,s){const n=e>0,a=i.length>0;for(const l of t){if(a&&!i.includes(l.type))return this.setError(s,o,this.TEXT_SNACKBAR_ERROR_TYPE(l.name)),!1;if(n&&l.size>e)return this.setError(s,r,this.TEXT_SNACKBAR_ERROR_SIZE(l.name,this.baseGetTextMaxFileSize(e))),!1}return!0}async baseHandleFiles(t,e){const{baseMaxFiles:i,maxFileSize:o,acceptedFileTypes:r,errorMessageType:s,errorMessageSize:n,typeError:a}=e;if(this.setError(a,null,null),!t||this.disabled||this.loading)return;const l=Array.isArray(this.files)?this.files:[],d=Number.isFinite(i)&&i>0?i:1,c=d-l.length;if(c<=0){const t=`se ha alcanzado el número máximo de archivos (${d}).`;return void this.setError(a,t,t)}const h=Array.from(t).slice(0,c);if(0===h.length)return;if(!this.validateFiles(h,o,r,s,n,a))return;const p=this.simulatedDelay??0;if(p<=0)return this.files=[...l,...h],void this.dispatchEvent(new CustomEvent("files-changed",{detail:this.files}));this.loading=!0,this.progress=0,await this.updateComplete;const u=Date.now(),g=setInterval((()=>{const t=Date.now()-u,e=Math.min(Math.round(t/p*100),100);this.progress=e,this.progress>=100&&(clearInterval(g),this.files=[...l,...h],this.loading=!1,this.progress=0,this.dispatchEvent(new CustomEvent("files-changed",{detail:this.files})))}),10);this.fileInput&&(this.fileInput.value="")}baseOnFileInputChange(t,e){const i=t.target;this.baseHandleFiles(i.files,e),this.fileInput&&(this.fileInput.value="")}removeFile(t,e){this.files=this.files.filter(((e,i)=>i!==t)),this.dispatchEvent(new CustomEvent("files-changed",{detail:this.files})),0===this.files.length&&this.setError(e,null,null),this.showAlertInError&&this.showSnackbar(this.TEXT_SNACKBAR_ERROR_DELETE(e),5e3,"success")}setError(t="file",e,i){"file"===t&&(this.error=!!e,this.errorMessage=e),"image"===t&&(this.errorTextMessage=e),this.showAlertInError&&i&&this.showSnackbar(i,5e3,"error")}renderLoadingContainer(t){return e`
2910
+ `}};s([L({type:Array}),n("design:type",Array)],pt.prototype,"tabs",void 0),s([L({type:String}),n("design:type",String)],pt.prototype,"selected",void 0),s([B(),n("design:type",String)],pt.prototype,"internalSelected",void 0),s([B(),n("design:type",Object)],pt.prototype,"showPrev",void 0),s([B(),n("design:type",Object)],pt.prototype,"showNext",void 0),pt=s([a("tabs-bar")],pt);let ut=class extends P{constructor(){super(...arguments),this.files=[],this.simulatedDelay=0,this.showAlertInError=!1,this.typeTextFile="",this.loading=!1,this.progress=0,this.errorTextMessage=null,this.isMultiple=!1,this.TEXT_SNACKBAR_ERROR_TYPE=()=>"El formato del archivo no es válido",this.TEXT_SNACKBAR_ERROR_SIZE=t=>`El archivo es muy grande. Máximo ${t}`,this.TEXT_SNACKBAR_ERROR_DELETE=t=>`Tu ${this.typeTextFile?this.typeTextFile:"file"===t?"archivo":"imagen"} fue ${"file"===t?"eliminado":"eliminada"}`}showSnackbar(t,e=5e3,i){const o=document.querySelector("randstad-snackbar");o?(o.type=i,o.icon="error"===i?"warning":"check",o.message=t,o.open=!0,clearTimeout(o.timer),o.timer=setTimeout((()=>o.open=!1),e)):console.warn("randstad-snackbar component not found in the DOM. Cannot show alert.")}baseGetTextMaxFileSize(t){const e=1048576;if(t>=e){return`${parseFloat((t/e).toPrecision(3)).toString()} MB`}return`${Math.round(t/1024)} KB`}getReadableFileTypes(t,e){const i=t.map((t=>e[t]||t));if(i.length<=1)return i.join("");const o=i.pop();return`${i.join(", ")} y ${o}`}validateFiles(t,e,i,o,r,s){const n=e>0,a=i.length>0;for(const l of t){if(a&&!i.includes(l.type))return this.setError(s,o,this.TEXT_SNACKBAR_ERROR_TYPE()),!1;if(n&&l.size>e)return this.setError(s,r,this.TEXT_SNACKBAR_ERROR_SIZE(this.baseGetTextMaxFileSize(e))),!1}return!0}async baseHandleFiles(t,e){const{baseMaxFiles:i,maxFileSize:o,acceptedFileTypes:r,errorMessageType:s,errorMessageSize:n,typeError:a}=e;if(this.setError(a,null,null),!t||this.disabled||this.loading)return;const l=Array.isArray(this.files)?this.files:[],d=(Number.isFinite(i)&&i>0?i:1)-l.length;if(d<=0){const t="Alcanzaste el número máximo de archivos";return void this.setError(a,t,t)}const c=Array.from(t).slice(0,d);if(0===c.length)return;if(!this.validateFiles(c,o,r,s,n,a))return;const h=this.simulatedDelay??0;if(h<=0)return this.files=[...l,...c],void this.dispatchEvent(new CustomEvent("files-changed",{detail:this.files}));this.loading=!0,this.progress=0,await this.updateComplete;const p=Date.now(),u=setInterval((()=>{const t=Date.now()-p,e=Math.min(Math.round(t/h*100),100);this.progress=e,this.progress>=100&&(clearInterval(u),this.files=[...l,...c],this.loading=!1,this.progress=0,this.dispatchEvent(new CustomEvent("files-changed",{detail:this.files})))}),10);this.fileInput&&(this.fileInput.value="")}baseOnFileInputChange(t,e){const i=t.target;this.baseHandleFiles(i.files,e),this.fileInput&&(this.fileInput.value="")}removeFile(t,e){this.files=this.files.filter(((e,i)=>i!==t)),this.dispatchEvent(new CustomEvent("files-changed",{detail:this.files})),0===this.files.length&&this.setError(e,null,null),this.showAlertInError&&this.showSnackbar(this.TEXT_SNACKBAR_ERROR_DELETE(e),5e3,"success")}setError(t="file",e,i){"file"===t&&(this.error=!!e,this.errorMessage=e),"image"===t&&(this.errorTextMessage=e),this.showAlertInError&&i&&this.showSnackbar(i,5e3,"error")}renderLoadingContainer(t){return e`
2911
2911
  ${this.loading?e`
2912
2912
  <div class="progress-bar-container">
2913
2913
  <div class="progress-bar" role="progressbar" aria-label="Subiendo archivo…">