Skip to content

Commit

Permalink
Merge branch 'v2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Franslee committed Apr 22, 2019
2 parents 3c9e7a5 + 5da4613 commit 2e8e67f
Show file tree
Hide file tree
Showing 21 changed files with 449 additions and 31 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 2.1.1

`2019-4-22`

* :sparkles: feat: 新增文本框组件`TextInput`
* :sparkles: chore: 优化单元测试配置
* :sparkles: upd: `Stepper`组件新增支持小数
* :bug: fix: 修复`CountDown`组件在iOS上某些场景下的一个问题
* :bug: fix: 修复`Scroller`内部元素无法触发点击事件的问题
* :bug: fix: 修复国际化语言包一处错误

## 2.1.0

`2019-4-15`
Expand Down
4 changes: 3 additions & 1 deletion build/webpack.test.conf.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

const path = require('path');
const prodConf = require('./webpack.prod.conf.js');
const merge = require('webpack-merge');

Expand All @@ -11,7 +12,8 @@ module.exports = merge(prodConf, {
use: {
loader: 'istanbul-instrumenter-loader',
options: { esModules: true }
}
},
include: path.resolve(__dirname, '../src/packages/')
},
{
test: /\.css$/,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nutui/nutui",
"version": "2.1.0",
"version": "2.1.1",
"description": "一套轻量级移动端Vue组件库",
"typings": "dist/types/index.d.ts",
"main": "dist/nutui.js",
Expand Down
10 changes: 10 additions & 0 deletions src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,16 @@
"sort": "5",
"showDemo": true,
"author": "林如风"
},
{
"version": "1.0.0",
"name": "TextInput",
"chnName": "文本框",
"desc": "单行文本框",
"type": "component",
"sort": "1",
"showDemo": true,
"author": "Frans"
}
]
}
5 changes: 4 additions & 1 deletion src/nutui.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ import InfiniteLoading from './packages/infiniteloading/index.js';
import './packages/infiniteloading/infiniteloading.scss';
import Uploader from "./packages/uploader/index.js";
import "./packages/uploader/uploader.scss";
import TextInput from "./packages/textinput/index.js";
import "./packages/textinput/textinput.scss";

