mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[Improvement] extract component common part (#703)
This commit is contained in:
parent
f26ad3b912
commit
ffd72e5442
@ -17,19 +17,20 @@ components.forEach(componentName => {
|
||||
// Analyze component dependencies
|
||||
function analyzeDependencies(componentName, libDir) {
|
||||
const checkList = ['base'];
|
||||
const whiteList = ['icon', 'loading', 'cell', 'button'];
|
||||
search(dependencyTree({
|
||||
directory: libDir,
|
||||
filename: path.resolve(libDir, componentName, 'index.js'),
|
||||
filter: path => path.indexOf(`vant${SEP}lib${SEP}`) !== -1
|
||||
}), checkList);
|
||||
}), checkList, whiteList);
|
||||
return checkList.filter(component => checkComponentHasStyle(component));
|
||||
}
|
||||
|
||||
function search(tree, checkList) {
|
||||
function search(tree, checkList, whiteList) {
|
||||
tree && Object.keys(tree).forEach(key => {
|
||||
search(tree[key], checkList);
|
||||
search(tree[key], checkList, whiteList);
|
||||
const component = key.split(`${SEP}vant${SEP}lib${SEP}`)[1].replace(`${SEP}index.js`, '').replace(`mixins${SEP}`, '');
|
||||
if (checkList.indexOf(component) === -1) {
|
||||
if (checkList.indexOf(component) === -1 && whiteList.indexOf(component) === -1) {
|
||||
checkList.push(component);
|
||||
}
|
||||
});
|
||||
|
@ -38,7 +38,7 @@ import { create } from '../utils';
|
||||
import Popup from '../mixins/popup';
|
||||
|
||||
export default create({
|
||||
name: 'van-actionsheet',
|
||||
name: 'actionsheet',
|
||||
|
||||
mixins: [Popup],
|
||||
|
||||
|
@ -41,17 +41,13 @@
|
||||
<script>
|
||||
import { create } from '../utils';
|
||||
import Field from '../field';
|
||||
import Cell from '../cell';
|
||||
import CellGroup from '../cell-group';
|
||||
import { isAndroid } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-address-edit-detail',
|
||||
name: 'address-edit-detail',
|
||||
|
||||
components: {
|
||||
Field,
|
||||
Cell,
|
||||
CellGroup
|
||||
Field
|
||||
},
|
||||
|
||||
props: {
|
||||
|
@ -5,7 +5,7 @@
|
||||
maxlength="15"
|
||||
:placeholder="$t('name')"
|
||||
:label="$t('label.name', computedAddressText)"
|
||||
v-model="currentInfo.name"
|
||||
v-model="data.name"
|
||||
:error="errorInfo.name"
|
||||
@focus="onFocus('name')"
|
||||
/>
|
||||
@ -13,7 +13,7 @@
|
||||
type="tel"
|
||||
:label="$t('tel')"
|
||||
:placeholder="$t('telPlaceholder')"
|
||||
v-model="currentInfo.tel"
|
||||
v-model="data.tel"
|
||||
:error="errorInfo.tel"
|
||||
@focus="onFocus('tel')"
|
||||
/>
|
||||
@ -23,17 +23,17 @@
|
||||
:title="$t('area')"
|
||||
@click="showArea = true"
|
||||
>
|
||||
<span>{{ currentInfo.province || $t('province') }}</span>
|
||||
<span>{{ currentInfo.city || $t('city') }}</span>
|
||||
<span>{{ currentInfo.county || $t('county') }}</span>
|
||||
<span>{{ data.province || $t('province') }}</span>
|
||||
<span>{{ data.city || $t('city') }}</span>
|
||||
<span>{{ data.county || $t('county') }}</span>
|
||||
</cell>
|
||||
<address-edit-detail
|
||||
:value="currentInfo.address_detail"
|
||||
:value="data.address_detail"
|
||||
:is-error="errorInfo.address_detail"
|
||||
:show-search-result="showSearchResult"
|
||||
:search-result="searchResult"
|
||||
@focus="onFocus('address_detail')"
|
||||
@blur="onDetailBlur"
|
||||
@blur="detailFocused = false"
|
||||
@input="onChangeDetail"
|
||||
@select-search="$emit('select-search', $event)"
|
||||
/>
|
||||
@ -43,7 +43,7 @@
|
||||
type="tel"
|
||||
:label="$t('label.postal')"
|
||||
:placeholder="$t('placeholder.postal')"
|
||||
v-model="currentInfo.postal_code"
|
||||
v-model="data.postal_code"
|
||||
maxlength="6"
|
||||
class="van-hairline--top"
|
||||
:error="errorInfo.postal_code"
|
||||
@ -53,7 +53,7 @@
|
||||
<switch-cell
|
||||
v-if="showSetDefault"
|
||||
v-show="!hideBottomFields"
|
||||
v-model="currentInfo.is_default"
|
||||
v-model="data.is_default"
|
||||
:title="$t('defaultAddress', computedAddressText)"
|
||||
/>
|
||||
</cell-group>
|
||||
@ -69,7 +69,7 @@
|
||||
<van-area
|
||||
ref="area"
|
||||
:loading="!areaListLoaded"
|
||||
:value="currentInfo.area_code"
|
||||
:value="data.area_code"
|
||||
:area-list="areaList"
|
||||
@confirm="onAreaConfirm"
|
||||
@cancel="showArea = false"
|
||||
@ -82,8 +82,6 @@
|
||||
/* eslint-disable camelcase */
|
||||
import { create, isObj } from '../utils';
|
||||
import Field from '../field';
|
||||
import Cell from '../cell';
|
||||
import CellGroup from '../cell-group';
|
||||
import VanButton from '../button';
|
||||
import Popup from '../popup';
|
||||
import Toast from '../toast';
|
||||
@ -106,12 +104,10 @@ const defaultAddress = {
|
||||
};
|
||||
|
||||
export default create({
|
||||
name: 'van-address-edit',
|
||||
name: 'address-edit',
|
||||
|
||||
components: {
|
||||
Field,
|
||||
Cell,
|
||||
CellGroup,
|
||||
SwitchCell,
|
||||
VanButton,
|
||||
Popup,
|
||||
@ -144,7 +140,7 @@ export default create({
|
||||
data() {
|
||||
return {
|
||||
showArea: false,
|
||||
currentInfo: {
|
||||
data: {
|
||||
...defaultAddress,
|
||||
...this.addressInfo
|
||||
},
|
||||
@ -162,7 +158,7 @@ export default create({
|
||||
watch: {
|
||||
addressInfo: {
|
||||
handler(val) {
|
||||
this.currentInfo = {
|
||||
this.data = {
|
||||
...defaultAddress,
|
||||
...val
|
||||
};
|
||||
@ -176,8 +172,8 @@ export default create({
|
||||
},
|
||||
|
||||
areaList() {
|
||||
if (this.currentInfo.area_code) {
|
||||
this.setAreaCode(this.currentInfo.area_code);
|
||||
if (this.data.area_code) {
|
||||
this.setAreaCode(this.data.area_code);
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -204,12 +200,8 @@ export default create({
|
||||
this.$emit('focus', key);
|
||||
},
|
||||
|
||||
onDetailBlur() {
|
||||
this.detailFocused = false;
|
||||
},
|
||||
|
||||
onChangeDetail(val) {
|
||||
this.currentInfo.address_detail = val;
|
||||
this.data.address_detail = val;
|
||||
this.$emit('change-detail', val);
|
||||
},
|
||||
|
||||
@ -223,7 +215,7 @@ export default create({
|
||||
},
|
||||
|
||||
assignAreaValues(values) {
|
||||
Object.assign(this.currentInfo, {
|
||||
Object.assign(this.data, {
|
||||
province: values[0].name,
|
||||
city: values[1].name,
|
||||
county: values[2].name,
|
||||
@ -253,12 +245,12 @@ export default create({
|
||||
});
|
||||
|
||||
if (isValid && !this.isSaving) {
|
||||
this.$emit('save', this.currentInfo);
|
||||
this.$emit('save', this.data);
|
||||
}
|
||||
},
|
||||
|
||||
getErrorMessageByKey(key) {
|
||||
const value = this.currentInfo[key];
|
||||
const value = this.data[key];
|
||||
const { $t } = this;
|
||||
|
||||
switch (key) {
|
||||
@ -283,7 +275,7 @@ export default create({
|
||||
Dialog.confirm({
|
||||
message: this.$t('confirmDelete', this.computedAddressText)
|
||||
}).then(() => {
|
||||
this.$emit('delete', this.currentInfo);
|
||||
this.$emit('delete', this.data);
|
||||
});
|
||||
},
|
||||
|
||||
@ -295,7 +287,7 @@ export default create({
|
||||
|
||||
// set area code to area component
|
||||
setAreaCode(code) {
|
||||
this.currentInfo.area_code = code;
|
||||
this.data.area_code = code;
|
||||
this.$nextTick(() => {
|
||||
this.$nextTick(() => {
|
||||
const { area } = this.$refs;
|
||||
|
@ -23,18 +23,14 @@
|
||||
|
||||
<script>
|
||||
import { create } from '../utils';
|
||||
import Cell from '../cell';
|
||||
import CellGroup from '../cell-group';
|
||||
import Radio from '../radio';
|
||||
import RadioGroup from '../radio-group';
|
||||
|
||||
export default create({
|
||||
name: 'van-address-list',
|
||||
name: 'address-list',
|
||||
|
||||
components: {
|
||||
Cell,
|
||||
Radio,
|
||||
CellGroup,
|
||||
RadioGroup
|
||||
},
|
||||
|
||||
|
@ -20,7 +20,7 @@ import { create, isObj } from '../utils';
|
||||
import Picker from '../picker';
|
||||
|
||||
export default create({
|
||||
name: 'van-area',
|
||||
name: 'area',
|
||||
|
||||
components: {
|
||||
Picker
|
||||
|
@ -8,7 +8,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-badge-group',
|
||||
name: 'badge-group',
|
||||
|
||||
props: {
|
||||
activeKey: {
|
||||
|
@ -9,7 +9,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-badge',
|
||||
name: 'badge',
|
||||
|
||||
props: {
|
||||
url: String,
|
||||
|
@ -27,7 +27,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-button',
|
||||
name: 'button',
|
||||
|
||||
props: {
|
||||
text: String,
|
||||
|
@ -30,7 +30,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-card',
|
||||
name: 'card',
|
||||
|
||||
props: {
|
||||
thumb: String,
|
||||
|
@ -5,10 +5,12 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { create } from '../utils';
|
||||
import install from '../utils/install';
|
||||
|
||||
export default create({
|
||||
name: 'van-cell-group',
|
||||
export default {
|
||||
install,
|
||||
|
||||
name: 'cell-group',
|
||||
|
||||
props: {
|
||||
border: {
|
||||
@ -16,5 +18,5 @@ export default create({
|
||||
default: true
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
@ -27,7 +27,7 @@ import Clickoutside from '../utils/clickoutside';
|
||||
const THRESHOLD = 0.15;
|
||||
|
||||
export default create({
|
||||
name: 'van-cell-swipe',
|
||||
name: 'cell-swipe',
|
||||
|
||||
props: {
|
||||
onClose: Function,
|
||||
|
@ -37,11 +37,18 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { create } from '../utils';
|
||||
import Icon from '../icon';
|
||||
import install from '../utils/install';
|
||||
import RouterLink from '../mixins/router-link';
|
||||
|
||||
export default create({
|
||||
name: 'van-cell',
|
||||
export default {
|
||||
install,
|
||||
|
||||
name: 'cell',
|
||||
|
||||
components: {
|
||||
Icon
|
||||
},
|
||||
|
||||
mixins: [RouterLink],
|
||||
|
||||
@ -65,5 +72,5 @@ export default create({
|
||||
this.routerLink();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
@ -8,7 +8,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-checkbox-group',
|
||||
name: 'checkbox-group',
|
||||
|
||||
props: {
|
||||
value: {},
|
||||
|
@ -21,7 +21,7 @@ import { create, isDef } from '../utils';
|
||||
import findParent from '../mixins/find-parent';
|
||||
|
||||
export default create({
|
||||
name: 'van-checkbox',
|
||||
name: 'checkbox',
|
||||
|
||||
mixins: [findParent],
|
||||
|
||||
|
@ -15,7 +15,7 @@ import { create } from '../utils';
|
||||
import { raf, cancel } from '../utils/raf';
|
||||
|
||||
export default create({
|
||||
name: 'van-circle',
|
||||
name: 'circle',
|
||||
|
||||
props: {
|
||||
text: String,
|
||||
|
@ -12,7 +12,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-col',
|
||||
name: 'col',
|
||||
|
||||
props: {
|
||||
span: [Number, String],
|
||||
|
@ -16,19 +16,14 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Cell from '../cell';
|
||||
import findParent from '../mixins/find-parent';
|
||||
import { create, isDef } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-collapse-item',
|
||||
name: 'collapse-item',
|
||||
|
||||
mixins: [findParent],
|
||||
|
||||
components: {
|
||||
Cell
|
||||
},
|
||||
|
||||
props: {
|
||||
name: [String, Number],
|
||||
title: String
|
||||
|
@ -8,7 +8,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-collapse',
|
||||
name: 'collapse',
|
||||
|
||||
model: {
|
||||
prop: 'activeNames'
|
||||
|
@ -21,7 +21,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-contact-card',
|
||||
name: 'contact-card',
|
||||
|
||||
props: {
|
||||
tel: String,
|
||||
|
@ -2,7 +2,7 @@
|
||||
<div class="van-contact-edit">
|
||||
<cell-group>
|
||||
<field
|
||||
v-model="currentInfo.name"
|
||||
v-model="data.name"
|
||||
maxlength="30"
|
||||
:label="$t('contact')"
|
||||
:placeholder="$t('name')"
|
||||
@ -10,7 +10,7 @@
|
||||
@focus="onFocus('name')"
|
||||
/>
|
||||
<field
|
||||
v-model="currentInfo.tel"
|
||||
v-model="data.tel"
|
||||
type="tel"
|
||||
:label="$t('tel')"
|
||||
:placeholder="$t('telPlaceholder')"
|
||||
@ -28,19 +28,17 @@
|
||||
<script>
|
||||
import Field from '../field';
|
||||
import VanButton from '../button';
|
||||
import CellGroup from '../cell-group';
|
||||
import Dialog from '../dialog';
|
||||
import Toast from '../toast';
|
||||
import validateMobile from '../utils/validate/mobile';
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-contact-edit',
|
||||
name: 'contact-edit',
|
||||
|
||||
components: {
|
||||
Field,
|
||||
VanButton,
|
||||
CellGroup
|
||||
VanButton
|
||||
},
|
||||
|
||||
props: {
|
||||
@ -63,7 +61,7 @@ export default create({
|
||||
|
||||
data() {
|
||||
return {
|
||||
currentInfo: this.contactInfo,
|
||||
data: this.contactInfo,
|
||||
errorInfo: {
|
||||
name: false,
|
||||
tel: false
|
||||
@ -73,7 +71,7 @@ export default create({
|
||||
|
||||
watch: {
|
||||
contactInfo(val) {
|
||||
this.currentInfo = val;
|
||||
this.data = val;
|
||||
}
|
||||
},
|
||||
|
||||
@ -83,7 +81,7 @@ export default create({
|
||||
},
|
||||
|
||||
getErrorMessageByKey(key) {
|
||||
const value = this.currentInfo[key];
|
||||
const value = this.data[key];
|
||||
switch (key) {
|
||||
case 'name':
|
||||
return value ? value.length <= 15 ? '' : this.$t('nameOverlimit') : this.$t('nameEmpty');
|
||||
@ -108,7 +106,7 @@ export default create({
|
||||
});
|
||||
|
||||
if (isValid && !this.isSaving) {
|
||||
this.$emit('save', this.currentInfo);
|
||||
this.$emit('save', this.data);
|
||||
}
|
||||
},
|
||||
|
||||
@ -120,7 +118,7 @@ export default create({
|
||||
Dialog.confirm({
|
||||
message: this.$t('confirmDelete')
|
||||
}).then(() => {
|
||||
this.$emit('delete', this.currentInfo);
|
||||
this.$emit('delete', this.data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -22,19 +22,15 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Cell from '../cell';
|
||||
import Radio from '../radio';
|
||||
import CellGroup from '../cell-group';
|
||||
import RadioGroup from '../radio-group';
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-contact-list',
|
||||
name: 'contact-list',
|
||||
|
||||
components: {
|
||||
Cell,
|
||||
Radio,
|
||||
CellGroup,
|
||||
RadioGroup
|
||||
},
|
||||
|
||||
|
@ -6,16 +6,9 @@
|
||||
|
||||
<script>
|
||||
import { create } from '../utils';
|
||||
import Cell from '../cell';
|
||||
import CellGroup from '../cell-group';
|
||||
|
||||
export default create({
|
||||
name: 'van-coupon-cell',
|
||||
|
||||
components: {
|
||||
Cell,
|
||||
CellGroup
|
||||
},
|
||||
name: 'coupon-cell',
|
||||
|
||||
model: {
|
||||
prop: 'chosenCoupon'
|
||||
|
@ -22,7 +22,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-coupon-item',
|
||||
name: 'coupon-item',
|
||||
|
||||
props: {
|
||||
data: Object,
|
||||
|
@ -49,19 +49,15 @@
|
||||
|
||||
<script>
|
||||
import { create } from '../utils';
|
||||
import Cell from '../cell';
|
||||
import CellGroup from '../cell-group';
|
||||
import CouponItem from './Item';
|
||||
import Field from '../field';
|
||||
import VanButton from '../button';
|
||||
|
||||
export default create({
|
||||
name: 'van-coupon-list',
|
||||
name: 'coupon-list',
|
||||
|
||||
components: {
|
||||
VanButton,
|
||||
Cell,
|
||||
CellGroup,
|
||||
Field,
|
||||
CouponItem
|
||||
},
|
||||
|
@ -17,7 +17,7 @@ import Picker from '../picker';
|
||||
const isValidDate = date => Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date.getTime());
|
||||
|
||||
export default create({
|
||||
name: 'van-datetime-picker',
|
||||
name: 'datetime-picker',
|
||||
|
||||
components: {
|
||||
Picker
|
||||
|
@ -36,7 +36,7 @@ import VanButton from '../button';
|
||||
import Popup from '../mixins/popup';
|
||||
|
||||
export default create({
|
||||
name: 'van-dialog',
|
||||
name: 'dialog',
|
||||
|
||||
components: {
|
||||
VanButton
|
||||
|
@ -50,17 +50,12 @@
|
||||
|
||||
<script>
|
||||
import { create } from '../utils';
|
||||
import Cell from '../cell';
|
||||
|
||||
export default create({
|
||||
name: 'van-field',
|
||||
name: 'field',
|
||||
|
||||
inheritAttrs: false,
|
||||
|
||||
components: {
|
||||
Cell
|
||||
},
|
||||
|
||||
props: {
|
||||
type: {
|
||||
type: String,
|
||||
|
@ -17,7 +17,7 @@ import VanButton from '../button';
|
||||
import RouterLink from '../mixins/router-link';
|
||||
|
||||
export default create({
|
||||
name: 'van-goods-action-big-btn',
|
||||
name: 'goods-action-big-btn',
|
||||
|
||||
mixins: [RouterLink],
|
||||
|
||||
|
@ -10,7 +10,7 @@ import { create } from '../utils';
|
||||
import RouterLink from '../mixins/router-link';
|
||||
|
||||
export default create({
|
||||
name: 'van-goods-action-mini-btn',
|
||||
name: 'goods-action-mini-btn',
|
||||
|
||||
mixins: [RouterLink],
|
||||
|
||||
|
@ -8,6 +8,6 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-goods-action'
|
||||
name: 'goods-action'
|
||||
});
|
||||
</script>
|
||||
|
@ -11,7 +11,7 @@ import install from '../utils/install';
|
||||
export default {
|
||||
install,
|
||||
|
||||
name: 'van-icon',
|
||||
name: 'icon',
|
||||
|
||||
props: {
|
||||
name: String,
|
||||
|
@ -22,7 +22,7 @@ import Swipe from '../swipe';
|
||||
import SwipeItem from '../swipe-item';
|
||||
|
||||
export default create({
|
||||
name: 'van-image-preview',
|
||||
name: 'image-preview',
|
||||
|
||||
mixins: [Popup],
|
||||
|
||||
|
@ -16,7 +16,7 @@ import utils from '../utils/scroll';
|
||||
import { on, off } from '../utils/event';
|
||||
|
||||
export default create({
|
||||
name: 'van-list',
|
||||
name: 'list',
|
||||
|
||||
model: {
|
||||
prop: 'loading'
|
||||
|
@ -15,7 +15,7 @@ import install from '../utils/install';
|
||||
export default {
|
||||
install,
|
||||
|
||||
name: 'van-loading',
|
||||
name: 'loading',
|
||||
|
||||
props: {
|
||||
size: String,
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'van-modal',
|
||||
name: 'modal',
|
||||
|
||||
props: {
|
||||
visible: Boolean,
|
||||
|
@ -25,7 +25,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-nav-bar',
|
||||
name: 'nav-bar',
|
||||
|
||||
props: {
|
||||
title: String,
|
||||
|
@ -29,7 +29,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-notice-bar',
|
||||
name: 'notice-bar',
|
||||
|
||||
props: {
|
||||
text: String,
|
||||
|
@ -39,7 +39,7 @@ import { create } from '../utils';
|
||||
import Key from './Key';
|
||||
|
||||
export default create({
|
||||
name: 'van-number-keyboard',
|
||||
name: 'number-keyboard',
|
||||
|
||||
components: { Key },
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-pagination',
|
||||
name: 'pagination',
|
||||
|
||||
props: {
|
||||
value: Number,
|
||||
|
@ -20,7 +20,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-panel',
|
||||
name: 'panel',
|
||||
props: {
|
||||
desc: String,
|
||||
title: String,
|
||||
|
@ -17,7 +17,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-password-input',
|
||||
name: 'password-input',
|
||||
|
||||
props: {
|
||||
info: String,
|
||||
|
@ -31,7 +31,7 @@ const DEFAULT_DURATION = 200;
|
||||
const range = (num, arr) => Math.min(Math.max(num, arr[0]), arr[1]);
|
||||
|
||||
export default create({
|
||||
name: 'van-picker-column',
|
||||
name: 'picker-column',
|
||||
|
||||
props: {
|
||||
valueKey: String,
|
||||
|
@ -33,7 +33,7 @@ import PickerColumn from './PickerColumn';
|
||||
import deepClone from '../utils/deep-clone';
|
||||
|
||||
export default create({
|
||||
name: 'van-picker',
|
||||
name: 'picker',
|
||||
|
||||
components: {
|
||||
PickerColumn
|
||||
|
@ -11,7 +11,7 @@ import { create } from '../utils';
|
||||
import Popup from '../mixins/popup';
|
||||
|
||||
export default create({
|
||||
name: 'van-popup',
|
||||
name: 'popup',
|
||||
|
||||
mixins: [Popup],
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-progress',
|
||||
name: 'progress',
|
||||
|
||||
props: {
|
||||
inactive: Boolean,
|
||||
|
@ -33,7 +33,7 @@ import { create } from '../utils';
|
||||
import scrollUtils from '../utils/scroll';
|
||||
|
||||
export default create({
|
||||
name: 'van-pull-refresh',
|
||||
name: 'pull-refresh',
|
||||
|
||||
props: {
|
||||
pullingText: String,
|
||||
|
@ -8,7 +8,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-radio-group',
|
||||
name: 'radio-group',
|
||||
|
||||
props: {
|
||||
value: {},
|
||||
|
@ -25,7 +25,7 @@ import { create } from '../utils';
|
||||
import findParent from '../mixins/find-parent';
|
||||
|
||||
export default create({
|
||||
name: 'van-radio',
|
||||
name: 'radio',
|
||||
|
||||
mixins: [findParent],
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-row',
|
||||
name: 'row',
|
||||
|
||||
props: {
|
||||
gutter: {
|
||||
|
@ -28,7 +28,7 @@ import { create } from '../utils';
|
||||
import Clickoutside from '../utils/clickoutside';
|
||||
|
||||
export default create({
|
||||
name: 'van-search',
|
||||
name: 'search',
|
||||
|
||||
inheritAttrs: false,
|
||||
|
||||
|
@ -120,7 +120,7 @@ import { create } from '../utils';
|
||||
const { QUOTA_LIMIT } = LIMIT_TYPE;
|
||||
|
||||
export default create({
|
||||
name: 'van-sku',
|
||||
name: 'sku',
|
||||
|
||||
components: {
|
||||
Popup,
|
||||
|
@ -20,7 +20,7 @@ import VanButton from '../../button';
|
||||
import { create } from '../../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-sku-actions',
|
||||
name: 'sku-actions',
|
||||
|
||||
components: {
|
||||
VanButton
|
||||
|
@ -15,7 +15,7 @@
|
||||
import { create } from '../../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-sku-header',
|
||||
name: 'sku-header',
|
||||
|
||||
props: {
|
||||
skuEventBus: Object,
|
||||
|
@ -46,7 +46,7 @@ import Loading from '../../loading';
|
||||
import { create } from '../../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-sku-img-uploader',
|
||||
name: 'sku-img-uploader',
|
||||
|
||||
components: {
|
||||
'van-uploader': Uploader,
|
||||
|
@ -30,20 +30,16 @@
|
||||
<script>
|
||||
import { create } from '../../utils';
|
||||
import Field from '../../field';
|
||||
import CellGroup from '../../cell-group';
|
||||
import Cell from '../../cell';
|
||||
import validateEmail from '../../utils/validate/email';
|
||||
import validateNumber from '../../utils/validate/number';
|
||||
import SkuImgUploader from './SkuImgUploader';
|
||||
|
||||
export default create({
|
||||
name: 'van-sku-messages',
|
||||
name: 'sku-messages',
|
||||
|
||||
components: {
|
||||
SkuImgUploader,
|
||||
Field,
|
||||
Cell,
|
||||
CellGroup
|
||||
Field
|
||||
},
|
||||
|
||||
props: {
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'van-sku-row',
|
||||
name: 'sku-row',
|
||||
|
||||
props: {
|
||||
skuRow: Object
|
||||
|
@ -15,7 +15,7 @@
|
||||
import { create } from '../../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-sku-row-item',
|
||||
name: 'sku-row-item',
|
||||
|
||||
props: {
|
||||
skuEventBus: Object,
|
||||
|
@ -25,7 +25,7 @@ import { LIMIT_TYPE } from '../constants';
|
||||
const { QUOTA_LIMIT, STOCK_LIMIT } = LIMIT_TYPE;
|
||||
|
||||
export default create({
|
||||
name: 'van-sku-stepper',
|
||||
name: 'sku-stepper',
|
||||
|
||||
components: {
|
||||
Stepper
|
||||
|
@ -15,7 +15,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-step',
|
||||
name: 'step',
|
||||
|
||||
beforeCreate() {
|
||||
this.$parent.steps.push(this);
|
||||
|
@ -24,7 +24,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-stepper',
|
||||
name: 'stepper',
|
||||
|
||||
props: {
|
||||
value: {},
|
||||
|
@ -22,7 +22,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-steps',
|
||||
name: 'steps',
|
||||
|
||||
props: {
|
||||
icon: String,
|
||||
|
@ -24,7 +24,7 @@ import VanButton from '../button';
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-submit-bar',
|
||||
name: 'submit-bar',
|
||||
|
||||
components: {
|
||||
VanButton
|
||||
|
@ -8,7 +8,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-swipe-item',
|
||||
name: 'swipe-item',
|
||||
|
||||
data() {
|
||||
return {
|
||||
|
@ -25,7 +25,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-swipe',
|
||||
name: 'swipe',
|
||||
|
||||
props: {
|
||||
autoplay: Number,
|
||||
|
@ -5,15 +5,13 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Cell from '../cell';
|
||||
import VanSwitch from '../switch';
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-switch-cell',
|
||||
name: 'switch-cell',
|
||||
|
||||
components: {
|
||||
Cell,
|
||||
VanSwitch
|
||||
},
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-switch',
|
||||
name: 'switch',
|
||||
|
||||
props: {
|
||||
value: Boolean,
|
||||
|
@ -9,7 +9,7 @@ import { create } from '../utils';
|
||||
import findParent from '../mixins/find-parent';
|
||||
|
||||
export default create({
|
||||
name: 'van-tab',
|
||||
name: 'tab',
|
||||
|
||||
mixins: [findParent],
|
||||
|
||||
|
@ -17,7 +17,7 @@ import { create } from '../utils';
|
||||
import RouterLink from '../mixins/router-link';
|
||||
|
||||
export default create({
|
||||
name: 'van-tabbar-item',
|
||||
name: 'tabbar-item',
|
||||
|
||||
mixins: [RouterLink],
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-tabbar',
|
||||
name: 'tabbar',
|
||||
|
||||
data() {
|
||||
return {
|
||||
|
@ -40,7 +40,7 @@ import VanNode from '../utils/node';
|
||||
import scrollUtils from '../utils/scroll';
|
||||
|
||||
export default create({
|
||||
name: 'van-tabs',
|
||||
name: 'tabs',
|
||||
|
||||
components: {
|
||||
VanNode
|
||||
|
@ -15,7 +15,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-tag',
|
||||
name: 'tag',
|
||||
props: {
|
||||
type: String,
|
||||
mark: Boolean,
|
||||
|
@ -24,7 +24,7 @@ import { create } from '../utils';
|
||||
const STYLE_LIST = ['success', 'fail', 'loading'];
|
||||
|
||||
export default create({
|
||||
name: 'van-toast',
|
||||
name: 'toast',
|
||||
|
||||
props: {
|
||||
mask: Boolean,
|
||||
|
@ -31,7 +31,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-tree-select',
|
||||
name: 'tree-select',
|
||||
|
||||
props: {
|
||||
items: {
|
||||
|
@ -16,7 +16,7 @@
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-uploader',
|
||||
name: 'uploader',
|
||||
|
||||
inheritAttrs: false,
|
||||
|
||||
|
@ -2,18 +2,24 @@
|
||||
* Create a component with common options
|
||||
*/
|
||||
import '../locale';
|
||||
import Icon from '../icon';
|
||||
import i18n from '../mixins/i18n';
|
||||
import install from './install';
|
||||
import Icon from '../icon';
|
||||
import Loading from '../loading';
|
||||
import Cell from '../cell';
|
||||
import CellGroup from '../cell-group';
|
||||
|
||||
export default function(sfc) {
|
||||
sfc.name = 'van-' + sfc.name;
|
||||
sfc.install = sfc.install || install;
|
||||
sfc.mixins = sfc.mixins || [];
|
||||
sfc.mixins.push(i18n);
|
||||
sfc.components = sfc.components || {};
|
||||
sfc.components.icon = Icon;
|
||||
sfc.components.loading = Loading;
|
||||
sfc.components = Object.assign(sfc.components || {}, {
|
||||
Icon,
|
||||
Loading,
|
||||
Cell,
|
||||
CellGroup
|
||||
});
|
||||
|
||||
return sfc;
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
export default function mobile(value) {
|
||||
return /^((\+86)|(86))?(1)\d{10}$/.test(value) ||
|
||||
/^\+?(9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1|)-?\d{1,14}$/.test(String(value));
|
||||
value = value.replace(/[^-|\d]/g, '');
|
||||
return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9\-]{10,13}$/.test(value);
|
||||
}
|
||||
|
@ -7,3 +7,7 @@
|
||||
@import "./common/ellipsis.css";
|
||||
@import "./common/hairline.css";
|
||||
@import "./common/animation.css";
|
||||
@import './icon.css';
|
||||
@import './loading.css';
|
||||
@import './button.css';
|
||||
@import './cell.css';
|
||||
|
@ -4,10 +4,6 @@
|
||||
|
||||
/* base */
|
||||
@import './base.css';
|
||||
@import './icon.css';
|
||||
@import './loading.css';
|
||||
@import './button.css';
|
||||
@import './cell.css';
|
||||
|
||||
/* common components */
|
||||
@import './col.css';
|
||||
|
@ -99,42 +99,42 @@ describe('AddressEdit', () => {
|
||||
const saveButton = wrapper.find('.van-button')[0];
|
||||
|
||||
// name empty
|
||||
wrapper.vm.currentInfo.name = '';
|
||||
wrapper.vm.data.name = '';
|
||||
saveButton.trigger('click');
|
||||
expect(wrapper.vm.errorInfo['name']).to.be.true;
|
||||
wrapper.find('.van-field__control')[0].trigger('focus');
|
||||
expect(wrapper.vm.errorInfo['name']).to.be.false;
|
||||
|
||||
// name too long
|
||||
wrapper.vm.currentInfo.name = '111111111111111111111111111';
|
||||
wrapper.vm.data.name = '111111111111111111111111111';
|
||||
saveButton.trigger('click');
|
||||
expect(wrapper.vm.errorInfo['name']).to.be.true;
|
||||
wrapper.find('.van-field__control')[0].trigger('focus');
|
||||
expect(wrapper.vm.errorInfo['name']).to.be.false;
|
||||
|
||||
// tel empty
|
||||
wrapper.vm.currentInfo.name = '123';
|
||||
wrapper.vm.currentInfo.tel = '';
|
||||
wrapper.vm.data.name = '123';
|
||||
wrapper.vm.data.tel = '';
|
||||
saveButton.trigger('click');
|
||||
expect(wrapper.vm.errorInfo['tel']).to.be.true;
|
||||
wrapper.find('.van-field__control')[1].trigger('focus');
|
||||
expect(wrapper.vm.errorInfo['tel']).to.be.false;
|
||||
|
||||
// area_code empty
|
||||
wrapper.vm.currentInfo.tel = '13000000000';
|
||||
wrapper.vm.currentInfo.area_code = '';
|
||||
wrapper.vm.data.tel = '13000000000';
|
||||
wrapper.vm.data.area_code = '';
|
||||
saveButton.trigger('click');
|
||||
expect(wrapper.vm.errorInfo['area_code']).to.be.true;
|
||||
|
||||
// area_code invalid
|
||||
wrapper.vm.currentInfo.tel = '13000000000';
|
||||
wrapper.vm.currentInfo.area_code = '-1';
|
||||
wrapper.vm.data.tel = '13000000000';
|
||||
wrapper.vm.data.area_code = '-1';
|
||||
saveButton.trigger('click');
|
||||
expect(wrapper.vm.errorInfo['area_code']).to.be.true;
|
||||
|
||||
// address_detail empty
|
||||
wrapper.vm.currentInfo.area_code = '100000';
|
||||
wrapper.vm.currentInfo.address_detail = '';
|
||||
wrapper.vm.data.area_code = '100000';
|
||||
wrapper.vm.data.address_detail = '';
|
||||
saveButton.trigger('click');
|
||||
expect(wrapper.vm.errorInfo['address_detail']).to.be.true;
|
||||
wrapper.find('.van-field__control')[2].trigger('focus');
|
||||
@ -145,26 +145,26 @@ describe('AddressEdit', () => {
|
||||
for (let i = 0; i < 300; i++) {
|
||||
longAddress += '1';
|
||||
}
|
||||
wrapper.vm.currentInfo.address_detail = longAddress;
|
||||
wrapper.vm.data.address_detail = longAddress;
|
||||
saveButton.trigger('click');
|
||||
expect(wrapper.vm.errorInfo['address_detail']).to.be.true;
|
||||
wrapper.find('.van-field__control')[2].trigger('focus');
|
||||
expect(wrapper.vm.errorInfo['address_detail']).to.be.false;
|
||||
|
||||
// postal_code invalid
|
||||
wrapper.vm.currentInfo.address_detail = '123';
|
||||
wrapper.vm.currentInfo.postal_code = '123';
|
||||
wrapper.vm.data.address_detail = '123';
|
||||
wrapper.vm.data.postal_code = '123';
|
||||
saveButton.trigger('click');
|
||||
expect(wrapper.vm.errorInfo['postal_code']).to.be.true;
|
||||
wrapper.find('.van-field__control')[3].trigger('focus');
|
||||
expect(wrapper.vm.errorInfo['postal_code']).to.be.false;
|
||||
|
||||
// valid result
|
||||
wrapper.vm.currentInfo.postal_code = '123456';
|
||||
wrapper.vm.data.postal_code = '123456';
|
||||
saveButton.trigger('click');
|
||||
|
||||
// not show postal_code
|
||||
wrapper.vm.currentInfo.postal_code = '156';
|
||||
wrapper.vm.data.postal_code = '156';
|
||||
wrapper.vm.showPostal = false;
|
||||
saveButton.trigger('click');
|
||||
expect(wrapper.vm.errorInfo['postal_code']).to.be.false;
|
||||
@ -235,17 +235,17 @@ describe('AddressEdit', () => {
|
||||
wrapper.vm.onAreaConfirm([{ code: -1 }]);
|
||||
wrapper.vm.onAreaConfirm([{ code: 1 }, { code: -1 }]);
|
||||
wrapper.vm.onAreaConfirm([{ code: 1 }, { code: 1 }, { code: -1 }]);
|
||||
expect(wrapper.vm.currentInfo['area_code']).to.equal('');
|
||||
expect(wrapper.vm.data['area_code']).to.equal('');
|
||||
|
||||
wrapper.vm.onAreaConfirm([
|
||||
{ name: '浙江省' },
|
||||
{ name: '杭州市' },
|
||||
{ name: '西湖区', code: '123456' }
|
||||
]);
|
||||
expect(wrapper.vm.currentInfo['province']).to.equal('浙江省');
|
||||
expect(wrapper.vm.currentInfo['city']).to.equal('杭州市');
|
||||
expect(wrapper.vm.currentInfo['county']).to.equal('西湖区');
|
||||
expect(wrapper.vm.currentInfo['area_code']).to.equal('123456');
|
||||
expect(wrapper.vm.data['province']).to.equal('浙江省');
|
||||
expect(wrapper.vm.data['city']).to.equal('杭州市');
|
||||
expect(wrapper.vm.data['county']).to.equal('西湖区');
|
||||
expect(wrapper.vm.data['area_code']).to.equal('123456');
|
||||
});
|
||||
|
||||
it('delete address', done => {
|
||||
@ -308,7 +308,7 @@ describe('AddressEdit', () => {
|
||||
wrapper.vm.$nextTick(() => {
|
||||
wrapper.find('.van-field__icon')[0].trigger('touchstart');
|
||||
wrapper.vm.$nextTick(() => {
|
||||
expect(wrapper.vm.currentInfo.address_detail).to.equal('');
|
||||
expect(wrapper.vm.data.address_detail).to.equal('');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -352,7 +352,7 @@ describe('AddressEdit', () => {
|
||||
|
||||
wrapper.setProps({ addressInfo });
|
||||
wrapper.vm.$nextTick(() => {
|
||||
expect(wrapper.vm.currentInfo.name).to.equal('123');
|
||||
expect(wrapper.vm.data.name).to.equal('123');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -375,7 +375,7 @@ describe('AddressEdit', () => {
|
||||
|
||||
wrapper.vm.setAreaCode('110101');
|
||||
setTimeout(() => {
|
||||
expect(wrapper.vm.currentInfo.area_code).to.eql('110101');
|
||||
expect(wrapper.vm.data.area_code).to.eql('110101');
|
||||
expect(wrapper.vm.getArea()).to.eql([
|
||||
{ code: '110000', name: '北京市' },
|
||||
{ code: '110100', name: '北京市' },
|
||||
@ -399,22 +399,22 @@ describe('AddressEdit', () => {
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.vm.currentInfo.city).to.equal('');
|
||||
expect(wrapper.vm.data.city).to.equal('');
|
||||
wrapper.vm.areaList = areaList;
|
||||
|
||||
setTimeout(() => {
|
||||
expect(wrapper.vm.currentInfo.city).to.equal('温州市');
|
||||
expect(wrapper.vm.data.city).to.equal('温州市');
|
||||
|
||||
wrapper.vm.addressInfo = { area_code: '' };
|
||||
wrapper.vm.areaList = {};
|
||||
|
||||
setTimeout(() => {
|
||||
expect(wrapper.vm.currentInfo.city).to.equal('');
|
||||
expect(wrapper.vm.data.city).to.equal('');
|
||||
wrapper.vm.areaList = areaList;
|
||||
wrapper.vm.addressInfo = { area_code: '330304' };
|
||||
|
||||
setTimeout(() => {
|
||||
expect(wrapper.vm.currentInfo.city).to.equal('温州市');
|
||||
expect(wrapper.vm.data.city).to.equal('温州市');
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
|
@ -179,36 +179,36 @@ describe('ContactEdit', () => {
|
||||
const saveButton = wrapper.find('.van-button')[0];
|
||||
|
||||
// name empty
|
||||
wrapper.vm.contactInfo.name = '';
|
||||
wrapper.vm.data.name = '';
|
||||
saveButton.trigger('click');
|
||||
expect(wrapper.vm.errorInfo['name']).to.be.true;
|
||||
wrapper.find('.van-field__control')[0].trigger('focus');
|
||||
expect(wrapper.vm.errorInfo['name']).to.be.false;
|
||||
|
||||
// name too long
|
||||
wrapper.vm.contactInfo.name = '111111111111111111111111111';
|
||||
wrapper.vm.data.name = '111111111111111111111111111';
|
||||
saveButton.trigger('click');
|
||||
expect(wrapper.vm.errorInfo['name']).to.be.true;
|
||||
wrapper.find('.van-field__control')[0].trigger('focus');
|
||||
expect(wrapper.vm.errorInfo['name']).to.be.false;
|
||||
|
||||
// tel empty
|
||||
wrapper.vm.contactInfo.name = '123';
|
||||
wrapper.vm.contactInfo.tel = '';
|
||||
wrapper.vm.data.name = '123';
|
||||
wrapper.vm.data.tel = '';
|
||||
saveButton.trigger('click');
|
||||
expect(wrapper.vm.errorInfo['tel']).to.be.true;
|
||||
wrapper.find('.van-field__control')[1].trigger('focus');
|
||||
expect(wrapper.vm.errorInfo['tel']).to.be.false;
|
||||
|
||||
// tel invalid
|
||||
wrapper.vm.contactInfo.tel = 'abc';
|
||||
wrapper.vm.data.tel = 'abc';
|
||||
saveButton.trigger('click');
|
||||
expect(wrapper.vm.errorInfo['tel']).to.be.true;
|
||||
wrapper.find('.van-field__control')[1].trigger('focus');
|
||||
expect(wrapper.vm.errorInfo['tel']).to.be.false;
|
||||
|
||||
// saving
|
||||
wrapper.vm.contactInfo.tel = '13000000000';
|
||||
wrapper.vm.data.tel = '13000000000';
|
||||
saveButton.trigger('click');
|
||||
wrapper.vm.isSaving = true;
|
||||
saveButton.trigger('click');
|
||||
@ -260,7 +260,7 @@ describe('ContactEdit', () => {
|
||||
|
||||
wrapper.setProps({ contactInfo });
|
||||
wrapper.vm.$nextTick(() => {
|
||||
expect(wrapper.vm.currentInfo.name).to.equal('123');
|
||||
expect(wrapper.vm.data.name).to.equal('123');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user