UNPKG

uv-ui

Version:

基于vue3的移动端组件库

2 lines (1 loc) 1.92 kB
"use strict";const e=require("vue"),m=require("../popup/index.cjs");require("./num-input.vue_vue_type_style_index_0_lang.cjs");const v={class:"uv-num-input"},f={class:"uv-num-content"},h={class:"uv-num-content-left"},_=["onClick"],g={name:"UvNumInput"},y=Object.assign(g,{props:{show:{type:Boolean,default:!1},modelValue:{type:String,default:""},maxlength:{type:Number,default:-1},extraKey:{type:String},diyArr:{type:Array}},emits:["update:show","update:modelValue","change"],setup(r,{emit:l}){const u=r,s=e.ref(!1);e.watch(()=>u.show,t=>{s.value=t}),e.watch(()=>s.value,t=>{l("update:show",t)});const c=e.computed(()=>{const t=["1","2","3","4","5","6","7","8","9","00","0","."];return u.extraKey?(t.splice(t.length-1,1),t.push(u.extraKey),t):u.diyArr?u.diyArr:t});function i(){l("update:show",!1)}const n=e.ref([]);function d(t){if(l("change",t),u.maxlength===-1){n.value.push(t);const o=n.value.join("");l("update:modelValue",o)}else if(n.value.length<u.maxlength){n.value.push(t);const o=n.value.join("");l("update:modelValue",o)}}function p(){if(n.value.length>0){n.value.pop();const t=n.value.join("");l("update:modelValue",t)}}return(t,o)=>(e.openBlock(),e.createElementBlock("div",v,[e.createVNode(e.unref(m),{modelValue:s.value,"onUpdate:modelValue":o[0]||(o[0]=a=>s.value=a),overlay:!1,"bg-color":"#f2f3f5"},{default:e.withCtx(()=>[e.createElementVNode("div",f,[e.createElementVNode("div",h,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(c),a=>(e.openBlock(),e.createElementBlock("div",{class:"uv-num-content-left-item",onClick:V=>d(a),key:a},e.toDisplayString(a),9,_))),128))]),e.createElementVNode("div",{class:"uv-num-content-right"},[e.createElementVNode("div",{onClick:p,class:"uv-num-content-right-item"}," x "),e.createElementVNode("div",{onClick:i,class:"uv-num-content-right-item uv-num-input-confim"}," \u5B8C\u6210 ")])])]),_:1},8,["modelValue"])]))}});module.exports=y;