UNPKG

@securecall/client-component

Version:

SecureCall Core Web Component

2 lines 2.13 kB
import{r as e,c as t,h as i,H as s}from"./p-CHf4eHvJ.js";import{L as a}from"./p-CgjdSc_8.js";const c=":host{display:block}.field-container{display:grid;grid-template-columns:10em 1fr 20px;align-items:center;gap:1rem}.custom-label{color:var(--theme-primary-color);text-align:right;align-items:center;font-weight:bold;gap:0.5rem}.custom-input{padding:0.2rem;border:1px solid #ccc;border-radius:4px;font-size:1rem}";const l=class{constructor(i){e(this,i);this.isValidEvent=t(this,"isValidEvent")}fieldName;config;isValidEvent;log=a("SecurecallRequestCurrency");get value(){return this.config.value}set value(e){if(this.config.value!==e){this.config.value=e;this.handleLocalStorageChange()}}handleConfigChange(e,t){if(t.value!==e.value){this.value=e.value;this.validateChange(this.value)}else if(t.valid!==e.valid){this.validateChange(this.value)}}componentWillLoad(){this.validateChange(this.value)}handleLocalStorageChange(){this.log.debug("handleChangeFromLocalStorage: string change:",this.value);this.validateChange(this.value)}handleChange(e){this.log.debug("handleChange: string change:",e.target.value);this.validateChange(e.target.value)}validateChange(e){const t=parseFloat(e);const i=/^(\d+(\.\d{1,2})?)?$/.test(e);const s=!isNaN(t)&&t!==0&&i&&t>=(this.config.min||.01)&&t<=(this.config.max||99999.99);this.isValidEvent.emit({field:this.fieldName,valid:s,value:e})}render(){return i(s,{key:"3fe918e381fc22f1f64259dc341e602bc96b8828"},i("div",{key:"460b5686e0ad353d695b8a1e0e1916b20757621c",class:"field-container"},i("label",{key:"2391480757aec9e1644da01fe66af61c2ccf4c8b",class:"custom-label",htmlFor:this.fieldName},this.config.label,":"),i("input",{key:"087aca1b62588daee0da3c745aeaa5d9370093ad",type:"text",class:"custom-input",id:this.fieldName,placeholder:this.config.placeholder||this.config.label,value:this.value,disabled:this.config.readOnly,onInput:e=>this.handleChange(e)}),i("div",{key:"1873c92d1c2c232b0a63782e52c0845311dd64e7",class:"validity none"})))}static get watchers(){return{config:["handleConfigChange"]}}};l.style=c;export{l as securecall_request_currency}; //# sourceMappingURL=p-92a46a94.entry.js.map