build: compile v1.6.9-beta.0

This commit is contained in:
nemo-shen 2021-05-22 17:03:11 +08:00
parent 11e83e5f4d
commit f2699c928b
83 changed files with 581 additions and 415 deletions

View File

@ -1,8 +1,7 @@
import { VantComponent } from '../common/component';
import { button } from '../mixins/button';
import { openType } from '../mixins/open-type';
VantComponent({
mixins: [button, openType],
mixins: [button],
props: {
show: Boolean,
title: String,
@ -40,12 +39,21 @@ VantComponent({
methods: {
onSelect(event) {
const { index } = event.currentTarget.dataset;
const item = this.data.actions[index];
if (item && !item.disabled && !item.loading) {
const { actions, closeOnClickAction, canIUseGetUserProfile } = this.data;
const item = actions[index];
if (item) {
this.$emit('select', item);
if (this.data.closeOnClickAction) {
if (closeOnClickAction) {
this.onClose();
}
if (item.openType === 'getUserInfo' && canIUseGetUserProfile) {
wx.getUserProfile({
desc: item.getUserProfileDesc || ' ',
complete: (userProfile) => {
this.$emit('getuserinfo', userProfile);
},
});
}
}
},
onCancel() {

View File

@ -27,18 +27,18 @@
<button
wx:for="{{ actions }}"
wx:key="index"
open-type="{{ item.openType }}"
open-type="{{ item.disabled || item.loading || (canIUseGetUserProfile && item.openType === 'getUserInfo') ? '' : item.openType }}"
style="{{ item.color ? 'color: ' + item.color : '' }}"
class="{{ utils.bem('action-sheet__item', { disabled: item.disabled || item.loading }) }} {{ item.className || '' }}"
hover-class="van-action-sheet__item--hover"
data-index="{{ index }}"
bind:tap="onSelect"
bindgetuserinfo="bindGetUserInfo"
bindcontact="bindContact"
bindgetphonenumber="bindGetPhoneNumber"
binderror="bindError"
bindlaunchapp="bindLaunchApp"
bindopensetting="bindOpenSetting"
bindtap="{{ item.disabled || item.loading ? '' : 'onSelect' }}"
bindgetuserinfo="onGetUserInfo"
bindcontact="onContact"
bindgetphonenumber="onGetPhoneNumber"
binderror="onError"
bindlaunchapp="onLaunchApp"
bindopensetting="onOpenSetting"
lang="{{ lang }}"
session-from="{{ sessionFrom }}"
send-message-title="{{ sendMessageTitle }}"

17
dist/area/index.js vendored
View File

@ -80,15 +80,18 @@ VantComponent({
});
},
onChange(event) {
var _a;
const { index, picker, value } = event.detail;
this.code = value[index].code;
this.setValues().then(() => {
this.$emit('change', {
picker,
values: this.parseValues(picker.getValues()),
index,
});
});
(_a = this.setValues()) === null || _a === void 0
? void 0
: _a.then(() => {
this.$emit('change', {
picker,
values: this.parseValues(picker.getValues()),
index,
});
});
},
getConfig(type) {
const { areaList } = this.data;

17
dist/button/index.js vendored
View File

@ -1,8 +1,7 @@
import { VantComponent } from '../common/component';
import { button } from '../mixins/button';
import { openType } from '../mixins/open-type';
import { canIUseFormFieldButton } from '../common/version';
const mixins = [button, openType];
const mixins = [button];
if (canIUseFormFieldButton()) {
mixins.push('wx://form-field-button');
}
@ -48,11 +47,17 @@ VantComponent({
color: String,
},
methods: {
onClick() {
if (!this.data.loading) {
this.$emit('click');
onClick(event) {
this.$emit('click', event);
const { canIUseGetUserProfile, openType, getUserProfileDesc } = this.data;
if (openType === 'getUserInfo' && canIUseGetUserProfile) {
wx.getUserProfile({
desc: getUserProfileDesc || ' ',
complete: (userProfile) => {
this.$emit('getuserinfo', userProfile);
},
});
}
},
noop() {},
},
});

View File

@ -9,7 +9,7 @@
lang="{{ lang }}"
form-type="{{ formType }}"
style="{{ computed.rootStyle({ plain, color, customStyle }) }}"
open-type="{{ disabled ? '' : openType }}"
open-type="{{ disabled || loading || (canIUseGetUserProfile && openType === 'getUserInfo') ? '' : openType }}"
business-id="{{ businessId }}"
session-from="{{ sessionFrom }}"
send-message-title="{{ sendMessageTitle }}"
@ -18,13 +18,13 @@
show-message-card="{{ showMessageCard }}"
app-parameter="{{ appParameter }}"
aria-label="{{ ariaLabel }}"
bindtap="{{ !disabled ? 'onClick' : 'noop' }}"
bindgetuserinfo="bindGetUserInfo"
bindcontact="bindContact"
bindgetphonenumber="bindGetPhoneNumber"
binderror="bindError"
bindlaunchapp="bindLaunchApp"
bindopensetting="bindOpenSetting"
bindtap="{{ disabled || loading ? '' : 'onClick' }}"
bindgetuserinfo="onGetUserInfo"
bindcontact="onContact"
bindgetphonenumber="onGetPhoneNumber"
binderror="onError"
bindlaunchapp="onLaunchApp"
bindopensetting="onOpenSetting"
>
<block wx:if="{{ loading }}">
<van-loading

View File

@ -4,6 +4,7 @@
showTitle="{{ showTitle }}"
subtitle="{{ subtitle }}"
showSubtitle="{{ showSubtitle }}"
firstDayOfWeek="{{ firstDayOfWeek }}"
>
<slot name="title" slot="title"></slot>
</header>
@ -31,6 +32,7 @@
showSubtitle="{{ showSubtitle }}"
allowSameDay="{{ allowSameDay }}"
showMonthTitle="{{ index !== 0 || !showSubtitle }}"
firstDayOfWeek="{{ firstDayOfWeek }}"
bind:click="onClickDay"
/>
</scroll-view>

View File

@ -8,9 +8,27 @@ VantComponent({
subtitle: String,
showTitle: Boolean,
showSubtitle: Boolean,
firstDayOfWeek: {
type: Number,
observer: 'initWeekDay',
},
},
data: {
weekdays: ['日', '一', '二', '三', '四', '五', '六'],
weekdays: [],
},
created() {
this.initWeekDay();
},
methods: {
initWeekDay() {
const defaultWeeks = ['日', '一', '二', '三', '四', '五', '六'];
const firstDayOfWeek = this.data.firstDayOfWeek || 0;
this.setData({
weekdays: [
...defaultWeeks.slice(firstDayOfWeek, 7),
...defaultWeeks.slice(0, firstDayOfWeek),
],
});
},
},
methods: {},
});

View File

@ -34,6 +34,10 @@ VantComponent({
type: null,
observer: 'setDays',
},
firstDayOfWeek: {
type: Number,
observer: 'setDays',
},
allowSameDay: Boolean,
showSubtitle: Boolean,
showMonthTitle: Boolean,
@ -100,11 +104,11 @@ VantComponent({
getRangeDayType(day) {
const { currentDate, allowSameDay } = this.data;
if (!Array.isArray(currentDate)) {
return;
return '';
}
const [startDay, endDay] = currentDate;
if (!startDay) {
return;
return '';
}
const compareToStart = compareDay(day, startDay);
if (!endDay) {
@ -123,6 +127,7 @@ VantComponent({
if (compareToStart > 0 && compareToEnd < 0) {
return 'middle';
}
return '';
},
getDayType(day) {
const { type, minDate, maxDate, currentDate } = this.data;
@ -139,6 +144,7 @@ VantComponent({
if (type === 'range') {
return this.getRangeDayType(day);
}
return '';
},
getBottomInfo(type) {
if (this.data.type === 'range') {

View File

@ -14,7 +14,7 @@
<view
wx:for="{{ days }}"
wx:key="index"
style="{{ computed.getDayStyle(item.type, index, date, rowHeight, color) }}"
style="{{ computed.getDayStyle(item.type, index, date, rowHeight, color, firstDayOfWeek) }}"
class="{{ utils.bem('calendar__day', [item.type]) }} {{ item.className }}"
data-index="{{ index }}"
bindtap="onClick"

View File

@ -7,9 +7,12 @@ function getMark(date) {
var ROW_HEIGHT = 64;
function getDayStyle(type, index, date, rowHeight, color) {
function getDayStyle(type, index, date, rowHeight, color, firstDayOfWeek) {
var style = [];
var offset = getDate(date).getDay();
var current = getDate(date).getDay() || 7;
var offset = current < firstDayOfWeek ? (7 - firstDayOfWeek + current) :
current === 7 && firstDayOfWeek === 0 ? 0 :
(current - firstDayOfWeek);
if (index === 0) {
style.push(['margin-left', (100 * offset) / 7 + '%']);
@ -23,6 +26,7 @@ function getDayStyle(type, index, date, rowHeight, color) {
if (
type === 'start' ||
type === 'end' ||
type === 'start-end' ||
type === 'multiple-selected' ||
type === 'multiple-middle'
) {

View File

@ -34,6 +34,10 @@ VantComponent({
value: '确定',
},
rangePrompt: String,
showRangePrompt: {
type: Boolean,
value: true,
},
defaultDate: {
type: null,
observer(val) {
@ -104,6 +108,10 @@ VantComponent({
type: null,
value: null,
},
firstDayOfWeek: {
type: Number,
value: 0,
},
},
data: {
subtitle: '',
@ -271,12 +279,16 @@ VantComponent({
this.$emit('select', copyDates(date));
},
checkRange(date) {
const { maxRange, rangePrompt } = this.data;
const { maxRange, rangePrompt, showRangePrompt } = this.data;
if (maxRange && calcDateNum(date) > maxRange) {
Toast({
context: this,
message: rangePrompt || `选择天数不能超过 ${maxRange}`,
});
if (showRangePrompt) {
Toast({
duration: 0,
context: this,
message: rangePrompt || `选择天数不能超过 ${maxRange}`,
});
}
this.$emit('over-range');
return false;
}
return true;

View File

@ -3,11 +3,11 @@ export declare function formatMonthTitle(date: Date): string;
export declare function compareMonth(
date1: Date | number,
date2: Date | number
): 0 | 1 | -1;
): 1 | -1 | 0;
export declare function compareDay(
day1: Date | number,
day2: Date | number
): 0 | 1 | -1;
): 1 | -1 | 0;
export declare function getDayByOffset(date: Date, offset: number): Date;
export declare function getPrevDay(date: Date): Date;
export declare function getNextDay(date: Date): Date;

View File

@ -20,6 +20,7 @@
style="{{ computed.titleStyle({ titleWidth, titleStyle }) }}"
class="van-cell__title title-class"
>
<block wx:if="{{ title }}">{{ title }}</block>
<slot wx:else name="title" />

10
dist/circle/index.js vendored
View File

@ -156,10 +156,14 @@ VantComponent({
this.currentValue = this.currentValue || 0;
this.interval = setInterval(() => {
if (this.currentValue !== value) {
if (this.currentValue < value) {
this.currentValue += STEP;
if (Math.abs(this.currentValue - value) < STEP) {
this.currentValue = value;
} else {
this.currentValue -= STEP;
if (this.currentValue < value) {
this.currentValue += STEP;
} else {
this.currentValue -= STEP;
}
}
this.drawCircle(this.currentValue);
} else {

View File

@ -1,7 +1,7 @@
/// <reference types="miniprogram-api-typings" />
export declare function range(num: number, min: number, max: number): number;
export declare function nextTick(cb: (...args: any[]) => void): void;
export declare function getSystemInfoSync(): WechatMiniprogram.GetSystemInfoSyncResult;
export declare function getSystemInfoSync(): WechatMiniprogram.SystemInfo;
export declare function addUnit(value?: string | number): string | undefined;
export declare function requestAnimationFrame(
cb: () => void
@ -25,6 +25,6 @@ export declare function toPromise(
export declare function getCurrentPage<T>(): T &
WechatMiniprogram.OptionalInterface<WechatMiniprogram.Page.ILifetime> &
WechatMiniprogram.Page.InstanceProperties &
WechatMiniprogram.Page.InstanceMethods<Record<string, any>> &
WechatMiniprogram.Page.Data<Record<string, any>> &
Record<string, any>;
WechatMiniprogram.Page.InstanceMethods<WechatMiniprogram.IAnyObject> &
WechatMiniprogram.Page.Data<WechatMiniprogram.IAnyObject> &
WechatMiniprogram.IAnyObject;

View File

@ -1,3 +1,4 @@
// eslint-disable-next-line @typescript-eslint/ban-types
export function isFunction(val) {
return typeof val === 'function';
}

View File

@ -4,3 +4,4 @@ export declare function canIUseAnimate(): boolean;
export declare function canIUseGroupSetData(): boolean;
export declare function canIUseNextTick(): boolean;
export declare function canIUseCanvas2d(): boolean;
export declare function canIUseGetUserProfile(): boolean;

View File

@ -43,3 +43,6 @@ export function canIUseNextTick() {
export function canIUseCanvas2d() {
return gte('2.9.0');
}
export function canIUseGetUserProfile() {
return !!wx.getUserProfile;
}

View File

@ -122,9 +122,8 @@ VantComponent({
const { filter } = this.data;
const results = this.getRanges().map(({ type, range }) => {
let values = times(range[1] - range[0] + 1, (index) => {
let value = range[0] + index;
value = type === 'year' ? `${value}` : padZero(value);
return value;
const value = range[0] + index;
return type === 'year' ? `${value}` : padZero(value);
});
if (filter) {
values = filter(type, values);

View File

@ -34,7 +34,7 @@ export declare type VantComponentOptions<
Data & {
name: string;
value: any;
},
} & Record<string, any>,
Props,
Methods
> &

View File

@ -40,36 +40,14 @@ interface DialogOptions {
}
declare const Dialog: {
(options: DialogOptions): Promise<
WechatMiniprogram.Component.Instance<
Record<string, any>,
Record<string, any>,
Record<string, any>,
Record<string, any>,
false
>
WechatMiniprogram.Component.TrivialInstance
>;
alert(
options: DialogOptions
): Promise<
WechatMiniprogram.Component.Instance<
Record<string, any>,
Record<string, any>,
Record<string, any>,
Record<string, any>,
false
>
>;
): Promise<WechatMiniprogram.Component.TrivialInstance>;
confirm(
options: DialogOptions
): Promise<
WechatMiniprogram.Component.Instance<
Record<string, any>,
Record<string, any>,
Record<string, any>,
Record<string, any>,
false
>
>;
): Promise<WechatMiniprogram.Component.TrivialInstance>;
close(): void;
stopLoading(): void;
currentOptions: DialogOptions;

View File

@ -1,10 +1,9 @@
import { VantComponent } from '../common/component';
import { button } from '../mixins/button';
import { openType } from '../mixins/open-type';
import { GRAY, RED } from '../common/color';
import { toPromise } from '../common/utils';
VantComponent({
mixins: [button, openType],
mixins: [button],
props: {
show: {
type: Boolean,

View File

@ -58,12 +58,12 @@
app-parameter="{{ appParameter }}"
bind:click="onConfirm"
bindgetuserinfo="bindGetUserInfo"
bindcontact="bindContact"
bindgetphonenumber="bindGetPhoneNumber"
binderror="bindError"
bindlaunchapp="bindLaunchApp"
bindopensetting="bindOpenSetting"
bindgetuserinfo="onGetUserInfo"
bindcontact="onContact"
bindgetphonenumber="onGetPhoneNumber"
binderror="onError"
bindlaunchapp="onLaunchApp"
bindopensetting="onOpenSetting"
>
{{ confirmButtonText }}
</van-goods-action-button>
@ -100,12 +100,12 @@
app-parameter="{{ appParameter }}"
bind:click="onConfirm"
bindgetuserinfo="bindGetUserInfo"
bindcontact="bindContact"
bindgetphonenumber="bindGetPhoneNumber"
binderror="bindError"
bindlaunchapp="bindLaunchApp"
bindopensetting="bindOpenSetting"
bindgetuserinfo="onGetUserInfo"
bindcontact="onContact"
bindgetphonenumber="onGetPhoneNumber"
binderror="onError"
bindlaunchapp="onLaunchApp"
bindopensetting="onOpenSetting"
>
{{ confirmButtonText }}
</van-button>

View File

@ -2,9 +2,8 @@ import { VantComponent } from '../common/component';
import { useParent } from '../common/relation';
import { button } from '../mixins/button';
import { link } from '../mixins/link';
import { openType } from '../mixins/open-type';
VantComponent({
mixins: [link, button, openType],
mixins: [link, button],
relation: useParent('goods-action'),
props: {
text: String,

View File

@ -18,12 +18,12 @@
show-message-card="{{ showMessageCard }}"
send-message-title="{{ sendMessageTitle }}"
bind:click="onClick"
binderror="bindError"
bindcontact="bindContact"
bindopensetting="bindOpenSetting"
bindgetuserinfo="bindGetUserInfo"
bindgetphonenumber="bindGetPhoneNumber"
bindlaunchapp="bindLaunchApp"
binderror="onError"
bindcontact="onContact"
bindopensetting="onOpenSetting"
bindgetuserinfo="onGetUserInfo"
bindgetphonenumber="onGetPhoneNumber"
bindlaunchapp="onLaunchApp"
>
{{ text }}
<slot></slot>

View File

@ -1,10 +1,9 @@
import { VantComponent } from '../common/component';
import { button } from '../mixins/button';
import { link } from '../mixins/link';
import { openType } from '../mixins/open-type';
VantComponent({
classes: ['icon-class', 'text-class'],
mixins: [link, button, openType],
mixins: [link, button],
props: {
text: String,
dot: Boolean,

View File

@ -15,12 +15,12 @@
show-message-card="{{ showMessageCard }}"
send-message-title="{{ sendMessageTitle }}"
bind:click="onClick"
binderror="bindError"
bindcontact="bindContact"
bindopensetting="bindOpenSetting"
bindgetuserinfo="bindGetUserInfo"
bindgetphonenumber="bindGetPhoneNumber"
bindlaunchapp="bindLaunchApp"
binderror="onError"
bindcontact="onContact"
bindopensetting="onOpenSetting"
bindgetuserinfo="onGetUserInfo"
bindgetphonenumber="onGetPhoneNumber"
bindlaunchapp="onLaunchApp"
>
<van-icon
wx:if="{{ icon }}"

File diff suppressed because one or more lines are too long

3
dist/image/index.js vendored
View File

@ -1,8 +1,7 @@
import { VantComponent } from '../common/component';
import { button } from '../mixins/button';
import { openType } from '../mixins/open-type';
VantComponent({
mixins: [button, openType],
mixins: [button],
classes: ['custom-class', 'loading-class', 'error-class', 'image-class'],
props: {
src: {

26
dist/mixins/button.js vendored
View File

@ -1,3 +1,4 @@
import { canIUseGetUserProfile } from '../common/version';
export const button = Behavior({
externalClasses: ['hover-class'],
properties: {
@ -11,5 +12,30 @@ export const button = Behavior({
showMessageCard: Boolean,
appParameter: String,
ariaLabel: String,
openType: String,
getUserProfileDesc: String,
},
data: {
canIUseGetUserProfile: canIUseGetUserProfile(),
},
methods: {
onGetUserInfo(event) {
this.triggerEvent('getuserinfo', event.detail);
},
onContact(event) {
this.triggerEvent('contact', event.detail);
},
onGetPhoneNumber(event) {
this.triggerEvent('getphonenumber', event.detail);
},
onError(event) {
this.triggerEvent('error', event.detail);
},
onLaunchApp(event) {
this.triggerEvent('launchapp', event.detail);
},
onOpenSetting(event) {
this.triggerEvent('opensetting', event.detail);
},
},
});

View File

@ -1 +0,0 @@
export declare const openType: string;

View File

@ -1,26 +0,0 @@
// @ts-nocheck
export const openType = Behavior({
properties: {
openType: String,
},
methods: {
bindGetUserInfo(event) {
this.$emit('getuserinfo', event.detail);
},
bindContact(event) {
this.$emit('contact', event.detail);
},
bindGetPhoneNumber(event) {
this.$emit('getphonenumber', event.detail);
},
bindError(event) {
this.$emit('error', event.detail);
},
bindLaunchApp(event) {
this.$emit('launchapp', event.detail);
},
bindOpenSetting(event) {
this.$emit('opensetting', event.detail);
},
},
});

View File

@ -25,13 +25,10 @@ VantComponent({
},
speed: {
type: Number,
value: 50,
value: 60,
observer: 'init',
},
scrollable: {
type: Boolean,
value: true,
},
scrollable: null,
leftIcon: {
type: String,
value: '',
@ -64,17 +61,19 @@ VantComponent({
getRect(this, '.van-notice-bar__wrap'),
]).then((rects) => {
const [contentRect, wrapRect] = rects;
const { speed, scrollable, delay } = this.data;
if (
contentRect == null ||
wrapRect == null ||
!contentRect.width ||
!wrapRect.width
!wrapRect.width ||
scrollable === false
) {
return;
}
const { speed, scrollable, delay } = this.data;
if (scrollable || wrapRect.width < contentRect.width) {
const duration = (contentRect.width / speed) * 1000;
const duration =
((wrapRect.width + contentRect.width) / speed) * 1000;
this.wrapWidth = wrapRect.width;
this.contentWidth = contentRect.width;
this.duration = duration;

View File

@ -16,7 +16,7 @@
<slot wx:else name="left-icon" />
<view class="van-notice-bar__wrap">
<view class="van-notice-bar__content {{ !scrollable && !wrapable ? 'van-ellipsis' : '' }}" animation="{{ animationData }}">
<view class="van-notice-bar__content {{ scrollable === false && !wrapable ? 'van-ellipsis' : '' }}" animation="{{ animationData }}">
{{ text }}
<slot wx:if="{{ !text }}"></slot>
</view>

1
dist/panel/index.js vendored
View File

@ -5,6 +5,5 @@ VantComponent({
desc: String,
title: String,
status: String,
useFooterSlot: Boolean,
},
});

View File

@ -1,5 +1,5 @@
<view class="van-panel van-hairline--top-bottom custom-class">
<van-cell
<van-cell
wx:if="{{ title || desc || status }}"
title="{{ title }}"
label="{{ desc }}"
@ -13,7 +13,7 @@
<slot />
</view>
<view wx:if="{{ useFooterSlot }}" class="van-panel__footer van-hairline--top footer-class">
<view class="van-panel__footer van-hairline--top footer-class">
<slot name="footer" />
</view>
</view>

View File

@ -1 +1 @@
@import '../common/index.wxss';.van-panel{background:#fff;background:var(--panel-background-color,#fff)}.van-panel__header-value{color:#ee0a24;color:var(--panel-header-value-color,#ee0a24)}.van-panel__footer{padding:8px 16px;padding:var(--panel-footer-padding,8px 16px)}
@import '../common/index.wxss';.van-panel{background:#fff;background:var(--panel-background-color,#fff)}.van-panel__header-value{color:#ee0a24;color:var(--panel-header-value-color,#ee0a24)}.van-panel__footer{padding:8px 16px;padding:var(--panel-footer-padding,8px 16px)}.van-panel__footer:empty{display:none}

View File

@ -9,7 +9,7 @@
bind:touchend="onTouchEnd"
bind:touchcancel="onTouchEnd"
>
<view style="{{ computed.wrapperStyle({ offset, itemHeight, visibleItemCount }) }}">
<view style="{{ computed.wrapperStyle({ offset, itemHeight, visibleItemCount, duration }) }}">
<view
wx:for="{{ options }}"
wx:for-item="option"

View File

@ -2,9 +2,7 @@ import { VantComponent } from '../common/component';
import { useChildren } from '../common/relation';
VantComponent({
field: true,
relation: useChildren('radio', function (target) {
this.updateChild(target);
}),
relation: useChildren('radio'),
props: {
value: {
type: null,
@ -18,15 +16,7 @@ VantComponent({
},
methods: {
updateChildren() {
this.children.forEach((child) => this.updateChild(child));
},
updateChild(child) {
const { value, disabled, direction } = this.data;
child.setData({
value,
direction,
disabled: disabled || child.data.disabled,
});
this.children.forEach((child) => child.updateFromParent());
},
},
});

29
dist/radio/index.js vendored
View File

@ -1,8 +1,11 @@
import { canIUseModel } from '../common/version';
import { VantComponent } from '../common/component';
import { useParent } from '../common/relation';
VantComponent({
field: true,
relation: useParent('radio-group'),
relation: useParent('radio-group', function () {
this.updateFromParent();
}),
classes: ['icon-class', 'label-class'],
props: {
name: null,
@ -24,20 +27,38 @@ VantComponent({
value: 20,
},
},
data: {
direction: '',
parentDisabled: false,
},
methods: {
updateFromParent() {
if (!this.parent) {
return;
}
const { value, disabled: parentDisabled, direction } = this.parent.data;
this.setData({
value,
direction,
parentDisabled,
});
},
emitChange(value) {
const instance = this.parent || this;
instance.$emit('input', value);
instance.$emit('change', value);
if (canIUseModel()) {
instance.setData({ value });
}
},
onChange() {
if (!this.data.disabled) {
if (!this.data.disabled && !this.data.parentDisabled) {
this.emitChange(this.data.name);
}
},
onClickLabel() {
const { disabled, labelDisabled, name } = this.data;
if (!disabled && !labelDisabled) {
const { disabled, parentDisabled, labelDisabled, name } = this.data;
if (!(disabled || parentDisabled) && !labelDisabled) {
this.emitChange(name);
}
},

13
dist/radio/index.wxml vendored
View File

@ -1,27 +1,28 @@
<wxs src="../wxs/utils.wxs" module="utils" />
<wxs src="./index.wxs" module="computed" />
<view class="{{ utils.bem('radio', [direction]) }} custom-class">
<view
wx:if="{{ labelPosition === 'left' }}"
class="label-class {{ utils.bem('radio__label', [labelPosition, { disabled }]) }}"
class="{{ utils.bem('radio__label', [labelPosition, { disabled: disabled || parentDisabled }]) }} label-class"
bindtap="onClickLabel"
>
<slot />
</view>
<view class="van-radio__icon-wrap" style="font-size: {{ utils.addUnit(iconSize) }};" bindtap="onChange">
<view class="van-radio__icon-wrap" style="font-size: {{ utils.addUnit(iconSize) }}" bindtap="onChange">
<slot wx:if="{{ useIconSlot }}" name="icon" />
<van-icon
wx:else
name="success"
class="{{ utils.bem('radio__icon', [shape, { disabled, checked: value === name }]) }}"
style="font-size: {{ utils.addUnit(iconSize) }};{{ checkedColor && !disabled && value === name ? 'border-color:' + checkedColor + '; background-color:' + checkedColor + ';' : '' }}"
class="{{ utils.bem('radio__icon', [shape, { disabled: disabled || parentDisabled, checked: value === name }]) }}"
style="{{ computed.iconStyle({ iconSize, checkedColor, disabled, parentDisabled, value, name }) }}"
custom-class="icon-class"
custom-style="line-height: {{ utils.addUnit(iconSize) }};font-size: .8em;display: block;"
custom-style="{{ computed.iconCustomStyle({ iconSize }) }}"
/>
</view>
<view
wx:if="{{ labelPosition === 'right' }}"
class="label-class {{ utils.bem('radio__label', [labelPosition, { disabled }]) }}"
class="label-class {{ utils.bem('radio__label', [labelPosition, { disabled: disabled || parentDisabled }]) }}"
bindtap="onClickLabel"
>
<slot />

33
dist/radio/index.wxs vendored Normal file
View File

@ -0,0 +1,33 @@
/* eslint-disable */
var style = require('../wxs/style.wxs');
var addUnit = require('../wxs/add-unit.wxs');
function iconStyle(data) {
var styles = {
'font-size': addUnit(data.iconSize),
};
if (
data.checkedColor &&
!(data.disabled || data.parentDisabled) &&
data.value === data.name
) {
styles['border-color'] = data.checkedColor;
styles['background-color'] = data.checkedColor;
}
return style(styles);
}
function iconCustomStyle(data) {
return style({
'line-height': addUnit(data.iconSize),
'font-size': '.8em',
display: 'block',
});
}
module.exports = {
iconStyle: iconStyle,
iconCustomStyle: iconCustomStyle,
};

2
dist/rate/index.js vendored
View File

@ -75,7 +75,7 @@ VantComponent({
const { clientX } = event.touches[0];
getAllRect(this, '.van-rate__icon').then((list) => {
const target = list
.sort((item) => item.right - item.left)
.sort((cur, next) => cur.dataset.score - next.dataset.score)
.find((item) => clientX >= item.left && clientX <= item.right);
if (target != null) {
this.onSelect(

46
dist/toast/toast.d.ts vendored
View File

@ -18,49 +18,17 @@ interface ToastOptions {
}
declare function Toast(
toastOptions: ToastOptions | ToastMessage
):
| WechatMiniprogram.Component.Instance<
Record<string, any>,
Record<string, any>,
Record<string, any>,
Record<string, any>,
false
>
| undefined;
): WechatMiniprogram.Component.TrivialInstance | undefined;
declare namespace Toast {
var loading: (
options: string | number | ToastOptions
) =>
| WechatMiniprogram.Component.Instance<
Record<string, any>,
Record<string, any>,
Record<string, any>,
Record<string, any>,
false
>
| undefined;
options: ToastMessage | ToastOptions
) => WechatMiniprogram.Component.TrivialInstance | undefined;
var success: (
options: string | number | ToastOptions
) =>
| WechatMiniprogram.Component.Instance<
Record<string, any>,
Record<string, any>,
Record<string, any>,
Record<string, any>,
false
>
| undefined;
options: ToastMessage | ToastOptions
) => WechatMiniprogram.Component.TrivialInstance | undefined;
var fail: (
options: string | number | ToastOptions
) =>
| WechatMiniprogram.Component.Instance<
Record<string, any>,
Record<string, any>,
Record<string, any>,
Record<string, any>,
false
>
| undefined;
options: ToastMessage | ToastOptions
) => WechatMiniprogram.Component.TrivialInstance | undefined;
var clear: () => void;
var setDefaultOptions: (options: ToastOptions) => void;
var resetDefaultOptions: () => void;

View File

@ -2,9 +2,8 @@
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],
mixins: [button_1.button],
props: {
show: Boolean,
title: String,
@ -41,13 +40,26 @@ component_1.VantComponent({
},
methods: {
onSelect: function (event) {
var _this = this;
var index = event.currentTarget.dataset.index;
var item = this.data.actions[index];
if (item && !item.disabled && !item.loading) {
var _a = this.data,
actions = _a.actions,
closeOnClickAction = _a.closeOnClickAction,
canIUseGetUserProfile = _a.canIUseGetUserProfile;
var item = actions[index];
if (item) {
this.$emit('select', item);
if (this.data.closeOnClickAction) {
if (closeOnClickAction) {
this.onClose();
}
if (item.openType === 'getUserInfo' && canIUseGetUserProfile) {
wx.getUserProfile({
desc: item.getUserProfileDesc || ' ',
complete: function (userProfile) {
_this.$emit('getuserinfo', userProfile);
},
});
}
}
},
onCancel: function () {

View File

@ -27,18 +27,18 @@
<button
wx:for="{{ actions }}"
wx:key="index"
open-type="{{ item.openType }}"
open-type="{{ item.disabled || item.loading || (canIUseGetUserProfile && item.openType === 'getUserInfo') ? '' : item.openType }}"
style="{{ item.color ? 'color: ' + item.color : '' }}"
class="{{ utils.bem('action-sheet__item', { disabled: item.disabled || item.loading }) }} {{ item.className || '' }}"
hover-class="van-action-sheet__item--hover"
data-index="{{ index }}"
bind:tap="onSelect"
bindgetuserinfo="bindGetUserInfo"
bindcontact="bindContact"
bindgetphonenumber="bindGetPhoneNumber"
binderror="bindError"
bindlaunchapp="bindLaunchApp"
bindopensetting="bindOpenSetting"
bindtap="{{ item.disabled || item.loading ? '' : 'onSelect' }}"
bindgetuserinfo="onGetUserInfo"
bindcontact="onContact"
bindgetphonenumber="onGetPhoneNumber"
binderror="onError"
bindlaunchapp="onLaunchApp"
bindopensetting="onOpenSetting"
lang="{{ lang }}"
session-from="{{ sessionFrom }}"
send-message-title="{{ sendMessageTitle }}"

View File

@ -96,18 +96,21 @@ component_1.VantComponent({
},
onChange: function (event) {
var _this = this;
var _a = event.detail,
index = _a.index,
picker = _a.picker,
value = _a.value;
var _a;
var _b = event.detail,
index = _b.index,
picker = _b.picker,
value = _b.value;
this.code = value[index].code;
this.setValues().then(function () {
_this.$emit('change', {
picker: picker,
values: _this.parseValues(picker.getValues()),
index: index,
});
});
(_a = this.setValues()) === null || _a === void 0
? void 0
: _a.then(function () {
_this.$emit('change', {
picker: picker,
values: _this.parseValues(picker.getValues()),
index: index,
});
});
},
getConfig: function (type) {
var areaList = this.data.areaList;

View File

@ -2,9 +2,8 @@
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');
var version_1 = require('../common/version');
var mixins = [button_1.button, open_type_1.openType];
var mixins = [button_1.button];
if (version_1.canIUseFormFieldButton()) {
mixins.push('wx://form-field-button');
}
@ -50,11 +49,21 @@ component_1.VantComponent({
color: String,
},
methods: {
onClick: function () {
if (!this.data.loading) {
this.$emit('click');
onClick: function (event) {
var _this = this;
this.$emit('click', event);
var _a = this.data,
canIUseGetUserProfile = _a.canIUseGetUserProfile,
openType = _a.openType,
getUserProfileDesc = _a.getUserProfileDesc;
if (openType === 'getUserInfo' && canIUseGetUserProfile) {
wx.getUserProfile({
desc: getUserProfileDesc || ' ',
complete: function (userProfile) {
_this.$emit('getuserinfo', userProfile);
},
});
}
},
noop: function () {},
},
});

View File

@ -9,7 +9,7 @@
lang="{{ lang }}"
form-type="{{ formType }}"
style="{{ computed.rootStyle({ plain, color, customStyle }) }}"
open-type="{{ disabled ? '' : openType }}"
open-type="{{ disabled || loading || (canIUseGetUserProfile && openType === 'getUserInfo') ? '' : openType }}"
business-id="{{ businessId }}"
session-from="{{ sessionFrom }}"
send-message-title="{{ sendMessageTitle }}"
@ -18,13 +18,13 @@
show-message-card="{{ showMessageCard }}"
app-parameter="{{ appParameter }}"
aria-label="{{ ariaLabel }}"
bindtap="{{ !disabled ? 'onClick' : 'noop' }}"
bindgetuserinfo="bindGetUserInfo"
bindcontact="bindContact"
bindgetphonenumber="bindGetPhoneNumber"
binderror="bindError"
bindlaunchapp="bindLaunchApp"
bindopensetting="bindOpenSetting"
bindtap="{{ disabled || loading ? '' : 'onClick' }}"
bindgetuserinfo="onGetUserInfo"
bindcontact="onContact"
bindgetphonenumber="onGetPhoneNumber"
binderror="onError"
bindlaunchapp="onLaunchApp"
bindopensetting="onOpenSetting"
>
<block wx:if="{{ loading }}">
<van-loading

View File

@ -4,6 +4,7 @@
showTitle="{{ showTitle }}"
subtitle="{{ subtitle }}"
showSubtitle="{{ showSubtitle }}"
firstDayOfWeek="{{ firstDayOfWeek }}"
>
<slot name="title" slot="title"></slot>
</header>
@ -31,6 +32,7 @@
showSubtitle="{{ showSubtitle }}"
allowSameDay="{{ allowSameDay }}"
showMonthTitle="{{ index !== 0 || !showSubtitle }}"
firstDayOfWeek="{{ firstDayOfWeek }}"
bind:click="onClickDay"
/>
</scroll-view>

View File

@ -1,4 +1,11 @@
'use strict';
var __spreadArray =
(this && this.__spreadArray) ||
function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};
Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../../../common/component');
component_1.VantComponent({
@ -10,9 +17,27 @@ component_1.VantComponent({
subtitle: String,
showTitle: Boolean,
showSubtitle: Boolean,
firstDayOfWeek: {
type: Number,
observer: 'initWeekDay',
},
},
data: {
weekdays: ['日', '一', '二', '三', '四', '五', '六'],
weekdays: [],
},
created: function () {
this.initWeekDay();
},
methods: {
initWeekDay: function () {
var defaultWeeks = ['日', '一', '二', '三', '四', '五', '六'];
var firstDayOfWeek = this.data.firstDayOfWeek || 0;
this.setData({
weekdays: __spreadArray(
__spreadArray([], defaultWeeks.slice(firstDayOfWeek, 7)),
defaultWeeks.slice(0, firstDayOfWeek)
),
});
},
},
methods: {},
});

View File

@ -31,6 +31,10 @@ component_1.VantComponent({
type: null,
observer: 'setDays',
},
firstDayOfWeek: {
type: Number,
observer: 'setDays',
},
allowSameDay: Boolean,
showSubtitle: Boolean,
showMonthTitle: Boolean,
@ -102,12 +106,12 @@ component_1.VantComponent({
currentDate = _a.currentDate,
allowSameDay = _a.allowSameDay;
if (!Array.isArray(currentDate)) {
return;
return '';
}
var startDay = currentDate[0],
endDay = currentDate[1];
if (!startDay) {
return;
return '';
}
var compareToStart = utils_1.compareDay(day, startDay);
if (!endDay) {
@ -126,6 +130,7 @@ component_1.VantComponent({
if (compareToStart > 0 && compareToEnd < 0) {
return 'middle';
}
return '';
},
getDayType: function (day) {
var _a = this.data,
@ -149,6 +154,7 @@ component_1.VantComponent({
if (type === 'range') {
return this.getRangeDayType(day);
}
return '';
},
getBottomInfo: function (type) {
if (this.data.type === 'range') {

View File

@ -14,7 +14,7 @@
<view
wx:for="{{ days }}"
wx:key="index"
style="{{ computed.getDayStyle(item.type, index, date, rowHeight, color) }}"
style="{{ computed.getDayStyle(item.type, index, date, rowHeight, color, firstDayOfWeek) }}"
class="{{ utils.bem('calendar__day', [item.type]) }} {{ item.className }}"
data-index="{{ index }}"
bindtap="onClick"

View File

@ -7,9 +7,12 @@ function getMark(date) {
var ROW_HEIGHT = 64;
function getDayStyle(type, index, date, rowHeight, color) {
function getDayStyle(type, index, date, rowHeight, color, firstDayOfWeek) {
var style = [];
var offset = getDate(date).getDay();
var current = getDate(date).getDay() || 7;
var offset = current < firstDayOfWeek ? (7 - firstDayOfWeek + current) :
current === 7 && firstDayOfWeek === 0 ? 0 :
(current - firstDayOfWeek);
if (index === 0) {
style.push(['margin-left', (100 * offset) / 7 + '%']);
@ -23,6 +26,7 @@ function getDayStyle(type, index, date, rowHeight, color) {
if (
type === 'start' ||
type === 'end' ||
type === 'start-end' ||
type === 'multiple-selected' ||
type === 'multiple-middle'
) {

View File

@ -1,13 +1,10 @@
'use strict';
var __spreadArrays =
(this && this.__spreadArrays) ||
function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
var __spreadArray =
(this && this.__spreadArray) ||
function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};
var __importDefault =
(this && this.__importDefault) ||
@ -41,6 +38,10 @@ component_1.VantComponent({
value: '确定',
},
rangePrompt: String,
showRangePrompt: {
type: Boolean,
value: true,
},
defaultDate: {
type: null,
observer: function (val) {
@ -111,6 +112,10 @@ component_1.VantComponent({
type: null,
value: null,
},
firstDayOfWeek: {
type: Number,
value: 0,
},
},
data: {
subtitle: '',
@ -249,7 +254,7 @@ component_1.VantComponent({
this.unselect(cancelDate);
} else {
// @ts-ignore
this.select(__spreadArrays(currentDate, [date]));
this.select(__spreadArray(__spreadArray([], currentDate), [date]));
}
} else {
this.select(date, true);
@ -294,16 +299,21 @@ component_1.VantComponent({
checkRange: function (date) {
var _a = this.data,
maxRange = _a.maxRange,
rangePrompt = _a.rangePrompt;
rangePrompt = _a.rangePrompt,
showRangePrompt = _a.showRangePrompt;
if (maxRange && utils_1.calcDateNum(date) > maxRange) {
toast_1.default({
context: this,
message:
rangePrompt ||
'\u9009\u62E9\u5929\u6570\u4E0D\u80FD\u8D85\u8FC7 ' +
maxRange +
' \u5929',
});
if (showRangePrompt) {
toast_1.default({
duration: 0,
context: this,
message:
rangePrompt ||
'\u9009\u62E9\u5929\u6570\u4E0D\u80FD\u8D85\u8FC7 ' +
maxRange +
' \u5929',
});
}
this.$emit('over-range');
return false;
}
return true;

View File

@ -20,6 +20,7 @@
style="{{ computed.titleStyle({ titleWidth, titleStyle }) }}"
class="van-cell__title title-class"
>
<block wx:if="{{ title }}">{{ title }}</block>
<slot wx:else name="title" />

View File

@ -180,10 +180,14 @@ component_1.VantComponent({
this.currentValue = this.currentValue || 0;
this.interval = setInterval(function () {
if (_this.currentValue !== value) {
if (_this.currentValue < value) {
_this.currentValue += STEP;
if (Math.abs(_this.currentValue - value) < STEP) {
_this.currentValue = value;
} else {
_this.currentValue -= STEP;
if (_this.currentValue < value) {
_this.currentValue += STEP;
} else {
_this.currentValue -= STEP;
}
}
_this.drawCircle(_this.currentValue);
} else {

View File

@ -1,6 +1,7 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
exports.isVideoUrl = exports.isImageUrl = exports.isBoolean = exports.isNumber = exports.isObj = exports.isDef = exports.isPromise = exports.isPlainObject = exports.isFunction = void 0;
// eslint-disable-next-line @typescript-eslint/ban-types
function isFunction(val) {
return typeof val === 'function';
}

View File

@ -1,6 +1,6 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
exports.canIUseCanvas2d = exports.canIUseNextTick = exports.canIUseGroupSetData = exports.canIUseAnimate = exports.canIUseFormFieldButton = exports.canIUseModel = void 0;
exports.canIUseGetUserProfile = exports.canIUseCanvas2d = exports.canIUseNextTick = exports.canIUseGroupSetData = exports.canIUseAnimate = exports.canIUseFormFieldButton = exports.canIUseModel = void 0;
var utils_1 = require('./utils');
function compareVersion(v1, v2) {
v1 = v1.split('.');
@ -52,3 +52,7 @@ function canIUseCanvas2d() {
return gte('2.9.0');
}
exports.canIUseCanvas2d = canIUseCanvas2d;
function canIUseGetUserProfile() {
return !!wx.getUserProfile;
}
exports.canIUseGetUserProfile = canIUseGetUserProfile;

View File

@ -14,15 +14,12 @@ var __assign =
};
return __assign.apply(this, arguments);
};
var __spreadArrays =
(this && this.__spreadArrays) ||
function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
var __spreadArray =
(this && this.__spreadArray) ||
function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};
Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component');
@ -143,7 +140,7 @@ component_1.VantComponent({
}
return setColumnValues_1.apply(
picker_1,
__spreadArrays(args, [false])
__spreadArray(__spreadArray([], args), [false])
);
};
}
@ -168,8 +165,7 @@ component_1.VantComponent({
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 type === 'year' ? '' + value : padZero(value);
});
if (filter) {
values = filter(type, values);

View File

@ -2,11 +2,10 @@
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');
var color_1 = require('../common/color');
var utils_1 = require('../common/utils');
component_1.VantComponent({
mixins: [button_1.button, open_type_1.openType],
mixins: [button_1.button],
props: {
show: {
type: Boolean,

View File

@ -58,12 +58,12 @@
app-parameter="{{ appParameter }}"
bind:click="onConfirm"
bindgetuserinfo="bindGetUserInfo"
bindcontact="bindContact"
bindgetphonenumber="bindGetPhoneNumber"
binderror="bindError"
bindlaunchapp="bindLaunchApp"
bindopensetting="bindOpenSetting"
bindgetuserinfo="onGetUserInfo"
bindcontact="onContact"
bindgetphonenumber="onGetPhoneNumber"
binderror="onError"
bindlaunchapp="onLaunchApp"
bindopensetting="onOpenSetting"
>
{{ confirmButtonText }}
</van-goods-action-button>
@ -100,12 +100,12 @@
app-parameter="{{ appParameter }}"
bind:click="onConfirm"
bindgetuserinfo="bindGetUserInfo"
bindcontact="bindContact"
bindgetphonenumber="bindGetPhoneNumber"
binderror="bindError"
bindlaunchapp="bindLaunchApp"
bindopensetting="bindOpenSetting"
bindgetuserinfo="onGetUserInfo"
bindcontact="onContact"
bindgetphonenumber="onGetPhoneNumber"
binderror="onError"
bindlaunchapp="onLaunchApp"
bindopensetting="onOpenSetting"
>
{{ confirmButtonText }}
</van-button>

View File

@ -4,9 +4,8 @@ var component_1 = require('../common/component');
var relation_1 = require('../common/relation');
var button_1 = require('../mixins/button');
var link_1 = require('../mixins/link');
var open_type_1 = require('../mixins/open-type');
component_1.VantComponent({
mixins: [link_1.link, button_1.button, open_type_1.openType],
mixins: [link_1.link, button_1.button],
relation: relation_1.useParent('goods-action'),
props: {
text: String,

View File

@ -18,12 +18,12 @@
show-message-card="{{ showMessageCard }}"
send-message-title="{{ sendMessageTitle }}"
bind:click="onClick"
binderror="bindError"
bindcontact="bindContact"
bindopensetting="bindOpenSetting"
bindgetuserinfo="bindGetUserInfo"
bindgetphonenumber="bindGetPhoneNumber"
bindlaunchapp="bindLaunchApp"
binderror="onError"
bindcontact="onContact"
bindopensetting="onOpenSetting"
bindgetuserinfo="onGetUserInfo"
bindgetphonenumber="onGetPhoneNumber"
bindlaunchapp="onLaunchApp"
>
{{ text }}
<slot></slot>

View File

@ -3,10 +3,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component');
var button_1 = require('../mixins/button');
var link_1 = require('../mixins/link');
var open_type_1 = require('../mixins/open-type');
component_1.VantComponent({
classes: ['icon-class', 'text-class'],
mixins: [link_1.link, button_1.button, open_type_1.openType],
mixins: [link_1.link, button_1.button],
props: {
text: String,
dot: Boolean,

View File

@ -15,12 +15,12 @@
show-message-card="{{ showMessageCard }}"
send-message-title="{{ sendMessageTitle }}"
bind:click="onClick"
binderror="bindError"
bindcontact="bindContact"
bindopensetting="bindOpenSetting"
bindgetuserinfo="bindGetUserInfo"
bindgetphonenumber="bindGetPhoneNumber"
bindlaunchapp="bindLaunchApp"
binderror="onError"
bindcontact="onContact"
bindopensetting="onOpenSetting"
bindgetuserinfo="onGetUserInfo"
bindgetphonenumber="onGetPhoneNumber"
bindlaunchapp="onLaunchApp"
>
<van-icon
wx:if="{{ icon }}"

File diff suppressed because one or more lines are too long

View File

@ -2,9 +2,8 @@
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],
mixins: [button_1.button],
classes: ['custom-class', 'loading-class', 'error-class', 'image-class'],
props: {
src: {

View File

@ -1,6 +1,7 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
exports.button = void 0;
var version_1 = require('../common/version');
exports.button = Behavior({
externalClasses: ['hover-class'],
properties: {
@ -14,5 +15,30 @@ exports.button = Behavior({
showMessageCard: Boolean,
appParameter: String,
ariaLabel: String,
openType: String,
getUserProfileDesc: String,
},
data: {
canIUseGetUserProfile: version_1.canIUseGetUserProfile(),
},
methods: {
onGetUserInfo: function (event) {
this.triggerEvent('getuserinfo', event.detail);
},
onContact: function (event) {
this.triggerEvent('contact', event.detail);
},
onGetPhoneNumber: function (event) {
this.triggerEvent('getphonenumber', event.detail);
},
onError: function (event) {
this.triggerEvent('error', event.detail);
},
onLaunchApp: function (event) {
this.triggerEvent('launchapp', event.detail);
},
onOpenSetting: function (event) {
this.triggerEvent('opensetting', event.detail);
},
},
});

View File

@ -1,29 +0,0 @@
'use strict';
// @ts-nocheck
Object.defineProperty(exports, '__esModule', { value: true });
exports.openType = void 0;
exports.openType = Behavior({
properties: {
openType: String,
},
methods: {
bindGetUserInfo: function (event) {
this.$emit('getuserinfo', event.detail);
},
bindContact: function (event) {
this.$emit('contact', event.detail);
},
bindGetPhoneNumber: function (event) {
this.$emit('getphonenumber', event.detail);
},
bindError: function (event) {
this.$emit('error', event.detail);
},
bindLaunchApp: function (event) {
this.$emit('launchapp', event.detail);
},
bindOpenSetting: function (event) {
this.$emit('opensetting', event.detail);
},
},
});

View File

@ -12,7 +12,7 @@ function onPageScroll(event) {
}
});
}
exports.pageScrollMixin = function (scroller) {
var pageScrollMixin = function (scroller) {
return Behavior({
attached: function () {
var page = utils_1.getCurrentPage();
@ -38,3 +38,4 @@ exports.pageScrollMixin = function (scroller) {
},
});
};
exports.pageScrollMixin = pageScrollMixin;

View File

@ -27,13 +27,10 @@ component_1.VantComponent({
},
speed: {
type: Number,
value: 50,
value: 60,
observer: 'init',
},
scrollable: {
type: Boolean,
value: true,
},
scrollable: null,
leftIcon: {
type: String,
value: '',
@ -68,20 +65,22 @@ component_1.VantComponent({
]).then(function (rects) {
var contentRect = rects[0],
wrapRect = rects[1];
if (
contentRect == null ||
wrapRect == null ||
!contentRect.width ||
!wrapRect.width
) {
return;
}
var _a = _this.data,
speed = _a.speed,
scrollable = _a.scrollable,
delay = _a.delay;
if (
contentRect == null ||
wrapRect == null ||
!contentRect.width ||
!wrapRect.width ||
scrollable === false
) {
return;
}
if (scrollable || wrapRect.width < contentRect.width) {
var duration = (contentRect.width / speed) * 1000;
var duration =
((wrapRect.width + contentRect.width) / speed) * 1000;
_this.wrapWidth = wrapRect.width;
_this.contentWidth = contentRect.width;
_this.duration = duration;

View File

@ -16,7 +16,7 @@
<slot wx:else name="left-icon" />
<view class="van-notice-bar__wrap">
<view class="van-notice-bar__content {{ !scrollable && !wrapable ? 'van-ellipsis' : '' }}" animation="{{ animationData }}">
<view class="van-notice-bar__content {{ scrollable === false && !wrapable ? 'van-ellipsis' : '' }}" animation="{{ animationData }}">
{{ text }}
<slot wx:if="{{ !text }}"></slot>
</view>

View File

@ -7,6 +7,5 @@ component_1.VantComponent({
desc: String,
title: String,
status: String,
useFooterSlot: Boolean,
},
});

View File

@ -1,5 +1,5 @@
<view class="van-panel van-hairline--top-bottom custom-class">
<van-cell
<van-cell
wx:if="{{ title || desc || status }}"
title="{{ title }}"
label="{{ desc }}"
@ -13,7 +13,7 @@
<slot />
</view>
<view wx:if="{{ useFooterSlot }}" class="van-panel__footer van-hairline--top footer-class">
<view class="van-panel__footer van-hairline--top footer-class">
<slot name="footer" />
</view>
</view>

View File

@ -1 +1 @@
@import '../common/index.wxss';.van-panel{background:#fff;background:var(--panel-background-color,#fff)}.van-panel__header-value{color:#ee0a24;color:var(--panel-header-value-color,#ee0a24)}.van-panel__footer{padding:8px 16px;padding:var(--panel-footer-padding,8px 16px)}
@import '../common/index.wxss';.van-panel{background:#fff;background:var(--panel-background-color,#fff)}.van-panel__header-value{color:#ee0a24;color:var(--panel-header-value-color,#ee0a24)}.van-panel__footer{padding:8px 16px;padding:var(--panel-footer-padding,8px 16px)}.van-panel__footer:empty{display:none}

View File

@ -9,7 +9,7 @@
bind:touchend="onTouchEnd"
bind:touchcancel="onTouchEnd"
>
<view style="{{ computed.wrapperStyle({ offset, itemHeight, visibleItemCount }) }}">
<view style="{{ computed.wrapperStyle({ offset, itemHeight, visibleItemCount, duration }) }}">
<view
wx:for="{{ options }}"
wx:for-item="option"

View File

@ -4,9 +4,7 @@ var component_1 = require('../common/component');
var relation_1 = require('../common/relation');
component_1.VantComponent({
field: true,
relation: relation_1.useChildren('radio', function (target) {
this.updateChild(target);
}),
relation: relation_1.useChildren('radio'),
props: {
value: {
type: null,
@ -20,20 +18,8 @@ component_1.VantComponent({
},
methods: {
updateChildren: function () {
var _this = this;
this.children.forEach(function (child) {
return _this.updateChild(child);
});
},
updateChild: function (child) {
var _a = this.data,
value = _a.value,
disabled = _a.disabled,
direction = _a.direction;
child.setData({
value: value,
direction: direction,
disabled: disabled || child.data.disabled,
return child.updateFromParent();
});
},
},

View File

@ -1,10 +1,13 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var version_1 = require('../common/version');
var component_1 = require('../common/component');
var relation_1 = require('../common/relation');
component_1.VantComponent({
field: true,
relation: relation_1.useParent('radio-group'),
relation: relation_1.useParent('radio-group', function () {
this.updateFromParent();
}),
classes: ['icon-class', 'label-class'],
props: {
name: null,
@ -26,23 +29,45 @@ component_1.VantComponent({
value: 20,
},
},
data: {
direction: '',
parentDisabled: false,
},
methods: {
updateFromParent: function () {
if (!this.parent) {
return;
}
var _a = this.parent.data,
value = _a.value,
parentDisabled = _a.disabled,
direction = _a.direction;
this.setData({
value: value,
direction: direction,
parentDisabled: parentDisabled,
});
},
emitChange: function (value) {
var instance = this.parent || this;
instance.$emit('input', value);
instance.$emit('change', value);
if (version_1.canIUseModel()) {
instance.setData({ value: value });
}
},
onChange: function () {
if (!this.data.disabled) {
if (!this.data.disabled && !this.data.parentDisabled) {
this.emitChange(this.data.name);
}
},
onClickLabel: function () {
var _a = this.data,
disabled = _a.disabled,
parentDisabled = _a.parentDisabled,
labelDisabled = _a.labelDisabled,
name = _a.name;
if (!disabled && !labelDisabled) {
if (!(disabled || parentDisabled) && !labelDisabled) {
this.emitChange(name);
}
},

View File

@ -1,27 +1,28 @@
<wxs src="../wxs/utils.wxs" module="utils" />
<wxs src="./index.wxs" module="computed" />
<view class="{{ utils.bem('radio', [direction]) }} custom-class">
<view
wx:if="{{ labelPosition === 'left' }}"
class="label-class {{ utils.bem('radio__label', [labelPosition, { disabled }]) }}"
class="{{ utils.bem('radio__label', [labelPosition, { disabled: disabled || parentDisabled }]) }} label-class"
bindtap="onClickLabel"
>
<slot />
</view>
<view class="van-radio__icon-wrap" style="font-size: {{ utils.addUnit(iconSize) }};" bindtap="onChange">
<view class="van-radio__icon-wrap" style="font-size: {{ utils.addUnit(iconSize) }}" bindtap="onChange">
<slot wx:if="{{ useIconSlot }}" name="icon" />
<van-icon
wx:else
name="success"
class="{{ utils.bem('radio__icon', [shape, { disabled, checked: value === name }]) }}"
style="font-size: {{ utils.addUnit(iconSize) }};{{ checkedColor && !disabled && value === name ? 'border-color:' + checkedColor + '; background-color:' + checkedColor + ';' : '' }}"
class="{{ utils.bem('radio__icon', [shape, { disabled: disabled || parentDisabled, checked: value === name }]) }}"
style="{{ computed.iconStyle({ iconSize, checkedColor, disabled, parentDisabled, value, name }) }}"
custom-class="icon-class"
custom-style="line-height: {{ utils.addUnit(iconSize) }};font-size: .8em;display: block;"
custom-style="{{ computed.iconCustomStyle({ iconSize }) }}"
/>
</view>
<view
wx:if="{{ labelPosition === 'right' }}"
class="label-class {{ utils.bem('radio__label', [labelPosition, { disabled }]) }}"
class="label-class {{ utils.bem('radio__label', [labelPosition, { disabled: disabled || parentDisabled }]) }}"
bindtap="onClickLabel"
>
<slot />

33
lib/radio/index.wxs Normal file
View File

@ -0,0 +1,33 @@
/* eslint-disable */
var style = require('../wxs/style.wxs');
var addUnit = require('../wxs/add-unit.wxs');
function iconStyle(data) {
var styles = {
'font-size': addUnit(data.iconSize),
};
if (
data.checkedColor &&
!(data.disabled || data.parentDisabled) &&
data.value === data.name
) {
styles['border-color'] = data.checkedColor;
styles['background-color'] = data.checkedColor;
}
return style(styles);
}
function iconCustomStyle(data) {
return style({
'line-height': addUnit(data.iconSize),
'font-size': '.8em',
display: 'block',
});
}
module.exports = {
iconStyle: iconStyle,
iconCustomStyle: iconCustomStyle,
};

View File

@ -94,8 +94,8 @@ component_1.VantComponent({
var clientX = event.touches[0].clientX;
utils_1.getAllRect(this, '.van-rate__icon').then(function (list) {
var target = list
.sort(function (item) {
return item.right - item.left;
.sort(function (cur, next) {
return cur.dataset.score - next.dataset.score;
})
.find(function (item) {
return clientX >= item.left && clientX <= item.right;

View File

@ -49,11 +49,12 @@ component_1.VantComponent({
methods: {
onScroll: function (_a) {
var _this = this;
var scrollTop = (_a === void 0 ? {} : _a).scrollTop;
var _b = this.data,
container = _b.container,
offsetTop = _b.offsetTop,
disabled = _b.disabled;
var _b = _a === void 0 ? {} : _a,
scrollTop = _b.scrollTop;
var _c = this.data,
container = _c.container,
offsetTop = _c.offsetTop,
disabled = _c.disabled;
if (disabled) {
this.setDataAfterDiff({
fixed: false,