UNPKG

jb-mobile-input

Version:
2 lines 2.62 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("jb-input")):"function"==typeof define&&define.amd?define(["exports","jb-input"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).JBMobileInput={},e.JBInput)}(this,(function(e,t){"use strict";var n,o,r,i=Object.create,u=Object.defineProperty,l=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,p=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty;function c(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}r=null!=(n=t)?i(p(n)):{},t=((e,t,n,o)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var r,i=a(t),p=0,c=i.length;p<c;p++)r=i[p],s.call(e,r)||r===n||u(e,r,{get:(e=>t[e]).bind(null,r),enumerable:!(o=l(t,r))||o.enumerable});return e})(!o&&n&&n.__esModule?r:u(r,"default",{value:n,enumerable:!0}),n);var d,b,f,g,m=class extends t.JBInputWebComponent{constructor(){super(),d.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,d,"m",b).bind(this)),this.addStandardValueCallback(c(this,d,"m",g).bind(this))}};d=new WeakSet,b=function(){const e=[],t={validator:/^(?:09[0-9]{2} [0-9]{7})?$/g,message:"شماره موبایل معتبر نیست"};return e.push(t),e},f=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,d,"m",f).call(this,e);const o=/(09[0-9]{0,2})([0-9]{0,7})/g.exec(n);return t=o&&o.length>0?o.slice(1).filter((e=>""!==e)).join(" "):n,{value:n,displayValue:t}};!customElements.get("jb-mobile-input")&&window.customElements.define("jb-mobile-input",m),e.JBMobileInputWebComponent=m})); //# sourceMappingURL=jb-mobile-input.umd.js.map