From 4714333cd69781c8bc0d3506b0692df4dc6d2712 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 27 Sep 2018 17:34:19 +0800 Subject: [PATCH] [build] use babel to compile typescript (#657) --- babel.config.js | 9 +- build/compiler.js | 5 +- dist/action-sheet/index.js | 71 +++---- dist/area/index.js | 272 +++++++++++++++------------ dist/badge-group/index.js | 94 +++++----- dist/badge/index.js | 39 ++-- dist/button/index.js | 77 ++++---- dist/card/index.js | 32 ++-- dist/cell-group/index.js | 12 +- dist/cell/index.js | 98 +++++----- dist/col/index.js | 62 +++--- dist/common/class-names.js | 49 ++--- dist/common/component.js | 90 ++++----- dist/dialog/dialog.js | 94 ++++++---- dist/dialog/index.js | 171 ++++++++--------- dist/field/index.js | 208 +++++++++++---------- dist/icon/index.js | 30 +-- dist/loading/index.js | 28 +-- dist/mixins/basic.js | 44 ++--- dist/mixins/button.js | 52 +++--- dist/mixins/observer/behavior.js | 68 ++++--- dist/mixins/observer/index.js | 55 +++--- dist/mixins/observer/props.js | 48 +++-- dist/mixins/open-type.js | 40 ++-- dist/mixins/touch.js | 40 ++-- dist/mixins/transition.js | 101 +++++----- dist/nav-bar/index.js | 40 ++-- dist/notice-bar/index.js | 286 +++++++++++++++------------- dist/notify/index.js | 71 +++---- dist/notify/notify.js | 39 ++-- dist/overlay/index.js | 32 ++-- dist/panel/index.js | 18 +- dist/popup/index.js | 59 +++--- dist/progress/index.js | 120 ++++++------ dist/radio-group/index.js | 64 ++++--- dist/radio/index.js | 77 ++++---- dist/row/index.js | 68 +++---- dist/search/index.js | 78 ++++---- dist/slider/index.js | 144 +++++++------- dist/stepper/index.js | 130 ++++++------- dist/steps/index.js | 81 ++++---- dist/submit-bar/index.js | 72 ++++--- dist/switch-cell/index.js | 54 +++--- dist/switch/index.js | 60 +++--- dist/tab/index.js | 54 +++--- dist/tabbar-item/index.js | 59 +++--- dist/tabbar/index.js | 129 +++++++------ dist/tabs/index.js | 312 ++++++++++++++++--------------- dist/tag/index.js | 12 +- dist/toast/index.js | 60 +++--- dist/toast/toast.js | 113 ++++++----- dist/transition/index.js | 14 +- dist/tree-select/index.js | 122 ++++++------ package.json | 3 +- yarn.lock | 265 +++++--------------------- 55 files changed, 2290 insertions(+), 2235 deletions(-) diff --git a/babel.config.js b/babel.config.js index ba8f331e..64f1034f 100644 --- a/babel.config.js +++ b/babel.config.js @@ -4,11 +4,10 @@ module.exports = { '@babel/preset-env', { loose: true, - modules: 'commonjs' + modules: false } - ] + ], + '@babel/preset-typescript' ], - plugins: [ - '@babel/plugin-syntax-dynamic-import' - ] + plugins: ['@babel/plugin-syntax-dynamic-import'] }; diff --git a/build/compiler.js b/build/compiler.js index 6bd93e5b..ef6f0257 100644 --- a/build/compiler.js +++ b/build/compiler.js @@ -1,6 +1,6 @@ const gulp = require('gulp'); const path = require('path'); -const ts = require('gulp-typescript'); +const babel = require('gulp-babel'); const postcss = require('gulp-postcss'); const cssmin = require('gulp-clean-css'); const rename = require('gulp-rename'); @@ -9,7 +9,6 @@ const isProduction = process.env.NODE_ENV === 'production'; const src = path.join(__dirname, '../packages'); const dist = path.join(__dirname, isProduction ? '../dist' : '../example/dist'); const ext = ['js', 'ts', 'pcss', 'json', 'wxml']; -const tsProject = ts.createProject('tsconfig.json'); function copy(ext) { return gulp.src([src + '/**/*.' + ext]).pipe(gulp.dest(dist)); @@ -32,7 +31,7 @@ gulp.task('compile-js', () => copy('js')); gulp.task('compile-ts', () => gulp .src([src + '/**/*.ts']) - .pipe(tsProject()) + .pipe(babel()) .on('error', (err) => { console.log(err); }) diff --git a/dist/action-sheet/index.js b/dist/action-sheet/index.js index f522c157..2f1d455e 100644 --- a/dist/action-sheet/index.js +++ b/dist/action-sheet/index.js @@ -1,39 +1,40 @@ import { VantComponent } from '../common/component'; VantComponent({ - props: { - show: Boolean, - title: String, - cancelText: String, - zIndex: { - type: Number, - value: 100 - }, - actions: { - type: Array, - value: [] - }, - overlay: { - type: Boolean, - value: true - }, - closeOnClickOverlay: { - type: Boolean, - value: true - } + props: { + show: Boolean, + title: String, + cancelText: String, + zIndex: { + type: Number, + value: 100 }, - methods: { - onSelect(event) { - const { index } = event.currentTarget.dataset; - const item = this.data.actions[index]; - if (item && !item.disabled && !item.loading) { - this.$emit('select', item); - } - }, - onCancel() { - this.$emit('cancel'); - }, - onClose() { - this.$emit('close'); - } + actions: { + type: Array, + value: [] + }, + overlay: { + type: Boolean, + value: true + }, + closeOnClickOverlay: { + type: Boolean, + value: true } -}); + }, + methods: { + onSelect: function onSelect(event) { + var index = event.currentTarget.dataset.index; + var item = this.data.actions[index]; + + if (item && !item.disabled && !item.loading) { + this.$emit('select', item); + } + }, + onCancel: function onCancel() { + this.$emit('cancel'); + }, + onClose: function onClose() { + this.$emit('close'); + } + } +}); \ No newline at end of file diff --git a/dist/area/index.js b/dist/area/index.js index 6d7b6de5..aadacf9e 100644 --- a/dist/area/index.js +++ b/dist/area/index.js @@ -1,130 +1,154 @@ import { VantComponent } from '../common/component'; VantComponent({ - props: { - title: String, - value: String, - loading: Boolean, - itemHeight: { - type: Number, - value: 44 - }, - visibleItemCount: { - type: Number, - value: 5 - }, - columnsNum: { - type: [String, Number], - value: 3 - }, - areaList: { - type: Object, - value: {} - } + props: { + title: String, + value: String, + loading: Boolean, + itemHeight: { + type: Number, + value: 44 }, - data: { - pickerValue: [0, 0, 0], - columns: [] + visibleItemCount: { + type: Number, + value: 5 }, - computed: { - displayColumns() { - const { columns = [], columnsNum } = this.data; - return columns.slice(0, +columnsNum); - } + columnsNum: { + type: [String, Number], + value: 3 }, - watch: { - value(value) { - this.code = value; - this.setValues(); - }, - areaList: 'setValues' - }, - methods: { - onCancel() { - this.$emit('cancel', { - values: this.getValues(), - indexs: this.getIndexs() - }); - }, - onConfirm() { - this.$emit('confirm', { - values: this.getValues(), - indexs: this.getIndexs() - }); - }, - onChange(event) { - const { value } = event.detail; - const { pickerValue, displayColumns } = this.data; - const index = pickerValue.findIndex((item, index) => item !== value[index]); - // 没有变更 或 选中项序号小于0 不处理 - if (index < 0 || value[index] < 0) { - return; - } - const values = displayColumns[index]; - this.code = values[value[index]].code; - this.setValues(); - this.$emit('change', { - picker: this, - values: this.getValues(), - index - }); - }, - getList(type, code) { - let result = []; - if (type !== 'province' && !code) { - return result; - } - const list = this.data.areaList[`${type}_list`] || {}; - result = Object.keys(list).map(code => ({ - code, - name: list[code] - })); - if (code) { - result = result.filter(item => item.code.indexOf(code) === 0); - } - return result; - }, - getIndex(type, code) { - const compareNum = type === 'province' ? 2 : type === 'city' ? 4 : 6; - const list = this.getList(type, code.slice(0, compareNum - 2)); - code = code.slice(0, compareNum); - for (let i = 0; i < list.length; i++) { - if (list[i].code.slice(0, compareNum) === code) { - return i; - } - } - return 0; - }, - setValues() { - let code = this.code || Object.keys(this.data.areaList.county_list)[0] || ''; - const province = this.getList('province'); - const city = this.getList('city', code.slice(0, 2)); - this.setData({ - 'columns[0]': province, - 'columns[1]': city - }); - if (city.length && code.slice(2, 4) === '00') { - code = city[0].code; - } - this.setData({ - 'columns[2]': this.getList('county', code.slice(0, 4)), - pickerValue: [ - this.getIndex('province', code), - this.getIndex('city', code), - this.getIndex('county', code) - ] - }); - }, - getValues() { - const { displayColumns = [], pickerValue = [] } = this.data; - return displayColumns.map((option, index) => option[pickerValue[index]]); - }, - getIndexs() { - const { pickerValue, columnsNum } = this.data; - return pickerValue.slice(0, columnsNum); - }, - reset() { - this.code = ''; - this.setValues(); - } + areaList: { + type: Object, + value: {} } -}); + }, + data: { + pickerValue: [0, 0, 0], + columns: [] + }, + computed: { + displayColumns: function displayColumns() { + var _this$data = this.data, + _this$data$columns = _this$data.columns, + columns = _this$data$columns === void 0 ? [] : _this$data$columns, + columnsNum = _this$data.columnsNum; + return columns.slice(0, +columnsNum); + } + }, + watch: { + value: function value(_value) { + this.code = _value; + this.setValues(); + }, + areaList: 'setValues' + }, + methods: { + onCancel: function onCancel() { + this.$emit('cancel', { + values: this.getValues(), + indexs: this.getIndexs() + }); + }, + onConfirm: function onConfirm() { + this.$emit('confirm', { + values: this.getValues(), + indexs: this.getIndexs() + }); + }, + onChange: function onChange(event) { + var value = event.detail.value; + var _this$data2 = this.data, + pickerValue = _this$data2.pickerValue, + displayColumns = _this$data2.displayColumns; + var index = pickerValue.findIndex(function (item, index) { + return item !== value[index]; + }); // 没有变更 或 选中项序号小于0 不处理 + + if (index < 0 || value[index] < 0) { + return; + } + + var values = displayColumns[index]; + this.code = values[value[index]].code; + this.setValues(); + this.$emit('change', { + picker: this, + values: this.getValues(), + index: index + }); + }, + getList: function getList(type, code) { + var result = []; + + if (type !== 'province' && !code) { + return result; + } + + var list = this.data.areaList[type + "_list"] || {}; + result = Object.keys(list).map(function (code) { + return { + code: code, + name: list[code] + }; + }); + + if (code) { + result = result.filter(function (item) { + return item.code.indexOf(code) === 0; + }); + } + + return result; + }, + getIndex: function getIndex(type, code) { + var compareNum = type === 'province' ? 2 : type === 'city' ? 4 : 6; + var list = this.getList(type, code.slice(0, compareNum - 2)); + code = code.slice(0, compareNum); + + for (var i = 0; i < list.length; i++) { + if (list[i].code.slice(0, compareNum) === code) { + return i; + } + } + + return 0; + }, + setValues: function setValues() { + var code = this.code || Object.keys(this.data.areaList.county_list)[0] || ''; + var province = this.getList('province'); + var city = this.getList('city', code.slice(0, 2)); + this.setData({ + 'columns[0]': province, + 'columns[1]': city + }); + + if (city.length && code.slice(2, 4) === '00') { + code = city[0].code; + } + + this.setData({ + 'columns[2]': this.getList('county', code.slice(0, 4)), + pickerValue: [this.getIndex('province', code), this.getIndex('city', code), this.getIndex('county', code)] + }); + }, + getValues: function getValues() { + var _this$data3 = this.data, + _this$data3$displayCo = _this$data3.displayColumns, + displayColumns = _this$data3$displayCo === void 0 ? [] : _this$data3$displayCo, + _this$data3$pickerVal = _this$data3.pickerValue, + pickerValue = _this$data3$pickerVal === void 0 ? [] : _this$data3$pickerVal; + return displayColumns.map(function (option, index) { + return option[pickerValue[index]]; + }); + }, + getIndexs: function getIndexs() { + var _this$data4 = this.data, + pickerValue = _this$data4.pickerValue, + columnsNum = _this$data4.columnsNum; + return pickerValue.slice(0, columnsNum); + }, + reset: function reset() { + this.code = ''; + this.setValues(); + } + } +}); \ No newline at end of file diff --git a/dist/badge-group/index.js b/dist/badge-group/index.js index 4cd50c0c..3e5d9560 100644 --- a/dist/badge-group/index.js +++ b/dist/badge-group/index.js @@ -1,48 +1,54 @@ import { VantComponent } from '../common/component'; VantComponent({ - relation: { - name: 'badge', - type: 'descendant', - linked(target) { - this.badges.push(target); - this.setActive(); - }, - unlinked(target) { - this.badges = this.badges.filter(item => item !== target); - this.setActive(); - } + relation: { + name: 'badge', + type: 'descendant', + linked: function linked(target) { + this.badges.push(target); + this.setActive(); }, - props: { - active: { - type: Number, - value: 0 - } - }, - watch: { - active: 'setActive' - }, - beforeCreate() { - this.badges = []; - this.currentActive = -1; - }, - methods: { - setActive(badge) { - let { active } = this.data; - const { badges } = this; - if (badge) { - active = badges.indexOf(badge); - } - if (active === this.currentActive) { - return; - } - if (this.currentActive !== -1 && badges[this.currentActive]) { - this.$emit('change', active); - badges[this.currentActive].setActive(false); - } - if (badges[active]) { - badges[active].setActive(true); - this.currentActive = active; - } - } + unlinked: function unlinked(target) { + this.badges = this.badges.filter(function (item) { + return item !== target; + }); + this.setActive(); } -}); + }, + props: { + active: { + type: Number, + value: 0 + } + }, + watch: { + active: 'setActive' + }, + beforeCreate: function beforeCreate() { + this.badges = []; + this.currentActive = -1; + }, + methods: { + setActive: function setActive(badge) { + var active = this.data.active; + var badges = this.badges; + + if (badge) { + active = badges.indexOf(badge); + } + + if (active === this.currentActive) { + return; + } + + if (this.currentActive !== -1 && badges[this.currentActive]) { + this.$emit('change', active); + badges[this.currentActive].setActive(false); + } + + if (badges[active]) { + badges[active].setActive(true); + this.currentActive = active; + } + } + } +}); \ No newline at end of file diff --git a/dist/badge/index.js b/dist/badge/index.js index a520c274..512370ad 100644 --- a/dist/badge/index.js +++ b/dist/badge/index.js @@ -1,22 +1,25 @@ import { VantComponent } from '../common/component'; VantComponent({ - relation: { - type: 'ancestor', - name: 'badge-group' + relation: { + type: 'ancestor', + name: 'badge-group' + }, + props: { + info: Number, + title: String + }, + methods: { + onClick: function onClick() { + var group = this.getRelationNodes('../badge-group/index')[0]; + + if (group) { + group.setActive(this); + } }, - props: { - info: Number, - title: String - }, - methods: { - onClick() { - const group = this.getRelationNodes('../badge-group/index')[0]; - if (group) { - group.setActive(this); - } - }, - setActive(active) { - this.setData({ active }); - } + setActive: function setActive(active) { + this.setData({ + active: active + }); } -}); + } +}); \ No newline at end of file diff --git a/dist/button/index.js b/dist/button/index.js index 0274d905..029eee5b 100644 --- a/dist/button/index.js +++ b/dist/button/index.js @@ -2,40 +2,47 @@ import { VantComponent } from '../common/component'; import { button } from '../mixins/button'; import { openType } from '../mixins/open-type'; VantComponent({ - mixins: [button, openType], - props: { - plain: Boolean, - block: Boolean, - square: Boolean, - loading: Boolean, - disabled: Boolean, - type: { - type: String, - value: 'default' - }, - size: { - type: String, - value: 'normal' - } + mixins: [button, openType], + props: { + plain: Boolean, + block: Boolean, + square: Boolean, + loading: Boolean, + disabled: Boolean, + type: { + type: String, + value: 'default' }, - computed: { - classes() { - const { type, size, plain, disabled, loading, square, block } = this.data; - return this.classNames(`van-button--${type}`, `van-button--${size}`, { - 'van-button--block': block, - 'van-button--plain': plain, - 'van-button--square': square, - 'van-button--loading': loading, - 'van-button--disabled': disabled, - 'van-button--unclickable': disabled || loading - }); - } - }, - methods: { - onClick() { - if (!this.data.disabled && !this.data.loading) { - this.$emit('click'); - } - } + size: { + type: String, + value: 'normal' } -}); + }, + computed: { + classes: function classes() { + var _this$data = this.data, + type = _this$data.type, + size = _this$data.size, + plain = _this$data.plain, + disabled = _this$data.disabled, + loading = _this$data.loading, + square = _this$data.square, + block = _this$data.block; + return this.classNames("van-button--" + type, "van-button--" + size, { + 'van-button--block': block, + 'van-button--plain': plain, + 'van-button--square': square, + 'van-button--loading': loading, + 'van-button--disabled': disabled, + 'van-button--unclickable': disabled || loading + }); + } + }, + methods: { + onClick: function onClick() { + if (!this.data.disabled && !this.data.loading) { + this.$emit('click'); + } + } + } +}); \ No newline at end of file diff --git a/dist/card/index.js b/dist/card/index.js index 50dce2d2..44ac3249 100644 --- a/dist/card/index.js +++ b/dist/card/index.js @@ -1,22 +1,16 @@ import { VantComponent } from '../common/component'; VantComponent({ - classes: [ - 'thumb-class', - 'title-class', - 'price-class', - 'desc-class', - 'num-class' - ], - props: { - num: String, - desc: String, - thumb: String, - title: String, - price: String, - centered: Boolean, - currency: { - type: String, - value: '¥' - } + classes: ['thumb-class', 'title-class', 'price-class', 'desc-class', 'num-class'], + props: { + num: String, + desc: String, + thumb: String, + title: String, + price: String, + centered: Boolean, + currency: { + type: String, + value: '¥' } -}); + } +}); \ No newline at end of file diff --git a/dist/cell-group/index.js b/dist/cell-group/index.js index 8e42c191..a9e114c1 100644 --- a/dist/cell-group/index.js +++ b/dist/cell-group/index.js @@ -1,9 +1,9 @@ import { VantComponent } from '../common/component'; VantComponent({ - props: { - border: { - type: Boolean, - value: true - } + props: { + border: { + type: Boolean, + value: true } -}); + } +}); \ No newline at end of file diff --git a/dist/cell/index.js b/dist/cell/index.js index 33aa83c2..9c7a8994 100644 --- a/dist/cell/index.js +++ b/dist/cell/index.js @@ -1,53 +1,53 @@ import { VantComponent } from '../common/component'; VantComponent({ - classes: [ - 'title-class', - 'label-class', - 'value-class' - ], - props: { - title: null, - value: null, - url: String, - icon: String, - label: String, - center: Boolean, - isLink: Boolean, - required: Boolean, - clickable: Boolean, - titleWidth: String, - customStyle: String, - linkType: { - type: String, - value: 'navigateTo' - }, - border: { - type: Boolean, - value: true - } + classes: ['title-class', 'label-class', 'value-class'], + props: { + title: null, + value: null, + url: String, + icon: String, + label: String, + center: Boolean, + isLink: Boolean, + required: Boolean, + clickable: Boolean, + titleWidth: String, + customStyle: String, + linkType: { + type: String, + value: 'navigateTo' }, - computed: { - cellClass() { - const { data } = this; - return this.classNames('custom-class', 'van-cell', { - 'van-hairline': data.border, - 'van-cell--center': data.center, - 'van-cell--required': data.required, - 'van-cell--clickable': data.isLink || data.clickable - }); - }, - titleStyle() { - const { titleWidth } = this.data; - return titleWidth ? `max-width: ${titleWidth};min-width: ${titleWidth}` : ''; - } - }, - methods: { - onClick() { - const { url } = this.data; - if (url) { - wx[this.data.linkType]({ url }); - } - this.$emit('click'); - } + border: { + type: Boolean, + value: true } -}); + }, + computed: { + cellClass: function cellClass() { + var data = this.data; + return this.classNames('custom-class', 'van-cell', { + 'van-hairline': data.border, + 'van-cell--center': data.center, + 'van-cell--required': data.required, + 'van-cell--clickable': data.isLink || data.clickable + }); + }, + titleStyle: function titleStyle() { + var titleWidth = this.data.titleWidth; + return titleWidth ? "max-width: " + titleWidth + ";min-width: " + titleWidth : ''; + } + }, + methods: { + onClick: function onClick() { + var url = this.data.url; + + if (url) { + wx[this.data.linkType]({ + url: url + }); + } + + this.$emit('click'); + } + } +}); \ No newline at end of file diff --git a/dist/col/index.js b/dist/col/index.js index 738ab183..6d35e033 100644 --- a/dist/col/index.js +++ b/dist/col/index.js @@ -1,32 +1,36 @@ import { VantComponent } from '../common/component'; VantComponent({ - relation: { - name: 'row', - type: 'ancestor' - }, - props: { - span: Number, - offset: Number - }, - data: { - style: '' - }, - computed: { - classes() { - const { span, offset } = this.data; - return this.classNames('custom-class', 'van-col', { - [`van-col--${span}`]: span, - [`van-col--offset-${offset}`]: offset - }); - } - }, - methods: { - setGutter(gutter) { - const padding = `${gutter / 2}px`; - const style = gutter ? `padding-left: ${padding}; padding-right: ${padding};` : ''; - if (style !== this.data.style) { - this.setData({ style }); - } - } + relation: { + name: 'row', + type: 'ancestor' + }, + props: { + span: Number, + offset: Number + }, + data: { + style: '' + }, + computed: { + classes: function classes() { + var _this$classNames; + + var _this$data = this.data, + span = _this$data.span, + offset = _this$data.offset; + return this.classNames('custom-class', 'van-col', (_this$classNames = {}, _this$classNames["van-col--" + span] = span, _this$classNames["van-col--offset-" + offset] = offset, _this$classNames)); } -}); + }, + methods: { + setGutter: function setGutter(gutter) { + var padding = gutter / 2 + "px"; + var style = gutter ? "padding-left: " + padding + "; padding-right: " + padding + ";" : ''; + + if (style !== this.data.style) { + this.setData({ + style: style + }); + } + } + } +}); \ No newline at end of file diff --git a/dist/common/class-names.js b/dist/common/class-names.js index b7823b3e..7e1d0507 100644 --- a/dist/common/class-names.js +++ b/dist/common/class-names.js @@ -1,28 +1,29 @@ -const hasOwn = {}.hasOwnProperty; +var hasOwn = {}.hasOwnProperty; export function classNames() { - const classes = []; - for (let i = 0; i < arguments.length; i++) { - const arg = arguments[i]; - if (!arg) - continue; - const argType = typeof arg; - if (argType === 'string' || argType === 'number') { - classes.push(arg); - } - else if (Array.isArray(arg) && arg.length) { - const inner = classNames.apply(null, arg); - if (inner) { - classes.push(inner); - } - } - else if (argType === 'object') { - for (const key in arg) { - if (hasOwn.call(arg, key) && arg[key]) { - classes.push(key); - } - } + var classes = []; + + for (var i = 0; i < arguments.length; i++) { + var arg = arguments[i]; + if (!arg) continue; + var argType = typeof arg; + + if (argType === 'string' || argType === 'number') { + classes.push(arg); + } else if (Array.isArray(arg) && arg.length) { + var inner = classNames.apply(null, arg); + + if (inner) { + classes.push(inner); + } + } else if (argType === 'object') { + for (var key in arg) { + if (hasOwn.call(arg, key) && arg[key]) { + classes.push(key); } + } } - return classes.join(' '); + } + + return classes.join(' '); } -; +; \ No newline at end of file diff --git a/dist/common/component.js b/dist/common/component.js index f4d196bc..a29393ed 100644 --- a/dist/common/component.js +++ b/dist/common/component.js @@ -1,48 +1,54 @@ import { basic } from '../mixins/basic'; import { observe } from '../mixins/observer/index'; + function mapKeys(source, target, map) { - Object.keys(map).forEach(key => { - if (source[key]) { - target[map[key]] = source[key]; - } - }); + Object.keys(map).forEach(function (key) { + if (source[key]) { + target[map[key]] = source[key]; + } + }); } + function VantComponent(vantOptions) { - const options = {}; - mapKeys(vantOptions, options, { - data: 'data', - props: 'properties', - mixins: 'behaviors', - methods: 'methods', - beforeCreate: 'created', - created: 'attached', - mounted: 'ready', - relations: 'relations', - destroyed: 'detached', - classes: 'externalClasses' - }); - const { relation } = vantOptions; - if (relation) { - options.relations = Object.assign(options.relations || {}, { - [`../${relation.name}/index`]: relation - }); - } - // add default externalClasses - options.externalClasses = options.externalClasses || []; - options.externalClasses.push('custom-class'); - // add default behaviors - options.behaviors = options.behaviors || []; - options.behaviors.push(basic); - // map field to form-field behavior - if (vantOptions.field) { - options.behaviors.push('wx://form-field'); - } - // add default options - options.options = { - multipleSlots: true, - addGlobalClass: true - }; - observe(vantOptions, options); - Component(options); + var options = {}; + mapKeys(vantOptions, options, { + data: 'data', + props: 'properties', + mixins: 'behaviors', + methods: 'methods', + beforeCreate: 'created', + created: 'attached', + mounted: 'ready', + relations: 'relations', + destroyed: 'detached', + classes: 'externalClasses' + }); + var relation = vantOptions.relation; + + if (relation) { + var _Object$assign; + + options.relations = Object.assign(options.relations || {}, (_Object$assign = {}, _Object$assign["../" + relation.name + "/index"] = relation, _Object$assign)); + } // add default externalClasses + + + options.externalClasses = options.externalClasses || []; + options.externalClasses.push('custom-class'); // add default behaviors + + options.behaviors = options.behaviors || []; + options.behaviors.push(basic); // map field to form-field behavior + + if (vantOptions.field) { + options.behaviors.push('wx://form-field'); + } // add default options + + + options.options = { + multipleSlots: true, + addGlobalClass: true + }; + observe(vantOptions, options); + Component(options); } -export { VantComponent }; + +export { VantComponent }; \ No newline at end of file diff --git a/dist/dialog/dialog.js b/dist/dialog/dialog.js index 18289604..4661923b 100644 --- a/dist/dialog/dialog.js +++ b/dist/dialog/dialog.js @@ -1,44 +1,64 @@ -let queue = []; -const Dialog = options => { - return new Promise((resolve, reject) => { - const pages = getCurrentPages(); - const ctx = pages[pages.length - 1]; - const dialog = ctx.selectComponent(options.selector); - delete options.selector; - if (dialog) { - dialog.setData(Object.assign({ onCancel: reject, onConfirm: resolve }, options)); - queue.push(dialog); - } - }); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +var queue = []; + +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); + delete options.selector; + + if (dialog) { + dialog.setData(_extends({ + onCancel: reject, + onConfirm: resolve + }, options)); + queue.push(dialog); + } + }); }; + Dialog.defaultOptions = { - show: true, - title: '', - message: '', - zIndex: 100, - overlay: true, - asyncClose: false, - selector: '#van-dialog', - confirmButtonText: '确认', - cancelButtonText: '取消', - showConfirmButton: true, - showCancelButton: false, - closeOnClickOverlay: false, - confirmButtonOpenType: '' + show: true, + title: '', + message: '', + zIndex: 100, + overlay: true, + asyncClose: false, + selector: '#van-dialog', + confirmButtonText: '确认', + cancelButtonText: '取消', + showConfirmButton: true, + showCancelButton: false, + closeOnClickOverlay: false, + confirmButtonOpenType: '' }; -Dialog.alert = options => Dialog(Object.assign({}, Dialog.currentOptions, options)); -Dialog.confirm = options => Dialog(Object.assign({}, Dialog.currentOptions, { showCancelButton: true }, options)); -Dialog.close = () => { - queue.forEach(dialog => { - dialog.close(); - }); - queue = []; + +Dialog.alert = function (options) { + return Dialog(_extends({}, Dialog.currentOptions, options)); }; -Dialog.setDefaultOptions = options => { - Object.assign(Dialog.currentOptions, options); + +Dialog.confirm = function (options) { + return Dialog(_extends({}, Dialog.currentOptions, { + showCancelButton: true + }, options)); }; -Dialog.resetDefaultOptions = () => { - Dialog.currentOptions = Object.assign({}, Dialog.defaultOptions); + +Dialog.close = function () { + queue.forEach(function (dialog) { + dialog.close(); + }); + queue = []; }; + +Dialog.setDefaultOptions = function (options) { + Object.assign(Dialog.currentOptions, options); +}; + +Dialog.resetDefaultOptions = function () { + Dialog.currentOptions = _extends({}, Dialog.defaultOptions); +}; + Dialog.resetDefaultOptions(); -export default Dialog; +export default Dialog; \ No newline at end of file diff --git a/dist/dialog/index.js b/dist/dialog/index.js index 88bfa851..11d8508e 100644 --- a/dist/dialog/index.js +++ b/dist/dialog/index.js @@ -1,91 +1,94 @@ import { VantComponent } from '../common/component'; import { openType } from '../mixins/open-type'; VantComponent({ - mixins: [openType], - props: { - show: Boolean, - title: String, - message: String, - useSlot: Boolean, - asyncClose: Boolean, - showCancelButton: Boolean, - confirmButtonOpenType: String, - zIndex: { - type: Number, - value: 100 - }, - confirmButtonText: { - type: String, - value: '确认' - }, - cancelButtonText: { - type: String, - value: '取消' - }, - showConfirmButton: { - type: Boolean, - value: true - }, - overlay: { - type: Boolean, - value: true - }, - closeOnClickOverlay: { - type: Boolean, - value: false - } + mixins: [openType], + props: { + show: Boolean, + title: String, + message: String, + useSlot: Boolean, + asyncClose: Boolean, + showCancelButton: Boolean, + confirmButtonOpenType: String, + zIndex: { + type: Number, + value: 100 }, - data: { - loading: { + confirmButtonText: { + type: String, + value: '确认' + }, + cancelButtonText: { + type: String, + value: '取消' + }, + showConfirmButton: { + type: Boolean, + value: true + }, + overlay: { + type: Boolean, + value: true + }, + closeOnClickOverlay: { + type: Boolean, + value: false + } + }, + data: { + loading: { + confirm: false, + cancel: false + } + }, + watch: { + show: function show(_show) { + if (!_show) { + this.setData({ + loading: { confirm: false, cancel: false - } - }, - watch: { - show(show) { - if (!show) { - this.setData({ - loading: { - confirm: false, - cancel: false - } - }); - } - } - }, - methods: { - onConfirm() { - this.handleAction('confirm'); - }, - onCancel() { - this.handleAction('cancel'); - }, - onClickOverlay() { - this.onClose('overlay'); - }, - handleAction(action) { - if (this.data.asyncClose) { - this.setData({ - [`loading.${action}`]: true - }); - } - this.onClose(action); - }, - close() { - this.setData({ - show: false - }); - }, - onClose(action) { - if (!this.data.asyncClose) { - this.close(); - } - this.$emit('close', action); - this.$emit(action); - const callback = this.data[action === 'confirm' ? 'onConfirm' : 'onCancel']; - if (callback) { - callback(this); - } - } + } + }); + } } -}); + }, + methods: { + onConfirm: function onConfirm() { + this.handleAction('confirm'); + }, + onCancel: function onCancel() { + this.handleAction('cancel'); + }, + onClickOverlay: function onClickOverlay() { + this.onClose('overlay'); + }, + handleAction: function handleAction(action) { + if (this.data.asyncClose) { + var _this$setData; + + this.setData((_this$setData = {}, _this$setData["loading." + action] = true, _this$setData)); + } + + this.onClose(action); + }, + close: function close() { + this.setData({ + show: false + }); + }, + onClose: function onClose(action) { + if (!this.data.asyncClose) { + this.close(); + } + + this.$emit('close', action); + this.$emit(action); + var callback = this.data[action === 'confirm' ? 'onConfirm' : 'onCancel']; + + if (callback) { + callback(this); + } + } + } +}); \ No newline at end of file diff --git a/dist/field/index.js b/dist/field/index.js index f0989e7f..9d6f4e40 100644 --- a/dist/field/index.js +++ b/dist/field/index.js @@ -1,109 +1,113 @@ import { VantComponent } from '../common/component'; VantComponent({ - field: true, - classes: ['input-class'], - props: { - icon: String, - label: String, - error: Boolean, - focus: Boolean, - center: Boolean, - isLink: Boolean, - leftIcon: String, - disabled: Boolean, - autosize: Boolean, - readonly: Boolean, - required: Boolean, - iconClass: String, - clearable: Boolean, - inputAlign: String, - customClass: String, - confirmType: String, - errorMessage: String, - placeholder: String, - customStyle: String, - useIconSlot: Boolean, - useButtonSlot: Boolean, - placeholderClass: String, - cursorSpacing: { - type: Number, - value: 50 - }, - maxlength: { - type: Number, - value: -1 - }, - type: { - type: String, - value: 'text' - }, - border: { - type: Boolean, - value: true - }, - titleWidth: { - type: String, - value: '90px' - } + field: true, + classes: ['input-class'], + props: { + icon: String, + label: String, + error: Boolean, + focus: Boolean, + center: Boolean, + isLink: Boolean, + leftIcon: String, + disabled: Boolean, + autosize: Boolean, + readonly: Boolean, + required: Boolean, + iconClass: String, + clearable: Boolean, + inputAlign: String, + customClass: String, + confirmType: String, + errorMessage: String, + placeholder: String, + customStyle: String, + useIconSlot: Boolean, + useButtonSlot: Boolean, + placeholderClass: String, + cursorSpacing: { + type: Number, + value: 50 }, - data: { - showClear: false + maxlength: { + type: Number, + value: -1 }, - computed: { - inputClass() { - const { data } = this; - return this.classNames('input-class', 'van-field__input', { - 'van-field--error': data.error, - 'van-field__textarea': data.type === 'textarea', - 'van-field__input--disabled': data.disabled, - [`van-field--${data.inputAlign}`]: data.inputAlign - }); - } + type: { + type: String, + value: 'text' }, - beforeCreate() { - this.focused = false; + border: { + type: Boolean, + value: true }, - methods: { - onInput(event) { - const { value = '' } = event.detail || {}; - this.$emit('input', value); - this.$emit('change', value); - this.setData({ - value, - showClear: this.getShowClear(value) - }); - }, - onFocus() { - this.$emit('focus'); - this.focused = true; - this.setData({ - showClear: this.getShowClear() - }); - }, - onBlur() { - this.focused = false; - this.$emit('blur'); - this.setData({ - showClear: this.getShowClear() - }); - }, - onClickIcon() { - this.$emit('click-icon'); - }, - getShowClear(value) { - value = value === undefined ? this.data.value : value; - return (this.data.clearable && this.focused && value && !this.data.readonly); - }, - onClear() { - this.setData({ - value: '', - showClear: this.getShowClear('') - }); - this.$emit('input', ''); - this.$emit('change', ''); - }, - onConfirm() { - this.$emit('confirm', this.data.value); - } + titleWidth: { + type: String, + value: '90px' } -}); + }, + data: { + showClear: false + }, + computed: { + inputClass: function inputClass() { + var _this$classNames; + + var data = this.data; + return this.classNames('input-class', 'van-field__input', (_this$classNames = { + 'van-field--error': data.error, + 'van-field__textarea': data.type === 'textarea', + 'van-field__input--disabled': data.disabled + }, _this$classNames["van-field--" + data.inputAlign] = data.inputAlign, _this$classNames)); + } + }, + beforeCreate: function beforeCreate() { + this.focused = false; + }, + methods: { + onInput: function onInput(event) { + var _ref = event.detail || {}, + _ref$value = _ref.value, + value = _ref$value === void 0 ? '' : _ref$value; + + this.$emit('input', value); + this.$emit('change', value); + this.setData({ + value: value, + showClear: this.getShowClear(value) + }); + }, + onFocus: function onFocus() { + this.$emit('focus'); + this.focused = true; + this.setData({ + showClear: this.getShowClear() + }); + }, + onBlur: function onBlur() { + this.focused = false; + this.$emit('blur'); + this.setData({ + showClear: this.getShowClear() + }); + }, + onClickIcon: function onClickIcon() { + this.$emit('click-icon'); + }, + getShowClear: function getShowClear(value) { + value = value === undefined ? this.data.value : value; + return this.data.clearable && this.focused && value && !this.data.readonly; + }, + onClear: function onClear() { + this.setData({ + value: '', + showClear: this.getShowClear('') + }); + this.$emit('input', ''); + this.$emit('change', ''); + }, + onConfirm: function onConfirm() { + this.$emit('confirm', this.data.value); + } + } +}); \ No newline at end of file diff --git a/dist/icon/index.js b/dist/icon/index.js index a8b14448..b59cda11 100644 --- a/dist/icon/index.js +++ b/dist/icon/index.js @@ -1,18 +1,18 @@ import { VantComponent } from '../common/component'; VantComponent({ - props: { - info: null, - name: String, - size: String, - color: String, - classPrefix: { - type: String, - value: 'van-icon' - } - }, - methods: { - onClick() { - this.$emit('click'); - } + props: { + info: null, + name: String, + size: String, + color: String, + classPrefix: { + type: String, + value: 'van-icon' } -}); + }, + methods: { + onClick: function onClick() { + this.$emit('click'); + } + } +}); \ No newline at end of file diff --git a/dist/loading/index.js b/dist/loading/index.js index 942b7a42..edb8360c 100644 --- a/dist/loading/index.js +++ b/dist/loading/index.js @@ -1,17 +1,17 @@ import { VantComponent } from '../common/component'; VantComponent({ - props: { - size: { - type: String, - value: '30px' - }, - type: { - type: String, - value: 'circular' - }, - color: { - type: String, - value: '#c9c9c9' - } + props: { + size: { + type: String, + value: '30px' + }, + type: { + type: String, + value: 'circular' + }, + color: { + type: String, + value: '#c9c9c9' } -}); + } +}); \ No newline at end of file diff --git a/dist/mixins/basic.js b/dist/mixins/basic.js index 3b9e5d50..1c8b37b4 100644 --- a/dist/mixins/basic.js +++ b/dist/mixins/basic.js @@ -1,24 +1,24 @@ import { classNames } from '../common/class-names'; -export const basic = Behavior({ - methods: { - classNames, - $emit() { - this.triggerEvent.apply(this, arguments); - }, - getRect(selector, all) { - return new Promise(resolve => { - wx.createSelectorQuery() - .in(this)[all ? 'selectAll' : 'select'](selector) - .boundingClientRect(rect => { - if (all && Array.isArray(rect) && rect.length) { - resolve(rect); - } - if (!all && rect) { - resolve(rect); - } - }) - .exec(); - }); - } +export var basic = Behavior({ + methods: { + classNames: classNames, + $emit: function $emit() { + this.triggerEvent.apply(this, arguments); + }, + getRect: function getRect(selector, all) { + var _this = this; + + return new Promise(function (resolve) { + wx.createSelectorQuery().in(_this)[all ? 'selectAll' : 'select'](selector).boundingClientRect(function (rect) { + if (all && Array.isArray(rect) && rect.length) { + resolve(rect); + } + + if (!all && rect) { + resolve(rect); + } + }).exec(); + }); } -}); + } +}); \ No newline at end of file diff --git a/dist/mixins/button.js b/dist/mixins/button.js index 4fbeec96..9e0dc31e 100644 --- a/dist/mixins/button.js +++ b/dist/mixins/button.js @@ -1,27 +1,27 @@ -export const button = Behavior({ - properties: { - id: String, - appParameter: String, - sendMessageTitle: String, - sendMessagePath: String, - sendMessageImg: String, - showMessageCard: String, - hoverStopPropagation: Boolean, - hoverStartTime: { - type: Number, - value: 20 - }, - hoverStayTime: { - type: Number, - value: 70 - }, - lang: { - type: String, - value: 'en' - }, - sessionFrom: { - type: String, - value: '' - } +export var button = Behavior({ + properties: { + id: String, + appParameter: String, + sendMessageTitle: String, + sendMessagePath: String, + sendMessageImg: String, + showMessageCard: String, + hoverStopPropagation: Boolean, + hoverStartTime: { + type: Number, + value: 20 + }, + hoverStayTime: { + type: Number, + value: 70 + }, + lang: { + type: String, + value: 'en' + }, + sessionFrom: { + type: String, + value: '' } -}); + } +}); \ No newline at end of file diff --git a/dist/mixins/observer/behavior.js b/dist/mixins/observer/behavior.js index d8efcf26..df389b5a 100644 --- a/dist/mixins/observer/behavior.js +++ b/dist/mixins/observer/behavior.js @@ -1,29 +1,41 @@ -export const behavior = Behavior({ - created() { - if (!this.$options) { - return; - } - const cache = {}; - const { setData } = this; - const { computed } = this.$options(); - const keys = Object.keys(computed); - const calcComputed = () => { - const needUpdate = {}; - keys.forEach(key => { - const value = computed[key].call(this); - if (cache[key] !== value) { - cache[key] = needUpdate[key] = value; - } - }); - return needUpdate; - }; - Object.defineProperty(this, 'setData', { writable: true }); - this.setData = (data, callback) => { - data && setData.call(this, data, callback); - setData.call(this, calcComputed()); - }; - }, - attached() { - this.setData(); +export var behavior = Behavior({ + created: function created() { + var _this = this; + + if (!this.$options) { + return; } -}); + + var cache = {}; + var setData = this.setData; + + var _this$$options = this.$options(), + computed = _this$$options.computed; + + var keys = Object.keys(computed); + + var calcComputed = function calcComputed() { + var needUpdate = {}; + keys.forEach(function (key) { + var value = computed[key].call(_this); + + if (cache[key] !== value) { + cache[key] = needUpdate[key] = value; + } + }); + return needUpdate; + }; + + Object.defineProperty(this, 'setData', { + writable: true + }); + + this.setData = function (data, callback) { + data && setData.call(_this, data, callback); + setData.call(_this, calcComputed()); + }; + }, + attached: function attached() { + this.setData(); + } +}); \ No newline at end of file diff --git a/dist/mixins/observer/index.js b/dist/mixins/observer/index.js index 247ea08f..487f2a48 100644 --- a/dist/mixins/observer/index.js +++ b/dist/mixins/observer/index.js @@ -1,27 +1,38 @@ import { behavior } from './behavior'; import { observeProps } from './props'; export function observe(vantOptions, options) { - const { watch, computed } = vantOptions; - if (watch) { - const props = options.properties || {}; - Object.keys(watch).forEach(key => { - if (key in props) { - let prop = props[key]; - if (prop === null || !prop.type) { - prop = { type: prop }; - } - prop.observer = watch[key]; - props[key] = prop; - } - }); - options.properties = props; - } - if (computed) { - options.behaviors.push(behavior); - options.methods = options.methods || {}; - options.methods.$options = () => vantOptions; - if (options.properties) { - observeProps(options.properties); + var watch = vantOptions.watch, + computed = vantOptions.computed; + + if (watch) { + var props = options.properties || {}; + Object.keys(watch).forEach(function (key) { + if (key in props) { + var prop = props[key]; + + if (prop === null || !prop.type) { + prop = { + type: prop + }; } + + prop.observer = watch[key]; + props[key] = prop; + } + }); + options.properties = props; + } + + if (computed) { + options.behaviors.push(behavior); + options.methods = options.methods || {}; + + options.methods.$options = function () { + return vantOptions; + }; + + if (options.properties) { + observeProps(options.properties); } -} + } +} \ No newline at end of file diff --git a/dist/mixins/observer/props.js b/dist/mixins/observer/props.js index ed74410d..254cfffd 100644 --- a/dist/mixins/observer/props.js +++ b/dist/mixins/observer/props.js @@ -1,22 +1,32 @@ export function observeProps(props) { - if (!props) { - return; + if (!props) { + return; + } + + Object.keys(props).forEach(function (key) { + var prop = props[key]; + + if (prop === null || !prop.type) { + prop = { + type: prop + }; } - Object.keys(props).forEach(key => { - let prop = props[key]; - if (prop === null || !prop.type) { - prop = { type: prop }; + + var _prop = prop, + observer = _prop.observer; + + prop.observer = function () { + if (observer) { + if (typeof observer === 'string') { + observer = this[observer]; } - let { observer } = prop; - prop.observer = function () { - if (observer) { - if (typeof observer === 'string') { - observer = this[observer]; - } - observer.apply(this, arguments); - } - this.setData(); - }; - props[key] = prop; - }); -} + + observer.apply(this, arguments); + } + + this.setData(); + }; + + props[key] = prop; + }); +} \ No newline at end of file diff --git a/dist/mixins/open-type.js b/dist/mixins/open-type.js index 2c2af784..98f09bb9 100644 --- a/dist/mixins/open-type.js +++ b/dist/mixins/open-type.js @@ -1,22 +1,22 @@ -export const openType = Behavior({ - properties: { - openType: String +export var openType = Behavior({ + properties: { + openType: String + }, + methods: { + bindGetUserInfo: function bindGetUserInfo(event) { + this.$emit('getuserinfo', event.detail); }, - methods: { - bindGetUserInfo(event) { - this.$emit('getuserinfo', event.detail); - }, - bindContact(event) { - this.$emit('contact', event.detail); - }, - bindGetPhoneNumber(event) { - this.$emit('getphonenumber', event.detail); - }, - bindOpenSetting(event) { - this.$emit('opensetting', event.detail); - }, - bindError(event) { - this.$emit('error', event.detail); - } + bindContact: function bindContact(event) { + this.$emit('contact', event.detail); + }, + bindGetPhoneNumber: function bindGetPhoneNumber(event) { + this.$emit('getphonenumber', event.detail); + }, + bindOpenSetting: function bindOpenSetting(event) { + this.$emit('opensetting', event.detail); + }, + bindError: function bindError(event) { + this.$emit('error', event.detail); } -}); + } +}); \ No newline at end of file diff --git a/dist/mixins/touch.js b/dist/mixins/touch.js index 5efa9dda..c31559bb 100644 --- a/dist/mixins/touch.js +++ b/dist/mixins/touch.js @@ -1,21 +1,21 @@ -export const touch = Behavior({ - methods: { - touchStart(event) { - this.direction = ''; - this.deltaX = 0; - this.deltaY = 0; - this.offsetX = 0; - this.offsetY = 0; - this.startX = event.touches[0].clientX; - this.startY = event.touches[0].clientY; - }, - touchMove(event) { - const touch = event.touches[0]; - this.deltaX = touch.clientX - this.startX; - this.deltaY = touch.clientY - this.startY; - this.offsetX = Math.abs(this.deltaX); - this.offsetY = Math.abs(this.deltaY); - this.direction = this.offsetX > this.offsetY ? 'horizontal' : this.offsetX < this.offsetY ? 'vertical' : ''; - } +export var touch = Behavior({ + methods: { + touchStart: function touchStart(event) { + this.direction = ''; + this.deltaX = 0; + this.deltaY = 0; + this.offsetX = 0; + this.offsetY = 0; + this.startX = event.touches[0].clientX; + this.startY = event.touches[0].clientY; + }, + touchMove: function touchMove(event) { + var touch = event.touches[0]; + this.deltaX = touch.clientX - this.startX; + this.deltaY = touch.clientY - this.startY; + this.offsetX = Math.abs(this.deltaX); + this.offsetY = Math.abs(this.deltaY); + this.direction = this.offsetX > this.offsetY ? 'horizontal' : this.offsetX < this.offsetY ? 'vertical' : ''; } -}); + } +}); \ No newline at end of file diff --git a/dist/mixins/transition.js b/dist/mixins/transition.js index 7e427e97..4c43bb48 100644 --- a/dist/mixins/transition.js +++ b/dist/mixins/transition.js @@ -1,52 +1,51 @@ -export const transition = function (showDefaultValue) { - return Behavior({ - properties: { - customStyle: String, - show: { - type: Boolean, - value: showDefaultValue, - observer: 'observeShow' - }, - duration: { - type: Number, - value: 300 - } - }, - data: { - type: '', - inited: false, - display: false - }, - attached() { - if (this.data.show) { - this.show(); - } - }, - methods: { - observeShow(value) { - if (value) { - this.show(); - } - else { - this.setData({ - type: 'leave' - }); - } - }, - show() { - this.setData({ - inited: true, - display: true, - type: 'enter' - }); - }, - onAnimationEnd() { - if (!this.data.show) { - this.setData({ - display: false - }); - } - } +export var transition = function transition(showDefaultValue) { + return Behavior({ + properties: { + customStyle: String, + show: { + type: Boolean, + value: showDefaultValue, + observer: 'observeShow' + }, + duration: { + type: Number, + value: 300 + } + }, + data: { + type: '', + inited: false, + display: false + }, + attached: function attached() { + if (this.data.show) { + this.show(); + } + }, + methods: { + observeShow: function observeShow(value) { + if (value) { + this.show(); + } else { + this.setData({ + type: 'leave' + }); } - }); -}; + }, + show: function show() { + this.setData({ + inited: true, + display: true, + type: 'enter' + }); + }, + onAnimationEnd: function onAnimationEnd() { + if (!this.data.show) { + this.setData({ + display: false + }); + } + } + } + }); +}; \ No newline at end of file diff --git a/dist/nav-bar/index.js b/dist/nav-bar/index.js index f1091096..aad78da6 100644 --- a/dist/nav-bar/index.js +++ b/dist/nav-bar/index.js @@ -1,23 +1,23 @@ import { VantComponent } from '../common/component'; VantComponent({ - classes: ['title-class'], - props: { - title: String, - leftText: String, - rightText: String, - leftArrow: Boolean, - fixed: Boolean, - zIndex: { - type: Number, - value: 1 - } - }, - methods: { - onClickLeft() { - this.$emit('click-left'); - }, - onClickRight() { - this.$emit('click-right'); - } + classes: ['title-class'], + props: { + title: String, + leftText: String, + rightText: String, + leftArrow: Boolean, + fixed: Boolean, + zIndex: { + type: Number, + value: 1 } -}); + }, + methods: { + onClickLeft: function onClickLeft() { + this.$emit('click-left'); + }, + onClickRight: function onClickRight() { + this.$emit('click-right'); + } + } +}); \ No newline at end of file diff --git a/dist/notice-bar/index.js b/dist/notice-bar/index.js index dd3ff015..9304483f 100644 --- a/dist/notice-bar/index.js +++ b/dist/notice-bar/index.js @@ -1,142 +1,160 @@ import { VantComponent } from '../common/component'; -const FONT_COLOR = '#f60'; -const BG_COLOR = '#fff7cc'; +var FONT_COLOR = '#f60'; +var BG_COLOR = '#fff7cc'; VantComponent({ - props: { - text: { - type: String, - value: '' - }, - mode: { - type: String, - value: '' - }, - url: { - type: String, - value: '' - }, - openType: { - type: String, - value: 'navigate' - }, - delay: { - type: Number, - value: 0 - }, - speed: { - type: Number, - value: 50 - }, - scrollable: { - type: Boolean, - value: true - }, - leftIcon: { - type: String, - value: '' - }, - color: { - type: String, - value: FONT_COLOR - }, - backgroundColor: { - type: String, - value: BG_COLOR - } + props: { + text: { + type: String, + value: '' }, - data: { - show: true, - hasRightIcon: false, - width: undefined, - wrapWidth: undefined, - elapse: undefined, - animation: null, - resetAnimation: null, - timer: null + mode: { + type: String, + value: '' }, - watch: { - text() { - this.setData({}, this.init); - } + url: { + type: String, + value: '' }, - created() { - if (this.data.mode) { - this.setData({ - hasRightIcon: true - }); - } + openType: { + type: String, + value: 'navigate' }, - destroyed() { - const { timer } = this.data; - timer && clearTimeout(timer); + delay: { + type: Number, + value: 0 }, - methods: { - init() { - this.getRect('.van-notice-bar__content').then(rect => { - if (!rect || !rect.width) { - return; - } - this.setData({ - width: rect.width - }); - this.getRect('.van-notice-bar__content-wrap').then(rect => { - if (!rect || !rect.width) { - return; - } - const wrapWidth = rect.width; - const { width, speed, scrollable, delay } = this.data; - if (scrollable && wrapWidth < width) { - const elapse = width / speed * 1000; - const animation = wx.createAnimation({ - duration: elapse, - timeingFunction: 'linear', - delay - }); - const resetAnimation = wx.createAnimation({ - duration: 0, - timeingFunction: 'linear' - }); - this.setData({ - elapse, - wrapWidth, - animation, - resetAnimation - }, () => { - this.scroll(); - }); - } - }); - }); - }, - scroll() { - const { animation, resetAnimation, wrapWidth, elapse, speed } = this.data; - resetAnimation.translateX(wrapWidth).step(); - const animationData = animation.translateX(-(elapse * speed) / 1000).step(); - this.setData({ - animationData: resetAnimation.export() - }); - setTimeout(() => { - this.setData({ - animationData: animationData.export() - }); - }, 100); - const timer = setTimeout(() => { - this.scroll(); - }, elapse); - this.setData({ - timer - }); - }, - onClickIcon() { - const { timer } = this.data; - timer && clearTimeout(timer); - this.setData({ - show: false, - timer: null - }); - }, - onClick(event) { - this.$emit('click', event); - } + speed: { + type: Number, + value: 50 + }, + scrollable: { + type: Boolean, + value: true + }, + leftIcon: { + type: String, + value: '' + }, + color: { + type: String, + value: FONT_COLOR + }, + backgroundColor: { + type: String, + value: BG_COLOR } -}); + }, + data: { + show: true, + hasRightIcon: false, + width: undefined, + wrapWidth: undefined, + elapse: undefined, + animation: null, + resetAnimation: null, + timer: null + }, + watch: { + text: function text() { + this.setData({}, this.init); + } + }, + created: function created() { + if (this.data.mode) { + this.setData({ + hasRightIcon: true + }); + } + }, + destroyed: function destroyed() { + var timer = this.data.timer; + timer && clearTimeout(timer); + }, + methods: { + init: function init() { + var _this = this; + + this.getRect('.van-notice-bar__content').then(function (rect) { + if (!rect || !rect.width) { + return; + } + + _this.setData({ + width: rect.width + }); + + _this.getRect('.van-notice-bar__content-wrap').then(function (rect) { + if (!rect || !rect.width) { + return; + } + + var wrapWidth = rect.width; + var _this$data = _this.data, + width = _this$data.width, + speed = _this$data.speed, + scrollable = _this$data.scrollable, + delay = _this$data.delay; + + if (scrollable && wrapWidth < width) { + var elapse = width / speed * 1000; + var animation = wx.createAnimation({ + duration: elapse, + timeingFunction: 'linear', + delay: delay + }); + var resetAnimation = wx.createAnimation({ + duration: 0, + timeingFunction: 'linear' + }); + + _this.setData({ + elapse: elapse, + wrapWidth: wrapWidth, + animation: animation, + resetAnimation: resetAnimation + }, function () { + _this.scroll(); + }); + } + }); + }); + }, + scroll: function scroll() { + var _this2 = this; + + var _this$data2 = this.data, + animation = _this$data2.animation, + resetAnimation = _this$data2.resetAnimation, + wrapWidth = _this$data2.wrapWidth, + elapse = _this$data2.elapse, + speed = _this$data2.speed; + resetAnimation.translateX(wrapWidth).step(); + var animationData = animation.translateX(-(elapse * speed) / 1000).step(); + this.setData({ + animationData: resetAnimation.export() + }); + setTimeout(function () { + _this2.setData({ + animationData: animationData.export() + }); + }, 100); + var timer = setTimeout(function () { + _this2.scroll(); + }, elapse); + this.setData({ + timer: timer + }); + }, + onClickIcon: function onClickIcon() { + var timer = this.data.timer; + timer && clearTimeout(timer); + this.setData({ + show: false, + timer: null + }); + }, + onClick: function onClick(event) { + this.$emit('click', event); + } + } +}); \ No newline at end of file diff --git a/dist/notify/index.js b/dist/notify/index.js index 29bcbf3a..4e6a00b7 100644 --- a/dist/notify/index.js +++ b/dist/notify/index.js @@ -1,38 +1,41 @@ import { VantComponent } from '../common/component'; VantComponent({ - props: { - text: String, - color: { - type: String, - value: '#fff' - }, - backgroundColor: { - type: String, - value: '#e64340' - }, - duration: { - type: Number, - value: 3000 - } + props: { + text: String, + color: { + type: String, + value: '#fff' }, - methods: { - show() { - const { duration } = this.data; - clearTimeout(this.timer); - this.setData({ - show: true - }); - if (duration > 0 && duration !== Infinity) { - this.timer = setTimeout(() => { - this.hide(); - }, duration); - } - }, - hide() { - clearTimeout(this.timer); - this.setData({ - show: false - }); - } + backgroundColor: { + type: String, + value: '#e64340' + }, + duration: { + type: Number, + value: 3000 } -}); + }, + methods: { + show: function show() { + var _this = this; + + var duration = this.data.duration; + clearTimeout(this.timer); + this.setData({ + show: true + }); + + if (duration > 0 && duration !== Infinity) { + this.timer = setTimeout(function () { + _this.hide(); + }, duration); + } + }, + hide: function hide() { + clearTimeout(this.timer); + this.setData({ + show: false + }); + } + } +}); \ No newline at end of file diff --git a/dist/notify/notify.js b/dist/notify/notify.js index de7dfcee..200be60d 100644 --- a/dist/notify/notify.js +++ b/dist/notify/notify.js @@ -1,19 +1,28 @@ import { isObj } from '../common/utils'; -const defaultOptions = { - selector: '#van-notify', - duration: 3000 +var defaultOptions = { + selector: '#van-notify', + duration: 3000 }; + function parseOptions(text) { - return isObj(text) ? text : { text }; -} -export default function Notify(options = {}) { - const pages = getCurrentPages(); - const ctx = pages[pages.length - 1]; - options = Object.assign({}, defaultOptions, parseOptions(options)); - const el = ctx.selectComponent(options.selector); - delete options.selector; - if (el) { - el.setData(options); - el.show(); - } + return isObj(text) ? text : { + text: text + }; } + +export default function Notify(options) { + if (options === void 0) { + options = {}; + } + + var pages = getCurrentPages(); + var ctx = pages[pages.length - 1]; + options = Object.assign({}, defaultOptions, parseOptions(options)); + var el = ctx.selectComponent(options.selector); + delete options.selector; + + if (el) { + el.setData(options); + el.show(); + } +} \ No newline at end of file diff --git a/dist/overlay/index.js b/dist/overlay/index.js index 657e1abb..1b12e8ed 100644 --- a/dist/overlay/index.js +++ b/dist/overlay/index.js @@ -1,19 +1,19 @@ import { VantComponent } from '../common/component'; VantComponent({ - props: { - show: Boolean, - mask: Boolean, - customStyle: String, - zIndex: { - type: Number, - value: 1 - } - }, - methods: { - onClick() { - this.$emit('click'); - }, - // for prevent touchmove - noop() { } + props: { + show: Boolean, + mask: Boolean, + customStyle: String, + zIndex: { + type: Number, + value: 1 } -}); + }, + methods: { + onClick: function onClick() { + this.$emit('click'); + }, + // for prevent touchmove + noop: function noop() {} + } +}); \ No newline at end of file diff --git a/dist/panel/index.js b/dist/panel/index.js index 2d53c14e..f218a488 100644 --- a/dist/panel/index.js +++ b/dist/panel/index.js @@ -1,11 +1,11 @@ import { VantComponent } from '../common/component'; VantComponent({ - classes: ['footer-class'], - props: { - desc: String, - title: String, - status: String, - headerClass: String, - useFooterSlot: Boolean - } -}); + classes: ['footer-class'], + props: { + desc: String, + title: String, + status: String, + headerClass: String, + useFooterSlot: Boolean + } +}); \ No newline at end of file diff --git a/dist/popup/index.js b/dist/popup/index.js index 054151bb..4da92679 100644 --- a/dist/popup/index.js +++ b/dist/popup/index.js @@ -1,34 +1,35 @@ import { VantComponent } from '../common/component'; import { transition } from '../mixins/transition'; VantComponent({ - mixins: [transition(false)], - props: { - transition: String, - customStyle: String, - overlayStyle: String, - zIndex: { - type: Number, - value: 100 - }, - overlay: { - type: Boolean, - value: true - }, - closeOnClickOverlay: { - type: Boolean, - value: true - }, - position: { - type: String, - value: 'center' - } + mixins: [transition(false)], + props: { + transition: String, + customStyle: String, + overlayStyle: String, + zIndex: { + type: Number, + value: 100 }, - methods: { - onClickOverlay() { - this.$emit('click-overlay'); - if (this.data.closeOnClickOverlay) { - this.$emit('close'); - } - } + overlay: { + type: Boolean, + value: true + }, + closeOnClickOverlay: { + type: Boolean, + value: true + }, + position: { + type: String, + value: 'center' } -}); + }, + methods: { + onClickOverlay: function onClickOverlay() { + this.$emit('click-overlay'); + + if (this.data.closeOnClickOverlay) { + this.$emit('close'); + } + } + } +}); \ No newline at end of file diff --git a/dist/progress/index.js b/dist/progress/index.js index 0fc54476..b915555c 100644 --- a/dist/progress/index.js +++ b/dist/progress/index.js @@ -1,64 +1,66 @@ import { VantComponent } from '../common/component'; VantComponent({ - props: { - inactive: Boolean, - percentage: Number, - pivotText: String, - pivotColor: String, - showPivot: { - type: Boolean, - value: true - }, - color: { - type: String, - value: '#38f' - }, - textColor: { - type: String, - value: '#fff' - } + props: { + inactive: Boolean, + percentage: Number, + pivotText: String, + pivotColor: String, + showPivot: { + type: Boolean, + value: true }, - data: { - pivotWidth: 0, - progressWidth: 0 + color: { + type: String, + value: '#38f' }, - watch: { - pivotText: 'getWidth', - showPivot: 'getWidth' - }, - computed: { - portionStyle() { - const width = (this.data.progressWidth - this.data.pivotWidth) * this.data.percentage / 100 + 'px'; - const background = this.getCurrentColor(); - return `width: ${width}; background: ${background}; `; - }, - pivotStyle() { - const color = this.data.textColor; - const background = this.data.pivotColor || this.getCurrentColor(); - return `color: ${color}; background: ${background}`; - }, - text() { - return this.data.pivotText || this.data.percentage + '%'; - } - }, - mounted() { - this.getWidth(); - }, - methods: { - getCurrentColor() { - return this.data.inactive ? '#cacaca' : this.data.color; - }, - getWidth() { - this.getRect('.van-progress').then(rect => { - this.setData({ - progressWidth: rect.width - }); - }); - this.getRect('.van-progress__pivot').then(rect => { - this.setData({ - pivotWidth: rect.width || 0 - }); - }); - } + textColor: { + type: String, + value: '#fff' } -}); + }, + data: { + pivotWidth: 0, + progressWidth: 0 + }, + watch: { + pivotText: 'getWidth', + showPivot: 'getWidth' + }, + computed: { + portionStyle: function portionStyle() { + var width = (this.data.progressWidth - this.data.pivotWidth) * this.data.percentage / 100 + 'px'; + var background = this.getCurrentColor(); + return "width: " + width + "; background: " + background + "; "; + }, + pivotStyle: function pivotStyle() { + var color = this.data.textColor; + var background = this.data.pivotColor || this.getCurrentColor(); + return "color: " + color + "; background: " + background; + }, + text: function text() { + return this.data.pivotText || this.data.percentage + '%'; + } + }, + mounted: function mounted() { + this.getWidth(); + }, + methods: { + getCurrentColor: function getCurrentColor() { + return this.data.inactive ? '#cacaca' : this.data.color; + }, + getWidth: function getWidth() { + var _this = this; + + this.getRect('.van-progress').then(function (rect) { + _this.setData({ + progressWidth: rect.width + }); + }); + this.getRect('.van-progress__pivot').then(function (rect) { + _this.setData({ + pivotWidth: rect.width || 0 + }); + }); + } + } +}); \ No newline at end of file diff --git a/dist/radio-group/index.js b/dist/radio-group/index.js index 6dfbb71f..aab92a33 100644 --- a/dist/radio-group/index.js +++ b/dist/radio-group/index.js @@ -1,32 +1,38 @@ import { VantComponent } from '../common/component'; VantComponent({ - relation: { - name: 'radio', - type: 'descendant', - linked(target) { - const { value, disabled } = this.data; - target.setData({ - value: value, - disabled: disabled || target.data.disabled - }); - } - }, - props: { - value: null, - disabled: Boolean - }, - watch: { - value(value) { - const children = this.getRelationNodes('../radio/index'); - children.forEach(child => { - child.setData({ value }); - }); - }, - disabled(disabled) { - const children = this.getRelationNodes('../radio/index'); - children.forEach(child => { - child.setData({ disabled: disabled || child.data.disabled }); - }); - } + relation: { + name: 'radio', + type: 'descendant', + linked: function linked(target) { + var _this$data = this.data, + value = _this$data.value, + disabled = _this$data.disabled; + target.setData({ + value: value, + disabled: disabled || target.data.disabled + }); } -}); + }, + props: { + value: null, + disabled: Boolean + }, + watch: { + value: function value(_value) { + var children = this.getRelationNodes('../radio/index'); + children.forEach(function (child) { + child.setData({ + value: _value + }); + }); + }, + disabled: function disabled(_disabled) { + var children = this.getRelationNodes('../radio/index'); + children.forEach(function (child) { + child.setData({ + disabled: _disabled || child.data.disabled + }); + }); + } + } +}); \ No newline at end of file diff --git a/dist/radio/index.js b/dist/radio/index.js index a95272ce..47687634 100644 --- a/dist/radio/index.js +++ b/dist/radio/index.js @@ -1,40 +1,43 @@ import { VantComponent } from '../common/component'; VantComponent({ - relation: { - name: 'radio-group', - type: 'ancestor' - }, - classes: ['icon-class', 'label-class'], - props: { - name: null, - value: null, - disabled: Boolean, - labelDisabled: Boolean, - labelPosition: String - }, - computed: { - iconClass() { - const { disabled, name, value } = this.data; - return this.classNames('van-radio__icon', { - 'van-radio__icon--disabled': disabled, - 'van-radio__icon--checked': !disabled && name === value, - 'van-radio__icon--check': !disabled && name !== value - }); - } - }, - methods: { - emitChange(value) { - const instance = this.getRelationNodes('../radio-group/index')[0] || this; - instance.$emit('input', value); - instance.$emit('change', value); - }, - onChange(event) { - this.emitChange(event.detail.value); - }, - onClickLabel() { - if (!this.data.disabled && !this.data.labelDisabled) { - this.emitChange(this.data.name); - } - } + relation: { + name: 'radio-group', + type: 'ancestor' + }, + classes: ['icon-class', 'label-class'], + props: { + name: null, + value: null, + disabled: Boolean, + labelDisabled: Boolean, + labelPosition: String + }, + computed: { + iconClass: function iconClass() { + var _this$data = this.data, + disabled = _this$data.disabled, + name = _this$data.name, + value = _this$data.value; + return this.classNames('van-radio__icon', { + 'van-radio__icon--disabled': disabled, + 'van-radio__icon--checked': !disabled && name === value, + 'van-radio__icon--check': !disabled && name !== value + }); } -}); + }, + methods: { + emitChange: function emitChange(value) { + var instance = this.getRelationNodes('../radio-group/index')[0] || this; + instance.$emit('input', value); + instance.$emit('change', value); + }, + onChange: function onChange(event) { + this.emitChange(event.detail.value); + }, + onClickLabel: function onClickLabel() { + if (!this.data.disabled && !this.data.labelDisabled) { + this.emitChange(this.data.name); + } + } + } +}); \ No newline at end of file diff --git a/dist/row/index.js b/dist/row/index.js index d7c8ba46..3c8d9aa7 100644 --- a/dist/row/index.js +++ b/dist/row/index.js @@ -1,36 +1,38 @@ import { VantComponent } from '../common/component'; VantComponent({ - relation: { - name: 'col', - type: 'descendant', - linked(target) { - if (this.data.gutter) { - target.setGutter(this.data.gutter); - } - } - }, - props: { - gutter: Number - }, - watch: { - gutter: 'setGutter' - }, - mounted() { - if (this.data.gutter) { - this.setGutter(); - } - }, - methods: { - setGutter() { - const { gutter } = this.data; - const margin = `-${Number(gutter) / 2}px`; - const style = gutter - ? `margin-right: ${margin}; margin-left: ${margin};` - : ''; - this.setData({ style }); - this.getRelationNodes('../col/index').forEach(col => { - col.setGutter(this.data.gutter); - }); - } + relation: { + name: 'col', + type: 'descendant', + linked: function linked(target) { + if (this.data.gutter) { + target.setGutter(this.data.gutter); + } } -}); + }, + props: { + gutter: Number + }, + watch: { + gutter: 'setGutter' + }, + mounted: function mounted() { + if (this.data.gutter) { + this.setGutter(); + } + }, + methods: { + setGutter: function setGutter() { + var _this = this; + + var gutter = this.data.gutter; + var margin = "-" + Number(gutter) / 2 + "px"; + var style = gutter ? "margin-right: " + margin + "; margin-left: " + margin + ";" : ''; + this.setData({ + style: style + }); + this.getRelationNodes('../col/index').forEach(function (col) { + col.setGutter(_this.data.gutter); + }); + } + } +}); \ No newline at end of file diff --git a/dist/search/index.js b/dist/search/index.js index 9ac15eb5..ea774eee 100644 --- a/dist/search/index.js +++ b/dist/search/index.js @@ -1,41 +1,45 @@ import { VantComponent } from '../common/component'; VantComponent({ - field: true, - classes: ['cancel-class'], - props: { - focus: Boolean, - disabled: Boolean, - readonly: Boolean, - showAction: Boolean, - useActionSlot: Boolean, - placeholder: String, - background: { - type: String, - value: '#f2f2f2' - }, - maxlength: { - type: Number, - value: -1 - } + field: true, + classes: ['cancel-class'], + props: { + focus: Boolean, + disabled: Boolean, + readonly: Boolean, + showAction: Boolean, + useActionSlot: Boolean, + placeholder: String, + background: { + type: String, + value: '#f2f2f2' }, - methods: { - onChange(event) { - this.setData({ value: event.detail }); - this.$emit('change', event.detail); - }, - onCancel() { - this.setData({ value: '' }); - this.$emit('cancel'); - this.$emit('change', ''); - }, - onSearch() { - this.$emit('search', this.data.value); - }, - onFocus() { - this.$emit('focus'); - }, - onBlur() { - this.$emit('blur'); - } + maxlength: { + type: Number, + value: -1 } -}); + }, + methods: { + onChange: function onChange(event) { + this.setData({ + value: event.detail + }); + this.$emit('change', event.detail); + }, + onCancel: function onCancel() { + this.setData({ + value: '' + }); + this.$emit('cancel'); + this.$emit('change', ''); + }, + onSearch: function onSearch() { + this.$emit('search', this.data.value); + }, + onFocus: function onFocus() { + this.$emit('focus'); + }, + onBlur: function onBlur() { + this.$emit('blur'); + } + } +}); \ No newline at end of file diff --git a/dist/slider/index.js b/dist/slider/index.js index 70b0c7a3..0ae35ace 100644 --- a/dist/slider/index.js +++ b/dist/slider/index.js @@ -1,75 +1,81 @@ import { VantComponent } from '../common/component'; import { touch } from '../mixins/touch'; VantComponent({ - mixins: [touch], - props: { - disabled: Boolean, - max: { - type: Number, - value: 100 - }, - min: { - type: Number, - value: 0 - }, - step: { - type: Number, - value: 1 - }, - value: { - type: Number, - value: 0 - }, - barHeight: { - type: String, - value: '2px' - } + mixins: [touch], + props: { + disabled: Boolean, + max: { + type: Number, + value: 100 }, - created() { - this.updateValue(this.data.value); + min: { + type: Number, + value: 0 }, - methods: { - onTouchStart(event) { - if (this.data.disabled) - return; - this.touchStart(event); - this.startValue = this.format(this.data.value); - }, - onTouchMove(event) { - if (this.data.disabled) - return; - this.touchMove(event); - this.getRect('.van-slider').then(rect => { - const diff = this.deltaX / rect.width * 100; - this.updateValue(this.startValue + diff); - }); - }, - onTouchEnd() { - if (this.data.disabled) - return; - this.updateValue(this.data.value, true); - }, - onClick(event) { - if (this.data.disabled) - return; - this.getRect(rect => { - const value = (event.detail.x - rect.left) / rect.width * 100; - this.updateValue(value, true); - }); - }, - updateValue(value, end) { - value = this.format(value); - this.setData({ - value, - barStyle: `width: ${value}%; height: ${this.data.barHeight};` - }); - if (end) { - this.$emit('change', value); - } - }, - format(value) { - const { max, min, step } = this.data; - return Math.round(Math.max(min, Math.min(value, max)) / step) * step; - } + step: { + type: Number, + value: 1 + }, + value: { + type: Number, + value: 0 + }, + barHeight: { + type: String, + value: '2px' } -}); + }, + created: function created() { + this.updateValue(this.data.value); + }, + methods: { + onTouchStart: function onTouchStart(event) { + if (this.data.disabled) return; + this.touchStart(event); + this.startValue = this.format(this.data.value); + }, + onTouchMove: function onTouchMove(event) { + var _this = this; + + if (this.data.disabled) return; + this.touchMove(event); + this.getRect('.van-slider').then(function (rect) { + var diff = _this.deltaX / rect.width * 100; + + _this.updateValue(_this.startValue + diff); + }); + }, + onTouchEnd: function onTouchEnd() { + if (this.data.disabled) return; + this.updateValue(this.data.value, true); + }, + onClick: function onClick(event) { + var _this2 = this; + + if (this.data.disabled) return; + this.getRect(function (rect) { + var value = (event.detail.x - rect.left) / rect.width * 100; + + _this2.updateValue(value, true); + }); + }, + updateValue: function updateValue(value, end) { + value = this.format(value); + this.setData({ + value: value, + barStyle: "width: " + value + "%; height: " + this.data.barHeight + ";" + }); + + if (end) { + this.$emit('change', value); + } + }, + format: function format(value) { + var _this$data = this.data, + max = _this$data.max, + min = _this$data.min, + step = _this$data.step; + return Math.round(Math.max(min, Math.min(value, max)) / step) * step; + } + } +}); \ No newline at end of file diff --git a/dist/stepper/index.js b/dist/stepper/index.js index e64e0ecc..d1f80e27 100644 --- a/dist/stepper/index.js +++ b/dist/stepper/index.js @@ -1,69 +1,71 @@ -import { VantComponent } from '../common/component'; -// Note that the bitwise operators and shift operators operate on 32-bit ints +import { VantComponent } from '../common/component'; // Note that the bitwise operators and shift operators operate on 32-bit ints // so in that case, the max safe integer is 2^31-1, or 2147483647 -const MAX = 2147483647; + +var MAX = 2147483647; VantComponent({ - field: true, - classes: [ - 'input-class', - 'plus-class', - 'minus-class' - ], - props: { - integer: Boolean, - disabled: Boolean, - disableInput: Boolean, - min: { - type: null, - value: 1 - }, - max: { - type: null, - value: MAX - }, - step: { - type: null, - value: 1 - } + field: true, + classes: ['input-class', 'plus-class', 'minus-class'], + props: { + integer: Boolean, + disabled: Boolean, + disableInput: Boolean, + min: { + type: null, + value: 1 }, - created() { - this.setData({ - value: this.range(this.data.value) - }); + max: { + type: null, + value: MAX }, - methods: { - // limit value range - range(value) { - return Math.max(Math.min(this.data.max, value), this.data.min); - }, - onInput(event) { - const { value = '' } = event.detail || {}; - this.triggerInput(value); - }, - onChange(type) { - if (this[`${type}Disabled`]) { - this.$emit('overlimit', type); - return; - } - const diff = type === 'minus' ? -this.data.step : +this.data.step; - const value = Math.round((this.data.value + diff) * 100) / 100; - this.triggerInput(this.range(value)); - this.$emit(type); - }, - onBlur(event) { - const value = this.range(this.data.value); - this.triggerInput(value); - this.$emit('blur', event); - }, - onMinus() { - this.onChange('minus'); - }, - onPlus() { - this.onChange('plus'); - }, - triggerInput(value) { - this.setData({ value }); - this.$emit('change', value); - } + step: { + type: null, + value: 1 } -}); + }, + created: function created() { + this.setData({ + value: this.range(this.data.value) + }); + }, + methods: { + // limit value range + range: function range(value) { + return Math.max(Math.min(this.data.max, value), this.data.min); + }, + onInput: function onInput(event) { + var _ref = event.detail || {}, + _ref$value = _ref.value, + value = _ref$value === void 0 ? '' : _ref$value; + + this.triggerInput(value); + }, + onChange: function onChange(type) { + if (this[type + "Disabled"]) { + this.$emit('overlimit', type); + return; + } + + var diff = type === 'minus' ? -this.data.step : +this.data.step; + var value = Math.round((this.data.value + diff) * 100) / 100; + this.triggerInput(this.range(value)); + this.$emit(type); + }, + onBlur: function onBlur(event) { + var value = this.range(this.data.value); + this.triggerInput(value); + this.$emit('blur', event); + }, + onMinus: function onMinus() { + this.onChange('minus'); + }, + onPlus: function onPlus() { + this.onChange('plus'); + }, + triggerInput: function triggerInput(value) { + this.setData({ + value: value + }); + this.$emit('change', value); + } + } +}); \ No newline at end of file diff --git a/dist/steps/index.js b/dist/steps/index.js index d660600c..31d53985 100644 --- a/dist/steps/index.js +++ b/dist/steps/index.js @@ -1,42 +1,47 @@ import { VantComponent } from '../common/component'; VantComponent({ - props: { - icon: String, - steps: Array, - active: Number, - direction: { - type: String, - value: 'horizontal' - }, - activeColor: { - type: String, - value: '#06bf04' - } + props: { + icon: String, + steps: Array, + active: Number, + direction: { + type: String, + value: 'horizontal' }, - watch: { - steps: 'formatSteps', - active: 'formatSteps' - }, - created() { - this.formatSteps(); - }, - methods: { - formatSteps() { - const { steps } = this.data; - steps.forEach((step, index) => { - step.status = this.getStatus(index); - }); - this.setData({ steps }); - }, - getStatus(index) { - const { active } = this.data; - if (index < active) { - return 'finish'; - } - else if (index === active) { - return 'process'; - } - return ''; - } + activeColor: { + type: String, + value: '#06bf04' } -}); + }, + watch: { + steps: 'formatSteps', + active: 'formatSteps' + }, + created: function created() { + this.formatSteps(); + }, + methods: { + formatSteps: function formatSteps() { + var _this = this; + + var steps = this.data.steps; + steps.forEach(function (step, index) { + step.status = _this.getStatus(index); + }); + this.setData({ + steps: steps + }); + }, + getStatus: function getStatus(index) { + var active = this.data.active; + + if (index < active) { + return 'finish'; + } else if (index === active) { + return 'process'; + } + + return ''; + } + } +}); \ No newline at end of file diff --git a/dist/submit-bar/index.js b/dist/submit-bar/index.js index 8a2607f6..ca033e30 100644 --- a/dist/submit-bar/index.js +++ b/dist/submit-bar/index.js @@ -1,42 +1,38 @@ import { VantComponent } from '../common/component'; VantComponent({ - classes: [ - 'bar-class', - 'price-class', - 'button-class' - ], - props: { - tip: [String, Boolean], - type: Number, - price: null, - label: String, - loading: Boolean, - disabled: Boolean, - buttonText: String, - currency: { - type: String, - value: '¥' - }, - buttonType: { - type: String, - value: 'danger' - } + classes: ['bar-class', 'price-class', 'button-class'], + props: { + tip: [String, Boolean], + type: Number, + price: null, + label: String, + loading: Boolean, + disabled: Boolean, + buttonText: String, + currency: { + type: String, + value: '¥' }, - computed: { - hasPrice() { - return typeof this.data.price === 'number'; - }, - priceStr() { - return (this.data.price / 100).toFixed(2); - }, - tipStr() { - const { tip } = this.data; - return typeof tip === 'string' ? tip : ''; - } - }, - methods: { - onSubmit(event) { - this.$emit('submit', event.detail); - } + buttonType: { + type: String, + value: 'danger' } -}); + }, + computed: { + hasPrice: function hasPrice() { + return typeof this.data.price === 'number'; + }, + priceStr: function priceStr() { + return (this.data.price / 100).toFixed(2); + }, + tipStr: function tipStr() { + var tip = this.data.tip; + return typeof tip === 'string' ? tip : ''; + } + }, + methods: { + onSubmit: function onSubmit(event) { + this.$emit('submit', event.detail); + } + } +}); \ No newline at end of file diff --git a/dist/switch-cell/index.js b/dist/switch-cell/index.js index 8f355592..4da58634 100644 --- a/dist/switch-cell/index.js +++ b/dist/switch-cell/index.js @@ -1,28 +1,32 @@ import { VantComponent } from '../common/component'; VantComponent({ - field: true, - props: { - title: String, - border: Boolean, - checked: Boolean, - loading: Boolean, - disabled: Boolean, - size: { - type: String, - value: '26px' - } - }, - watch: { - checked(value) { - this.setData({ value }); - } - }, - created() { - this.setData({ value: this.data.checked }); - }, - methods: { - onChange(event) { - this.$emit('change', event.detail); - } + field: true, + props: { + title: String, + border: Boolean, + checked: Boolean, + loading: Boolean, + disabled: Boolean, + size: { + type: String, + value: '26px' } -}); + }, + watch: { + checked: function checked(value) { + this.setData({ + value: value + }); + } + }, + created: function created() { + this.setData({ + value: this.data.checked + }); + }, + methods: { + onChange: function onChange(event) { + this.$emit('change', event.detail); + } + } +}); \ No newline at end of file diff --git a/dist/switch/index.js b/dist/switch/index.js index adc4a53d..9923a547 100644 --- a/dist/switch/index.js +++ b/dist/switch/index.js @@ -1,31 +1,35 @@ import { VantComponent } from '../common/component'; VantComponent({ - field: true, - classes: ['node-class'], - props: { - checked: Boolean, - loading: Boolean, - disabled: Boolean, - size: { - type: String, - value: '30px' - } - }, - watch: { - checked(value) { - this.setData({ value }); - } - }, - created() { - this.setData({ value: this.data.checked }); - }, - methods: { - onClick() { - if (!this.data.disabled && !this.data.loading) { - const checked = !this.data.checked; - this.$emit('input', checked); - this.$emit('change', checked); - } - } + field: true, + classes: ['node-class'], + props: { + checked: Boolean, + loading: Boolean, + disabled: Boolean, + size: { + type: String, + value: '30px' } -}); + }, + watch: { + checked: function checked(value) { + this.setData({ + value: value + }); + } + }, + created: function created() { + this.setData({ + value: this.data.checked + }); + }, + methods: { + onClick: function onClick() { + if (!this.data.disabled && !this.data.loading) { + var checked = !this.data.checked; + this.$emit('input', checked); + this.$emit('change', checked); + } + } + } +}); \ No newline at end of file diff --git a/dist/tab/index.js b/dist/tab/index.js index 67da013b..276e9e0c 100644 --- a/dist/tab/index.js +++ b/dist/tab/index.js @@ -1,30 +1,32 @@ import { VantComponent } from '../common/component'; VantComponent({ - relation: { - name: 'tabs', - type: 'ancestor' + relation: { + name: 'tabs', + type: 'ancestor' + }, + props: { + title: String, + disabled: Boolean + }, + data: { + inited: false, + active: false + }, + watch: { + disabled: function disabled() { + var parent = this.getRelationNodes('../tabs/index')[0]; + + if (parent) { + parent.updateTabs(); + } }, - props: { - title: String, - disabled: Boolean - }, - data: { - inited: false, - active: false - }, - watch: { - disabled() { - const parent = this.getRelationNodes('../tabs/index')[0]; - if (parent) { - parent.updateTabs(); - } - }, - title() { - const parent = this.getRelationNodes('../tabs/index')[0]; - if (parent) { - parent.setLine(); - parent.updateTabs(); - } - } + title: function title() { + var parent = this.getRelationNodes('../tabs/index')[0]; + + if (parent) { + parent.setLine(); + parent.updateTabs(); + } } -}); + } +}); \ No newline at end of file diff --git a/dist/tabbar-item/index.js b/dist/tabbar-item/index.js index d0778bc9..440b936f 100644 --- a/dist/tabbar-item/index.js +++ b/dist/tabbar-item/index.js @@ -1,31 +1,36 @@ import { VantComponent } from '../common/component'; VantComponent({ - props: { - info: null, - icon: String, - dot: Boolean + props: { + info: null, + icon: String, + dot: Boolean + }, + relation: { + name: 'tabbar', + type: 'ancestor' + }, + data: { + active: false, + count: 0 + }, + methods: { + onClick: function onClick() { + var parent = this.getRelationNodes('../tabbar/index')[0]; + + if (parent) { + parent.onChange(this); + } + + this.$emit('click'); }, - relation: { - name: 'tabbar', - type: 'ancestor' - }, - data: { - active: false, - count: 0 - }, - methods: { - onClick() { - const parent = this.getRelationNodes('../tabbar/index')[0]; - if (parent) { - parent.onChange(this); - } - this.$emit('click'); - }, - setActive(data) { - const { active, count } = this.data; - if (active !== data.active || count !== data.count) { - this.setData(data); - } - } + setActive: function setActive(data) { + var _this$data = this.data, + active = _this$data.active, + count = _this$data.count; + + if (active !== data.active || count !== data.count) { + this.setData(data); + } } -}); + } +}); \ No newline at end of file diff --git a/dist/tabbar/index.js b/dist/tabbar/index.js index b0d33963..07eecd9d 100644 --- a/dist/tabbar/index.js +++ b/dist/tabbar/index.js @@ -1,61 +1,76 @@ import { VantComponent } from '../common/component'; VantComponent({ - relation: { - name: 'tabbar-item', - type: 'descendant', - linked(target) { - this.data.items.push(target); - setTimeout(() => { - this.setActiveItem(); - }); - }, - unlinked(target) { - this.data.items = this.data.items.filter(item => item !== target); - setTimeout(() => { - this.setActiveItem(); - }); - } + relation: { + name: 'tabbar-item', + type: 'descendant', + linked: function linked(target) { + var _this = this; + + this.data.items.push(target); + setTimeout(function () { + _this.setActiveItem(); + }); }, - props: { - active: Number, - fixed: { - type: Boolean, - value: true - }, - zIndex: { - type: Number, - value: 1 - } - }, - data: { - items: [], - currentActive: -1 - }, - watch: { - active(active) { - this.setData({ currentActive: active }); - this.setActiveItem(); - } - }, - created() { - this.setData({ currentActive: this.data.active }); - }, - methods: { - setActiveItem() { - this.data.items.forEach((item, index) => { - item.setActive({ - active: index === this.data.currentActive, - count: this.data.items.length - }); - }); - }, - onChange(child) { - const active = this.data.items.indexOf(child); - if (active !== this.data.currentActive && active !== -1) { - this.$emit('change', active); - this.setData({ currentActive: active }); - this.setActiveItem(); - } - } + unlinked: function unlinked(target) { + var _this2 = this; + + this.data.items = this.data.items.filter(function (item) { + return item !== target; + }); + setTimeout(function () { + _this2.setActiveItem(); + }); } -}); + }, + props: { + active: Number, + fixed: { + type: Boolean, + value: true + }, + zIndex: { + type: Number, + value: 1 + } + }, + data: { + items: [], + currentActive: -1 + }, + watch: { + active: function active(_active) { + this.setData({ + currentActive: _active + }); + this.setActiveItem(); + } + }, + created: function created() { + this.setData({ + currentActive: this.data.active + }); + }, + methods: { + setActiveItem: function setActiveItem() { + var _this3 = this; + + this.data.items.forEach(function (item, index) { + item.setActive({ + active: index === _this3.data.currentActive, + count: _this3.data.items.length + }); + }); + }, + onChange: function onChange(child) { + var active = this.data.items.indexOf(child); + + if (active !== this.data.currentActive && active !== -1) { + this.$emit('change', active); + this.setData({ + currentActive: active + }); + this.setActiveItem(); + } + } + } +}); \ No newline at end of file diff --git a/dist/tabs/index.js b/dist/tabs/index.js index 9df0a6c5..d59870d4 100644 --- a/dist/tabs/index.js +++ b/dist/tabs/index.js @@ -1,154 +1,166 @@ import { VantComponent } from '../common/component'; VantComponent({ - relation: { - name: 'tab', - type: 'descendant', - linked(child) { - this.data.tabs.push({ - instance: child, - data: child.data - }); - this.updateTabs(); - }, - unlinked(child) { - const tabs = this.data.tabs.filter(item => item.instance !== child); - this.setData({ - tabs, - scrollable: tabs.length > this.data.swipeThreshold - }); - this.setActiveTab(); - } + relation: { + name: 'tab', + type: 'descendant', + linked: function linked(child) { + this.data.tabs.push({ + instance: child, + data: child.data + }); + this.updateTabs(); }, - props: { - color: String, - lineWidth: Number, - active: { - type: null, - value: 0 - }, - type: { - type: String, - value: 'line' - }, - border: { - type: Boolean, - value: true - }, - duration: { - type: Number, - value: 0.2 - }, - swipeThreshold: { - type: Number, - value: 4 - } - }, - data: { - tabs: [], - lineStyle: '', - scrollLeft: 0, - scrollable: false - }, - watch: { - swipeThreshold() { - this.setData({ - scrollable: this.data.tabs.length > this.data.swipeThreshold - }); - }, - color: 'setLine', - lineWidth: 'setLine', - active: 'setActiveTab' - }, - mounted() { - this.setLine(); - this.scrollIntoView(); - }, - methods: { - updateTabs() { - const { tabs } = this.data; - this.setData({ - tabs, - scrollable: tabs.length > this.data.swipeThreshold - }); - this.setActiveTab(); - }, - trigger(eventName, index) { - this.$emit(eventName, { - index, - title: this.data.tabs[index].data.title - }); - }, - onTap(event) { - const { index } = event.currentTarget.dataset; - if (this.data.tabs[index].data.disabled) { - this.trigger('disabled', index); - } - else { - this.trigger('click', index); - this.setActive(index); - } - }, - setActive(active) { - if (active !== this.data.active) { - this.trigger('change', active); - this.setData({ active }); - this.setActiveTab(); - } - }, - setLine() { - if (this.data.type !== 'line') { - return; - } - this.getRect('.van-tab', true).then(rects => { - const rect = rects[this.data.active]; - const width = this.data.lineWidth || rect.width; - let left = rects - .slice(0, this.data.active) - .reduce((prev, curr) => prev + curr.width, 0); - left += (rect.width - width) / 2; - this.setData({ - lineStyle: ` - width: ${width}px; - background-color: ${this.data.color}; - transform: translateX(${left}px); - transition-duration: ${this.data.duration}s; - ` - }); - }); - }, - setActiveTab() { - this.data.tabs.forEach((item, index) => { - const data = { - active: index === this.data.active - }; - if (data.active) { - data.inited = true; - } - if (data.active !== item.instance.data.active) { - item.instance.setData(data); - } - }); - this.setLine(); - this.scrollIntoView(); - }, - // scroll active tab into view - scrollIntoView(immediate) { - if (!this.data.scrollable) { - return; - } - this.getRect('.van-tab', true).then(tabRects => { - const tabRect = tabRects[this.data.active]; - const offsetLeft = tabRects - .slice(0, this.data.active) - .reduce((prev, curr) => prev + curr.width, 0); - const tabWidth = tabRect.width; - this.getRect('.van-tabs__nav').then(navRect => { - const navWidth = navRect.width; - this.setData({ - scrollLeft: offsetLeft - (navWidth - tabWidth) / 2 - }); - }); - }); - } + unlinked: function unlinked(child) { + var tabs = this.data.tabs.filter(function (item) { + return item.instance !== child; + }); + this.setData({ + tabs: tabs, + scrollable: tabs.length > this.data.swipeThreshold + }); + this.setActiveTab(); } -}); + }, + props: { + color: String, + lineWidth: Number, + active: { + type: null, + value: 0 + }, + type: { + type: String, + value: 'line' + }, + border: { + type: Boolean, + value: true + }, + duration: { + type: Number, + value: 0.2 + }, + swipeThreshold: { + type: Number, + value: 4 + } + }, + data: { + tabs: [], + lineStyle: '', + scrollLeft: 0, + scrollable: false + }, + watch: { + swipeThreshold: function swipeThreshold() { + this.setData({ + scrollable: this.data.tabs.length > this.data.swipeThreshold + }); + }, + color: 'setLine', + lineWidth: 'setLine', + active: 'setActiveTab' + }, + mounted: function mounted() { + this.setLine(); + this.scrollIntoView(); + }, + methods: { + updateTabs: function updateTabs() { + var tabs = this.data.tabs; + this.setData({ + tabs: tabs, + scrollable: tabs.length > this.data.swipeThreshold + }); + this.setActiveTab(); + }, + trigger: function trigger(eventName, index) { + this.$emit(eventName, { + index: index, + title: this.data.tabs[index].data.title + }); + }, + onTap: function onTap(event) { + var index = event.currentTarget.dataset.index; + + if (this.data.tabs[index].data.disabled) { + this.trigger('disabled', index); + } else { + this.trigger('click', index); + this.setActive(index); + } + }, + setActive: function setActive(active) { + if (active !== this.data.active) { + this.trigger('change', active); + this.setData({ + active: active + }); + this.setActiveTab(); + } + }, + setLine: function setLine() { + var _this = this; + + if (this.data.type !== 'line') { + return; + } + + this.getRect('.van-tab', true).then(function (rects) { + var rect = rects[_this.data.active]; + var width = _this.data.lineWidth || rect.width; + var left = rects.slice(0, _this.data.active).reduce(function (prev, curr) { + return prev + curr.width; + }, 0); + left += (rect.width - width) / 2; + + _this.setData({ + lineStyle: "\n width: " + width + "px;\n background-color: " + _this.data.color + ";\n transform: translateX(" + left + "px);\n transition-duration: " + _this.data.duration + "s;\n " + }); + }); + }, + setActiveTab: function setActiveTab() { + var _this2 = this; + + this.data.tabs.forEach(function (item, index) { + var data = { + active: index === _this2.data.active + }; + + if (data.active) { + data.inited = true; + } + + if (data.active !== item.instance.data.active) { + item.instance.setData(data); + } + }); + this.setLine(); + this.scrollIntoView(); + }, + // scroll active tab into view + scrollIntoView: function scrollIntoView(immediate) { + var _this3 = this; + + if (!this.data.scrollable) { + return; + } + + this.getRect('.van-tab', true).then(function (tabRects) { + var tabRect = tabRects[_this3.data.active]; + var offsetLeft = tabRects.slice(0, _this3.data.active).reduce(function (prev, curr) { + return prev + curr.width; + }, 0); + var tabWidth = tabRect.width; + + _this3.getRect('.van-tabs__nav').then(function (navRect) { + var navWidth = navRect.width; + + _this3.setData({ + scrollLeft: offsetLeft - (navWidth - tabWidth) / 2 + }); + }); + }); + } + } +}); \ No newline at end of file diff --git a/dist/tag/index.js b/dist/tag/index.js index e3826e7b..a130471c 100644 --- a/dist/tag/index.js +++ b/dist/tag/index.js @@ -1,8 +1,8 @@ import { VantComponent } from '../common/component'; VantComponent({ - props: { - type: String, - mark: Boolean, - plain: Boolean - } -}); + props: { + type: String, + mark: Boolean, + plain: Boolean + } +}); \ No newline at end of file diff --git a/dist/toast/index.js b/dist/toast/index.js index 3ed296b6..e3cc3072 100644 --- a/dist/toast/index.js +++ b/dist/toast/index.js @@ -1,34 +1,34 @@ import { VantComponent } from '../common/component'; VantComponent({ - props: { - show: Boolean, - mask: Boolean, - message: String, - forbidClick: Boolean, - zIndex: { - type: Number, - value: 1000 - }, - type: { - type: String, - value: 'text' - }, - loadingType: { - type: String, - value: 'circular' - }, - position: { - type: String, - value: 'middle' - } + props: { + show: Boolean, + mask: Boolean, + message: String, + forbidClick: Boolean, + zIndex: { + type: Number, + value: 1000 }, - methods: { - clear() { - this.setData({ - show: false - }); - }, - // for prevent touchmove - noop() { } + type: { + type: String, + value: 'text' + }, + loadingType: { + type: String, + value: 'circular' + }, + position: { + type: String, + value: 'middle' } -}); + }, + methods: { + clear: function clear() { + this.setData({ + show: false + }); + }, + // for prevent touchmove + noop: function noop() {} + } +}); \ No newline at end of file diff --git a/dist/toast/toast.js b/dist/toast/toast.js index 045da2bb..d927bc11 100644 --- a/dist/toast/toast.js +++ b/dist/toast/toast.js @@ -1,52 +1,79 @@ +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + import { isObj } from '../common/utils'; -const defaultOptions = { - type: 'text', - mask: false, - message: '', - show: true, - zIndex: 1000, - duration: 3000, - position: 'middle', - forbidClick: false, - loadingType: 'circular', - selector: '#van-toast' +var defaultOptions = { + type: 'text', + mask: false, + message: '', + show: true, + zIndex: 1000, + duration: 3000, + position: 'middle', + forbidClick: false, + loadingType: 'circular', + selector: '#van-toast' }; -let queue = []; -let currentOptions = Object.assign({}, defaultOptions); +var queue = []; + +var currentOptions = _extends({}, defaultOptions); + function parseOptions(message) { - return isObj(message) ? message : { message }; + return isObj(message) ? message : { + message: message + }; } -const Toast = (options = {}) => { - options = Object.assign({}, currentOptions, parseOptions(options)); - const pages = getCurrentPages(); - const ctx = pages[pages.length - 1]; - const toast = ctx.selectComponent(options.selector); - delete options.selector; - queue.push(toast); - toast.setData(options); - clearTimeout(toast.timer); - if (options.duration > 0) { - toast.timer = setTimeout(() => { - toast.clear(); - queue = queue.filter(item => item !== toast); - }, options.duration); - } - return toast; + +var Toast = function Toast(options) { + if (options === void 0) { + options = {}; + } + + options = _extends({}, currentOptions, parseOptions(options)); + var pages = getCurrentPages(); + var ctx = pages[pages.length - 1]; + var toast = ctx.selectComponent(options.selector); + delete options.selector; + queue.push(toast); + toast.setData(options); + clearTimeout(toast.timer); + + if (options.duration > 0) { + toast.timer = setTimeout(function () { + toast.clear(); + queue = queue.filter(function (item) { + return item !== toast; + }); + }, options.duration); + } + + return toast; }; -const createMethod = type => options => Toast(Object.assign({ type }, parseOptions(options))); -['loading', 'success', 'fail'].forEach(method => { - Toast[method] = createMethod(method); + +var createMethod = function createMethod(type) { + return function (options) { + return Toast(_extends({ + type: type + }, parseOptions(options))); + }; +}; + +['loading', 'success', 'fail'].forEach(function (method) { + Toast[method] = createMethod(method); }); -Toast.clear = () => { - queue.forEach(toast => { - toast.clear(); - }); - queue = []; + +Toast.clear = function () { + queue.forEach(function (toast) { + toast.clear(); + }); + queue = []; }; -Toast.setDefaultOptions = options => { - Object.assign(currentOptions, options); + +Toast.setDefaultOptions = function (options) { + Object.assign(currentOptions, options); }; -Toast.resetDefaultOptions = () => { - currentOptions = Object.assign({}, defaultOptions); + +Toast.resetDefaultOptions = function () { + currentOptions = _extends({}, defaultOptions); }; -export default Toast; + +export default Toast; \ No newline at end of file diff --git a/dist/transition/index.js b/dist/transition/index.js index dcb987f8..443375c2 100644 --- a/dist/transition/index.js +++ b/dist/transition/index.js @@ -1,11 +1,11 @@ import { VantComponent } from '../common/component'; import { transition } from '../mixins/transition'; VantComponent({ - mixins: [transition(true)], - props: { - name: { - type: String, - value: 'fade' - } + mixins: [transition(true)], + props: { + name: { + type: String, + value: 'fade' } -}); + } +}); \ No newline at end of file diff --git a/dist/tree-select/index.js b/dist/tree-select/index.js index c9a2bc80..cc8e4600 100644 --- a/dist/tree-select/index.js +++ b/dist/tree-select/index.js @@ -1,63 +1,69 @@ import { VantComponent } from '../common/component'; -const ITEM_HEIGHT = 44; +var ITEM_HEIGHT = 44; VantComponent({ - props: { - items: Array, - mainActiveIndex: { - type: Number, - value: 0 - }, - activeId: { - type: Number, - value: 0 - }, - maxHeight: { - type: Number, - value: 300 - } + props: { + items: Array, + mainActiveIndex: { + type: Number, + value: 0 }, - data: { - subItems: [], - mainHeight: 0, - itemHeight: 0 + activeId: { + type: Number, + value: 0 }, - watch: { - items() { - this.updateSubItems(); - this.updateMainHeight(); - }, - maxHeight() { - this.updateItemHeight(); - this.updateMainHeight(); - }, - mainActiveIndex: 'updateSubItems' - }, - methods: { - // 当一个子项被选择时 - onSelectItem(event) { - this.$emit('click-item', event.currentTarget.dataset.item); - }, - // 当一个导航被点击时 - onClickNav(event) { - const { index } = event.currentTarget.dataset; - this.$emit('click-nav', { index }); - }, - // 更新子项列表 - updateSubItems() { - const selectedItem = this.data.items[this.data.mainActiveIndex] || {}; - this.setData({ subItems: selectedItem.children || [] }); - this.updateItemHeight(); - }, - // 更新组件整体高度,根据最大高度和当前组件需要展示的高度来决定 - updateMainHeight() { - const maxHeight = Math.max(this.data.items.length * ITEM_HEIGHT, this.data.subItems.length * ITEM_HEIGHT); - this.setData({ mainHeight: Math.min(maxHeight, this.data.maxHeight) }); - }, - // 更新子项列表高度,根据可展示的最大高度和当前子项列表的高度决定 - updateItemHeight() { - this.setData({ - itemHeight: Math.min(this.data.subItems.length * ITEM_HEIGHT, this.data.maxHeight) - }); - } + maxHeight: { + type: Number, + value: 300 } -}); + }, + data: { + subItems: [], + mainHeight: 0, + itemHeight: 0 + }, + watch: { + items: function items() { + this.updateSubItems(); + this.updateMainHeight(); + }, + maxHeight: function maxHeight() { + this.updateItemHeight(); + this.updateMainHeight(); + }, + mainActiveIndex: 'updateSubItems' + }, + methods: { + // 当一个子项被选择时 + onSelectItem: function onSelectItem(event) { + this.$emit('click-item', event.currentTarget.dataset.item); + }, + // 当一个导航被点击时 + onClickNav: function onClickNav(event) { + var index = event.currentTarget.dataset.index; + this.$emit('click-nav', { + index: index + }); + }, + // 更新子项列表 + updateSubItems: function updateSubItems() { + var selectedItem = this.data.items[this.data.mainActiveIndex] || {}; + this.setData({ + subItems: selectedItem.children || [] + }); + this.updateItemHeight(); + }, + // 更新组件整体高度,根据最大高度和当前组件需要展示的高度来决定 + updateMainHeight: function updateMainHeight() { + var maxHeight = Math.max(this.data.items.length * ITEM_HEIGHT, this.data.subItems.length * ITEM_HEIGHT); + this.setData({ + mainHeight: Math.min(maxHeight, this.data.maxHeight) + }); + }, + // 更新子项列表高度,根据可展示的最大高度和当前子项列表的高度决定 + updateItemHeight: function updateItemHeight() { + this.setData({ + itemHeight: Math.min(this.data.subItems.length * ITEM_HEIGHT, this.data.maxHeight) + }); + } + } +}); \ No newline at end of file diff --git a/package.json b/package.json index 6ff169b5..1064d535 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "@babel/core": "^7.1.0", "@babel/plugin-syntax-dynamic-import": "^7.0.0", "@babel/preset-env": "^7.1.0", + "@babel/preset-typescript": "^7.1.0", "autoprefixer": "^9.1.5", "babel-loader": "8.0.2", "cross-env": "^5.1.4", @@ -34,10 +35,10 @@ "fast-vue-md-loader": "^1.0.3", "gh-pages": "^2.0.0", "gulp": "^3.9.1", + "gulp-babel": "^8.0.0", "gulp-clean-css": "^3.9.0", "gulp-postcss": "^8.0.0", "gulp-rename": "^1.2.2", - "gulp-typescript": "^5.0.0-alpha.3", "html-webpack-plugin": "^3.2.0", "postcss-calc": "^6.0.2", "postcss-easy-import": "^3.0.0", diff --git a/yarn.lock b/yarn.lock index 1fd2e8e0..6929395b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -304,6 +304,12 @@ dependencies: "@babel/helper-plugin-utils" "^7.0.0" +"@babel/plugin-syntax-typescript@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.0.0.tgz#90f4fe0a741ae9c0dcdc3017717c05a0cbbd5158" + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/plugin-transform-arrow-functions@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.0.0.tgz#a6c14875848c68a3b4b3163a486535ef25c7e749" @@ -484,6 +490,13 @@ dependencies: "@babel/helper-plugin-utils" "^7.0.0" +"@babel/plugin-transform-typescript@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.1.0.tgz#81e7b4be90e7317cbd04bf1163ebf06b2adee60b" + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/plugin-syntax-typescript" "^7.0.0" + "@babel/plugin-transform-unicode-regex@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.0.0.tgz#c6780e5b1863a76fe792d90eded9fcd5b51d68fc" @@ -538,6 +551,13 @@ js-levenshtein "^1.1.3" semver "^5.3.0" +"@babel/preset-typescript@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.1.0.tgz#49ad6e2084ff0bfb5f1f7fb3b5e76c434d442c7f" + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/plugin-transform-typescript" "^7.1.0" + "@babel/template@7.0.0-beta.44": version "7.0.0-beta.44" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.0.0-beta.44.tgz#f8832f4fdcee5d59bf515e595fc5106c529b394f" @@ -896,10 +916,6 @@ ansi-colors@^1.0.1: dependencies: ansi-wrap "^0.1.0" -ansi-colors@^2.0.2: - version "2.0.5" - resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-2.0.5.tgz#5da37825fef3e75f3bda47f760d64bfd10e15e10" - ansi-escapes@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.1.0.tgz#f73207bb81207d75fd6c83f125af26eea378ca30" @@ -947,12 +963,6 @@ app-root-path@^2.0.1: version "2.1.0" resolved "https://registry.yarnpkg.com/app-root-path/-/app-root-path-2.1.0.tgz#98bf6599327ecea199309866e8140368fd2e646a" -append-buffer@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/append-buffer/-/append-buffer-1.0.2.tgz#d8220cf466081525efea50614f3de6514dfa58f1" - dependencies: - buffer-equal "^1.0.0" - aproba@^1.0.3, aproba@^1.1.1: version "1.2.0" resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" @@ -1264,10 +1274,6 @@ browserslist@^4.1.0: electron-to-chromium "^1.3.62" node-releases "^1.0.0-alpha.11" -buffer-equal@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/buffer-equal/-/buffer-equal-1.0.0.tgz#59616b498304d556abd466966b22eeda3eca5fbe" - buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" @@ -1517,18 +1523,10 @@ cliui@^4.0.0: strip-ansi "^4.0.0" wrap-ansi "^2.0.0" -clone-buffer@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/clone-buffer/-/clone-buffer-1.0.0.tgz#e3e25b207ac4e701af721e2cb5a16792cac3dc58" - clone-stats@^0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/clone-stats/-/clone-stats-0.0.1.tgz#b88f94a82cf38b8791d58046ea4029ad88ca99d1" -clone-stats@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/clone-stats/-/clone-stats-1.0.0.tgz#b3782dff8bb5474e18b9b6bf0fdfe782f8777680" - clone@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/clone/-/clone-0.2.0.tgz#c6126a90ad4f72dbf5acdb243cc37724fe93fc1f" @@ -1537,18 +1535,6 @@ clone@^1.0.0, clone@^1.0.2: version "1.0.4" resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e" -clone@^2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f" - -cloneable-readable@^1.0.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/cloneable-readable/-/cloneable-readable-1.1.2.tgz#d591dee4a8f8bc15da43ce97dceeba13d43e2a65" - dependencies: - inherits "^2.0.1" - process-nextick-args "^2.0.0" - readable-stream "^2.3.5" - co@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" @@ -1678,7 +1664,7 @@ content-type@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b" -convert-source-map@^1.1.0, convert-source-map@^1.5.0: +convert-source-map@^1.1.0: version "1.6.0" resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.6.0.tgz#51b537a8c43e0f04dec1993bffcdd504e758ac20" dependencies: @@ -2587,7 +2573,7 @@ flatten@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782" -flush-write-stream@^1.0.0, flush-write-stream@^1.0.2: +flush-write-stream@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/flush-write-stream/-/flush-write-stream-1.0.3.tgz#c5d586ef38af6097650b49bc41b55fabb19f35bd" dependencies: @@ -2647,13 +2633,6 @@ fs-minipass@^1.2.5: dependencies: minipass "^2.2.1" -fs-mkdirp-stream@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs-mkdirp-stream/-/fs-mkdirp-stream-1.0.0.tgz#0b7815fc3201c6a69e14db98ce098c16935259eb" - dependencies: - graceful-fs "^4.1.11" - through2 "^2.0.3" - fs-write-stream-atomic@^1.0.8: version "1.0.10" resolved "https://registry.yarnpkg.com/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz#b47df53493ef911df75731e70a9ded0189db40c9" @@ -2748,21 +2727,6 @@ glob-stream@^3.1.5: through2 "^0.6.1" unique-stream "^1.0.0" -glob-stream@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/glob-stream/-/glob-stream-6.1.0.tgz#7045c99413b3eb94888d83ab46d0b404cc7bdde4" - dependencies: - extend "^3.0.0" - glob "^7.1.1" - glob-parent "^3.1.0" - is-negated-glob "^1.0.0" - ordered-read-streams "^1.0.0" - pumpify "^1.3.5" - readable-stream "^2.1.5" - remove-trailing-separator "^1.0.1" - to-absolute-glob "^2.0.0" - unique-stream "^2.0.2" - glob-watcher@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/glob-watcher/-/glob-watcher-0.0.6.tgz#b95b4a8df74b39c83298b0c05c978b4d9a3b710b" @@ -2795,7 +2759,7 @@ glob@^7.0.0: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2: +glob@^7.0.3, glob@^7.0.5, glob@^7.1.2: version "7.1.2" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" dependencies: @@ -2903,7 +2867,7 @@ graceful-fs@^3.0.0: dependencies: natives "^1.1.0" -graceful-fs@^4.0.0, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6: +graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" @@ -2911,6 +2875,15 @@ graceful-fs@~1.2.0: version "1.2.3" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-1.2.3.tgz#15a4806a57547cb2d2dbf27f42e89a8c3451b364" +gulp-babel@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/gulp-babel/-/gulp-babel-8.0.0.tgz#e0da96f4f2ec4a88dd3a3030f476e38ab2126d87" + dependencies: + plugin-error "^1.0.1" + replace-ext "^1.0.0" + through2 "^2.0.0" + vinyl-sourcemaps-apply "^0.2.0" + gulp-clean-css@^3.9.0: version "3.10.0" resolved "https://registry.yarnpkg.com/gulp-clean-css/-/gulp-clean-css-3.10.0.tgz#bccd4605eff104bfa4980014cc4b3c24c571736d" @@ -2934,17 +2907,6 @@ gulp-rename@^1.2.2: version "1.4.0" resolved "https://registry.yarnpkg.com/gulp-rename/-/gulp-rename-1.4.0.tgz#de1c718e7c4095ae861f7296ef4f3248648240bd" -gulp-typescript@^5.0.0-alpha.3: - version "5.0.0-alpha.3" - resolved "https://registry.yarnpkg.com/gulp-typescript/-/gulp-typescript-5.0.0-alpha.3.tgz#c49a306cbbb8c97f5fe8a79208671b6642ef9861" - dependencies: - ansi-colors "^2.0.2" - plugin-error "^1.0.1" - source-map "^0.7.3" - through2 "^2.0.3" - vinyl "^2.1.0" - vinyl-fs "^3.0.3" - gulp-util@^3.0.0: version "3.0.8" resolved "https://registry.yarnpkg.com/gulp-util/-/gulp-util-3.0.8.tgz#0054e1e744502e27c04c187c3ecc505dd54bbb4f" @@ -3455,10 +3417,6 @@ is-installed-globally@^0.1.0: global-dirs "^0.1.0" is-path-inside "^1.0.0" -is-negated-glob@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-negated-glob/-/is-negated-glob-1.0.0.tgz#6910bca5da8c95e784b5751b976cf5a10fee36d2" - is-npm@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-npm/-/is-npm-1.0.0.tgz#f2fb63a65e4905b406c86072765a1a4dc793b9f4" @@ -3541,14 +3499,10 @@ is-unc-path@^1.0.0: dependencies: unc-path-regex "^0.1.2" -is-utf8@^0.2.0, is-utf8@^0.2.1: +is-utf8@^0.2.0: version "0.2.1" resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" -is-valid-glob@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-valid-glob/-/is-valid-glob-1.0.0.tgz#29bf3eff701be2d4d315dbacc39bc39fe8f601aa" - is-windows@^1.0.0, is-windows@^1.0.1, is-windows@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" @@ -3622,12 +3576,6 @@ json-stable-stringify-without-jsonify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" -json-stable-stringify@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" - dependencies: - jsonify "~0.0.0" - json-stringify-safe@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" @@ -3642,10 +3590,6 @@ jsonfile@^4.0.0: optionalDependencies: graceful-fs "^4.1.6" -jsonify@~0.0.0: - version "0.0.0" - resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" - keygrip@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/keygrip/-/keygrip-1.0.2.tgz#ad3297c557069dea8bcfe7a4fa491b75c5ddeb91" @@ -3742,24 +3686,12 @@ latest-version@^3.0.0: dependencies: package-json "^4.0.0" -lazystream@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/lazystream/-/lazystream-1.0.0.tgz#f6995fe0f820392f61396be89462407bb77168e4" - dependencies: - readable-stream "^2.0.5" - lcid@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/lcid/-/lcid-2.0.0.tgz#6ef5d2df60e52f82eb228a4c373e8d1f397253cf" dependencies: invert-kv "^2.0.0" -lead@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/lead/-/lead-1.0.0.tgz#6f14f99a37be3a9dd784f5495690e5903466ee42" - dependencies: - flush-write-stream "^1.0.2" - levn@^0.3.0, levn@~0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" @@ -4477,12 +4409,6 @@ normalize-url@^1.0.0: query-string "^4.1.0" sort-keys "^1.0.0" -now-and-later@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/now-and-later/-/now-and-later-2.0.0.tgz#bc61cbb456d79cb32207ce47ca05136ff2e7d6ee" - dependencies: - once "^1.3.2" - npm-bundled@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.0.3.tgz#7e71703d973af3370a9591bafe3a63aca0be2308" @@ -4553,7 +4479,7 @@ object-visit@^1.0.0: dependencies: isobject "^3.0.0" -object.assign@^4.0.1, object.assign@^4.0.4, object.assign@^4.1.0: +object.assign@^4.0.1, object.assign@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da" dependencies: @@ -4597,7 +4523,7 @@ on-finished@^2.3.0: dependencies: ee-first "1.1.1" -once@^1.3.0, once@^1.3.1, once@^1.3.2, once@^1.4.0: +once@^1.3.0, once@^1.3.1, once@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" dependencies: @@ -4648,12 +4574,6 @@ ordered-read-streams@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz#fd565a9af8eb4473ba69b6ed8a34352cb552f126" -ordered-read-streams@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/ordered-read-streams/-/ordered-read-streams-1.0.1.tgz#77c0cb37c41525d64166d990ffad7ec6a0e1363e" - dependencies: - readable-stream "^2.0.1" - os-browserify@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.3.0.tgz#854373c7f5c2315914fc9bfc6bd8238fdda1ec27" @@ -5287,7 +5207,7 @@ private@^0.1.6: version "0.1.8" resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" -process-nextick-args@^2.0.0, process-nextick-args@~2.0.0: +process-nextick-args@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa" @@ -5340,7 +5260,7 @@ pump@^2.0.0, pump@^2.0.1: end-of-stream "^1.1.0" once "^1.3.1" -pumpify@^1.3.3, pumpify@^1.3.5: +pumpify@^1.3.3: version "1.5.1" resolved "https://registry.yarnpkg.com/pumpify/-/pumpify-1.5.1.tgz#36513be246ab27570b1a374a5ce278bfd74370ce" dependencies: @@ -5426,7 +5346,7 @@ read-pkg@^3.0.0: normalize-package-data "^2.3.2" path-type "^3.0.0" -"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.4, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.3, readable-stream@^2.3.5, readable-stream@^2.3.6: +"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.4, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.3, readable-stream@^2.3.6: version "2.3.6" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" dependencies: @@ -5576,21 +5496,6 @@ remove-array-items@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/remove-array-items/-/remove-array-items-1.0.0.tgz#07bf42cb332f4cf6e85ead83b5e4e896d2326b21" -remove-bom-buffer@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/remove-bom-buffer/-/remove-bom-buffer-3.0.0.tgz#c2bf1e377520d324f623892e33c10cac2c252b53" - dependencies: - is-buffer "^1.1.5" - is-utf8 "^0.2.1" - -remove-bom-stream@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/remove-bom-stream/-/remove-bom-stream-1.2.0.tgz#05f1a593f16e42e1fb90ebf59de8e569525f9523" - dependencies: - remove-bom-buffer "^3.0.0" - safe-buffer "^5.1.0" - through2 "^2.0.3" - remove-trailing-separator@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" @@ -5661,12 +5566,6 @@ resolve-from@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-3.0.0.tgz#b22c7af7d9d6881bc8b6e653335eebcb0a188748" -resolve-options@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/resolve-options/-/resolve-options-1.1.0.tgz#32bb9e39c06d67338dc9378c0d6d6074566ad131" - dependencies: - value-or-function "^3.0.0" - resolve-path@^1.3.3: version "1.4.0" resolved "https://registry.yarnpkg.com/resolve-path/-/resolve-path-1.4.0.tgz#c4bda9f5efb2fce65247873ab36bb4d834fe16f7" @@ -5923,10 +5822,6 @@ source-map@^0.6.1, source-map@~0.6.0, source-map@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" -source-map@^0.7.3: - version "0.7.3" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" - sparkles@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/sparkles/-/sparkles-1.0.1.tgz#008db65edce6c50eec0c5e228e1945061dd0437c" @@ -6172,14 +6067,7 @@ thenify-all@^1.0.0: dependencies: any-promise "^1.0.0" -through2-filter@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/through2-filter/-/through2-filter-2.0.0.tgz#60bc55a0dacb76085db1f9dae99ab43f83d622ec" - dependencies: - through2 "~2.0.0" - xtend "~4.0.0" - -through2@2.0.3, through2@^2.0.0, through2@^2.0.3, through2@~2.0.0: +through2@2.0.3, through2@^2.0.0: version "2.0.3" resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be" dependencies: @@ -6227,13 +6115,6 @@ tmp@^0.0.33: dependencies: os-tmpdir "~1.0.2" -to-absolute-glob@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/to-absolute-glob/-/to-absolute-glob-2.0.2.tgz#1865f43d9e74b0822db9f145b78cff7d0f7c849b" - dependencies: - is-absolute "^1.0.0" - is-negated-glob "^1.0.0" - to-arraybuffer@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43" @@ -6264,12 +6145,6 @@ to-regex@^3.0.1, to-regex@^3.0.2: regex-not "^1.0.2" safe-regex "^1.1.0" -to-through@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/to-through/-/to-through-2.0.0.tgz#fc92adaba072647bc0b67d6b03664aa195093af6" - dependencies: - through2 "^2.0.3" - toidentifier@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553" @@ -6404,13 +6279,6 @@ unique-stream@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unique-stream/-/unique-stream-1.0.0.tgz#d59a4a75427447d9aa6c91e70263f8d26a4b104b" -unique-stream@^2.0.2: - version "2.2.1" - resolved "https://registry.yarnpkg.com/unique-stream/-/unique-stream-2.2.1.tgz#5aa003cfbe94c5ff866c4e7d668bb1c4dbadb369" - dependencies: - json-stable-stringify "^1.0.0" - through2-filter "^2.0.0" - unique-string@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unique-string/-/unique-string-1.0.0.tgz#9e1057cca851abb93398f8b33ae187b99caec11a" @@ -6542,10 +6410,6 @@ validate-npm-package-license@^3.0.1: spdx-correct "^3.0.0" spdx-expression-parse "^3.0.0" -value-or-function@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/value-or-function/-/value-or-function-3.0.0.tgz#1c243a50b595c1be54a754bfece8563b9ff8d813" - vant-doc@^1.0.17: version "1.0.17" resolved "https://registry.yarnpkg.com/vant-doc/-/vant-doc-1.0.17.tgz#2897598260b6e670f6b1214adcbceccc3f4a919b" @@ -6574,41 +6438,7 @@ vinyl-fs@^0.3.0: through2 "^0.6.1" vinyl "^0.4.0" -vinyl-fs@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/vinyl-fs/-/vinyl-fs-3.0.3.tgz#c85849405f67428feabbbd5c5dbdd64f47d31bc7" - dependencies: - fs-mkdirp-stream "^1.0.0" - glob-stream "^6.1.0" - graceful-fs "^4.0.0" - is-valid-glob "^1.0.0" - lazystream "^1.0.0" - lead "^1.0.0" - object.assign "^4.0.4" - pumpify "^1.3.5" - readable-stream "^2.3.3" - remove-bom-buffer "^3.0.0" - remove-bom-stream "^1.2.0" - resolve-options "^1.1.0" - through2 "^2.0.0" - to-through "^2.0.0" - value-or-function "^3.0.0" - vinyl "^2.0.0" - vinyl-sourcemap "^1.1.0" - -vinyl-sourcemap@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/vinyl-sourcemap/-/vinyl-sourcemap-1.1.0.tgz#92a800593a38703a8cdb11d8b300ad4be63b3e16" - dependencies: - append-buffer "^1.0.2" - convert-source-map "^1.5.0" - graceful-fs "^4.1.6" - normalize-path "^2.1.1" - now-and-later "^2.0.0" - remove-bom-buffer "^3.0.0" - vinyl "^2.0.0" - -vinyl-sourcemaps-apply@0.2.1, vinyl-sourcemaps-apply@^0.2.1: +vinyl-sourcemaps-apply@0.2.1, vinyl-sourcemaps-apply@^0.2.0, vinyl-sourcemaps-apply@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz#ab6549d61d172c2b1b87be5c508d239c8ef87705" dependencies: @@ -6629,17 +6459,6 @@ vinyl@^0.5.0: clone-stats "^0.0.1" replace-ext "0.0.1" -vinyl@^2.0.0, vinyl@^2.1.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-2.2.0.tgz#d85b07da96e458d25b2ffe19fece9f2caa13ed86" - dependencies: - clone "^2.1.1" - clone-buffer "^1.0.0" - clone-stats "^1.0.0" - cloneable-readable "^1.0.0" - remove-trailing-separator "^1.0.1" - replace-ext "^1.0.0" - vm-browserify@0.0.4: version "0.0.4" resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-0.0.4.tgz#5d7ea45bbef9e4a6ff65f95438e0a87c357d5a73" @@ -6905,7 +6724,7 @@ xregexp@4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-4.0.0.tgz#e698189de49dd2a18cc5687b05e17c8e43943020" -"xtend@>=4.0.0 <4.1.0-0", xtend@^4.0.0, xtend@~4.0.0, xtend@~4.0.1: +"xtend@>=4.0.0 <4.1.0-0", xtend@^4.0.0, xtend@~4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af"