build: compile 1.0.2

This commit is contained in:
rex-zsd 2019-12-31 09:44:38 +08:00
parent cf2edcc0de
commit 9f68ed42b8
19 changed files with 166 additions and 49 deletions

9
dist/field/index.js vendored
View File

@ -76,7 +76,8 @@ VantComponent({
methods: { methods: {
onInput(event) { onInput(event) {
const { value = '' } = event.detail || {}; const { value = '' } = event.detail || {};
this.setData({ value }, () => { this.setData({ value });
wx.nextTick(() => {
this.emitChange(value); this.emitChange(value);
}); });
}, },
@ -92,7 +93,8 @@ VantComponent({
this.$emit('click-icon'); this.$emit('click-icon');
}, },
onClear() { onClear() {
this.setData({ value: '' }, () => { this.setData({ value: '' });
wx.nextTick(() => {
this.emitChange(''); this.emitChange('');
this.$emit('clear', ''); this.$emit('clear', '');
}); });
@ -103,6 +105,7 @@ VantComponent({
emitChange(value) { emitChange(value) {
this.$emit('input', value); this.$emit('input', value);
this.$emit('change', value); this.$emit('change', value);
} },
noop() { }
} }
}); });

View File

@ -70,7 +70,7 @@
size="16px" size="16px"
name="clear" name="clear"
class="van-field__clear-root van-field__icon-root" class="van-field__clear-root van-field__icon-root"
bindtouchstart="onClear" catch:touchstart="onClear"
/> />
<view class="van-field__icon-container" bind:tap="onClickIcon"> <view class="van-field__icon-container" bind:tap="onClickIcon">
<van-icon <van-icon

View File

@ -74,12 +74,14 @@ VantComponent({
]); ]);
}, },
setAnchorsRect() { setAnchorsRect() {
return Promise.all(this.children.map(anchor => (anchor.getRect('.van-index-anchor-wrapper').then((rect) => { return Promise.all(this.children.map(anchor => anchor
.getRect('.van-index-anchor-wrapper')
.then((rect) => {
Object.assign(anchor, { Object.assign(anchor, {
height: rect.height, height: rect.height,
top: rect.top + this.data.scrollTop top: rect.top + this.data.scrollTop
}); });
})))); })));
}, },
setListRect() { setListRect() {
return this.getRect('.van-index-bar').then((rect) => { return this.getRect('.van-index-bar').then((rect) => {
@ -109,7 +111,9 @@ VantComponent({
} }
}, },
getAnchorRect(anchor) { getAnchorRect(anchor) {
return anchor.getRect('.van-index-anchor-wrapper').then((rect) => ({ return anchor
.getRect('.van-index-anchor-wrapper')
.then((rect) => ({
height: rect.height, height: rect.height,
top: rect.top top: rect.top
})); }));
@ -142,7 +146,8 @@ VantComponent({
if (sticky) { if (sticky) {
let isActiveAnchorSticky = false; let isActiveAnchorSticky = false;
if (active !== -1) { if (active !== -1) {
isActiveAnchorSticky = children[active].top <= stickyOffsetTop + scrollTop; isActiveAnchorSticky =
children[active].top <= stickyOffsetTop + scrollTop;
} }
children.forEach((item, index) => { children.forEach((item, index) => {
if (index === active) { if (index === active) {
@ -198,7 +203,7 @@ VantComponent({
data: { data: {
active: false, active: false,
anchorStyle: '', anchorStyle: '',
wrapperStyle: '', wrapperStyle: ''
} }
}); });
} }
@ -229,12 +234,14 @@ VantComponent({
return; return;
} }
this.scrollToAnchorIndex = index; this.scrollToAnchorIndex = index;
const anchor = this.children.filter(item => item.data.index === this.data.indexList[index])[0]; const anchor = this.children.find((item) => item.data.index === this.data.indexList[index]);
this.$emit('select', anchor.data.index); if (anchor) {
anchor && wx.pageScrollTo({ this.$emit('select', anchor.data.index);
duration: 0, wx.pageScrollTo({
scrollTop: anchor.top duration: 0,
}); scrollTop: anchor.top
});
}
} }
} }
}); });

View File

@ -1,5 +1,6 @@
import { VantComponent } from '../common/component'; import { VantComponent } from '../common/component';
VantComponent({ VantComponent({
classes: ['avatar-class', 'title-class', 'row-class'],
props: { props: {
row: { row: {
type: Number, type: Number,

View File

@ -6,20 +6,20 @@
> >
<view <view
wx:if="{{ avatar }}" wx:if="{{ avatar }}"
class="{{ utils.bem('skeleton__avatar', [avatarShape])}}" class="avatar-class {{ utils.bem('skeleton__avatar', [avatarShape])}}"
style="{{ 'width:' + avatarSize + ';height:' + avatarSize }}" style="{{ 'width:' + avatarSize + ';height:' + avatarSize }}"
/> />
<view class="{{ utils.bem('skeleton__content')}}"> <view class="{{ utils.bem('skeleton__content')}}">
<view <view
wx:if="{{ title }}" wx:if="{{ title }}"
class="{{ utils.bem('skeleton__title') }}" class="title-class {{ utils.bem('skeleton__title') }}"
style="{{ 'width:' + titleWidth }}" style="{{ 'width:' + titleWidth }}"
/> />
<view <view
wx:for="{{ row }}" wx:for="{{ row }}"
wx:key="index" wx:key="index"
wx:for-index="index" wx:for-index="index"
class="{{ utils.bem('skeleton__row') }}" class="row-class {{ utils.bem('skeleton__row') }}"
style="{{ 'width:' + (isArray ? rowWidth[index] : rowWidth) }}" style="{{ 'width:' + (isArray ? rowWidth[index] : rowWidth) }}"
/> />
</view> </view>

View File

@ -8,11 +8,21 @@ VantComponent({
disabled: Boolean, disabled: Boolean,
leftWidth: { leftWidth: {
type: Number, type: Number,
value: 0 value: 0,
observer(leftWidth = 0) {
if (this.offset > 0) {
this.swipeMove(leftWidth);
}
}
}, },
rightWidth: { rightWidth: {
type: Number, type: Number,
value: 0 value: 0,
observer(rightWidth = 0) {
if (this.offset < 0) {
this.swipeMove(-rightWidth);
}
}
}, },
asyncClose: Boolean, asyncClose: Boolean,
name: { name: {

2
dist/tab/index.wxss vendored
View File

@ -1 +1 @@
@import '../common/index.wxss';:host{-webkit-flex-shrink:0;flex-shrink:0;width:100%}.van-tab__pane,:host{box-sizing:border-box}.van-tab__pane{overflow-y:auto}.van-tab__pane--active{height:auto}.van-tab__pane--inactive{height:0;overflow:visible} @import '../common/index.wxss';:host{-webkit-flex-shrink:0;flex-shrink:0;width:100%}.van-tab__pane,:host{box-sizing:border-box}.van-tab__pane{overflow-y:auto;-webkit-overflow-scrolling:touch}.van-tab__pane--active{height:auto}.van-tab__pane--inactive{height:0;overflow:visible}

View File

@ -1,5 +1,5 @@
import { VantComponent } from '../common/component'; import { VantComponent } from '../common/component';
import { isImageFile } from './utils'; import { isImageFile, isVideo } from './utils';
VantComponent({ VantComponent({
props: { props: {
disabled: Boolean, disabled: Boolean,
@ -54,6 +54,18 @@ VantComponent({
imageFit: { imageFit: {
type: String, type: String,
value: 'scaleToFill' value: 'scaleToFill'
},
camera: {
type: String,
value: 'back'
},
compressed: {
type: Boolean,
value: true
},
maxDuration: {
type: Number,
value: 60
} }
}, },
data: { data: {
@ -70,7 +82,7 @@ VantComponent({
startUpload() { startUpload() {
if (this.data.disabled) if (this.data.disabled)
return; return;
const { name = '', capture, maxCount, multiple, maxSize, accept, sizeType, lists, useBeforeRead = false // 是否定义了 beforeRead const { name = '', capture, maxCount, multiple, maxSize, accept, sizeType, lists, camera, compressed, maxDuration, useBeforeRead = false // 是否定义了 beforeRead
} = this.data; } = this.data;
let chooseFile = null; let chooseFile = null;
const newMaxCount = maxCount - lists.length; const newMaxCount = maxCount - lists.length;
@ -86,6 +98,18 @@ VantComponent({
}); });
}); });
} }
else if (accept === 'video') {
chooseFile = new Promise((resolve, reject) => {
wx.chooseVideo({
sourceType: capture,
compressed,
maxDuration,
camera,
success: resolve,
fail: reject
});
});
}
else { else {
chooseFile = new Promise((resolve, reject) => { chooseFile = new Promise((resolve, reject) => {
wx.chooseMessageFile({ wx.chooseMessageFile({
@ -98,7 +122,13 @@ VantComponent({
} }
chooseFile chooseFile
.then((res) => { .then((res) => {
const file = multiple ? res.tempFiles : res.tempFiles[0]; let file = null;
if (isVideo(res, accept)) {
file = Object.assign({ path: res.tempFilePath }, res);
}
else {
file = multiple ? res.tempFiles : res.tempFiles[0];
}
// 检查文件大小 // 检查文件大小
if (file instanceof Array) { if (file instanceof Array) {
const sizeEnable = file.every(item => item.size <= maxSize); const sizeEnable = file.every(item => item.size <= maxSize);

View File

@ -1,3 +1,4 @@
/// <reference types="miniprogram-api-typings" />
interface File { interface File {
path: string; path: string;
url: string; url: string;
@ -9,4 +10,5 @@ interface File {
} }
export declare function isImageUrl(url: string): boolean; export declare function isImageUrl(url: string): boolean;
export declare function isImageFile(item: File): boolean; export declare function isImageFile(item: File): boolean;
export declare function isVideo(res: any, accept: any): res is WechatMiniprogram.ChooseVideoSuccessCallbackResult;
export {}; export {};

View File

@ -14,3 +14,6 @@ export function isImageFile(item) {
} }
return false; return false;
} }
export function isVideo(res, accept) {
return accept === 'video';
}

View File

@ -79,7 +79,8 @@ component_1.VantComponent({
onInput: function (event) { onInput: function (event) {
var _this = this; var _this = this;
var _a = (event.detail || {}).value, value = _a === void 0 ? '' : _a; var _a = (event.detail || {}).value, value = _a === void 0 ? '' : _a;
this.setData({ value: value }, function () { this.setData({ value: value });
wx.nextTick(function () {
_this.emitChange(value); _this.emitChange(value);
}); });
}, },
@ -96,7 +97,8 @@ component_1.VantComponent({
}, },
onClear: function () { onClear: function () {
var _this = this; var _this = this;
this.setData({ value: '' }, function () { this.setData({ value: '' });
wx.nextTick(function () {
_this.emitChange(''); _this.emitChange('');
_this.$emit('clear', ''); _this.$emit('clear', '');
}); });
@ -107,6 +109,7 @@ component_1.VantComponent({
emitChange: function (value) { emitChange: function (value) {
this.$emit('input', value); this.$emit('input', value);
this.$emit('change', value); this.$emit('change', value);
} },
noop: function () { }
} }
}); });

View File

@ -70,7 +70,7 @@
size="16px" size="16px"
name="clear" name="clear"
class="van-field__clear-root van-field__icon-root" class="van-field__clear-root van-field__icon-root"
bindtouchstart="onClear" catch:touchstart="onClear"
/> />
<view class="van-field__icon-container" bind:tap="onClickIcon"> <view class="van-field__icon-container" bind:tap="onClickIcon">
<van-icon <van-icon

View File

@ -78,12 +78,16 @@ component_1.VantComponent({
}, },
setAnchorsRect: function () { setAnchorsRect: function () {
var _this = this; var _this = this;
return Promise.all(this.children.map(function (anchor) { return (anchor.getRect('.van-index-anchor-wrapper').then(function (rect) { return Promise.all(this.children.map(function (anchor) {
Object.assign(anchor, { return anchor
height: rect.height, .getRect('.van-index-anchor-wrapper')
top: rect.top + _this.data.scrollTop .then(function (rect) {
Object.assign(anchor, {
height: rect.height,
top: rect.top + _this.data.scrollTop
});
}); });
})); })); }));
}, },
setListRect: function () { setListRect: function () {
var _this = this; var _this = this;
@ -116,7 +120,9 @@ component_1.VantComponent({
} }
}, },
getAnchorRect: function (anchor) { getAnchorRect: function (anchor) {
return anchor.getRect('.van-index-anchor-wrapper').then(function (rect) { return ({ return anchor
.getRect('.van-index-anchor-wrapper')
.then(function (rect) { return ({
height: rect.height, height: rect.height,
top: rect.top top: rect.top
}); }); }); });
@ -150,7 +156,8 @@ component_1.VantComponent({
if (sticky) { if (sticky) {
var isActiveAnchorSticky_1 = false; var isActiveAnchorSticky_1 = false;
if (active !== -1) { if (active !== -1) {
isActiveAnchorSticky_1 = children[active].top <= stickyOffsetTop + scrollTop; isActiveAnchorSticky_1 =
children[active].top <= stickyOffsetTop + scrollTop;
} }
children.forEach(function (item, index) { children.forEach(function (item, index) {
if (index === active) { if (index === active) {
@ -192,7 +199,7 @@ component_1.VantComponent({
data: { data: {
active: false, active: false,
anchorStyle: '', anchorStyle: '',
wrapperStyle: '', wrapperStyle: ''
} }
}); });
} }
@ -224,12 +231,16 @@ component_1.VantComponent({
return; return;
} }
this.scrollToAnchorIndex = index; this.scrollToAnchorIndex = index;
var anchor = this.children.filter(function (item) { return item.data.index === _this.data.indexList[index]; })[0]; var anchor = this.children.find(function (item) {
this.$emit('select', anchor.data.index); return item.data.index === _this.data.indexList[index];
anchor && wx.pageScrollTo({
duration: 0,
scrollTop: anchor.top
}); });
if (anchor) {
this.$emit('select', anchor.data.index);
wx.pageScrollTo({
duration: 0,
scrollTop: anchor.top
});
}
} }
} }
}); });

View File

@ -2,6 +2,7 @@
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component"); var component_1 = require("../common/component");
component_1.VantComponent({ component_1.VantComponent({
classes: ['avatar-class', 'title-class', 'row-class'],
props: { props: {
row: { row: {
type: Number, type: Number,

View File

@ -6,20 +6,20 @@
> >
<view <view
wx:if="{{ avatar }}" wx:if="{{ avatar }}"
class="{{ utils.bem('skeleton__avatar', [avatarShape])}}" class="avatar-class {{ utils.bem('skeleton__avatar', [avatarShape])}}"
style="{{ 'width:' + avatarSize + ';height:' + avatarSize }}" style="{{ 'width:' + avatarSize + ';height:' + avatarSize }}"
/> />
<view class="{{ utils.bem('skeleton__content')}}"> <view class="{{ utils.bem('skeleton__content')}}">
<view <view
wx:if="{{ title }}" wx:if="{{ title }}"
class="{{ utils.bem('skeleton__title') }}" class="title-class {{ utils.bem('skeleton__title') }}"
style="{{ 'width:' + titleWidth }}" style="{{ 'width:' + titleWidth }}"
/> />
<view <view
wx:for="{{ row }}" wx:for="{{ row }}"
wx:key="index" wx:key="index"
wx:for-index="index" wx:for-index="index"
class="{{ utils.bem('skeleton__row') }}" class="row-class {{ utils.bem('skeleton__row') }}"
style="{{ 'width:' + (isArray ? rowWidth[index] : rowWidth) }}" style="{{ 'width:' + (isArray ? rowWidth[index] : rowWidth) }}"
/> />
</view> </view>

View File

@ -10,11 +10,23 @@ component_1.VantComponent({
disabled: Boolean, disabled: Boolean,
leftWidth: { leftWidth: {
type: Number, type: Number,
value: 0 value: 0,
observer: function (leftWidth) {
if (leftWidth === void 0) { leftWidth = 0; }
if (this.offset > 0) {
this.swipeMove(leftWidth);
}
}
}, },
rightWidth: { rightWidth: {
type: Number, type: Number,
value: 0 value: 0,
observer: function (rightWidth) {
if (rightWidth === void 0) { rightWidth = 0; }
if (this.offset < 0) {
this.swipeMove(-rightWidth);
}
}
}, },
asyncClose: Boolean, asyncClose: Boolean,
name: { name: {

View File

@ -1 +1 @@
@import '../common/index.wxss';:host{-webkit-flex-shrink:0;flex-shrink:0;width:100%}.van-tab__pane,:host{box-sizing:border-box}.van-tab__pane{overflow-y:auto}.van-tab__pane--active{height:auto}.van-tab__pane--inactive{height:0;overflow:visible} @import '../common/index.wxss';:host{-webkit-flex-shrink:0;flex-shrink:0;width:100%}.van-tab__pane,:host{box-sizing:border-box}.van-tab__pane{overflow-y:auto;-webkit-overflow-scrolling:touch}.van-tab__pane--active{height:auto}.van-tab__pane--inactive{height:0;overflow:visible}

View File

@ -67,6 +67,18 @@ component_1.VantComponent({
imageFit: { imageFit: {
type: String, type: String,
value: 'scaleToFill' value: 'scaleToFill'
},
camera: {
type: String,
value: 'back'
},
compressed: {
type: Boolean,
value: true
},
maxDuration: {
type: Number,
value: 60
} }
}, },
data: { data: {
@ -84,7 +96,7 @@ component_1.VantComponent({
var _this = this; var _this = this;
if (this.data.disabled) if (this.data.disabled)
return; return;
var _a = this.data, _b = _a.name, name = _b === void 0 ? '' : _b, capture = _a.capture, maxCount = _a.maxCount, multiple = _a.multiple, maxSize = _a.maxSize, accept = _a.accept, sizeType = _a.sizeType, lists = _a.lists, _c = _a.useBeforeRead // 是否定义了 beforeRead var _a = this.data, _b = _a.name, name = _b === void 0 ? '' : _b, capture = _a.capture, maxCount = _a.maxCount, multiple = _a.multiple, maxSize = _a.maxSize, accept = _a.accept, sizeType = _a.sizeType, lists = _a.lists, camera = _a.camera, compressed = _a.compressed, maxDuration = _a.maxDuration, _c = _a.useBeforeRead // 是否定义了 beforeRead
, useBeforeRead = _c === void 0 ? false : _c // 是否定义了 beforeRead , useBeforeRead = _c === void 0 ? false : _c // 是否定义了 beforeRead
; ;
var chooseFile = null; var chooseFile = null;
@ -101,6 +113,18 @@ component_1.VantComponent({
}); });
}); });
} }
else if (accept === 'video') {
chooseFile = new Promise(function (resolve, reject) {
wx.chooseVideo({
sourceType: capture,
compressed: compressed,
maxDuration: maxDuration,
camera: camera,
success: resolve,
fail: reject
});
});
}
else { else {
chooseFile = new Promise(function (resolve, reject) { chooseFile = new Promise(function (resolve, reject) {
wx.chooseMessageFile({ wx.chooseMessageFile({
@ -113,7 +137,13 @@ component_1.VantComponent({
} }
chooseFile chooseFile
.then(function (res) { .then(function (res) {
var file = multiple ? res.tempFiles : res.tempFiles[0]; var file = null;
if (utils_1.isVideo(res, accept)) {
file = __assign({ path: res.tempFilePath }, res);
}
else {
file = multiple ? res.tempFiles : res.tempFiles[0];
}
// 检查文件大小 // 检查文件大小
if (file instanceof Array) { if (file instanceof Array) {
var sizeEnable = file.every(function (item) { return item.size <= maxSize; }); var sizeEnable = file.every(function (item) { return item.size <= maxSize; });

View File

@ -18,3 +18,7 @@ function isImageFile(item) {
return false; return false;
} }
exports.isImageFile = isImageFile; exports.isImageFile = isImageFile;
function isVideo(res, accept) {
return accept === 'video';
}
exports.isVideo = isVideo;