diff --git a/dist/action-sheet/index.wxss b/dist/action-sheet/index.wxss index 92fed001..4f7f35fd 100644 --- a/dist/action-sheet/index.wxss +++ b/dist/action-sheet/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-action-sheet{max-height:90%!important;color:#333}.van-action-sheet__cancel,.van-action-sheet__item{height:50px;font-size:16px;line-height:50px;text-align:center;background-color:#fff}.van-action-sheet__cancel:active,.van-action-sheet__item:active{background-color:#e8e8e8}.van-action-sheet__cancel{height:60px}.van-action-sheet__cancel::before{display:block;content:' ';height:10px;background-color:#f8f8f8}.van-action-sheet__item--disabled{color:#c9c9c9}.van-action-sheet__item--disabled:active{background-color:#fff}.van-action-sheet__subname{margin-left:5px;font-size:12px;color:#666}.van-action-sheet__header{font-size:16px;font-weight:500;line-height:44px;text-align:center}.van-action-sheet__close{position:absolute!important;top:0;right:0;padding:0 15px;font-size:18px!important;line-height:inherit!important;color:#999} \ No newline at end of file +@import '../common/index.wxss';.van-action-sheet{max-height:90%!important;color:#333}.van-action-sheet__cancel,.van-action-sheet__item{height:50px;font-size:16px;line-height:50px;text-align:center;background-color:#fff}.van-action-sheet__cancel:active,.van-action-sheet__item:active{background-color:#e8e8e8}.van-action-sheet__cancel{height:60px}.van-action-sheet__cancel::before{display:block;content:' ';height:10px;background-color:#f8f8f8}.van-action-sheet__item--disabled{color:#c9c9c9}.van-action-sheet__item--disabled:active{background-color:#fff}.van-action-sheet__subname{margin-left:5px;font-size:12px;color:#7d7e80}.van-action-sheet__header{font-size:16px;font-weight:500;line-height:44px;text-align:center}.van-action-sheet__close{position:absolute!important;top:0;right:0;padding:0 15px;font-size:18px!important;line-height:inherit!important;color:#999} \ No newline at end of file diff --git a/dist/badge/index.wxss b/dist/badge/index.wxss index 10695329..bb5f6b2d 100644 --- a/dist/badge/index.wxss +++ b/dist/badge/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-badge{display:block;overflow:hidden;font-size:14px;line-height:1.4;-webkit-user-select:none;user-select:none;color:#666;word-break:break-all;box-sizing:border-box;padding:20px 12px 20px 9px;background-color:#f8f8f8;border-left:3px solid transparent}.van-badge:active{background-color:#e8e8e8}.van-badge::after{border-bottom-width:1px}.van-badge--active{font-weight:700;color:#333;border-color:#f44}.van-badge--active::after{border-right-width:1px}.van-badge--active,.van-badge--active:active{background-color:#fff}.van-badge__info{position:absolute;top:4px;right:2px;color:#fff;font-size:12px;font-weight:500;-webkit-transform:scale(.8);transform:scale(.8);text-align:center;box-sizing:border-box;padding:0 6px;min-width:18px;line-height:18px;border-radius:9px;background-color:#f44} \ No newline at end of file +@import '../common/index.wxss';.van-badge{display:block;overflow:hidden;font-size:14px;line-height:1.4;-webkit-user-select:none;user-select:none;color:#7d7e80;word-break:break-all;box-sizing:border-box;padding:20px 12px 20px 9px;background-color:#f8f8f8;border-left:3px solid transparent}.van-badge:active{background-color:#e8e8e8}.van-badge::after{border-bottom-width:1px}.van-badge--active{font-weight:700;color:#333;border-color:#f44}.van-badge--active::after{border-right-width:1px}.van-badge--active,.van-badge--active:active{background-color:#fff}.van-badge__info{position:absolute;top:4px;right:2px;color:#fff;font-size:12px;font-weight:500;-webkit-transform:scale(.8);transform:scale(.8);text-align:center;box-sizing:border-box;padding:0 6px;min-width:18px;line-height:18px;border-radius:9px;background-color:#f44} \ No newline at end of file diff --git a/dist/card/index.wxss b/dist/card/index.wxss index 02d047a5..ef76adf1 100644 --- a/dist/card/index.wxss +++ b/dist/card/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-card{box-sizing:border-box;position:relative;height:100px;font-size:12px;color:#333;padding:5px 15px 5px 115px;background:#fafafa}.van-card--center{-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-card__thumb{position:absolute;top:5px;left:15px;width:90px;height:90px}.van-card__img{width:100%;height:100%}.van-card,.van-card__content{display:-webkit-flex;display:flex}.van-card__content{width:100%}.van-card__desc,.van-card__title{line-height:20px;word-break:break-all}.van-card__title{max-height:40px}.van-card__desc{max-height:20px;color:#666}.van-card__left{-webkit-flex:1;flex:1;min-width:0}.van-card__right{-webkit-flex:none;flex:none;padding-left:10px;line-height:20px;text-align:right}.van-card__origin-price{color:#666;text-decoration:line-through}.van-card__num{color:#666}.van-card__tag{position:absolute;top:2px;left:0}.van-card__footer{position:absolute;right:15px;bottom:5px}.van-card__footer .van-button{margin-left:5px} \ No newline at end of file +@import '../common/index.wxss';.van-card{box-sizing:border-box;position:relative;height:100px;font-size:12px;color:#333;padding:5px 15px 5px 115px;background:#fafafa}.van-card--center{-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-card__thumb{position:absolute;top:5px;left:15px;width:90px;height:90px}.van-card__img{width:100%;height:100%}.van-card,.van-card__content{display:-webkit-flex;display:flex}.van-card__content{width:100%}.van-card__desc,.van-card__title{line-height:20px;word-break:break-all}.van-card__title{max-height:40px}.van-card__desc{max-height:20px;color:#7d7e80}.van-card__left{-webkit-flex:1;flex:1;min-width:0}.van-card__right{-webkit-flex:none;flex:none;padding-left:10px;line-height:20px;text-align:right}.van-card__origin-price{color:#7d7e80;text-decoration:line-through}.van-card__num{color:#7d7e80}.van-card__tag{position:absolute;top:2px;left:0}.van-card__footer{position:absolute;right:15px;bottom:5px}.van-card__footer .van-button{margin-left:5px} \ No newline at end of file diff --git a/dist/cell/index.js b/dist/cell/index.js index c2332fef..4762d554 100644 --- a/dist/cell/index.js +++ b/dist/cell/index.js @@ -1,12 +1,13 @@ import { link } from '../mixins/link'; import { VantComponent } from '../common/component'; VantComponent({ - classes: ['title-class', 'label-class', 'value-class'], + classes: ['title-class', 'label-class', 'value-class', 'right-icon-class'], mixins: [link], props: { title: null, value: null, icon: String, + size: String, label: String, center: Boolean, isLink: Boolean, @@ -27,7 +28,8 @@ VantComponent({ 'van-cell--center': data.center, 'van-cell--required': data.required, 'van-cell--borderless': !data.border, - 'van-cell--clickable': data.isLink || data.clickable + 'van-cell--clickable': data.isLink || data.clickable, + ["van-cell--" + data.size]: data.size }); }, titleStyle: function titleStyle() { @@ -35,7 +37,7 @@ VantComponent({ return titleWidth ? "max-width: " + titleWidth + ";min-width: " + titleWidth : ''; }, iconWrapClass: function iconWrapClass() { - var prefix = 'van-cell__right-icon-wrap'; + var prefix = 'van-cell__right-icon-wrap right-icon-class'; return this.classNames(prefix, prefix + "--" + this.data.arrowDirection); } }, diff --git a/dist/cell/index.wxss b/dist/cell/index.wxss index 97e326e2..b15ff008 100644 --- a/dist/cell/index.wxss +++ b/dist/cell/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-cell{width:100%;display:-webkit-flex;display:flex;padding:10px 15px;box-sizing:border-box;line-height:24px;position:relative;background-color:#fff;color:#333;font-size:14px}.van-cell::after{content:' ';position:absolute;pointer-events:none;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;top:auto;left:15px;right:0;bottom:0;-webkit-transform:scaleY(.5);transform:scaleY(.5);border-bottom:1px solid #eee}.van-cell--borderless::after{display:none}.van-cell-group{background-color:#fff}.van-cell__label{font-size:12px;line-height:1.2;color:#666}.van-cell__title,.van-cell__value{-webkit-flex:1;flex:1}.van-cell__title:empty,.van-cell__value:empty{display:none}.van-cell__value{overflow:hidden;text-align:right;vertical-align:middle}.van-cell__left-icon-wrap,.van-cell__right-icon-wrap{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;height:24px}.van-cell__left-icon-wrap{margin-right:5px}.van-cell__right-icon-wrap{margin-left:5px}.van-cell__right-icon-wrap--left{-webkit-transform:rotate(180deg);transform:rotate(180deg)}.van-cell__right-icon-wrap--up{-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}.van-cell__right-icon-wrap--down{-webkit-transform:rotate(90deg);transform:rotate(90deg)}.van-cell__left-icon{font-size:16px!important;line-height:24px;vertical-align:middle}.van-cell__right-icon{color:#999;font-size:12px!important;line-height:24px}.van-cell--clickable:active{background-color:#e8e8e8}.van-cell--required{overflow:visible}.van-cell--required::before{content:'*';position:absolute;left:7px;font-size:14px;color:#f44}.van-cell--center{-webkit-align-items:center;align-items:center} \ No newline at end of file +@import '../common/index.wxss';.van-cell{width:100%;display:-webkit-flex;display:flex;padding:10px 15px;box-sizing:border-box;line-height:24px;position:relative;background-color:#fff;color:#333;font-size:14px}.van-cell::after{content:' ';position:absolute;pointer-events:none;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;top:auto;left:15px;right:0;bottom:0;-webkit-transform:scaleY(.5);transform:scaleY(.5);border-bottom:1px solid #eee}.van-cell--borderless::after{display:none}.van-cell-group{background-color:#fff}.van-cell__label{font-size:12px;line-height:18px;color:#7d7e80}.van-cell__title,.van-cell__value{-webkit-flex:1;flex:1}.van-cell__title:empty,.van-cell__value:empty{display:none}.van-cell__value{overflow:hidden;text-align:right;vertical-align:middle}.van-cell__left-icon-wrap,.van-cell__right-icon-wrap{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;height:24px}.van-cell__left-icon-wrap{margin-right:5px;font-size:16px}.van-cell__right-icon-wrap{margin-left:5px;font-size:12px;color:#999}.van-cell__right-icon-wrap--left{-webkit-transform:rotate(180deg);transform:rotate(180deg)}.van-cell__right-icon-wrap--up{-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}.van-cell__right-icon-wrap--down{-webkit-transform:rotate(90deg);transform:rotate(90deg)}.van-cell__left-icon{line-height:24px;vertical-align:middle}.van-cell__right-icon{line-height:24px}.van-cell--clickable:active{background-color:#e8e8e8}.van-cell--required{overflow:visible}.van-cell--required::before{content:'*';position:absolute;left:7px;font-size:14px;color:#f44}.van-cell--center{-webkit-align-items:center;align-items:center}.van-cell--large{padding-top:12px;padding-bottom:12px}.van-cell--large .van-cell__title{font-size:16px} \ No newline at end of file diff --git a/dist/collapse-item/index.js b/dist/collapse-item/index.js new file mode 100644 index 00000000..7416abfa --- /dev/null +++ b/dist/collapse-item/index.js @@ -0,0 +1,95 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + classes: ['content-class'], + relation: { + name: 'collapse', + type: 'ancestor', + linked: function linked(parent) { + this.parent = parent; + } + }, + props: { + name: [String, Number], + icon: String, + label: String, + title: [String, Number], + value: [String, Number], + disabled: Boolean, + border: { + type: Boolean, + value: true + }, + isLink: { + type: Boolean, + value: true + } + }, + data: { + contentHeight: 0, + expanded: false + }, + computed: { + titleClass: function titleClass() { + var _this$data = this.data, + disabled = _this$data.disabled, + expanded = _this$data.expanded; + return this.classNames('van-collapse-item__title', { + 'van-collapse-item__title--disabled': disabled, + 'van-collapse-item__title--expanded': expanded + }); + } + }, + methods: { + updateExpanded: function updateExpanded() { + if (!this.parent) { + return null; + } + + var _this$parent$data = this.parent.data, + value = _this$parent$data.value, + accordion = _this$parent$data.accordion, + items = _this$parent$data.items; + var name = this.data.name; + var index = items.indexOf(this); + var currentName = name == null ? index : name; + var expanded = accordion ? value === currentName : value.some(function (name) { + return name === currentName; + }); + + if (expanded !== this.data.expanded) { + this.updateStyle(expanded); + } + + this.setData({ + expanded: expanded + }); + }, + updateStyle: function updateStyle(expanded) { + var _this = this; + + if (expanded) { + this.getRect('.van-collapse-item__content').then(function (res) { + _this.setData({ + contentHeight: res.height ? res.height + 'px' : null + }); + }); + } else { + this.setData({ + contentHeight: 0 + }); + } + }, + onClick: function onClick() { + if (this.data.disabled) { + return; + } + + var _this$data2 = this.data, + name = _this$data2.name, + expanded = _this$data2.expanded; + var index = this.parent.data.items.indexOf(this); + var currentName = name == null ? index : name; + this.parent.switch(currentName, !expanded); + } + } +}); \ No newline at end of file diff --git a/dist/collapse-item/index.json b/dist/collapse-item/index.json new file mode 100644 index 00000000..0e5425cd --- /dev/null +++ b/dist/collapse-item/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-cell": "../cell/index" + } +} diff --git a/dist/collapse-item/index.wxml b/dist/collapse-item/index.wxml new file mode 100644 index 00000000..f1fc9d3c --- /dev/null +++ b/dist/collapse-item/index.wxml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + diff --git a/dist/collapse-item/index.wxss b/dist/collapse-item/index.wxss new file mode 100644 index 00000000..f7fdb515 --- /dev/null +++ b/dist/collapse-item/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-collapse-item__title .van-cell__right-icon{-webkit-transform:rotate(90deg);transform:rotate(90deg);transition:.3s}.van-collapse-item__title--expanded .van-cell__right-icon{-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}.van-collapse-item__title--disabled .van-cell,.van-collapse-item__title--disabled .van-cell__right-icon{color:#c9c9c9!important}.van-collapse-item__title--disabled:active{background-color:#fff!important}.van-collapse-item__wrapper{overflow:hidden;will-change:max-height;transition:max-height .3s ease-in-out}.van-collapse-item__content{padding:15px;background-color:#fff} \ No newline at end of file diff --git a/dist/collapse/index.js b/dist/collapse/index.js new file mode 100644 index 00000000..1546bc9d --- /dev/null +++ b/dist/collapse/index.js @@ -0,0 +1,51 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + relation: { + name: 'collapse-item', + type: 'descendant', + linked: function linked(child) { + this.setData({ + items: this.data.items.concat([child]) + }, function () { + child.updateExpanded(); + }); + } + }, + props: { + accordion: Boolean, + value: null + }, + data: { + items: [] + }, + watch: { + value: function value() { + this.data.items.forEach(function (child) { + child.updateExpanded(); + }); + }, + accordion: function accordion() { + this.data.items.forEach(function (child) { + child.updateExpanded(); + }); + } + }, + methods: { + switch: function _switch(name, expanded) { + var _this$data = this.data, + accordion = _this$data.accordion, + value = _this$data.value; + + if (!accordion) { + name = expanded ? value.concat(name) : value.filter(function (activeName) { + return activeName !== name; + }); + } else { + name = expanded ? name : ''; + } + + this.$emit('change', name); + this.$emit('input', name); + } + } +}); \ No newline at end of file diff --git a/dist/collapse/index.json b/dist/collapse/index.json new file mode 100644 index 00000000..467ce294 --- /dev/null +++ b/dist/collapse/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/dist/collapse/index.wxml b/dist/collapse/index.wxml new file mode 100644 index 00000000..49667522 --- /dev/null +++ b/dist/collapse/index.wxml @@ -0,0 +1,3 @@ + + + diff --git a/dist/datetime-picker/index.js b/dist/datetime-picker/index.js index 2b478e8a..25cac887 100644 --- a/dist/datetime-picker/index.js +++ b/dist/datetime-picker/index.js @@ -1,8 +1,9 @@ import { VantComponent } from '../common/component'; +import { isDef } from '../common/utils'; var currentYear = new Date().getFullYear(); var isValidDate = function isValidDate(date) { - return !isNaN(new Date(date).getTime()); + return isDef(date) && !isNaN(new Date(date).getTime()); }; function range(num, min, max) { @@ -165,8 +166,8 @@ VantComponent({ if (isDateType && !isValidDate(value)) { value = data.minDate; } else if (!isDateType && !value) { - var _minHour = data.minHour; - value = pad(_minHour) + ":00"; + var minHour = data.minHour; + value = pad(minHour) + ":00"; } // time type @@ -181,24 +182,8 @@ VantComponent({ } // date type - var _this$getBoundary3 = this.getBoundary('max', value), - maxYear = _this$getBoundary3.maxYear, - maxDate = _this$getBoundary3.maxDate, - maxMonth = _this$getBoundary3.maxMonth, - maxHour = _this$getBoundary3.maxHour, - maxMinute = _this$getBoundary3.maxMinute; - - var _this$getBoundary4 = this.getBoundary('min', value), - minYear = _this$getBoundary4.minYear, - minDate = _this$getBoundary4.minDate, - minMonth = _this$getBoundary4.minMonth, - minHour = _this$getBoundary4.minHour, - minMinute = _this$getBoundary4.minMinute; - - var minDay = new Date(minYear, minMonth - 1, minDate, minHour, minMinute); - var maxDay = new Date(maxYear, maxMonth - 1, maxDate, maxHour, maxMinute); - value = Math.max(value, minDay.getTime()); - value = Math.min(value, maxDay.getTime()); + value = Math.max(value, data.minDate); + value = Math.min(value, data.maxDate); return value; }, times: function times(n, iteratee) { diff --git a/dist/dialog/dialog.js b/dist/dialog/dialog.js index 8801d1da..19a6e3cc 100644 --- a/dist/dialog/dialog.js +++ b/dist/dialog/dialog.js @@ -2,11 +2,15 @@ function _extends() { _extends = Object.assign || function (target) { for (var i var queue = []; +function getContext() { + var pages = getCurrentPages(); + return pages[pages.length - 1]; +} + var Dialog = function Dialog(options) { return new Promise(function (resolve, reject) { - var pages = getCurrentPages(); - var ctx = pages[pages.length - 1]; - var dialog = ctx.selectComponent(options.selector); + var context = options.context || getContext(); + var dialog = context.selectComponent(options.selector); delete options.selector; if (dialog) { @@ -15,6 +19,8 @@ var Dialog = function Dialog(options) { onConfirm: resolve }, options)); queue.push(dialog); + } else { + console.warn('未找到 van-dialog 节点,请确认 selector 及 context 是否正确'); } }); }; diff --git a/dist/dialog/index.wxss b/dist/dialog/index.wxss index a7c48182..bb1c5fb8 100644 --- a/dist/dialog/index.wxss +++ b/dist/dialog/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-dialog{width:85%;font-size:16px;overflow:hidden;border-radius:4px;background-color:#fff}.van-dialog__header{font-weight:500;padding-top:25px;text-align:center}.van-dialog__header--isolated{padding:25px 0}.van-dialog__message{padding:25px;font-size:14px;line-height:1.5}.van-dialog__message--has-title{padding-top:12px;color:#666}.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,.van-dialog__confirm:active{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{width:85%;font-size:16px;overflow:hidden;border-radius:4px;background-color:#fff}.van-dialog__header{font-weight:500;padding-top:25px;text-align:center}.van-dialog__header--isolated{padding:25px 0}.van-dialog__message{padding:25px;font-size:14px;line-height:1.5;max-height:60vh;overflow-y:auto;-webkit-overflow-scrolling:touch}.van-dialog__message--has-title{padding-top:12px;color:#7d7e80}.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,.van-dialog__confirm:active{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/field/index.js b/dist/field/index.js index f9328a0b..83b589d9 100644 --- a/dist/field/index.js +++ b/dist/field/index.js @@ -6,6 +6,7 @@ VantComponent({ icon: String, label: String, error: Boolean, + fixed: Boolean, focus: Boolean, center: Boolean, isLink: Boolean, @@ -104,6 +105,7 @@ VantComponent({ }); this.$emit('input', ''); this.$emit('change', ''); + this.$emit('clear', ''); }, onConfirm: function onConfirm() { this.$emit('confirm', this.data.value); diff --git a/dist/field/index.wxml b/dist/field/index.wxml index fcc8521d..dea13deb 100644 --- a/dist/field/index.wxml +++ b/dist/field/index.wxml @@ -14,6 +14,7 @@