mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 18:36:51 +08:00
Merge pull request #87 from chenjiahan/dev
directory adjust: delete entry index.js
This commit is contained in:
commit
f141c65306
@ -1,3 +0,0 @@
|
|||||||
import ActionSheet from './src/actionsheet';
|
|
||||||
|
|
||||||
export default ActionSheet;
|
|
@ -27,9 +27,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Popup from '../../mixins/popup';
|
import Popup from '../mixins/popup';
|
||||||
import VanIcon from '../../icon';
|
import VanIcon from '../icon';
|
||||||
import VanLoading from '../../loading';
|
import VanLoading from '../loading';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'van-actionsheet',
|
name: 'van-actionsheet',
|
@ -1,3 +0,0 @@
|
|||||||
import BadgeGroup from '../badge/src/badge-group';
|
|
||||||
|
|
||||||
export default BadgeGroup;
|
|
@ -1,3 +0,0 @@
|
|||||||
import Badge from './src/badge';
|
|
||||||
|
|
||||||
export default Badge;
|
|
@ -1,3 +1,76 @@
|
|||||||
import Button from './src/button';
|
import Loading from '../loading';
|
||||||
|
|
||||||
export default Button;
|
const ALLOWED_SIZE = ['mini', 'small', 'normal', 'large'];
|
||||||
|
const ALLOWED_TYPE = ['default', 'danger', 'primary'];
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'van-button',
|
||||||
|
|
||||||
|
components: {
|
||||||
|
[Loading.name]: Loading
|
||||||
|
},
|
||||||
|
|
||||||
|
props: {
|
||||||
|
block: Boolean,
|
||||||
|
loading: Boolean,
|
||||||
|
disabled: Boolean,
|
||||||
|
nativeType: String,
|
||||||
|
bottomAction: Boolean,
|
||||||
|
tag: {
|
||||||
|
type: String,
|
||||||
|
default: 'button'
|
||||||
|
},
|
||||||
|
type: {
|
||||||
|
type: String,
|
||||||
|
default: 'default',
|
||||||
|
validator: value => ALLOWED_TYPE.indexOf(value) > -1
|
||||||
|
},
|
||||||
|
size: {
|
||||||
|
type: String,
|
||||||
|
default: 'normal',
|
||||||
|
validator: value => ALLOWED_SIZE.indexOf(value) > -1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
onClick(event) {
|
||||||
|
if (!this.loading && !this.disabled) {
|
||||||
|
this.$emit('click', event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
render(h) {
|
||||||
|
const { type, loading, disabled, tag: Tag } = this;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tag
|
||||||
|
type={this.nativeType}
|
||||||
|
disabled={disabled}
|
||||||
|
class={[
|
||||||
|
'van-button',
|
||||||
|
'van-button--' + type,
|
||||||
|
'van-button--' + this.size,
|
||||||
|
{
|
||||||
|
'van-button--disabled': disabled,
|
||||||
|
'van-button--loading': loading,
|
||||||
|
'van-button--block': this.block,
|
||||||
|
'van-button--bottom-action': this.bottomAction
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
onClick={this.onClick}
|
||||||
|
>
|
||||||
|
{loading
|
||||||
|
? <van-loading
|
||||||
|
class="van-button__icon-loading"
|
||||||
|
type="circle"
|
||||||
|
color={type === 'default' ? 'black' : 'white'}
|
||||||
|
/>
|
||||||
|
: null}
|
||||||
|
<span class="van-button__text">
|
||||||
|
{this.$slots.default}
|
||||||
|
</span>
|
||||||
|
</Tag>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@ -1,76 +0,0 @@
|
|||||||
import Loading from '../../loading';
|
|
||||||
|
|
||||||
const ALLOWED_SIZE = ['mini', 'small', 'normal', 'large'];
|
|
||||||
const ALLOWED_TYPE = ['default', 'danger', 'primary'];
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'van-button',
|
|
||||||
|
|
||||||
components: {
|
|
||||||
[Loading.name]: Loading
|
|
||||||
},
|
|
||||||
|
|
||||||
props: {
|
|
||||||
block: Boolean,
|
|
||||||
loading: Boolean,
|
|
||||||
disabled: Boolean,
|
|
||||||
nativeType: String,
|
|
||||||
bottomAction: Boolean,
|
|
||||||
tag: {
|
|
||||||
type: String,
|
|
||||||
default: 'button'
|
|
||||||
},
|
|
||||||
type: {
|
|
||||||
type: String,
|
|
||||||
default: 'default',
|
|
||||||
validator: value => ALLOWED_TYPE.indexOf(value) > -1
|
|
||||||
},
|
|
||||||
size: {
|
|
||||||
type: String,
|
|
||||||
default: 'normal',
|
|
||||||
validator: value => ALLOWED_SIZE.indexOf(value) > -1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
onClick(event) {
|
|
||||||
if (!this.loading && !this.disabled) {
|
|
||||||
this.$emit('click', event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
render(h) {
|
|
||||||
const { type, loading, disabled, tag: Tag } = this;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Tag
|
|
||||||
type={this.nativeType}
|
|
||||||
disabled={disabled}
|
|
||||||
class={[
|
|
||||||
'van-button',
|
|
||||||
'van-button--' + type,
|
|
||||||
'van-button--' + this.size,
|
|
||||||
{
|
|
||||||
'van-button--disabled': disabled,
|
|
||||||
'van-button--loading': loading,
|
|
||||||
'van-button--block': this.block,
|
|
||||||
'van-button--bottom-action': this.bottomAction
|
|
||||||
}
|
|
||||||
]}
|
|
||||||
onClick={this.onClick}
|
|
||||||
>
|
|
||||||
{loading
|
|
||||||
? <van-loading
|
|
||||||
class="van-button__icon-loading"
|
|
||||||
type="circle"
|
|
||||||
color={type === 'default' ? 'black' : 'white'}
|
|
||||||
/>
|
|
||||||
: null}
|
|
||||||
<span class="van-button__text">
|
|
||||||
{this.$slots.default}
|
|
||||||
</span>
|
|
||||||
</Tag>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,3 +0,0 @@
|
|||||||
import Card from './src/card';
|
|
||||||
|
|
||||||
export default Card;
|
|
@ -1,3 +0,0 @@
|
|||||||
import CellGroup from '../cell/src/cell-group';
|
|
||||||
|
|
||||||
export default CellGroup;
|
|
@ -1,3 +0,0 @@
|
|||||||
import CellSwipe from './src/cell-swipe';
|
|
||||||
|
|
||||||
export default CellSwipe;
|
|
129
packages/cell-swipe/index.vue
Normal file
129
packages/cell-swipe/index.vue
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
<template>
|
||||||
|
<div v-clickoutside:touchstart="swipeMove" @click="swipeMove()" @touchstart="startDrag" @touchmove="onDrag" @touchend="endDrag" class="van-cell-swipe" ref="cell">
|
||||||
|
<div class="van-cell-wrapper">
|
||||||
|
<slot>单元格内容</slot>
|
||||||
|
</div>
|
||||||
|
<div class="van-cell-left">
|
||||||
|
<div ref="left">
|
||||||
|
<slot name="left"></slot>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="van-cell-right">
|
||||||
|
<div ref="right">
|
||||||
|
<slot name="right"></slot>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { once } from '../utils/dom';
|
||||||
|
import Clickoutside from '../utils/clickoutside';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'van-cell-swipe',
|
||||||
|
props: {
|
||||||
|
'leftWidth': { type: Number, default: 0 },
|
||||||
|
'rightWidth': { type: Number, default: 0 }
|
||||||
|
},
|
||||||
|
directives: { Clickoutside },
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
start: { x: 0, y: 0 }
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
leftDefaultTransform() {
|
||||||
|
return this.translate3d(-this.leftWidth - 1);
|
||||||
|
},
|
||||||
|
rightDefaultTransform() {
|
||||||
|
return this.translate3d(this.rightWidth);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.wrap = this.$refs.cell.querySelector('.van-cell-wrapper');
|
||||||
|
this.leftElm = this.$refs.left;
|
||||||
|
this.leftWrapElm = this.leftElm.parentNode;
|
||||||
|
this.leftWrapElm.style.webkitTransform = this.leftDefaultTransform;
|
||||||
|
|
||||||
|
this.rightElm = this.$refs.right;
|
||||||
|
this.rightWrapElm = this.rightElm.parentNode;
|
||||||
|
this.rightWrapElm.style.webkitTransform = this.rightDefaultTransform;
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
resetSwipeStatus() {
|
||||||
|
this.swiping = false; // 是否正在拖动
|
||||||
|
this.opened = true; // 记录是否滑动左右 或者 注册
|
||||||
|
this.offsetLeft = 0; // 记录单次拖动的拖动距离
|
||||||
|
},
|
||||||
|
translate3d(offset) {
|
||||||
|
return `translate3d(${offset}px, 0, 0)`;
|
||||||
|
},
|
||||||
|
swipeMove(offset = 0) {
|
||||||
|
this.wrap.style.webkitTransform = this.translate3d(offset);
|
||||||
|
this.rightWrapElm.style.webkitTransform = this.translate3d(this.rightWidth + offset);
|
||||||
|
this.leftWrapElm.style.webkitTransform = this.translate3d(-this.leftWidth + offset);
|
||||||
|
offset && (this.swiping = true);
|
||||||
|
},
|
||||||
|
swipeLeaveTransition(direction) {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.swipeLeave = true;
|
||||||
|
// left
|
||||||
|
if (direction > 0 && -this.offsetLeft > this.rightWidth * 0.4 && this.rightWidth > 0) {
|
||||||
|
this.swipeMove(-this.rightWidth);
|
||||||
|
this.resetSwipeStatus();
|
||||||
|
return;
|
||||||
|
// right
|
||||||
|
} else if (direction < 0 && this.offsetLeft > this.leftWidth * 0.4 && this.leftWidth > 0) {
|
||||||
|
this.swipeMove(this.leftWidth);
|
||||||
|
this.resetSwipeStatus();
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
this.swipeMove(0);
|
||||||
|
once(this.wrap, 'webkitTransitionEnd', _ => {
|
||||||
|
this.wrap.style.webkitTransform = '';
|
||||||
|
this.rightWrapElm.style.webkitTransform = this.rightDefaultTransform;
|
||||||
|
this.leftWrapElm.style.webkitTransform = this.leftDefaultTransform;
|
||||||
|
this.swipeLeave = false;
|
||||||
|
this.swiping = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
},
|
||||||
|
startDrag(evt) {
|
||||||
|
evt = evt.changedTouches ? evt.changedTouches[0] : evt;
|
||||||
|
this.dragging = true;
|
||||||
|
this.start.x = evt.pageX;
|
||||||
|
this.start.y = evt.pageY;
|
||||||
|
},
|
||||||
|
onDrag(evt) {
|
||||||
|
if (this.opened) {
|
||||||
|
!this.swiping && this.swipeMove(0);
|
||||||
|
this.opened = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!this.dragging) return;
|
||||||
|
let swiping;
|
||||||
|
const e = evt.changedTouches ? evt.changedTouches[0] : evt;
|
||||||
|
const offsetTop = e.pageY - this.start.y;
|
||||||
|
const offsetLeft = this.offsetLeft = e.pageX - this.start.x;
|
||||||
|
if ((offsetLeft < 0 && -offsetLeft > this.rightWidth) ||
|
||||||
|
(offsetLeft > 0 && offsetLeft > this.leftWidth) ||
|
||||||
|
(offsetLeft > 0 && !this.leftWidth) ||
|
||||||
|
(offsetLeft < 0 && !this.rightWidth)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const y = Math.abs(offsetTop);
|
||||||
|
const x = Math.abs(offsetLeft);
|
||||||
|
swiping = !(x < 5 || (x >= 5 && y >= x * 1.73));
|
||||||
|
if (!swiping) return;
|
||||||
|
evt.preventDefault();
|
||||||
|
this.swipeMove(offsetLeft);
|
||||||
|
},
|
||||||
|
endDrag() {
|
||||||
|
if (!this.swiping) return;
|
||||||
|
this.swipeLeaveTransition(this.offsetLeft > 0 ? -1 : 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
@ -1,137 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div
|
|
||||||
v-clickoutside:touchstart="swipeMove"
|
|
||||||
@click="swipeMove()"
|
|
||||||
@touchstart="startDrag"
|
|
||||||
@touchmove="onDrag"
|
|
||||||
@touchend="endDrag"
|
|
||||||
class="van-cell-swipe"
|
|
||||||
ref="cell">
|
|
||||||
<div class="van-cell-wrapper">
|
|
||||||
<slot>单元格内容</slot>
|
|
||||||
</div>
|
|
||||||
<div class="van-cell-left">
|
|
||||||
<div ref="left">
|
|
||||||
<slot name="left"></slot>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="van-cell-right">
|
|
||||||
<div ref="right">
|
|
||||||
<slot name="right"></slot>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import {once} from '../../utils/dom';
|
|
||||||
import Clickoutside from '../../utils/clickoutside';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'van-cell-swipe',
|
|
||||||
props: {
|
|
||||||
'leftWidth': {type: Number, default: 0},
|
|
||||||
'rightWidth': {type: Number, default: 0}
|
|
||||||
},
|
|
||||||
directives: {Clickoutside},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
start: {x: 0, y: 0}
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
leftDefaultTransform(){
|
|
||||||
return this.translate3d(-this.leftWidth - 1);
|
|
||||||
},
|
|
||||||
rightDefaultTransform(){
|
|
||||||
return this.translate3d(this.rightWidth);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.wrap = this.$refs.cell.querySelector('.van-cell-wrapper');
|
|
||||||
this.leftElm = this.$refs.left;
|
|
||||||
this.leftWrapElm = this.leftElm.parentNode;
|
|
||||||
this.leftWrapElm.style.webkitTransform = this.leftDefaultTransform;
|
|
||||||
|
|
||||||
this.rightElm = this.$refs.right;
|
|
||||||
this.rightWrapElm = this.rightElm.parentNode;
|
|
||||||
this.rightWrapElm.style.webkitTransform = this.rightDefaultTransform;
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
resetSwipeStatus() {
|
|
||||||
this.swiping = false; // 是否正在拖动
|
|
||||||
this.opened = true; // 记录是否滑动左右 或者 注册
|
|
||||||
this.offsetLeft = 0; // 记录单次拖动的拖动距离
|
|
||||||
},
|
|
||||||
translate3d(offset) {
|
|
||||||
return `translate3d(${offset}px, 0, 0)`;
|
|
||||||
},
|
|
||||||
swipeMove(offset = 0) {
|
|
||||||
this.wrap.style.webkitTransform = this.translate3d(offset);
|
|
||||||
this.rightWrapElm.style.webkitTransform = this.translate3d(this.rightWidth + offset);
|
|
||||||
this.leftWrapElm.style.webkitTransform = this.translate3d(-this.leftWidth + offset);
|
|
||||||
offset && (this.swiping = true);
|
|
||||||
},
|
|
||||||
swipeLeaveTransition(direction) {
|
|
||||||
setTimeout(() => {
|
|
||||||
this.swipeLeave = true;
|
|
||||||
// left
|
|
||||||
if (direction > 0 && -this.offsetLeft > this.rightWidth * 0.4 && this.rightWidth > 0) {
|
|
||||||
this.swipeMove(-this.rightWidth);
|
|
||||||
this.resetSwipeStatus();
|
|
||||||
return;
|
|
||||||
// right
|
|
||||||
} else if (direction < 0 && this.offsetLeft > this.leftWidth * 0.4 && this.leftWidth > 0) {
|
|
||||||
this.swipeMove(this.leftWidth);
|
|
||||||
this.resetSwipeStatus();
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
this.swipeMove(0);
|
|
||||||
once(this.wrap, 'webkitTransitionEnd', _ => {
|
|
||||||
this.wrap.style.webkitTransform = '';
|
|
||||||
this.rightWrapElm.style.webkitTransform = this.rightDefaultTransform;
|
|
||||||
this.leftWrapElm.style.webkitTransform = this.leftDefaultTransform;
|
|
||||||
this.swipeLeave = false;
|
|
||||||
this.swiping = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, 0);
|
|
||||||
},
|
|
||||||
startDrag(evt) {
|
|
||||||
evt = evt.changedTouches ? evt.changedTouches[0] : evt;
|
|
||||||
this.dragging = true;
|
|
||||||
this.start.x = evt.pageX;
|
|
||||||
this.start.y = evt.pageY;
|
|
||||||
},
|
|
||||||
onDrag(evt) {
|
|
||||||
if (this.opened) {
|
|
||||||
!this.swiping && this.swipeMove(0);
|
|
||||||
this.opened = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!this.dragging) return;
|
|
||||||
let swiping;
|
|
||||||
const e = evt.changedTouches ? evt.changedTouches[0] : evt;
|
|
||||||
const offsetTop = e.pageY - this.start.y;
|
|
||||||
const offsetLeft = this.offsetLeft = e.pageX - this.start.x;
|
|
||||||
if ((offsetLeft < 0 && -offsetLeft > this.rightWidth) ||
|
|
||||||
(offsetLeft > 0 && offsetLeft > this.leftWidth) ||
|
|
||||||
(offsetLeft > 0 && !this.leftWidth) ||
|
|
||||||
(offsetLeft < 0 && !this.rightWidth)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const y = Math.abs(offsetTop);
|
|
||||||
const x = Math.abs(offsetLeft);
|
|
||||||
swiping = !(x < 5 || (x >= 5 && y >= x * 1.73));
|
|
||||||
if (!swiping) return;
|
|
||||||
evt.preventDefault();
|
|
||||||
this.swipeMove(offsetLeft);
|
|
||||||
},
|
|
||||||
endDrag() {
|
|
||||||
if (!this.swiping) return;
|
|
||||||
this.swipeLeaveTransition(this.offsetLeft > 0 ? -1 : 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
import Cell from './src/cell';
|
|
||||||
|
|
||||||
export default Cell;
|
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<a :class="['van-cell', { 'van-cell--required': required }]" :href="url" @click="handleClick">
|
<a :class="['van-cell', { 'van-cell--required': required }]" :href="url" @click="$emit('click')">
|
||||||
<div
|
<div
|
||||||
class="van-cell__title"
|
class="van-cell__title"
|
||||||
v-if="this.$slots.title || title"
|
v-if="this.$slots.title || title"
|
||||||
@ -42,12 +42,6 @@ export default {
|
|||||||
label: String,
|
label: String,
|
||||||
isLink: Boolean,
|
isLink: Boolean,
|
||||||
required: Boolean
|
required: Boolean
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
handleClick() {
|
|
||||||
this.$emit('click');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
@ -1,3 +0,0 @@
|
|||||||
import CheckboxGroup from '../checkbox/src/checkbox-group';
|
|
||||||
|
|
||||||
export default CheckboxGroup;
|
|
@ -1,3 +0,0 @@
|
|||||||
import Checkbox from './src/checkbox';
|
|
||||||
|
|
||||||
export default Checkbox;
|
|
@ -23,7 +23,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import findParent from '../../mixins/findParent';
|
import findParent from '../mixins/findParent';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'van-checkbox',
|
name: 'van-checkbox',
|
@ -1,3 +0,0 @@
|
|||||||
import Col from './src/col';
|
|
||||||
|
|
||||||
export default Col;
|
|
@ -1,3 +0,0 @@
|
|||||||
import DatetimePicker from './src/datetime-picker';
|
|
||||||
|
|
||||||
export default DatetimePicker;
|
|
@ -11,7 +11,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Picker from '../../picker';
|
import Picker from '../picker';
|
||||||
|
|
||||||
const allowedType = ['time', 'date', 'datetime'];
|
const allowedType = ['time', 'date', 'datetime'];
|
||||||
|
|
@ -14,8 +14,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Button from '../../button';
|
import Button from '../button';
|
||||||
import Popup from '../../mixins/popup';
|
import Popup from '../mixins/popup';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'van-dialog',
|
name: 'van-dialog',
|
@ -1,3 +1,97 @@
|
|||||||
import Dialog from './src/dialog.js';
|
import Vue from 'vue';
|
||||||
|
import Dialog from './dialog';
|
||||||
|
|
||||||
export default Dialog;
|
const DialogConstructor = Vue.extend(Dialog);
|
||||||
|
|
||||||
|
let currentDialog;
|
||||||
|
let instance;
|
||||||
|
let dialogQueue = [];
|
||||||
|
|
||||||
|
const defaultCallback = action => {
|
||||||
|
/* istanbul ignore else */
|
||||||
|
if (currentDialog) {
|
||||||
|
if (currentDialog.resolve && action === 'confirm') {
|
||||||
|
currentDialog.resolve(action);
|
||||||
|
} else if (currentDialog.reject && action === 'cancel') {
|
||||||
|
currentDialog.reject(action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const initInstance = () => {
|
||||||
|
instance = new DialogConstructor({
|
||||||
|
el: document.createElement('div')
|
||||||
|
});
|
||||||
|
|
||||||
|
instance.$on('input', value => {
|
||||||
|
instance.value = value;
|
||||||
|
})
|
||||||
|
instance.callback = defaultCallback;
|
||||||
|
};
|
||||||
|
|
||||||
|
const showNextDialog = () => {
|
||||||
|
if (!instance) {
|
||||||
|
initInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* istanbul ignore else */
|
||||||
|
if (!instance.value && dialogQueue.length > 0) {
|
||||||
|
currentDialog = dialogQueue.shift();
|
||||||
|
|
||||||
|
const { options } = currentDialog;
|
||||||
|
|
||||||
|
for (const prop in options) {
|
||||||
|
/* istanbul ignore else */
|
||||||
|
if (options.hasOwnProperty(prop)) {
|
||||||
|
instance[prop] = options[prop];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
instance.callback = options.callback || defaultCallback;
|
||||||
|
instance.value = true;
|
||||||
|
document.body.appendChild(instance.$el);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const DialogBox = options => {
|
||||||
|
return new Promise((resolve, reject) => { // eslint-disable-line
|
||||||
|
dialogQueue.push({
|
||||||
|
options: { ...options },
|
||||||
|
callback: options.callback,
|
||||||
|
resolve: resolve,
|
||||||
|
reject: reject
|
||||||
|
});
|
||||||
|
|
||||||
|
showNextDialog();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
DialogBox.alert = function(options) {
|
||||||
|
return DialogBox({
|
||||||
|
type: 'alert',
|
||||||
|
title: '',
|
||||||
|
message: '',
|
||||||
|
closeOnClickOverlay: false,
|
||||||
|
showCancelButton: false,
|
||||||
|
...options
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
DialogBox.confirm = function(options) {
|
||||||
|
return DialogBox({
|
||||||
|
type: 'confirm',
|
||||||
|
title: '',
|
||||||
|
message: '',
|
||||||
|
closeOnClickOverlay: true,
|
||||||
|
showCancelButton: true,
|
||||||
|
...options
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
DialogBox.close = function() {
|
||||||
|
instance.value = false;
|
||||||
|
dialogQueue = [];
|
||||||
|
currentDialog = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DialogBox;
|
||||||
|
@ -1,97 +0,0 @@
|
|||||||
import Vue from 'vue';
|
|
||||||
import Dialog from './dialog.vue';
|
|
||||||
|
|
||||||
const DialogConstructor = Vue.extend(Dialog);
|
|
||||||
|
|
||||||
let currentDialog;
|
|
||||||
let instance;
|
|
||||||
let dialogQueue = [];
|
|
||||||
|
|
||||||
const defaultCallback = action => {
|
|
||||||
/* istanbul ignore else */
|
|
||||||
if (currentDialog) {
|
|
||||||
if (currentDialog.resolve && action === 'confirm') {
|
|
||||||
currentDialog.resolve(action);
|
|
||||||
} else if (currentDialog.reject && action === 'cancel') {
|
|
||||||
currentDialog.reject(action);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const initInstance = () => {
|
|
||||||
instance = new DialogConstructor({
|
|
||||||
el: document.createElement('div')
|
|
||||||
});
|
|
||||||
|
|
||||||
instance.$on('input', value => {
|
|
||||||
instance.value = value;
|
|
||||||
})
|
|
||||||
instance.callback = defaultCallback;
|
|
||||||
};
|
|
||||||
|
|
||||||
const showNextDialog = () => {
|
|
||||||
if (!instance) {
|
|
||||||
initInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* istanbul ignore else */
|
|
||||||
if (!instance.value && dialogQueue.length > 0) {
|
|
||||||
currentDialog = dialogQueue.shift();
|
|
||||||
|
|
||||||
const { options } = currentDialog;
|
|
||||||
|
|
||||||
for (const prop in options) {
|
|
||||||
/* istanbul ignore else */
|
|
||||||
if (options.hasOwnProperty(prop)) {
|
|
||||||
instance[prop] = options[prop];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
instance.callback = options.callback || defaultCallback;
|
|
||||||
instance.value = true;
|
|
||||||
document.body.appendChild(instance.$el);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var DialogBox = options => {
|
|
||||||
return new Promise((resolve, reject) => { // eslint-disable-line
|
|
||||||
dialogQueue.push({
|
|
||||||
options: { ...options },
|
|
||||||
callback: options.callback,
|
|
||||||
resolve: resolve,
|
|
||||||
reject: reject
|
|
||||||
});
|
|
||||||
|
|
||||||
showNextDialog();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
DialogBox.alert = function(options) {
|
|
||||||
return DialogBox({
|
|
||||||
type: 'alert',
|
|
||||||
title: '',
|
|
||||||
message: '',
|
|
||||||
closeOnClickOverlay: false,
|
|
||||||
showCancelButton: false,
|
|
||||||
...options
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
DialogBox.confirm = function(options) {
|
|
||||||
return DialogBox({
|
|
||||||
type: 'confirm',
|
|
||||||
title: '',
|
|
||||||
message: '',
|
|
||||||
closeOnClickOverlay: true,
|
|
||||||
showCancelButton: true,
|
|
||||||
...options
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
DialogBox.close = function() {
|
|
||||||
instance.value = false;
|
|
||||||
dialogQueue = [];
|
|
||||||
currentDialog = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default DialogBox;
|
|
@ -1,3 +0,0 @@
|
|||||||
import Field from './src/field';
|
|
||||||
|
|
||||||
export default Field;
|
|
@ -48,8 +48,8 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
const VALID_TYPES = ['text', 'number', 'email', 'url', 'tel', 'date', 'time', 'datetime', 'password', 'textarea'];
|
const VALID_TYPES = ['text', 'number', 'email', 'url', 'tel', 'date', 'time', 'datetime', 'password', 'textarea'];
|
||||||
import vanCell from '../../cell';
|
import vanCell from '../cell';
|
||||||
import vanIcon from '../../icon';
|
import vanIcon from '../icon';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'van-field',
|
name: 'van-field',
|
@ -1,3 +0,0 @@
|
|||||||
import Icon from './src/icon';
|
|
||||||
|
|
||||||
export default Icon;
|
|
@ -12,9 +12,9 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import Popup from '../../mixins/popup';
|
import Popup from '../mixins/popup';
|
||||||
import VanSwipe from '../../swipe';
|
import VanSwipe from '../swipe';
|
||||||
import VanSwipeItem from '../../swipe-item';
|
import VanSwipeItem from '../swipe-item';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'van-image-preview',
|
name: 'van-image-preview',
|
@ -1,3 +1,35 @@
|
|||||||
import ImagePreview from './src/image-preview.js';
|
import Vue from 'vue';
|
||||||
|
import ImagePreview from './image-preview';
|
||||||
|
|
||||||
export default ImagePreview;
|
let instance;
|
||||||
|
|
||||||
|
const ImagePreviewConstructor = Vue.extend(ImagePreview);
|
||||||
|
|
||||||
|
const initInstance = () => {
|
||||||
|
/* istanbul ignore if */
|
||||||
|
if (Vue.prototype.$isServer) return;
|
||||||
|
instance = new ImagePreviewConstructor({
|
||||||
|
el: document.createElement('div')
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var ImagePreviewBox = images => {
|
||||||
|
/* istanbul ignore if */
|
||||||
|
if (Vue.prototype.$isServer) return;
|
||||||
|
if (!instance) {
|
||||||
|
initInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* istanbul ignore else */
|
||||||
|
if (!instance.value) {
|
||||||
|
instance.images = images;
|
||||||
|
|
||||||
|
document.body.appendChild(instance.$el);
|
||||||
|
|
||||||
|
Vue.nextTick(() => {
|
||||||
|
instance.value = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ImagePreviewBox;
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
import Vue from 'vue';
|
|
||||||
import ImagePreview from './image-preview.vue';
|
|
||||||
|
|
||||||
let instance;
|
|
||||||
|
|
||||||
const ImagePreviewConstructor = Vue.extend(ImagePreview);
|
|
||||||
|
|
||||||
const initInstance = () => {
|
|
||||||
/* istanbul ignore if */
|
|
||||||
if (Vue.prototype.$isServer) return;
|
|
||||||
instance = new ImagePreviewConstructor({
|
|
||||||
el: document.createElement('div')
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
var ImagePreviewBox = images => {
|
|
||||||
/* istanbul ignore if */
|
|
||||||
if (Vue.prototype.$isServer) return;
|
|
||||||
if (!instance) {
|
|
||||||
initInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* istanbul ignore else */
|
|
||||||
if (!instance.value) {
|
|
||||||
instance.images = images;
|
|
||||||
|
|
||||||
document.body.appendChild(instance.$el);
|
|
||||||
|
|
||||||
Vue.nextTick(() => {
|
|
||||||
instance.value = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ImagePreviewBox;
|
|
@ -1,3 +0,0 @@
|
|||||||
import Loading from './src/loading';
|
|
||||||
|
|
||||||
export default Loading;
|
|
@ -1,3 +0,0 @@
|
|||||||
import Panel from './src/panel';
|
|
||||||
|
|
||||||
export default Panel;
|
|
@ -1,3 +0,0 @@
|
|||||||
import Picker from './src/picker';
|
|
||||||
|
|
||||||
export default Picker;
|
|
@ -14,7 +14,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import translateUtil from '../../utils/transition';
|
import translateUtil from '../utils/transition';
|
||||||
import draggable from './draggable';
|
import draggable from './draggable';
|
||||||
|
|
||||||
const DEFAULT_ITEM_HEIGHT = 44;
|
const DEFAULT_ITEM_HEIGHT = 44;
|
@ -1,3 +0,0 @@
|
|||||||
import Popup from './src/popup';
|
|
||||||
|
|
||||||
export default Popup;
|
|
@ -7,7 +7,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Popup from '../../mixins/popup';
|
import Popup from '../mixins/popup';
|
||||||
export default {
|
export default {
|
||||||
name: 'van-popup',
|
name: 'van-popup',
|
||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
import Progress from './src/progress';
|
|
||||||
|
|
||||||
export default Progress;
|
|
@ -1,3 +0,0 @@
|
|||||||
import Quantity from './src/quantity';
|
|
||||||
|
|
||||||
export default Quantity;
|
|
@ -1,3 +0,0 @@
|
|||||||
import RadioGroup from '../radio/src/radio-group';
|
|
||||||
|
|
||||||
export default RadioGroup;
|
|
@ -1,3 +0,0 @@
|
|||||||
import Radio from './src/radio';
|
|
||||||
|
|
||||||
export default Radio;
|
|
@ -25,7 +25,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import findParent from '../../mixins/findParent';
|
import findParent from '../mixins/findParent';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'van-radio',
|
name: 'van-radio',
|
@ -1,3 +0,0 @@
|
|||||||
import Row from './src/row';
|
|
||||||
|
|
||||||
export default Row;
|
|
@ -1,3 +0,0 @@
|
|||||||
import Search from './src/search';
|
|
||||||
|
|
||||||
export default Search;
|
|
105
packages/search/index.vue
Normal file
105
packages/search/index.vue
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
<template>
|
||||||
|
<div
|
||||||
|
class="van-search"
|
||||||
|
v-clickoutside="handleClickoutside"
|
||||||
|
:class="{ 'van-search--focus': isFocus, 'van-search--showcase': type === 'showcase' }">
|
||||||
|
<div class="van-search__input-wrap">
|
||||||
|
<van-icon name="search"></van-icon>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
:placeholder="placeholder"
|
||||||
|
class="van-search__input"
|
||||||
|
v-model="value"
|
||||||
|
v-refocus="focusStatus"
|
||||||
|
@focus="handleFocus"
|
||||||
|
@keyup.enter="handleSearch">
|
||||||
|
<van-icon name="clear" @click="handleClean" v-show="isFocus"></van-icon>
|
||||||
|
</div>
|
||||||
|
<div class="van-search__cancel" v-show="type !== 'showcase' && isFocus" @click="handleBack">取消</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import VanIcon from '../icon';
|
||||||
|
import Clickoutside from '../utils/clickoutside';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'van-search',
|
||||||
|
|
||||||
|
components: {
|
||||||
|
VanIcon
|
||||||
|
},
|
||||||
|
|
||||||
|
props: {
|
||||||
|
placeholder: String,
|
||||||
|
type: {
|
||||||
|
type: String,
|
||||||
|
default: 'normal'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
value(val) {
|
||||||
|
this.$emit('change', val);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
value: '',
|
||||||
|
focusStatus: false,
|
||||||
|
isFocus: false
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
directives: {
|
||||||
|
Clickoutside,
|
||||||
|
refocus: {
|
||||||
|
update: function(el, state) {
|
||||||
|
if (state.value) {
|
||||||
|
el.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
/**
|
||||||
|
* 进入input焦点,出现close和取消
|
||||||
|
*/
|
||||||
|
handleFocus() {
|
||||||
|
this.isFocus = true;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点击close后清空vlaue后,再聚焦input框
|
||||||
|
*/
|
||||||
|
handleClean() {
|
||||||
|
this.value = '';
|
||||||
|
this.focusStatus = true;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点击取消后,清空所有回复最初状态
|
||||||
|
*/
|
||||||
|
handleBack() {
|
||||||
|
this.value = '';
|
||||||
|
this.focusStatus = false;
|
||||||
|
this.isFocus = false;
|
||||||
|
this.$emit('cancel');
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* input输入回车后,发送回调
|
||||||
|
*/
|
||||||
|
handleSearch() {
|
||||||
|
this.$emit('search', this.value);
|
||||||
|
},
|
||||||
|
|
||||||
|
handleClickoutside() {
|
||||||
|
this.isFocus = false;
|
||||||
|
this.focusStatus = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
@ -1,105 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div
|
|
||||||
class="van-search"
|
|
||||||
v-clickoutside="handleClickoutside"
|
|
||||||
:class="{ 'van-search--focus': isFocus, 'van-search--showcase': type === 'showcase' }">
|
|
||||||
<div class="van-search__input-wrap">
|
|
||||||
<van-icon name="search"></van-icon>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
:placeholder="placeholder"
|
|
||||||
class="van-search__input"
|
|
||||||
v-model="value"
|
|
||||||
v-refocus="focusStatus"
|
|
||||||
@focus="handleFocus"
|
|
||||||
@keyup.enter="handleSearch">
|
|
||||||
<van-icon name="clear" @click="handleClean" v-show="isFocus"></van-icon>
|
|
||||||
</div>
|
|
||||||
<div class="van-search__cancel" v-show="type !== 'showcase' && isFocus" @click="handleBack">取消</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import VanIcon from '../../icon';
|
|
||||||
import Clickoutside from '../../utils/clickoutside';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'van-search',
|
|
||||||
|
|
||||||
components: {
|
|
||||||
VanIcon
|
|
||||||
},
|
|
||||||
|
|
||||||
props: {
|
|
||||||
placeholder: String,
|
|
||||||
type: {
|
|
||||||
type: String,
|
|
||||||
default: 'normal'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
watch: {
|
|
||||||
value(val) {
|
|
||||||
this.$emit('change', val);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
value: '',
|
|
||||||
focusStatus: false,
|
|
||||||
isFocus: false
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
directives: {
|
|
||||||
Clickoutside,
|
|
||||||
refocus: {
|
|
||||||
update: function(el, state) {
|
|
||||||
if (state.value) {
|
|
||||||
el.focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
/**
|
|
||||||
* 进入input焦点,出现close和取消
|
|
||||||
*/
|
|
||||||
handleFocus() {
|
|
||||||
this.isFocus = true;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 点击close后清空vlaue后,再聚焦input框
|
|
||||||
*/
|
|
||||||
handleClean() {
|
|
||||||
this.value = '';
|
|
||||||
this.focusStatus = true;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 点击取消后,清空所有回复最初状态
|
|
||||||
*/
|
|
||||||
handleBack() {
|
|
||||||
this.value = '';
|
|
||||||
this.focusStatus = false;
|
|
||||||
this.isFocus = false;
|
|
||||||
this.$emit('cancel');
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* input输入回车后,发送回调
|
|
||||||
*/
|
|
||||||
handleSearch() {
|
|
||||||
this.$emit('search', this.value);
|
|
||||||
},
|
|
||||||
|
|
||||||
handleClickoutside() {
|
|
||||||
this.isFocus = false;
|
|
||||||
this.focusStatus = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
@ -1,3 +0,0 @@
|
|||||||
import Step from '../steps/src/step';
|
|
||||||
|
|
||||||
export default Step;
|
|
@ -1,3 +0,0 @@
|
|||||||
import Steps from './src/steps';
|
|
||||||
|
|
||||||
export default Steps;
|
|
@ -24,7 +24,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Icon from '../../icon';
|
import Icon from '../icon';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'van-steps',
|
name: 'van-steps',
|
@ -1,3 +0,0 @@
|
|||||||
import SwipeItem from '../swipe/src/swipe-item';
|
|
||||||
|
|
||||||
export default SwipeItem;
|
|
@ -1,3 +0,0 @@
|
|||||||
import Swipe from './src/swipe';
|
|
||||||
|
|
||||||
export default Swipe;
|
|
@ -1,3 +0,0 @@
|
|||||||
import Switch from './src/switch';
|
|
||||||
|
|
||||||
export default Switch;
|
|
@ -8,7 +8,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import VanLoading from '../../loading';
|
import VanLoading from '../loading';
|
||||||
/**
|
/**
|
||||||
* van-switch
|
* van-switch
|
||||||
* @module components/switch
|
* @module components/switch
|
@ -1,2 +0,0 @@
|
|||||||
import Tab from './src/tab';
|
|
||||||
export default Tab;
|
|
36
packages/tab/index.vue
Normal file
36
packages/tab/index.vue
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<template>
|
||||||
|
<div class="van-tab__pane" :class="classNames">
|
||||||
|
<slot></slot>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'van-tab',
|
||||||
|
props: {
|
||||||
|
// 选项卡头显示文字
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
disabled: Boolean
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
const nextIndex = this.$parent.tabs.length;
|
||||||
|
this.$parent.tabs.push({
|
||||||
|
title: this.title,
|
||||||
|
disabled: this.disabled,
|
||||||
|
index: nextIndex
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
key: nextIndex
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
classNames() {
|
||||||
|
return { 'van-tab__pane--select': this.key === this.$parent.curActive };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
@ -1,36 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="van-tab__pane" :class="classNames">
|
|
||||||
<slot></slot>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
name: 'van-tab',
|
|
||||||
props: {
|
|
||||||
// 选项卡头显示文字
|
|
||||||
title: {
|
|
||||||
type: String,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
disabled: Boolean
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
const nextIndex = this.$parent.tabs.length;
|
|
||||||
this.$parent.tabs.push({
|
|
||||||
title: this.title,
|
|
||||||
disabled: this.disabled,
|
|
||||||
index: nextIndex
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
key: nextIndex
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
classNames() {
|
|
||||||
return { 'van-tab__pane--select': this.key === this.$parent.curActive };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
@ -1,3 +0,0 @@
|
|||||||
import Tabs from '../tab/src/tabs';
|
|
||||||
|
|
||||||
export default Tabs;
|
|
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import swipe from './swipe';
|
import swipe from './swipe';
|
||||||
import translateUtil from '../../utils/transition';
|
import translateUtil from '../utils/transition';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'van-tabs',
|
name: 'van-tabs',
|
@ -1,3 +0,0 @@
|
|||||||
import Tag from './src/main';
|
|
||||||
|
|
||||||
export default Tag;
|
|
@ -1,3 +1,79 @@
|
|||||||
import Toast from './src/toast';
|
import Vue from 'vue';
|
||||||
|
import merge from '../utils/merge';
|
||||||
|
import ToastComponent from './toast';
|
||||||
|
|
||||||
|
const ToastConstructor = Vue.extend(ToastComponent);
|
||||||
|
let instance;
|
||||||
|
|
||||||
|
const getInstance = () => {
|
||||||
|
if (instance) instance.clear();
|
||||||
|
|
||||||
|
instance = new ToastConstructor({
|
||||||
|
el: document.createElement('div')
|
||||||
|
});
|
||||||
|
return instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
const removeDom = event => {
|
||||||
|
/* istanbul ignore else */
|
||||||
|
if (event.target.parentNode) {
|
||||||
|
event.target.parentNode.removeChild(event.target);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var Toast = (options = {}) => {
|
||||||
|
const duration = options.duration || 3000;
|
||||||
|
|
||||||
|
const instance = getInstance();
|
||||||
|
|
||||||
|
instance.closed = false;
|
||||||
|
clearTimeout(instance.timer);
|
||||||
|
instance.type = options.type ? options.type : 'text';
|
||||||
|
instance.message = typeof options === 'string' ? options : options.message;
|
||||||
|
instance.forbidClick = options.forbidClick ? options.forbidClick : false;
|
||||||
|
instance.clear = () => {
|
||||||
|
if (instance.closed) return;
|
||||||
|
instance.visible = false;
|
||||||
|
instance.$el.addEventListener('transitionend', removeDom);
|
||||||
|
instance.closed = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
document.body.appendChild(instance.$el);
|
||||||
|
Vue.nextTick(function() {
|
||||||
|
instance.visible = true;
|
||||||
|
instance.$el.removeEventListener('transitionend', removeDom);
|
||||||
|
instance.timer = setTimeout(function() {
|
||||||
|
instance.clear();
|
||||||
|
}, duration);
|
||||||
|
});
|
||||||
|
return instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
Toast.loading = (options) => {
|
||||||
|
return new Toast(merge({
|
||||||
|
type: 'loading'
|
||||||
|
}, options));
|
||||||
|
};
|
||||||
|
|
||||||
|
Toast.success = (options) => {
|
||||||
|
const message = typeof options === 'string' ? options : options.message;
|
||||||
|
return new Toast(merge({
|
||||||
|
type: 'success',
|
||||||
|
message: message
|
||||||
|
}, options));
|
||||||
|
};
|
||||||
|
|
||||||
|
Toast.fail = (options) => {
|
||||||
|
const message = typeof options === 'string' ? options : options.message;
|
||||||
|
return new Toast(merge({
|
||||||
|
type: 'fail',
|
||||||
|
message: message
|
||||||
|
}, options));
|
||||||
|
};
|
||||||
|
|
||||||
|
Toast.clear = () => {
|
||||||
|
/* istanbul ignore else */
|
||||||
|
if (instance) instance.clear();
|
||||||
|
};
|
||||||
|
|
||||||
export default Toast;
|
export default Toast;
|
||||||
|
@ -1,79 +0,0 @@
|
|||||||
import Vue from 'vue';
|
|
||||||
import merge from '../../utils/merge';
|
|
||||||
import ToastComponent from './toast.vue';
|
|
||||||
|
|
||||||
const ToastConstructor = Vue.extend(ToastComponent);
|
|
||||||
let instance;
|
|
||||||
|
|
||||||
const getInstance = () => {
|
|
||||||
if (instance) instance.clear();
|
|
||||||
|
|
||||||
instance = new ToastConstructor({
|
|
||||||
el: document.createElement('div')
|
|
||||||
});
|
|
||||||
return instance;
|
|
||||||
};
|
|
||||||
|
|
||||||
const removeDom = event => {
|
|
||||||
/* istanbul ignore else */
|
|
||||||
if (event.target.parentNode) {
|
|
||||||
event.target.parentNode.removeChild(event.target);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var Toast = (options = {}) => {
|
|
||||||
const duration = options.duration || 3000;
|
|
||||||
|
|
||||||
const instance = getInstance();
|
|
||||||
|
|
||||||
instance.closed = false;
|
|
||||||
clearTimeout(instance.timer);
|
|
||||||
instance.type = options.type ? options.type : 'text';
|
|
||||||
instance.message = typeof options === 'string' ? options : options.message;
|
|
||||||
instance.forbidClick = options.forbidClick ? options.forbidClick : false;
|
|
||||||
instance.clear = () => {
|
|
||||||
if (instance.closed) return;
|
|
||||||
instance.visible = false;
|
|
||||||
instance.$el.addEventListener('transitionend', removeDom);
|
|
||||||
instance.closed = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
document.body.appendChild(instance.$el);
|
|
||||||
Vue.nextTick(function() {
|
|
||||||
instance.visible = true;
|
|
||||||
instance.$el.removeEventListener('transitionend', removeDom);
|
|
||||||
instance.timer = setTimeout(function() {
|
|
||||||
instance.clear();
|
|
||||||
}, duration);
|
|
||||||
});
|
|
||||||
return instance;
|
|
||||||
};
|
|
||||||
|
|
||||||
Toast.loading = (options) => {
|
|
||||||
return new Toast(merge({
|
|
||||||
type: 'loading'
|
|
||||||
}, options));
|
|
||||||
};
|
|
||||||
|
|
||||||
Toast.success = (options) => {
|
|
||||||
const message = typeof options === 'string' ? options : options.message;
|
|
||||||
return new Toast(merge({
|
|
||||||
type: 'success',
|
|
||||||
message: message
|
|
||||||
}, options));
|
|
||||||
};
|
|
||||||
|
|
||||||
Toast.fail = (options) => {
|
|
||||||
const message = typeof options === 'string' ? options : options.message;
|
|
||||||
return new Toast(merge({
|
|
||||||
type: 'fail',
|
|
||||||
message: message
|
|
||||||
}, options));
|
|
||||||
};
|
|
||||||
|
|
||||||
Toast.clear = () => {
|
|
||||||
/* istanbul ignore else */
|
|
||||||
if (instance) instance.clear();
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Toast;
|
|
@ -20,8 +20,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import vanLoading from '../../loading';
|
import vanLoading from '../loading';
|
||||||
import vanIcon from '../../icon';
|
import vanIcon from '../icon';
|
||||||
|
|
||||||
const TOAST_TYPES = ['text', 'html', 'loading', 'success', 'fail'];
|
const TOAST_TYPES = ['text', 'html', 'loading', 'success', 'fail'];
|
||||||
const DEFAULT_STYLE_LIST = ['success', 'fail'];
|
const DEFAULT_STYLE_LIST = ['success', 'fail'];
|
@ -1,3 +0,0 @@
|
|||||||
import Uploader from './src/main';
|
|
||||||
|
|
||||||
export default Uploader;
|
|
@ -1,8 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="van-uploader">
|
<div class="van-uploader">
|
||||||
<slot>
|
<slot></slot>
|
||||||
|
|
||||||
</slot>
|
|
||||||
<template v-if="disabled">
|
<template v-if="disabled">
|
||||||
<input type="file" @change="onValueChange" disabled="disabled" class="van-uploader__input" />
|
<input type="file" @change="onValueChange" disabled="disabled" class="van-uploader__input" />
|
||||||
</template>
|
</template>
|
@ -1,4 +1,4 @@
|
|||||||
import Utils from '../../utils/scroll.js';
|
import Utils from '../utils/scroll';
|
||||||
|
|
||||||
const CONTEXT = '@@Waterfall';
|
const CONTEXT = '@@Waterfall';
|
||||||
const OFFSET = 300;
|
const OFFSET = 300;
|
@ -1,3 +1,14 @@
|
|||||||
import Waterfall from './src/main.js';
|
import Waterfall from './directive.js';
|
||||||
|
import Vue from 'vue';
|
||||||
|
|
||||||
|
const install = function(Vue) {
|
||||||
|
Vue.directive('WaterfallLower', Waterfall('lower'));
|
||||||
|
Vue.directive('WaterfallUpper', Waterfall('upper'));
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!Vue.prototype.$isServer) {
|
||||||
|
Vue.use(install);
|
||||||
|
}
|
||||||
|
|
||||||
|
Waterfall.install = install;
|
||||||
export default Waterfall;
|
export default Waterfall;
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
import Waterfall from './directive.js';
|
|
||||||
import Vue from 'vue';
|
|
||||||
|
|
||||||
const install = function(Vue) {
|
|
||||||
Vue.directive('WaterfallLower', Waterfall('lower'));
|
|
||||||
Vue.directive('WaterfallUpper', Waterfall('upper'));
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!Vue.prototype.$isServer) {
|
|
||||||
Vue.use(install);
|
|
||||||
}
|
|
||||||
|
|
||||||
Waterfall.install = install;
|
|
||||||
export default Waterfall;
|
|
@ -74,23 +74,7 @@ const webpackConfig = {
|
|||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /test\/unit\/components\/.*\.vue$|packages\/swipe\/.*\.vue$/,
|
test: /\.vue$/,
|
||||||
use: [{
|
|
||||||
loader: 'vue-loader',
|
|
||||||
options: {
|
|
||||||
loaders: {
|
|
||||||
css: [
|
|
||||||
'style-loader',
|
|
||||||
'css-loader',
|
|
||||||
'postcss-loader'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /packages\/.*\.vue$/,
|
|
||||||
exclude: /packages\/swipe/,
|
|
||||||
use: [{
|
use: [{
|
||||||
loader: 'vue-loader',
|
loader: 'vue-loader',
|
||||||
options: {
|
options: {
|
||||||
@ -100,9 +84,7 @@ const webpackConfig = {
|
|||||||
'css-loader',
|
'css-loader',
|
||||||
'postcss-loader'
|
'postcss-loader'
|
||||||
],
|
],
|
||||||
js: [
|
js: ['isparta-loader']
|
||||||
'isparta-loader'
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import Picker from 'packages/picker';
|
import Picker from 'packages/picker';
|
||||||
import PickerColumn from 'packages/picker/src/picker-column';
|
import PickerColumn from 'packages/picker/picker-column';
|
||||||
import { mount } from 'avoriaz';
|
import { mount } from 'avoriaz';
|
||||||
import Wrapper from 'avoriaz/dist/Wrapper';
|
import Wrapper from 'avoriaz/dist/Wrapper';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user