Files
hedena_gold/apps/user-app/dist/assets/LoginRegisterView-CyzrcQd1.js
T

2 lines
13 KiB
JavaScript
Raw Normal View History

import{d as L,k as F,w as H,o as se,$ as K,e as v,f as w,v as W,a0 as ae,g as a,i as R,h as E,F as V,r as ne,N as j,M as J,a1 as le,W as oe,L as Z,x as c,H as m,q as l,B as U,J as z,t as D,V as B,a2 as ue,T as M,D as A,a3 as P,j as ie,_ as G,S as re,X as ce}from"./index-DfuyKmMj.js";import{P as X}from"./PageBar-C3mlO1TZ.js";import{a as Q,F as $,I as S,T as de}from"./index-6kM653hg.js";import"./FormItemContext-CYvf0Rhz.js";import"./classCallCheck-BMJnla2q.js";import"./raf-nDFcuFT6.js";const pe={class:"otp-single-input"},me=["type","placeholder","disabled"],he={key:0},fe=["innerHTML"],_e=L({__name:"SingleOtpInput",props:{inputType:{default:"tel"},value:{},separator:{},focus:{type:Boolean},inputClasses:{},shouldAutoFocus:{type:Boolean},isLastChild:{type:Boolean},placeholder:{},disabled:{type:Boolean}},emits:["on-change","on-keydown","on-paste","on-focus","on-blur"],setup(i,{emit:b}){const d=i,h=b,o=F(d.value||""),u=F(null),n=()=>(o.value=o.value.toString(),o.value.length>1&&(o.value=o.value.slice(0,1)),h("on-change",o.value)),r=t=>t>=48&&t<=57||t>=96&&t<=105,f=t=>{d.disabled&&t.preventDefault();const p=t||window.event,x=p.which?p.which:p.keyCode;r(x)||[8,9,13,37,39,46,86].includes(x)?h("on-keydown",t):p.preventDefault()},g=t=>h("on-paste",t),s=()=>(u.value.select(),h("on-focus")),y=()=>h("on-blur");return H(()=>d.value,(t,p)=>{t!==p&&(o.value=t??"")}),H(()=>d.focus,(t,p)=>{p!==t&&u.value&&d.focus&&(u.value.focus(),u.value.select())}),se(()=>{!d.focus||!d.shouldAutoFocus||K(()=>{var t,p;(t=u.value)==null||t.focus(),(p=u.value)==null||p.select()})}),(t,p)=>(v(),w("div",pe,[W(a("input",{type:i.inputType,placeholder:i.placeholder,disabled:i.disabled,ref_key:"input",ref:u,min:"0",max:"9",maxlength:"1",pattern:"[0-9]","onUpdate:modelValue":p[0]||(p[0]=x=>o.value=x),class:R(i.inputClasses),onInput:n,onKeydown:f,onPaste:g,onFocus:s,onBlur:y},null,42,me),[[ae,o.value]]),!i.isLastChild&&i.separator?(v(),w("span",he,[a("span",{innerHTML:i.separator},null,8,fe)])):E("",!0)]))}}),ve={class:"flex ltr justify-around w-full"},ge=8,ye=37,be=39,we=46,ke=L({__name:"OtpInput",props:{defaultFocus:{type:Boolean},numInputs:{default:4},separator:{},inputClasses:{},inputType:{},shouldAutoFocus:{type:Boolean,default:!1},placeholder:{},disabled:{type:Boolean,default:!1}},emits:["on-change","on-complete"],setup(i,{emit:b}){const d=i,h=b,o=F(0),u=F([]),n=F([]),r=e=>{d.defaultFocus&&e<d.numInputs&&!u.value[e]?o.value=u.value.length:o.value=e},f=()=>{o.value=-1},g=()=>u.value.join("").length===d.numInputs?h("on-complete",u.value.join("")):"Wait until the user enters the required number of characters",s=e=>{o.value=Math.max(Math.min(d.numInputs-1,e),0)},y=()=>s(o.value+1),t=()=>s(o.value-1),p=e=>{n.value=Object.assign([],u.value),typeof e=="string"&&e===""?u.value.splice(o.value,1):u.value[o.value]=e,n.value.join("")!==u.value.join("")&&(h("on-change",u.value.join("")),g())},x=e=>{var q;e.preventDefault();const k=(((q=e.clipboardData)==null?void 0:q.getData("text/plain"))??"").slice(0,d.numInputs-o.value).split("");if(d.inputType==="number"&&!k.join("").match(/^\d+$/))return"Invalid pasted data";const T=u.value.slice(0,o.value).concat(k);return T.slice(0,d.numInputs).forEach((ee,te)=>{u.value[te]=ee}),s(T.slice(0,d.numInputs).length),g()},N=e=>{p(e),y()},_=e=>{switch(e.keyCode){case ge:e.preventDefault(),p(""),t();break;case we:e.preventDefault(),p("");break;case ye:e.preventDefault(),t();break;case be:e.preventDefault(),y();break}};return(e,O)=>(v(),w("div",null,[a("div",ve,[(v(!0),w(V,null,ne(i.numInputs,(k,I)=>(v(),j(_e,{key:I,focus:o.value===I,value:u.value[I],separator:i.separator,"input-type":i.inputType,"input-classes":i.inputClasses,"is-last-child":I===i.numInputs-1,"should-auto-focus":i.shouldAutoFocus,placeholder:i.placeholder,disabled:i.disabled,onOnChange:N,onOnKeydown:_,onOnPaste:x,onOnFocus:T=>r(I),onOnBlur:f},null,8,["focus","value","separator","input-type","input-classes","is-last-child","should-auto-focus","placeholder","disabled","onOnFocus"]))),128))])]))}}),xe=i=>` مقدار ${i} نا معتبر است `,Y=i=>({pattern:/^(\+98|0098|9