From fa5458ba31074bbc0239362ac7f5695da015d869 Mon Sep 17 00:00:00 2001 From: rex-zsd Date: Tue, 30 Jul 2019 20:29:34 +0800 Subject: [PATCH] [build] 0.5.17 --- dist/collapse-item/index.js | 8 +++----- dist/datetime-picker/index.js | 5 +++-- dist/dialog/dialog.d.ts | 1 + dist/dialog/dialog.js | 1 + dist/dialog/index.js | 1 + dist/dialog/index.wxml | 1 + dist/dialog/index.wxss | 2 +- dist/mixins/basic.js | 4 ++-- dist/mixins/observer/behavior.js | 4 ++-- dist/mixins/observer/props.js | 4 ++-- dist/picker-column/index.js | 4 +--- dist/picker-column/index.wxml | 13 ++----------- dist/picker-column/index.wxs | 8 ++++++++ dist/picker/index.js | 6 +++--- dist/search/index.js | 12 +++++++++--- lib/collapse-item/index.js | 8 +++----- lib/datetime-picker/index.js | 5 +++-- lib/dialog/dialog.js | 1 + lib/dialog/index.js | 1 + lib/dialog/index.wxml | 1 + lib/dialog/index.wxss | 2 +- lib/mixins/basic.js | 6 +++++- lib/mixins/observer/behavior.js | 4 ++-- lib/mixins/observer/props.js | 6 +++++- lib/picker-column/index.js | 4 +--- lib/picker-column/index.wxml | 13 ++----------- lib/picker-column/index.wxs | 8 ++++++++ lib/picker/index.js | 6 +++--- lib/search/index.js | 13 ++++++++++--- 29 files changed, 86 insertions(+), 66 deletions(-) create mode 100644 dist/picker-column/index.wxs create mode 100644 lib/picker-column/index.wxs diff --git a/dist/collapse-item/index.js b/dist/collapse-item/index.js index a1cad543..592dfbb9 100644 --- a/dist/collapse-item/index.js +++ b/dist/collapse-item/index.js @@ -67,11 +67,9 @@ VantComponent({ contentHeight: height ? `${height}px` : 'auto' }); } - else { - return this.set({ contentHeight: `${height}px` }) - .then(nextTick) - .then(() => this.set({ contentHeight: 0 })); - } + return this.set({ contentHeight: `${height}px` }) + .then(nextTick) + .then(() => this.set({ contentHeight: 0 })); }); }, onClick() { diff --git a/dist/datetime-picker/index.js b/dist/datetime-picker/index.js index a79a973f..e615f1b0 100644 --- a/dist/datetime-picker/index.js +++ b/dist/datetime-picker/index.js @@ -91,7 +91,8 @@ VantComponent({ }, getPicker() { if (this.picker == null) { - const picker = (this.picker = this.selectComponent('.van-datetime-picker')); + this.picker = this.selectComponent('.van-datetime-picker'); + const { picker } = this; const { setColumnValues } = picker; picker.setColumnValues = (...args) => setColumnValues.apply(picker, [...args, false]); } @@ -99,7 +100,7 @@ VantComponent({ }, updateColumns() { const { formatter = defaultFormatter } = this.data; - const results = this.getRanges().map(({ type, range }, index) => { + const results = this.getRanges().map(({ type, range }) => { const values = times(range[1] - range[0] + 1, index => { let value = range[0] + index; value = type === 'year' ? `${value}` : padZero(value); diff --git a/dist/dialog/dialog.d.ts b/dist/dialog/dialog.d.ts index ca52f88a..fef2da6c 100644 --- a/dist/dialog/dialog.d.ts +++ b/dist/dialog/dialog.d.ts @@ -10,6 +10,7 @@ declare type DialogOptions = { selector?: string; ariaLabel?: string; className?: string; + customStyle?: string; transition?: string; asyncClose?: boolean; businessId?: number; diff --git a/dist/dialog/dialog.js b/dist/dialog/dialog.js index 68acc1af..875701ef 100644 --- a/dist/dialog/dialog.js +++ b/dist/dialog/dialog.js @@ -25,6 +25,7 @@ Dialog.defaultOptions = { zIndex: 100, overlay: true, className: '', + customStyle: '', asyncClose: false, messageAlign: '', transition: 'scale', diff --git a/dist/dialog/index.js b/dist/dialog/index.js index 269f7f4b..bbbbff23 100644 --- a/dist/dialog/index.js +++ b/dist/dialog/index.js @@ -9,6 +9,7 @@ VantComponent({ message: String, useSlot: Boolean, className: String, + customStyle: String, asyncClose: Boolean, messageAlign: String, showCancelButton: Boolean, diff --git a/dist/dialog/index.wxml b/dist/dialog/index.wxml index 6c9dac42..13a77d16 100644 --- a/dist/dialog/index.wxml +++ b/dist/dialog/index.wxml @@ -4,6 +4,7 @@ overlay="{{ overlay }}" custom-class="van-dialog {{ className }}" transition="{{ transition }}" + custom-style="{{ customStyle }}" close-on-click-overlay="{{ closeOnClickOverlay }}" bind:close="onClickOverlay" > diff --git a/dist/dialog/index.wxss b/dist/dialog/index.wxss index eea753a8..9dfacb26 100644 --- a/dist/dialog/index.wxss +++ b/dist/dialog/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-dialog{width:85%;overflow:hidden;font-size:16px;background-color:#fff;border-radius:4px}.van-dialog__header{padding-top:25px;font-weight:500;text-align:center}.van-dialog__header--isolated{padding:25px 0}.van-dialog__message{max-height:60vh;padding:25px;overflow-y:auto;font-size:14px;line-height:1.5;text-align:center;-webkit-overflow-scrolling:touch}.van-dialog__message--has-title{padding-top:12px;color:#7d7e80}.van-dialog__message--left{text-align:left}.van-dialog__message--right{text-align:right}.van-dialog__footer{display:-webkit-flex;display:flex}.van-dialog__button{-webkit-flex:1;flex:1}.van-dialog__cancel,.van-dialog__confirm{border:0!important}.van-dialog__confirm{color:#1989fa!important}.van-dialog-bounce-enter{opacity:0;-webkit-transform:translate3d(-50%,-50%,0) scale(.7);transform:translate3d(-50%,-50%,0) scale(.7)}.van-dialog-bounce-leave-active{opacity:0;-webkit-transform:translate3d(-50%,-50%,0) scale(.9);transform:translate3d(-50%,-50%,0) scale(.9)} \ No newline at end of file +@import '../common/index.wxss';.van-dialog{top:45%!important;width:85%;overflow:hidden;font-size:16px;background-color:#fff;border-radius:4px}.van-dialog__header{padding-top:25px;font-weight:500;line-height:24px;text-align:center}.van-dialog__header--isolated{padding:25px 0}.van-dialog__message{max-height:60vh;padding:25px;overflow-y:auto;font-size:14px;line-height:20px;text-align:center;-webkit-overflow-scrolling:touch}.van-dialog__message--has-title{padding-top:12px;color:#7d7e80}.van-dialog__message--left{text-align:left}.van-dialog__message--right{text-align:right}.van-dialog__footer{display:-webkit-flex;display:flex}.van-dialog__button{-webkit-flex:1;flex:1}.van-dialog__cancel,.van-dialog__confirm{border:0!important}.van-dialog__confirm{color:#1989fa!important}.van-dialog-bounce-enter{opacity:0;-webkit-transform:translate3d(-50%,-50%,0) scale(.7);transform:translate3d(-50%,-50%,0) scale(.7)}.van-dialog-bounce-leave-active{opacity:0;-webkit-transform:translate3d(-50%,-50%,0) scale(.9);transform:translate3d(-50%,-50%,0) scale(.9)} \ No newline at end of file diff --git a/dist/mixins/basic.js b/dist/mixins/basic.js index 09b0dcfa..2fdd634f 100644 --- a/dist/mixins/basic.js +++ b/dist/mixins/basic.js @@ -1,7 +1,7 @@ export const basic = Behavior({ methods: { - $emit() { - this.triggerEvent.apply(this, arguments); + $emit(...args) { + this.triggerEvent(...args); }, getRect(selector, all) { return new Promise(resolve => { diff --git a/dist/mixins/observer/behavior.js b/dist/mixins/observer/behavior.js index 794bc53a..6e5d1a41 100644 --- a/dist/mixins/observer/behavior.js +++ b/dist/mixins/observer/behavior.js @@ -3,7 +3,6 @@ function setAsync(context, data) { context.setData(data, resolve); }); } -; export const behavior = Behavior({ created() { if (!this.$options) { @@ -17,7 +16,8 @@ export const behavior = Behavior({ keys.forEach(key => { const value = computed[key].call(this); if (cache[key] !== value) { - cache[key] = needUpdate[key] = value; + cache[key] = value; + needUpdate[key] = value; } }); return needUpdate; diff --git a/dist/mixins/observer/props.js b/dist/mixins/observer/props.js index c77aa79a..54f6623a 100644 --- a/dist/mixins/observer/props.js +++ b/dist/mixins/observer/props.js @@ -8,12 +8,12 @@ export function observeProps(props) { prop = { type: prop }; } let { observer } = prop; - prop.observer = function () { + prop.observer = function (...args) { if (observer) { if (typeof observer === 'string') { observer = this[observer]; } - observer.apply(this, arguments); + observer.apply(this, args); } this.set(); }; diff --git a/dist/picker-column/index.js b/dist/picker-column/index.js index fbe52935..4b227c91 100644 --- a/dist/picker-column/index.js +++ b/dist/picker-column/index.js @@ -115,9 +115,7 @@ VantComponent({ userAction && this.$emit('change', index); }); } - else { - return this.set({ offset }); - } + return this.set({ offset }); }, setValue(value) { const { options } = this.data; diff --git a/dist/picker-column/index.wxml b/dist/picker-column/index.wxml index d0ecb33c..5d9f0ea2 100644 --- a/dist/picker-column/index.wxml +++ b/dist/picker-column/index.wxml @@ -1,3 +1,5 @@ + + {{ getOptionText(option, valueKey) }} - - -function isObj(x) { - var type = typeof x; - return x !== null && (type === 'object' || type === 'function'); -} - -module.exports = function (option, valueKey) { - return isObj(option) && option[valueKey] ? option[valueKey] : option; -} - diff --git a/dist/picker-column/index.wxs b/dist/picker-column/index.wxs new file mode 100644 index 00000000..3c8fc681 --- /dev/null +++ b/dist/picker-column/index.wxs @@ -0,0 +1,8 @@ +function isObj(x) { + var type = typeof x; + return x !== null && (type === 'object' || type === 'function'); +} + +module.exports = function (option, valueKey) { + return isObj(option) && option[valueKey] != null ? option[valueKey] : option; +} diff --git a/dist/picker/index.js b/dist/picker/index.js index 3589df2c..52ee623c 100644 --- a/dist/picker/index.js +++ b/dist/picker/index.js @@ -74,7 +74,7 @@ VantComponent({ setColumnValue(index, value) { const column = this.getColumn(index); if (column == null) { - return Promise.reject('setColumnValue: 对应列不存在'); + return Promise.reject(new Error('setColumnValue: 对应列不存在')); } return column.setValue(value); }, @@ -86,7 +86,7 @@ VantComponent({ setColumnIndex(columnIndex, optionIndex) { const column = this.getColumn(columnIndex); if (column == null) { - return Promise.reject('setColumnIndex: 对应列不存在'); + return Promise.reject(new Error('setColumnIndex: 对应列不存在')); } return column.setIndex(optionIndex); }, @@ -98,7 +98,7 @@ VantComponent({ setColumnValues(index, options, needReset = true) { const column = this.children[index]; if (column == null) { - return Promise.reject('setColumnValues: 对应列不存在'); + return Promise.reject(new Error('setColumnValues: 对应列不存在')); } const isSame = JSON.stringify(column.data.options) === JSON.stringify(options); if (isSame) { diff --git a/dist/search/index.js b/dist/search/index.js index 2c873c13..d2648403 100644 --- a/dist/search/index.js +++ b/dist/search/index.js @@ -32,9 +32,15 @@ VantComponent({ this.$emit('change', event.detail); }, onCancel() { - this.set({ value: '' }); - this.$emit('cancel'); - this.$emit('change', ''); + /** + * 修复修改输入框值时,输入框失焦和赋值同时触发,赋值失效 + * // https://github.com/youzan/vant-weapp/issues/1768 + */ + setTimeout(() => { + this.set({ value: '' }); + this.$emit('cancel'); + this.$emit('change', ''); + }, 200); }, onSearch() { this.$emit('search', this.data.value); diff --git a/lib/collapse-item/index.js b/lib/collapse-item/index.js index 41f1090f..96c72fac 100644 --- a/lib/collapse-item/index.js +++ b/lib/collapse-item/index.js @@ -71,11 +71,9 @@ component_1.VantComponent({ contentHeight: height ? height + "px" : 'auto' }); } - else { - return _this.set({ contentHeight: height + "px" }) - .then(nextTick) - .then(function () { return _this.set({ contentHeight: 0 }); }); - } + return _this.set({ contentHeight: height + "px" }) + .then(nextTick) + .then(function () { return _this.set({ contentHeight: 0 }); }); }); }, onClick: function () { diff --git a/lib/datetime-picker/index.js b/lib/datetime-picker/index.js index a9d6c551..6e7d6cda 100644 --- a/lib/datetime-picker/index.js +++ b/lib/datetime-picker/index.js @@ -105,7 +105,8 @@ component_1.VantComponent({ }, getPicker: function () { if (this.picker == null) { - var picker_1 = (this.picker = this.selectComponent('.van-datetime-picker')); + this.picker = this.selectComponent('.van-datetime-picker'); + var picker_1 = this.picker; var setColumnValues_1 = picker_1.setColumnValues; picker_1.setColumnValues = function () { var args = []; @@ -119,7 +120,7 @@ component_1.VantComponent({ }, updateColumns: function () { var _a = this.data.formatter, formatter = _a === void 0 ? defaultFormatter : _a; - var results = this.getRanges().map(function (_a, index) { + var results = this.getRanges().map(function (_a) { var type = _a.type, range = _a.range; var values = times(range[1] - range[0] + 1, function (index) { var value = range[0] + index; diff --git a/lib/dialog/dialog.js b/lib/dialog/dialog.js index 1f8f05c8..8cdf888b 100644 --- a/lib/dialog/dialog.js +++ b/lib/dialog/dialog.js @@ -38,6 +38,7 @@ Dialog.defaultOptions = { zIndex: 100, overlay: true, className: '', + customStyle: '', asyncClose: false, messageAlign: '', transition: 'scale', diff --git a/lib/dialog/index.js b/lib/dialog/index.js index 07eba806..06b67d5c 100644 --- a/lib/dialog/index.js +++ b/lib/dialog/index.js @@ -11,6 +11,7 @@ component_1.VantComponent({ message: String, useSlot: Boolean, className: String, + customStyle: String, asyncClose: Boolean, messageAlign: String, showCancelButton: Boolean, diff --git a/lib/dialog/index.wxml b/lib/dialog/index.wxml index 6c9dac42..13a77d16 100644 --- a/lib/dialog/index.wxml +++ b/lib/dialog/index.wxml @@ -4,6 +4,7 @@ overlay="{{ overlay }}" custom-class="van-dialog {{ className }}" transition="{{ transition }}" + custom-style="{{ customStyle }}" close-on-click-overlay="{{ closeOnClickOverlay }}" bind:close="onClickOverlay" > diff --git a/lib/dialog/index.wxss b/lib/dialog/index.wxss index eea753a8..9dfacb26 100644 --- a/lib/dialog/index.wxss +++ b/lib/dialog/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-dialog{width:85%;overflow:hidden;font-size:16px;background-color:#fff;border-radius:4px}.van-dialog__header{padding-top:25px;font-weight:500;text-align:center}.van-dialog__header--isolated{padding:25px 0}.van-dialog__message{max-height:60vh;padding:25px;overflow-y:auto;font-size:14px;line-height:1.5;text-align:center;-webkit-overflow-scrolling:touch}.van-dialog__message--has-title{padding-top:12px;color:#7d7e80}.van-dialog__message--left{text-align:left}.van-dialog__message--right{text-align:right}.van-dialog__footer{display:-webkit-flex;display:flex}.van-dialog__button{-webkit-flex:1;flex:1}.van-dialog__cancel,.van-dialog__confirm{border:0!important}.van-dialog__confirm{color:#1989fa!important}.van-dialog-bounce-enter{opacity:0;-webkit-transform:translate3d(-50%,-50%,0) scale(.7);transform:translate3d(-50%,-50%,0) scale(.7)}.van-dialog-bounce-leave-active{opacity:0;-webkit-transform:translate3d(-50%,-50%,0) scale(.9);transform:translate3d(-50%,-50%,0) scale(.9)} \ No newline at end of file +@import '../common/index.wxss';.van-dialog{top:45%!important;width:85%;overflow:hidden;font-size:16px;background-color:#fff;border-radius:4px}.van-dialog__header{padding-top:25px;font-weight:500;line-height:24px;text-align:center}.van-dialog__header--isolated{padding:25px 0}.van-dialog__message{max-height:60vh;padding:25px;overflow-y:auto;font-size:14px;line-height:20px;text-align:center;-webkit-overflow-scrolling:touch}.van-dialog__message--has-title{padding-top:12px;color:#7d7e80}.van-dialog__message--left{text-align:left}.van-dialog__message--right{text-align:right}.van-dialog__footer{display:-webkit-flex;display:flex}.van-dialog__button{-webkit-flex:1;flex:1}.van-dialog__cancel,.van-dialog__confirm{border:0!important}.van-dialog__confirm{color:#1989fa!important}.van-dialog-bounce-enter{opacity:0;-webkit-transform:translate3d(-50%,-50%,0) scale(.7);transform:translate3d(-50%,-50%,0) scale(.7)}.van-dialog-bounce-leave-active{opacity:0;-webkit-transform:translate3d(-50%,-50%,0) scale(.9);transform:translate3d(-50%,-50%,0) scale(.9)} \ No newline at end of file diff --git a/lib/mixins/basic.js b/lib/mixins/basic.js index ae9f3440..4a47215a 100644 --- a/lib/mixins/basic.js +++ b/lib/mixins/basic.js @@ -3,7 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.basic = Behavior({ methods: { $emit: function () { - this.triggerEvent.apply(this, arguments); + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + this.triggerEvent.apply(this, args); }, getRect: function (selector, all) { var _this = this; diff --git a/lib/mixins/observer/behavior.js b/lib/mixins/observer/behavior.js index 01afb7d7..dc53a926 100644 --- a/lib/mixins/observer/behavior.js +++ b/lib/mixins/observer/behavior.js @@ -5,7 +5,6 @@ function setAsync(context, data) { context.setData(data, resolve); }); } -; exports.behavior = Behavior({ created: function () { var _this = this; @@ -20,7 +19,8 @@ exports.behavior = Behavior({ keys.forEach(function (key) { var value = computed[key].call(_this); if (cache[key] !== value) { - cache[key] = needUpdate[key] = value; + cache[key] = value; + needUpdate[key] = value; } }); return needUpdate; diff --git a/lib/mixins/observer/props.js b/lib/mixins/observer/props.js index 61f0b9c8..3fd9da7c 100644 --- a/lib/mixins/observer/props.js +++ b/lib/mixins/observer/props.js @@ -11,11 +11,15 @@ function observeProps(props) { } var observer = prop.observer; prop.observer = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } if (observer) { if (typeof observer === 'string') { observer = this[observer]; } - observer.apply(this, arguments); + observer.apply(this, args); } this.set(); }; diff --git a/lib/picker-column/index.js b/lib/picker-column/index.js index 3e1cef0d..3ab7f87c 100644 --- a/lib/picker-column/index.js +++ b/lib/picker-column/index.js @@ -119,9 +119,7 @@ component_1.VantComponent({ userAction && _this.$emit('change', index); }); } - else { - return this.set({ offset: offset }); - } + return this.set({ offset: offset }); }, setValue: function (value) { var options = this.data.options; diff --git a/lib/picker-column/index.wxml b/lib/picker-column/index.wxml index d0ecb33c..5d9f0ea2 100644 --- a/lib/picker-column/index.wxml +++ b/lib/picker-column/index.wxml @@ -1,3 +1,5 @@ + + {{ getOptionText(option, valueKey) }} - - -function isObj(x) { - var type = typeof x; - return x !== null && (type === 'object' || type === 'function'); -} - -module.exports = function (option, valueKey) { - return isObj(option) && option[valueKey] ? option[valueKey] : option; -} - diff --git a/lib/picker-column/index.wxs b/lib/picker-column/index.wxs new file mode 100644 index 00000000..3c8fc681 --- /dev/null +++ b/lib/picker-column/index.wxs @@ -0,0 +1,8 @@ +function isObj(x) { + var type = typeof x; + return x !== null && (type === 'object' || type === 'function'); +} + +module.exports = function (option, valueKey) { + return isObj(option) && option[valueKey] != null ? option[valueKey] : option; +} diff --git a/lib/picker/index.js b/lib/picker/index.js index 9a67533d..00fad40a 100644 --- a/lib/picker/index.js +++ b/lib/picker/index.js @@ -91,7 +91,7 @@ component_1.VantComponent({ setColumnValue: function (index, value) { var column = this.getColumn(index); if (column == null) { - return Promise.reject('setColumnValue: 对应列不存在'); + return Promise.reject(new Error('setColumnValue: 对应列不存在')); } return column.setValue(value); }, @@ -103,7 +103,7 @@ component_1.VantComponent({ setColumnIndex: function (columnIndex, optionIndex) { var column = this.getColumn(columnIndex); if (column == null) { - return Promise.reject('setColumnIndex: 对应列不存在'); + return Promise.reject(new Error('setColumnIndex: 对应列不存在')); } return column.setIndex(optionIndex); }, @@ -116,7 +116,7 @@ component_1.VantComponent({ if (needReset === void 0) { needReset = true; } var column = this.children[index]; if (column == null) { - return Promise.reject('setColumnValues: 对应列不存在'); + return Promise.reject(new Error('setColumnValues: 对应列不存在')); } var isSame = JSON.stringify(column.data.options) === JSON.stringify(options); if (isSame) { diff --git a/lib/search/index.js b/lib/search/index.js index 58d1aed6..46a42240 100644 --- a/lib/search/index.js +++ b/lib/search/index.js @@ -34,9 +34,16 @@ component_1.VantComponent({ this.$emit('change', event.detail); }, onCancel: function () { - this.set({ value: '' }); - this.$emit('cancel'); - this.$emit('change', ''); + var _this = this; + /** + * 修复修改输入框值时,输入框失焦和赋值同时触发,赋值失效 + * // https://github.com/youzan/vant-weapp/issues/1768 + */ + setTimeout(function () { + _this.set({ value: '' }); + _this.$emit('cancel'); + _this.$emit('change', ''); + }, 200); }, onSearch: function () { this.$emit('search', this.data.value);