@zh-keyboard/vue 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +190 -190
- package/dist/style.css +2 -1
- package/dist/zh-keyboard-vue.js +991 -1428
- package/dist/zh-keyboard-vue.js.map +1 -1
- package/dist/zh-keyboard-vue.umd.cjs +2 -2
- package/dist/zh-keyboard-vue.umd.cjs.map +1 -1
- package/package.json +10 -10
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(E,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(E=typeof globalThis<"u"?globalThis:E||self,e(E.ZhKeyboardVue={},E.Vue))})(this,function(E,e){"use strict";var Ht=Object.defineProperty;var It=(E,e,_)=>e in E?Ht(E,e,{enumerable:!0,configurable:!0,writable:!0,value:_}):E[e]=_;var x=(E,e,_)=>It(E,typeof e!="symbol"?e+"":e,_);function _(t){return e.getCurrentScope()?(e.onScopeDispose(t),!0):!1}const ae=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const de=t=>t!=null,ce=Object.prototype.toString,fe=t=>ce.call(t)==="[object Object]",W=()=>{};function ue(t,o){function r(...a){return new Promise((s,i)=>{Promise.resolve(t(()=>o.apply(this,a),{fn:o,thisArg:this,args:a})).then(s).catch(i)})}return r}function me(t,o={}){let r,a,s=W;const i=f=>{clearTimeout(f),s(),s=W};let m;return f=>{const y=e.toValue(t),g=e.toValue(o.maxWait);return r&&i(r),y<=0||g!==void 0&&g<=0?(a&&(i(a),a=null),Promise.resolve(f())):new Promise((d,k)=>{s=o.rejectOnCancel?k:d,m=f,g&&!a&&(a=setTimeout(()=>{r&&i(r),a=null,d(m())},g)),r=setTimeout(()=>{a&&i(a),a=null,d(f())},y)})}}function R(t){return Array.isArray(t)?t:[t]}function pe(t){return e.getCurrentInstance()}function ke(t,o=200,r={}){return ue(me(o,r),t)}function he(t,o=!0,r){pe()?e.onMounted(t,r):o?t():e.nextTick(t)}function ge(t,o,r){return e.watch(t,o,{...r,immediate:!0})}const $=ae?window:void 0;function N(t){var o;const r=e.toValue(t);return(o=r==null?void 0:r.$el)!=null?o:r}function H(...t){const o=[],r=()=>{o.forEach(u=>u()),o.length=0},a=(u,f,y,g)=>(u.addEventListener(f,y,g),()=>u.removeEventListener(f,y,g)),s=e.computed(()=>{const u=R(e.toValue(t[0])).filter(f=>f!=null);return u.every(f=>typeof f!="string")?u:void 0}),i=ge(()=>{var u,f;return[(f=(u=s.value)==null?void 0:u.map(y=>N(y)))!=null?f:[$].filter(y=>y!=null),R(e.toValue(s.value?t[1]:t[0])),R(e.unref(s.value?t[2]:t[1])),e.toValue(s.value?t[3]:t[2])]},([u,f,y,g])=>{if(r(),!(u!=null&&u.length)||!(f!=null&&f.length)||!(y!=null&&y.length))return;const d=fe(g)?{...g}:g;o.push(...u.flatMap(k=>f.flatMap(c=>y.map(p=>a(k,c,p,d)))))},{flush:"post"}),m=()=>{i(),r()};return _(r),m}function ye(){const t=e.shallowRef(!1),o=e.getCurrentInstance();return o&&e.onMounted(()=>{t.value=!0},o),t}function j(t){const o=ye();return e.computed(()=>(o.value,!!t()))}function be(t,o,r={}){const{window:a=$,...s}=r;let i;const m=j(()=>a&&"MutationObserver"in a),u=()=>{i&&(i.disconnect(),i=void 0)},f=e.computed(()=>{const k=e.toValue(t),c=R(k).map(N).filter(de);return new Set(c)}),y=e.watch(()=>f.value,k=>{u(),m.value&&k.size&&(i=new MutationObserver(o),k.forEach(c=>i.observe(c,s)))},{immediate:!0,flush:"post"}),g=()=>i==null?void 0:i.takeRecords(),d=()=>{y(),u()};return _(d),{isSupported:m,stop:d,takeRecords:g}}function we(t,o,r={}){const{window:a=$,document:s=a==null?void 0:a.document,flush:i="sync"}=r;if(!a||!s)return W;let m;const u=g=>{m==null||m(),m=g},f=e.watchEffect(()=>{const g=N(t);if(g){const{stop:d}=be(s,k=>{k.map(p=>[...p.removedNodes]).flat().some(p=>p===g||p.contains(g))&&o(k)},{window:a,childList:!0,subtree:!0});u(d)}},{flush:i}),y=()=>{f(),u()};return _(y),y}function Ee(t={}){var o;const{window:r=$,deep:a=!0,triggerOnRemoval:s=!1}=t,i=(o=t.document)!=null?o:r==null?void 0:r.document,m=()=>{var y;let g=i==null?void 0:i.activeElement;if(a)for(;g!=null&&g.shadowRoot;)g=(y=g==null?void 0:g.shadowRoot)==null?void 0:y.activeElement;return g},u=e.shallowRef(),f=()=>{u.value=m()};if(r){const y={capture:!0,passive:!0};H(r,"blur",g=>{g.relatedTarget===null&&f()},y),H(r,"focus",f,y)}return s&&we(u,f,{document:i}),f(),u}function Ce(t,o,r={}){const{window:a=$,...s}=r;let i;const m=j(()=>a&&"ResizeObserver"in a),u=()=>{i&&(i.disconnect(),i=void 0)},f=e.computed(()=>{const d=e.toValue(t);return Array.isArray(d)?d.map(k=>N(k)):[N(d)]}),y=e.watch(f,d=>{if(u(),m.value&&a){i=new ResizeObserver(o);for(const k of d)k&&i.observe(k,s)}},{immediate:!0,flush:"post"}),g=()=>{u(),y()};return _(g),{isSupported:m,stop:g}}function X(t,o={width:0,height:0},r={}){const{window:a=$,box:s="content-box"}=r,i=e.computed(()=>{var d,k;return(k=(d=N(t))==null?void 0:d.namespaceURI)==null?void 0:k.includes("svg")}),m=e.shallowRef(o.width),u=e.shallowRef(o.height),{stop:f}=Ce(t,([d])=>{const k=s==="border-box"?d.borderBoxSize:s==="content-box"?d.contentBoxSize:d.devicePixelContentBoxSize;if(a&&i.value){const c=N(t);if(c){const p=c.getBoundingClientRect();m.value=p.width,u.value=p.height}}else if(k){const c=R(k);m.value=c.reduce((p,{inlineSize:C})=>p+C,0),u.value=c.reduce((p,{blockSize:C})=>p+C,0)}else m.value=d.contentRect.width,u.value=d.contentRect.height},r);he(()=>{const d=N(t);d&&(m.value="offsetWidth"in d?d.offsetWidth:o.width,u.value="offsetHeight"in d?d.offsetHeight:o.height)});const y=e.watch(()=>N(t),d=>{m.value=d?o.width:0,u.value=d?o.height:0});function g(){f(),y()}return{width:m,height:u,stop:g}}var Y=class{constructor(t,o={}){x(this,"canvas");x(this,"ctx");x(this,"lastX",0);x(this,"lastY",0);x(this,"strokeData",[]);x(this,"clearTimerId",null);x(this,"isDrawing",!1);x(this,"options");x(this,"handleStart",t=>{t.preventDefault(),this.isDrawing=!0;const{offsetX:o,offsetY:r}=this.getEventCoordinates(t);this.startDrawing(o,r),this.resetClearTimer()});x(this,"handleMove",t=>{if(!this.isDrawing)return;t.preventDefault();const{offsetX:o,offsetY:r}=this.getEventCoordinates(t);this.draw(o,r),this.resetClearTimer()});x(this,"handleEnd",t=>{this.isDrawing&&(t.preventDefault(),this.isDrawing=!1,this.endStroke(),this.startClearTimer(),this.options.onDrawEnd&&this.options.onDrawEnd())});this.canvas=t,this.options={clearDelay:1e3,...o};const r=this.canvas.getContext("2d");if(!r)throw new Error("Failed to get 2D rendering context");this.ctx=r,this.setupCanvas(),this.attachEvents()}setupCanvas(){this.ctx.lineJoin="round",this.ctx.lineCap="round",this.ctx.lineWidth=3,this.ctx.strokeStyle="#000",this.clearCanvas(),this.drawGrid()}drawGrid(){const t=this.canvas.width,o=this.canvas.height;this.ctx.save(),this.ctx.strokeStyle="#ddd",this.ctx.lineWidth=1,this.ctx.setLineDash([3,3]),this.ctx.beginPath(),this.ctx.moveTo(0,o/2),this.ctx.lineTo(t,o/2),this.ctx.moveTo(t/2,0),this.ctx.lineTo(t/2,o),this.ctx.stroke(),this.ctx.setLineDash([]),this.ctx.beginPath(),this.ctx.rect(0,0,t,o),this.ctx.stroke(),this.ctx.restore()}clearCanvas(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.drawGrid(),this.strokeData=[],this.resetClearTimer()}startDrawing(t,o){this.lastX=t,this.lastY=o,this.ctx.strokeStyle="#000",this.ctx.lineWidth=3,this.ctx.setLineDash([]),this.strokeData.push(t,o,0)}draw(t,o){this.ctx.beginPath(),this.ctx.moveTo(this.lastX,this.lastY),this.ctx.lineTo(t,o),this.ctx.stroke(),this.lastX=t,this.lastY=o,this.strokeData.push(t,o,0)}endStroke(){this.strokeData.length>=3&&(this.strokeData[this.strokeData.length-1]=1)}getStrokeData(){return this.strokeData}resetClearTimer(){this.clearTimerId&&(window.clearTimeout(this.clearTimerId),this.clearTimerId=null)}startClearTimer(){this.resetClearTimer(),this.clearTimerId=window.setTimeout(()=>{this.clearCanvas(),this.clearTimerId=null},this.options.clearDelay)}getEventCoordinates(t){if(t instanceof MouseEvent)return{offsetX:t.offsetX,offsetY:t.offsetY};{const o=t.touches[0]||t.changedTouches[0],r=t.target.getBoundingClientRect();return{offsetX:o.clientX-r.left,offsetY:o.clientY-r.top}}}attachEvents(){this.canvas.addEventListener("mousedown",this.handleStart),this.canvas.addEventListener("mousemove",this.handleMove),this.canvas.addEventListener("mouseup",this.handleEnd),this.canvas.addEventListener("mouseleave",this.handleEnd),this.canvas.addEventListener("touchstart",this.handleStart,{passive:!1}),this.canvas.addEventListener("touchmove",this.handleMove,{passive:!1}),this.canvas.addEventListener("touchend",this.handleEnd),this.canvas.addEventListener("touchcancel",this.handleEnd)}detachEvents(){this.canvas.removeEventListener("mousedown",this.handleStart),this.canvas.removeEventListener("mousemove",this.handleMove),this.canvas.removeEventListener("mouseup",this.handleEnd),this.canvas.removeEventListener("mouseleave",this.handleEnd),this.canvas.removeEventListener("touchstart",this.handleStart),this.canvas.removeEventListener("touchmove",this.handleMove),this.canvas.removeEventListener("touchend",this.handleEnd),this.canvas.removeEventListener("touchcancel",this.handleEnd)}destroy(){this.detachEvents(),this.resetClearTimer()}getCanvas(){return this.canvas}getContext(){return this.ctx}};let v={defaultMode:"en",enableHandwriting:!1,position:"static",disableWhenNoFocus:!0},G=null,q=null;function M(){return v}function Be(t){v={...v,...t}}function ze(t){G=t}function I(){return G}function Ve(t){q=t}function J(){return q}function Q(t,o,r,a=0){if(!t||!o||r==="static")return null;let s,i;if(r==="bottom")s=window.innerHeight-o.offsetHeight,i=0;else{const m=t.getBoundingClientRect(),u=o.offsetWidth;s=m.bottom+window.scrollY+a,i=m.left+window.scrollX+m.width/2-u/2;const f=window.innerWidth;i+u>f&&(i=f-u-10),i<10&&(i=10)}return{top:`${s}px`,left:`${i}px`}}function A(t){if(!t)return!1;if(t.tagName==="TEXTAREA")return!0;if(t.tagName==="INPUT"){const r=(t.type||"text").toLowerCase();return!["checkbox","radio","button","submit","reset","file","image","range","color","hidden","date","datetime-local","month","week","time"].includes(r)}return!1}function xe(){if(document.activeElement&&A(document.activeElement))return document.activeElement;throw new Error("输入框没有被激活")}function Pe(t,o,r){t.value=o,oe(t,r),t.dispatchEvent(new Event("input",{bubbles:!0}))}function _e(t,o,r,a=""){return t.slice(0,o)+a+t.slice(o+r)}function ee(t,o=""){const r=Number(t.getAttribute("maxlength"));let a=t.selectionStart??0;const s=t.selectionEnd??a;let i;if(o.length>0)i=s-a;else{const f=s-a;if(f>0)i=f;else if(a>0)i=1,a--;else return}if(o.length>0&&r&&t.value.length-i+o.length>r)return;const m=_e(t.value,a,i,o),u=a+o.length;Pe(t,m,u)}function te(t,o){ee(t,o)}function ne(t){ee(t)}function oe(t,o){t.selectionStart=o,t.selectionEnd=o}function ie(t={}){const o=t.delay??400,r=t.interval??60;let a,s;function i(){a&&(clearTimeout(a),a=void 0),s&&(clearInterval(s),s=void 0)}function m(u){i(),u(),a=setTimeout(()=>{s=setInterval(()=>{u()},r)},o)}return{start:m,stop:i}}function Ne(t=!1){const o=e.ref(!1),r=e.ref(0);async function a(){const i=I();if(i)try{o.value=await i.initialize({onProgress:m=>{r.value=m}})}catch(m){console.error("初始化手写识别服务失败:",m),o.value=!1}else console.warn("未注册手写识别服务"),o.value=!1}async function s(){const i=I();if(i&&o.value)try{await i.close(),o.value=!1}catch(m){console.error("关闭手写识别服务失败:",m)}}return e.onMounted(()=>{t&&a()}),e.onUnmounted(()=>{s()}),{recognizerInitialized:o,recognizerProgress:r}}const F="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M21,11H6.83L10.41,7.41L9,6L3,12L9,18L10.41,16.58L6.83,13H21V11Z'%20/%3e%3c/svg%3e",O="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M19,7V11H5.83L9.41,7.41L8,6L2,12L8,18L9.41,16.58L5.83,13H21V7H19Z'%20/%3e%3c/svg%3e";function K(){const t=ie();function o(a,s){var i,m;a.preventDefault(),(m=(i=a.currentTarget)==null?void 0:i.setPointerCapture)==null||m.call(i,a.pointerId),t.start(s)}function r(){t.stop()}return e.onBeforeUnmount(()=>{t.stop()}),{startRepeat:o,stopRepeat:r}}const Me={class:"zhk-candidate-list"},Se=["onClick"],re=e.defineComponent({__name:"CandidateList",props:{candidates:{}},emits:["select"],setup(t,{emit:o}){const r=o;function a(s){r("select",s)}return(s,i)=>(e.openBlock(),e.createElementBlock("div",Me,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.candidates,(m,u)=>(e.openBlock(),e.createElementBlock("button",{key:`candidate-${u}`,class:"zhk-candidate-list__item",onClick:f=>a(u)},e.toDisplayString(m),9,Se))),128))]))}}),$e={class:"handwriting-input"},Le={class:"handwriting-content"},Te={class:"handwriting-buttons"},De={class:"handwriting-canvas-container"},Re={key:0,class:"handwriting-loading"},He={class:"progress-bar"},Ie={class:"progress-text"},Ae={class:"handwriting-buttons"},Ke=e.defineComponent({__name:"HandwritingInput",props:{recognizerInitialized:{type:Boolean},recognizerProgress:{}},emits:["key","exit"],setup(t,{emit:o}){const r=t,a=o,s=e.ref(null);let i=null;const m=e.ref(!1),{width:u,height:f}=X(s);function y(){i&&i.clearCanvas()}function g(){s.value&&(i&&i.destroy(),s.value.width=u.value,s.value.height=f.value,i=new Y(s.value,{onDrawEnd:p}))}const d=e.ref([]),{startRepeat:k,stopRepeat:c}=K();async function p(){if(!i||i.getStrokeData().length===0||m.value)return;const w=I();if(w){m.value=!0;try{const n=[...i.getStrokeData()],h=await w.recognize(n);d.value=h}catch(n){console.error("识别笔迹失败:",n)}finally{m.value=!1}}else console.warn("手写识别服务不可用")}e.onUnmounted(()=>{i&&i.destroy()}),e.watchEffect(()=>{s.value&&(u.value||f.value)&&r.recognizerInitialized&&e.nextTick(()=>{g()})});function C(w){const n=d.value[w];n&&(a("key",{key:n}),d.value=[],y())}return(w,n)=>(e.openBlock(),e.createElementBlock("div",$e,[e.createVNode(re,{candidates:d.value,onSelect:C},null,8,["candidates"]),e.createElementVNode("div",Le,[e.createElementVNode("div",Te,[e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[0]||(n[0]=h=>e.unref(k)(h,()=>a("key",{key:"。"}))),onPointerup:n[1]||(n[1]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointerleave:n[2]||(n[2]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointercancel:n[3]||(n[3]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onContextmenu:n[4]||(n[4]=e.withModifiers(()=>{},["prevent"]))}," 。 ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[5]||(n[5]=h=>e.unref(k)(h,()=>a("key",{key:"?"}))),onPointerup:n[6]||(n[6]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointerleave:n[7]||(n[7]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointercancel:n[8]||(n[8]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onContextmenu:n[9]||(n[9]=e.withModifiers(()=>{},["prevent"]))}," ? ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[10]||(n[10]=h=>e.unref(k)(h,()=>a("key",{key:"!"}))),onPointerup:n[11]||(n[11]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointerleave:n[12]||(n[12]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointercancel:n[13]||(n[13]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onContextmenu:n[14]||(n[14]=e.withModifiers(()=>{},["prevent"]))}," ! ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[15]||(n[15]=h=>e.unref(k)(h,()=>a("key",{key:"、"}))),onPointerup:n[16]||(n[16]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointerleave:n[17]||(n[17]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointercancel:n[18]||(n[18]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onContextmenu:n[19]||(n[19]=e.withModifiers(()=>{},["prevent"]))}," 、 ",32)]),e.createElementVNode("div",De,[w.recognizerInitialized?(e.openBlock(),e.createElementBlock("canvas",{key:1,ref_key:"canvasRef",ref:s,class:"handwriting-canvas"},null,512)):(e.openBlock(),e.createElementBlock("div",Re,[n[37]||(n[37]=e.createElementVNode("div",{class:"loading-text"}," 正在加载手写识别... ",-1)),e.createElementVNode("div",He,[e.createElementVNode("div",{class:"progress-fill",style:e.normalizeStyle({width:`${w.recognizerProgress*100}%`})},null,4)]),e.createElementVNode("div",Ie,e.toDisplayString(Math.round(w.recognizerProgress*100))+"% ",1)]))]),e.createElementVNode("div",Ae,[e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[20]||(n[20]=h=>e.unref(k)(h,()=>a("key",{key:"delete",isControl:!0}))),onPointerup:n[21]||(n[21]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointerleave:n[22]||(n[22]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointercancel:n[23]||(n[23]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onContextmenu:n[24]||(n[24]=e.withModifiers(()=>{},["prevent"]))},n[38]||(n[38]=[e.createElementVNode("img",{src:F,alt:"删除"},null,-1)]),32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onClick:n[25]||(n[25]=h=>a("exit")),onContextmenu:n[26]||(n[26]=e.withModifiers(()=>{},["prevent"]))}," 拼音 ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[27]||(n[27]=h=>e.unref(k)(h,()=>a("key",{key:","}))),onPointerup:n[28]||(n[28]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointerleave:n[29]||(n[29]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointercancel:n[30]||(n[30]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onContextmenu:n[31]||(n[31]=e.withModifiers(()=>{},["prevent"]))}," , ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[32]||(n[32]=h=>e.unref(k)(h,()=>a("key",{key:"enter",isControl:!0}))),onPointerup:n[33]||(n[33]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointerleave:n[34]||(n[34]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointercancel:n[35]||(n[35]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onContextmenu:n[36]||(n[36]=e.withModifiers(()=>{},["prevent"]))},n[39]||(n[39]=[e.createElementVNode("img",{src:O,alt:"回车"},null,-1)]),32)])])]))}}),We="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M6,18H18V16H6M12,8.41L16.59,13L18,11.58L12,5.58L6,11.58L7.41,13L12,8.41Z'%20/%3e%3c/svg%3e",se="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M3%2015H5V19H19V15H21V19C21%2020.1%2020.1%2021%2019%2021H5C3.9%2021%203%2020.1%203%2019V15Z'%20/%3e%3c/svg%3e",ve="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z'%20/%3e%3c/svg%3e",Fe={class:"zhk-selection"},Oe={class:"zhk-selection__list"},Ue=["onClick"],Ze=e.defineComponent({__name:"CandidateSelection",props:{candidates:{}},emits:["select","close"],setup(t,{emit:o}){const r=o;function a(m){r("select",m)}function s(){r("close")}function i(m){const u=Array.from(m).length;return u>=2&&u<=3?2:u>=4?3:1}return(m,u)=>(e.openBlock(),e.createElementBlock("div",Fe,[e.createElementVNode("div",Oe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.candidates,(f,y)=>(e.openBlock(),e.createElementBlock("div",{key:y,class:e.normalizeClass(["zhk-selection__text",[`zhk-selection__text--span-${i(f)}`]]),onClick:g=>a(y)},e.toDisplayString(f),11,Ue))),128))]),e.createElementVNode("div",{class:"zhk-selection__func"},[e.createElementVNode("button",{class:"zhk-selection__func-btn",onClick:s}," 返回 ")])]))}}),je={class:"zhk-candidate"},Xe={class:"zhk-candidate__container"},Ye={key:0,class:"zhk-candidate__pinyin"},Ge={class:"zhk-candidate__bottom-container"},qe=e.defineComponent({__name:"CandidateBar",props:{modelValue:{required:!0},modelModifiers:{}},emits:e.mergeModels(["key","input"],["update:modelValue"]),setup(t,{expose:o,emit:r}){const a=r,s=e.useModel(t,"modelValue");let i=null;const m=e.ref(null),u=e.computed(()=>{var d;return((d=m.value)==null?void 0:d.candidates.map(k=>k.text))??[]}),f=e.ref(!1);e.onMounted(async()=>{if(i=J(),!i)throw new Error("未找到拼音引擎实例,请确保已正确注册引擎");s.value&&(m.value=await i.processInput(s.value))}),e.onUnmounted(()=>{i==null||i.processInput("").catch(()=>{}),i=null}),e.watch(s,async d=>{const k=i;if(k){if(d===""){k.processInput("").catch(()=>{}),m.value=null;return}m.value=await k.processInput(d)}});async function y(d){if(!i)return;const k=await i.pickCandidate(d);m.value=k,k.preeditBody||(a("input",k.committed||""),s.value="",m.value=null,f.value=!1)}o({handleSelection:y});const g=e.computed(()=>{const d=m.value;return d?d.preeditHead+d.preeditBody:""});return(d,k)=>(e.openBlock(),e.createElementBlock("div",je,[e.createElementVNode("div",Xe,[g.value?(e.openBlock(),e.createElementBlock("div",Ye,e.toDisplayString(g.value),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Ge,[u.value.length>0?(e.openBlock(),e.createBlock(re,{key:0,candidates:u.value,onSelect:y},null,8,["candidates"])):e.createCommentVNode("",!0),u.value.length>0?(e.openBlock(),e.createElementBlock("button",{key:1,class:"zhk-candidate__more",onClick:k[0]||(k[0]=c=>f.value=!0)},k[2]||(k[2]=[e.createElementVNode("img",{src:ve,alt:"更多"},null,-1)]))):e.createCommentVNode("",!0)])]),f.value?(e.openBlock(),e.createBlock(Ze,{key:0,candidates:u.value,onSelect:y,onClose:k[1]||(k[1]=c=>f.value=!1)},null,8,["candidates"])):e.createCommentVNode("",!0)]))}}),Je={class:"zhk-base"},Qe={class:"zhk-base__row"},et=["onPointerdown"],tt=["disabled"],nt={key:1,src:We,class:"zhk-base__key-icon",alt:"Shift"},ot=["onPointerdown"],it={class:"zhk-base__row"},rt={class:"zhk-base__toggle-main"},st={class:"zhk-base__toggle-sub"},lt=e.defineComponent({__name:"KeyboardBase",props:e.mergeModels({enableHandwriting:{type:Boolean}},{modelValue:{default:"en"},modelModifiers:{}}),emits:e.mergeModels(["key"],["update:modelValue"]),setup(t,{emit:o}){const r=t,a=o,s=e.useModel(t,"modelValue"),i=e.computed(()=>s.value==="en_cap"),m=e.computed(()=>s.value==="zh"),u=e.computed(()=>m.value?!0:i.value);function f(P,l=!1){a("key",{key:P,isControl:l})}function y(){m.value?s.value="hand":s.value=i.value?"en":"en_cap"}function g(){s.value="num"}function d(){s.value="symbol"}const k=["1","2","3","4","5","6","7","8","9","0"],c=[["q","w","e","r","t","y","u","i","o","p"],["a","s","d","f","g","h","j","k","l"],["z","x","c","v","b","n","m"]],p=e.ref(""),C=e.ref(null),{startRepeat:w,stopRepeat:n}=K();function h(){if(s.value==="zh"&&p.value){p.value=p.value.slice(0,-1);return}f("delete",!0)}function L(){var P;if(s.value==="zh"&&p.value){(P=C.value)==null||P.handleSelection(0);return}f(" ")}function U(){if(s.value==="zh"&&p.value){f(p.value),p.value="";return}f("enter",!0)}function T(P){if(s.value==="zh"){p.value+=P;return}const l=i.value?P.toUpperCase():P;f(l)}function Z(){s.value=s.value==="zh"?"en":"zh"}const z=e.computed(()=>r.enableHandwriting?"手写":"-"),V=e.computed(()=>!r.enableHandwriting);return(P,l)=>(e.openBlock(),e.createElementBlock("div",Je,[e.createElementVNode("div",Qe,[s.value==="zh"?(e.openBlock(),e.createBlock(qe,{key:0,ref_key:"candidateBarRef",ref:C,modelValue:p.value,"onUpdate:modelValue":l[0]||(l[0]=b=>p.value=b),onInput:l[1]||(l[1]=b=>f(b,!1))},null,8,["modelValue"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},e.renderList(k,(b,D)=>e.createElementVNode("button",{key:`number-${D}`,class:"zhk-base__key zhk-base__key--letter",onPointerdown:B=>e.unref(w)(B,()=>T(b)),onPointerup:l[2]||(l[2]=(...B)=>e.unref(n)&&e.unref(n)(...B)),onPointerleave:l[3]||(l[3]=(...B)=>e.unref(n)&&e.unref(n)(...B)),onPointercancel:l[4]||(l[4]=(...B)=>e.unref(n)&&e.unref(n)(...B)),onContextmenu:l[5]||(l[5]=e.withModifiers(()=>{},["prevent"]))},e.toDisplayString(b),41,et)),64))]),(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(c,(b,D)=>e.createElementVNode("div",{key:`row-${D}`,class:"zhk-base__row"},[D===2?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["zhk-base__key zhk-base__key--function zhk-base__key--shift",{"zhk-base__key--active":!m.value&&i.value,"zhk-base__key--disabled":m.value&&V.value}]),disabled:m.value&&V.value,onClick:y,onContextmenu:l[6]||(l[6]=e.withModifiers(()=>{},["prevent"]))},[m.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(z.value),1)],64)):(e.openBlock(),e.createElementBlock("img",nt))],42,tt)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b,(B,Rt)=>(e.openBlock(),e.createElementBlock("button",{key:`key-${D}-${Rt}`,class:"zhk-base__key zhk-base__key--letter",onPointerdown:S=>e.unref(w)(S,()=>T(B)),onPointerup:l[7]||(l[7]=(...S)=>e.unref(n)&&e.unref(n)(...S)),onPointerleave:l[8]||(l[8]=(...S)=>e.unref(n)&&e.unref(n)(...S)),onPointercancel:l[9]||(l[9]=(...S)=>e.unref(n)&&e.unref(n)(...S)),onContextmenu:l[10]||(l[10]=e.withModifiers(()=>{},["prevent"]))},e.toDisplayString(u.value?B.toUpperCase():B),41,ot))),128)),D===2?(e.openBlock(),e.createElementBlock("button",{key:1,class:"zhk-base__key zhk-base__key--function zhk-base__key--delete",onPointerdown:l[11]||(l[11]=B=>e.unref(w)(B,()=>h())),onPointerup:l[12]||(l[12]=(...B)=>e.unref(n)&&e.unref(n)(...B)),onPointerleave:l[13]||(l[13]=(...B)=>e.unref(n)&&e.unref(n)(...B)),onPointercancel:l[14]||(l[14]=(...B)=>e.unref(n)&&e.unref(n)(...B)),onContextmenu:l[15]||(l[15]=e.withModifiers(()=>{},["prevent"]))},l[39]||(l[39]=[e.createElementVNode("img",{src:F,class:"zhk-base__key-icon",alt:"Delete"},null,-1)]),32)):e.createCommentVNode("",!0)])),64)),e.createElementVNode("div",it,[e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onClick:d,onContextmenu:l[16]||(l[16]=e.withModifiers(()=>{},["prevent"]))}," 符 ",32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onClick:g,onContextmenu:l[17]||(l[17]=e.withModifiers(()=>{},["prevent"]))}," 123 ",32),e.createElementVNode("button",{class:"zhk-base__key",onPointerdown:l[18]||(l[18]=b=>e.unref(w)(b,()=>f(","))),onPointerup:l[19]||(l[19]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointerleave:l[20]||(l[20]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointercancel:l[21]||(l[21]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onContextmenu:l[22]||(l[22]=e.withModifiers(()=>{},["prevent"]))}," , ",32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--space",onPointerdown:l[23]||(l[23]=b=>e.unref(w)(b,()=>L())),onPointerup:l[24]||(l[24]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointerleave:l[25]||(l[25]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointercancel:l[26]||(l[26]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onContextmenu:l[27]||(l[27]=e.withModifiers(()=>{},["prevent"]))},l[40]||(l[40]=[e.createElementVNode("img",{src:se,class:"zhk-base__key-icon",alt:"Space"},null,-1)]),32),e.createElementVNode("button",{class:"zhk-base__key",onPointerdown:l[28]||(l[28]=b=>e.unref(w)(b,()=>f("。"))),onPointerup:l[29]||(l[29]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointerleave:l[30]||(l[30]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointercancel:l[31]||(l[31]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onContextmenu:l[32]||(l[32]=e.withModifiers(()=>{},["prevent"]))}," 。 ",32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onClick:Z,onContextmenu:l[33]||(l[33]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("span",rt,e.toDisplayString(s.value==="zh"?"中":"英"),1),e.createElementVNode("span",st,"/"+e.toDisplayString(s.value==="zh"?"英":"中"),1)],32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onPointerdown:l[34]||(l[34]=b=>e.unref(w)(b,()=>U())),onPointerup:l[35]||(l[35]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointerleave:l[36]||(l[36]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointercancel:l[37]||(l[37]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onContextmenu:l[38]||(l[38]=e.withModifiers(()=>{},["prevent"]))},l[41]||(l[41]=[e.createElementVNode("img",{src:O,class:"zhk-base__key-icon",alt:"Enter"},null,-1)]),32)])]))}}),at={class:"num-keyboard"},dt={class:"num-keyboard__container"},ct={class:"num-keyboard__left"},ft={class:"num-keyboard__rows"},ut=["onClick","onPointerdown"],mt={key:1,src:se,class:"zhk-base__key-icon",alt:"Space"},pt={class:"num-keyboard__right"},kt=["onPointerdown"],ht=["src","alt"],gt={key:1},yt=e.defineComponent({__name:"NumericKeyboard",props:{keyboardRows:{default:()=>M().numKeys||[["1","2","3"],["4","5","6"],["7","8","9"],["back","0","space"]]}},emits:["key","exit"],setup(t,{emit:o}){const r=o,a=[{key:"delete",icon:F,text:"",alt:"Delete"},{key:".",icon:"",text:".",alt:"."},{key:"@",icon:"",text:"@",alt:"@"},{key:"enter",icon:O,text:"",alt:"Enter"}];function s(g){r("key",{key:g})}function i(g,d=!0){r("key",{key:g,isControl:d})}function m(){r("exit")}const{startRepeat:u,stopRepeat:f}=K();function y(g,d){g==="back"||(g==="space"&&(g=" "),g==="delete"||g==="enter"?u(d,()=>i(g)):u(d,()=>s(g)))}return(g,d)=>(e.openBlock(),e.createElementBlock("div",at,[e.createElementVNode("div",dt,[e.createElementVNode("div",ct,[e.createElementVNode("div",ft,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.keyboardRows,(k,c)=>(e.openBlock(),e.createElementBlock("div",{key:`row-${c}`,class:"num-keyboard__row"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k,(p,C)=>(e.openBlock(),e.createElementBlock("button",{key:`key-${c}-${C}`,class:e.normalizeClass(["num-keyboard__key",{"num-keyboard__key--back":p==="back","num-keyboard__key--space":p==="space"}]),onClick:w=>p==="back"&&m(),onPointerdown:w=>y(p,w),onPointerup:d[0]||(d[0]=(...w)=>e.unref(f)&&e.unref(f)(...w)),onPointerleave:d[1]||(d[1]=(...w)=>e.unref(f)&&e.unref(f)(...w)),onPointercancel:d[2]||(d[2]=(...w)=>e.unref(f)&&e.unref(f)(...w)),onContextmenu:d[3]||(d[3]=e.withModifiers(()=>{},["prevent"]))},[p==="back"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(" 返回 ")],64)):p==="space"?(e.openBlock(),e.createElementBlock("img",mt)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createTextVNode(e.toDisplayString(p),1)],64))],42,ut))),128))]))),128))])]),e.createElementVNode("div",pt,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(a,(k,c)=>e.createElementVNode("button",{key:`func-${c}`,class:"num-keyboard__key num-keyboard__key--function",onPointerdown:p=>y(k.key,p),onPointerup:d[4]||(d[4]=(...p)=>e.unref(f)&&e.unref(f)(...p)),onPointerleave:d[5]||(d[5]=(...p)=>e.unref(f)&&e.unref(f)(...p)),onPointercancel:d[6]||(d[6]=(...p)=>e.unref(f)&&e.unref(f)(...p)),onContextmenu:d[7]||(d[7]=e.withModifiers(()=>{},["prevent"]))},[k.icon?(e.openBlock(),e.createElementBlock("img",{key:0,src:k.icon,class:"num-keyboard__key-icon",alt:k.alt},null,8,ht)):(e.openBlock(),e.createElementBlock("span",gt,e.toDisplayString(k.text),1))],40,kt)),64))])])]))}}),bt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M18,20V10H6V20H18M18,8A2,2%200%200,1%2020,10V20A2,2%200%200,1%2018,22H6C4.89,22%204,21.1%204,20V10A2,2%200%200,1%206,8H15V6A3,3%200%200,0%2012,3A3,3%200%200,0%209,6H7A5,5%200%200,1%2012,1A5,5%200%200,1%2017,6V8H18M12,17A2,2%200%200,1%2010,15A2,2%200%200,1%2012,13A2,2%200%200,1%2014,15A2,2%200%200,1%2012,17Z'%20/%3e%3c/svg%3e",wt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M12,17C10.89,17%2010,16.1%2010,15C10,13.89%2010.89,13%2012,13A2,2%200%200,1%2014,15A2,2%200%200,1%2012,17M18,20V10H6V20H18M18,8A2,2%200%200,1%2020,10V20A2,2%200%200,1%2018,22H6C4.89,22%204,21.1%204,20V10C4,8.89%204.89,8%206,8H7V6A5,5%200%200,1%2012,1A5,5%200%200,1%2017,6V8H18M12,3A3,3%200%200,0%209,6V8H15V6A3,3%200%200,0%2012,3Z'%20/%3e%3c/svg%3e",Et={class:"symbol-keyboard"},Ct={class:"symbol-keyboard__content"},Bt={class:"symbol-keyboard__functions"},zt={class:"symbol-keyboard__lang-selector"},Vt={class:"symbol-keyboard__control-group"},xt=["src"],Pt=["src"],_t={class:"symbol-keyboard__symbols-container"},Nt={class:"symbol-keyboard__symbols-grid"},Mt=["onClick","onPointerdown"],St="!@#$%^&*(){}[]<>/\\|:;\"',.?+-=_~`€£¥₹©®™°",$t="!@#¥%…&*(){}[]<>/\|:;"',。?+-=_~·€£¥₹©®™°",Lt=e.defineComponent({__name:"SymbolKeyboard",emits:["key","exit"],setup(t,{emit:o}){const r=o,a=e.ref("en"),s=e.computed(()=>a.value==="zh"?$t:St),i=e.ref(!1),{startRepeat:m,stopRepeat:u}=K();function f(c,p){i.value&&m(p,()=>y(c))}function y(c){r("key",{key:c}),i.value||r("exit")}function g(){r("exit")}function d(c){a.value=c}function k(){i.value=!i.value}return(c,p)=>(e.openBlock(),e.createElementBlock("div",Et,[e.createElementVNode("div",Ct,[e.createElementVNode("div",Bt,[e.createElementVNode("div",zt,[e.createElementVNode("button",{class:e.normalizeClass(["symbol-keyboard__lang-btn",{"symbol-keyboard__lang-btn--active":a.value==="zh"}]),onClick:p[0]||(p[0]=C=>d("zh")),onContextmenu:p[1]||(p[1]=e.withModifiers(()=>{},["prevent"]))}," 中文 ",34),e.createElementVNode("button",{class:e.normalizeClass(["symbol-keyboard__lang-btn",{"symbol-keyboard__lang-btn--active":a.value==="en"}]),onClick:p[2]||(p[2]=C=>d("en")),onContextmenu:p[3]||(p[3]=e.withModifiers(()=>{},["prevent"]))}," 英文 ",34)]),e.createElementVNode("div",Vt,[e.createElementVNode("button",{class:e.normalizeClass(["symbol-keyboard__key symbol-keyboard__key--function symbol-keyboard__key--lock",{"symbol-keyboard__key--locked":i.value}]),onClick:k,onContextmenu:p[4]||(p[4]=e.withModifiers(()=>{},["prevent"]))},[i.value?(e.openBlock(),e.createElementBlock("img",{key:1,src:e.unref(wt),alt:"Lock closed"},null,8,Pt)):(e.openBlock(),e.createElementBlock("img",{key:0,src:e.unref(bt),alt:"Lock open"},null,8,xt))],34),e.createElementVNode("button",{class:"symbol-keyboard__key symbol-keyboard__key--function symbol-keyboard__key--back",onClick:g,onContextmenu:p[5]||(p[5]=e.withModifiers(()=>{},["prevent"]))}," 返回 ",32)])]),e.createElementVNode("div",_t,[e.createElementVNode("div",Nt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,(C,w)=>(e.openBlock(),e.createElementBlock("button",{key:`key-${w}`,class:"symbol-keyboard__key",onClick:n=>!i.value&&y(C),onPointerdown:n=>f(C,n),onPointerup:p[6]||(p[6]=(...n)=>e.unref(u)&&e.unref(u)(...n)),onPointerleave:p[7]||(p[7]=(...n)=>e.unref(u)&&e.unref(u)(...n)),onPointercancel:p[8]||(p[8]=(...n)=>e.unref(u)&&e.unref(u)(...n)),onContextmenu:p[9]||(p[9]=e.withModifiers(()=>{},["prevent"]))},e.toDisplayString(C),41,Mt))),128))])])])]))}}),Tt={key:0,class:"zhk__disabled-overlay"},le=e.defineComponent({__name:"ZhKeyboard",props:{defaultMode:{type:String,default:()=>M().defaultMode??"en"},enableHandwriting:{type:Boolean,default:()=>M().enableHandwriting??!1},position:{type:String,default:()=>M().position??"static"},floatMarginTop:{type:Number,default:()=>M().floatMarginTop??0},disableWhenNoFocus:{type:Boolean,default:()=>M().disableWhenNoFocus??!0},numKeys:{type:Array||void 0}},emits:["key"],setup(t,{emit:o}){const r=t,a=o,s=e.ref(r.defaultMode),i=e.ref(r.defaultMode),m=e.ref([]),u=e.ref(!1),f=e.ref(null),y=e.ref(null),{recognizerInitialized:g,recognizerProgress:d}=Ne(r.enableHandwriting);e.watch(s,(z,V)=>{z!==V&&(i.value=V)});const k=Ee(),c=e.computed(()=>k.value&&A(k.value)?k.value:null),p=e.computed(()=>r.position==="static"||!!(k.value&&A(k.value))),{height:C}=X(y);e.watchEffect(()=>{if(c.value){const z=c.value.dataset.inputmode;z&&(s.value=z)}});const w=e.computed(()=>r.disableWhenNoFocus===!1?!1:!c.value);function n(){if(!C.value)return;const z=Q(c.value,y.value,r.position,r.floatMarginTop);f.value=z}e.watchEffect(n);const h=ke(n,100);H(window,"scroll",h,{passive:!0}),H(window,"resize",h,{passive:!0});function L(z){if(z.isControl){switch(z.key){case"delete":ne(c.value);break;case"more":u.value=!0;break}return}else U(z.key);a("key",z)}function U(z){te(c.value,z)}function T(){s.value==="hand"?i.value="zh":["num","symbol"].includes(i.value)&&(i.value=r.defaultMode),s.value=i.value}function Z(z){m.value=z}return(z,V)=>e.withDirectives((e.openBlock(),e.createElementBlock("div",{ref_key:"keyboardRef",ref:y,class:e.normalizeClass(["zhk",{"zhk--floating":t.position==="float","zhk--bottom":t.position==="bottom","zhk--disabled":w.value}]),style:e.normalizeStyle({"--keyboard-height":`${e.unref(C)}px`,...f.value}),onMousedown:V[1]||(V[1]=e.withModifiers(()=>{},["prevent"]))},[w.value||!p.value||!e.unref(C)?(e.openBlock(),e.createElementBlock("div",Tt,V[2]||(V[2]=[e.createElementVNode("span",null,"请选择输入框以启用键盘",-1)]))):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[s.value==="hand"?(e.openBlock(),e.createBlock(Ke,{key:0,"recognizer-initialized":e.unref(g),"recognizer-progress":e.unref(d),onKey:L,onExit:T,onRecognize:Z},null,8,["recognizer-initialized","recognizer-progress"])):s.value==="num"?(e.openBlock(),e.createBlock(yt,{key:1,"keyboard-rows":t.numKeys,onKey:L,onExit:T},null,8,["keyboard-rows"])):s.value==="symbol"?(e.openBlock(),e.createBlock(Lt,{key:2,onKey:L,onExit:T})):s.value==="en"||s.value==="en_cap"||s.value==="zh"?(e.openBlock(),e.createBlock(lt,{key:3,modelValue:s.value,"onUpdate:modelValue":V[0]||(V[0]=P=>s.value=P),"enable-handwriting":t.enableHandwriting,onKey:L},null,8,["modelValue","enable-handwriting"])):e.createCommentVNode("",!0)],64))],38)),[[e.vShow,p.value]])}}),Dt={install:t=>{t.component("ZhKeyboard",le)}};E.CanvasDrawer=Y,E.ZhKeyboard=le,E.calculateKeyboardPosition=Q,E.createKeyRepeater=ie,E.default=Dt,E.delToInputElement=ne,E.getHandwritingRecognizer=I,E.getInputElement=xe,E.getKeyboardConfig=M,E.getPinyinEngine=J,E.isInputElement=A,E.moveCursor=oe,E.registerHandwritingRecognizer=ze,E.registerPinyinEngine=Ve,E.setKeyboardConfig=Be,E.writeToInputElement=te,Object.defineProperties(E,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
2
|
-
//# sourceMappingURL=zh-keyboard-vue.umd.cjs.map
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`vue`),require(`@zh-keyboard/core`)):typeof define==`function`&&define.amd?define([`exports`,`vue`,`@zh-keyboard/core`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ZhKeyboardVue={},e.Vue,e.ZhKeyboardCore))})(this,function(e,t,n){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});function r(e){return(0,t.getCurrentScope)()?((0,t.onScopeDispose)(e),!0):!1}var i=typeof window<`u`&&typeof document<`u`;typeof WorkerGlobalScope<`u`&&globalThis instanceof WorkerGlobalScope;var a=e=>e!=null,o=Object.prototype.toString,s=e=>o.call(e)===`[object Object]`,c=()=>{};function l(e,t){function n(...n){return new Promise((r,i)=>{Promise.resolve(e(()=>t.apply(this,n),{fn:t,thisArg:this,args:n})).then(r).catch(i)})}return n}function u(e,n={}){let r,i,a=c,o=e=>{clearTimeout(e),a(),a=c},s;return c=>{let l=(0,t.toValue)(e),u=(0,t.toValue)(n.maxWait);return r&&o(r),l<=0||u!==void 0&&u<=0?(i&&=(o(i),null),Promise.resolve(c())):new Promise((e,t)=>{a=n.rejectOnCancel?t:e,s=c,u&&!i&&(i=setTimeout(()=>{r&&o(r),i=null,e(s())},u)),r=setTimeout(()=>{i&&o(i),i=null,e(c())},l)})}}function d(e){return Array.isArray(e)?e:[e]}function f(e){return e||(0,t.getCurrentInstance)()}function p(e,t=200,n={}){return l(u(t,n),e)}function m(e,n=!0,r){f(r)?(0,t.onMounted)(e,r):n?e():(0,t.nextTick)(e)}function h(e,n,r){return(0,t.watch)(e,n,{...r,immediate:!0})}var g=i?window:void 0;i&&window.document,i&&window.navigator,i&&window.location;function _(e){let n=(0,t.toValue)(e);return n?.$el??n}function v(...e){let n=[],i=()=>{n.forEach(e=>e()),n.length=0},a=(e,t,n,r)=>(e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)),o=(0,t.computed)(()=>{let n=d((0,t.toValue)(e[0])).filter(e=>e!=null);return n.every(e=>typeof e!=`string`)?n:void 0}),c=h(()=>[o.value?.map(e=>_(e))??[g].filter(e=>e!=null),d((0,t.toValue)(o.value?e[1]:e[0])),d((0,t.unref)(o.value?e[2]:e[1])),(0,t.toValue)(o.value?e[3]:e[2])],([e,t,r,o])=>{if(i(),!e?.length||!t?.length||!r?.length)return;let c=s(o)?{...o}:o;n.push(...e.flatMap(e=>t.flatMap(t=>r.map(n=>a(e,t,n,c)))))},{flush:`post`});return r(i),()=>{c(),i()}}function y(){let e=(0,t.shallowRef)(!1),n=(0,t.getCurrentInstance)();return n&&(0,t.onMounted)(()=>{e.value=!0},n),e}function b(e){let n=y();return(0,t.computed)(()=>(n.value,!!e()))}function x(e,n,i={}){let{window:o=g,...s}=i,c,l=b(()=>o&&`MutationObserver`in o),u=()=>{c&&=(c.disconnect(),void 0)},f=(0,t.computed)(()=>{let n=d((0,t.toValue)(e)).map(_).filter(a);return new Set(n)}),p=(0,t.watch)(()=>f.value,e=>{u(),l.value&&e.size&&(c=new MutationObserver(n),e.forEach(e=>c.observe(e,s)))},{immediate:!0,flush:`post`}),m=()=>c?.takeRecords(),h=()=>{p(),u()};return r(h),{isSupported:l,stop:h,takeRecords:m}}function S(e,n,i={}){let{window:a=g,document:o=a?.document,flush:s=`sync`}=i;if(!a||!o)return c;let l,u=e=>{l?.(),l=e},d=(0,t.watchEffect)(()=>{let t=_(e);if(t){let{stop:e}=x(o,e=>{e.map(e=>[...e.removedNodes]).flat().some(e=>e===t||e.contains(t))&&n(e)},{window:a,childList:!0,subtree:!0});u(e)}},{flush:s}),f=()=>{d(),u()};return r(f),f}function C(e={}){let{window:n=g,deep:r=!0,triggerOnRemoval:i=!1}=e,a=e.document??n?.document,o=()=>{let e=a?.activeElement;if(r)for(;e?.shadowRoot;)e=e?.shadowRoot?.activeElement;return e},s=(0,t.shallowRef)(),c=()=>{s.value=o()};if(n){let e={capture:!0,passive:!0};v(n,`blur`,e=>{e.relatedTarget===null&&c()},e),v(n,`focus`,c,e)}return i&&S(s,c,{document:a}),c(),s}function w(e,n,i={}){let{window:a=g,...o}=i,s,c=b(()=>a&&`ResizeObserver`in a),l=()=>{s&&=(s.disconnect(),void 0)},u=(0,t.watch)((0,t.computed)(()=>{let n=(0,t.toValue)(e);return Array.isArray(n)?n.map(e=>_(e)):[_(n)]}),e=>{if(l(),c.value&&a){s=new ResizeObserver(n);for(let t of e)t&&s.observe(t,o)}},{immediate:!0,flush:`post`}),d=()=>{l(),u()};return r(d),{isSupported:c,stop:d}}function T(e,n={width:0,height:0},r={}){let{window:i=g,box:a=`content-box`}=r,o=(0,t.computed)(()=>(_(e)?.namespaceURI)?.includes(`svg`)),s=(0,t.shallowRef)(n.width),c=(0,t.shallowRef)(n.height),{stop:l}=w(e,([t])=>{let n=a===`border-box`?t.borderBoxSize:a===`content-box`?t.contentBoxSize:t.devicePixelContentBoxSize;if(i&&o.value){let t=_(e);if(t){let e=t.getBoundingClientRect();s.value=e.width,c.value=e.height}}else if(n){let e=d(n);s.value=e.reduce((e,{inlineSize:t})=>e+t,0),c.value=e.reduce((e,{blockSize:t})=>e+t,0)}else s.value=t.contentRect.width,c.value=t.contentRect.height},r);m(()=>{let t=_(e);t&&(s.value=`offsetWidth`in t?t.offsetWidth:n.width,c.value=`offsetHeight`in t?t.offsetHeight:n.height)});let u=(0,t.watch)(()=>_(e),e=>{s.value=e?n.width:0,c.value=e?n.height:0});function f(){l(),u()}return{width:s,height:c,stop:f}}function ee(e=!1){let r=(0,t.ref)(!1),i=(0,t.ref)(0);async function a(){let e=(0,n.getHandwritingRecognizer)();if(e)try{r.value=await e.initialize({onProgress:e=>{i.value=e}})}catch(e){console.error(`初始化手写识别服务失败:`,e),r.value=!1}else console.warn(`未注册手写识别服务`),r.value=!1}async function o(){let e=(0,n.getHandwritingRecognizer)();if(e&&r.value)try{await e.close(),r.value=!1}catch(e){console.error(`关闭手写识别服务失败:`,e)}}return(0,t.onMounted)(()=>{e&&a()}),(0,t.onUnmounted)(()=>{o()}),{recognizerInitialized:r,recognizerProgress:i}}var E=`data:image/svg+xml,%3csvg%20t='1777011781316'%20class='icon'%20viewBox='0%200%201439%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='5887'%20width='200'%20height='200'%3e%3cpath%20d='M1283.03672%200.000187H465.243153a158.045778%20158.045778%200%200%200-122.329921%2057.680486L24.083875%20440.475014c-0.622227%200.68445-1.182232%201.431123-1.742237%202.177796A115.672087%20115.672087%200%200%200%200.003672%20511.906728a118.658779%20118.658779%200%200%200%2026.818004%2074.667297l316.713783%20380.492099a158.232446%20158.232446%200%200%200%20121.707694%2056.933814H1283.03672a156.303541%20156.303541%200%200%200%20156.05465-156.116873V156.054837A156.241318%20156.241318%200%200%200%201283.03672%200.000187z%20m-257.477728%20689.863598a47.538179%2047.538179%200%200%201-33.600284%2013.937896%2047.662624%2047.662624%200%200%201-33.662506-13.937896L847.72638%20579.293963l-110.569822%20110.569822a47.911515%2047.911515%200%200%201-33.724729%2013.937896%2047.662624%2047.662624%200%200%201-33.662506-81.325131l110.383154-110.569822-110.569822-110.569822a47.662624%2047.662624%200%200%201%200-67.387235%2047.600402%2047.600402%200%200%201%2067.325012%200l110.632045%20110.632045%20110.569822-110.632045A47.625291%2047.625291%200%200%201%201025.434546%20401.336906l-110.383153%20110.569822%20110.569821%20110.569822a47.662624%2047.662624%200%200%201-0.062222%2067.387235z'%20fill='%232C2C2C'%20p-id='5888'%3e%3c/path%3e%3c/svg%3e`,D=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M19,7V11H5.83L9.41,7.41L8,6L2,12L8,18L9.41,16.58L5.83,13H21V7H19Z'%20/%3e%3c/svg%3e`;function O(){let e=(0,n.createKeyRepeater)();function r(t,n){t.preventDefault(),t.currentTarget?.setPointerCapture?.(t.pointerId),e.start(n)}function i(){e.stop()}return(0,t.onBeforeUnmount)(()=>{e.stop()}),{startRepeat:r,stopRepeat:i}}var te={class:`zhk-candidate-list`},ne=[`onClick`],k=(0,t.defineComponent)({__name:`CandidateList`,props:{candidates:{}},emits:[`select`],setup(e,{emit:n}){let r=n;function i(e){r(`select`,e)}return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,te,[((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(e.candidates,(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:`candidate-${n}`,class:`zhk-candidate-list__item`,onClick:e=>i(n)},(0,t.toDisplayString)(e),9,ne))),128))]))}}),A={class:`handwriting-input`},j={class:`handwriting-content`},M={class:`handwriting-buttons`},N={class:`handwriting-canvas-container`},P={key:0,class:`handwriting-loading`},F={class:`progress-bar`},I={class:`progress-text`},L={class:`handwriting-buttons`},R=(0,t.defineComponent)({__name:`HandwritingInput`,props:{recognizerInitialized:{type:Boolean},recognizerProgress:{}},emits:[`key`,`exit`],setup(e,{emit:r}){let i=e,a=r,o=(0,t.ref)(null),s=null,c=(0,t.ref)(!1),{width:l,height:u}=T(o);function d(){s&&s.clearCanvas()}function f(){o.value&&(s&&s.destroy(),o.value.width=l.value,o.value.height=u.value,s=new n.CanvasDrawer(o.value,{onDrawEnd:g}))}let p=(0,t.ref)([]),{startRepeat:m,stopRepeat:h}=O();async function g(){if(!s||s.getStrokeData().length===0||c.value)return;let e=(0,n.getHandwritingRecognizer)();if(e){c.value=!0;try{let t=[...s.getStrokeData()];p.value=await e.recognize(t)}catch(e){console.error(`识别笔迹失败:`,e)}finally{c.value=!1}}else console.warn(`手写识别服务不可用`)}(0,t.onUnmounted)(()=>{s&&s.destroy()}),(0,t.watchEffect)(()=>{o.value&&(l.value||u.value)&&i.recognizerInitialized&&(0,t.nextTick)(()=>{f()})});function _(e){let t=p.value[e];t&&(a(`key`,{key:t}),p.value=[],d())}return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,A,[(0,t.createVNode)(k,{candidates:p.value,onSelect:_},null,8,[`candidates`]),(0,t.createElementVNode)(`div`,j,[(0,t.createElementVNode)(`div`,M,[(0,t.createElementVNode)(`button`,{class:`handwriting-btn handwriting-btn--function`,onPointerdown:n[0]||=e=>(0,t.unref)(m)(e,()=>a(`key`,{key:`。`})),onPointerup:n[1]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointerleave:n[2]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointercancel:n[3]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onContextmenu:n[4]||=(0,t.withModifiers)(()=>{},[`prevent`])},` 。 `,32),(0,t.createElementVNode)(`button`,{class:`handwriting-btn handwriting-btn--function`,onPointerdown:n[5]||=e=>(0,t.unref)(m)(e,()=>a(`key`,{key:`?`})),onPointerup:n[6]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointerleave:n[7]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointercancel:n[8]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onContextmenu:n[9]||=(0,t.withModifiers)(()=>{},[`prevent`])},` ? `,32),(0,t.createElementVNode)(`button`,{class:`handwriting-btn handwriting-btn--function`,onPointerdown:n[10]||=e=>(0,t.unref)(m)(e,()=>a(`key`,{key:`!`})),onPointerup:n[11]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointerleave:n[12]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointercancel:n[13]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onContextmenu:n[14]||=(0,t.withModifiers)(()=>{},[`prevent`])},` ! `,32),(0,t.createElementVNode)(`button`,{class:`handwriting-btn handwriting-btn--function`,onPointerdown:n[15]||=e=>(0,t.unref)(m)(e,()=>a(`key`,{key:`、`})),onPointerup:n[16]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointerleave:n[17]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointercancel:n[18]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onContextmenu:n[19]||=(0,t.withModifiers)(()=>{},[`prevent`])},` 、 `,32)]),(0,t.createElementVNode)(`div`,N,[e.recognizerInitialized?((0,t.openBlock)(),(0,t.createElementBlock)(`canvas`,{key:1,ref_key:`canvasRef`,ref:o,class:`handwriting-canvas`},null,512)):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,P,[n[37]||=(0,t.createElementVNode)(`div`,{class:`loading-text`},` 正在加载手写识别... `,-1),(0,t.createElementVNode)(`div`,F,[(0,t.createElementVNode)(`div`,{class:`progress-fill`,style:(0,t.normalizeStyle)({width:`${e.recognizerProgress*100}%`})},null,4)]),(0,t.createElementVNode)(`div`,I,(0,t.toDisplayString)(Math.round(e.recognizerProgress*100))+`% `,1)]))]),(0,t.createElementVNode)(`div`,L,[(0,t.createElementVNode)(`button`,{class:`handwriting-btn handwriting-btn--function`,onPointerdown:n[20]||=e=>(0,t.unref)(m)(e,()=>a(`key`,{key:`delete`,isControl:!0})),onPointerup:n[21]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointerleave:n[22]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointercancel:n[23]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onContextmenu:n[24]||=(0,t.withModifiers)(()=>{},[`prevent`])},n[38]||=[(0,t.createElementVNode)(`img`,{src:`data:image/svg+xml,%3csvg%20t='1777011781316'%20class='icon'%20viewBox='0%200%201439%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='5887'%20width='200'%20height='200'%3e%3cpath%20d='M1283.03672%200.000187H465.243153a158.045778%20158.045778%200%200%200-122.329921%2057.680486L24.083875%20440.475014c-0.622227%200.68445-1.182232%201.431123-1.742237%202.177796A115.672087%20115.672087%200%200%200%200.003672%20511.906728a118.658779%20118.658779%200%200%200%2026.818004%2074.667297l316.713783%20380.492099a158.232446%20158.232446%200%200%200%20121.707694%2056.933814H1283.03672a156.303541%20156.303541%200%200%200%20156.05465-156.116873V156.054837A156.241318%20156.241318%200%200%200%201283.03672%200.000187z%20m-257.477728%20689.863598a47.538179%2047.538179%200%200%201-33.600284%2013.937896%2047.662624%2047.662624%200%200%201-33.662506-13.937896L847.72638%20579.293963l-110.569822%20110.569822a47.911515%2047.911515%200%200%201-33.724729%2013.937896%2047.662624%2047.662624%200%200%201-33.662506-81.325131l110.383154-110.569822-110.569822-110.569822a47.662624%2047.662624%200%200%201%200-67.387235%2047.600402%2047.600402%200%200%201%2067.325012%200l110.632045%20110.632045%20110.569822-110.632045A47.625291%2047.625291%200%200%201%201025.434546%20401.336906l-110.383153%20110.569822%20110.569821%20110.569822a47.662624%2047.662624%200%200%201-0.062222%2067.387235z'%20fill='%232C2C2C'%20p-id='5888'%3e%3c/path%3e%3c/svg%3e`,alt:`删除`},null,-1)],32),(0,t.createElementVNode)(`button`,{class:`handwriting-btn handwriting-btn--function`,onClick:n[25]||=e=>a(`exit`),onContextmenu:n[26]||=(0,t.withModifiers)(()=>{},[`prevent`])},` 拼音 `,32),(0,t.createElementVNode)(`button`,{class:`handwriting-btn handwriting-btn--function`,onPointerdown:n[27]||=e=>(0,t.unref)(m)(e,()=>a(`key`,{key:`,`})),onPointerup:n[28]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointerleave:n[29]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointercancel:n[30]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onContextmenu:n[31]||=(0,t.withModifiers)(()=>{},[`prevent`])},` , `,32),(0,t.createElementVNode)(`button`,{class:`handwriting-btn handwriting-btn--function`,onPointerdown:n[32]||=e=>(0,t.unref)(m)(e,()=>a(`key`,{key:`enter`,isControl:!0})),onPointerup:n[33]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointerleave:n[34]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointercancel:n[35]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onContextmenu:n[36]||=(0,t.withModifiers)(()=>{},[`prevent`])},n[39]||=[(0,t.createElementVNode)(`img`,{src:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M19,7V11H5.83L9.41,7.41L8,6L2,12L8,18L9.41,16.58L5.83,13H21V7H19Z'%20/%3e%3c/svg%3e`,alt:`回车`},null,-1)],32)])])]))}}),z=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M6,18H18V16H6M12,8.41L16.59,13L18,11.58L12,5.58L6,11.58L7.41,13L12,8.41Z'%20/%3e%3c/svg%3e`,B=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M3%2015H5V19H19V15H21V19C21%2020.1%2020.1%2021%2019%2021H5C3.9%2021%203%2020.1%203%2019V15Z'%20/%3e%3c/svg%3e`,V={class:`zhk-selection`},H={class:`zhk-selection__list`},U=[`onClick`],W=(0,t.defineComponent)({__name:`CandidateSelection`,props:{candidates:{}},emits:[`select`,`close`],setup(e,{emit:n}){let r=n;function i(e){r(`select`,e)}function a(){r(`close`)}function o(e){let t=Array.from(e).length;return t>=2&&t<=3?2:t>=4?3:1}return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,V,[(0,t.createElementVNode)(`div`,H,[((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(e.candidates,(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:n,class:(0,t.normalizeClass)([`zhk-selection__text`,[`zhk-selection__text--span-${o(e)}`]]),onClick:e=>i(n)},(0,t.toDisplayString)(e),11,U))),128))]),(0,t.createElementVNode)(`div`,{class:`zhk-selection__func`},[(0,t.createElementVNode)(`button`,{class:`zhk-selection__func-btn`,onClick:a},` 返回 `)])]))}}),G={class:`zhk-candidate`},K={class:`zhk-candidate__container`},q={key:0,class:`zhk-candidate__pinyin`},J={class:`zhk-candidate__bottom-container`},Y=(0,t.defineComponent)({__name:`CandidateBar`,props:{modelValue:{required:!0},modelModifiers:{}},emits:(0,t.mergeModels)([`key`,`input`],[`update:modelValue`]),setup(e,{expose:r,emit:i}){let a=i,o=(0,t.useModel)(e,`modelValue`),s=null,c=(0,t.ref)(null),l=(0,t.computed)(()=>c.value?.candidates.map(e=>e.text)??[]),u=(0,t.ref)(!1);(0,t.onMounted)(async()=>{if(s=(0,n.getPinyinEngine)(),!s)throw Error(`未找到拼音引擎实例,请确保已正确注册引擎`);o.value&&(c.value=await s.processInput(o.value))}),(0,t.onUnmounted)(()=>{s?.processInput(``).catch(()=>{}),s=null}),(0,t.watch)(o,async e=>{let t=s;if(t){if(e===``){t.processInput(``).catch(()=>{}),c.value=null;return}c.value=await t.processInput(e)}});async function d(e){if(!s)return;let t=await s.pickCandidate(e);c.value=t,t.preeditBody||(a(`input`,t.committed||``),o.value=``,c.value=null,u.value=!1)}r({handleSelection:d});let f=(0,t.computed)(()=>{let e=c.value;return e?e.preeditHead+e.preeditBody:``});return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,G,[(0,t.createElementVNode)(`div`,K,[f.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,q,(0,t.toDisplayString)(f.value),1)):(0,t.createCommentVNode)(``,!0),(0,t.createElementVNode)(`div`,J,[l.value.length>0?((0,t.openBlock)(),(0,t.createBlock)(k,{key:0,candidates:l.value,onSelect:d},null,8,[`candidates`])):(0,t.createCommentVNode)(``,!0),l.value.length>0?((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:1,class:`zhk-candidate__more`,onClick:n[0]||=e=>u.value=!0},n[2]||=[(0,t.createElementVNode)(`img`,{src:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z'%20/%3e%3c/svg%3e`,alt:`更多`},null,-1)])):(0,t.createCommentVNode)(``,!0)])]),u.value?((0,t.openBlock)(),(0,t.createBlock)(W,{key:0,candidates:l.value,onSelect:d,onClose:n[1]||=e=>u.value=!1},null,8,[`candidates`])):(0,t.createCommentVNode)(``,!0)]))}}),X={class:`zhk-base`},Z={class:`zhk-base__row`},re=[`onPointerdown`],ie=[`disabled`],ae={key:1,src:z,class:`zhk-base__key-icon`,alt:`Shift`},oe=[`onPointerdown`],se={class:`zhk-base__row`},ce={class:`zhk-base__toggle-main`},le={class:`zhk-base__toggle-sub`},ue=(0,t.defineComponent)({__name:`KeyboardBase`,props:(0,t.mergeModels)({enableHandwriting:{type:Boolean}},{modelValue:{default:`en`},modelModifiers:{}}),emits:(0,t.mergeModels)([`key`],[`update:modelValue`]),setup(e,{emit:n}){let r=e,i=n,a=(0,t.useModel)(e,`modelValue`),o=(0,t.computed)(()=>a.value===`en_cap`),s=(0,t.computed)(()=>a.value===`zh`),c=(0,t.computed)(()=>s.value?!0:o.value);function l(e,t=!1){i(`key`,{key:e,isControl:t})}function u(){s.value?a.value=`hand`:a.value=o.value?`en`:`en_cap`}function d(){a.value=`num`}function f(){a.value=`symbol`}let p=[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`0`],m=[[`q`,`w`,`e`,`r`,`t`,`y`,`u`,`i`,`o`,`p`],[`a`,`s`,`d`,`f`,`g`,`h`,`j`,`k`,`l`],[`z`,`x`,`c`,`v`,`b`,`n`,`m`]],h=(0,t.ref)(``),g=(0,t.ref)(null),{startRepeat:_,stopRepeat:v}=O();function y(){if(a.value===`zh`&&h.value){h.value=h.value.slice(0,-1);return}l(`delete`,!0)}function b(){if(a.value===`zh`&&h.value){g.value?.handleSelection(0);return}l(` `)}function x(){if(a.value===`zh`&&h.value){l(h.value),h.value=``;return}l(`enter`,!0)}function S(e){if(a.value===`zh`){h.value+=e;return}l(o.value?e.toUpperCase():e)}function C(){a.value=a.value===`zh`?`en`:`zh`}let w=(0,t.computed)(()=>r.enableHandwriting?`手写`:`-`),T=(0,t.computed)(()=>!r.enableHandwriting);return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,X,[(0,t.createElementVNode)(`div`,Z,[a.value===`zh`?((0,t.openBlock)(),(0,t.createBlock)(Y,{key:0,ref_key:`candidateBarRef`,ref:g,modelValue:h.value,"onUpdate:modelValue":n[0]||=e=>h.value=e,onInput:n[1]||=e=>l(e,!1)},null,8,[`modelValue`])):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:1},(0,t.renderList)(p,(e,r)=>(0,t.createElementVNode)(`button`,{key:`number-${r}`,class:`zhk-base__key zhk-base__key--letter`,onPointerdown:n=>(0,t.unref)(_)(n,()=>S(e)),onPointerup:n[2]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointerleave:n[3]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointercancel:n[4]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onContextmenu:n[5]||=(0,t.withModifiers)(()=>{},[`prevent`])},(0,t.toDisplayString)(e),41,re)),64))]),((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(m,(e,r)=>(0,t.createElementVNode)(`div`,{key:`row-${r}`,class:`zhk-base__row`},[r===2?((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:0,class:(0,t.normalizeClass)([`zhk-base__key zhk-base__key--function zhk-base__key--shift`,{"zhk-base__key--active":!s.value&&o.value,"zhk-base__key--disabled":s.value&&T.value}]),disabled:s.value&&T.value,onClick:u,onContextmenu:n[6]||=(0,t.withModifiers)(()=>{},[`prevent`])},[s.value?((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:0},[(0,t.createTextVNode)((0,t.toDisplayString)(w.value),1)],64)):((0,t.openBlock)(),(0,t.createElementBlock)(`img`,ae))],42,ie)):(0,t.createCommentVNode)(``,!0),((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(e,(e,i)=>((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:`key-${r}-${i}`,class:`zhk-base__key zhk-base__key--letter`,onPointerdown:n=>(0,t.unref)(_)(n,()=>S(e)),onPointerup:n[7]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointerleave:n[8]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointercancel:n[9]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onContextmenu:n[10]||=(0,t.withModifiers)(()=>{},[`prevent`])},(0,t.toDisplayString)(c.value?e.toUpperCase():e),41,oe))),128)),r===2?((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:1,class:`zhk-base__key zhk-base__key--function zhk-base__key--delete`,onPointerdown:n[11]||=e=>(0,t.unref)(_)(e,()=>y()),onPointerup:n[12]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointerleave:n[13]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointercancel:n[14]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onContextmenu:n[15]||=(0,t.withModifiers)(()=>{},[`prevent`])},n[39]||=[(0,t.createElementVNode)(`img`,{src:`data:image/svg+xml,%3csvg%20t='1777011781316'%20class='icon'%20viewBox='0%200%201439%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='5887'%20width='200'%20height='200'%3e%3cpath%20d='M1283.03672%200.000187H465.243153a158.045778%20158.045778%200%200%200-122.329921%2057.680486L24.083875%20440.475014c-0.622227%200.68445-1.182232%201.431123-1.742237%202.177796A115.672087%20115.672087%200%200%200%200.003672%20511.906728a118.658779%20118.658779%200%200%200%2026.818004%2074.667297l316.713783%20380.492099a158.232446%20158.232446%200%200%200%20121.707694%2056.933814H1283.03672a156.303541%20156.303541%200%200%200%20156.05465-156.116873V156.054837A156.241318%20156.241318%200%200%200%201283.03672%200.000187z%20m-257.477728%20689.863598a47.538179%2047.538179%200%200%201-33.600284%2013.937896%2047.662624%2047.662624%200%200%201-33.662506-13.937896L847.72638%20579.293963l-110.569822%20110.569822a47.911515%2047.911515%200%200%201-33.724729%2013.937896%2047.662624%2047.662624%200%200%201-33.662506-81.325131l110.383154-110.569822-110.569822-110.569822a47.662624%2047.662624%200%200%201%200-67.387235%2047.600402%2047.600402%200%200%201%2067.325012%200l110.632045%20110.632045%20110.569822-110.632045A47.625291%2047.625291%200%200%201%201025.434546%20401.336906l-110.383153%20110.569822%20110.569821%20110.569822a47.662624%2047.662624%200%200%201-0.062222%2067.387235z'%20fill='%232C2C2C'%20p-id='5888'%3e%3c/path%3e%3c/svg%3e`,class:`zhk-base__key-icon`,alt:`Delete`},null,-1)],32)):(0,t.createCommentVNode)(``,!0)])),64)),(0,t.createElementVNode)(`div`,se,[(0,t.createElementVNode)(`button`,{class:`zhk-base__key zhk-base__key--function`,onClick:f,onContextmenu:n[16]||=(0,t.withModifiers)(()=>{},[`prevent`])},` 符 `,32),(0,t.createElementVNode)(`button`,{class:`zhk-base__key zhk-base__key--function`,onClick:d,onContextmenu:n[17]||=(0,t.withModifiers)(()=>{},[`prevent`])},` 123 `,32),(0,t.createElementVNode)(`button`,{class:`zhk-base__key`,onPointerdown:n[18]||=e=>(0,t.unref)(_)(e,()=>l(`,`)),onPointerup:n[19]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointerleave:n[20]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointercancel:n[21]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onContextmenu:n[22]||=(0,t.withModifiers)(()=>{},[`prevent`])},` , `,32),(0,t.createElementVNode)(`button`,{class:`zhk-base__key zhk-base__key--space`,onPointerdown:n[23]||=e=>(0,t.unref)(_)(e,()=>b()),onPointerup:n[24]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointerleave:n[25]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointercancel:n[26]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onContextmenu:n[27]||=(0,t.withModifiers)(()=>{},[`prevent`])},n[40]||=[(0,t.createElementVNode)(`img`,{src:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M3%2015H5V19H19V15H21V19C21%2020.1%2020.1%2021%2019%2021H5C3.9%2021%203%2020.1%203%2019V15Z'%20/%3e%3c/svg%3e`,class:`zhk-base__key-icon`,alt:`Space`},null,-1)],32),(0,t.createElementVNode)(`button`,{class:`zhk-base__key`,onPointerdown:n[28]||=e=>(0,t.unref)(_)(e,()=>l(`。`)),onPointerup:n[29]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointerleave:n[30]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointercancel:n[31]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onContextmenu:n[32]||=(0,t.withModifiers)(()=>{},[`prevent`])},` 。 `,32),(0,t.createElementVNode)(`button`,{class:`zhk-base__key zhk-base__key--function`,onClick:C,onContextmenu:n[33]||=(0,t.withModifiers)(()=>{},[`prevent`])},[(0,t.createElementVNode)(`span`,ce,(0,t.toDisplayString)(a.value===`zh`?`中`:`英`),1),(0,t.createElementVNode)(`span`,le,`/`+(0,t.toDisplayString)(a.value===`zh`?`英`:`中`),1)],32),(0,t.createElementVNode)(`button`,{class:`zhk-base__key zhk-base__key--function`,onPointerdown:n[34]||=e=>(0,t.unref)(_)(e,()=>x()),onPointerup:n[35]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointerleave:n[36]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointercancel:n[37]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onContextmenu:n[38]||=(0,t.withModifiers)(()=>{},[`prevent`])},n[41]||=[(0,t.createElementVNode)(`img`,{src:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M19,7V11H5.83L9.41,7.41L8,6L2,12L8,18L9.41,16.58L5.83,13H21V7H19Z'%20/%3e%3c/svg%3e`,class:`zhk-base__key-icon`,alt:`Enter`},null,-1)],32)])]))}}),de={class:`num-keyboard`},fe={class:`num-keyboard__container`},pe={class:`num-keyboard__left`},me={class:`num-keyboard__rows`},he=[`onClick`,`onPointerdown`],ge={key:1,src:B,class:`zhk-base__key-icon`,alt:`Space`},_e={class:`num-keyboard__right`},ve=[`onPointerdown`],ye=[`src`,`alt`],be={key:1},xe=(0,t.defineComponent)({__name:`NumericKeyboard`,props:{keyboardRows:{default:()=>(0,n.getKeyboardConfig)().numKeys||[[`1`,`2`,`3`],[`4`,`5`,`6`],[`7`,`8`,`9`],[`back`,`0`,`space`]]}},emits:[`key`,`exit`],setup(e,{emit:n}){let r=n,i=[{key:`delete`,icon:E,text:``,alt:`Delete`},{key:`.`,icon:``,text:`.`,alt:`.`},{key:`@`,icon:``,text:`@`,alt:`@`},{key:`enter`,icon:D,text:``,alt:`Enter`}];function a(e){r(`key`,{key:e})}function o(e,t=!0){r(`key`,{key:e,isControl:t})}function s(){r(`exit`)}let{startRepeat:c,stopRepeat:l}=O();function u(e,t){e===`back`||(e===`space`&&(e=` `),e===`delete`||e===`enter`?c(t,()=>o(e)):c(t,()=>a(e)))}return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,de,[(0,t.createElementVNode)(`div`,fe,[(0,t.createElementVNode)(`div`,pe,[(0,t.createElementVNode)(`div`,me,[((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(e.keyboardRows,(e,r)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:`row-${r}`,class:`num-keyboard__row`},[((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(e,(e,i)=>((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:`key-${r}-${i}`,class:(0,t.normalizeClass)([`num-keyboard__key`,{"num-keyboard__key--back":e===`back`,"num-keyboard__key--space":e===`space`}]),onClick:t=>e===`back`&&s(),onPointerdown:t=>u(e,t),onPointerup:n[0]||=(...e)=>(0,t.unref)(l)&&(0,t.unref)(l)(...e),onPointerleave:n[1]||=(...e)=>(0,t.unref)(l)&&(0,t.unref)(l)(...e),onPointercancel:n[2]||=(...e)=>(0,t.unref)(l)&&(0,t.unref)(l)(...e),onContextmenu:n[3]||=(0,t.withModifiers)(()=>{},[`prevent`])},[e===`back`?((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:0},[(0,t.createTextVNode)(` 返回 `)],64)):e===`space`?((0,t.openBlock)(),(0,t.createElementBlock)(`img`,ge)):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:2},[(0,t.createTextVNode)((0,t.toDisplayString)(e),1)],64))],42,he))),128))]))),128))])]),(0,t.createElementVNode)(`div`,_e,[((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(i,(e,r)=>(0,t.createElementVNode)(`button`,{key:`func-${r}`,class:`num-keyboard__key num-keyboard__key--function`,onPointerdown:t=>u(e.key,t),onPointerup:n[4]||=(...e)=>(0,t.unref)(l)&&(0,t.unref)(l)(...e),onPointerleave:n[5]||=(...e)=>(0,t.unref)(l)&&(0,t.unref)(l)(...e),onPointercancel:n[6]||=(...e)=>(0,t.unref)(l)&&(0,t.unref)(l)(...e),onContextmenu:n[7]||=(0,t.withModifiers)(()=>{},[`prevent`])},[e.icon?((0,t.openBlock)(),(0,t.createElementBlock)(`img`,{key:0,src:e.icon,class:`num-keyboard__key-icon`,alt:e.alt},null,8,ye)):((0,t.openBlock)(),(0,t.createElementBlock)(`span`,be,(0,t.toDisplayString)(e.text),1))],40,ve)),64))])])]))}}),Se=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M18,20V10H6V20H18M18,8A2,2%200%200,1%2020,10V20A2,2%200%200,1%2018,22H6C4.89,22%204,21.1%204,20V10A2,2%200%200,1%206,8H15V6A3,3%200%200,0%2012,3A3,3%200%200,0%209,6H7A5,5%200%200,1%2012,1A5,5%200%200,1%2017,6V8H18M12,17A2,2%200%200,1%2010,15A2,2%200%200,1%2012,13A2,2%200%200,1%2014,15A2,2%200%200,1%2012,17Z'%20/%3e%3c/svg%3e`,Ce=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M12,17C10.89,17%2010,16.1%2010,15C10,13.89%2010.89,13%2012,13A2,2%200%200,1%2014,15A2,2%200%200,1%2012,17M18,20V10H6V20H18M18,8A2,2%200%200,1%2020,10V20A2,2%200%200,1%2018,22H6C4.89,22%204,21.1%204,20V10C4,8.89%204.89,8%206,8H7V6A5,5%200%200,1%2012,1A5,5%200%200,1%2017,6V8H18M12,3A3,3%200%200,0%209,6V8H15V6A3,3%200%200,0%2012,3Z'%20/%3e%3c/svg%3e`,we={class:`symbol-keyboard`},Te={class:`symbol-keyboard__content`},Ee={class:`symbol-keyboard__functions`},De={class:`symbol-keyboard__lang-selector`},Oe={class:`symbol-keyboard__control-group`},Q=[`src`],ke=[`src`],Ae={class:`symbol-keyboard__symbols-container`},je={class:`symbol-keyboard__symbols-grid`},Me=[`onClick`,`onPointerdown`],Ne=`!@#$%^&*(){}[]<>/\\|:;"',.?+-=_~\`€£¥₹©®™°`,Pe=`!@#¥%…&*(){}[]<>/\|:;"',。?+-=_~·€£¥₹©®™°`,Fe=(0,t.defineComponent)({__name:`SymbolKeyboard`,emits:[`key`,`exit`],setup(e,{emit:n}){let r=n,i=(0,t.ref)(`en`),a=(0,t.computed)(()=>i.value===`zh`?Pe:Ne),o=(0,t.ref)(!1),{startRepeat:s,stopRepeat:c}=O();function l(e,t){o.value&&s(t,()=>u(e))}function u(e){r(`key`,{key:e}),o.value||r(`exit`)}function d(){r(`exit`)}function f(e){i.value=e}function p(){o.value=!o.value}return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,we,[(0,t.createElementVNode)(`div`,Te,[(0,t.createElementVNode)(`div`,Ee,[(0,t.createElementVNode)(`div`,De,[(0,t.createElementVNode)(`button`,{class:(0,t.normalizeClass)([`symbol-keyboard__lang-btn`,{"symbol-keyboard__lang-btn--active":i.value===`zh`}]),onClick:n[0]||=e=>f(`zh`),onContextmenu:n[1]||=(0,t.withModifiers)(()=>{},[`prevent`])},` 中文 `,34),(0,t.createElementVNode)(`button`,{class:(0,t.normalizeClass)([`symbol-keyboard__lang-btn`,{"symbol-keyboard__lang-btn--active":i.value===`en`}]),onClick:n[2]||=e=>f(`en`),onContextmenu:n[3]||=(0,t.withModifiers)(()=>{},[`prevent`])},` 英文 `,34)]),(0,t.createElementVNode)(`div`,Oe,[(0,t.createElementVNode)(`button`,{class:(0,t.normalizeClass)([`symbol-keyboard__key symbol-keyboard__key--function symbol-keyboard__key--lock`,{"symbol-keyboard__key--locked":o.value}]),onClick:p,onContextmenu:n[4]||=(0,t.withModifiers)(()=>{},[`prevent`])},[o.value?((0,t.openBlock)(),(0,t.createElementBlock)(`img`,{key:1,src:(0,t.unref)(Ce),alt:`Lock closed`},null,8,ke)):((0,t.openBlock)(),(0,t.createElementBlock)(`img`,{key:0,src:(0,t.unref)(Se),alt:`Lock open`},null,8,Q))],34),(0,t.createElementVNode)(`button`,{class:`symbol-keyboard__key symbol-keyboard__key--function symbol-keyboard__key--back`,onClick:d,onContextmenu:n[5]||=(0,t.withModifiers)(()=>{},[`prevent`])},` 返回 `,32)])]),(0,t.createElementVNode)(`div`,Ae,[(0,t.createElementVNode)(`div`,je,[((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(a.value,(e,r)=>((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:`key-${r}`,class:`symbol-keyboard__key`,onClick:t=>!o.value&&u(e),onPointerdown:t=>l(e,t),onPointerup:n[6]||=(...e)=>(0,t.unref)(c)&&(0,t.unref)(c)(...e),onPointerleave:n[7]||=(...e)=>(0,t.unref)(c)&&(0,t.unref)(c)(...e),onPointercancel:n[8]||=(...e)=>(0,t.unref)(c)&&(0,t.unref)(c)(...e),onContextmenu:n[9]||=(0,t.withModifiers)(()=>{},[`prevent`])},(0,t.toDisplayString)(e),41,Me))),128))])])])]))}}),Ie={key:0,class:`zhk__disabled-overlay`},$=(0,t.defineComponent)({__name:`ZhKeyboard`,props:{defaultMode:{type:String,default:()=>(0,n.getKeyboardConfig)().defaultMode??`en`},enableHandwriting:{type:Boolean,default:()=>(0,n.getKeyboardConfig)().enableHandwriting??!1},position:{type:String,default:()=>(0,n.getKeyboardConfig)().position??`static`},floatMarginTop:{type:Number,default:()=>(0,n.getKeyboardConfig)().floatMarginTop??0},disableWhenNoFocus:{type:Boolean,default:()=>(0,n.getKeyboardConfig)().disableWhenNoFocus??!0},numKeys:{type:Array||void 0}},emits:[`key`],setup(e,{emit:r}){let i=e,a=r,o=(0,t.ref)(i.defaultMode),s=(0,t.ref)(i.defaultMode),c=(0,t.ref)([]),l=(0,t.ref)(!1),u=(0,t.ref)(null),d=(0,t.ref)(null),{recognizerInitialized:f,recognizerProgress:m}=ee(i.enableHandwriting);(0,t.watch)(o,(e,t)=>{e!==t&&(s.value=t)});let h=C(),g=(0,t.computed)(()=>h.value&&(0,n.isInputElement)(h.value)?h.value:null),_=(0,t.computed)(()=>i.position===`static`||!!(h.value&&(0,n.isInputElement)(h.value))),{height:y}=T(d);(0,t.watchEffect)(()=>{if(g.value){let e=g.value.dataset.inputmode;e&&(o.value=e)}});let b=(0,t.computed)(()=>i.disableWhenNoFocus===!1?!1:!g.value);function x(){y.value&&(u.value=(0,n.calculateKeyboardPosition)(g.value,d.value,i.position,i.floatMarginTop))}(0,t.watchEffect)(x);let S=p(x,100);v(window,`scroll`,S,{passive:!0}),v(window,`resize`,S,{passive:!0});function w(e){if(e.isControl){switch(e.key){case`delete`:(0,n.delToInputElement)(g.value);break;case`more`:l.value=!0;break;default:break}return}else E(e.key);a(`key`,e)}function E(e){(0,n.writeToInputElement)(g.value,e)}function D(){o.value===`hand`?s.value=`zh`:[`num`,`symbol`].includes(s.value)&&(s.value=i.defaultMode),o.value=s.value}function O(e){c.value=e}return(n,r)=>(0,t.withDirectives)(((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{ref_key:`keyboardRef`,ref:d,class:(0,t.normalizeClass)([`zhk`,{"zhk--floating":e.position===`float`,"zhk--bottom":e.position===`bottom`,"zhk--disabled":b.value}]),style:(0,t.normalizeStyle)({"--keyboard-height":`${(0,t.unref)(y)}px`,...u.value}),onMousedown:r[1]||=(0,t.withModifiers)(()=>{},[`prevent`])},[b.value||!_.value||!(0,t.unref)(y)?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Ie,r[2]||=[(0,t.createElementVNode)(`span`,null,`请选择输入框以启用键盘`,-1)])):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:1},[o.value===`hand`?((0,t.openBlock)(),(0,t.createBlock)(R,{key:0,"recognizer-initialized":(0,t.unref)(f),"recognizer-progress":(0,t.unref)(m),onKey:w,onExit:D,onRecognize:O},null,8,[`recognizer-initialized`,`recognizer-progress`])):o.value===`num`?((0,t.openBlock)(),(0,t.createBlock)(xe,{key:1,"keyboard-rows":e.numKeys,onKey:w,onExit:D},null,8,[`keyboard-rows`])):o.value===`symbol`?((0,t.openBlock)(),(0,t.createBlock)(Fe,{key:2,onKey:w,onExit:D})):o.value===`en`||o.value===`en_cap`||o.value===`zh`?((0,t.openBlock)(),(0,t.createBlock)(ue,{key:3,modelValue:o.value,"onUpdate:modelValue":r[0]||=e=>o.value=e,"enable-handwriting":e.enableHandwriting,onKey:w},null,8,[`modelValue`,`enable-handwriting`])):(0,t.createCommentVNode)(``,!0)],64))],38)),[[t.vShow,_.value]])}});e.ZhKeyboard=$,e.default={install:e=>{e.component(`ZhKeyboard`,$)}},Object.keys(n).forEach(function(t){t!==`default`&&!Object.prototype.hasOwnProperty.call(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})})});
|
|
2
|
+
//# sourceMappingURL=zh-keyboard-vue.umd.cjs.map
|