[build] 0.5.0-beta2

This commit is contained in:
陈嘉涵 2018-12-28 13:45:26 +08:00
parent a3d4702b78
commit bffb7a066f
5 changed files with 69 additions and 67 deletions

View File

@ -20,8 +20,8 @@
> >
<van-loading <van-loading
wx:if="{{ loading }}" wx:if="{{ loading }}"
size="20px"
custom-class="loading-class" custom-class="loading-class"
size="{{ size === 'mini' ? '14px' : '20px' }}"
color="{{ type === 'default' ? '#c9c9c9' : '' }}" color="{{ type === 'default' ? '#c9c9c9' : '' }}"
/> />
<slot wx:else /> <slot wx:else />

View File

@ -2,14 +2,45 @@ import { VantComponent } from '../common/component';
import { isDef } from '../common/utils'; import { isDef } from '../common/utils';
var currentYear = new Date().getFullYear(); var currentYear = new Date().getFullYear();
var isValidDate = function isValidDate(date) { function isValidDate(date) {
return isDef(date) && !isNaN(new Date(date).getTime()); return isDef(date) && !isNaN(new Date(date).getTime());
}; }
;
function range(num, min, max) { function range(num, min, max) {
return Math.min(Math.max(num, min), max); return Math.min(Math.max(num, min), max);
} }
function padZero(val) {
return ("00" + val).slice(-2);
}
function times(n, iteratee) {
var index = -1;
var result = Array(n);
while (++index < n) {
result[index] = iteratee(index);
}
return result;
}
function getTrueValue(formattedValue) {
if (!formattedValue) return;
while (isNaN(parseInt(formattedValue, 10))) {
formattedValue = formattedValue.slice(1);
}
return parseInt(formattedValue, 10);
}
function getMonthEndDay(year, month) {
return 32 - new Date(year, month - 1, 32).getDate();
}
VantComponent({ VantComponent({
props: { props: {
value: null, value: null,
@ -70,18 +101,14 @@ VantComponent({
}, },
computed: { computed: {
columns: function columns() { columns: function columns() {
var _this = this;
var results = this.getRanges().map(function (_ref) { var results = this.getRanges().map(function (_ref) {
var type = _ref.type, var type = _ref.type,
range = _ref.range; range = _ref.range;
var values = times(range[1] - range[0] + 1, function (index) {
var values = _this.times(range[1] - range[0] + 1, function (index) {
var value = range[0] + index; var value = range[0] + index;
value = type === 'year' ? "" + value : _this.pad(value); value = type === 'year' ? "" + value : padZero(value);
return value; return value;
}); });
return values; return values;
}); });
return results; return results;
@ -89,7 +116,7 @@ VantComponent({
}, },
watch: { watch: {
value: function value(val) { value: function value(val) {
var _this2 = this; var _this = this;
var data = this.data; var data = this.data;
val = this.correctValue(val); val = this.correctValue(val);
@ -99,9 +126,9 @@ VantComponent({
this.set({ this.set({
innerValue: val innerValue: val
}, function () { }, function () {
_this2.updateColumnValue(val); _this.updateColumnValue(val);
_this2.$emit('input', val); _this.$emit('input', val);
}); });
} }
} }
@ -154,12 +181,8 @@ VantComponent({
if (data.type === 'year-month') result.splice(2, 3); if (data.type === 'year-month') result.splice(2, 3);
return result; return result;
}, },
pad: function pad(val) {
return ("00" + val).slice(-2);
},
correctValue: function correctValue(value) { correctValue: function correctValue(value) {
var data = this.data, var data = this.data; // validate value
pad = this.pad; // validate value
var isDateType = data.type !== 'time'; var isDateType = data.type !== 'time';
@ -167,7 +190,7 @@ VantComponent({
value = data.minDate; value = data.minDate;
} else if (!isDateType && !value) { } else if (!isDateType && !value) {
var minHour = data.minHour; var minHour = data.minHour;
value = pad(minHour) + ":00"; value = padZero(minHour) + ":00";
} // time type } // time type
@ -176,8 +199,8 @@ VantComponent({
hour = _value$split[0], hour = _value$split[0],
minute = _value$split[1]; minute = _value$split[1];
hour = pad(range(hour, data.minHour, data.maxHour)); hour = padZero(range(hour, data.minHour, data.maxHour));
minute = pad(range(minute, data.minMinute, data.maxMinute)); minute = padZero(range(minute, data.minMinute, data.maxMinute));
return hour + ":" + minute; return hour + ":" + minute;
} // date type } // date type
@ -186,16 +209,6 @@ VantComponent({
value = Math.min(value, data.maxDate); value = Math.min(value, data.maxDate);
return value; return value;
}, },
times: function times(n, iteratee) {
var index = -1;
var result = Array(n);
while (++index < n) {
result[index] = iteratee(index);
}
return result;
},
getBoundary: function getBoundary(type, innerValue) { getBoundary: function getBoundary(type, innerValue) {
var value = new Date(innerValue); var value = new Date(innerValue);
var boundary = new Date(this.data[type + "Date"]); var boundary = new Date(this.data[type + "Date"]);
@ -207,7 +220,7 @@ VantComponent({
if (type === 'max') { if (type === 'max') {
month = 12; month = 12;
date = this.getMonthEndDay(value.getFullYear(), value.getMonth() + 1); date = getMonthEndDay(value.getFullYear(), value.getMonth() + 1);
hour = 23; hour = 23;
minute = 59; minute = 59;
} }
@ -236,18 +249,6 @@ VantComponent({
[type + "Minute"]: minute [type + "Minute"]: minute
}; };
}, },
getTrueValue: function getTrueValue(formattedValue) {
if (!formattedValue) return;
while (isNaN(parseInt(formattedValue, 10))) {
formattedValue = formattedValue.slice(1);
}
return parseInt(formattedValue, 10);
},
getMonthEndDay: function getMonthEndDay(year, month) {
return 32 - new Date(year, month - 1, 32).getDate();
},
onCancel: function onCancel() { onCancel: function onCancel() {
this.$emit('cancel'); this.$emit('cancel');
}, },
@ -255,7 +256,7 @@ VantComponent({
this.$emit('confirm', this.data.innerValue); this.$emit('confirm', this.data.innerValue);
}, },
onChange: function onChange(event) { onChange: function onChange(event) {
var _this3 = this; var _this2 = this;
var data = this.data; var data = this.data;
var pickerValue = event.detail.value; var pickerValue = event.detail.value;
@ -267,10 +268,10 @@ VantComponent({
if (data.type === 'time') { if (data.type === 'time') {
value = values.join(':'); value = values.join(':');
} else { } else {
var year = this.getTrueValue(values[0]); var year = getTrueValue(values[0]);
var month = this.getTrueValue(values[1]); var month = getTrueValue(values[1]);
var maxDate = this.getMonthEndDay(year, month); var maxDate = getMonthEndDay(year, month);
var date = this.getTrueValue(values[2]); var date = getTrueValue(values[2]);
if (data.type === 'year-month') { if (data.type === 'year-month') {
date = 1; date = 1;
@ -281,8 +282,8 @@ VantComponent({
var minute = 0; var minute = 0;
if (data.type === 'datetime') { if (data.type === 'datetime') {
hour = this.getTrueValue(values[3]); hour = getTrueValue(values[3]);
minute = this.getTrueValue(values[4]); minute = getTrueValue(values[4]);
} }
value = new Date(year, month - 1, date, hour, minute); value = new Date(year, month - 1, date, hour, minute);
@ -292,11 +293,11 @@ VantComponent({
this.set({ this.set({
innerValue: value innerValue: value
}, function () { }, function () {
_this3.updateColumnValue(value); _this2.updateColumnValue(value);
_this3.$emit('input', value); _this2.$emit('input', value);
_this3.$emit('change', _this3); _this2.$emit('change', _this2);
}); });
}, },
getColumnValue: function getColumnValue(index) { getColumnValue: function getColumnValue(index) {
@ -339,8 +340,7 @@ VantComponent({
}, },
updateColumnValue: function updateColumnValue(value) { updateColumnValue: function updateColumnValue(value) {
var values = []; var values = [];
var pad = this.pad, var data = this.data;
data = this.data;
var columns = data.columns; var columns = data.columns;
if (data.type === 'time') { if (data.type === 'time') {
@ -348,14 +348,14 @@ VantComponent({
values = [columns[0].indexOf(currentValue[0]), columns[1].indexOf(currentValue[1])]; values = [columns[0].indexOf(currentValue[0]), columns[1].indexOf(currentValue[1])];
} else { } else {
var date = new Date(value); var date = new Date(value);
values = [columns[0].indexOf("" + date.getFullYear()), columns[1].indexOf(pad(date.getMonth() + 1))]; values = [columns[0].indexOf("" + date.getFullYear()), columns[1].indexOf(padZero(date.getMonth() + 1))];
if (data.type === 'date') { if (data.type === 'date') {
values.push(columns[2].indexOf(pad(date.getDate()))); values.push(columns[2].indexOf(padZero(date.getDate())));
} }
if (data.type === 'datetime') { if (data.type === 'datetime') {
values.push(columns[2].indexOf(pad(date.getDate())), columns[3].indexOf(pad(date.getHours())), columns[4].indexOf(pad(date.getMinutes()))); values.push(columns[2].indexOf(padZero(date.getDate())), columns[3].indexOf(padZero(date.getHours())), columns[4].indexOf(padZero(date.getMinutes())));
} }
} }
@ -365,15 +365,15 @@ VantComponent({
} }
}, },
created: function created() { created: function created() {
var _this4 = this; var _this3 = this;
var innerValue = this.correctValue(this.data.value); var innerValue = this.correctValue(this.data.value);
this.set({ this.set({
innerValue: innerValue innerValue: innerValue
}, function () { }, function () {
_this4.updateColumnValue(innerValue); _this3.updateColumnValue(innerValue);
_this4.$emit('input', innerValue); _this3.$emit('input', innerValue);
}); });
} }
}); });

View File

@ -1 +1 @@
@import '../common/index.wxss';.van-goods-action-icon{width:50px!important;border:none!important}.van-goods-action-icon__content{height:100%;display:-webkit-flex;display:flex;line-height:1;font-size:10px;color:#7d7e80;-webkit-flex-direction:column;flex-direction:column;-webkit-justify-content:center;justify-content:center}.van-goods-action-icon__icon{margin-bottom:5px} @import '../common/index.wxss';.van-goods-action-icon{width:50px!important;border:none!important}.van-goods-action-icon__content{height:100%;display:-webkit-flex;display:flex;line-height:1;font-size:10px;color:#7d7e80;-webkit-flex-direction:column;flex-direction:column;-webkit-justify-content:center;justify-content:center}.van-goods-action-icon__icon{margin-bottom:4px}

View File

@ -1 +1 @@
@import '../common/index.wxss';.van-loading{z-index:0;font-size:0;line-height:0;position:relative;display:inline-block;vertical-align:middle}.van-loading__spinner{z-index:-1;width:100%;height:100%;position:relative;display:inline-block;box-sizing:border-box;-webkit-animation:van-rotate .8s linear infinite;animation:van-rotate .8s linear infinite}.van-loading__spinner--spinner{-webkit-animation-timing-function:steps(12);animation-timing-function:steps(12)}.van-loading__spinner--circular{border:1px solid;border-radius:100%;border-color:currentColor;border-top-color:transparent}.van-loading__dot{top:0;left:0;width:100%;height:100%;position:absolute}.van-loading__dot::before{width:2px;height:25%;content:' ';display:block;margin:0 auto;border-radius:40%;background-color:currentColor}.van-loading__dot:nth-of-type(1){opacity:1;-webkit-transform:rotate(30deg);transform:rotate(30deg)}.van-loading__dot:nth-of-type(2){opacity:.9375;-webkit-transform:rotate(60deg);transform:rotate(60deg)}.van-loading__dot:nth-of-type(3){opacity:.875;-webkit-transform:rotate(90deg);transform:rotate(90deg)}.van-loading__dot:nth-of-type(4){opacity:.8125;-webkit-transform:rotate(120deg);transform:rotate(120deg)}.van-loading__dot:nth-of-type(5){opacity:.75;-webkit-transform:rotate(150deg);transform:rotate(150deg)}.van-loading__dot:nth-of-type(6){opacity:.6875;-webkit-transform:rotate(180deg);transform:rotate(180deg)}.van-loading__dot:nth-of-type(7){opacity:.625;-webkit-transform:rotate(210deg);transform:rotate(210deg)}.van-loading__dot:nth-of-type(8){opacity:.5625;-webkit-transform:rotate(240deg);transform:rotate(240deg)}.van-loading__dot:nth-of-type(9){opacity:.5;-webkit-transform:rotate(270deg);transform:rotate(270deg)}.van-loading__dot:nth-of-type(10){opacity:.4375;-webkit-transform:rotate(300deg);transform:rotate(300deg)}.van-loading__dot:nth-of-type(11){opacity:.375;-webkit-transform:rotate(330deg);transform:rotate(330deg)}.van-loading__dot:nth-of-type(12){opacity:.3125;-webkit-transform:rotate(360deg);transform:rotate(360deg)}@-webkit-keyframes van-rotate{from{-webkit-transform:rotate(0);transform:rotate(0)}to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes van-rotate{from{-webkit-transform:rotate(0);transform:rotate(0)}to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}} @import '../common/index.wxss';.van-loading{z-index:0;line-height:0;position:relative;display:inline-block;vertical-align:middle}.van-loading__spinner{z-index:-1;width:100%;height:100%;position:relative;display:inline-block;box-sizing:border-box;-webkit-animation:van-rotate .8s linear infinite;animation:van-rotate .8s linear infinite}.van-loading__spinner--spinner{-webkit-animation-timing-function:steps(12);animation-timing-function:steps(12)}.van-loading__spinner--circular{border:1px solid;border-radius:100%;border-color:transparent;border-top-color:currentColor}.van-loading__dot{top:0;left:0;width:100%;height:100%;position:absolute}.van-loading__dot::before{width:2px;height:25%;content:' ';display:block;margin:0 auto;border-radius:40%;background-color:currentColor}.van-loading__dot:nth-of-type(1){opacity:1;-webkit-transform:rotate(30deg);transform:rotate(30deg)}.van-loading__dot:nth-of-type(2){opacity:.9375;-webkit-transform:rotate(60deg);transform:rotate(60deg)}.van-loading__dot:nth-of-type(3){opacity:.875;-webkit-transform:rotate(90deg);transform:rotate(90deg)}.van-loading__dot:nth-of-type(4){opacity:.8125;-webkit-transform:rotate(120deg);transform:rotate(120deg)}.van-loading__dot:nth-of-type(5){opacity:.75;-webkit-transform:rotate(150deg);transform:rotate(150deg)}.van-loading__dot:nth-of-type(6){opacity:.6875;-webkit-transform:rotate(180deg);transform:rotate(180deg)}.van-loading__dot:nth-of-type(7){opacity:.625;-webkit-transform:rotate(210deg);transform:rotate(210deg)}.van-loading__dot:nth-of-type(8){opacity:.5625;-webkit-transform:rotate(240deg);transform:rotate(240deg)}.van-loading__dot:nth-of-type(9){opacity:.5;-webkit-transform:rotate(270deg);transform:rotate(270deg)}.van-loading__dot:nth-of-type(10){opacity:.4375;-webkit-transform:rotate(300deg);transform:rotate(300deg)}.van-loading__dot:nth-of-type(11){opacity:.375;-webkit-transform:rotate(330deg);transform:rotate(330deg)}.van-loading__dot:nth-of-type(12){opacity:.3125;-webkit-transform:rotate(360deg);transform:rotate(360deg)}@-webkit-keyframes van-rotate{from{-webkit-transform:rotate(0);transform:rotate(0)}to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes van-rotate{from{-webkit-transform:rotate(0);transform:rotate(0)}to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}

10
dist/stepper/index.js vendored
View File

@ -6,7 +6,7 @@ VantComponent({
field: true, field: true,
classes: ['input-class', 'plus-class', 'minus-class'], classes: ['input-class', 'plus-class', 'minus-class'],
props: { props: {
value: Number, value: null,
integer: Boolean, integer: Boolean,
disabled: Boolean, disabled: Boolean,
asyncChange: Boolean, asyncChange: Boolean,
@ -34,9 +34,11 @@ VantComponent({
}, },
watch: { watch: {
value: function value(_value) { value: function value(_value) {
this.set({ if (_value !== '') {
value: this.range(_value) this.set({
}); value: this.range(_value)
});
}
} }
}, },
data: { data: {