mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
[build] 0.5.9
This commit is contained in:
parent
cded2c8a4f
commit
f7ab8449f9
4
dist/action-sheet/index.js
vendored
4
dist/action-sheet/index.js
vendored
@ -1,7 +1,7 @@
|
||||
import { VantComponent } from '../common/component';
|
||||
import { iphonex } from '../mixins/iphonex';
|
||||
import { safeArea } from '../mixins/safe-area';
|
||||
VantComponent({
|
||||
mixins: [iphonex],
|
||||
mixins: [safeArea()],
|
||||
props: {
|
||||
show: Boolean,
|
||||
title: String,
|
||||
|
1
dist/button/index.js
vendored
1
dist/button/index.js
vendored
@ -10,6 +10,7 @@ VantComponent({
|
||||
round: Boolean,
|
||||
square: Boolean,
|
||||
loading: Boolean,
|
||||
hairline: Boolean,
|
||||
disabled: Boolean,
|
||||
loadingText: String,
|
||||
type: {
|
||||
|
2
dist/button/index.wxml
vendored
2
dist/button/index.wxml
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
<button
|
||||
id="{{ id }}"
|
||||
class="custom-class {{ utils.bem('button', [type, size, { block, round, plain, square, loading, disabled, unclickable: disabled || loading }]) }}"
|
||||
class="custom-class {{ utils.bem('button', [type, size, { block, round, plain, square, loading, disabled, hairline, unclickable: disabled || loading }]) }} {{ hairline ? 'van-hairline--surround' : '' }}"
|
||||
open-type="{{ openType }}"
|
||||
hover-class="van-button--active hover-class"
|
||||
lang="{{ lang }}"
|
||||
|
2
dist/button/index.wxss
vendored
2
dist/button/index.wxss
vendored
@ -1 +1 @@
|
||||
@import '../common/index.wxss';.van-button{position:relative;display:inline-block;height:44px;padding:0;font-size:16px;line-height:42px;text-align:center;-webkit-text-size-adjust:100%;vertical-align:middle;border-radius:2px;box-sizing:border-box;-webkit-appearance:none}.van-button:after{position:absolute;top:50%;left:50%;width:100%;height:100%;background-color:#000;border:inherit;border-color:#000;border-radius:inherit;content:" ";opacity:0;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.van-button--active:after{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#333;background-color:#fff;border:1px solid #eee}.van-button--primary{color:#fff;background-color:#07c160;border:1px solid #07c160}.van-button--info{color:#fff;background-color:#1989fa;border:1px solid #1989fa}.van-button--danger{color:#fff;background-color:#f44;border:1px solid #f44}.van-button--warning{color:#fff;background-color:#ff976a;border:1px solid #ff976a}.van-button--plain{background-color:#fff}.van-button--plain.van-button--primary{color:#07c160}.van-button--plain.van-button--info{color:#1989fa}.van-button--plain.van-button--danger{color:#f44}.van-button--plain.van-button--warning{color:#ff976a}.van-button--large{width:100%;height:50px;line-height:48px}.van-button--normal{padding:0 15px;font-size:14px}.van-button--small{height:30px;min-width:60px;padding:0 8px;font-size:12px;line-height:28px}.van-button--mini{display:inline-block;width:50px;height:22px;font-size:10px;line-height:20px}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:block;width:100%}.van-button--round{border-radius:10em}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5}.van-button__loading-text{margin-left:5px;display:inline-block;vertical-align:middle}
|
||||
@import '../common/index.wxss';.van-button{position:relative;display:inline-block;height:44px;padding:0;font-size:16px;line-height:42px;text-align:center;vertical-align:middle;box-sizing:border-box;border-radius:2px;-webkit-appearance:none;-webkit-text-size-adjust:100%}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;background-color:#000;border:inherit;border-color:#000;border-radius:inherit;content:" ";opacity:0;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#333;background-color:#fff;border:1px solid #eee}.van-button--primary{color:#fff;background-color:#07c160;border:1px solid #07c160}.van-button--info{color:#fff;background-color:#1989fa;border:1px solid #1989fa}.van-button--danger{color:#fff;background-color:#f44;border:1px solid #f44}.van-button--warning{color:#fff;background-color:#ff976a;border:1px solid #ff976a}.van-button--plain{background-color:#fff}.van-button--plain.van-button--primary{color:#07c160}.van-button--plain.van-button--info{color:#1989fa}.van-button--plain.van-button--danger{color:#f44}.van-button--plain.van-button--warning{color:#ff976a}.van-button--large{width:100%;height:50px;line-height:48px}.van-button--normal{padding:0 15px;font-size:14px}.van-button--small{height:30px;min-width:60px;padding:0 8px;font-size:12px;line-height:28px}.van-button--mini{display:inline-block;width:50px;height:22px;font-size:10px;line-height:20px}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:block;width:100%}.van-button--round{border-radius:10em}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5}.van-button__loading-text{margin-left:5px;display:inline-block;vertical-align:middle}.van-button--hairline{border-width:0;padding-top:1px}.van-button--hairline:after{border-width:1px;border-color:inherit;border-radius:4px}.van-button--hairline.van-button--round:after{border-radius:10em}.van-button--hairline.van-button--square:after{border-radius:0}
|
4
dist/goods-action/index.js
vendored
4
dist/goods-action/index.js
vendored
@ -1,5 +1,5 @@
|
||||
import { VantComponent } from '../common/component';
|
||||
import { iphonex } from '../mixins/iphonex';
|
||||
import { safeArea } from '../mixins/safe-area';
|
||||
VantComponent({
|
||||
mixins: [iphonex]
|
||||
mixins: [safeArea()]
|
||||
});
|
||||
|
1
dist/icon/index.wxml
vendored
1
dist/icon/index.wxml
vendored
@ -13,5 +13,6 @@
|
||||
<image
|
||||
wx:if="{{ utils.isSrc(name) }}"
|
||||
src="{{ name }}"
|
||||
class="van-icon__image"
|
||||
/>
|
||||
</view>
|
||||
|
2
dist/icon/index.wxss
vendored
2
dist/icon/index.wxss
vendored
File diff suppressed because one or more lines are too long
1
dist/mixins/iphonex.d.ts
vendored
1
dist/mixins/iphonex.d.ts
vendored
@ -1 +0,0 @@
|
||||
export declare const iphonex: void;
|
32
dist/mixins/iphonex.js
vendored
32
dist/mixins/iphonex.js
vendored
@ -1,32 +0,0 @@
|
||||
let isIPhoneX = null;
|
||||
function getIsIPhoneX() {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (isIPhoneX !== null) {
|
||||
resolve(isIPhoneX);
|
||||
}
|
||||
else {
|
||||
wx.getSystemInfo({
|
||||
success: ({ model, screenHeight }) => {
|
||||
const iphoneX = /iphone x/i.test(model);
|
||||
const iphoneNew = /iPhone11/i.test(model) && screenHeight === 812;
|
||||
isIPhoneX = iphoneX || iphoneNew;
|
||||
resolve(isIPhoneX);
|
||||
},
|
||||
fail: reject
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
export const iphonex = Behavior({
|
||||
properties: {
|
||||
safeAreaInsetBottom: {
|
||||
type: Boolean,
|
||||
value: true
|
||||
}
|
||||
},
|
||||
created() {
|
||||
getIsIPhoneX().then(isIPhoneX => {
|
||||
this.set({ isIPhoneX });
|
||||
});
|
||||
}
|
||||
});
|
4
dist/mixins/safe-area.d.ts
vendored
Normal file
4
dist/mixins/safe-area.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
export declare const safeArea: ({ safeAreaInsetBottom, safeAreaInsetTop }?: {
|
||||
safeAreaInsetBottom?: boolean;
|
||||
safeAreaInsetTop?: boolean;
|
||||
}) => void;
|
39
dist/mixins/safe-area.js
vendored
Normal file
39
dist/mixins/safe-area.js
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
let cache = null;
|
||||
function getSafeArea() {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (cache != null) {
|
||||
resolve(cache);
|
||||
}
|
||||
else {
|
||||
wx.getSystemInfo({
|
||||
success: ({ model, screenHeight, statusBarHeight }) => {
|
||||
const iphoneX = /iphone x/i.test(model);
|
||||
const iphoneNew = /iPhone11/i.test(model) && screenHeight === 812;
|
||||
cache = {
|
||||
isIPhoneX: iphoneX || iphoneNew,
|
||||
statusBarHeight
|
||||
};
|
||||
resolve(cache);
|
||||
},
|
||||
fail: reject
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
export const safeArea = ({ safeAreaInsetBottom = true, safeAreaInsetTop = false } = {}) => Behavior({
|
||||
properties: {
|
||||
safeAreaInsetTop: {
|
||||
type: Boolean,
|
||||
value: safeAreaInsetTop
|
||||
},
|
||||
safeAreaInsetBottom: {
|
||||
type: Boolean,
|
||||
value: safeAreaInsetBottom
|
||||
}
|
||||
},
|
||||
created() {
|
||||
getSafeArea().then(({ isIPhoneX, statusBarHeight }) => {
|
||||
this.set({ isIPhoneX, statusBarHeight });
|
||||
});
|
||||
}
|
||||
});
|
4
dist/nav-bar/index.js
vendored
4
dist/nav-bar/index.js
vendored
@ -1,5 +1,7 @@
|
||||
import { VantComponent } from '../common/component';
|
||||
import { safeArea } from '../mixins/safe-area';
|
||||
VantComponent({
|
||||
mixins: [safeArea({ safeAreaInsetTop: true })],
|
||||
classes: ['title-class'],
|
||||
props: {
|
||||
title: String,
|
||||
@ -13,7 +15,7 @@ VantComponent({
|
||||
},
|
||||
zIndex: {
|
||||
type: Number,
|
||||
value: 1
|
||||
value: 120
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
6
dist/nav-bar/index.wxml
vendored
6
dist/nav-bar/index.wxml
vendored
@ -1,6 +1,8 @@
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<view
|
||||
class="custom-class van-nav-bar {{ border ? 'van-hairline--bottom' : '' }} {{ fixed ? 'van-nav-bar--fixed' : '' }}"
|
||||
style="z-index: {{ zIndex }}"
|
||||
class="{{ utils.bem('nav-bar', { fixed }) }} custom-class {{ border ? 'van-hairline--bottom' : '' }}"
|
||||
style="z-index: {{ zIndex }}; {{ safeAreaInsetTop ? 'padding-top: ' + statusBarHeight + 'px;' : '' }}"
|
||||
>
|
||||
<view class="van-nav-bar__left" bind:tap="onClickLeft">
|
||||
<block wx:if="{{ leftArrow || leftText }}">
|
||||
|
2
dist/nav-bar/index.wxss
vendored
2
dist/nav-bar/index.wxss
vendored
@ -1 +1 @@
|
||||
@import '../common/index.wxss';.van-nav-bar{position:relative;height:46px;line-height:46px;text-align:center;background-color:#fff;-webkit-user-select:none;user-select:none}.van-nav-bar__text{display:inline-block;padding:0 15px;margin:0 -15px;color:#1989fa;vertical-align:middle}.van-nav-bar__text--hover{background-color:#f2f3f5}.van-nav-bar__arrow{color:#1989fa;vertical-align:middle}.van-nav-bar__arrow+.van-nav-bar__text{padding-left:25px;margin-left:-20px}.van-nav-bar--fixed{position:fixed;top:0;left:0;width:100%}.van-nav-bar__title{max-width:60%;margin:0 auto;font-size:16px;font-weight:500}.van-nav-bar__left,.van-nav-bar__right{position:absolute;bottom:0;font-size:14px}.van-nav-bar__left{left:15px}.van-nav-bar__right{right:15px}
|
||||
@import '../common/index.wxss';.van-nav-bar{position:relative;height:44px;line-height:44px;text-align:center;background-color:#fff;-webkit-user-select:none;user-select:none}.van-nav-bar__text{display:inline-block;padding:0 15px;margin:0 -15px;color:#1989fa;vertical-align:middle}.van-nav-bar__text--hover{background-color:#f2f3f5}.van-nav-bar__arrow{color:#1989fa;vertical-align:middle}.van-nav-bar__arrow+.van-nav-bar__text{padding-left:25px;margin-left:-20px}.van-nav-bar--fixed{position:fixed;top:0;left:0;width:100%}.van-nav-bar__title{max-width:60%;margin:0 auto;font-size:16px;font-weight:500}.van-nav-bar__left,.van-nav-bar__right{position:absolute;bottom:0;font-size:14px}.van-nav-bar__left{left:15px}.van-nav-bar__right{right:15px}
|
2
dist/notify/index.js
vendored
2
dist/notify/index.js
vendored
@ -1,6 +1,8 @@
|
||||
import { VantComponent } from '../common/component';
|
||||
import { RED } from '../common/color';
|
||||
import { safeArea } from '../mixins/safe-area';
|
||||
VantComponent({
|
||||
mixins: [safeArea()],
|
||||
props: {
|
||||
text: String,
|
||||
color: {
|
||||
|
3
dist/notify/index.wxml
vendored
3
dist/notify/index.wxml
vendored
@ -2,7 +2,8 @@
|
||||
name="slide-down"
|
||||
show="{{ show }}"
|
||||
custom-class="van-notify"
|
||||
custom-style="background-color:{{ backgroundColor }}; color: {{ color }}"
|
||||
custom-style="background-color:{{ backgroundColor }}; color: {{ color }};"
|
||||
>
|
||||
<view wx:if="{{ safeAreaInsetTop }}" class="van-notify__safe-top" style="padding-top: {{ statusBarHeight }}px"></view>
|
||||
{{ text }}
|
||||
</van-transition>
|
||||
|
2
dist/notify/index.wxss
vendored
2
dist/notify/index.wxss
vendored
@ -1 +1 @@
|
||||
@import '../common/index.wxss';.van-notify{position:fixed;top:0;z-index:110;width:100%;padding:6px 15px;font-size:14px;line-height:20px;text-align:center;word-break:break-all;box-sizing:border-box}
|
||||
@import '../common/index.wxss';.van-notify{position:fixed;top:0;z-index:110;width:100%;padding:6px 15px;font-size:14px;line-height:20px;text-align:center;word-break:break-all;box-sizing:border-box}.van-notify__safe-top{height:44px}
|
8
dist/notify/notify.d.ts
vendored
8
dist/notify/notify.d.ts
vendored
@ -1,7 +1,11 @@
|
||||
declare type NotifyOptions = {
|
||||
selector?: string;
|
||||
text: string;
|
||||
color?: string;
|
||||
backgroundColor?: string;
|
||||
duration?: number;
|
||||
selector?: string;
|
||||
context?: any;
|
||||
safeAreaInsetTop?: boolean;
|
||||
};
|
||||
export default function Notify(options?: NotifyOptions): void;
|
||||
export default function Notify(options: NotifyOptions | string): void;
|
||||
export {};
|
||||
|
2
dist/notify/notify.js
vendored
2
dist/notify/notify.js
vendored
@ -10,7 +10,7 @@ function getContext() {
|
||||
const pages = getCurrentPages();
|
||||
return pages[pages.length - 1];
|
||||
}
|
||||
export default function Notify(options = {}) {
|
||||
export default function Notify(options) {
|
||||
options = Object.assign({}, defaultOptions, parseOptions(options));
|
||||
const context = options.context || getContext();
|
||||
const notify = context.selectComponent(options.selector);
|
||||
|
4
dist/popup/index.js
vendored
4
dist/popup/index.js
vendored
@ -1,6 +1,6 @@
|
||||
import { VantComponent } from '../common/component';
|
||||
import { transition } from '../mixins/transition';
|
||||
import { iphonex } from '../mixins/iphonex';
|
||||
import { safeArea } from '../mixins/safe-area';
|
||||
VantComponent({
|
||||
classes: [
|
||||
'enter-class',
|
||||
@ -10,7 +10,7 @@ VantComponent({
|
||||
'leave-active-class',
|
||||
'leave-to-class'
|
||||
],
|
||||
mixins: [transition(false), iphonex],
|
||||
mixins: [transition(false), safeArea()],
|
||||
props: {
|
||||
transition: {
|
||||
type: String,
|
||||
|
3
dist/popup/index.wxml
vendored
3
dist/popup/index.wxml
vendored
@ -11,9 +11,10 @@
|
||||
/>
|
||||
<view
|
||||
wx:if="{{ inited }}"
|
||||
class="custom-class {{ classes }} {{ utils.bem('popup', [position, { safe: isIPhoneX && safeAreaInsetBottom && position === 'bottom' }]) }}"
|
||||
class="custom-class {{ classes }} {{ utils.bem('popup', [position, { safe: isIPhoneX && safeAreaInsetBottom }]) }}"
|
||||
style="z-index: {{ zIndex }}; -webkit-transition-duration:{{ currentDuration }}ms; transition-duration:{{ currentDuration }}ms; {{ display ? '' : 'display: none;' }} {{ customStyle }}"
|
||||
bind:transitionend="onTransitionEnd"
|
||||
>
|
||||
<view wx:if="{{ safeAreaInsetTop }}" class="van-popup__safe-top" style="padding-top: {{ statusBarHeight }}px;"></view>
|
||||
<slot />
|
||||
</view>
|
||||
|
2
dist/popup/index.wxss
vendored
2
dist/popup/index.wxss
vendored
@ -1 +1 @@
|
||||
@import '../common/index.wxss';.van-popup{position:fixed;top:50%;left:50%;max-height:100%;overflow-y:auto;background-color:#fff;box-sizing:border-box;-webkit-animation:ease both;animation:ease both;-webkit-overflow-scrolling:touch;transition-timing-function:ease}.van-popup--center{-webkit-transform:translate3d(-50%,-50%,0);transform:translate3d(-50%,-50%,0)}.van-popup--top{top:0;right:auto;bottom:auto;left:50%;width:100%;-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0)}.van-popup--right{top:50%;right:0;bottom:auto;left:auto;-webkit-transform:translate3d(0,-50%,0);transform:translate3d(0,-50%,0)}.van-popup--bottom{top:auto;right:auto;bottom:0;left:50%;width:100%;-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0)}.van-popup--left{top:50%;right:auto;bottom:auto;left:0;-webkit-transform:translate3d(0,-50%,0);transform:translate3d(0,-50%,0)}.van-popup--safe{padding-bottom:34px}.van-scale-enter-active,.van-scale-leave-active{transition-property:opacity,-webkit-transform;transition-property:opacity,transform;transition-property:opacity,transform,-webkit-transform}.van-scale-enter,.van-scale-leave-to{opacity:0;-webkit-transform:translate3d(-50%,-50%,0) scale(.7);transform:translate3d(-50%,-50%,0) scale(.7)}.van-fade-enter-active,.van-fade-leave-active{transition-property:opacity}.van-fade-enter,.van-fade-leave-to{opacity:0}.van-center-enter-active,.van-center-leave-active{transition-property:opacity}.van-center-enter,.van-center-leave-to{opacity:0}.van-bottom-enter-active,.van-bottom-leave-active,.van-left-enter-active,.van-left-leave-active,.van-right-enter-active,.van-right-leave-active,.van-top-enter-active,.van-top-leave-active{transition-property:-webkit-transform;transition-property:transform;transition-property:transform,-webkit-transform}.van-bottom-enter,.van-bottom-leave-to{-webkit-transform:translate3d(-50%,100%,0);transform:translate3d(-50%,100%,0)}.van-top-enter,.van-top-leave-to{-webkit-transform:translate3d(-50%,-100%,0);transform:translate3d(-50%,-100%,0)}.van-left-enter,.van-left-leave-to{-webkit-transform:translate3d(-100%,-50%,0);transform:translate3d(-100%,-50%,0)}.van-right-enter,.van-right-leave-to{-webkit-transform:translate3d(100%,-50%,0);transform:translate3d(100%,-50%,0)}
|
||||
@import '../common/index.wxss';.van-popup{position:fixed;top:50%;left:50%;max-height:100%;overflow-y:auto;background-color:#fff;box-sizing:border-box;-webkit-animation:ease both;animation:ease both;-webkit-overflow-scrolling:touch;transition-timing-function:ease}.van-popup--center{-webkit-transform:translate3d(-50%,-50%,0);transform:translate3d(-50%,-50%,0)}.van-popup--top{top:0;right:auto;bottom:auto;left:50%;width:100%;-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0)}.van-popup--right{top:50%;right:0;bottom:auto;left:auto;-webkit-transform:translate3d(0,-50%,0);transform:translate3d(0,-50%,0)}.van-popup--bottom{top:auto;right:auto;bottom:0;left:50%;width:100%;-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0)}.van-popup--left{top:50%;right:auto;bottom:auto;left:0;-webkit-transform:translate3d(0,-50%,0);transform:translate3d(0,-50%,0)}.van-popup--bottom.van-popup--safe{padding-bottom:34px}.van-popup--left .van-popup__safe-top,.van-popup--right .van-popup__safe-top,.van-popup--top .van-popup__safe-top{height:44px}.van-popup--bottom .van-popup__safe-top,.van-popup--center .van-popup__safe-top{padding-top:0!important}.van-scale-enter-active,.van-scale-leave-active{transition-property:opacity,-webkit-transform;transition-property:opacity,transform;transition-property:opacity,transform,-webkit-transform}.van-scale-enter,.van-scale-leave-to{opacity:0;-webkit-transform:translate3d(-50%,-50%,0) scale(.7);transform:translate3d(-50%,-50%,0) scale(.7)}.van-fade-enter-active,.van-fade-leave-active{transition-property:opacity}.van-fade-enter,.van-fade-leave-to{opacity:0}.van-center-enter-active,.van-center-leave-active{transition-property:opacity}.van-center-enter,.van-center-leave-to{opacity:0}.van-bottom-enter-active,.van-bottom-leave-active,.van-left-enter-active,.van-left-leave-active,.van-right-enter-active,.van-right-leave-active,.van-top-enter-active,.van-top-leave-active{transition-property:-webkit-transform;transition-property:transform;transition-property:transform,-webkit-transform}.van-bottom-enter,.van-bottom-leave-to{-webkit-transform:translate3d(-50%,100%,0);transform:translate3d(-50%,100%,0)}.van-top-enter,.van-top-leave-to{-webkit-transform:translate3d(-50%,-100%,0);transform:translate3d(-50%,-100%,0)}.van-left-enter,.van-left-leave-to{-webkit-transform:translate3d(-100%,-50%,0);transform:translate3d(-100%,-50%,0)}.van-right-enter,.van-right-leave-to{-webkit-transform:translate3d(100%,-50%,0);transform:translate3d(100%,-50%,0)}
|
4
dist/slider/index.js
vendored
4
dist/slider/index.js
vendored
@ -47,7 +47,7 @@ VantComponent({
|
||||
if (this.data.disabled)
|
||||
return;
|
||||
this.touchMove(event);
|
||||
this.getRect('.van-slider').then(rect => {
|
||||
this.getRect('.van-slider').then((rect) => {
|
||||
const diff = this.deltaX / rect.width * 100;
|
||||
this.updateValue(this.startValue + diff, false, true);
|
||||
});
|
||||
@ -60,7 +60,7 @@ VantComponent({
|
||||
onClick(event) {
|
||||
if (this.data.disabled)
|
||||
return;
|
||||
this.getRect(rect => {
|
||||
this.getRect('.van-slider').then((rect) => {
|
||||
const value = (event.detail.x - rect.left) / rect.width * 100;
|
||||
this.updateValue(value, true);
|
||||
});
|
||||
|
4
dist/slider/index.wxml
vendored
4
dist/slider/index.wxml
vendored
@ -1,5 +1,7 @@
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<view
|
||||
class="custom-class van-slider {{ disabled ? 'van-slider--disabled' : '' }}"
|
||||
class="custom-class {{ utils.bem('slider', { disabled }) }}"
|
||||
style="{{ inactiveColor ? 'background:' + inactiveColor : '' }}"
|
||||
bind:tap="onClick"
|
||||
>
|
||||
|
1
dist/stepper/index.js
vendored
1
dist/stepper/index.js
vendored
@ -10,6 +10,7 @@ VantComponent({
|
||||
value: null,
|
||||
integer: Boolean,
|
||||
disabled: Boolean,
|
||||
inputWidth: String,
|
||||
asyncChange: Boolean,
|
||||
disableInput: Boolean,
|
||||
min: {
|
||||
|
1
dist/stepper/index.wxml
vendored
1
dist/stepper/index.wxml
vendored
@ -10,6 +10,7 @@
|
||||
<input
|
||||
type="{{ integer ? 'number' : 'digit' }}"
|
||||
class="input-class {{ utils.bem('stepper__input', { disabled: disabled || disableInput }) }}"
|
||||
style="{{ inputWidth ? 'width: ' + inputWidth : '' }}"
|
||||
value="{{ value }}"
|
||||
focus="{{ focus }}"
|
||||
disabled="{{ disabled || disableInput }}"
|
||||
|
4
dist/submit-bar/index.js
vendored
4
dist/submit-bar/index.js
vendored
@ -1,7 +1,7 @@
|
||||
import { VantComponent } from '../common/component';
|
||||
import { iphonex } from '../mixins/iphonex';
|
||||
import { safeArea } from '../mixins/safe-area';
|
||||
VantComponent({
|
||||
mixins: [iphonex],
|
||||
mixins: [safeArea()],
|
||||
classes: [
|
||||
'bar-class',
|
||||
'price-class',
|
||||
|
4
dist/swipe-cell/index.wxml
vendored
4
dist/swipe-cell/index.wxml
vendored
@ -1,8 +1,8 @@
|
||||
<view
|
||||
class="van-swipe-cell"
|
||||
data-key="cell"
|
||||
bindtap="onClick"
|
||||
catchtouchstart="startDrag"
|
||||
catchtap="onClick"
|
||||
bindtouchstart="startDrag"
|
||||
catchtouchmove="onDrag"
|
||||
catchtouchend="endDrag"
|
||||
catchtouchcancel="endDrag"
|
||||
|
13
dist/tabbar-item/index.js
vendored
13
dist/tabbar-item/index.js
vendored
@ -7,23 +7,26 @@ VantComponent({
|
||||
},
|
||||
relation: {
|
||||
name: 'tabbar',
|
||||
type: 'ancestor'
|
||||
type: 'ancestor',
|
||||
linked(target) {
|
||||
this.parent = target;
|
||||
}
|
||||
},
|
||||
data: {
|
||||
active: false
|
||||
},
|
||||
methods: {
|
||||
onClick() {
|
||||
const parent = this.getRelationNodes('../tabbar/index')[0];
|
||||
if (parent) {
|
||||
parent.onChange(this);
|
||||
if (this.parent) {
|
||||
this.parent.onChange(this);
|
||||
}
|
||||
this.$emit('click');
|
||||
},
|
||||
setActive({ active, color }) {
|
||||
if (this.data.active !== active) {
|
||||
this.set({ active, color });
|
||||
return this.set({ active, color });
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
6
dist/tabbar-item/index.wxml
vendored
6
dist/tabbar-item/index.wxml
vendored
@ -1,9 +1,11 @@
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<view
|
||||
class="van-tabbar-item custom-class {{ active ? 'van-tabbar-item--active' : '' }}"
|
||||
class="{{ utils.bem('tabbar-item', { active }) }} custom-class"
|
||||
style="{{ active && color ? 'color: ' + color : '' }}"
|
||||
bind:tap="onClick"
|
||||
>
|
||||
<view class="van-tabbar-item__icon {{ dot ? 'van-tabbar-item__icon--dot' : '' }}">
|
||||
<view class="{{ utils.bem('tabbar-item__icon', { dot }) }}">
|
||||
<van-icon
|
||||
wx:if="{{ icon }}"
|
||||
name="{{ icon }}"
|
||||
|
41
dist/tabbar/index.js
vendored
41
dist/tabbar/index.js
vendored
@ -1,21 +1,19 @@
|
||||
import { VantComponent } from '../common/component';
|
||||
import { iphonex } from '../mixins/iphonex';
|
||||
import { safeArea } from '../mixins/safe-area';
|
||||
VantComponent({
|
||||
mixins: [iphonex],
|
||||
mixins: [safeArea()],
|
||||
relation: {
|
||||
name: 'tabbar-item',
|
||||
type: 'descendant',
|
||||
linked(target) {
|
||||
this.data.items.push(target);
|
||||
setTimeout(() => {
|
||||
this.setActiveItem();
|
||||
});
|
||||
this.children = this.children || [];
|
||||
this.children.push(target);
|
||||
this.setActiveItem();
|
||||
},
|
||||
unlinked(target) {
|
||||
this.data.items = this.data.items.filter(item => item !== target);
|
||||
setTimeout(() => {
|
||||
this.setActiveItem();
|
||||
});
|
||||
this.children = this.children || [];
|
||||
this.children = this.children.filter(item => item !== target);
|
||||
this.setActiveItem();
|
||||
}
|
||||
},
|
||||
props: {
|
||||
@ -30,9 +28,6 @@ VantComponent({
|
||||
value: 1
|
||||
}
|
||||
},
|
||||
data: {
|
||||
items: []
|
||||
},
|
||||
watch: {
|
||||
active(active) {
|
||||
this.currentActive = active;
|
||||
@ -44,19 +39,21 @@ VantComponent({
|
||||
},
|
||||
methods: {
|
||||
setActiveItem() {
|
||||
this.data.items.forEach((item, index) => {
|
||||
item.setActive({
|
||||
active: index === this.currentActive,
|
||||
color: this.data.activeColor
|
||||
});
|
||||
});
|
||||
if (!Array.isArray(this.children) || !this.children.length) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return Promise.all(this.children.map((item, index) => item.setActive({
|
||||
active: index === this.currentActive,
|
||||
color: this.data.activeColor
|
||||
})));
|
||||
},
|
||||
onChange(child) {
|
||||
const active = this.data.items.indexOf(child);
|
||||
const active = (this.children || []).indexOf(child);
|
||||
if (active !== this.currentActive && active !== -1) {
|
||||
this.$emit('change', active);
|
||||
this.currentActive = active;
|
||||
this.setActiveItem();
|
||||
this.setActiveItem().then(() => {
|
||||
this.$emit('change', active);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
43
lib/action-sheet/index.js
Normal file
43
lib/action-sheet/index.js
Normal file
@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../common/component");
|
||||
var safe_area_1 = require("../mixins/safe-area");
|
||||
component_1.VantComponent({
|
||||
mixins: [safe_area_1.safeArea()],
|
||||
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
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onSelect: function (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 () {
|
||||
this.$emit('cancel');
|
||||
},
|
||||
onClose: function () {
|
||||
this.$emit('close');
|
||||
}
|
||||
}
|
||||
});
|
8
lib/action-sheet/index.json
Normal file
8
lib/action-sheet/index.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-icon": "../icon/index",
|
||||
"van-popup": "../popup/index",
|
||||
"van-loading": "../loading/index"
|
||||
}
|
||||
}
|
49
lib/action-sheet/index.wxml
Normal file
49
lib/action-sheet/index.wxml
Normal file
@ -0,0 +1,49 @@
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<van-popup
|
||||
show="{{ show }}"
|
||||
position="bottom"
|
||||
z-index="{{ zIndex }}"
|
||||
overlay="{{ overlay }}"
|
||||
custom-class="van-action-sheet"
|
||||
safe-area-inset-bottom="{{ safeAreaInsetBottom }}"
|
||||
close-on-click-overlay="{{ closeOnClickOverlay }}"
|
||||
bind:close="onClose"
|
||||
>
|
||||
<view wx:if="{{ title }}" class="van-hairline--bottom van-action-sheet__header">
|
||||
{{ title }}
|
||||
<van-icon
|
||||
name="close"
|
||||
custom-class="van-action-sheet__close"
|
||||
bind:click="onClose"
|
||||
/>
|
||||
</view>
|
||||
<view wx:if="{{ actions && actions.length }}">
|
||||
<!-- button外包一层view,防止actions动态变化,导致渲染时button被打散 -->
|
||||
<button
|
||||
wx:for="{{ actions }}"
|
||||
wx:key="index"
|
||||
open-type="{{ item.openType }}"
|
||||
class="{{ utils.bem('action-sheet__item', { disabled: item.disabled || item.loading }) }} van-hairline--top {{ item.className || '' }}"
|
||||
hover-class="van-action-sheet__item--hover"
|
||||
data-index="{{ index }}"
|
||||
bind:tap="onSelect"
|
||||
>
|
||||
<block wx:if="{{ !item.loading }}">
|
||||
{{ item.name }}
|
||||
<text wx:if="{{ item.subname }}" class="van-action-sheet__subname" >{{ item.subname }}</text>
|
||||
</block>
|
||||
<van-loading wx:else size="20px" />
|
||||
</button>
|
||||
</view>
|
||||
<slot />
|
||||
<view
|
||||
wx:if="{{ cancelText }}"
|
||||
class="van-action-sheet__cancel"
|
||||
hover-class="van-action-sheet__cancel--hover"
|
||||
hover-stay-time="70"
|
||||
bind:tap="onCancel"
|
||||
>
|
||||
{{ cancelText }}
|
||||
</view>
|
||||
</van-popup>
|
1
lib/action-sheet/index.wxss
Normal file
1
lib/action-sheet/index.wxss
Normal file
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';.van-action-sheet{max-height:90%!important;color:#333}.van-action-sheet__cancel,.van-action-sheet__item{height:50px;font-size:16px;line-height:50px;text-align:center;background-color:#fff}.van-action-sheet__cancel--hover,.van-action-sheet__item--hover{background-color:#f2f3f5}.van-action-sheet__cancel{height:60px}.van-action-sheet__cancel:before{display:block;height:10px;background-color:#f8f8f8;content:" "}.van-action-sheet__item--disabled{color:#c9c9c9}.van-action-sheet__item--disabled.van-action-sheet__item--hover{background-color:#fff}.van-action-sheet__subname{margin-left:5px;font-size:12px;color:#7d7e80}.van-action-sheet__header{font-size:16px;font-weight:500;line-height:44px;text-align:center}.van-action-sheet__close{position:absolute!important;top:0;right:0;padding:0 15px;font-size:18px!important;line-height:inherit!important;color:#999}
|
176
lib/area/index.js
Normal file
176
lib/area/index.js
Normal file
@ -0,0 +1,176 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../common/component");
|
||||
component_1.VantComponent({
|
||||
classes: ['active-class', 'toolbar-class', 'column-class'],
|
||||
props: {
|
||||
title: String,
|
||||
value: String,
|
||||
loading: Boolean,
|
||||
cancelButtonText: String,
|
||||
confirmButtonText: String,
|
||||
itemHeight: {
|
||||
type: Number,
|
||||
value: 44
|
||||
},
|
||||
visibleItemCount: {
|
||||
type: Number,
|
||||
value: 5
|
||||
},
|
||||
columnsNum: {
|
||||
type: [String, Number],
|
||||
value: 3
|
||||
},
|
||||
areaList: {
|
||||
type: Object,
|
||||
value: {}
|
||||
}
|
||||
},
|
||||
data: {
|
||||
columns: [{ values: [] }, { values: [] }, { values: [] }],
|
||||
displayColumns: [{ values: [] }, { values: [] }, { values: [] }]
|
||||
},
|
||||
watch: {
|
||||
value: function (value) {
|
||||
this.code = value;
|
||||
this.setValues();
|
||||
},
|
||||
areaList: 'setValues',
|
||||
columnsNum: function (value) {
|
||||
this.set({
|
||||
displayColumns: this.data.columns.slice(0, +value)
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getPicker: function () {
|
||||
if (this.picker == null) {
|
||||
this.picker = this.selectComponent('.van-area__picker');
|
||||
}
|
||||
return this.picker;
|
||||
},
|
||||
onCancel: function (event) {
|
||||
this.emit('cancel', event.detail);
|
||||
},
|
||||
onConfirm: function (event) {
|
||||
this.emit('confirm', event.detail);
|
||||
},
|
||||
emit: function (type, detail) {
|
||||
detail.values = detail.value;
|
||||
delete detail.value;
|
||||
this.$emit(type, detail);
|
||||
},
|
||||
onChange: function (event) {
|
||||
var _this = this;
|
||||
var _a = event.detail, index = _a.index, picker = _a.picker, value = _a.value;
|
||||
this.code = value[index].code;
|
||||
this.setValues().then(function () {
|
||||
_this.$emit('change', {
|
||||
picker: picker,
|
||||
values: picker.getValues(),
|
||||
index: index
|
||||
});
|
||||
});
|
||||
},
|
||||
getConfig: function (type) {
|
||||
var areaList = this.data.areaList;
|
||||
return (areaList && areaList[type + "_list"]) || {};
|
||||
},
|
||||
getList: function (type, code) {
|
||||
var result = [];
|
||||
if (type !== 'province' && !code) {
|
||||
return result;
|
||||
}
|
||||
var list = this.getConfig(type);
|
||||
result = Object.keys(list).map(function (code) { return ({
|
||||
code: code,
|
||||
name: list[code]
|
||||
}); });
|
||||
if (code) {
|
||||
// oversea code
|
||||
if (code[0] === '9' && type === 'city') {
|
||||
code = '9';
|
||||
}
|
||||
result = result.filter(function (item) { return item.code.indexOf(code) === 0; });
|
||||
}
|
||||
return result;
|
||||
},
|
||||
getIndex: function (type, code) {
|
||||
var compareNum = type === 'province' ? 2 : type === 'city' ? 4 : 6;
|
||||
var list = this.getList(type, code.slice(0, compareNum - 2));
|
||||
// oversea code
|
||||
if (code[0] === '9' && type === 'province') {
|
||||
compareNum = 1;
|
||||
}
|
||||
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 () {
|
||||
var _this = this;
|
||||
var county = this.getConfig('county');
|
||||
var code = this.code || Object.keys(county)[0] || '';
|
||||
var province = this.getList('province');
|
||||
var city = this.getList('city', code.slice(0, 2));
|
||||
var picker = this.getPicker();
|
||||
if (!picker) {
|
||||
return;
|
||||
}
|
||||
var stack = [];
|
||||
stack.push(picker.setColumnValues(0, province, false));
|
||||
stack.push(picker.setColumnValues(1, city, false));
|
||||
if (city.length && code.slice(2, 4) === '00') {
|
||||
;
|
||||
code = city[0].code;
|
||||
}
|
||||
stack.push(picker.setColumnValues(2, this.getList('county', code.slice(0, 4)), false));
|
||||
return Promise.all(stack)
|
||||
.catch(function () { })
|
||||
.then(function () {
|
||||
return picker.setIndexes([
|
||||
_this.getIndex('province', code),
|
||||
_this.getIndex('city', code),
|
||||
_this.getIndex('county', code)
|
||||
]);
|
||||
})
|
||||
.catch(function () { });
|
||||
},
|
||||
getValues: function () {
|
||||
var picker = this.getPicker();
|
||||
return picker ? picker.getValues().filter(function (value) { return !!value; }) : [];
|
||||
},
|
||||
getDetail: function () {
|
||||
var values = this.getValues();
|
||||
var area = {
|
||||
code: '',
|
||||
country: '',
|
||||
province: '',
|
||||
city: '',
|
||||
county: ''
|
||||
};
|
||||
if (!values.length) {
|
||||
return area;
|
||||
}
|
||||
var names = values.map(function (item) { return item.name; });
|
||||
area.code = values[values.length - 1].code;
|
||||
if (area.code[0] === '9') {
|
||||
area.country = names[1] || '';
|
||||
area.province = names[2] || '';
|
||||
}
|
||||
else {
|
||||
area.province = names[0] || '';
|
||||
area.city = names[1] || '';
|
||||
area.county = names[2] || '';
|
||||
}
|
||||
return area;
|
||||
},
|
||||
reset: function () {
|
||||
this.code = '';
|
||||
return this.setValues();
|
||||
}
|
||||
}
|
||||
});
|
6
lib/area/index.json
Normal file
6
lib/area/index.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-picker": "../picker/index"
|
||||
}
|
||||
}
|
18
lib/area/index.wxml
Normal file
18
lib/area/index.wxml
Normal file
@ -0,0 +1,18 @@
|
||||
<van-picker
|
||||
class="van-area__picker"
|
||||
active-class="active-class"
|
||||
toolbar-class="toolbar-class"
|
||||
column-class="column-class"
|
||||
show-toolbar
|
||||
value-key="name"
|
||||
title="{{ title }}"
|
||||
loading="{{ loading }}"
|
||||
columns="{{ displayColumns }}"
|
||||
item-height="{{ itemHeight }}"
|
||||
visible-item-count="{{ visibleItemCount }}"
|
||||
cancel-button-text="{{ cancelButtonText }}"
|
||||
confirm-button-text="{{ confirmButtonText }}"
|
||||
bind:change="onChange"
|
||||
bind:confirm="onConfirm"
|
||||
bind:cancel="onCancel"
|
||||
/>
|
1
lib/area/index.wxss
Normal file
1
lib/area/index.wxss
Normal file
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';
|
51
lib/badge-group/index.js
Normal file
51
lib/badge-group/index.js
Normal file
@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../common/component");
|
||||
var utils_1 = require("../common/utils");
|
||||
component_1.VantComponent({
|
||||
relation: {
|
||||
name: 'badge',
|
||||
type: 'descendant',
|
||||
linked: function (target) {
|
||||
this.badges.push(target);
|
||||
this.setActive();
|
||||
},
|
||||
unlinked: function (target) {
|
||||
this.badges = this.badges.filter(function (item) { return item !== target; });
|
||||
this.setActive();
|
||||
}
|
||||
},
|
||||
props: {
|
||||
active: {
|
||||
type: Number,
|
||||
value: 0
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
active: 'setActive'
|
||||
},
|
||||
beforeCreate: function () {
|
||||
this.badges = [];
|
||||
this.currentActive = -1;
|
||||
},
|
||||
methods: {
|
||||
setActive: function (badge) {
|
||||
var active = this.data.active;
|
||||
var badges = this.badges;
|
||||
if (badge && !utils_1.isNumber(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
3
lib/badge-group/index.json
Normal file
3
lib/badge-group/index.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
3
lib/badge-group/index.wxml
Normal file
3
lib/badge-group/index.wxml
Normal file
@ -0,0 +1,3 @@
|
||||
<view class="van-badge-group van-hairline--top-bottom custom-class">
|
||||
<slot />
|
||||
</view>
|
1
lib/badge-group/index.wxss
Normal file
1
lib/badge-group/index.wxss
Normal file
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';.van-badge-group{width:85px}
|
24
lib/badge/index.js
Normal file
24
lib/badge/index.js
Normal file
@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../common/component");
|
||||
component_1.VantComponent({
|
||||
relation: {
|
||||
type: 'ancestor',
|
||||
name: 'badge-group'
|
||||
},
|
||||
props: {
|
||||
info: null,
|
||||
title: String
|
||||
},
|
||||
methods: {
|
||||
onClick: function () {
|
||||
var group = this.getRelationNodes('../badge-group/index')[0];
|
||||
if (group) {
|
||||
group.setActive(this);
|
||||
}
|
||||
},
|
||||
setActive: function (active) {
|
||||
this.set({ active: active });
|
||||
}
|
||||
}
|
||||
});
|
6
lib/badge/index.json
Normal file
6
lib/badge/index.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-info": "../info/index"
|
||||
}
|
||||
}
|
17
lib/badge/index.wxml
Normal file
17
lib/badge/index.wxml
Normal file
@ -0,0 +1,17 @@
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<view
|
||||
class="{{ utils.bem('badge', { active }) }} van-hairline custom-class"
|
||||
hover-class="van-badge--hover"
|
||||
hover-stay-time="70"
|
||||
bind:tap="onClick"
|
||||
>
|
||||
<view class="van-badge__text">
|
||||
<van-info
|
||||
wx:if="{{ info !== null }}"
|
||||
info="{{ info }}"
|
||||
custom-style="right: 4px"
|
||||
/>
|
||||
{{ title }}
|
||||
</view>
|
||||
</view>
|
1
lib/badge/index.wxss
Normal file
1
lib/badge/index.wxss
Normal file
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';.van-badge{display:block;padding:20px 12px 20px 9px;overflow:hidden;font-size:14px;line-height:1.4;color:#7d7e80;word-break:break-all;background-color:#f8f8f8;border-left:3px solid transparent;box-sizing:border-box;-webkit-user-select:none;user-select:none}.van-badge--hover{background-color:#f2f3f5}.van-badge:after{border-bottom-width:1px}.van-badge--active{font-weight:700;color:#333;border-color:#f44}.van-badge--active:after{border-right-width:1px}.van-badge--active,.van-badge--active.van-badge--hover{background-color:#fff}.van-badge__text{position:relative}
|
38
lib/button/index.js
Normal file
38
lib/button/index.js
Normal file
@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../common/component");
|
||||
var button_1 = require("../mixins/button");
|
||||
var open_type_1 = require("../mixins/open-type");
|
||||
component_1.VantComponent({
|
||||
mixins: [button_1.button, open_type_1.openType],
|
||||
classes: ['hover-class', 'loading-class'],
|
||||
props: {
|
||||
plain: Boolean,
|
||||
block: Boolean,
|
||||
round: Boolean,
|
||||
square: Boolean,
|
||||
loading: Boolean,
|
||||
hairline: Boolean,
|
||||
disabled: Boolean,
|
||||
loadingText: String,
|
||||
type: {
|
||||
type: String,
|
||||
value: 'default'
|
||||
},
|
||||
size: {
|
||||
type: String,
|
||||
value: 'normal'
|
||||
},
|
||||
loadingSize: {
|
||||
type: String,
|
||||
value: '20px'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onClick: function () {
|
||||
if (!this.data.disabled && !this.data.loading) {
|
||||
this.$emit('click');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
6
lib/button/index.json
Normal file
6
lib/button/index.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-loading": "../loading/index"
|
||||
}
|
||||
}
|
39
lib/button/index.wxml
Normal file
39
lib/button/index.wxml
Normal file
@ -0,0 +1,39 @@
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<button
|
||||
id="{{ id }}"
|
||||
class="custom-class {{ utils.bem('button', [type, size, { block, round, plain, square, loading, disabled, hairline, unclickable: disabled || loading }]) }} {{ hairline ? 'van-hairline--surround' : '' }}"
|
||||
open-type="{{ openType }}"
|
||||
hover-class="van-button--active hover-class"
|
||||
lang="{{ lang }}"
|
||||
business-id="{{ businessId }}"
|
||||
session-from="{{ sessionFrom }}"
|
||||
send-message-title="{{ sendMessageTitle }}"
|
||||
send-message-path="{{ sendMessagePath }}"
|
||||
send-message-img="{{ sendMessageImg }}"
|
||||
show-message-card="{{ showMessageCard }}"
|
||||
app-parameter="{{ appParameter }}"
|
||||
aria-label="{{ ariaLabel }}"
|
||||
bindtap="onClick"
|
||||
bindgetuserinfo="bindGetUserInfo"
|
||||
bindcontact="bindContact"
|
||||
bindgetphonenumber="bindGetPhoneNumber"
|
||||
binderror="bindError"
|
||||
bindlaunchapp="bindLaunchApp"
|
||||
bindopensetting="bindOpenSetting"
|
||||
>
|
||||
<block wx:if="{{ loading }}">
|
||||
<van-loading
|
||||
custom-class="loading-class"
|
||||
size="{{ loadingSize }}"
|
||||
color="{{ type === 'default' ? '#c9c9c9' : '' }}"
|
||||
/>
|
||||
<view
|
||||
wx:if="{{ loadingText }}"
|
||||
class="van-button__loading-text"
|
||||
>
|
||||
{{ loadingText }}
|
||||
</view>
|
||||
</block>
|
||||
<slot wx:else />
|
||||
</button>
|
1
lib/button/index.wxss
Normal file
1
lib/button/index.wxss
Normal file
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';.van-button{position:relative;display:inline-block;height:44px;padding:0;font-size:16px;line-height:42px;text-align:center;vertical-align:middle;box-sizing:border-box;border-radius:2px;-webkit-appearance:none;-webkit-text-size-adjust:100%}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;background-color:#000;border:inherit;border-color:#000;border-radius:inherit;content:" ";opacity:0;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#333;background-color:#fff;border:1px solid #eee}.van-button--primary{color:#fff;background-color:#07c160;border:1px solid #07c160}.van-button--info{color:#fff;background-color:#1989fa;border:1px solid #1989fa}.van-button--danger{color:#fff;background-color:#f44;border:1px solid #f44}.van-button--warning{color:#fff;background-color:#ff976a;border:1px solid #ff976a}.van-button--plain{background-color:#fff}.van-button--plain.van-button--primary{color:#07c160}.van-button--plain.van-button--info{color:#1989fa}.van-button--plain.van-button--danger{color:#f44}.van-button--plain.van-button--warning{color:#ff976a}.van-button--large{width:100%;height:50px;line-height:48px}.van-button--normal{padding:0 15px;font-size:14px}.van-button--small{height:30px;min-width:60px;padding:0 8px;font-size:12px;line-height:28px}.van-button--mini{display:inline-block;width:50px;height:22px;font-size:10px;line-height:20px}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:block;width:100%}.van-button--round{border-radius:10em}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5}.van-button__loading-text{margin-left:5px;display:inline-block;vertical-align:middle}.van-button--hairline{border-width:0;padding-top:1px}.van-button--hairline:after{border-width:1px;border-color:inherit;border-radius:4px}.van-button--hairline.van-button--round:after{border-radius:10em}.van-button--hairline.van-button--square:after{border-radius:0}
|
40
lib/card/index.js
Normal file
40
lib/card/index.js
Normal file
@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var link_1 = require("../mixins/link");
|
||||
var component_1 = require("../common/component");
|
||||
component_1.VantComponent({
|
||||
classes: [
|
||||
'num-class',
|
||||
'desc-class',
|
||||
'thumb-class',
|
||||
'title-class',
|
||||
'price-class',
|
||||
'origin-price-class',
|
||||
],
|
||||
mixins: [link_1.link],
|
||||
props: {
|
||||
tag: String,
|
||||
num: String,
|
||||
desc: String,
|
||||
thumb: String,
|
||||
title: String,
|
||||
price: String,
|
||||
centered: Boolean,
|
||||
lazyLoad: Boolean,
|
||||
thumbLink: String,
|
||||
originPrice: String,
|
||||
thumbMode: {
|
||||
type: String,
|
||||
value: 'aspectFit'
|
||||
},
|
||||
currency: {
|
||||
type: String,
|
||||
value: '¥'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onClickThumb: function () {
|
||||
this.jumpLink('thumbLink');
|
||||
}
|
||||
}
|
||||
});
|
6
lib/card/index.json
Normal file
6
lib/card/index.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-tag": "../tag/index"
|
||||
}
|
||||
}
|
44
lib/card/index.wxml
Normal file
44
lib/card/index.wxml
Normal file
@ -0,0 +1,44 @@
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<view class="custom-class van-card">
|
||||
<view class="{{ utils.bem('card__header', { center: centered }) }}">
|
||||
<view class="van-card__thumb" bind:tap="onClickThumb">
|
||||
<image
|
||||
wx:if="{{ thumb }}"
|
||||
src="{{ thumb }}"
|
||||
mode="{{ thumbMode }}"
|
||||
lazy-load="{{ lazyLoad }}"
|
||||
class="van-card__img thumb-class"
|
||||
/>
|
||||
<slot name="thumb" />
|
||||
<van-tag
|
||||
wx:if="{{ tag }}"
|
||||
mark
|
||||
type="danger"
|
||||
custom-class="van-card__tag"
|
||||
>
|
||||
{{ tag }}
|
||||
</van-tag>
|
||||
</view>
|
||||
|
||||
<view class="van-card__content">
|
||||
<view wx:if="{{ title }}" class="van-card__title title-class">{{ title }}</view>
|
||||
<slot wx:else name="title" />
|
||||
|
||||
<view wx:if="{{ desc }}" class="van-card__desc desc-class">{{ desc }}</view>
|
||||
<slot wx:else name="desc" />
|
||||
|
||||
<slot name="tags" />
|
||||
|
||||
<view class="van-card__bottom">
|
||||
<view wx:if="{{ price || price === 0 }}" class="van-card__price price-class">{{ currency }} {{ price }}</view>
|
||||
<view wx:if="{{ originPrice || originPrice === 0 }}" class="van-card__origin-price origin-price-class">{{ currency }} {{ originPrice }}</view>
|
||||
<view wx:if="{{ num }}" class="van-card__num num-class">x {{ num }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="van-card__footer">
|
||||
<slot name="footer" />
|
||||
</view>
|
||||
</view>
|
1
lib/card/index.wxss
Normal file
1
lib/card/index.wxss
Normal file
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';.van-card{position:relative;padding:5px 15px;font-size:12px;color:#333;background-color:#fafafa;box-sizing:border-box}.van-card__header{display:-webkit-flex;display:flex}.van-card__header--center{-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-card__thumb{position:relative;width:90px;height:90px;margin-right:10px;-webkit-flex:none;flex:none}.van-card__thumb:empty{display:none}.van-card__img{width:100%;height:100%}.van-card__content{position:relative;min-width:0;-webkit-flex:1;flex:1}.van-card__desc,.van-card__title{word-break:break-all}.van-card__title{font-weight:700;line-height:16px}.van-card__desc{color:#7d7e80}.van-card__bottom,.van-card__desc{line-height:20px}.van-card__price{display:inline-block;font-weight:700;color:#f44}.van-card__origin-price{display:inline-block;margin-left:5px;font-size:10px;color:#7d7e80;text-decoration:line-through}.van-card__num{float:right}.van-card__tag{position:absolute;top:2px;left:0}.van-card__footer{width:100%;text-align:right;-webkit-flex:none;flex:none}
|
12
lib/cell-group/index.js
Normal file
12
lib/cell-group/index.js
Normal file
@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../common/component");
|
||||
component_1.VantComponent({
|
||||
props: {
|
||||
title: String,
|
||||
border: {
|
||||
type: Boolean,
|
||||
value: true
|
||||
}
|
||||
}
|
||||
});
|
3
lib/cell-group/index.json
Normal file
3
lib/cell-group/index.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
9
lib/cell-group/index.wxml
Normal file
9
lib/cell-group/index.wxml
Normal file
@ -0,0 +1,9 @@
|
||||
<view
|
||||
wx:if="{{ title }}"
|
||||
class="van-cell-group__title"
|
||||
>
|
||||
{{ title }}
|
||||
</view>
|
||||
<view class="custom-class van-cell-group {{ border ? 'van-hairline--top-bottom' : '' }}">
|
||||
<slot />
|
||||
</view>
|
1
lib/cell-group/index.wxss
Normal file
1
lib/cell-group/index.wxss
Normal file
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';.van-cell-group__title{font-size:14px;padding:15px 15px 5px;color:#999;line-height:16px}
|
38
lib/cell/index.js
Normal file
38
lib/cell/index.js
Normal file
@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var link_1 = require("../mixins/link");
|
||||
var component_1 = require("../common/component");
|
||||
component_1.VantComponent({
|
||||
classes: [
|
||||
'title-class',
|
||||
'label-class',
|
||||
'value-class',
|
||||
'right-icon-class',
|
||||
'hover-class'
|
||||
],
|
||||
mixins: [link_1.link],
|
||||
props: {
|
||||
title: null,
|
||||
value: null,
|
||||
icon: String,
|
||||
size: String,
|
||||
label: String,
|
||||
center: Boolean,
|
||||
isLink: Boolean,
|
||||
required: Boolean,
|
||||
clickable: Boolean,
|
||||
titleWidth: String,
|
||||
customStyle: String,
|
||||
arrowDirection: String,
|
||||
border: {
|
||||
type: Boolean,
|
||||
value: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onClick: function (event) {
|
||||
this.$emit('click', event.detail);
|
||||
this.jumpLink();
|
||||
}
|
||||
}
|
||||
});
|
6
lib/cell/index.json
Normal file
6
lib/cell/index.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-icon": "../icon/index"
|
||||
}
|
||||
}
|
43
lib/cell/index.wxml
Normal file
43
lib/cell/index.wxml
Normal file
@ -0,0 +1,43 @@
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<view
|
||||
class="custom-class {{ utils.bem('cell', [size, { center, required, borderless: !border, clickable: isLink || clickable }]) }}"
|
||||
hover-class="van-cell--hover hover-class"
|
||||
hover-stay-time="70"
|
||||
style="{{ customStyle }}"
|
||||
bind:tap="onClick"
|
||||
>
|
||||
<van-icon
|
||||
wx:if="{{ icon }}"
|
||||
name="{{ icon }}"
|
||||
class="van-cell__left-icon-wrap"
|
||||
custom-class="van-cell__left-icon"
|
||||
/>
|
||||
<slot wx:else name="icon" />
|
||||
|
||||
<view
|
||||
style="{{ titleWidth ? 'max-width:' + titleWidth + ';min-width:' + titleWidth : '' }}"
|
||||
class="van-cell__title title-class"
|
||||
>
|
||||
<block wx:if="{{ title }}">
|
||||
{{ title }}
|
||||
<view wx:if="{{ label }}" class="van-cell__label label-class">{{ label }}</view>
|
||||
</block>
|
||||
<slot wx:else name="title" />
|
||||
</view>
|
||||
|
||||
<view class="van-cell__value value-class">
|
||||
<block wx:if="{{ value || value === 0 }}">{{ value }}</block>
|
||||
<slot wx:else />
|
||||
</view>
|
||||
|
||||
<van-icon
|
||||
wx:if="{{ isLink }}"
|
||||
name="{{ arrowDirection ? 'arrow' + '-' + arrowDirection : 'arrow' }}"
|
||||
class="van-cell__right-icon-wrap right-icon-class"
|
||||
custom-class="van-cell__right-icon"
|
||||
/>
|
||||
<slot wx:else name="right-icon" />
|
||||
|
||||
<slot name="extra" />
|
||||
</view>
|
1
lib/cell/index.wxss
Normal file
1
lib/cell/index.wxss
Normal file
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';.van-cell{position:relative;display:-webkit-flex;display:flex;width:100%;padding:10px 15px;font-size:14px;line-height:24px;color:#333;background-color:#fff;box-sizing:border-box}.van-cell:after{content:" ";position:absolute;pointer-events:none;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;top:auto;left:15px;right:0;bottom:0;-webkit-transform:scaleY(.5);transform:scaleY(.5);border-bottom:1px solid #eee}.van-cell--borderless:after{display:none}.van-cell-group{background-color:#fff}.van-cell__label{margin-top:3px;font-size:12px;line-height:18px;color:#999}.van-cell__value{overflow:hidden;color:#999;text-align:right;vertical-align:middle}.van-cell__title,.van-cell__value{-webkit-flex:1;flex:1}.van-cell__title:empty,.van-cell__value:empty{display:none}.van-cell__left-icon-wrap,.van-cell__right-icon-wrap{display:-webkit-flex;display:flex;height:24px;font-size:16px;-webkit-align-items:center;align-items:center}.van-cell__left-icon-wrap{margin-right:5px}.van-cell__right-icon-wrap{margin-left:5px;color:#999}.van-cell__left-icon{line-height:24px;vertical-align:middle}.van-cell__right-icon{line-height:24px}.van-cell--clickable.van-cell--hover{background-color:#f2f3f5}.van-cell--required{overflow:visible}.van-cell--required:before{position:absolute;left:7px;font-size:14px;color:#f44;content:"*"}.van-cell--center{-webkit-align-items:center;align-items:center}.van-cell--large{padding-top:12px;padding-bottom:12px}.van-cell--large .van-cell__title{font-size:16px}.van-cell--large .van-cell__label{font-size:14px}
|
36
lib/checkbox-group/index.js
Normal file
36
lib/checkbox-group/index.js
Normal file
@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../common/component");
|
||||
component_1.VantComponent({
|
||||
field: true,
|
||||
relation: {
|
||||
name: 'checkbox',
|
||||
type: 'descendant',
|
||||
linked: function (target) {
|
||||
var _a = this.data, value = _a.value, disabled = _a.disabled;
|
||||
target.set({
|
||||
value: value.indexOf(target.data.name) !== -1,
|
||||
disabled: disabled || target.data.disabled
|
||||
});
|
||||
}
|
||||
},
|
||||
props: {
|
||||
max: Number,
|
||||
value: Array,
|
||||
disabled: Boolean
|
||||
},
|
||||
watch: {
|
||||
value: function (value) {
|
||||
var children = this.getRelationNodes('../checkbox/index');
|
||||
children.forEach(function (child) {
|
||||
child.set({ value: value.indexOf(child.data.name) !== -1 });
|
||||
});
|
||||
},
|
||||
disabled: function (disabled) {
|
||||
var children = this.getRelationNodes('../checkbox/index');
|
||||
children.forEach(function (child) {
|
||||
child.set({ disabled: disabled || child.data.disabled });
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
6
lib/checkbox-group/index.json
Normal file
6
lib/checkbox-group/index.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-icon": "../icon/index"
|
||||
}
|
||||
}
|
1
lib/checkbox-group/index.wxml
Normal file
1
lib/checkbox-group/index.wxml
Normal file
@ -0,0 +1 @@
|
||||
<slot />
|
1
lib/checkbox-group/index.wxss
Normal file
1
lib/checkbox-group/index.wxss
Normal file
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';
|
69
lib/checkbox/index.js
Normal file
69
lib/checkbox/index.js
Normal file
@ -0,0 +1,69 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../common/component");
|
||||
component_1.VantComponent({
|
||||
field: true,
|
||||
relation: {
|
||||
name: 'checkbox-group',
|
||||
type: 'ancestor'
|
||||
},
|
||||
classes: ['icon-class', 'label-class'],
|
||||
props: {
|
||||
value: null,
|
||||
disabled: Boolean,
|
||||
useIconSlot: Boolean,
|
||||
checkedColor: String,
|
||||
labelPosition: String,
|
||||
labelDisabled: Boolean,
|
||||
shape: {
|
||||
type: String,
|
||||
value: 'round'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
emitChange: function (value) {
|
||||
var parent = this.getRelationNodes('../checkbox-group/index')[0];
|
||||
if (parent) {
|
||||
this.setParentValue(parent, value);
|
||||
}
|
||||
else {
|
||||
this.$emit('input', value);
|
||||
this.$emit('change', value);
|
||||
}
|
||||
},
|
||||
toggle: function () {
|
||||
if (!this.data.disabled) {
|
||||
this.emitChange(!this.data.value);
|
||||
}
|
||||
},
|
||||
onClickLabel: function () {
|
||||
if (!this.data.disabled && !this.data.labelDisabled) {
|
||||
this.emitChange(!this.data.value);
|
||||
}
|
||||
},
|
||||
setParentValue: function (parent, value) {
|
||||
var parentValue = parent.data.value.slice();
|
||||
var name = this.data.name;
|
||||
if (value) {
|
||||
if (parent.data.max && parentValue.length >= parent.data.max) {
|
||||
return;
|
||||
}
|
||||
/* istanbul ignore else */
|
||||
if (parentValue.indexOf(name) === -1) {
|
||||
parentValue.push(name);
|
||||
parent.$emit('input', parentValue);
|
||||
parent.$emit('change', parentValue);
|
||||
}
|
||||
}
|
||||
else {
|
||||
var index = parentValue.indexOf(name);
|
||||
/* istanbul ignore else */
|
||||
if (index !== -1) {
|
||||
parentValue.splice(index, 1);
|
||||
parent.$emit('input', parentValue);
|
||||
parent.$emit('change', parentValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
6
lib/checkbox/index.json
Normal file
6
lib/checkbox/index.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-icon": "../icon/index"
|
||||
}
|
||||
}
|
18
lib/checkbox/index.wxml
Normal file
18
lib/checkbox/index.wxml
Normal file
@ -0,0 +1,18 @@
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<view class="van-checkbox custom-class">
|
||||
<view class="van-checkbox__icon-wrap" bindtap="toggle">
|
||||
<slot wx:if="{{ useIconSlot }}" name="icon" />
|
||||
<van-icon
|
||||
wx:else
|
||||
name="success"
|
||||
class="{{ utils.bem('checkbox__icon', [shape, { disabled, checked: value }]) }}"
|
||||
style="{{ checkedColor && value && !disabled ? 'border-color:' + checkedColor + '; background-color:' + checkedColor : '' }}"
|
||||
custom-class="icon-class"
|
||||
custom-style="line-height: 20px;"
|
||||
/>
|
||||
</view>
|
||||
<view class="label-class {{ utils.bem('checkbox__label', [labelPosition, { disabled }]) }}" bindtap="onClickLabel">
|
||||
<slot />
|
||||
</view>
|
||||
</view>
|
1
lib/checkbox/index.wxss
Normal file
1
lib/checkbox/index.wxss
Normal file
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';.van-checkbox{overflow:hidden;-webkit-user-select:none;user-select:none}.van-checkbox__icon-wrap,.van-checkbox__label{display:inline-block;line-height:20px;vertical-align:middle}.van-checkbox__icon{display:block;font-size:14px;width:20px;height:20px;color:transparent;text-align:center;box-sizing:border-box;border:1px solid #e5e5e5;transition:.2s}.van-checkbox__icon--round{border-radius:100%}.van-checkbox__icon--checked{color:#fff;border-color:#1989fa;background-color:#1989fa}.van-checkbox__icon--disabled{border-color:#c9c9c9;background-color:#eee}.van-checkbox__icon--disabled.van-checkbox__icon--checked{color:#c9c9c9}.van-checkbox__label{color:#333;margin-left:10px}.van-checkbox__label--left{float:left;margin:0 10px 0 0}.van-checkbox__label--disabled{color:#c9c9c9}.van-checkbox__label:empty{margin:0}
|
25
lib/col/index.js
Normal file
25
lib/col/index.js
Normal file
@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../common/component");
|
||||
component_1.VantComponent({
|
||||
relation: {
|
||||
name: 'row',
|
||||
type: 'ancestor'
|
||||
},
|
||||
props: {
|
||||
span: Number,
|
||||
offset: Number
|
||||
},
|
||||
data: {
|
||||
style: ''
|
||||
},
|
||||
methods: {
|
||||
setGutter: function (gutter) {
|
||||
var padding = gutter / 2 + "px";
|
||||
var style = gutter ? "padding-left: " + padding + "; padding-right: " + padding + ";" : '';
|
||||
if (style !== this.data.style) {
|
||||
this.set({ style: style });
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
3
lib/col/index.json
Normal file
3
lib/col/index.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
8
lib/col/index.wxml
Normal file
8
lib/col/index.wxml
Normal file
@ -0,0 +1,8 @@
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<view
|
||||
class="custom-class {{ utils.bem('col', [span]) }} {{ offset ? 'van-col--offset-' + offset : '' }}"
|
||||
style="{{ style }}"
|
||||
>
|
||||
<slot />
|
||||
</view>
|
1
lib/col/index.wxss
Normal file
1
lib/col/index.wxss
Normal file
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';.van-col{float:left;box-sizing:border-box}.van-col--1{width:4.16666667%}.van-col--offset-1{margin-left:4.16666667%}.van-col--2{width:8.33333333%}.van-col--offset-2{margin-left:8.33333333%}.van-col--3{width:12.5%}.van-col--offset-3{margin-left:12.5%}.van-col--4{width:16.66666667%}.van-col--offset-4{margin-left:16.66666667%}.van-col--5{width:20.83333333%}.van-col--offset-5{margin-left:20.83333333%}.van-col--6{width:25%}.van-col--offset-6{margin-left:25%}.van-col--7{width:29.16666667%}.van-col--offset-7{margin-left:29.16666667%}.van-col--8{width:33.33333333%}.van-col--offset-8{margin-left:33.33333333%}.van-col--9{width:37.5%}.van-col--offset-9{margin-left:37.5%}.van-col--10{width:41.66666667%}.van-col--offset-10{margin-left:41.66666667%}.van-col--11{width:45.83333333%}.van-col--offset-11{margin-left:45.83333333%}.van-col--12{width:50%}.van-col--offset-12{margin-left:50%}.van-col--13{width:54.16666667%}.van-col--offset-13{margin-left:54.16666667%}.van-col--14{width:58.33333333%}.van-col--offset-14{margin-left:58.33333333%}.van-col--15{width:62.5%}.van-col--offset-15{margin-left:62.5%}.van-col--16{width:66.66666667%}.van-col--offset-16{margin-left:66.66666667%}.van-col--17{width:70.83333333%}.van-col--offset-17{margin-left:70.83333333%}.van-col--18{width:75%}.van-col--offset-18{margin-left:75%}.van-col--19{width:79.16666667%}.van-col--offset-19{margin-left:79.16666667%}.van-col--20{width:83.33333333%}.van-col--offset-20{margin-left:83.33333333%}.van-col--21{width:87.5%}.van-col--offset-21{margin-left:87.5%}.van-col--22{width:91.66666667%}.van-col--offset-22{margin-left:91.66666667%}.van-col--23{width:95.83333333%}.van-col--offset-23{margin-left:95.83333333%}.van-col--24{width:100%}.van-col--offset-24{margin-left:100%}
|
94
lib/collapse-item/index.js
Normal file
94
lib/collapse-item/index.js
Normal file
@ -0,0 +1,94 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../common/component");
|
||||
component_1.VantComponent({
|
||||
classes: ['title-class', 'content-class'],
|
||||
relation: {
|
||||
name: 'collapse',
|
||||
type: 'ancestor',
|
||||
linked: function (parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
},
|
||||
props: {
|
||||
name: null,
|
||||
title: null,
|
||||
value: null,
|
||||
icon: String,
|
||||
label: String,
|
||||
disabled: Boolean,
|
||||
border: {
|
||||
type: Boolean,
|
||||
value: true
|
||||
},
|
||||
isLink: {
|
||||
type: Boolean,
|
||||
value: true
|
||||
}
|
||||
},
|
||||
data: {
|
||||
contentHeight: 0,
|
||||
expanded: false
|
||||
},
|
||||
beforeCreate: function () {
|
||||
this.animation = wx.createAnimation({
|
||||
duration: 300,
|
||||
timingFunction: 'ease-in-out'
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
updateExpanded: function () {
|
||||
if (!this.parent) {
|
||||
return null;
|
||||
}
|
||||
var _a = this.parent.data, value = _a.value, accordion = _a.accordion, items = _a.items;
|
||||
var name = this.data.name;
|
||||
var index = items.indexOf(this);
|
||||
var currentName = name == null ? index : name;
|
||||
var expanded = accordion
|
||||
? value === currentName
|
||||
: value.some(function (name) { return name === currentName; });
|
||||
if (expanded !== this.data.expanded) {
|
||||
this.updateStyle(expanded);
|
||||
}
|
||||
this.set({ index: index, expanded: expanded });
|
||||
},
|
||||
updateStyle: function (expanded) {
|
||||
var _this = this;
|
||||
this.getRect('.van-collapse-item__content').then(function (res) {
|
||||
var animationData = _this.animation
|
||||
.height(expanded ? res.height : 0)
|
||||
.step()
|
||||
.export();
|
||||
if (expanded) {
|
||||
_this.set({ animationData: animationData });
|
||||
}
|
||||
else {
|
||||
_this.set({
|
||||
contentHeight: res.height + 'px'
|
||||
}, function () {
|
||||
setTimeout(function () {
|
||||
_this.set({ animationData: animationData });
|
||||
}, 20);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
onClick: function () {
|
||||
if (this.data.disabled) {
|
||||
return;
|
||||
}
|
||||
var _a = this.data, name = _a.name, expanded = _a.expanded;
|
||||
var index = this.parent.data.items.indexOf(this);
|
||||
var currentName = name == null ? index : name;
|
||||
this.parent.switch(currentName, !expanded);
|
||||
},
|
||||
onTransitionEnd: function () {
|
||||
if (this.data.expanded) {
|
||||
this.set({
|
||||
contentHeight: 'auto'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
6
lib/collapse-item/index.json
Normal file
6
lib/collapse-item/index.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-cell": "../cell/index"
|
||||
}
|
||||
}
|
44
lib/collapse-item/index.wxml
Normal file
44
lib/collapse-item/index.wxml
Normal file
@ -0,0 +1,44 @@
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<view class="van-collapse-item custom-class {{ index !== 0 ? 'van-hairline--top' : '' }}">
|
||||
<van-cell
|
||||
title="{{ title }}"
|
||||
title-class="title-class"
|
||||
icon="{{ icon }}"
|
||||
is-link="{{ isLink }}"
|
||||
value="{{ value }}"
|
||||
label="{{ label }}"
|
||||
border="{{ border && expanded }}"
|
||||
class="{{ utils.bem('collapse-item__title', { disabled, expanded }) }}"
|
||||
right-icon-class="van-cell__right-icon"
|
||||
custom-class="van-cell"
|
||||
hover-class="van-cell--hover"
|
||||
bind:click="onClick"
|
||||
>
|
||||
<slot
|
||||
name="title"
|
||||
slot="title"
|
||||
/>
|
||||
<slot
|
||||
name="icon"
|
||||
slot="icon"
|
||||
/>
|
||||
<slot name="value" />
|
||||
<slot
|
||||
name="right-icon"
|
||||
slot="right-icon"
|
||||
/>
|
||||
</van-cell>
|
||||
<view
|
||||
class="van-collapse-item__wrapper"
|
||||
style="height: {{ contentHeight }};"
|
||||
animation="{{ animationData }}"
|
||||
bind:transitionend="onTransitionEnd"
|
||||
>
|
||||
<view
|
||||
class="van-collapse-item__content content-class"
|
||||
>
|
||||
<slot />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
1
lib/collapse-item/index.wxss
Normal file
1
lib/collapse-item/index.wxss
Normal file
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';.van-collapse-item__title .van-cell__right-icon{-webkit-transform:rotate(90deg);transform:rotate(90deg);transition:.3s}.van-collapse-item__title--expanded .van-cell__right-icon{-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}.van-collapse-item__title--disabled .van-cell,.van-collapse-item__title--disabled .van-cell__right-icon{color:#c9c9c9!important}.van-collapse-item__title--disabled .van-cell--hover{background-color:#fff!important}.van-collapse-item__wrapper{overflow:hidden}.van-collapse-item__content{padding:15px;font-size:13px;line-height:1.5;color:#999;background-color:#fff}
|
54
lib/collapse/index.js
Normal file
54
lib/collapse/index.js
Normal file
@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../common/component");
|
||||
component_1.VantComponent({
|
||||
relation: {
|
||||
name: 'collapse-item',
|
||||
type: 'descendant',
|
||||
linked: function (child) {
|
||||
this.set({
|
||||
items: this.data.items.concat([child])
|
||||
}, function () {
|
||||
child.updateExpanded();
|
||||
});
|
||||
}
|
||||
},
|
||||
props: {
|
||||
value: null,
|
||||
accordion: Boolean,
|
||||
border: {
|
||||
type: Boolean,
|
||||
value: true
|
||||
}
|
||||
},
|
||||
data: {
|
||||
items: []
|
||||
},
|
||||
watch: {
|
||||
value: function () {
|
||||
this.data.items.forEach(function (child) {
|
||||
child.updateExpanded();
|
||||
});
|
||||
},
|
||||
accordion: function () {
|
||||
this.data.items.forEach(function (child) {
|
||||
child.updateExpanded();
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
switch: function (name, expanded) {
|
||||
var _a = this.data, accordion = _a.accordion, value = _a.value;
|
||||
if (!accordion) {
|
||||
name = expanded
|
||||
? value.concat(name)
|
||||
: value.filter(function (activeName) { return activeName !== name; });
|
||||
}
|
||||
else {
|
||||
name = expanded ? name : '';
|
||||
}
|
||||
this.$emit('change', name);
|
||||
this.$emit('input', name);
|
||||
}
|
||||
}
|
||||
});
|
3
lib/collapse/index.json
Normal file
3
lib/collapse/index.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
3
lib/collapse/index.wxml
Normal file
3
lib/collapse/index.wxml
Normal file
@ -0,0 +1,3 @@
|
||||
<view class="custom-class van-collapse {{ border ? 'van-hairline--top-bottom' : '' }}">
|
||||
<slot />
|
||||
</view>
|
1
lib/collapse/index.wxss
Normal file
1
lib/collapse/index.wxss
Normal file
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';
|
5
lib/common/color.js
Normal file
5
lib/common/color.js
Normal file
@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RED = '#f44';
|
||||
exports.BLUE = '#1989fa';
|
||||
exports.GREEN = '#07c160';
|
52
lib/common/component.js
Normal file
52
lib/common/component.js
Normal file
@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var basic_1 = require("../mixins/basic");
|
||||
var index_1 = require("../mixins/observer/index");
|
||||
function mapKeys(source, target, map) {
|
||||
Object.keys(map).forEach(function (key) {
|
||||
if (source[key]) {
|
||||
target[map[key]] = source[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
function VantComponent(vantOptions) {
|
||||
if (vantOptions === void 0) { vantOptions = {}; }
|
||||
var _a;
|
||||
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) {
|
||||
options.relations = Object.assign(options.relations || {}, (_a = {},
|
||||
_a["../" + relation.name + "/index"] = relation,
|
||||
_a));
|
||||
}
|
||||
// add default externalClasses
|
||||
options.externalClasses = options.externalClasses || [];
|
||||
options.externalClasses.push('custom-class');
|
||||
// add default behaviors
|
||||
options.behaviors = options.behaviors || [];
|
||||
options.behaviors.push(basic_1.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
|
||||
};
|
||||
index_1.observe(vantOptions, options);
|
||||
Component(options);
|
||||
}
|
||||
exports.VantComponent = VantComponent;
|
1
lib/common/index.wxss
Normal file
1
lib/common/index.wxss
Normal file
@ -0,0 +1 @@
|
||||
.van-ellipsis{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.van-multi-ellipsis--l2{-webkit-line-clamp:2}.van-multi-ellipsis--l2,.van-multi-ellipsis--l3{overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-box-orient:vertical}.van-multi-ellipsis--l3{-webkit-line-clamp:3}.van-clearfix:after{content:"";display:table;clear:both}.van-hairline,.van-hairline--bottom,.van-hairline--left,.van-hairline--right,.van-hairline--surround,.van-hairline--top,.van-hairline--top-bottom{position:relative}.van-hairline--bottom:after,.van-hairline--left:after,.van-hairline--right:after,.van-hairline--surround:after,.van-hairline--top-bottom:after,.van-hairline--top:after,.van-hairline:after{content:" ";position:absolute;pointer-events:none;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;top:-50%;left:-50%;right:-50%;bottom:-50%;-webkit-transform:scale(.5);transform:scale(.5);border:0 solid #eee}.van-hairline--top:after{border-top-width:1px}.van-hairline--left:after{border-left-width:1px}.van-hairline--right:after{border-right-width:1px}.van-hairline--bottom:after{border-bottom-width:1px}.van-hairline--top-bottom:after{border-width:1px 0}.van-hairline--surround:after{border-width:1px}
|
1
lib/common/style/clearfix.wxss
Normal file
1
lib/common/style/clearfix.wxss
Normal file
@ -0,0 +1 @@
|
||||
.van-clearfix:after{content:"";display:table;clear:both}
|
1
lib/common/style/ellipsis.wxss
Normal file
1
lib/common/style/ellipsis.wxss
Normal file
@ -0,0 +1 @@
|
||||
.van-ellipsis{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.van-multi-ellipsis--l2{-webkit-line-clamp:2}.van-multi-ellipsis--l2,.van-multi-ellipsis--l3{overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-box-orient:vertical}.van-multi-ellipsis--l3{-webkit-line-clamp:3}
|
1
lib/common/style/hairline.wxss
Normal file
1
lib/common/style/hairline.wxss
Normal file
@ -0,0 +1 @@
|
||||
.van-hairline,.van-hairline--bottom,.van-hairline--left,.van-hairline--right,.van-hairline--surround,.van-hairline--top,.van-hairline--top-bottom{position:relative}.van-hairline--bottom:after,.van-hairline--left:after,.van-hairline--right:after,.van-hairline--surround:after,.van-hairline--top-bottom:after,.van-hairline--top:after,.van-hairline:after{content:" ";position:absolute;pointer-events:none;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;top:-50%;left:-50%;right:-50%;bottom:-50%;-webkit-transform:scale(.5);transform:scale(.5);border:0 solid #eee}.van-hairline--top:after{border-top-width:1px}.van-hairline--left:after{border-left-width:1px}.van-hairline--right:after{border-right-width:1px}.van-hairline--bottom:after{border-bottom-width:1px}.van-hairline--top-bottom:after{border-width:1px 0}.van-hairline--surround:after{border-width:1px}
|
0
lib/common/style/mixins/clearfix.wxss
Normal file
0
lib/common/style/mixins/clearfix.wxss
Normal file
0
lib/common/style/mixins/ellipsis.wxss
Normal file
0
lib/common/style/mixins/ellipsis.wxss
Normal file
0
lib/common/style/mixins/hairline.wxss
Normal file
0
lib/common/style/mixins/hairline.wxss
Normal file
0
lib/common/style/var.wxss
Normal file
0
lib/common/style/var.wxss
Normal file
19
lib/common/utils.js
Normal file
19
lib/common/utils.js
Normal file
@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function isDef(value) {
|
||||
return value !== undefined && value !== null;
|
||||
}
|
||||
exports.isDef = isDef;
|
||||
function isObj(x) {
|
||||
var type = typeof x;
|
||||
return x !== null && (type === 'object' || type === 'function');
|
||||
}
|
||||
exports.isObj = isObj;
|
||||
function isNumber(value) {
|
||||
return /^\d+$/.test(value);
|
||||
}
|
||||
exports.isNumber = isNumber;
|
||||
function range(num, min, max) {
|
||||
return Math.min(Math.max(num, min), max);
|
||||
}
|
||||
exports.range = range;
|
309
lib/datetime-picker/index.js
Normal file
309
lib/datetime-picker/index.js
Normal file
@ -0,0 +1,309 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../common/component");
|
||||
var utils_1 = require("../common/utils");
|
||||
var currentYear = new Date().getFullYear();
|
||||
function isValidDate(date) {
|
||||
return utils_1.isDef(date) && !isNaN(new Date(date).getTime());
|
||||
}
|
||||
function range(num, min, max) {
|
||||
return Math.min(Math.max(num, min), max);
|
||||
}
|
||||
function padZero(val) {
|
||||
return ("00" + val).slice(-2);
|
||||
}
|
||||
function times(n, iteratee) {
|
||||
var index = -1;
|
||||
var result = Array(n);
|
||||
while (++index < n) {
|
||||
result[index] = iteratee(index);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function getTrueValue(formattedValue) {
|
||||
if (!formattedValue)
|
||||
return;
|
||||
while (isNaN(parseInt(formattedValue, 10))) {
|
||||
formattedValue = formattedValue.slice(1);
|
||||
}
|
||||
return parseInt(formattedValue, 10);
|
||||
}
|
||||
function getMonthEndDay(year, month) {
|
||||
return 32 - new Date(year, month - 1, 32).getDate();
|
||||
}
|
||||
component_1.VantComponent({
|
||||
props: {
|
||||
value: null,
|
||||
title: String,
|
||||
loading: Boolean,
|
||||
itemHeight: {
|
||||
type: Number,
|
||||
value: 44
|
||||
},
|
||||
visibleItemCount: {
|
||||
type: Number,
|
||||
value: 5
|
||||
},
|
||||
confirmButtonText: {
|
||||
type: String,
|
||||
value: '确认'
|
||||
},
|
||||
cancelButtonText: {
|
||||
type: String,
|
||||
value: '取消'
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
value: 'datetime'
|
||||
},
|
||||
showToolbar: {
|
||||
type: Boolean,
|
||||
value: true
|
||||
},
|
||||
minDate: {
|
||||
type: Number,
|
||||
value: new Date(currentYear - 10, 0, 1).getTime()
|
||||
},
|
||||
maxDate: {
|
||||
type: Number,
|
||||
value: new Date(currentYear + 10, 11, 31).getTime()
|
||||
},
|
||||
minHour: {
|
||||
type: Number,
|
||||
value: 0
|
||||
},
|
||||
maxHour: {
|
||||
type: Number,
|
||||
value: 23
|
||||
},
|
||||
minMinute: {
|
||||
type: Number,
|
||||
value: 0
|
||||
},
|
||||
maxMinute: {
|
||||
type: Number,
|
||||
value: 59
|
||||
}
|
||||
},
|
||||
data: {
|
||||
innerValue: Date.now(),
|
||||
columns: []
|
||||
},
|
||||
watch: {
|
||||
value: function (val) {
|
||||
var _this = this;
|
||||
var data = this.data;
|
||||
val = this.correctValue(val);
|
||||
var isEqual = val === data.innerValue;
|
||||
if (!isEqual) {
|
||||
this.updateColumnValue(val).then(function () {
|
||||
_this.$emit('input', val);
|
||||
});
|
||||
}
|
||||
},
|
||||
type: 'updateColumns',
|
||||
minHour: 'updateColumns',
|
||||
maxHour: 'updateColumns',
|
||||
minMinute: 'updateColumns',
|
||||
maxMinute: 'updateColumns'
|
||||
},
|
||||
methods: {
|
||||
getPicker: function () {
|
||||
if (this.picker == null) {
|
||||
var picker_1 = this.picker = this.selectComponent('.van-datetime-picker');
|
||||
var setColumnValues_1 = picker_1.setColumnValues;
|
||||
picker_1.setColumnValues = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
return setColumnValues_1.apply(picker_1, args.concat([false]));
|
||||
};
|
||||
}
|
||||
return this.picker;
|
||||
},
|
||||
updateColumns: function () {
|
||||
var results = this.getRanges().map(function (_a, index) {
|
||||
var type = _a.type, range = _a.range;
|
||||
var values = times(range[1] - range[0] + 1, function (index) {
|
||||
var value = range[0] + index;
|
||||
value = type === 'year' ? "" + value : padZero(value);
|
||||
return value;
|
||||
});
|
||||
return { values: values };
|
||||
});
|
||||
return this.set({ columns: results });
|
||||
},
|
||||
getRanges: function () {
|
||||
var data = this.data;
|
||||
if (data.type === 'time') {
|
||||
return [
|
||||
{
|
||||
type: 'hour',
|
||||
range: [data.minHour, data.maxHour]
|
||||
},
|
||||
{
|
||||
type: 'minute',
|
||||
range: [data.minMinute, data.maxMinute]
|
||||
}
|
||||
];
|
||||
}
|
||||
var _a = this.getBoundary('max', data.innerValue), maxYear = _a.maxYear, maxDate = _a.maxDate, maxMonth = _a.maxMonth, maxHour = _a.maxHour, maxMinute = _a.maxMinute;
|
||||
var _b = this.getBoundary('min', data.innerValue), minYear = _b.minYear, minDate = _b.minDate, minMonth = _b.minMonth, minHour = _b.minHour, minMinute = _b.minMinute;
|
||||
var result = [
|
||||
{
|
||||
type: 'year',
|
||||
range: [minYear, maxYear]
|
||||
},
|
||||
{
|
||||
type: 'month',
|
||||
range: [minMonth, maxMonth]
|
||||
},
|
||||
{
|
||||
type: 'day',
|
||||
range: [minDate, maxDate]
|
||||
},
|
||||
{
|
||||
type: 'hour',
|
||||
range: [minHour, maxHour]
|
||||
},
|
||||
{
|
||||
type: 'minute',
|
||||
range: [minMinute, maxMinute]
|
||||
}
|
||||
];
|
||||
if (data.type === 'date')
|
||||
result.splice(3, 2);
|
||||
if (data.type === 'year-month')
|
||||
result.splice(2, 3);
|
||||
return result;
|
||||
},
|
||||
correctValue: function (value) {
|
||||
var data = this.data;
|
||||
// validate value
|
||||
var isDateType = data.type !== 'time';
|
||||
if (isDateType && !isValidDate(value)) {
|
||||
value = data.minDate;
|
||||
}
|
||||
else if (!isDateType && !value) {
|
||||
var minHour = data.minHour;
|
||||
value = padZero(minHour) + ":00";
|
||||
}
|
||||
// time type
|
||||
if (!isDateType) {
|
||||
var _a = value.split(':'), hour = _a[0], minute = _a[1];
|
||||
hour = padZero(range(hour, data.minHour, data.maxHour));
|
||||
minute = padZero(range(minute, data.minMinute, data.maxMinute));
|
||||
return hour + ":" + minute;
|
||||
}
|
||||
// date type
|
||||
value = Math.max(value, data.minDate);
|
||||
value = Math.min(value, data.maxDate);
|
||||
return value;
|
||||
},
|
||||
getBoundary: function (type, innerValue) {
|
||||
var _a;
|
||||
var value = new Date(innerValue);
|
||||
var boundary = new Date(this.data[type + "Date"]);
|
||||
var year = boundary.getFullYear();
|
||||
var month = 1;
|
||||
var date = 1;
|
||||
var hour = 0;
|
||||
var minute = 0;
|
||||
if (type === 'max') {
|
||||
month = 12;
|
||||
date = getMonthEndDay(value.getFullYear(), value.getMonth() + 1);
|
||||
hour = 23;
|
||||
minute = 59;
|
||||
}
|
||||
if (value.getFullYear() === year) {
|
||||
month = boundary.getMonth() + 1;
|
||||
if (value.getMonth() + 1 === month) {
|
||||
date = boundary.getDate();
|
||||
if (value.getDate() === date) {
|
||||
hour = boundary.getHours();
|
||||
if (value.getHours() === hour) {
|
||||
minute = boundary.getMinutes();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return _a = {},
|
||||
_a[type + "Year"] = year,
|
||||
_a[type + "Month"] = month,
|
||||
_a[type + "Date"] = date,
|
||||
_a[type + "Hour"] = hour,
|
||||
_a[type + "Minute"] = minute,
|
||||
_a;
|
||||
},
|
||||
onCancel: function () {
|
||||
this.$emit('cancel');
|
||||
},
|
||||
onConfirm: function () {
|
||||
this.$emit('confirm', this.data.innerValue);
|
||||
},
|
||||
onChange: function () {
|
||||
var _this = this;
|
||||
var data = this.data;
|
||||
var value;
|
||||
var picker = this.getPicker();
|
||||
if (data.type === 'time') {
|
||||
var indexes = picker.getIndexes();
|
||||
value = indexes[0] + data.minHour + ":" + (indexes[1] + data.minMinute);
|
||||
}
|
||||
else {
|
||||
var values = picker.getValues();
|
||||
var year = getTrueValue(values[0]);
|
||||
var month = getTrueValue(values[1]);
|
||||
var maxDate = getMonthEndDay(year, month);
|
||||
var date = getTrueValue(values[2]);
|
||||
if (data.type === 'year-month') {
|
||||
date = 1;
|
||||
}
|
||||
date = date > maxDate ? maxDate : date;
|
||||
var hour = 0;
|
||||
var minute = 0;
|
||||
if (data.type === 'datetime') {
|
||||
hour = getTrueValue(values[3]);
|
||||
minute = getTrueValue(values[4]);
|
||||
}
|
||||
value = new Date(year, month - 1, date, hour, minute);
|
||||
}
|
||||
value = this.correctValue(value);
|
||||
this.updateColumnValue(value).then(function () {
|
||||
_this.$emit('input', value);
|
||||
_this.$emit('change', picker);
|
||||
});
|
||||
},
|
||||
updateColumnValue: function (value) {
|
||||
var _this = this;
|
||||
var values = [];
|
||||
var data = this.data;
|
||||
var picker = this.getPicker();
|
||||
if (data.type === 'time') {
|
||||
var pair = value.split(':');
|
||||
values = [pair[0], pair[1]];
|
||||
}
|
||||
else {
|
||||
var date = new Date(value);
|
||||
values = ["" + date.getFullYear(), padZero(date.getMonth() + 1)];
|
||||
if (data.type === 'date') {
|
||||
values.push(padZero(date.getDate()));
|
||||
}
|
||||
if (data.type === 'datetime') {
|
||||
values.push(padZero(date.getDate()), padZero(date.getHours()), padZero(date.getMinutes()));
|
||||
}
|
||||
}
|
||||
return this.set({ innerValue: value })
|
||||
.then(function () { return _this.updateColumns(); })
|
||||
.then(function () { return picker.setValues(values); });
|
||||
}
|
||||
},
|
||||
created: function () {
|
||||
var _this = this;
|
||||
var innerValue = this.correctValue(this.data.value);
|
||||
this.updateColumnValue(innerValue).then(function () {
|
||||
_this.$emit('input', innerValue);
|
||||
});
|
||||
}
|
||||
});
|
6
lib/datetime-picker/index.json
Normal file
6
lib/datetime-picker/index.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-picker": "../picker/index"
|
||||
}
|
||||
}
|
13
lib/datetime-picker/index.wxml
Normal file
13
lib/datetime-picker/index.wxml
Normal file
@ -0,0 +1,13 @@
|
||||
<van-picker
|
||||
class="van-datetime-picker"
|
||||
title="{{ title }}"
|
||||
columns="{{ columns }}"
|
||||
item-height="{{ itemHeight }}"
|
||||
show-toolbar="{{ showToolbar }}"
|
||||
visible-item-count="{{ visibleItemCount }}"
|
||||
confirm-button-text="{{ confirmButtonText }}"
|
||||
cancel-button-text="{{ cancelButtonText }}"
|
||||
bind:change="onChange"
|
||||
bind:confirm="onConfirm"
|
||||
bind:cancel="onCancel"
|
||||
/>
|
1
lib/datetime-picker/index.wxss
Normal file
1
lib/datetime-picker/index.wxss
Normal file
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';
|
73
lib/dialog/dialog.js
Normal file
73
lib/dialog/dialog.js
Normal file
@ -0,0 +1,73 @@
|
||||
"use strict";
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var queue = [];
|
||||
function getContext() {
|
||||
var pages = getCurrentPages();
|
||||
return pages[pages.length - 1];
|
||||
}
|
||||
var Dialog = function (options) {
|
||||
options = __assign({}, Dialog.currentOptions, options);
|
||||
return new Promise(function (resolve, reject) {
|
||||
var context = options.context || getContext();
|
||||
var dialog = context.selectComponent(options.selector);
|
||||
delete options.selector;
|
||||
if (dialog) {
|
||||
dialog.set(__assign({ onCancel: reject, onConfirm: resolve }, options));
|
||||
queue.push(dialog);
|
||||
}
|
||||
else {
|
||||
console.warn('未找到 van-dialog 节点,请确认 selector 及 context 是否正确');
|
||||
}
|
||||
});
|
||||
};
|
||||
Dialog.defaultOptions = {
|
||||
show: true,
|
||||
title: '',
|
||||
message: '',
|
||||
zIndex: 100,
|
||||
overlay: true,
|
||||
asyncClose: false,
|
||||
messageAlign: '',
|
||||
transition: 'scale',
|
||||
selector: '#van-dialog',
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
showConfirmButton: true,
|
||||
showCancelButton: false,
|
||||
closeOnClickOverlay: false,
|
||||
confirmButtonOpenType: ''
|
||||
};
|
||||
Dialog.alert = Dialog;
|
||||
Dialog.confirm = function (options) {
|
||||
return Dialog(__assign({ showCancelButton: true }, options));
|
||||
};
|
||||
Dialog.close = function () {
|
||||
queue.forEach(function (dialog) {
|
||||
dialog.close();
|
||||
});
|
||||
queue = [];
|
||||
};
|
||||
Dialog.stopLoading = function () {
|
||||
queue.forEach(function (dialog) {
|
||||
dialog.stopLoading();
|
||||
});
|
||||
};
|
||||
Dialog.setDefaultOptions = function (options) {
|
||||
Object.assign(Dialog.currentOptions, options);
|
||||
};
|
||||
Dialog.resetDefaultOptions = function () {
|
||||
Dialog.currentOptions = __assign({}, Dialog.defaultOptions);
|
||||
};
|
||||
Dialog.resetDefaultOptions();
|
||||
exports.default = Dialog;
|
99
lib/dialog/index.js
Normal file
99
lib/dialog/index.js
Normal file
@ -0,0 +1,99 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../common/component");
|
||||
var button_1 = require("../mixins/button");
|
||||
var open_type_1 = require("../mixins/open-type");
|
||||
component_1.VantComponent({
|
||||
mixins: [button_1.button, open_type_1.openType],
|
||||
props: {
|
||||
show: Boolean,
|
||||
title: String,
|
||||
message: String,
|
||||
useSlot: Boolean,
|
||||
asyncClose: Boolean,
|
||||
messageAlign: String,
|
||||
showCancelButton: Boolean,
|
||||
closeOnClickOverlay: Boolean,
|
||||
confirmButtonOpenType: String,
|
||||
zIndex: {
|
||||
type: Number,
|
||||
value: 2000
|
||||
},
|
||||
confirmButtonText: {
|
||||
type: String,
|
||||
value: '确认'
|
||||
},
|
||||
cancelButtonText: {
|
||||
type: String,
|
||||
value: '取消'
|
||||
},
|
||||
showConfirmButton: {
|
||||
type: Boolean,
|
||||
value: true
|
||||
},
|
||||
overlay: {
|
||||
type: Boolean,
|
||||
value: true
|
||||
},
|
||||
transition: {
|
||||
type: String,
|
||||
value: 'scale'
|
||||
}
|
||||
},
|
||||
data: {
|
||||
loading: {
|
||||
confirm: false,
|
||||
cancel: false
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
show: function (show) {
|
||||
!show && this.stopLoading();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onConfirm: function () {
|
||||
this.handleAction('confirm');
|
||||
},
|
||||
onCancel: function () {
|
||||
this.handleAction('cancel');
|
||||
},
|
||||
onClickOverlay: function () {
|
||||
this.onClose('overlay');
|
||||
},
|
||||
handleAction: function (action) {
|
||||
var _a;
|
||||
if (this.data.asyncClose) {
|
||||
this.set((_a = {},
|
||||
_a["loading." + action] = true,
|
||||
_a));
|
||||
}
|
||||
this.onClose(action);
|
||||
},
|
||||
close: function () {
|
||||
this.set({
|
||||
show: false
|
||||
});
|
||||
},
|
||||
stopLoading: function () {
|
||||
this.set({
|
||||
loading: {
|
||||
confirm: false,
|
||||
cancel: false
|
||||
}
|
||||
});
|
||||
},
|
||||
onClose: function (action) {
|
||||
if (!this.data.asyncClose) {
|
||||
this.close();
|
||||
}
|
||||
this.$emit('close', action);
|
||||
//把 dialog 实例传递出去,可以通过 stopLoading() 在外部关闭按钮的 loading
|
||||
this.$emit(action, { dialog: this });
|
||||
var callback = this.data[action === 'confirm' ? 'onConfirm' : 'onCancel'];
|
||||
if (callback) {
|
||||
callback(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user