jb-national-input
Version:
national input web component
2 lines • 2.35 kB
JavaScript
;var t=Object.create,e=Object.defineProperty,n=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,o=Object.getPrototypeOf,r=Object.prototype.hasOwnProperty;const a=(u=require("jb-input"),l=null!=u?t(o(u)):{},((t,o,a,u)=>{if(o&&"object"==typeof o||"function"==typeof o)for(var s,l=i(o),c=0,p=l.length;c<p;c++)s=l[c],r.call(t,s)||s===a||e(t,s,{get:(t=>o[t]).bind(null,s),enumerable:!(u=n(o,s))||u.enumerable});return t})(!s&&u&&u.__esModule?l:e(l,"default",{value:u,enumerable:!0}),u));var u,s,l;function c(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)}var p,d,b,f,m;function h(t){return"string"!=typeof t?"":t.replace(/[۰-۹]/g,(function(t){return String.fromCharCode(t.charCodeAt(0)-1728)}))}var g=class extends a.JBInputWebComponent{constructor(){super(),p.add(this),this.initMobileInputWebComponent()}initMobileInputWebComponent(){const t=document.createElement("template");t.innerHTML="<style>.jb-input-web-component{--jb-input-input-direction: var(--jb-national-input-input-direction, ltr)}</style>",this.shadowRoot.appendChild(t.content.cloneNode(!0)),this.validation.addValidationListGetter(c(this,p,"m",m).bind(this)),c(this,p,"m",b).call(this),this.addStandardValueCallback(c(this,p,"m",d).bind(this))}};p=new WeakSet,d=function(t){let e="",n="";const i=/(?<nationalId>[\u06F0-\u06F90-9]{1,10})/g.exec(t);return e=i&&i.groups?i.groups.nationalId:"",n=h(e),{value:n,displayValue:e}},b=function(){this.elements.input.addEventListener("beforeinput",c(this,p,"m",f).bind(this))},f=function(t){const e=t.data;/[\u06F0-\u06F90-9]{1,10}/g.test(e)||"deleteContentBackward"==t.inputType||t.preventDefault()},m=function(){return[{validator:({value:t})=>function(t){if(0===t.length)return!0;const e=h(t);if(!/^\d{10}$/.test(e))return!1;const n=+e[9],i=e.split("").slice(0,9).reduce(((t,e,n)=>t+ +e*(10-n)),0)%11;return i<2?n===i:n+i===11}(t),message:"کد ملی وارد شده نامعتبر است"}]};!customElements.get("jb-national-input")&&window.customElements.define("jb-national-input",g),exports.JBNationalInputWebComponent=g;
//# sourceMappingURL=jb-national-input.cjs.js.map