[build] 0.4.8

This commit is contained in:
陈嘉涵 2018-12-03 17:34:26 +08:00
parent 294cd3d77e
commit 2b06095587
34 changed files with 177 additions and 63 deletions

View File

@ -31,7 +31,7 @@ VantComponent({
square = _this$data.square, square = _this$data.square,
loading = _this$data.loading, loading = _this$data.loading,
disabled = _this$data.disabled; disabled = _this$data.disabled;
return this.classNames('custom-class', 'van-button', "van-button--" + type, "van-button--" + size, { return this.classNames('van-button', "van-button--" + type, "van-button--" + size, {
'van-button--block': block, 'van-button--block': block,
'van-button--round': round, 'van-button--round': round,
'van-button--plain': plain, 'van-button--plain': plain,

View File

@ -1,7 +1,7 @@
<button <button
id="{{ id }}" id="{{ id }}"
lang="{{ lang }}" lang="{{ lang }}"
class="{{ classes }}" class="custom-class {{ classes }}"
open-type="{{ openType }}" open-type="{{ openType }}"
session-from="{{ sessionFrom }}" session-from="{{ sessionFrom }}"
app-parameter="{{ appParameter }}" app-parameter="{{ appParameter }}"

6
dist/cell/index.js vendored
View File

@ -24,7 +24,7 @@ VantComponent({
computed: { computed: {
cellClass: function cellClass() { cellClass: function cellClass() {
var data = this.data; var data = this.data;
return this.classNames('custom-class', 'van-cell', { return this.classNames('van-cell', {
'van-cell--center': data.center, 'van-cell--center': data.center,
'van-cell--required': data.required, 'van-cell--required': data.required,
'van-cell--borderless': !data.border, 'van-cell--borderless': !data.border,
@ -35,10 +35,6 @@ VantComponent({
titleStyle: function titleStyle() { titleStyle: function titleStyle() {
var titleWidth = this.data.titleWidth; var titleWidth = this.data.titleWidth;
return titleWidth ? "max-width: " + titleWidth + ";min-width: " + titleWidth : ''; return titleWidth ? "max-width: " + titleWidth + ";min-width: " + titleWidth : '';
},
iconWrapClass: function iconWrapClass() {
var prefix = 'van-cell__right-icon-wrap right-icon-class';
return this.classNames(prefix, prefix + "--" + this.data.arrowDirection);
} }
}, },
methods: { methods: {

View File

@ -1,5 +1,5 @@
<view <view
class="{{ cellClass }}" class="custom-class {{ cellClass }}"
style="{{ customStyle }}" style="{{ customStyle }}"
bind:tap="onClick" bind:tap="onClick"
> >
@ -29,8 +29,8 @@
<van-icon <van-icon
wx:if="{{ isLink }}" wx:if="{{ isLink }}"
name="arrow" name="{{ arrowDirection ? 'arrow' + '-' + arrowDirection : 'arrow' }}"
class="{{ iconWrapClass }}" class="van-cell__right-icon-wrap right-icon-class"
custom-class="van-cell__right-icon" custom-class="van-cell__right-icon"
/> />
<slot wx:else name="right-icon" /> <slot wx:else name="right-icon" />

View File

@ -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: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} @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;font-size:16px}.van-cell__left-icon-wrap{margin-right:5px}.van-cell__right-icon-wrap{margin-left:5px;color:#999}.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}

View File

@ -1 +1 @@
@import '../common/index.wxss';.van-checkbox{overflow:hidden;-webkit-user-select:none;user-select:none}.van-checkbox__icon-wrap,.van-checkbox__label{display:inline-block;line-height:20px;vertical-align:middle}.van-checkbox__icon{box-sizing:border-box;display:block;width:20px;height:20px;border:1px solid #e5e5e5;color:transparent;font-size:12px;text-align:center;transition:.2s}.van-checkbox__icon--round{border-radius:100%}.van-checkbox__icon--checked{color:#fff;border-color:#1989fa;background-color:#1989fa}.van-checkbox__icon--disabled{border-color:#eee;background-color:currentColor;color:#f8f8f8}.van-checkbox__icon--disabled.van-checkbox__icon--checked{border-color:#eee;background-color:#eee}.van-checkbox__label{margin-left:10px}.van-checkbox__label--left{margin:0 10px 0 0;float:left}.van-checkbox__label:empty{margin:0} @import '../common/index.wxss';.van-checkbox{overflow:hidden;-webkit-user-select:none;user-select:none}.van-checkbox__icon-wrap,.van-checkbox__label{display:inline-block;line-height:20px;vertical-align:middle}.van-checkbox__icon{box-sizing:border-box;display:block;width:20px;height:20px;border:1px solid #e5e5e5;color:transparent;font-size:14px;text-align:center;transition:.2s}.van-checkbox__icon--round{border-radius:100%}.van-checkbox__icon--checked{color:#fff;border-color:#1989fa;background-color:#1989fa}.van-checkbox__icon--disabled{border-color:#eee;background-color:currentColor;color:#f8f8f8}.van-checkbox__icon--disabled.van-checkbox__icon--checked{border-color:#eee;background-color:#eee}.van-checkbox__label{margin-left:10px}.van-checkbox__label--left{margin:0 10px 0 0;float:left}.van-checkbox__label:empty{margin:0}

2
dist/col/index.js vendored
View File

@ -16,7 +16,7 @@ VantComponent({
var _this$data = this.data, var _this$data = this.data,
span = _this$data.span, span = _this$data.span,
offset = _this$data.offset; offset = _this$data.offset;
return this.classNames('custom-class', 'van-col', { return this.classNames('van-col', {
["van-col--" + span]: span, ["van-col--" + span]: span,
["van-col--offset-" + offset]: offset ["van-col--offset-" + offset]: offset
}); });

2
dist/col/index.wxml vendored
View File

@ -1,5 +1,5 @@
<view <view
class="{{ classes }}" class="custom-class {{ classes }}"
style="{{ style }}" style="{{ style }}"
> >
<slot /> <slot />

View File

@ -11,4 +11,8 @@ function isNumber(value) {
return /^\d+$/.test(value); return /^\d+$/.test(value);
} }
export { isObj, isDef, isNumber }; function isSrc(url) {
return /^(https?:)?\/\/|data:image/.test(url);
}
export { isObj, isDef, isSrc, isNumber };

View File

@ -8,6 +8,7 @@ function getContext() {
} }
var Dialog = function Dialog(options) { var Dialog = function Dialog(options) {
options = _extends({}, Dialog.currentOptions, options);
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
var context = options.context || getContext(); var context = options.context || getContext();
var dialog = context.selectComponent(options.selector); var dialog = context.selectComponent(options.selector);
@ -32,6 +33,7 @@ Dialog.defaultOptions = {
zIndex: 100, zIndex: 100,
overlay: true, overlay: true,
asyncClose: false, asyncClose: false,
transition: 'scale',
selector: '#van-dialog', selector: '#van-dialog',
confirmButtonText: '确认', confirmButtonText: '确认',
cancelButtonText: '取消', cancelButtonText: '取消',
@ -40,13 +42,10 @@ Dialog.defaultOptions = {
closeOnClickOverlay: false, closeOnClickOverlay: false,
confirmButtonOpenType: '' confirmButtonOpenType: ''
}; };
Dialog.alert = Dialog;
Dialog.alert = function (options) {
return Dialog(_extends({}, Dialog.currentOptions, options));
};
Dialog.confirm = function (options) { Dialog.confirm = function (options) {
return Dialog(_extends({}, Dialog.currentOptions, { return Dialog(_extends({
showCancelButton: true showCancelButton: true
}, options)); }, options));
}; };

View File

@ -30,6 +30,10 @@ VantComponent({
overlay: { overlay: {
type: Boolean, type: Boolean,
value: true value: true
},
transition: {
type: String,
value: 'scale'
} }
}, },
data: { data: {

View File

@ -1,9 +1,9 @@
<van-popup <van-popup
show="{{ show }}" show="{{ show }}"
transition="scale"
z-index="{{ zIndex }}" z-index="{{ zIndex }}"
overlay="{{ overlay }}" overlay="{{ overlay }}"
custom-class="van-dialog" custom-class="van-dialog"
transition="{{ transition }}"
close-on-click-overlay="{{ closeOnClickOverlay }}" close-on-click-overlay="{{ closeOnClickOverlay }}"
bind:close="onClickOverlay" bind:close="onClickOverlay"
> >

50
dist/field/index.js vendored
View File

@ -20,12 +20,17 @@ VantComponent({
inputAlign: String, inputAlign: String,
customClass: String, customClass: String,
confirmType: String, confirmType: String,
confirmHold: Boolean,
errorMessage: String, errorMessage: String,
placeholder: String, placeholder: String,
customStyle: String, customStyle: String,
useIconSlot: Boolean, useIconSlot: Boolean,
useButtonSlot: Boolean, useButtonSlot: Boolean,
placeholderStyle: String, placeholderStyle: String,
adjustPosition: {
type: Boolean,
value: true
},
cursorSpacing: { cursorSpacing: {
type: Number, type: Number,
value: 50 value: 50
@ -66,27 +71,49 @@ VantComponent({
}, },
methods: { methods: {
onInput: function onInput(event) { onInput: function onInput(event) {
var _this = this;
var _ref = event.detail || {}, var _ref = event.detail || {},
_ref$value = _ref.value, _ref$value = _ref.value,
value = _ref$value === void 0 ? '' : _ref$value; value = _ref$value === void 0 ? '' : _ref$value;
this.$emit('input', value);
this.$emit('change', value);
this.setData({ this.setData({
value: value, value: value,
showClear: this.getShowClear(value) showClear: this.getShowClear(value)
}, function () {
_this.$emit('input', value);
_this.$emit('change', value);
}); });
}, },
onFocus: function onFocus() { onFocus: function onFocus(event) {
this.$emit('focus'); var _ref2 = event.detail || {},
_ref2$value = _ref2.value,
value = _ref2$value === void 0 ? '' : _ref2$value,
_ref2$height = _ref2.height,
height = _ref2$height === void 0 ? 0 : _ref2$height;
this.$emit('focus', {
value: value,
height: height
});
this.focused = true; this.focused = true;
this.setData({ this.setData({
showClear: this.getShowClear() showClear: this.getShowClear()
}); });
}, },
onBlur: function onBlur() { onBlur: function onBlur(event) {
var _ref3 = event.detail || {},
_ref3$value = _ref3.value,
value = _ref3$value === void 0 ? '' : _ref3$value,
_ref3$cursor = _ref3.cursor,
cursor = _ref3$cursor === void 0 ? 0 : _ref3$cursor;
this.$emit('blur', {
value: value,
cursor: cursor
});
this.focused = false; this.focused = false;
this.$emit('blur');
this.setData({ this.setData({
showClear: this.getShowClear() showClear: this.getShowClear()
}); });
@ -99,13 +126,18 @@ VantComponent({
return this.data.clearable && this.focused && value && !this.data.readonly; return this.data.clearable && this.focused && value && !this.data.readonly;
}, },
onClear: function onClear() { onClear: function onClear() {
var _this2 = this;
this.setData({ this.setData({
value: '', value: '',
showClear: this.getShowClear('') showClear: this.getShowClear('')
}, function () {
_this2.$emit('input', '');
_this2.$emit('change', '');
_this2.$emit('clear', '');
}); });
this.$emit('input', '');
this.$emit('change', '');
this.$emit('clear', '');
}, },
onConfirm: function onConfirm() { onConfirm: function onConfirm() {
this.$emit('confirm', this.data.value); this.$emit('confirm', this.data.value);

View File

@ -9,6 +9,7 @@
title-width="{{ titleWidth }}" title-width="{{ titleWidth }}"
custom-class="van-field" custom-class="van-field"
> >
<slot name="left-icon" slot="icon" />
<slot name="label" slot="title" /> <slot name="label" slot="title" />
<view class="van-field__body {{ type === 'textarea' ? 'van-field__body--textarea' : '' }}"> <view class="van-field__body {{ type === 'textarea' ? 'van-field__body--textarea' : '' }}">
<textarea <textarea
@ -24,6 +25,7 @@
placeholder-style="{{ placeholderStyle }}" placeholder-style="{{ placeholderStyle }}"
placeholder-class="{{ error ? 'van-field--error' : '' }}" placeholder-class="{{ error ? 'van-field--error' : '' }}"
cursor-spacing="{{ cursorSpacing }}" cursor-spacing="{{ cursorSpacing }}"
adjust-position="{{ adjustPosition }}"
bindinput="onInput" bindinput="onInput"
bind:blur="onBlur" bind:blur="onBlur"
bind:focus="onFocus" bind:focus="onFocus"
@ -41,7 +43,9 @@
placeholder-style="{{ placeholderStyle }}" placeholder-style="{{ placeholderStyle }}"
placeholder-class="{{ error ? 'van-field--error' : '' }}" placeholder-class="{{ error ? 'van-field--error' : '' }}"
confirm-type="{{ confirmType }}" confirm-type="{{ confirmType }}"
confirm-hold="{{ confirmHold }}"
cursor-spacing="{{ cursorSpacing }}" cursor-spacing="{{ cursorSpacing }}"
adjust-position="{{ adjustPosition }}"
bindinput="onInput" bindinput="onInput"
bind:blur="onBlur" bind:blur="onBlur"
bind:focus="onFocus" bind:focus="onFocus"

6
dist/icon/index.js vendored
View File

@ -1,3 +1,4 @@
import { isSrc as _isSrc } from '../common/utils';
import { VantComponent } from '../common/component'; import { VantComponent } from '../common/component';
VantComponent({ VantComponent({
props: { props: {
@ -11,6 +12,11 @@ VantComponent({
value: 'van-icon' value: 'van-icon'
} }
}, },
computed: {
isSrc: function isSrc() {
return _isSrc(this.data.name);
}
},
methods: { methods: {
onClick: function onClick() { onClick: function onClick() {
this.$emit('click'); this.$emit('click');

13
dist/icon/index.wxml vendored
View File

@ -1,7 +1,16 @@
<view <view
class="custom-class {{ classPrefix }} {{ classPrefix }}-{{ name }}" class="custom-class {{ classPrefix }} {{ isSrc ? 'van-icon--image' : classPrefix + '-' + name }}"
style="{{ color ? 'color: ' + color + ';' : '' }}{{ size ? 'font-size: ' + size + ';' : '' }}{{ customStyle }}" style="{{ color ? 'color: ' + color + ';' : '' }}{{ size ? 'font-size: ' + size + ';' : '' }}{{ customStyle }}"
bind:tap="onClick" bind:tap="onClick"
> >
<view wx:if="{{ info !== null }}" class="van-icon__info">{{ info }}</view> <view
wx:if="{{ info !== null }}"
class="van-icon__info"
>
{{ info }}
</view>
<image
wx:if="{{ isSrc }}"
src="{{ name }}"
/>
</view> </view>

File diff suppressed because one or more lines are too long

View File

@ -3,10 +3,14 @@ VantComponent({
classes: ['title-class'], classes: ['title-class'],
props: { props: {
title: String, title: String,
fixed: Boolean,
leftText: String, leftText: String,
rightText: String, rightText: String,
leftArrow: Boolean, leftArrow: Boolean,
fixed: Boolean, border: {
type: Boolean,
value: true
},
zIndex: { zIndex: {
type: Number, type: Number,
value: 1 value: 1

View File

@ -1,12 +1,13 @@
<view <view
class="custom-class van-nav-bar van-hairline--bottom {{ fixed ? 'van-nav-bar--fixed' : '' }}" class="custom-class van-nav-bar {{ border ? 'van-hairline--bottom' : '' }} {{ fixed ? 'van-nav-bar--fixed' : '' }}"
style="z-index: {{ zIndex }}" style="z-index: {{ zIndex }}"
> >
<view class="van-nav-bar__left" bind:tap="onClickLeft"> <view class="van-nav-bar__left" bind:tap="onClickLeft">
<block wx:if="{{ leftArrow || leftText }}"> <block wx:if="{{ leftArrow || leftText }}">
<van-icon <van-icon
wx:if="{{ leftArrow }}" wx:if="{{ leftArrow }}"
name="arrow" size="16px"
name="arrow-left"
custom-class="van-nav-bar__arrow" custom-class="van-nav-bar__arrow"
/> />
<view wx:if="{{ leftText }}" class="van-nav-bar__text">{{ leftText }}</view> <view wx:if="{{ leftText }}" class="van-nav-bar__text">{{ leftText }}</view>

View File

@ -1 +1 @@
@import '../common/index.wxss';.van-nav-bar{height:46px;position:relative;-webkit-user-select:none;user-select:none;text-align:center;line-height:46px;background-color:#fff}.van-nav-bar__arrow{color:#1989fa;vertical-align:middle;-webkit-transform:rotate(180deg);transform:rotate(180deg)}.van-nav-bar__arrow+.van-nav-bar__text{margin-left:-20px;padding-left:25px}.van-nav-bar--fixed{top:0;left:0;width:100%;position:fixed}.van-nav-bar__title{margin:0 auto;max-width:60%;font-size:16px;font-weight:500}.van-nav-bar__left,.van-nav-bar__right{bottom:0;font-size:14px;position:absolute}.van-nav-bar__left{left:15px}.van-nav-bar__right{right:15px}.van-nav-bar__text{color:#1989fa;margin:0 -15px;padding:0 15px;display:inline-block;vertical-align:middle}.van-nav-bar__text:active{background-color:#e8e8e8} @import '../common/index.wxss';.van-nav-bar{height:46px;position:relative;-webkit-user-select:none;user-select:none;text-align:center;line-height:46px;background-color:#fff}.van-nav-bar__arrow{color:#1989fa;vertical-align:middle}.van-nav-bar__arrow+.van-nav-bar__text{margin-left:-20px;padding-left:25px}.van-nav-bar--fixed{top:0;left:0;width:100%;position:fixed}.van-nav-bar__title{margin:0 auto;max-width:60%;font-size:16px;font-weight:500}.van-nav-bar__left,.van-nav-bar__right{bottom:0;font-size:14px;position:absolute}.van-nav-bar__left{left:15px}.van-nav-bar__right{right:15px}.van-nav-bar__text{color:#1989fa;margin:0 -15px;padding:0 15px;display:inline-block;vertical-align:middle}.van-nav-bar__text:active{background-color:#e8e8e8}

8
dist/rate/index.js vendored
View File

@ -10,6 +10,14 @@ VantComponent({
type: Number, type: Number,
value: 20 value: 20
}, },
icon: {
type: String,
value: 'star'
},
voidIcon: {
type: String,
value: 'star-o'
},
color: { color: {
type: String, type: String,
value: '#ffd21e' value: '#ffd21e'

View File

@ -8,7 +8,7 @@
class="van-rate__item" class="van-rate__item"
size="{{ size }}px" size="{{ size }}px"
data-index="{{ index }}" data-index="{{ index }}"
name="{{ item ? 'star' : 'star-o' }}" name="{{ item ? icon : voidIcon }}"
color="{{ disabled ? disabledColor : item ? color : voidColor }}" color="{{ disabled ? disabledColor : item ? color : voidColor }}"
bind:click="onSelect" bind:click="onSelect"
/> />

View File

@ -22,7 +22,7 @@ VantComponent({
}, },
computed: { computed: {
classes: function classes() { classes: function classes() {
return this.classNames('custom-class', 'van-switch', { return this.classNames('van-switch', {
'van-switch--on': this.data.checked, 'van-switch--on': this.data.checked,
'van-switch--disabled': this.data.disabled 'van-switch--disabled': this.data.disabled
}); });

View File

@ -1,6 +1,6 @@
<view <view
style="{{ style }}" style="{{ style }}"
class="{{ classes }}" class="custom-class {{ classes }}"
bind:tap="onClick" bind:tap="onClick"
> >
<view class="van-switch__node node-class"> <view class="van-switch__node node-class">

4
dist/tab/index.js vendored
View File

@ -10,7 +10,9 @@ VantComponent({
}, },
data: { data: {
inited: false, inited: false,
active: false active: false,
animated: false,
width: null
}, },
watch: { watch: {
title: 'update', title: 'update',

6
dist/tab/index.wxml vendored
View File

@ -1,7 +1,7 @@
<view <view
wx:if="{{ inited }}" wx:if="{{ animated || inited }}"
class="custom-class van-tab__pane" class="custom-class van-tab__pane {{ animated ? 'van-tab__pane--float' : '' }}"
style="{{ active ? '' : 'display: none' }}" style="{{ animated || active ? '' : 'display: none;' }} {{ width ? 'width:' + width + 'px;' : '' }}"
> >
<slot /> <slot />
</view> </view>

1
dist/tab/index.wxss vendored Normal file
View File

@ -0,0 +1 @@
@import '../common/index.wxss';.van-tab__pane{box-sizing:border-box}.van-tab__pane--float{float:left}

View File

@ -3,7 +3,12 @@
bind:tap="onClick" bind:tap="onClick"
> >
<view class="van-tabbar-item__icon {{ dot ? 'van-tabbar-item__icon--dot' : '' }}"> <view class="van-tabbar-item__icon {{ dot ? 'van-tabbar-item__icon--dot' : '' }}">
<van-icon wx:if="{{ icon }}" name="{{ icon }}" info="{{ info }}" /> <van-icon
wx:if="{{ icon }}"
name="{{ icon }}"
info="{{ info }}"
customStyle="display: block"
/>
<block wx:else> <block wx:else>
<slot wx:if="{{ active }}" name="icon-active" /> <slot wx:if="{{ active }}" name="icon-active" />
<slot wx:else name="icon" /> <slot wx:else name="icon" />

58
dist/tabs/index.js vendored
View File

@ -35,7 +35,7 @@ VantComponent({
}, },
duration: { duration: {
type: Number, type: Number,
value: 0.2 value: 0.3
}, },
zIndex: { zIndex: {
type: Number, type: Number,
@ -44,13 +44,15 @@ VantComponent({
swipeThreshold: { swipeThreshold: {
type: Number, type: Number,
value: 4 value: 4
} },
animated: Boolean
}, },
data: { data: {
tabs: [], tabs: [],
lineStyle: '', lineStyle: '',
scrollLeft: 0, scrollLeft: 0,
scrollable: false scrollable: false,
trackStyle: ''
}, },
watch: { watch: {
swipeThreshold: function swipeThreshold() { swipeThreshold: function swipeThreshold() {
@ -60,13 +62,15 @@ VantComponent({
}, },
color: 'setLine', color: 'setLine',
lineWidth: 'setLine', lineWidth: 'setLine',
active: 'setActiveTab' active: 'setActiveTab',
animated: 'setTrack'
}, },
beforeCreate: function beforeCreate() { beforeCreate: function beforeCreate() {
this.child = []; this.child = [];
}, },
mounted: function mounted() { mounted: function mounted() {
this.setLine(); this.setLine();
this.setTrack();
this.scrollIntoView(); this.scrollIntoView();
}, },
methods: { methods: {
@ -128,12 +132,38 @@ VantComponent({
}); });
}); });
}, },
setActiveTab: function setActiveTab() { setTrack: function setTrack() {
var _this2 = this; var _this2 = this;
var _this$data2 = this.data,
animated = _this$data2.animated,
active = _this$data2.active,
duration = _this$data2.duration;
if (!animated) return '';
this.getRect('.van-tabs__content').then(function (rect) {
var width = rect.width;
_this2.setData({
trackStyle: "\n width: " + width * _this2.child.length + "px;\n transform: translateX(" + -1 * active * width + "px);\n transition-duration: " + duration + "s;\n "
});
_this2.setTabsProps({
width: width,
animated: animated
});
});
},
setTabsProps: function setTabsProps(props) {
this.child.forEach(function (item) {
item.setData(props);
});
},
setActiveTab: function setActiveTab() {
var _this3 = this;
this.child.forEach(function (item, index) { this.child.forEach(function (item, index) {
var data = { var data = {
active: index === _this2.data.active active: index === _this3.data.active
}; };
if (data.active) { if (data.active) {
@ -145,30 +175,32 @@ VantComponent({
} }
}); });
this.setData({}, function () { this.setData({}, function () {
_this2.setLine(); _this3.setLine();
_this2.scrollIntoView(); _this3.setTrack();
_this3.scrollIntoView();
}); });
}, },
// scroll active tab into view // scroll active tab into view
scrollIntoView: function scrollIntoView() { scrollIntoView: function scrollIntoView() {
var _this3 = this; var _this4 = this;
if (!this.data.scrollable) { if (!this.data.scrollable) {
return; return;
} }
this.getRect('.van-tab', true).then(function (tabRects) { this.getRect('.van-tab', true).then(function (tabRects) {
var tabRect = tabRects[_this3.data.active]; var tabRect = tabRects[_this4.data.active];
var offsetLeft = tabRects.slice(0, _this3.data.active).reduce(function (prev, curr) { var offsetLeft = tabRects.slice(0, _this4.data.active).reduce(function (prev, curr) {
return prev + curr.width; return prev + curr.width;
}, 0); }, 0);
var tabWidth = tabRect.width; var tabWidth = tabRect.width;
_this3.getRect('.van-tabs__nav').then(function (navRect) { _this4.getRect('.van-tabs__nav').then(function (navRect) {
var navWidth = navRect.width; var navWidth = navRect.width;
_this3.setData({ _this4.setData({
scrollLeft: offsetLeft - (navWidth - tabWidth) / 2 scrollLeft: offsetLeft - (navWidth - tabWidth) / 2
}); });
}); });

View File

@ -22,5 +22,9 @@
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
<slot /> <view class="van-tabs__content">
<view class="van-tabs__track" style="{{ trackStyle }}">
<slot />
</view>
</view>
</view> </view>

View File

@ -1 +1 @@
@import '../common/index.wxss';.van-tabs{position:relative;-webkit-tap-highlight-color:transparent}.van-tabs__wrap{top:0;left:0;right:0;position:absolute}.van-tabs__wrap--page-top{position:fixed}.van-tabs__wrap--content-bottom{top:auto;bottom:0}.van-tabs__wrap--scrollable .van-tab{-webkit-flex:0 0 22%;flex:0 0 22%}.van-tabs__scroll--card{border:1px solid #f44;border-radius:2px}.van-tabs__nav{display:-webkit-flex;display:flex;-webkit-user-select:none;user-select:none;position:relative;background-color:#fff}.van-tabs__nav--line{height:100%}.van-tabs__nav--card{height:30px}.van-tabs__nav--card .van-tab{color:#f44;border-right:1px solid #f44;line-height:30px}.van-tabs__nav--card .van-tab:last-child{border-right:none}.van-tabs__nav--card .van-tab.van-tab--active{color:#fff;background-color:#f44}.van-tabs__line{z-index:1;left:0;bottom:0;height:2px;position:absolute;background-color:#f44;border-radius:2px}.van-tabs--line{padding-top:44px}.van-tabs--line .van-tabs__wrap{height:44px}.van-tabs--card{padding-top:30px;margin:0 15px}.van-tabs--card .van-tabs__wrap{height:30px}.van-tab{-webkit-flex:1;flex:1;cursor:pointer;padding:0 5px;font-size:14px;position:relative;color:#7d7e80;line-height:44px;text-align:center;box-sizing:border-box;background-color:#fff;min-width:0}.van-tab span{display:block}.van-tab--active{font-weight:500;color:#333}.van-tab--disabled{color:#c9c9c9} @import '../common/index.wxss';.van-tabs{position:relative;-webkit-tap-highlight-color:transparent}.van-tabs__wrap{top:0;left:0;right:0;position:absolute}.van-tabs__wrap--page-top{position:fixed}.van-tabs__wrap--content-bottom{top:auto;bottom:0}.van-tabs__wrap--scrollable .van-tab{-webkit-flex:0 0 22%;flex:0 0 22%}.van-tabs__scroll--card{border:1px solid #f44;border-radius:2px}.van-tabs__nav{display:-webkit-flex;display:flex;-webkit-user-select:none;user-select:none;position:relative;background-color:#fff}.van-tabs__nav--line{height:100%}.van-tabs__nav--card{height:30px}.van-tabs__nav--card .van-tab{color:#f44;border-right:1px solid #f44;line-height:30px}.van-tabs__nav--card .van-tab:last-child{border-right:none}.van-tabs__nav--card .van-tab.van-tab--active{color:#fff;background-color:#f44}.van-tabs__line{z-index:1;left:0;bottom:0;height:2px;position:absolute;background-color:#f44;border-radius:2px}.van-tabs--line{padding-top:44px}.van-tabs--line .van-tabs__wrap{height:44px}.van-tabs--card{padding-top:30px;margin:0 15px}.van-tabs--card .van-tabs__wrap{height:30px}.van-tabs__content{overflow:hidden}.van-tab{-webkit-flex:1;flex:1;cursor:pointer;padding:0 5px;font-size:14px;position:relative;color:#7d7e80;line-height:44px;text-align:center;box-sizing:border-box;background-color:#fff;min-width:0}.van-tab span{display:block}.van-tab--active{font-weight:500;color:#333}.van-tab--disabled{color:#c9c9c9}

2
dist/tag/index.js vendored
View File

@ -18,7 +18,7 @@ VantComponent({
computed: { computed: {
classes: function classes() { classes: function classes() {
var data = this.data; var data = this.data;
return this.classNames('van-tag', 'custom-class', { return this.classNames('van-tag', {
'van-tag--mark': data.mark, 'van-tag--mark': data.mark,
'van-tag--plain': data.plain, 'van-tag--plain': data.plain,
'van-tag--round': data.round, 'van-tag--round': data.round,

5
dist/tag/index.wxml vendored
View File

@ -1,3 +1,6 @@
<view class="{{ classes }}" style="{{ style }}"> <view
class="custom-class {{ classes }}"
style="{{ style }}"
>
<slot /> <slot />
</view> </view>

View File

@ -1 +1 @@
@import '../common/index.wxss';.van-toast{display:-webkit-flex;display:flex;color:#fff;font-size:14px;line-height:20px;border-radius:4px;word-break:break-all;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;-webkit-flex-direction:column;flex-direction:column;box-sizing:border-box;background-color:rgba(0,0,0,.7)}.van-toast__container{top:50%;left:50%;max-width:80%;position:fixed;width:-webkit-fit-content;width:fit-content;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.van-toast--text{min-width:120px;padding:8px 12px}.van-toast--icon{width:120px;min-height:120px;padding:15px}.van-toast--icon .van-toast__icon{height:1em;font-size:50px}.van-toast--icon .van-toast__text{font-size:14px;padding-top:10px}.van-toast__loading{margin:10px 0 5px}.van-toast--top{-webkit-transform:translate(0,-30vh);transform:translate(0,-30vh)}.van-toast--bottom{-webkit-transform:translate(0,30vh);transform:translate(0,30vh)} @import '../common/index.wxss';.van-toast{display:-webkit-flex;display:flex;color:#fff;font-size:14px;line-height:20px;border-radius:4px;word-break:break-all;-webkit-align-items:center;align-items:center;-webkit-flex-direction:column;flex-direction:column;-webkit-justify-content:center;justify-content:center;box-sizing:content-box;background-color:rgba(0,0,0,.7)}.van-toast__container{position:fixed;top:50%;left:50%;max-width:70%;width:-webkit-fit-content;width:fit-content;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.van-toast--text{padding:8px 12px;min-width:96px}.van-toast--icon{width:90px;padding:15px;min-height:90px}.van-toast--icon .van-toast__icon{font-size:50px}.van-toast--icon .van-toast__text{padding-top:5px}.van-toast__loading{margin:10px 0}.van-toast--top{-webkit-transform:translate(0,-30vh);transform:translate(0,-30vh)}.van-toast--bottom{-webkit-transform:translate(0,30vh);transform:translate(0,30vh)}