import{e,r as a,f as l,l as s,i as o,w as t,o as d,a as n,b as u,q as i,J as r,L as c,n as y,t as m,d as b,ai as p,_ as v}from"./index-D8tPjwDN.js";/* empty css                                                                     */const k={class:"keyboard-body"},V=["onClick"],f=v(e({__name:"SoftKeyboard",props:{modelValue:{},keyboardType:{},isVisible:{type:Boolean}},emits:["update:modelValue","updateKeyboardVisible","confirm","close"],setup(e,{emit:v}){const f=e,_=v,x=a("en");l((()=>{document.addEventListener("click",(e=>{var a;T.value&&!(null==(a=e.target)?void 0:a.name)&&(T.value=!1,_("updateKeyboardVisible",!1))}))}));const T=a(!1);s((()=>{setTimeout((()=>{T.value=f.isVisible}),100)}));const g=a(""),h=o((()=>"number"===f.keyboardType?[["1","2","3"],["4","5","6"],["7","8","9"],[".","0","del"]]:[["1","2","3","4","5","6","7","8","9","0","del"],["q","w","e","r","t","y","u","i","o","p","/"],["a","s","d","f","g","h","j","k","l",";","enter"],["z","x","c","v","b","n","m",",","?",".",":"],[" ","close"]])),w=["del","enter"," "],K=()=>{T.value=!1,_("close")};return t((()=>f.isVisible),(e=>{T.value=e})),(e,a)=>{const l=p;return T.value?(d(),n("div",{key:0,class:y(["soft-keyboard",{"keyboard-open":T.value}])},[u("div",k,[u("div",null,[i(l,{name:"modelVal",modelValue:f.modelValue,"onUpdate:modelValue":a[0]||(a[0]=e=>f.modelValue=e),style:{width:"93%",height:"5rem","font-size":"2rem"}},null,8,["modelValue"])]),(d(!0),n(r,null,c(h.value,((a,l)=>(d(),n("div",{class:"keyboard-row",key:l},[(d(!0),n(r,null,c(a,((a,l)=>(d(),n("button",{key:l,style:{"font-size":"24px"},class:y({"key-space":" "===a,"key-special":w.includes(a),"key-active":g.value===a,"key-number":"number"===e.keyboardType,"key-text":" "!==a&&"text"===e.keyboardType}),onClick:e=>{e.stopPropagation(),(e=>{if(g.value=e,setTimeout((()=>{g.value=""}),150),"del"===e){const e=f.modelValue.slice(0,-1);_("update:modelValue",e)}else if("enter"===e)_("confirm",f.modelValue),K();else if("close"===e)K();else if("en"!==e&&"cn"!==e||"text"!==f.keyboardType){const a=f.modelValue+e;_("update:modelValue",a)}else x.value="en"===e?"cn":"en",h.value[4][1]="en"===e?"cn":"en"})(a)}},m(" "===a?"空格":"del"===a?"删除":"enter"===a?"确认":"close"===a?"关闭":a),11,V)))),128))])))),128))])],2)):b("",!0)}}}),[["__scopeId","data-v-6be7b6b5"]]);export{f as _};
