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

View File

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

17
dist/area/index.js vendored
View File

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

17
dist/button/index.js vendored
View File

@ -1,8 +1,7 @@
import { VantComponent } from '../common/component'; import { VantComponent } from '../common/component';
import { button } from '../mixins/button'; import { button } from '../mixins/button';
import { openType } from '../mixins/open-type';
import { canIUseFormFieldButton } from '../common/version'; import { canIUseFormFieldButton } from '../common/version';
const mixins = [button, openType]; const mixins = [button];
if (canIUseFormFieldButton()) { if (canIUseFormFieldButton()) {
mixins.push('wx://form-field-button'); mixins.push('wx://form-field-button');
} }
@ -48,11 +47,17 @@ VantComponent({
color: String, color: String,
}, },
methods: { methods: {
onClick() { onClick(event) {
if (!this.data.loading) { this.$emit('click', event);
this.$emit('click'); 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 }}" lang="{{ lang }}"
form-type="{{ formType }}" form-type="{{ formType }}"
style="{{ computed.rootStyle({ plain, color, customStyle }) }}" style="{{ computed.rootStyle({ plain, color, customStyle }) }}"
open-type="{{ disabled ? '' : openType }}" open-type="{{ disabled || loading || (canIUseGetUserProfile && openType === 'getUserInfo') ? '' : openType }}"
business-id="{{ businessId }}" business-id="{{ businessId }}"
session-from="{{ sessionFrom }}" session-from="{{ sessionFrom }}"
send-message-title="{{ sendMessageTitle }}" send-message-title="{{ sendMessageTitle }}"
@ -18,13 +18,13 @@
show-message-card="{{ showMessageCard }}" show-message-card="{{ showMessageCard }}"
app-parameter="{{ appParameter }}" app-parameter="{{ appParameter }}"
aria-label="{{ ariaLabel }}" aria-label="{{ ariaLabel }}"
bindtap="{{ !disabled ? 'onClick' : 'noop' }}" bindtap="{{ disabled || loading ? '' : 'onClick' }}"
bindgetuserinfo="bindGetUserInfo" bindgetuserinfo="onGetUserInfo"
bindcontact="bindContact" bindcontact="onContact"
bindgetphonenumber="bindGetPhoneNumber" bindgetphonenumber="onGetPhoneNumber"
binderror="bindError" binderror="onError"
bindlaunchapp="bindLaunchApp" bindlaunchapp="onLaunchApp"
bindopensetting="bindOpenSetting" bindopensetting="onOpenSetting"
> >
<block wx:if="{{ loading }}"> <block wx:if="{{ loading }}">
<van-loading <van-loading

View File

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

View File

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

View File

@ -14,7 +14,7 @@
<view <view
wx:for="{{ days }}" wx:for="{{ days }}"
wx:key="index" 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 }}" class="{{ utils.bem('calendar__day', [item.type]) }} {{ item.className }}"
data-index="{{ index }}" data-index="{{ index }}"
bindtap="onClick" bindtap="onClick"

View File

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

View File

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

View File

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

View File

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

10
dist/circle/index.js vendored
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -15,12 +15,12 @@
show-message-card="{{ showMessageCard }}" show-message-card="{{ showMessageCard }}"
send-message-title="{{ sendMessageTitle }}" send-message-title="{{ sendMessageTitle }}"
bind:click="onClick" bind:click="onClick"
binderror="bindError" binderror="onError"
bindcontact="bindContact" bindcontact="onContact"
bindopensetting="bindOpenSetting" bindopensetting="onOpenSetting"
bindgetuserinfo="bindGetUserInfo" bindgetuserinfo="onGetUserInfo"
bindgetphonenumber="bindGetPhoneNumber" bindgetphonenumber="onGetPhoneNumber"
bindlaunchapp="bindLaunchApp" bindlaunchapp="onLaunchApp"
> >
<van-icon <van-icon
wx:if="{{ 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 { VantComponent } from '../common/component';
import { button } from '../mixins/button'; import { button } from '../mixins/button';
import { openType } from '../mixins/open-type';
VantComponent({ VantComponent({
mixins: [button, openType], mixins: [button],
classes: ['custom-class', 'loading-class', 'error-class', 'image-class'], classes: ['custom-class', 'loading-class', 'error-class', 'image-class'],
props: { props: {
src: { src: {

26
dist/mixins/button.js vendored
View File

@ -1,3 +1,4 @@
import { canIUseGetUserProfile } from '../common/version';
export const button = Behavior({ export const button = Behavior({
externalClasses: ['hover-class'], externalClasses: ['hover-class'],
properties: { properties: {
@ -11,5 +12,30 @@ export const button = Behavior({
showMessageCard: Boolean, showMessageCard: Boolean,
appParameter: String, appParameter: String,
ariaLabel: 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: { speed: {
type: Number, type: Number,
value: 50, value: 60,
observer: 'init', observer: 'init',
}, },
scrollable: { scrollable: null,
type: Boolean,
value: true,
},
leftIcon: { leftIcon: {
type: String, type: String,
value: '', value: '',
@ -64,17 +61,19 @@ VantComponent({
getRect(this, '.van-notice-bar__wrap'), getRect(this, '.van-notice-bar__wrap'),
]).then((rects) => { ]).then((rects) => {
const [contentRect, wrapRect] = rects; const [contentRect, wrapRect] = rects;
const { speed, scrollable, delay } = this.data;
if ( if (
contentRect == null || contentRect == null ||
wrapRect == null || wrapRect == null ||
!contentRect.width || !contentRect.width ||
!wrapRect.width !wrapRect.width ||
scrollable === false
) { ) {
return; return;
} }
const { speed, scrollable, delay } = this.data;
if (scrollable || wrapRect.width < contentRect.width) { 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.wrapWidth = wrapRect.width;
this.contentWidth = contentRect.width; this.contentWidth = contentRect.width;
this.duration = duration; this.duration = duration;

View File

@ -16,7 +16,7 @@
<slot wx:else name="left-icon" /> <slot wx:else name="left-icon" />
<view class="van-notice-bar__wrap"> <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 }} {{ text }}
<slot wx:if="{{ !text }}"></slot> <slot wx:if="{{ !text }}"></slot>
</view> </view>

1
dist/panel/index.js vendored
View File

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

View File

@ -13,7 +13,7 @@
<slot /> <slot />
</view> </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" /> <slot name="footer" />
</view> </view>
</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:touchend="onTouchEnd"
bind:touchcancel="onTouchEnd" bind:touchcancel="onTouchEnd"
> >
<view style="{{ computed.wrapperStyle({ offset, itemHeight, visibleItemCount }) }}"> <view style="{{ computed.wrapperStyle({ offset, itemHeight, visibleItemCount, duration }) }}">
<view <view
wx:for="{{ options }}" wx:for="{{ options }}"
wx:for-item="option" wx:for-item="option"

View File

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

29
dist/radio/index.js vendored
View File

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

13
dist/radio/index.wxml vendored
View File

@ -1,27 +1,28 @@
<wxs src="../wxs/utils.wxs" module="utils" /> <wxs src="../wxs/utils.wxs" module="utils" />
<wxs src="./index.wxs" module="computed" />
<view class="{{ utils.bem('radio', [direction]) }} custom-class"> <view class="{{ utils.bem('radio', [direction]) }} custom-class">
<view <view
wx:if="{{ labelPosition === 'left' }}" 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" bindtap="onClickLabel"
> >
<slot /> <slot />
</view> </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" /> <slot wx:if="{{ useIconSlot }}" name="icon" />
<van-icon <van-icon
wx:else wx:else
name="success" name="success"
class="{{ utils.bem('radio__icon', [shape, { disabled, checked: value === name }]) }}" class="{{ utils.bem('radio__icon', [shape, { disabled: disabled || parentDisabled, checked: value === name }]) }}"
style="font-size: {{ utils.addUnit(iconSize) }};{{ checkedColor && !disabled && value === name ? 'border-color:' + checkedColor + '; background-color:' + checkedColor + ';' : '' }}" style="{{ computed.iconStyle({ iconSize, checkedColor, disabled, parentDisabled, value, name }) }}"
custom-class="icon-class" custom-class="icon-class"
custom-style="line-height: {{ utils.addUnit(iconSize) }};font-size: .8em;display: block;" custom-style="{{ computed.iconCustomStyle({ iconSize }) }}"
/> />
</view> </view>
<view <view
wx:if="{{ labelPosition === 'right' }}" 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" bindtap="onClickLabel"
> >
<slot /> <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]; const { clientX } = event.touches[0];
getAllRect(this, '.van-rate__icon').then((list) => { getAllRect(this, '.van-rate__icon').then((list) => {
const target = 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); .find((item) => clientX >= item.left && clientX <= item.right);
if (target != null) { if (target != null) {
this.onSelect( this.onSelect(

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

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

View File

@ -2,9 +2,8 @@
Object.defineProperty(exports, '__esModule', { value: true }); Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component'); var component_1 = require('../common/component');
var button_1 = require('../mixins/button'); var button_1 = require('../mixins/button');
var open_type_1 = require('../mixins/open-type');
component_1.VantComponent({ component_1.VantComponent({
mixins: [button_1.button, open_type_1.openType], mixins: [button_1.button],
props: { props: {
show: Boolean, show: Boolean,
title: String, title: String,
@ -41,13 +40,26 @@ component_1.VantComponent({
}, },
methods: { methods: {
onSelect: function (event) { onSelect: function (event) {
var _this = this;
var index = event.currentTarget.dataset.index; var index = event.currentTarget.dataset.index;
var item = this.data.actions[index]; var _a = this.data,
if (item && !item.disabled && !item.loading) { actions = _a.actions,
closeOnClickAction = _a.closeOnClickAction,
canIUseGetUserProfile = _a.canIUseGetUserProfile;
var item = actions[index];
if (item) {
this.$emit('select', item); this.$emit('select', item);
if (this.data.closeOnClickAction) { if (closeOnClickAction) {
this.onClose(); this.onClose();
} }
if (item.openType === 'getUserInfo' && canIUseGetUserProfile) {
wx.getUserProfile({
desc: item.getUserProfileDesc || ' ',
complete: function (userProfile) {
_this.$emit('getuserinfo', userProfile);
},
});
}
} }
}, },
onCancel: function () { onCancel: function () {

View File

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

View File

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

View File

@ -2,9 +2,8 @@
Object.defineProperty(exports, '__esModule', { value: true }); Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component'); var component_1 = require('../common/component');
var button_1 = require('../mixins/button'); var button_1 = require('../mixins/button');
var open_type_1 = require('../mixins/open-type');
var version_1 = require('../common/version'); var version_1 = require('../common/version');
var mixins = [button_1.button, open_type_1.openType]; var mixins = [button_1.button];
if (version_1.canIUseFormFieldButton()) { if (version_1.canIUseFormFieldButton()) {
mixins.push('wx://form-field-button'); mixins.push('wx://form-field-button');
} }
@ -50,11 +49,21 @@ component_1.VantComponent({
color: String, color: String,
}, },
methods: { methods: {
onClick: function () { onClick: function (event) {
if (!this.data.loading) { var _this = this;
this.$emit('click'); 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 }}" lang="{{ lang }}"
form-type="{{ formType }}" form-type="{{ formType }}"
style="{{ computed.rootStyle({ plain, color, customStyle }) }}" style="{{ computed.rootStyle({ plain, color, customStyle }) }}"
open-type="{{ disabled ? '' : openType }}" open-type="{{ disabled || loading || (canIUseGetUserProfile && openType === 'getUserInfo') ? '' : openType }}"
business-id="{{ businessId }}" business-id="{{ businessId }}"
session-from="{{ sessionFrom }}" session-from="{{ sessionFrom }}"
send-message-title="{{ sendMessageTitle }}" send-message-title="{{ sendMessageTitle }}"
@ -18,13 +18,13 @@
show-message-card="{{ showMessageCard }}" show-message-card="{{ showMessageCard }}"
app-parameter="{{ appParameter }}" app-parameter="{{ appParameter }}"
aria-label="{{ ariaLabel }}" aria-label="{{ ariaLabel }}"
bindtap="{{ !disabled ? 'onClick' : 'noop' }}" bindtap="{{ disabled || loading ? '' : 'onClick' }}"
bindgetuserinfo="bindGetUserInfo" bindgetuserinfo="onGetUserInfo"
bindcontact="bindContact" bindcontact="onContact"
bindgetphonenumber="bindGetPhoneNumber" bindgetphonenumber="onGetPhoneNumber"
binderror="bindError" binderror="onError"
bindlaunchapp="bindLaunchApp" bindlaunchapp="onLaunchApp"
bindopensetting="bindOpenSetting" bindopensetting="onOpenSetting"
> >
<block wx:if="{{ loading }}"> <block wx:if="{{ loading }}">
<van-loading <van-loading

View File

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

View File

@ -1,4 +1,11 @@
'use strict'; '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 }); Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../../../common/component'); var component_1 = require('../../../common/component');
component_1.VantComponent({ component_1.VantComponent({
@ -10,9 +17,27 @@ component_1.VantComponent({
subtitle: String, subtitle: String,
showTitle: Boolean, showTitle: Boolean,
showSubtitle: Boolean, showSubtitle: Boolean,
firstDayOfWeek: {
type: Number,
observer: 'initWeekDay',
},
}, },
data: { 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, type: null,
observer: 'setDays', observer: 'setDays',
}, },
firstDayOfWeek: {
type: Number,
observer: 'setDays',
},
allowSameDay: Boolean, allowSameDay: Boolean,
showSubtitle: Boolean, showSubtitle: Boolean,
showMonthTitle: Boolean, showMonthTitle: Boolean,
@ -102,12 +106,12 @@ component_1.VantComponent({
currentDate = _a.currentDate, currentDate = _a.currentDate,
allowSameDay = _a.allowSameDay; allowSameDay = _a.allowSameDay;
if (!Array.isArray(currentDate)) { if (!Array.isArray(currentDate)) {
return; return '';
} }
var startDay = currentDate[0], var startDay = currentDate[0],
endDay = currentDate[1]; endDay = currentDate[1];
if (!startDay) { if (!startDay) {
return; return '';
} }
var compareToStart = utils_1.compareDay(day, startDay); var compareToStart = utils_1.compareDay(day, startDay);
if (!endDay) { if (!endDay) {
@ -126,6 +130,7 @@ component_1.VantComponent({
if (compareToStart > 0 && compareToEnd < 0) { if (compareToStart > 0 && compareToEnd < 0) {
return 'middle'; return 'middle';
} }
return '';
}, },
getDayType: function (day) { getDayType: function (day) {
var _a = this.data, var _a = this.data,
@ -149,6 +154,7 @@ component_1.VantComponent({
if (type === 'range') { if (type === 'range') {
return this.getRangeDayType(day); return this.getRangeDayType(day);
} }
return '';
}, },
getBottomInfo: function (type) { getBottomInfo: function (type) {
if (this.data.type === 'range') { if (this.data.type === 'range') {

View File

@ -14,7 +14,7 @@
<view <view
wx:for="{{ days }}" wx:for="{{ days }}"
wx:key="index" 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 }}" class="{{ utils.bem('calendar__day', [item.type]) }} {{ item.className }}"
data-index="{{ index }}" data-index="{{ index }}"
bindtap="onClick" bindtap="onClick"

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,7 @@
'use strict'; 'use strict';
Object.defineProperty(exports, '__esModule', { value: true }); 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; 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) { function isFunction(val) {
return typeof val === 'function'; return typeof val === 'function';
} }

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
Object.defineProperty(exports, '__esModule', { value: true }); 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'); var utils_1 = require('./utils');
function compareVersion(v1, v2) { function compareVersion(v1, v2) {
v1 = v1.split('.'); v1 = v1.split('.');
@ -52,3 +52,7 @@ function canIUseCanvas2d() {
return gte('2.9.0'); return gte('2.9.0');
} }
exports.canIUseCanvas2d = canIUseCanvas2d; exports.canIUseCanvas2d = canIUseCanvas2d;
function canIUseGetUserProfile() {
return !!wx.getUserProfile;
}
exports.canIUseGetUserProfile = canIUseGetUserProfile;

View File

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

View File

@ -2,11 +2,10 @@
Object.defineProperty(exports, '__esModule', { value: true }); Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component'); var component_1 = require('../common/component');
var button_1 = require('../mixins/button'); var button_1 = require('../mixins/button');
var open_type_1 = require('../mixins/open-type');
var color_1 = require('../common/color'); var color_1 = require('../common/color');
var utils_1 = require('../common/utils'); var utils_1 = require('../common/utils');
component_1.VantComponent({ component_1.VantComponent({
mixins: [button_1.button, open_type_1.openType], mixins: [button_1.button],
props: { props: {
show: { show: {
type: Boolean, type: Boolean,

View File

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

View File

@ -4,9 +4,8 @@ var component_1 = require('../common/component');
var relation_1 = require('../common/relation'); var relation_1 = require('../common/relation');
var button_1 = require('../mixins/button'); var button_1 = require('../mixins/button');
var link_1 = require('../mixins/link'); var link_1 = require('../mixins/link');
var open_type_1 = require('../mixins/open-type');
component_1.VantComponent({ 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'), relation: relation_1.useParent('goods-action'),
props: { props: {
text: String, text: String,

View File

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

View File

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

View File

@ -15,12 +15,12 @@
show-message-card="{{ showMessageCard }}" show-message-card="{{ showMessageCard }}"
send-message-title="{{ sendMessageTitle }}" send-message-title="{{ sendMessageTitle }}"
bind:click="onClick" bind:click="onClick"
binderror="bindError" binderror="onError"
bindcontact="bindContact" bindcontact="onContact"
bindopensetting="bindOpenSetting" bindopensetting="onOpenSetting"
bindgetuserinfo="bindGetUserInfo" bindgetuserinfo="onGetUserInfo"
bindgetphonenumber="bindGetPhoneNumber" bindgetphonenumber="onGetPhoneNumber"
bindlaunchapp="bindLaunchApp" bindlaunchapp="onLaunchApp"
> >
<van-icon <van-icon
wx:if="{{ 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 }); Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component'); var component_1 = require('../common/component');
var button_1 = require('../mixins/button'); var button_1 = require('../mixins/button');
var open_type_1 = require('../mixins/open-type');
component_1.VantComponent({ component_1.VantComponent({
mixins: [button_1.button, open_type_1.openType], mixins: [button_1.button],
classes: ['custom-class', 'loading-class', 'error-class', 'image-class'], classes: ['custom-class', 'loading-class', 'error-class', 'image-class'],
props: { props: {
src: { src: {

View File

@ -1,6 +1,7 @@
'use strict'; 'use strict';
Object.defineProperty(exports, '__esModule', { value: true }); Object.defineProperty(exports, '__esModule', { value: true });
exports.button = void 0; exports.button = void 0;
var version_1 = require('../common/version');
exports.button = Behavior({ exports.button = Behavior({
externalClasses: ['hover-class'], externalClasses: ['hover-class'],
properties: { properties: {
@ -14,5 +15,30 @@ exports.button = Behavior({
showMessageCard: Boolean, showMessageCard: Boolean,
appParameter: String, appParameter: String,
ariaLabel: 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({ return Behavior({
attached: function () { attached: function () {
var page = utils_1.getCurrentPage(); 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: { speed: {
type: Number, type: Number,
value: 50, value: 60,
observer: 'init', observer: 'init',
}, },
scrollable: { scrollable: null,
type: Boolean,
value: true,
},
leftIcon: { leftIcon: {
type: String, type: String,
value: '', value: '',
@ -68,20 +65,22 @@ component_1.VantComponent({
]).then(function (rects) { ]).then(function (rects) {
var contentRect = rects[0], var contentRect = rects[0],
wrapRect = rects[1]; wrapRect = rects[1];
if (
contentRect == null ||
wrapRect == null ||
!contentRect.width ||
!wrapRect.width
) {
return;
}
var _a = _this.data, var _a = _this.data,
speed = _a.speed, speed = _a.speed,
scrollable = _a.scrollable, scrollable = _a.scrollable,
delay = _a.delay; delay = _a.delay;
if (
contentRect == null ||
wrapRect == null ||
!contentRect.width ||
!wrapRect.width ||
scrollable === false
) {
return;
}
if (scrollable || wrapRect.width < contentRect.width) { 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.wrapWidth = wrapRect.width;
_this.contentWidth = contentRect.width; _this.contentWidth = contentRect.width;
_this.duration = duration; _this.duration = duration;

View File

@ -16,7 +16,7 @@
<slot wx:else name="left-icon" /> <slot wx:else name="left-icon" />
<view class="van-notice-bar__wrap"> <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 }} {{ text }}
<slot wx:if="{{ !text }}"></slot> <slot wx:if="{{ !text }}"></slot>
</view> </view>

View File

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

View File

@ -13,7 +13,7 @@
<slot /> <slot />
</view> </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" /> <slot name="footer" />
</view> </view>
</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:touchend="onTouchEnd"
bind:touchcancel="onTouchEnd" bind:touchcancel="onTouchEnd"
> >
<view style="{{ computed.wrapperStyle({ offset, itemHeight, visibleItemCount }) }}"> <view style="{{ computed.wrapperStyle({ offset, itemHeight, visibleItemCount, duration }) }}">
<view <view
wx:for="{{ options }}" wx:for="{{ options }}"
wx:for-item="option" wx:for-item="option"

View File

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

View File

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

View File

@ -1,27 +1,28 @@
<wxs src="../wxs/utils.wxs" module="utils" /> <wxs src="../wxs/utils.wxs" module="utils" />
<wxs src="./index.wxs" module="computed" />
<view class="{{ utils.bem('radio', [direction]) }} custom-class"> <view class="{{ utils.bem('radio', [direction]) }} custom-class">
<view <view
wx:if="{{ labelPosition === 'left' }}" 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" bindtap="onClickLabel"
> >
<slot /> <slot />
</view> </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" /> <slot wx:if="{{ useIconSlot }}" name="icon" />
<van-icon <van-icon
wx:else wx:else
name="success" name="success"
class="{{ utils.bem('radio__icon', [shape, { disabled, checked: value === name }]) }}" class="{{ utils.bem('radio__icon', [shape, { disabled: disabled || parentDisabled, checked: value === name }]) }}"
style="font-size: {{ utils.addUnit(iconSize) }};{{ checkedColor && !disabled && value === name ? 'border-color:' + checkedColor + '; background-color:' + checkedColor + ';' : '' }}" style="{{ computed.iconStyle({ iconSize, checkedColor, disabled, parentDisabled, value, name }) }}"
custom-class="icon-class" custom-class="icon-class"
custom-style="line-height: {{ utils.addUnit(iconSize) }};font-size: .8em;display: block;" custom-style="{{ computed.iconCustomStyle({ iconSize }) }}"
/> />
</view> </view>
<view <view
wx:if="{{ labelPosition === 'right' }}" 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" bindtap="onClickLabel"
> >
<slot /> <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; var clientX = event.touches[0].clientX;
utils_1.getAllRect(this, '.van-rate__icon').then(function (list) { utils_1.getAllRect(this, '.van-rate__icon').then(function (list) {
var target = list var target = list
.sort(function (item) { .sort(function (cur, next) {
return item.right - item.left; return cur.dataset.score - next.dataset.score;
}) })
.find(function (item) { .find(function (item) {
return clientX >= item.left && clientX <= item.right; return clientX >= item.left && clientX <= item.right;

View File

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