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

2 lines
13 KiB
JavaScript
Raw Normal View History

import{d as L,k as F,w as q,o as se,$ as H,e as _,f as w,v as K,a0 as ae,g as l,i as W,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 i,H as m,q as n,B as P,J as z,t as D,V as B,a2 as ue,T as U,D as R,a3 as A,j as re,_ as G,S as ie,X as ce}from"./index-CVwJmJzN.js";import{P as X}from"./PageBar-BbDixxVX.js";import{a as Q,F as $,I as S,T as de}from"./index-Cxj5xLOO.js";import"./FormItemContext-VSm5I2XV.js";import"./classCallCheck-Cq3GxPzH.js";import"./raf-nDFcuFT6.js";const pe={class:"otp-single-input"},me=["type","placeholder","disabled"],he={key:0},fe=["innerHTML"],ve=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(r,{emit:b}){const c=r,h=b,o=F(c.value||""),u=F(null),a=()=>(o.value=o.value.toString(),o.value.length>1&&(o.value=o.value.slice(0,1)),h("on-change",o.value)),d=t=>t>=48&&t<=57||t>=96&&t<=105,f=t=>{c.disabled&&t.preventDefault();const p=t||window.event,x=p.which?p.which:p.keyCode;d(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 q(()=>c.value,(t,p)=>{t!==p&&(o.value=t??"")}),q(()=>c.focus,(t,p)=>{p!==t&&u.value&&c.focus&&(u.value.focus(),u.value.select())}),se(()=>{!c.focus||!c.shouldAutoFocus||H(()=>{var t,p;(t=u.value)==null||t.focus(),(p=u.value)==null||p.select()})}),(t,p)=>(_(),w("div",pe,[K(l("input",{type:r.inputType,placeholder:r.placeholder,disabled:r.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:W(r.inputClasses),onInput:a,onKeydown:f,onPaste:g,onFocus:s,onBlur:y},null,42,me),[[ae,o.value]]),!r.isLastChild&&r.separator?(_(),w("span",he,[l("span",{innerHTML:r.separator},null,8,fe)])):E("",!0)]))}}),_e={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(r,{emit:b}){const c=r,h=b,o=F(0),u=F([]),a=F([]),d=e=>{c.defaultFocus&&e<c.numInputs&&!u.value[e]?o.value=u.value.length:o.value=e},f=()=>{o.value=-1},g=()=>u.value.join("").length===c.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(c.numInputs-1,e),0)},y=()=>s(o.value+1),t=()=>s(o.value-1),p=e=>{a.value=Object.assign([],u.value),typeof e=="string"&&e===""?u.value.splice(o.value,1):u.value[o.value]=e,a.value.join("")!==u.value.join("")&&(h("on-change",u.value.join("")),g())},x=e=>{var N;e.preventDefault();const k=(((N=e.clipboardData)==null?void 0:N.getData("text/plain"))??"").slice(0,c.numInputs-o.value).split("");if(c.inputType==="number"&&!k.join("").match(/^\d+$/))return"Invalid pasted data";const T=u.value.slice(0,o.value).concat(k);return T.slice(0,c.numInputs).forEach((ee,te)=>{u.value[te]=ee}),s(T.slice(0,c.numInputs).length),g()},M=e=>{p(e),y()},v=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)=>(_(),w("div",null,[l("div",_e,[(_(!0),w(V,null,ne(r.numInputs,(k,I)=>(_(),j(ve,{key:I,focus:o.value===I,value:u.value[I],separator:r.separator,"input-type":r.inputType,"input-classes":r.inputClasses,"is-last-child":I===r.numInputs-1,"should-auto-focus":r.shouldAutoFocus,placeholder:r.placeholder,disabled:r.disabled,onOnChange:M,onOnKeydown:v,onOnPaste:x,onOnFocus:T=>d(I),onOnBlur:f},null,8,["focus","value","separator","input-type","input-classes","is-last-child","should-auto-focus","placeholder","disabled","onOnFocus"]))),128))])]))}}),xe=r=>` مقدار ${r} نا معتبر است `,Y=r=>({pattern:/^(\+98|0098|9