const packages = {
Cell,
Expand Down Expand Up @@ -128,7 +130,8 @@ const packages = {
BackTop,
CountDown,
InfiniteLoading,
Uploader
Uploader,
TextInput
};

const components = {};
Expand Down
2 changes: 1 addition & 1 deletion src/packages/calendar/calendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="nut-calendar" v-show="isVisible">
<div class="nut-calendar-control">
<span class="nut-calendar-confirm-btn" @click="confirm" v-if="(type == 'range' && currDate && currDate.length == 2) || type != 'range'">{{nutTranslate('lang.okBtnTxt')}}</span>
<span class="nut-calendar-cancel-btn" @click="closeActionSheet">{{nutTranslate('lang.cancelText')}}</span>
<span class="nut-calendar-cancel-btn" @click="closeActionSheet">{{nutTranslate('lang.cancelBtnTxt')}}</span>
<div class="nut-calendar-title">{{title || nutTranslate('lang.calendar.title')}}</div>
<div class="nut-calendar-week">
<span v-for="(item, index) of week" :key="index">{{item}}</span>
Expand Down
30 changes: 23 additions & 7 deletions src/packages/countdown/countdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,19 @@ const countdownTimer = {
startTime: {
// 可以是服务器当前时间
default: Date.now(),
type: [Number, String]
type: [Number, String],
validator(v) {
const dateStr = (new Date(v)).toString().toLowerCase();
return dateStr !== 'invalid date';
}
},
endTime: {
default: Date.now(),
type: [Number, String]
type: [Number, String],
validator(v) {
const dateStr = (new Date(v)).toString().toLowerCase();
return dateStr !== 'invalid date';
}
}
},
computed: {
Expand All @@ -111,24 +119,32 @@ const countdownTimer = {
watch: {
paused(v, ov) {
if(!ov) {
this._curr = Date.now();
this._curr = this.getTimeStamp();
}else{
this.p += (Date.now() - this._curr);
this.p += (this.getTimeStamp() - this._curr);
}
}
},
methods: {
getTimeStamp(timeStr) {
if(!timeStr) return Date.now();
let t = timeStr;
t = t > 0? +t: t.toString().replace(/\-/g, '/');
return new Date(t).getTime();
}
},
created() {
if(this.interval > 0) {
let _start = 0;
const curr = Date.now();
const start = new Date(+this.startTime).getTime();
const end = new Date(+this.endTime).getTime();
const start = this.getTimeStamp(this.startTime);
const end = this.getTimeStamp(this.endTime);
const diffTime = curr - start;
this.restTime = end - (start + diffTime);
this.timer = setInterval(() => {
if(!this.paused) {
let restTime = end - (new Date().getTime() - this.p + diffTime);
let restTime = end - (this.getTimeStamp() - this.p + diffTime);
restTime -= 1000;
this.restTime = restTime;
if(restTime < 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/packages/countdown/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
export default {
data() {
return {
serverTime: 1551943874069,
end: 1559334689373,
serverTime: Date.now() - 30 * 1000,
end: Date.now() + 2 * 60 * 60 * 1000,
paused: false
};
},
Expand Down
2 changes: 1 addition & 1 deletion src/packages/picker/picker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<nut-actionsheet :is-visible="isVisible" @close="closeActionSheet">
<div class="nut-picker" slot="custom" :class="customClassName ? customClassName : null">
<div class="nut-picker-control">
<span class="nut-picker-confirm-btn" @click="closeActionSheet">{{nutTranslate('lang.cancelText')}}</span>
<span class="nut-picker-confirm-btn" @click="closeActionSheet">{{nutTranslate('lang.cancelBtnTxt')}}</span>
<div class="nut-picker-title">{{title ? title : ''}}</div>
<span class="nut-picker-cancel-btn" @click="confirm">{{nutTranslate('lang.okBtnTxt')}}</span>
</div>
Expand Down
1 change: 0 additions & 1 deletion src/packages/row/row.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export default {
mounted() {
let slot = [...this.$slots.default];
this.initCol(slot);
console.log(slot);
},
}
</script>
2 changes: 1 addition & 1 deletion src/packages/scroller/horizontal-scroll.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default {
},
touchStart(event) {
event.preventDefault();
// event.preventDefault();
let changedTouches = event.changedTouches[0];
this.touchParams.startX = changedTouches.pageX;
Expand Down
5 changes: 3 additions & 2 deletions src/packages/scroller/vertical-scroll.vue
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export default {
},
touchStart(event) {
event.preventDefault();
// event.preventDefault();
let changedTouches = event.changedTouches[0];
this.touchParams.startY = changedTouches.pageY;
Expand All @@ -167,6 +167,7 @@ export default {
},
touchMove(event) {
event.preventDefault();
let changedTouches = event.changedTouches[0];
this.touchParams.lastY = changedTouches.pageY;
Expand All @@ -179,7 +180,7 @@ export default {
},
touchEnd(event) {
event.preventDefault();
// event.preventDefault();
let changedTouches = event.changedTouches[0];
this.touchParams.lastY = changedTouches.pageY;
Expand Down
6 changes: 3 additions & 3 deletions src/packages/stepper/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div>
<nut-cell>
<span slot="title">
<nut-stepper @focus="focus" :blur="blur" :value.sync="val1" :max="12"></nut-stepper>
<nut-stepper @focus="focus" :blur="blur" :value.sync="val1" :max="12" :step="0.1" :decimalPlaces="1" @add="add"></nut-stepper>
</span>
<span slot="desc">
value: {{val1}} <button @click="reduce" class="demo-btn">-</button> <button @click="add" class="demo-btn">+</button>
Expand Down Expand Up @@ -59,7 +59,7 @@
export default {
data() {
return {
val1: 0,
val1: 1,
val2: 12,
val3: 5,
val4: 0,
Expand All @@ -76,7 +76,7 @@ export default {
},
add(v) {
console.log(v)
this.val1 = Number(this.val1) + 1;
// this.val1 = Number(this.val1) + 1;
},
reduce() {
this.val1 = Math.max(Number(this.val1) - 1, 0);
Expand Down
1 change: 1 addition & 0 deletions src/packages/stepper/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
| readonly | 是否只读 | Boolean | false
| transition | 是否需要过渡效果 | Boolean | true
| simple | 是否显示简单版 | Boolean | true
| decimalPlaces | 设置保留的小数位 | Number | 0

## Event

Expand Down
31 changes: 21 additions & 10 deletions src/packages/stepper/stepper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ export default {
value: {
type: [String, Number],
required: true
}
},
decimalPlaces: {
type: Number,
default: 0
}
},
data() {
return {
Expand All @@ -105,11 +109,14 @@ export default {
}
},
watch: {
value(v, ov) {
if(v > this.max) v = this.max;
if(v < this.minNum) v = this.minNum;
this.num = v;
this.$emit('change', this.num);
value: {
handler(v, ov) {
if(v > this.max) v = this.max;
if(v < this.minNum) v = this.minNum;
this.num = v > 0? this.fixedDecimalPlaces(v): v;
this.$emit('change', this.num);
},
immediate: true
}
},
computed: {
Expand Down Expand Up @@ -161,12 +168,16 @@ export default {
this.$emit('update:value', this.num);
this.$emit('change', this.num);
},
fixedDecimalPlaces(v) {
return Number(v).toFixed(this.decimalPlaces);
// .replace(/(\d+\.[^0]*)0+$/, '$1').replace(/\.$/, '')
},
add() {
this.num = Number(this.num);
if(this.num <= this.max - this.step && this.max > this.minNum) {
let [n1, n2] = this.num.toString().split('.');
let [n1, n2] = this.fixedDecimalPlaces(this.num + Number(this.step)).split('.');
let fixedLen = n2? n2.length: 0;
this.num = parseFloat((Number(n1) + Number(this.step)) + (n2? '.'+n2: '')).toFixed(fixedLen);
this.num = parseFloat(n1 + (n2? '.'+n2: '')).toFixed(fixedLen);
if(this.transition) {
this.showNum = false;
this.showAddAnim = true;
Expand All @@ -192,9 +203,9 @@ export default {
},
reduce(){
if(this.num - this.step >= this.minNum) {
let [n1, n2] = this.num.toString().split('.');
let [n1, n2] = this.fixedDecimalPlaces(this.num - Number(this.step)).split('.');
let fixedLen = n2? n2.length: 0;
this.num = parseFloat((Number(n1) - this.step) + (n2? '.'+n2: '')).toFixed(fixedLen);
this.num = parseFloat(n1 + (n2? '.'+n2: '')).toFixed(fixedLen);
if(this.transition) {
this.showNum = false;
this.showAddAnim = false;
Expand Down
Loading

0 comments on commit 2e8e67f

Please sign in to comment.