@zh-keyboard/vue 1.1.0 → 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/components/HandwritingInput.vue.d.ts +0 -1
- package/dist/style.css +2 -1
- package/dist/zh-keyboard-vue.js +991 -1433
- 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 Dt=Object.defineProperty;var Ht=(E,e,_)=>e in E?Dt(E,e,{enumerable:!0,configurable:!0,writable:!0,value:_}):E[e]=_;var x=(E,e,_)=>Ht(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]",F=()=>{};function ue(t,o){function i(...a){return new Promise((l,r)=>{Promise.resolve(t(()=>o.apply(this,a),{fn:o,thisArg:this,args:a})).then(l).catch(r)})}return i}function me(t,o={}){let i,a,l=F;const r=f=>{clearTimeout(f),l(),l=F};let c;return f=>{const y=e.toValue(t),h=e.toValue(o.maxWait);return i&&r(i),y<=0||h!==void 0&&h<=0?(a&&(r(a),a=null),Promise.resolve(f())):new Promise((d,k)=>{l=o.rejectOnCancel?k:d,c=f,h&&!a&&(a=setTimeout(()=>{i&&r(i),a=null,d(c())},h)),i=setTimeout(()=>{a&&r(a),a=null,d(f())},y)})}}function D(t){return Array.isArray(t)?t:[t]}function pe(t){return e.getCurrentInstance()}function ke(t,o=200,i={}){return ue(me(o,i),t)}function ge(t,o=!0,i){pe()?e.onMounted(t,i):o?t():e.nextTick(t)}function he(t,o,i){return e.watch(t,o,{...i,immediate:!0})}const $=ae?window:void 0;function N(t){var o;const i=e.toValue(t);return(o=i==null?void 0:i.$el)!=null?o:i}function H(...t){const o=[],i=()=>{o.forEach(m=>m()),o.length=0},a=(m,f,y,h)=>(m.addEventListener(f,y,h),()=>m.removeEventListener(f,y,h)),l=e.computed(()=>{const m=D(e.toValue(t[0])).filter(f=>f!=null);return m.every(f=>typeof f!="string")?m:void 0}),r=he(()=>{var m,f;return[(f=(m=l.value)==null?void 0:m.map(y=>N(y)))!=null?f:[$].filter(y=>y!=null),D(e.toValue(l.value?t[1]:t[0])),D(e.unref(l.value?t[2]:t[1])),e.toValue(l.value?t[3]:t[2])]},([m,f,y,h])=>{if(i(),!(m!=null&&m.length)||!(f!=null&&f.length)||!(y!=null&&y.length))return;const d=fe(h)?{...h}:h;o.push(...m.flatMap(k=>f.flatMap(u=>y.map(p=>a(k,u,p,d)))))},{flush:"post"}),c=()=>{r(),i()};return _(i),c}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,i={}){const{window:a=$,...l}=i;let r;const c=j(()=>a&&"MutationObserver"in a),m=()=>{r&&(r.disconnect(),r=void 0)},f=e.computed(()=>{const k=e.toValue(t),u=D(k).map(N).filter(de);return new Set(u)}),y=e.watch(()=>f.value,k=>{m(),c.value&&k.size&&(r=new MutationObserver(o),k.forEach(u=>r.observe(u,l)))},{immediate:!0,flush:"post"}),h=()=>r==null?void 0:r.takeRecords(),d=()=>{y(),m()};return _(d),{isSupported:c,stop:d,takeRecords:h}}function we(t,o,i={}){const{window:a=$,document:l=a==null?void 0:a.document,flush:r="sync"}=i;if(!a||!l)return F;let c;const m=h=>{c==null||c(),c=h},f=e.watchEffect(()=>{const h=N(t);if(h){const{stop:d}=be(l,k=>{k.map(p=>[...p.removedNodes]).flat().some(p=>p===h||p.contains(h))&&o(k)},{window:a,childList:!0,subtree:!0});m(d)}},{flush:r}),y=()=>{f(),m()};return _(y),y}function Ee(t={}){var o;const{window:i=$,deep:a=!0,triggerOnRemoval:l=!1}=t,r=(o=t.document)!=null?o:i==null?void 0:i.document,c=()=>{var y;let h=r==null?void 0:r.activeElement;if(a)for(;h!=null&&h.shadowRoot;)h=(y=h==null?void 0:h.shadowRoot)==null?void 0:y.activeElement;return h},m=e.shallowRef(),f=()=>{m.value=c()};if(i){const y={capture:!0,passive:!0};H(i,"blur",h=>{h.relatedTarget===null&&f()},y),H(i,"focus",f,y)}return l&&we(m,f,{document:r}),f(),m}function Ce(t,o,i={}){const{window:a=$,...l}=i;let r;const c=j(()=>a&&"ResizeObserver"in a),m=()=>{r&&(r.disconnect(),r=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(m(),c.value&&a){r=new ResizeObserver(o);for(const k of d)k&&r.observe(k,l)}},{immediate:!0,flush:"post"}),h=()=>{m(),y()};return _(h),{isSupported:c,stop:h}}function X(t,o={width:0,height:0},i={}){const{window:a=$,box:l="content-box"}=i,r=e.computed(()=>{var d,k;return(k=(d=N(t))==null?void 0:d.namespaceURI)==null?void 0:k.includes("svg")}),c=e.shallowRef(o.width),m=e.shallowRef(o.height),{stop:f}=Ce(t,([d])=>{const k=l==="border-box"?d.borderBoxSize:l==="content-box"?d.contentBoxSize:d.devicePixelContentBoxSize;if(a&&r.value){const u=N(t);if(u){const p=u.getBoundingClientRect();c.value=p.width,m.value=p.height}}else if(k){const u=D(k);c.value=u.reduce((p,{inlineSize:C})=>p+C,0),m.value=u.reduce((p,{blockSize:C})=>p+C,0)}else c.value=d.contentRect.width,m.value=d.contentRect.height},i);ge(()=>{const d=N(t);d&&(c.value="offsetWidth"in d?d.offsetWidth:o.width,m.value="offsetHeight"in d?d.offsetHeight:o.height)});const y=e.watch(()=>N(t),d=>{c.value=d?o.width:0,m.value=d?o.height:0});function h(){f(),y()}return{width:c,height:m,stop:h}}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:i}=this.getEventCoordinates(t);this.startDrawing(o,i),this.resetClearTimer()});x(this,"handleMove",t=>{if(!this.isDrawing)return;t.preventDefault();const{offsetX:o,offsetY:i}=this.getEventCoordinates(t);this.draw(o,i),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 i=this.canvas.getContext("2d");if(!i)throw new Error("Failed to get 2D rendering context");this.ctx=i,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],i=t.target.getBoundingClientRect();return{offsetX:o.clientX-i.left,offsetY:o.clientY-i.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 W={defaultMode:"en",enableHandwriting:!1,position:"static",disableWhenNoFocus:!0},G=null,q=null;function S(){return W}function ze(t){W={...W,...t}}function Be(t){G=t}function I(){return G}function Ve(t){q=t}function J(){return q}function Q(t,o,i,a=0){if(!t||!o||i==="static")return null;let l,r;if(i==="bottom")l=window.innerHeight-o.offsetHeight,r=0;else{const c=t.getBoundingClientRect(),m=o.offsetWidth;l=c.bottom+window.scrollY+a,r=c.left+window.scrollX+c.width/2-m/2;const f=window.innerWidth;r+m>f&&(r=f-m-10),r<10&&(r=10)}return{top:`${l}px`,left:`${r}px`}}function A(t){if(!t)return!1;if(t.tagName==="TEXTAREA")return!0;if(t.tagName==="INPUT"){const i=(t.type||"text").toLowerCase();return!["checkbox","radio","button","submit","reset","file","image","range","color","hidden","date","datetime-local","month","week","time"].includes(i)}return!1}function xe(){if(document.activeElement&&A(document.activeElement))return document.activeElement;throw new Error("输入框没有被激活")}function Pe(t,o,i){t.value=o,oe(t,i),t.dispatchEvent(new Event("input",{bubbles:!0}))}function _e(t,o,i,a=""){return t.slice(0,o)+a+t.slice(o+i)}function ee(t,o=""){const i=Number(t.getAttribute("maxlength"));let a=t.selectionStart??0;const l=t.selectionEnd??a;let r;if(o.length>0)r=l-a;else{const f=l-a;if(f>0)r=f;else if(a>0)r=1,a--;else return}if(o.length>0&&i&&t.value.length-r+o.length>i)return;const c=_e(t.value,a,r,o),m=a+o.length;Pe(t,c,m)}function te(t,o){ee(t,o)}function ne(t){ee(t)}function oe(t,o){t.selectionStart=o,t.selectionEnd=o}function re(t={}){const o=t.delay??400,i=t.interval??60;let a,l;function r(){a&&(clearTimeout(a),a=void 0),l&&(clearInterval(l),l=void 0)}function c(m){r(),m(),a=setTimeout(()=>{l=setInterval(()=>{m()},i)},o)}return{start:c,stop:r}}function Ne(t=!1){const o=e.ref(!1),i=e.ref(0);async function a(){const r=I();if(r)try{o.value=await r.initialize({onProgress:c=>{i.value=c}})}catch(c){console.error("初始化手写识别服务失败:",c),o.value=!1}else console.warn("未注册手写识别服务"),o.value=!1}async function l(){const r=I();if(r&&o.value)try{await r.close(),o.value=!1}catch(c){console.error("关闭手写识别服务失败:",c)}}return e.onMounted(()=>{t&&a()}),e.onUnmounted(()=>{l()}),{recognizerInitialized:o,recognizerProgress:i}}const O="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",U="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=re();function o(a,l){var r,c;a.preventDefault(),(c=(r=a.currentTarget)==null?void 0:r.setPointerCapture)==null||c.call(r,a.pointerId),t.start(l)}function i(){t.stop()}return e.onBeforeUnmount(()=>{t.stop()}),{startRepeat:o,stopRepeat:i}}const Se={class:"zhk-candidate-list"},Me=["onClick"],ie=e.defineComponent({__name:"CandidateList",props:{candidates:{}},emits:["select"],setup(t,{emit:o}){const i=o;function a(l){i("select",l)}return(l,r)=>(e.openBlock(),e.createElementBlock("div",Se,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.candidates,(c,m)=>(e.openBlock(),e.createElementBlock("button",{key:`candidate-${m}`,class:"zhk-candidate-list__item",onClick:f=>a(m)},e.toDisplayString(c),9,Me))),128))]))}}),$e={class:"handwriting-input"},Le={class:"handwriting-buttons"},Te={class:"handwriting-canvas-container"},Re={class:"progress-bar"},De={class:"progress-text"},He=["width","height"],Ie={class:"handwriting-buttons"},Ae=e.defineComponent({__name:"HandwritingInput",props:{recognizerInitialized:{type:Boolean},recognizerProgress:{}},emits:["key","exit"],setup(t,{emit:o}){const i=t,a=o,l=e.ref(null),r=e.ref(null);let c=null;const m=e.ref(!1),{height:f}=X(r);function y(){c&&c.clearCanvas()}function h(){l.value&&(c&&c.destroy(),c=new Y(l.value,{onDrawEnd:p}))}const d=e.ref([]),{startRepeat:k,stopRepeat:u}=K();async function p(){if(!c||c.getStrokeData().length===0||m.value)return;const w=I();if(w){m.value=!0;try{const n=[...c.getStrokeData()],g=await w.recognize(n);d.value=g}catch(n){console.error("识别笔迹失败:",n)}finally{m.value=!1}}else console.warn("手写识别服务不可用")}e.onUnmounted(()=>{c&&c.destroy()}),e.watchEffect(()=>{l.value&&f.value&&i.recognizerInitialized&&e.nextTick(()=>{h()})});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(ie,{candidates:d.value,onSelect:C},null,8,["candidates"]),e.createElementVNode("div",{ref_key:"containerRef",ref:r,class:"handwriting-content"},[e.createElementVNode("div",Le,[e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[0]||(n[0]=g=>e.unref(k)(g,()=>a("key",{key:"。"}))),onPointerup:n[1]||(n[1]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointerleave:n[2]||(n[2]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointercancel:n[3]||(n[3]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onContextmenu:n[4]||(n[4]=e.withModifiers(()=>{},["prevent"]))}," 。 ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[5]||(n[5]=g=>e.unref(k)(g,()=>a("key",{key:"?"}))),onPointerup:n[6]||(n[6]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointerleave:n[7]||(n[7]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointercancel:n[8]||(n[8]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onContextmenu:n[9]||(n[9]=e.withModifiers(()=>{},["prevent"]))}," ? ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[10]||(n[10]=g=>e.unref(k)(g,()=>a("key",{key:"!"}))),onPointerup:n[11]||(n[11]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointerleave:n[12]||(n[12]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointercancel:n[13]||(n[13]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onContextmenu:n[14]||(n[14]=e.withModifiers(()=>{},["prevent"]))}," ! ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[15]||(n[15]=g=>e.unref(k)(g,()=>a("key",{key:"、"}))),onPointerup:n[16]||(n[16]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointerleave:n[17]||(n[17]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointercancel:n[18]||(n[18]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onContextmenu:n[19]||(n[19]=e.withModifiers(()=>{},["prevent"]))}," 、 ",32)]),e.createElementVNode("div",Te,[w.recognizerInitialized?(e.openBlock(),e.createElementBlock("canvas",{key:1,ref_key:"canvasRef",ref:l,class:"handwriting-canvas",width:e.unref(f),height:e.unref(f)},null,8,He)):(e.openBlock(),e.createElementBlock("div",{key:0,class:"handwriting-loading",style:e.normalizeStyle({width:`${e.unref(f)}px`,height:`${e.unref(f)}px`})},[n[37]||(n[37]=e.createElementVNode("div",{class:"loading-text"}," 正在加载手写识别... ",-1)),e.createElementVNode("div",Re,[e.createElementVNode("div",{class:"progress-fill",style:e.normalizeStyle({width:`${w.recognizerProgress*100}%`})},null,4)]),e.createElementVNode("div",De,e.toDisplayString(Math.round(w.recognizerProgress*100))+"% ",1)],4))]),e.createElementVNode("div",Ie,[e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[20]||(n[20]=g=>e.unref(k)(g,()=>a("key",{key:"delete",isControl:!0}))),onPointerup:n[21]||(n[21]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointerleave:n[22]||(n[22]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointercancel:n[23]||(n[23]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onContextmenu:n[24]||(n[24]=e.withModifiers(()=>{},["prevent"]))},n[38]||(n[38]=[e.createElementVNode("img",{src:O,alt:"删除"},null,-1)]),32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onClick:n[25]||(n[25]=g=>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]=g=>e.unref(k)(g,()=>a("key",{key:","}))),onPointerup:n[28]||(n[28]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointerleave:n[29]||(n[29]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointercancel:n[30]||(n[30]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onContextmenu:n[31]||(n[31]=e.withModifiers(()=>{},["prevent"]))}," , ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[32]||(n[32]=g=>e.unref(k)(g,()=>a("key",{key:"enter",isControl:!0}))),onPointerup:n[33]||(n[33]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointerleave:n[34]||(n[34]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onPointercancel:n[35]||(n[35]=(...g)=>e.unref(u)&&e.unref(u)(...g)),onContextmenu:n[36]||(n[36]=e.withModifiers(()=>{},["prevent"]))},n[39]||(n[39]=[e.createElementVNode("img",{src:U,alt:"回车"},null,-1)]),32)])],512)]))}}),Ke="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",Fe="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",We={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 i=o;function a(c){i("select",c)}function l(){i("close")}function r(c){const m=Array.from(c).length;return m>=2&&m<=3?2:m>=4?3:1}return(c,m)=>(e.openBlock(),e.createElementBlock("div",We,[e.createElementVNode("div",Oe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.candidates,(f,y)=>(e.openBlock(),e.createElementBlock("div",{key:y,class:e.normalizeClass(["zhk-selection__text",[`zhk-selection__text--span-${r(f)}`]]),onClick:h=>a(y)},e.toDisplayString(f),11,Ue))),128))]),e.createElementVNode("div",{class:"zhk-selection__func"},[e.createElementVNode("button",{class:"zhk-selection__func-btn",onClick:l}," 返回 ")])]))}}),ve={class:"zhk-candidate"},je={class:"zhk-candidate__container"},Xe={key:0,class:"zhk-candidate__pinyin"},Ye={class:"zhk-candidate__bottom-container"},Ge=e.defineComponent({__name:"CandidateBar",props:{modelValue:{required:!0},modelModifiers:{}},emits:e.mergeModels(["key","input"],["update:modelValue"]),setup(t,{expose:o,emit:i}){const a=i,l=e.useModel(t,"modelValue");let r=null;const c=e.ref(null),m=e.computed(()=>{var d;return((d=c.value)==null?void 0:d.candidates.map(k=>k.text))??[]}),f=e.ref(!1);e.onMounted(async()=>{if(r=J(),!r)throw new Error("未找到拼音引擎实例,请确保已正确注册引擎");l.value&&(c.value=await r.processInput(l.value))}),e.onUnmounted(()=>{r==null||r.clearInput(),r=null}),e.watch(l,async d=>{const k=r;if(k){if(d===""){k.clearInput(),c.value=null;return}c.value=await k.processInput(d)}});async function y(d){if(!r)return;const k=await r.pickCandidate(d);c.value=k,k.preeditBody||(a("input",k.committed||""),l.value="",c.value=null,f.value=!1)}o({handleSelection:y});const h=e.computed(()=>{const d=c.value;return d?d.preeditHead+d.preeditBody:""});return(d,k)=>(e.openBlock(),e.createElementBlock("div",ve,[e.createElementVNode("div",je,[h.value?(e.openBlock(),e.createElementBlock("div",Xe,e.toDisplayString(h.value),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Ye,[m.value.length>0?(e.openBlock(),e.createBlock(ie,{key:0,candidates:m.value,onSelect:y},null,8,["candidates"])):e.createCommentVNode("",!0),m.value.length>0?(e.openBlock(),e.createElementBlock("button",{key:1,class:"zhk-candidate__more",onClick:k[0]||(k[0]=u=>f.value=!0)},k[2]||(k[2]=[e.createElementVNode("img",{src:Fe,alt:"更多"},null,-1)]))):e.createCommentVNode("",!0)])]),f.value?(e.openBlock(),e.createBlock(Ze,{key:0,candidates:m.value,onSelect:y,onClose:k[1]||(k[1]=u=>f.value=!1)},null,8,["candidates"])):e.createCommentVNode("",!0)]))}}),qe={class:"zhk-base"},Je={class:"zhk-base__row"},Qe=["onPointerdown"],et=["disabled"],tt={key:1,src:Ke,class:"zhk-base__key-icon",alt:"Shift"},nt=["onPointerdown"],ot={class:"zhk-base__row"},rt={class:"zhk-base__toggle-main"},it={class:"zhk-base__toggle-sub"},st=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 i=t,a=o,l=e.useModel(t,"modelValue"),r=e.computed(()=>l.value==="en_cap"),c=e.computed(()=>l.value==="zh"),m=e.computed(()=>c.value?!0:r.value);function f(P,s=!1){a("key",{key:P,isControl:s})}function y(){c.value?l.value="hand":l.value=r.value?"en":"en_cap"}function h(){l.value="num"}function d(){l.value="symbol"}const k=["1","2","3","4","5","6","7","8","9","0"],u=[["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 g(){if(l.value==="zh"&&p.value){p.value=p.value.slice(0,-1);return}f("delete",!0)}function L(){var P;if(l.value==="zh"&&p.value){(P=C.value)==null||P.handleSelection(0);return}f(" ")}function Z(){if(l.value==="zh"&&p.value){f(p.value),p.value="";return}f("enter",!0)}function T(P){if(l.value==="zh"){p.value+=P;return}const s=r.value?P.toUpperCase():P;f(s)}function v(){l.value=l.value==="zh"?"en":"zh"}const B=e.computed(()=>i.enableHandwriting?"手写":"-"),V=e.computed(()=>!i.enableHandwriting);return(P,s)=>(e.openBlock(),e.createElementBlock("div",qe,[e.createElementVNode("div",Je,[l.value==="zh"?(e.openBlock(),e.createBlock(Ge,{key:0,ref_key:"candidateBarRef",ref:C,modelValue:p.value,"onUpdate:modelValue":s[0]||(s[0]=b=>p.value=b),onInput:s[1]||(s[1]=b=>f(b,!1))},null,8,["modelValue"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},e.renderList(k,(b,R)=>e.createElementVNode("button",{key:`number-${R}`,class:"zhk-base__key zhk-base__key--letter",onPointerdown:z=>e.unref(w)(z,()=>T(b)),onPointerup:s[2]||(s[2]=(...z)=>e.unref(n)&&e.unref(n)(...z)),onPointerleave:s[3]||(s[3]=(...z)=>e.unref(n)&&e.unref(n)(...z)),onPointercancel:s[4]||(s[4]=(...z)=>e.unref(n)&&e.unref(n)(...z)),onContextmenu:s[5]||(s[5]=e.withModifiers(()=>{},["prevent"]))},e.toDisplayString(b),41,Qe)),64))]),(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(u,(b,R)=>e.createElementVNode("div",{key:`row-${R}`,class:"zhk-base__row"},[R===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":!c.value&&r.value,"zhk-base__key--disabled":c.value&&V.value}]),disabled:c.value&&V.value,onClick:y,onContextmenu:s[6]||(s[6]=e.withModifiers(()=>{},["prevent"]))},[c.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(B.value),1)],64)):(e.openBlock(),e.createElementBlock("img",tt))],42,et)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b,(z,Rt)=>(e.openBlock(),e.createElementBlock("button",{key:`key-${R}-${Rt}`,class:"zhk-base__key zhk-base__key--letter",onPointerdown:M=>e.unref(w)(M,()=>T(z)),onPointerup:s[7]||(s[7]=(...M)=>e.unref(n)&&e.unref(n)(...M)),onPointerleave:s[8]||(s[8]=(...M)=>e.unref(n)&&e.unref(n)(...M)),onPointercancel:s[9]||(s[9]=(...M)=>e.unref(n)&&e.unref(n)(...M)),onContextmenu:s[10]||(s[10]=e.withModifiers(()=>{},["prevent"]))},e.toDisplayString(m.value?z.toUpperCase():z),41,nt))),128)),R===2?(e.openBlock(),e.createElementBlock("button",{key:1,class:"zhk-base__key zhk-base__key--function zhk-base__key--delete",onPointerdown:s[11]||(s[11]=z=>e.unref(w)(z,()=>g())),onPointerup:s[12]||(s[12]=(...z)=>e.unref(n)&&e.unref(n)(...z)),onPointerleave:s[13]||(s[13]=(...z)=>e.unref(n)&&e.unref(n)(...z)),onPointercancel:s[14]||(s[14]=(...z)=>e.unref(n)&&e.unref(n)(...z)),onContextmenu:s[15]||(s[15]=e.withModifiers(()=>{},["prevent"]))},s[39]||(s[39]=[e.createElementVNode("img",{src:O,class:"zhk-base__key-icon",alt:"Delete"},null,-1)]),32)):e.createCommentVNode("",!0)])),64)),e.createElementVNode("div",ot,[e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onClick:d,onContextmenu:s[16]||(s[16]=e.withModifiers(()=>{},["prevent"]))}," 符 ",32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onClick:h,onContextmenu:s[17]||(s[17]=e.withModifiers(()=>{},["prevent"]))}," 123 ",32),e.createElementVNode("button",{class:"zhk-base__key",onPointerdown:s[18]||(s[18]=b=>e.unref(w)(b,()=>f(","))),onPointerup:s[19]||(s[19]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointerleave:s[20]||(s[20]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointercancel:s[21]||(s[21]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onContextmenu:s[22]||(s[22]=e.withModifiers(()=>{},["prevent"]))}," , ",32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--space",onPointerdown:s[23]||(s[23]=b=>e.unref(w)(b,()=>L())),onPointerup:s[24]||(s[24]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointerleave:s[25]||(s[25]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointercancel:s[26]||(s[26]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onContextmenu:s[27]||(s[27]=e.withModifiers(()=>{},["prevent"]))},s[40]||(s[40]=[e.createElementVNode("img",{src:se,class:"zhk-base__key-icon",alt:"Space"},null,-1)]),32),e.createElementVNode("button",{class:"zhk-base__key",onPointerdown:s[28]||(s[28]=b=>e.unref(w)(b,()=>f("。"))),onPointerup:s[29]||(s[29]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointerleave:s[30]||(s[30]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointercancel:s[31]||(s[31]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onContextmenu:s[32]||(s[32]=e.withModifiers(()=>{},["prevent"]))}," 。 ",32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onClick:v,onContextmenu:s[33]||(s[33]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("span",rt,e.toDisplayString(l.value==="zh"?"中":"英"),1),e.createElementVNode("span",it,"/"+e.toDisplayString(l.value==="zh"?"英":"中"),1)],32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onPointerdown:s[34]||(s[34]=b=>e.unref(w)(b,()=>Z())),onPointerup:s[35]||(s[35]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointerleave:s[36]||(s[36]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointercancel:s[37]||(s[37]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onContextmenu:s[38]||(s[38]=e.withModifiers(()=>{},["prevent"]))},s[41]||(s[41]=[e.createElementVNode("img",{src:U,class:"zhk-base__key-icon",alt:"Enter"},null,-1)]),32)])]))}}),lt={class:"num-keyboard"},at={class:"num-keyboard__container"},dt={class:"num-keyboard__left"},ct={class:"num-keyboard__rows"},ft=["onClick","onPointerdown"],ut={key:1,src:se,class:"zhk-base__key-icon",alt:"Space"},mt={class:"num-keyboard__right"},pt=["onPointerdown"],kt=["src","alt"],gt={key:1},ht=e.defineComponent({__name:"NumericKeyboard",props:{keyboardRows:{default:()=>S().numKeys||[["1","2","3"],["4","5","6"],["7","8","9"],["back","0","space"]]}},emits:["key","exit"],setup(t,{emit:o}){const i=o,a=[{key:"delete",icon:O,text:"",alt:"Delete"},{key:".",icon:"",text:".",alt:"."},{key:"@",icon:"",text:"@",alt:"@"},{key:"enter",icon:U,text:"",alt:"Enter"}];function l(h){i("key",{key:h})}function r(h,d=!0){i("key",{key:h,isControl:d})}function c(){i("exit")}const{startRepeat:m,stopRepeat:f}=K();function y(h,d){h==="back"||(h==="space"&&(h=" "),h==="delete"||h==="enter"?m(d,()=>r(h)):m(d,()=>l(h)))}return(h,d)=>(e.openBlock(),e.createElementBlock("div",lt,[e.createElementVNode("div",at,[e.createElementVNode("div",dt,[e.createElementVNode("div",ct,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.keyboardRows,(k,u)=>(e.openBlock(),e.createElementBlock("div",{key:`row-${u}`,class:"num-keyboard__row"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k,(p,C)=>(e.openBlock(),e.createElementBlock("button",{key:`key-${u}-${C}`,class:e.normalizeClass(["num-keyboard__key",{"num-keyboard__key--back":p==="back","num-keyboard__key--space":p==="space"}]),onClick:w=>p==="back"&&c(),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",ut)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createTextVNode(e.toDisplayString(p),1)],64))],42,ft))),128))]))),128))])]),e.createElementVNode("div",mt,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(a,(k,u)=>e.createElementVNode("button",{key:`func-${u}`,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,kt)):(e.openBlock(),e.createElementBlock("span",gt,e.toDisplayString(k.text),1))],40,pt)),64))])])]))}}),yt="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",bt="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",wt={class:"symbol-keyboard"},Et={class:"symbol-keyboard__content"},Ct={class:"symbol-keyboard__functions"},zt={class:"symbol-keyboard__lang-selector"},Bt={class:"symbol-keyboard__control-group"},Vt=["src"],xt=["src"],Pt={class:"symbol-keyboard__symbols-container"},_t={class:"symbol-keyboard__symbols-grid"},Nt=["onClick","onPointerdown"],St="!@#$%^&*(){}[]<>/\\|:;\"',.?+-=_~`€£¥₹©®™°",Mt="!@#¥%…&*(){}[]<>/\|:;"',。?+-=_~·€£¥₹©®™°",$t=e.defineComponent({__name:"SymbolKeyboard",emits:["key","exit"],setup(t,{emit:o}){const i=o,a=e.ref("en"),l=e.computed(()=>a.value==="zh"?Mt:St),r=e.ref(!1),{startRepeat:c,stopRepeat:m}=K();function f(u,p){r.value&&c(p,()=>y(u))}function y(u){i("key",{key:u}),r.value||i("exit")}function h(){i("exit")}function d(u){a.value=u}function k(){r.value=!r.value}return(u,p)=>(e.openBlock(),e.createElementBlock("div",wt,[e.createElementVNode("div",Et,[e.createElementVNode("div",Ct,[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",Bt,[e.createElementVNode("button",{class:e.normalizeClass(["symbol-keyboard__key symbol-keyboard__key--function symbol-keyboard__key--lock",{"symbol-keyboard__key--locked":r.value}]),onClick:k,onContextmenu:p[4]||(p[4]=e.withModifiers(()=>{},["prevent"]))},[r.value?(e.openBlock(),e.createElementBlock("img",{key:1,src:e.unref(bt),alt:"Lock closed"},null,8,xt)):(e.openBlock(),e.createElementBlock("img",{key:0,src:e.unref(yt),alt:"Lock open"},null,8,Vt))],34),e.createElementVNode("button",{class:"symbol-keyboard__key symbol-keyboard__key--function symbol-keyboard__key--back",onClick:h,onContextmenu:p[5]||(p[5]=e.withModifiers(()=>{},["prevent"]))}," 返回 ",32)])]),e.createElementVNode("div",Pt,[e.createElementVNode("div",_t,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,(C,w)=>(e.openBlock(),e.createElementBlock("button",{key:`key-${w}`,class:"symbol-keyboard__key",onClick:n=>!r.value&&y(C),onPointerdown:n=>f(C,n),onPointerup:p[6]||(p[6]=(...n)=>e.unref(m)&&e.unref(m)(...n)),onPointerleave:p[7]||(p[7]=(...n)=>e.unref(m)&&e.unref(m)(...n)),onPointercancel:p[8]||(p[8]=(...n)=>e.unref(m)&&e.unref(m)(...n)),onContextmenu:p[9]||(p[9]=e.withModifiers(()=>{},["prevent"]))},e.toDisplayString(C),41,Nt))),128))])])])]))}}),Lt={key:0,class:"zhk__disabled-overlay"},le=e.defineComponent({__name:"ZhKeyboard",props:{defaultMode:{type:String,default:()=>S().defaultMode??"en"},enableHandwriting:{type:Boolean,default:()=>S().enableHandwriting??!1},position:{type:String,default:()=>S().position??"static"},floatMarginTop:{type:Number,default:()=>S().floatMarginTop??0},disableWhenNoFocus:{type:Boolean,default:()=>S().disableWhenNoFocus??!0},numKeys:{type:Array||void 0}},emits:["key"],setup(t,{emit:o}){const i=t,a=o,l=e.ref(i.defaultMode),r=e.ref(i.defaultMode),c=e.ref([]),m=e.ref(!1),f=e.ref(null),y=e.ref(null),{recognizerInitialized:h,recognizerProgress:d}=Ne(i.enableHandwriting);e.watch(l,(B,V)=>{B!==V&&(r.value=V)});const k=Ee(),u=e.computed(()=>k.value&&A(k.value)?k.value:null),p=e.computed(()=>i.position==="static"||!!(k.value&&A(k.value))),{height:C}=X(y);e.watchEffect(()=>{if(u.value){const B=u.value.dataset.inputmode;B&&(l.value=B)}});const w=e.computed(()=>i.disableWhenNoFocus===!1?!1:!u.value);function n(){if(!C.value)return;const B=Q(u.value,y.value,i.position,i.floatMarginTop);f.value=B}e.watchEffect(n);const g=ke(n,100);H(window,"scroll",g,{passive:!0}),H(window,"resize",g,{passive:!0});function L(B){if(B.isControl){switch(B.key){case"delete":ne(u.value);break;case"more":m.value=!0;break}return}else Z(B.key);a("key",B)}function Z(B){te(u.value,B)}function T(){l.value==="hand"?r.value="zh":["num","symbol"].includes(r.value)&&(r.value=i.defaultMode),l.value=r.value}function v(B){c.value=B}return(B,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",Lt,V[2]||(V[2]=[e.createElementVNode("span",null,"请选择输入框以启用键盘",-1)]))):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[l.value==="hand"?(e.openBlock(),e.createBlock(Ae,{key:0,"recognizer-initialized":e.unref(h),"recognizer-progress":e.unref(d),onKey:L,onExit:T,onRecognize:v},null,8,["recognizer-initialized","recognizer-progress"])):l.value==="num"?(e.openBlock(),e.createBlock(ht,{key:1,"keyboard-rows":t.numKeys,onKey:L,onExit:T},null,8,["keyboard-rows"])):l.value==="symbol"?(e.openBlock(),e.createBlock($t,{key:2,onKey:L,onExit:T})):l.value==="en"||l.value==="en_cap"||l.value==="zh"?(e.openBlock(),e.createBlock(st,{key:3,modelValue:l.value,"onUpdate:modelValue":V[0]||(V[0]=P=>l.value=P),"enable-handwriting":t.enableHandwriting,onKey:L},null,8,["modelValue","enable-handwriting"])):e.createCommentVNode("",!0)],64))],38)),[[e.vShow,p.value]])}}),Tt={install:t=>{t.component("ZhKeyboard",le)}};E.CanvasDrawer=Y,E.ZhKeyboard=le,E.calculateKeyboardPosition=Q,E.createKeyRepeater=re,E.default=Tt,E.delToInputElement=ne,E.getHandwritingRecognizer=I,E.getInputElement=xe,E.getKeyboardConfig=S,E.getPinyinEngine=J,E.isInputElement=A,E.moveCursor=oe,E.registerHandwritingRecognizer=Be,E.registerPinyinEngine=Ve,E.setKeyboardConfig=ze,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
|