PageSourceSearch

https://rezact.io/assets/ValidatorInput-PzAJrwPH.js

js rezact.io collected 2026-09-25 22:45:45 UTC 12,226 bytes, 2 lines download raw bytes

1import{S,i as Z,d as ee,f as te,g as ne,e as re,u as se,c as ae,x as L,a as oe}from"./main-Ex-1LHMJ.js";function W(e){return e instanceof Window||e instanceof Document||e instanceof HTMLElement||e instanceof Node}const ie=new Set(["elmRef","idxState","deps","subs","func","associatedState","state","computed"]);function T(e,t=[]){if(W(e))return[];if(typeof e=="object"&&e!==null)if(Array.isArray(e))for(let n of e)T(n,t);else for(let n in e)n.startsWith("$")&&t.push(e[n]),!ie.has(n)&&(W(e[n])||T(e[n],t));return t}function H(e,t){T(e).forEach(r=>{e.nestedSubscribed=!0,r.subscribe(()=>{t.deps&&t.deps.length>0&&t.deps[0]instanceof R?t.deps[0].refresh():t.refresh()},{elm:e.elmRef})})}class R extends S{elmRefCache=new Map;refreshTimer;clearCacheTimer;push;map;constructor(t){super(t),["push","pop","splice","shift","unshift","reduce","map"].forEach(n=>{this[n]=(...r)=>{this.value[n](...r),this.makeChildrenSignals(),this.updateList(this.func),this.alertSubs(this.value),Z||ee()}}),this.makeChildrenSignals()}removeStaleElmRefCacheItems(){this.clearCacheTimer&&clearTimeout(this.clearCacheTimer),this.clearCacheTimer=setTimeout(()=>{for(let[t,n]of this.elmRefCache)n.isConnected||this.elmRefCache.delete(t);this.deps&&this.deps.forEach(t=>{t instanceof R&&t.removeStaleElmRefCacheItems()})},10)}Map(t){if(!t.args){this.func=t;const n=t.toString().split("=>")[0].replaceAll(" ",""),r=n.slice(1,n.length-1).split(",");t.args=r}return this.updateList(t),this.value}updateList(t){if(t===void 0)return;const n=this.value.length;for(let r=0;r<n;r++){let s=this.value[r];s.state||(this.value[r]=s=new S(s)),s.__private_idx=r,t.args[1]&&(s.idxState||(s.idxState=new S(0)),s.idxState.set(r));let o=this.elmRefCache.get(s);o?.isConnected===!1&&(this.elmRefCache.delete(s),o=void 0),(s.elmRef?.isConnected===!1||s.elmRef?.isConnected===void 0)&&(s.elmRef=void 0),s.elmRef=o||te({func:t,item:s}),o||this.elmRefCache.set(s,s.elmRef),s.nestedSubscribed||H(s,this),ne(s.elmRef)?s.elmRef.forEach(d=>d.associatedState=s):s.elmRef.associatedState=s}}makeChildrenSignals(){if(!this.value)return;const t=this.value.length;for(let n=0;n<t;n++){let r=this.value[n];r.state||(this.value[n]=r=new S(r)),r.__private_idx=n,r.nestedSubscribed||H(r,this)}}deleteValue(t){const n=t.__private_idx||this.value.indexOf(t);n<0||(t.elmRef&&t.elmRef instanceof HTMLElement&&(this.elmRefCache.delete(t),t.elmRef.remove()),this.value.splice(n,1),this.alertSubs(this.value),setTimeout(()=>this.updateList(this.func),0))}toJSON(){return this.value.map(t=>{if(typeof t=="object"&&!t.state&&!t.get)return t;if(t.toJSON)return t.toJSON();t.get&&t.get()})}refresh=()=>{this.refreshTimer&&clearTimeout(this.refreshTimer),this.refreshTimer=setTimeout(()=>{this.updateList(this.func),this.alertSubs(this.value)},10)}}const Ne=(e,t)=>{const n=re(e,t);return n.deps=t,n.mapStateObj=!1,n},c=new Map,j=new Map,z="keydown",U="input",M="blur",ce="click",le="focus";function ue(e){e.inputElm=de(e),e.errorElm=he(e);const t=e.inputElm;if(c.has(t))return;e.errorElm=e.errorElm||we(t),e=ge(e),me(e);const n=e.errorElm,r=t.form;t.errorElm=n,c.set(t,e),j.set(n,e),n.errorObj=new Map,e.mask&&Re(t),e.mask||fe(t),g(t,M,ke),g(t,U,ye),g(t,z,ve),!r.zwcSubmitValidation&&g(r,"submit",pe,!0),r.zwcSubmitValidation=!0,r.noValidate=!0}function g(e,t,n,r={}){e.addEventListener(t,n,r)}function A(e,t,n){return Object.defineProperty(e,t,n)}function K(e,t){return Object.getOwnPropertyDescriptor(e,t)}function fe(e){var t=K(HTMLInputElement.prototype,"value");const n=s=>t.set.call(e,s);A(e,"value",{get:()=>t.get.call(e),set:s=>{n(s);const o=new Event(M);e.dispatchEvent(o)}})}function G(e){return document.querySelector(e)}function de(e){return typeof e.inputElm=="function"?e.inputElm(e):typeof e.inputElm=="string"?G(e.inputElm):e.inputElm}function he(e){return typeof e.errorElm=="function"?e.errorElm(e):typeof e.errorElm=="string"?G(e.errorElm):e.errorElm}function ge(e){const t=new RegExp(e.dataAccept||"[\\d\\w]","g"),r=`abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 !@#$%^&*()_+-=[];',./{}|:"<>?`.match(t);return{...{inputElm:null,errorElm:null,required:!1,minLength:null,maxLength:null,exactLength:null,pattern:null,customValidator:null,mask:null,maskSlots:null,dataAccept:null,allowUnacceptedChars:!1,unmaskInputValueProp:!1,show
1FullMaskWhileTyping:!1,hideDotSlots:!0,validateUnMaskedValue:!0,validateOnInput:!0,isNumeric:e.dataAccept&&r.length===10,customErrorMessages:{isRequired:null,inputNotLongEnough:null,inputLengthTooLong:null,patternNotValid:null}},...e}}function me(e){e.inputElm.mask=e.mask,e.inputElm.maskSlots=e.maskSlots,e.inputElm.dataAccept=e.dataAccept,e.inputElm.unmaskInputValueProp=e.unmaskInputValueProp,e.inputElm.showFullMaskWhileTyping=e.showFullMaskWhileTyping,e.inputElm.hideDotSlots=e.hideDotSlots,e.inputElm.validatorOptions=e;const t=r=>A(e.inputElm.validatorOptions,r,{get:()=>e.inputElm[r],set:s=>e.inputElm[r]=s});["mask","maskSlots","dataAccept","unmaskInputValueProp","showFullMaskWhileTyping","hideDotSlots"].forEach(r=>t(r))}function pe(e){const t=e.target;if(Ve(e.target),!t.checkValidity())return e.preventDefault()}function ke(e){const t=e.target;if(J(t))return E(t);if(y(t)==="")return m(t);if(N(t))return v(t);if(C(t))return I(t);if(O(t))return P(t);if(q(t))return v(t);if($(t))return D(t);m(t)}function ve(e){const t=e.target,n=c.get(t);if(n.mask||!n.dataAccept||n.allowUnacceptedChars||["Backspace","Tab","ArrowRight","ArrowLeft"].includes(e.key))return;if(!new RegExp(n.dataAccept).test(e.key))return e.preventDefault()}function ye(e){const t=e.target;if(!(!c.get(t).validateOnInput&&t.checkValidity())){if(J(t))return E(t);if(y(t)==="")return m(t);if(N(t))return v(t);if(!C(t)){if(O(t))return P(t);if(q(t))return v(t);if($(t))return D(t);m(t)}}}function Ve(e){Array.from(e.querySelectorAll("input")).forEach(n=>{if(c.get(n)){if(xe(n))return E(n);if(N(n))return v(n);if(C(n))return I(n);if(O(n))return P(n);if(q(n))return v(n);if($(n))return D(n);if(Se(n))return Le(n);m(n)}})}function y(e){const t=c.get(e),n=typeof e.unmaskedValue=="string"?e.unmaskedValue:e.value,r=typeof e.maskedValue=="string"?e.maskedValue:e.value;return t.validateUnMaskedValue?n:r}function xe(e){const t=c.get(e);return t.required?(t.mask?e.unmaskedValue:e.value).trim().length===0:!1}function E(e){const n=c.get(e).customErrorMessages.isRequired;if(n)return f(e,n);e.requiredValidationActive=!0,e.failedRequiredValidationOnce=!0;const s=`${e.labels[0]?.innerText||"This field"} is required.`;f(e,s)}function J(e){return e.failedRequiredValidationOnce?(c.get(e).mask?e.unmaskedValue:e.value).length<1?!0:(e.requiredValidationActive&&(e.requiredValidationActive=!1,m(e)),!1):!1}function N(e){const t=c.get(e);if(!t.dataAccept)return!1;const n=y(e).split(""),r=new RegExp(t.dataAccept);for(const s of n)if(!r.test(s))return!0;return e.patternValidationActive&&m(e),e.patternValidationActive=!1,!1}function C(e){const t=c.get(e);if(!t.minLength&&!t.exactLength)return!1;const n=y(e),r=e.inputTooLongErrorActive,s=t.maxLength||t.exactLength;return r&&n.length<=s&&(e.inputTooLongErrorActive=!1,m(e)),!!(t.minLength&&n.length<t.minLength||t.exactLength&&n.length<t.exactLength)}function I(e){const t=c.get(e),n=t.customErrorMessages.inputNotLongEnough;if(n)return f(e,n);const r=e.labels[0]?.innerText||"This field",s=t.minLength,o=t.exactLength,d=t.maxLength,i=t.exactLength||d===s?"exactly":"atleast",h=t.isNumeric?"digits":"characters",b=`${r} must be ${i} ${s||o} ${h} long.`;f(e,b)}function O(e){const t=c.get(e),n=t.maxLength||t.exactLength;return n&&y(e).length>n?(e.inputTooLongErrorActive=!0,!0):!1}function P(e){const t=c.get(e);if(t.exactLength)return I(e);const n=t.maxLength,r=t.customErrorMessages.inputLengthTooLong;if(r)return f(e,r);const s=e.labels[0]?.innerText||"This field",o=t.isNumeric?"digits":"characters",d=`${s} must not be longer than ${n} ${o}.`;f(e,d)}function q(e){const t=c.get(e);if(!t.pattern)return!1;const n=e.value;return!new RegExp(t.pattern).test(n)}function v(e){const n=c.get(e).customErrorMessages.patternNotValid;if(n)return f(e,n);e.patternValidationActive=!0;const s=`${e.labels[0]?.innerText||"This field"} is not valid.`;f(e,s)}function $(e){const t=c.get(e);if(!t.customValidator)return!1;const n=t.customValidator(y(e));return typeof n=="string"?(t.customErrorMessages.customNotValid=n,!0):!n}function D(e){const n=c.get(e).customErrorMessages.customNotValid;if(n)return f(e,n);const s=`${e.labels[0]?.innerText||"This field"}
1 is not valid.`;f(e,s)}function Se(e){return!e.checkValidity()}function Le(e){const n=c.get(e).customErrorMessages.nativeNotValid;if(n)return f(e,n);if(e.validationMessage)return f(e,e.validationMessage,!0);const s=`${e.labels[0]?.innerText||"This field"} is not valid.`;f(e,s)}function Ae(e){e.style.height=e.scrollHeight+"px"}function Me(e){e.style.height="0px"}function m(e,t=!1){const n=e.validationMessage;e.classList.remove("invalid"),e.setCustomValidity("");const r=e.errorElm;r.errorObj.delete(n),!t&&Q(r)}function f(e,t,n=!1){if(!n&&(m(e,!0),e.validationMessage===t))return;e.classList.add("invalid"),e.setCustomValidity(t);const r=e.errorElm;r.errorObj.set(t,!0),Q(r)}let B=null;function Q(e){let t=Array.from(e.errorObj.keys()).join(`
2`);e.innerText=t,clearTimeout(B),B=setTimeout(be,100)}function be(){const e=Array.from(j.keys());for(const t of e)t&&(t.errorObj.size===0&&Me(t),t.errorObj.size>0&&Ae(t))}function we(e){const t=document.createElement("div");return t.style.height="0px",t.style.overflow="hidden",t.style.transition="all 300ms",t.style.color="red",t.style.fontSize="10pt",t.style.marginBottom="10px",t.classList.add("error-message"),e.style.marginBottom="0px",e.after(t),t}function Te(e,t){const n=K(HTMLInputElement.prototype,"value"),r=i=>n.set.call(e,i),s=()=>n.get.call(e);A(e,"value",{get:function(){const i=typeof e.unmaskedValue=="string"?e.unmaskedValue:s(),h=typeof e.maskedValue=="string"?e.maskedValue:s();return e.unmaskInputValueProp?i:h},set:function(i){r(t(i));const h=new Event(M);e.dispatchEvent(h)}});const o={mask:e.mask,maskSlots:e.maskSlots,dataAccept:e.dataAccept},d=i=>A(e,i,{get:()=>o[i],set:h=>{o[i]=h,e.resetVars(),e.value=e.value}});return["mask","maskSlots","dataAccept"].forEach(i=>d(i)),[s,r]}function Re(e){let t=null,n=null,r=null,s=null,o=null;e.resetVars=()=>{t=e.mask||e.getAttribute("placeholder"),n=new Set(e.maskSlots||e.dataset.slots||"_"),r=new RegExp(e.dataAccept||e.dataset.accept||"[\\d\\w]","g"),s=(l=>Array.from(t,(u,a)=>n.has(u)?l=a+1:l))(0),o=[...t].findIndex(l=>n.has(l))},e.resetVars();const d=l=>{const u=l.match(r)||[],a=Array.from(t,p=>(u[0]===p||n.has(p))&&u.shift()||p);return e.unmaskedValue=a?.join("").match(r)?.join("")||"",a},V=l=>{const u=d(l),a=u.findIndex(Y=>n.has(Y)),p=e.showFullMaskWhileTyping||a===-1,k=a===-1?u:u.slice(0,a),X=p?u:k,w=e.hideDotSlots&&n.has(".")?".":"",_=X.join("").replaceAll(w,"").trim();return e.fullMaskValue=u.join("").replaceAll(w,"").trim(),e.partialMaskValue=k.join("").replaceAll(w,"").trim(),e.maskedValue=_,_},[i,h]=Te(e,V),b=()=>{const[l,u]=[e.selectionStart,e.selectionEnd].map(a=>(a=d(i().slice(0,a)).findIndex(k=>n.has(k)),a<0?s[s.length-1]:x?s[a-1]||o:a));h(V(i())),e.setSelectionRange(l,u),x=!1},F=()=>{h(V(i())),setTimeout(()=>{const[l,u]=[e.selectionStart,e.selectionEnd].map(a=>(a=d(i().slice(0,a)).findIndex(k=>n.has(k)),a<0?s[s.length-1]:x?s[a-1]||o:a));e.setSelectionRange(l,u),x=!1},100)};let x=!1;g(e,z,l=>x=l.key==="Backspace",!0),g(e,U,b,!0),g(e,le,F,!0),g(e,ce,F,!0),g(e,M,()=>t.startsWith(i())&&h(""),!0),e.value=e.value,e.alreadyMasked=!0}se();ae();function Ce(e){const t={elm:null},n={elm:null},r=()=>{t.elm.readOnly=e.readonly||!1,ue({inputElm:t.elm,errorElm:n.elm,...e})};return L(oe,null,L("label",{for:e.name,class:"sr-only"},e.label||e.placeholder||e.name),L("input",{value:e.value||"",onMount:r,ref:t,name:e.name,id:e.name,class:`block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6 ${e.class||""}`,placeholder:e.placeholder||"",type:e.type||"text"}),L("div",{ref:n,style:"height: 0px;",class:" overflow-hidden text-xs text-red-600 transition-all"}))}export{Ce as I,R as M,Ne as m};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.