mirror of
https://gitee.com/wot-design-uni/wot-design-uni.git
synced 2025-12-06 17:18:40 +08:00
2 lines
5.2 KiB
JavaScript
2 lines
5.2 KiB
JavaScript
var e=Object.defineProperty,t=Object.defineProperties,a=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,r=(t,a,l)=>a in t?e(t,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[a]=l,d=(e,t)=>{for(var a in t||(t={}))o.call(t,a)&&r(e,a,t[a]);if(l)for(var a of l(t))s.call(t,a)&&r(e,a,t[a]);return e},n=(e,l)=>t(e,a(l));import{d as u,r as c,c as i,b as y,g as p,i as m,q as x,w as b,h as k,z as f,m as w,F as _,j as v,t as h,a5 as g,C as O,E as j,D as K,k as S,n as T}from"./index-ChV97F5w.js";import{i as P,g as I}from"./page-wraper.D9WpzC1k.js";import{c as C,d as V,a as z,w as A,_ as D,b as $,m as B}from"./base64.D3gEw_Hf.js";import{u as M}from"./useTouch.yh-0Hnfy.js";const G={type:z(""),text:V(""),wider:C(!1),large:C(!1),loading:C(!1)},E=D(u(n(d({},{name:"wd-key",options:{virtualHost:!0,addGlobalClass:!0,styleIsolation:"shared"}}),{props:G,emits:["press"],setup(e,{emit:t}){const a=e,l=t,o=M(),s=c(!1),r=i((()=>`wd-key ${a.large?"wd-key--large":""} ${"delete"===a.type?"wd-key--delete":""} ${"close"===a.type?"wd-key--close":""}`));function d(e){o.touchStart(e),s.value=!0}function n(e){o.touchMove(e),o.direction.value&&(s.value=!1)}function u(){s.value&&(s.value=!1,l("press",a.text,a.type))}return(e,t)=>{const l=m;return p(),y(l,{class:x("wd-key-wrapper "+(e.wider?"wd-key-wrapper--wider":"")),onTouchstart:d,onTouchmove:n,onTouchend:u},{default:b((()=>[k(l,{class:x(r.value)},{default:b((()=>[a.loading?(p(),y(P,{key:0,"custom-class":"wd-key__loading-icon"})):f("",!0),"delete"===e.type?(p(),w(_,{key:1},[e.text?(p(),w(_,{key:0},[v(h(e.text),1)],64)):(p(),y(A,{key:1,"custom-class":"wd-key__icon",name:"keyboard-delete",size:"22px"}))],64)):"extra"===e.type?(p(),w(_,{key:2},[e.text?(p(),w(_,{key:0},[v(h(e.text),1)],64)):(p(),y(A,{key:1,"custom-class":"wd-key__icon",name:"keyboard-collapse",size:"22px"}))],64)):(p(),w(_,{key:3},[v(h(e.text),1)],64))])),_:1},8,["class"])])),_:1},8,["class"])}}})),[["__scopeId","data-v-82fa53f0"]]),H=n(d({},$),{visible:C(!1),modelValue:z(""),title:String,mode:z("default"),zIndex:B(100),maxlength:B(1/0),showDeleteKey:C(!0),randomKeyOrder:C(!1),closeText:String,deleteText:String,closeButtonLoading:C(!1),modal:C(!1),hideOnClickOutside:C(!0),lockScroll:C(!0),safeAreaInsetBottom:C(!0),extraKey:[String,Array],rootPortal:C(!1)}),L=D(u(n(d({},{name:"wd-number-keyboard",options:{virtualHost:!0,addGlobalClass:!0,styleIsolation:"shared"}}),{props:H,emits:["update:visible","input","close","delete","update:modelValue"],setup(e,{emit:t}){const a=e,l=t,o=g(),s=c(a.visible);O((()=>a.visible),(e=>{s.value=e}));const r=i((()=>"custom"===a.mode?function(){const e=P(),t=Array.isArray(a.extraKey)?a.extraKey:[a.extraKey];1===t.length?e.push({text:0,wider:!0},{text:t[0],type:"extra"}):2===t.length&&e.push({text:t[0],type:"extra"},{text:0},{text:t[1],type:"extra"});return e}():[...P(),{text:a.extraKey,type:"extra"},{text:0},{text:a.showDeleteKey?a.deleteText:"",type:a.showDeleteKey?"delete":""}])),d=i((()=>a.closeText&&"default"===a.mode)),n=i((()=>!!a.title||!!o.title)),u=i((()=>n.value||d.value));function P(){const e=Array.from({length:9},((e,t)=>({text:t+1})));return a.randomKeyOrder?function(e){const t=[...e];for(let a=t.length-1;a>0;a--){const e=Math.floor(Math.random()*(a+1));[t[a],t[e]]=[t[e],t[a]]}return t}(e):e}const C=()=>{l("close"),l("update:visible",!1)},V=(e,t)=>{if(""===e&&"extra"===t)return C();const o=a.modelValue;"delete"===t?(l("delete"),l("update:modelValue",o.slice(0,o.length-1))):"close"===t?C():o.length<+a.maxlength&&(l("input",e),l("update:modelValue",o+e))};return(e,t)=>{const a=S,l=m;return p(),y(I,{modelValue:s.value,"onUpdate:modelValue":t[0]||(t[0]=e=>s.value=e),position:"bottom","z-index":e.zIndex,"safe-area-inset-bottom":e.safeAreaInsetBottom,"modal-style":e.modal?"":"opacity: 0;",modal:e.hideOnClickOutside,lockScroll:e.lockScroll,"root-portal":e.rootPortal,onClickModal:C},{default:b((()=>[k(l,{class:x(`wd-number-keyboard ${e.customClass}`),style:j(e.customStyle)},{default:b((()=>[u.value?(p(),y(l,{key:0,class:"wd-number-keyboard__header"},{default:b((()=>[n.value?K(e.$slots,"title",{key:0},(()=>[k(a,{class:"wd-number-keyboard__title"},{default:b((()=>[v(h(e.title),1)])),_:1})]),!0):f("",!0),d.value?(p(),y(l,{key:1,class:"wd-number-keyboard__close","hover-class":"wd-number-keyboard__close--hover",onClick:C},{default:b((()=>[k(a,null,{default:b((()=>[v(h(e.closeText),1)])),_:1})])),_:1})):f("",!0)])),_:3})):f("",!0),k(l,{class:"wd-number-keyboard__body"},{default:b((()=>[k(l,{class:"wd-number-keyboard__keys"},{default:b((()=>[(p(!0),w(_,null,T(r.value,(e=>(p(),y(E,{key:e.text,text:e.text,type:e.type,wider:e.wider,onPress:V},null,8,["text","type","wider"])))),128))])),_:1}),"custom"===e.mode?(p(),y(l,{key:0,class:"wd-number-keyboard__sidebar"},{default:b((()=>[e.showDeleteKey?(p(),y(E,{key:0,large:"",text:e.deleteText,type:"delete",onPress:V},null,8,["text"])):f("",!0),k(E,{large:"",text:e.closeText,type:"close",loading:e.closeButtonLoading,onPress:V},null,8,["text","loading"])])),_:1})):f("",!0)])),_:1})])),_:3},8,["class","style"])])),_:3},8,["modelValue","z-index","safe-area-inset-bottom","modal-style","modal","lockScroll","root-portal"])}}})),[["__scopeId","data-v-a1ee65a2"]]);export{L as _};
|