UNPKG

jb-mobile-input

Version:
2 lines 2.38 kB
"use strict";var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.getPrototypeOf,i=Object.prototype.hasOwnProperty;const a=(l=require("jb-input"),p=null!=l?e(o(l)):{},((e,o,a,l)=>{if(o&&"object"==typeof o||"function"==typeof o)for(var u,p=r(o),c=0,s=p.length;c<s;c++)u=p[c],i.call(e,u)||u===a||t(e,u,{get:(e=>o[e]).bind(null,u),enumerable:!(l=n(o,u))||l.enumerable});return e})(!u&&l&&l.__esModule?p:t(p,"default",{value:l,enumerable:!0}),l));var l,u,p;function c(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}var s,d,b,g,m=class extends a.JBInputWebComponent{constructor(){super(),s.add(this),this.initMobileInputWebComponent()}initMobileInputWebComponent(){const e=document.createElement("template");e.innerHTML="<style>.jb-input-web-component{--jb-input-input-direction: var(--jb-mobile-input-input-direction, ltr)}</style>",this.shadowRoot.appendChild(e.content.cloneNode(!0)),this.validation.addValidationListGetter(c(this,s,"m",d).bind(this)),this.addStandardValueCallback(c(this,s,"m",g).bind(this))}};s=new WeakSet,d=function(){const e=[],t={validator:/^(?:09[0-9]{2} [0-9]{7})?$/g,message:"شماره موبایل معتبر نیست"};return e.push(t),e},b=function(e){const t=e.replace(/\s/g,"").replace(/\u06F0/g,"0").replace(/\u06F1/g,"1").replace(/\u06F2/g,"2").replace(/\u06F3/g,"3").replace(/\u06F4/g,"4").replace(/\u06F5/g,"5").replace(/\u06F6/g,"6").replace(/\u06F7/g,"7").replace(/\u06F8/g,"8").replace(/\u06F9/g,"9").replace(/[^0-9]/g,""),n=/(?<opCode>(09|0|9)?)(?<number>.{0,})/g.exec(t);if(n&&n.groups){let e,t=n.groups.number;if(t=t.substring(0,9),n.groups.opCode)e="9"===n.groups.opCode?"09":n.groups.opCode;else{if(!(t.length>0))return"";e="09"}return 1==e.length?e:e+t}return""},g=function(e){let t="",n="";n=c(this,s,"m",b).call(this,e);const r=/(09[0-9]{0,2})([0-9]{0,7})/g.exec(n);return t=r&&r.length>0?r.slice(1).filter((e=>""!==e)).join(" "):n,{value:n,displayValue:t}};!customElements.get("jb-mobile-input")&&window.customElements.define("jb-mobile-input",m),exports.JBMobileInputWebComponent=m; //# sourceMappingURL=jb-mobile-input.cjs.js.map