first commit
This commit is contained in:
1
unpackage/dist/build/mp-weixin/uni_modules/uview-plus/components/u-number-box/props.js
vendored
Normal file
1
unpackage/dist/build/mp-weixin/uni_modules/uview-plus/components/u-number-box/props.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";const e=require("../../libs/config/props.js"),o={props:{name:{type:[String,Number],default:()=>e.defProps.numberBox.name},modelValue:{type:[String,Number],default:()=>e.defProps.numberBox.value},min:{type:[String,Number],default:()=>e.defProps.numberBox.min},max:{type:[String,Number],default:()=>e.defProps.numberBox.max},step:{type:[String,Number],default:()=>e.defProps.numberBox.step},integer:{type:Boolean,default:()=>e.defProps.numberBox.integer},disabled:{type:Boolean,default:()=>e.defProps.numberBox.disabled},disabledInput:{type:Boolean,default:()=>e.defProps.numberBox.disabledInput},asyncChange:{type:Boolean,default:()=>e.defProps.numberBox.asyncChange},inputWidth:{type:[String,Number],default:()=>e.defProps.numberBox.inputWidth},showMinus:{type:Boolean,default:()=>e.defProps.numberBox.showMinus},showPlus:{type:Boolean,default:()=>e.defProps.numberBox.showPlus},decimalLength:{type:[String,Number,null],default:()=>e.defProps.numberBox.decimalLength},longPress:{type:Boolean,default:()=>e.defProps.numberBox.longPress},color:{type:String,default:()=>e.defProps.numberBox.color},buttonSize:{type:[String,Number],default:()=>e.defProps.numberBox.buttonSize},bgColor:{type:String,default:()=>e.defProps.numberBox.bgColor},cursorSpacing:{type:[String,Number],default:()=>e.defProps.numberBox.cursorSpacing},disablePlus:{type:Boolean,default:()=>e.defProps.numberBox.disablePlus},disableMinus:{type:Boolean,default:()=>e.defProps.numberBox.disableMinus},iconStyle:{type:[Object,String],default:()=>e.defProps.numberBox.iconStyle}}};exports.props=o;
|
||||
@@ -0,0 +1 @@
|
||||
"use strict";const t=require("./props.js"),i=require("../../libs/mixin/mpMixin.js"),e=require("../../libs/mixin/mixin.js"),s=require("../../libs/function/index.js"),n=require("../../../../common/vendor.js"),o={name:"u-number-box",mixins:[i.mpMixin,e.mixin,t.props],data:()=>({currentValue:"",longPressTimer:null}),watch:{watchChange(t){this.check()},modelValue:{handler:function(t,i){t!==this.currentValue&&(this.currentValue=this.format(this.modelValue))},immediate:!0}},computed:{getCursorSpacing(){return s.getPx(this.cursorSpacing)},buttonStyle(){return t=>{const i={backgroundColor:this.bgColor,height:s.addUnit(this.buttonSize),color:this.color};return this.isDisabled(t)&&(i.backgroundColor="#f7f8fa"),i}},inputStyle(){this.disabled||this.disabledInput;return{color:this.color,backgroundColor:this.bgColor,height:s.addUnit(this.buttonSize),width:s.addUnit(this.inputWidth)}},watchChange(){return[this.integer,this.decimalLength,this.min,this.max]},isDisabled(){return t=>"plus"===t?this.disabled||this.disablePlus||this.currentValue>=this.max:this.disabled||this.disableMinus||this.currentValue<=this.min}},mounted(){this.init()},emits:["update:modelValue","focus","blur","overlimit","change","plus","minus"],methods:{init(){this.currentValue=this.format(this.modelValue)},format(t){return t=""===(t=this.filter(t))?0:+t,t=Math.max(Math.min(this.max,t),this.min),null!==this.decimalLength&&(t=t.toFixed(this.decimalLength)),t},filter(t){return t=String(t).replace(/[^0-9.-]/g,""),this.integer&&-1!==t.indexOf(".")&&(t=t.split(".")[0]),t},check(){const t=this.format(this.currentValue);t!==this.currentValue&&(this.currentValue=t)},onFocus(t){this.$emit("focus",{...t.detail,name:this.name})},onBlur(t){this.format(t.detail.value),this.$emit("blur",{...t.detail,name:this.name})},onInput(t){const{value:i=""}=t.detail||{};if(""===i)return;let e=this.filter(i);if(null!==this.decimalLength&&-1!==e.indexOf(".")){const t=e.split(".");e=`${t[0]}.${t[1].slice(0,this.decimalLength)}`}return e=this.format(e),this.emitChange(e),e},emitChange(t){this.asyncChange||this.$nextTick((()=>{this.$emit("update:modelValue",t),this.currentValue=t,this.$forceUpdate()})),this.$emit("change",{value:t,name:this.name})},onChange(){const{type:t}=this;if(this.isDisabled(t))return this.$emit("overlimit",t);const i="minus"===t?-this.step:+this.step,e=this.format(this.add(+this.currentValue,i));this.emitChange(e),this.$emit(t)},add(t,i){const e=Math.pow(10,10);return Math.round((t+i)*e)/e},clickHandler(t){this.type=t,this.onChange()},longPressStep(){this.clearTimeout(),this.longPressTimer=setTimeout((()=>{this.onChange(),this.longPressStep()}),250)},onTouchStart(t){this.longPress&&(this.clearTimeout(),this.type=t,this.longPressTimer=setTimeout((()=>{this.onChange(),this.longPressStep()}),600))},onTouchEnd(){this.longPress&&this.clearTimeout()},clearTimeout(){clearTimeout(this.longPressTimer),this.longPressTimer=null}}};if(!Array){n.resolveComponent("u-icon")()}Math;const l=n._export_sfc(o,[["render",function(t,i,e,s,o,l){return n.e({a:t.showMinus&&t.$slots.minus},t.showMinus&&t.$slots.minus?{b:n.o((t=>l.clickHandler("minus"))),c:n.o((t=>l.onTouchStart("minus"))),d:n.o(((...t)=>l.clearTimeout&&l.clearTimeout(...t)))}:t.showMinus?{f:n.p({name:"minus",color:l.isDisabled("minus")?"#c8c9cc":"#323233",size:"15",bold:!0,customStyle:t.iconStyle}),g:n.o((t=>l.clickHandler("minus"))),h:n.o((t=>l.onTouchStart("minus"))),i:n.o(((...t)=>l.clearTimeout&&l.clearTimeout(...t))),j:l.isDisabled("minus")?1:"",k:n.s(l.buttonStyle("minus"))}:{},{e:t.showMinus,l:t.disabledInput||t.disabled,m:l.getCursorSpacing,n:t.disabled||t.disabledInput?1:"",o:o.currentValue,p:n.o(((...t)=>l.onBlur&&l.onBlur(...t))),q:n.o(((...t)=>l.onFocus&&l.onFocus(...t))),r:n.o(((...t)=>l.onInput&&l.onInput(...t))),s:n.s(l.inputStyle),t:t.showPlus&&t.$slots.plus},t.showPlus&&t.$slots.plus?{v:n.o((t=>l.clickHandler("plus"))),w:n.o((t=>l.onTouchStart("plus"))),x:n.o(((...t)=>l.clearTimeout&&l.clearTimeout(...t)))}:t.showPlus?{z:n.p({name:"plus",color:l.isDisabled("plus")?"#c8c9cc":"#323233",size:"15",bold:!0,customStyle:t.iconStyle}),A:n.o((t=>l.clickHandler("plus"))),B:n.o((t=>l.onTouchStart("plus"))),C:n.o(((...t)=>l.clearTimeout&&l.clearTimeout(...t))),D:l.isDisabled("plus")?1:"",E:n.s(l.buttonStyle("plus"))}:{},{y:t.showPlus})}],["__scopeId","data-v-7e4456df"]]);wx.createComponent(l);
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"u-icon": "../u-icon/u-icon"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<view class="u-number-box data-v-7e4456df"><view wx:if="{{a}}" class="u-number-box__slot cursor-pointer data-v-7e4456df" catchtap="{{b}}" bindtouchstart="{{c}}" catchtouchend="{{d}}"><slot name="minus"/></view><view wx:elif="{{e}}" catchtap="{{g}}" bindtouchstart="{{h}}" catchtouchend="{{i}}" hover-class="u-number-box__minus--hover" hover-stay-time="150" class="{{['u-number-box__minus', 'cursor-pointer', 'data-v-7e4456df', j && 'u-number-box__minus--disabled']}}" style="{{k}}"><u-icon wx:if="{{f}}" class="data-v-7e4456df" u-i="7e4456df-0" bind:__l="__l" u-p="{{f}}"></u-icon></view><block wx:if="{{$slots.input}}"><slot name="input"></slot></block><block wx:else><input disabled="{{l}}" cursor-spacing="{{m}}" class="{{[n && 'u-number-box__input--disabled', 'u-number-box__input', 'data-v-7e4456df']}}" value="{{o}}" bindblur="{{p}}" bindfocus="{{q}}" bindinput="{{r}}" type="number" style="{{s}}"/></block><view wx:if="{{t}}" class="u-number-box__slot cursor-pointer data-v-7e4456df" catchtap="{{v}}" bindtouchstart="{{w}}" catchtouchend="{{x}}"><slot name="plus"/></view><view wx:elif="{{y}}" catchtap="{{A}}" bindtouchstart="{{B}}" catchtouchend="{{C}}" hover-class="u-number-box__plus--hover" hover-stay-time="150" class="{{['u-number-box__plus', 'cursor-pointer', 'data-v-7e4456df', D && 'u-number-box__minus--disabled']}}" style="{{E}}"><u-icon wx:if="{{z}}" class="data-v-7e4456df" u-i="7e4456df-1" bind:__l="__l" u-p="{{z}}"></u-icon></view></view>
|
||||
@@ -0,0 +1 @@
|
||||
.u-empty.data-v-7e4456df,.u-empty__wrap.data-v-7e4456df,.u-tabs.data-v-7e4456df,.u-tabs__wrapper.data-v-7e4456df,.u-tabs__wrapper__scroll-view-wrapper.data-v-7e4456df,.u-tabs__wrapper__scroll-view.data-v-7e4456df,.u-tabs__wrapper__nav.data-v-7e4456df,.u-tabs__wrapper__nav__line.data-v-7e4456df{display:flex;flex-direction:column;flex-shrink:0;flex-grow:0;flex-basis:auto;align-items:stretch;align-content:flex-start}.u-number-box.data-v-7e4456df{display:flex;flex-direction:row;align-items:center}.u-number-box__slot.data-v-7e4456df{touch-action:none}.u-number-box__plus.data-v-7e4456df,.u-number-box__minus.data-v-7e4456df{width:35px;display:flex;flex-direction:row;justify-content:center;align-items:center;touch-action:none}.u-number-box__plus--hover.data-v-7e4456df,.u-number-box__minus--hover.data-v-7e4456df{background-color:#e6e6e6!important}.u-number-box__plus--disabled.data-v-7e4456df,.u-number-box__minus--disabled.data-v-7e4456df{color:#c8c9cc;background-color:#f7f8fa}.u-number-box__plus.data-v-7e4456df{border-top-right-radius:4px;border-bottom-right-radius:4px}.u-number-box__minus.data-v-7e4456df{border-top-left-radius:4px;border-bottom-left-radius:4px}.u-number-box__input.data-v-7e4456df{position:relative;text-align:center;font-size:15px;padding:0;margin:0 2px;display:flex;flex-direction:row;align-items:center;justify-content:center}.u-number-box__input--disabled.data-v-7e4456df{color:#c8c9cc;background-color:#f2f3f5}
|
||||
Reference in New Issue
Block a user