build: compile 1.8.7

This commit is contained in:
chenjiahan 2021-09-22 16:28:37 +08:00
parent 8ffa83ae53
commit cfe9eb25a4
202 changed files with 12224 additions and 13304 deletions

48
dist/area/index.js vendored
View File

@ -4,24 +4,20 @@ import { requestAnimationFrame } from '../common/utils';
const EMPTY_CODE = '000000';
VantComponent({
classes: ['active-class', 'toolbar-class', 'column-class'],
props: Object.assign(Object.assign({}, pickerProps), {
value: {
props: Object.assign(Object.assign({}, pickerProps), { value: {
type: String,
observer(value) {
this.code = value;
this.setValues();
},
},
areaList: {
}, areaList: {
type: Object,
value: {},
observer: 'setValues',
},
columnsNum: {
}, columnsNum: {
type: null,
value: 3,
},
columnsPlaceholder: {
}, columnsPlaceholder: {
type: Array,
observer(val) {
this.setData({
@ -32,8 +28,7 @@ VantComponent({
},
});
},
},
}),
} }),
data: {
columns: [{ values: [] }, { values: [] }, { values: [] }],
typeToColumnsPlaceholder: {},
@ -67,14 +62,9 @@ VantComponent({
parseValues(values) {
const { columnsPlaceholder } = this.data;
return values.map((value, index) => {
if (
value &&
(!value.code || value.name === columnsPlaceholder[index])
) {
return Object.assign(Object.assign({}, value), {
code: '',
name: '',
});
if (value &&
(!value.code || value.name === columnsPlaceholder[index])) {
return Object.assign(Object.assign({}, value), { code: '', name: '' });
}
return value;
});
@ -83,9 +73,7 @@ VantComponent({
var _a;
const { index, picker, value } = event.detail;
this.code = value[index].code;
(_a = this.setValues()) === null || _a === void 0
? void 0
: _a.then(() => {
(_a = this.setValues()) === null || _a === void 0 ? void 0 : _a.then(() => {
this.$emit('change', {
picker,
values: this.parseValues(picker.getValues()),
@ -116,8 +104,7 @@ VantComponent({
}
if (typeToColumnsPlaceholder[type] && result.length) {
// set columns placeholder
const codeFill =
type === 'province'
const codeFill = type === 'province'
? ''
: type === 'city'
? EMPTY_CODE.slice(2, 4)
@ -167,19 +154,13 @@ VantComponent({
}
}
if (columnsNum === 3) {
stack.push(
picker.setColumnValues(
2,
this.getList('county', code.slice(0, 4)),
false
)
);
stack.push(picker.setColumnValues(2, this.getList('county', code.slice(0, 4)), false));
indexes.push(this.getIndex('county', code));
}
return Promise.all(stack)
.catch(() => {})
.catch(() => { })
.then(() => picker.setIndexes(indexes))
.catch(() => {});
.catch(() => { });
},
getDefaultCode() {
const { columnsPlaceholder } = this.data;
@ -220,7 +201,8 @@ VantComponent({
if (area.code[0] === '9') {
area.country = names[1] || '';
area.province = names[2] || '';
} else {
}
else {
area.province = names[0] || '';
area.city = names[1] || '';
area.county = names[2] || '';

View File

@ -49,12 +49,7 @@ VantComponent({
methods: {
onClick(event) {
this.$emit('click', event);
const {
canIUseGetUserProfile,
openType,
getUserProfileDesc,
lang,
} = this.data;
const { canIUseGetUserProfile, openType, getUserProfileDesc, lang, } = this.data;
if (openType === 'getUserInfo' && canIUseGetUserProfile) {
wx.getUserProfile({
desc: getUserProfileDesc || ' ',

View File

@ -1,10 +1,5 @@
import { VantComponent } from '../../../common/component';
import {
getMonthEndDay,
compareDay,
getPrevDay,
getNextDay,
} from '../../utils';
import { getMonthEndDay, compareDay, getPrevDay, getNextDay, } from '../../utils';
VantComponent({
props: {
date: {
@ -59,10 +54,7 @@ VantComponent({
const startDate = new Date(this.data.date);
const year = startDate.getFullYear();
const month = startDate.getMonth();
const totalDay = getMonthEndDay(
startDate.getFullYear(),
startDate.getMonth() + 1
);
const totalDay = getMonthEndDay(startDate.getFullYear(), startDate.getMonth() + 1);
for (let day = 1; day <= totalDay; day++) {
const date = new Date(year, month, day);
const type = this.getDayType(date);
@ -84,8 +76,7 @@ VantComponent({
if (!Array.isArray(currentDate)) {
return '';
}
const isSelected = (date) =>
currentDate.some((item) => compareDay(item, date) === 0);
const isSelected = (date) => currentDate.some((item) => compareDay(item, date) === 0);
if (isSelected(day)) {
const prevDay = getPrevDay(day);
const nextDay = getNextDay(day);

View File

@ -1,27 +1,11 @@
import { VantComponent } from '../common/component';
import {
ROW_HEIGHT,
getPrevDay,
getNextDay,
getToday,
compareDay,
copyDates,
calcDateNum,
formatMonthTitle,
compareMonth,
getMonths,
getDayByOffset,
} from './utils';
import { ROW_HEIGHT, getPrevDay, getNextDay, getToday, compareDay, copyDates, calcDateNum, formatMonthTitle, compareMonth, getMonths, getDayByOffset, } from './utils';
import Toast from '../toast/toast';
import { requestAnimationFrame } from '../common/utils';
const initialMinDate = getToday().getTime();
const initialMaxDate = (() => {
const now = getToday();
return new Date(
now.getFullYear(),
now.getMonth() + 6,
now.getDate()
).getTime();
return new Date(now.getFullYear(), now.getMonth() + 6, now.getDate()).getTime();
})();
VantComponent({
props: {
@ -180,15 +164,8 @@ VantComponent({
defaultDate = [];
}
const [startDay, endDay] = defaultDate || [];
const start = this.limitDateRange(
startDay || now,
minDate,
getPrevDay(new Date(maxDate)).getTime()
);
const end = this.limitDateRange(
endDay || now,
getNextDay(new Date(minDate)).getTime()
);
const start = this.limitDateRange(startDay || now, minDate, getPrevDay(new Date(maxDate)).getTime());
const end = this.limitDateRange(endDay || now, getNextDay(new Date(minDate)).getTime());
return [start, end];
}
if (type === 'multiple') {
@ -204,14 +181,7 @@ VantComponent({
},
scrollIntoView() {
requestAnimationFrame(() => {
const {
currentDate,
type,
show,
poppable,
minDate,
maxDate,
} = this.data;
const { currentDate, type, show, poppable, minDate, maxDate, } = this.data;
// @ts-ignore
const targetDate = type === 'single' ? currentDate : currentDate[0];
const displayed = show || !poppable;
@ -250,15 +220,19 @@ VantComponent({
const compareToStart = compareDay(date, startDay);
if (compareToStart === 1) {
this.select([startDay, date], true);
} else if (compareToStart === -1) {
}
else if (compareToStart === -1) {
this.select([date, null]);
} else if (allowSameDay) {
}
else if (allowSameDay) {
this.select([date, date]);
}
} else {
}
else {
this.select([date, null]);
}
} else if (type === 'multiple') {
}
else if (type === 'multiple') {
let selectedIndex;
// @ts-ignore
const selected = currentDate.some((dateItem, index) => {
@ -273,11 +247,13 @@ VantComponent({
const cancelDate = currentDate.splice(selectedIndex, 1);
this.setData({ currentDate });
this.unselect(cancelDate);
} else {
}
else {
// @ts-ignore
this.select([...currentDate, date]);
}
} else {
}
else {
this.select(date, true);
}
},
@ -297,7 +273,8 @@ VantComponent({
date[0],
getDayByOffset(date[0], this.data.maxRange - 1),
]);
} else {
}
else {
this.emit(date);
}
return;
@ -309,7 +286,7 @@ VantComponent({
}
},
emit(date) {
const getTime = (date) => (date instanceof Date ? date.getTime() : date);
const getTime = (date) => date instanceof Date ? date.getTime() : date;
this.setData({
currentDate: Array.isArray(date) ? date.map(getTime) : getTime(date),
});
@ -330,10 +307,8 @@ VantComponent({
return true;
},
onConfirm() {
if (
this.data.type === 'range' &&
!this.checkRange(this.data.currentDate)
) {
if (this.data.type === 'range' &&
!this.checkRange(this.data.currentDate)) {
return;
}
wx.nextTick(() => {

View File

@ -1,13 +1,7 @@
export declare const ROW_HEIGHT = 64;
export declare function formatMonthTitle(date: Date): string;
export declare function compareMonth(
date1: Date | number,
date2: Date | number
): 1 | -1 | 0;
export declare function compareDay(
day1: Date | number,
day2: Date | number
): 1 | -1 | 0;
export declare function compareMonth(date1: Date | number, date2: Date | number): 1 | -1 | 0;
export declare function compareDay(day1: Date | number, day2: Date | number): 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

@ -35,7 +35,8 @@ VantComponent({
emitChange(value) {
if (this.parent) {
this.setParentValue(this.parent, value);
} else {
}
else {
emit(this, value);
}
},
@ -63,7 +64,8 @@ VantComponent({
parentValue.push(name);
emit(parent, parentValue);
}
} else {
}
else {
const index = parentValue.indexOf(name);
if (index !== -1) {
parentValue.splice(index, 1);

View File

@ -1,6 +1,4 @@
/// <reference types="miniprogram-api-typings" />
declare type CanvasContext = WechatMiniprogram.CanvasContext;
export declare function adaptor(
ctx: CanvasContext & Record<string, unknown>
): CanvasContext;
export declare function adaptor(ctx: CanvasContext & Record<string, unknown>): CanvasContext;
export {};

View File

@ -37,7 +37,7 @@ export function adaptor(ctx) {
setTextBaseline(val) {
ctx.textBaseline = val;
},
createCircularGradient() {},
draw() {},
createCircularGradient() { },
draw() { },
});
}

13
dist/circle/index.js vendored
View File

@ -96,9 +96,7 @@ VantComponent({
const LinearColor = context.createLinearGradient(size, 0, 0, 0);
Object.keys(color)
.sort((a, b) => parseFloat(a) - parseFloat(b))
.map((key) =>
LinearColor.addColorStop(parseFloat(key) / 100, color[key])
);
.map((key) => LinearColor.addColorStop(parseFloat(key) / 100, color[key]));
this.hoverColor = LinearColor;
});
}
@ -159,14 +157,17 @@ VantComponent({
if (this.currentValue !== value) {
if (Math.abs(this.currentValue - value) < STEP) {
this.currentValue = value;
} else if (this.currentValue < value) {
}
else if (this.currentValue < value) {
this.currentValue += STEP;
} else {
}
else {
this.currentValue -= STEP;
}
this.drawCircle(this.currentValue);
run();
} else {
}
else {
this.clearMockInterval();
}
}, 1000 / speed);

View File

@ -1,6 +1,2 @@
/// <reference types="miniprogram-api-typings" />
export declare function setContentAnimate(
context: WechatMiniprogram.Component.TrivialInstance,
expanded: boolean,
mounted: boolean
): void;
export declare function setContentAnimate(context: WechatMiniprogram.Component.TrivialInstance, expanded: boolean, mounted: boolean): void;

View File

@ -3,31 +3,21 @@ import { getRect } from '../common/utils';
function useAnimate(context, expanded, mounted, height) {
const selector = '.van-collapse-item__wrapper';
if (expanded) {
context.animate(
selector,
[
context.animate(selector, [
{ height: 0, ease: 'ease-in-out', offset: 0 },
{ height: `${height}px`, ease: 'ease-in-out', offset: 1 },
{ height: `auto`, ease: 'ease-in-out', offset: 1 },
],
mounted ? 300 : 0,
() => {
], mounted ? 300 : 0, () => {
context.clearAnimation(selector);
}
);
});
return;
}
context.animate(
selector,
[
context.animate(selector, [
{ height: `${height}px`, ease: 'ease-in-out', offset: 0 },
{ height: 0, ease: 'ease-in-out', offset: 1 },
],
300,
() => {
], 300, () => {
context.clearAnimation(selector);
}
);
});
}
function useAnimation(context, expanded, mounted, height) {
const animation = wx.createAnimation({
@ -37,7 +27,8 @@ function useAnimation(context, expanded, mounted, height) {
if (expanded) {
if (height === 0) {
animation.height('auto').top(1).step();
} else {
}
else {
animation
.height(height)
.top(1)

View File

@ -29,12 +29,14 @@ VantComponent({
name = expanded
? (value || []).concat(name)
: (value || []).filter((activeName) => activeName !== name);
} else {
}
else {
name = expanded ? name : '';
}
if (expanded) {
this.$emit('open', changeItem);
} else {
}
else {
this.$emit('close', changeItem);
}
this.$emit('change', name);

View File

@ -1,8 +1,4 @@
/// <reference types="miniprogram-api-typings" />
import { VantComponentOptions } from '../definitions/index';
declare function VantComponent<
Data extends WechatMiniprogram.Component.DataOption,
Props extends WechatMiniprogram.Component.PropertyOption,
Methods extends WechatMiniprogram.Component.MethodOption
>(vantOptions: VantComponentOptions<Data, Props, Methods>): void;
declare function VantComponent<Data extends WechatMiniprogram.Component.DataOption, Props extends WechatMiniprogram.Component.PropertyOption, Methods extends WechatMiniprogram.Component.MethodOption>(vantOptions: VantComponentOptions<Data, Props, Methods>): void;
export { VantComponent };

View File

@ -1,18 +1,12 @@
/// <reference types="miniprogram-api-typings" />
declare type TrivialInstance = WechatMiniprogram.Component.TrivialInstance;
export declare function useParent(
name: string,
onEffect?: (this: TrivialInstance) => void
): {
export declare function useParent(name: string, onEffect?: (this: TrivialInstance) => void): {
relations: {
[x: string]: WechatMiniprogram.Component.RelationOption;
};
mixin: string;
};
export declare function useChildren(
name: string,
onEffect?: (this: TrivialInstance, target: TrivialInstance) => void
): {
export declare function useChildren(name: string, onEffect?: (this: TrivialInstance, target: TrivialInstance) => void): {
relations: {
[x: string]: WechatMiniprogram.Component.RelationOption;
};

View File

@ -22,15 +22,7 @@ export function useParent(name, onEffect) {
});
Object.defineProperty(this, 'index', {
// @ts-ignore
get: () => {
var _a, _b;
return (_b =
(_a = this.parent) === null || _a === void 0
? void 0
: _a.children) === null || _b === void 0
? void 0
: _b.indexOf(this);
},
get: () => { var _a, _b; return (_b = (_a = this.parent) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.indexOf(this); },
});
},
}),

View File

@ -4,28 +4,10 @@ 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.SystemInfo;
export declare function addUnit(value?: string | number): string | undefined;
export declare function requestAnimationFrame(
cb: () => void
): number | WechatMiniprogram.NodesRef;
export declare function requestAnimationFrame(cb: () => void): number | WechatMiniprogram.NodesRef;
export declare function pickExclude(obj: unknown, keys: string[]): {};
export declare function getRect(
context: WechatMiniprogram.Component.TrivialInstance,
selector: string
): Promise<WechatMiniprogram.BoundingClientRectCallbackResult>;
export declare function getAllRect(
context: WechatMiniprogram.Component.TrivialInstance,
selector: string
): Promise<WechatMiniprogram.BoundingClientRectCallbackResult[]>;
export declare function groupSetData(
context: WechatMiniprogram.Component.TrivialInstance,
cb: () => void
): void;
export declare function toPromise(
promiseLike: Promise<unknown> | unknown
): Promise<unknown>;
export declare function getCurrentPage<T>(): T &
WechatMiniprogram.OptionalInterface<WechatMiniprogram.Page.ILifetime> &
WechatMiniprogram.Page.InstanceProperties &
WechatMiniprogram.Page.InstanceMethods<WechatMiniprogram.IAnyObject> &
WechatMiniprogram.Page.Data<WechatMiniprogram.IAnyObject> &
WechatMiniprogram.IAnyObject;
export declare function getRect(context: WechatMiniprogram.Component.TrivialInstance, selector: string): Promise<WechatMiniprogram.BoundingClientRectCallbackResult>;
export declare function getAllRect(context: WechatMiniprogram.Component.TrivialInstance, selector: string): Promise<WechatMiniprogram.BoundingClientRectCallbackResult[]>;
export declare function groupSetData(context: WechatMiniprogram.Component.TrivialInstance, cb: () => void): void;
export declare function toPromise(promiseLike: Promise<unknown> | unknown): Promise<unknown>;
export declare function getCurrentPage<T>(): T & WechatMiniprogram.OptionalInterface<WechatMiniprogram.Page.ILifetime> & WechatMiniprogram.Page.InstanceProperties & WechatMiniprogram.Page.InstanceMethods<WechatMiniprogram.IAnyObject> & WechatMiniprogram.Page.Data<WechatMiniprogram.IAnyObject> & WechatMiniprogram.IAnyObject;

View File

@ -7,7 +7,8 @@ export function range(num, min, max) {
export function nextTick(cb) {
if (canIUseNextTick()) {
wx.nextTick(cb);
} else {
}
else {
setTimeout(() => {
cb();
}, 1000 / 30);
@ -74,7 +75,8 @@ export function getAllRect(context, selector) {
export function groupSetData(context, cb) {
if (canIUseGroupSetData()) {
context.groupSetData(cb);
} else {
}
else {
cb();
}
}

View File

@ -1,7 +1,5 @@
export declare function isFunction(val: unknown): val is Function;
export declare function isPlainObject(
val: unknown
): val is Record<string, unknown>;
export declare function isPlainObject(val: unknown): val is Record<string, unknown>;
export declare function isPromise<T = unknown>(val: unknown): val is Promise<T>;
export declare function isDef(value: unknown): boolean;
export declare function isObj(x: unknown): x is Record<string, unknown>;

View File

@ -55,7 +55,8 @@ VantComponent({
tick() {
if (this.data.millisecond) {
this.microTick();
} else {
}
else {
this.macroTick();
}
},

View File

@ -28,22 +28,26 @@ export function parseFormat(format, timeData) {
let { hours, minutes, seconds, milliseconds } = timeData;
if (format.indexOf('DD') === -1) {
hours += days * 24;
} else {
}
else {
format = format.replace('DD', padZero(days));
}
if (format.indexOf('HH') === -1) {
minutes += hours * 60;
} else {
}
else {
format = format.replace('HH', padZero(hours));
}
if (format.indexOf('mm') === -1) {
seconds += minutes * 60;
} else {
}
else {
format = format.replace('mm', padZero(minutes));
}
if (format.indexOf('ss') === -1) {
milliseconds += seconds * 1000;
} else {
}
else {
format = format.replace('ss', padZero(seconds));
}
return format.replace('SSS', padZero(milliseconds, 3));

View File

@ -34,56 +34,44 @@ function getMonthEndDay(year, month) {
const defaultFormatter = (type, value) => value;
VantComponent({
classes: ['active-class', 'toolbar-class', 'column-class'],
props: Object.assign(Object.assign({}, pickerProps), {
value: {
props: Object.assign(Object.assign({}, pickerProps), { value: {
type: null,
observer: 'updateValue',
},
filter: null,
type: {
}, filter: null, type: {
type: String,
value: 'datetime',
observer: 'updateValue',
},
showToolbar: {
}, showToolbar: {
type: Boolean,
value: true,
},
formatter: {
}, formatter: {
type: null,
value: defaultFormatter,
},
minDate: {
}, minDate: {
type: Number,
value: new Date(currentYear - 10, 0, 1).getTime(),
observer: 'updateValue',
},
maxDate: {
}, maxDate: {
type: Number,
value: new Date(currentYear + 10, 11, 31).getTime(),
observer: 'updateValue',
},
minHour: {
}, minHour: {
type: Number,
value: 0,
observer: 'updateValue',
},
maxHour: {
}, maxHour: {
type: Number,
value: 23,
observer: 'updateValue',
},
minMinute: {
}, minMinute: {
type: Number,
value: 0,
observer: 'updateValue',
},
maxMinute: {
}, maxMinute: {
type: Number,
value: 59,
observer: 'updateValue',
},
}),
} }),
data: {
innerValue: Date.now(),
columns: [],
@ -104,8 +92,7 @@ VantComponent({
this.picker = this.selectComponent('.van-datetime-picker');
const { picker } = this;
const { setColumnValues } = picker;
picker.setColumnValues = (...args) =>
setColumnValues.apply(picker, [...args, false]);
picker.setColumnValues = (...args) => setColumnValues.apply(picker, [...args, false]);
}
return this.picker;
},
@ -144,20 +131,8 @@ VantComponent({
},
];
}
const {
maxYear,
maxDate,
maxMonth,
maxHour,
maxMinute,
} = this.getBoundary('max', data.innerValue);
const {
minYear,
minDate,
minMonth,
minHour,
minMinute,
} = this.getBoundary('min', data.innerValue);
const { maxYear, maxDate, maxMonth, maxHour, maxMinute, } = this.getBoundary('max', data.innerValue);
const { minYear, minDate, minMonth, minHour, minMinute, } = this.getBoundary('min', data.innerValue);
const result = [
{
type: 'year',
@ -180,8 +155,10 @@ VantComponent({
range: [minMinute, maxMinute],
},
];
if (data.type === 'date') result.splice(3, 2);
if (data.type === 'year-month') result.splice(2, 3);
if (data.type === 'date')
result.splice(3, 2);
if (data.type === 'year-month')
result.splice(2, 3);
return result;
},
correctValue(value) {
@ -190,7 +167,8 @@ VantComponent({
const isDateType = data.type !== 'time';
if (isDateType && !isValidDate(value)) {
value = data.minDate;
} else if (!isDateType && !value) {
}
else if (!isDateType && !value) {
const { minHour } = data;
value = `${padZero(minHour)}:00`;
}
@ -255,11 +233,10 @@ VantComponent({
const indexes = picker.getIndexes();
value = `${+originColumns[0].values[indexes[0]]}:${+originColumns[1]
.values[indexes[1]]}`;
} else {
}
else {
const indexes = picker.getIndexes();
const values = indexes.map(
(value, index) => originColumns[index].values[value]
);
const values = indexes.map((value, index) => originColumns[index].values[value]);
const year = getTrueValue(values[0]);
const month = getTrueValue(values[1]);
const maxDate = getMonthEndDay(year, month);
@ -290,7 +267,8 @@ VantComponent({
if (type === 'time') {
const pair = value.split(':');
values = [formatter('hour', pair[0]), formatter('minute', pair[1])];
} else {
}
else {
const date = new Date(value);
values = [
formatter('year', `${date.getFullYear()}`),
@ -300,11 +278,7 @@ VantComponent({
values.push(formatter('day', padZero(date.getDate())));
}
if (type === 'datetime') {
values.push(
formatter('day', padZero(date.getDate())),
formatter('hour', padZero(date.getHours())),
formatter('minute', padZero(date.getMinutes()))
);
values.push(formatter('day', padZero(date.getDate())), formatter('hour', padZero(date.getHours())), formatter('minute', padZero(date.getMinutes())));
}
}
return this.set({ innerValue: value })

View File

@ -3,17 +3,9 @@ interface VantComponentInstance {
parent: WechatMiniprogram.Component.TrivialInstance;
children: WechatMiniprogram.Component.TrivialInstance[];
index: number;
$emit: (
name: string,
detail?: unknown,
options?: WechatMiniprogram.Component.TriggerEventOption
) => void;
$emit: (name: string, detail?: unknown, options?: WechatMiniprogram.Component.TriggerEventOption) => void;
}
export declare type VantComponentOptions<
Data extends WechatMiniprogram.Component.DataOption,
Props extends WechatMiniprogram.Component.PropertyOption,
Methods extends WechatMiniprogram.Component.MethodOption
> = {
export declare type VantComponentOptions<Data extends WechatMiniprogram.Component.DataOption, Props extends WechatMiniprogram.Component.PropertyOption, Methods extends WechatMiniprogram.Component.MethodOption> = {
data?: Data;
field?: boolean;
classes?: string[];
@ -28,16 +20,8 @@ export declare type VantComponentOptions<
created?: () => void;
mounted?: () => void;
destroyed?: () => void;
} & ThisType<
VantComponentInstance &
WechatMiniprogram.Component.Instance<
Data & {
} & ThisType<VantComponentInstance & WechatMiniprogram.Component.Instance<Data & {
name: string;
value: any;
} & Record<string, any>,
Props,
Methods
> &
Record<string, any>
>;
} & Record<string, any>, Props, Methods> & Record<string, any>>;
export {};

View File

@ -7,9 +7,7 @@ interface DialogOptions {
width?: string | number | null;
zIndex?: number;
theme?: string;
context?:
| WechatMiniprogram.Page.TrivialInstance
| WechatMiniprogram.Component.TrivialInstance;
context?: WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance;
message?: string;
overlay?: boolean;
selector?: string;
@ -39,15 +37,9 @@ interface DialogOptions {
confirmButtonOpenType?: string;
}
declare const Dialog: {
(options: DialogOptions): Promise<
WechatMiniprogram.Component.TrivialInstance
>;
alert(
options: DialogOptions
): Promise<WechatMiniprogram.Component.TrivialInstance>;
confirm(
options: DialogOptions
): Promise<WechatMiniprogram.Component.TrivialInstance>;
(options: DialogOptions): Promise<WechatMiniprogram.Component.TrivialInstance>;
alert(options: DialogOptions): Promise<WechatMiniprogram.Component.TrivialInstance>;
confirm(options: DialogOptions): Promise<WechatMiniprogram.Component.TrivialInstance>;
close(): void;
stopLoading(): void;
currentOptions: DialogOptions;

21
dist/dialog/dialog.js vendored
View File

@ -35,30 +35,21 @@ const Dialog = (options) => {
delete options.context;
delete options.selector;
if (dialog) {
dialog.setData(
Object.assign(
{
callback: (action, instance) => {
dialog.setData(Object.assign({ callback: (action, instance) => {
action === 'confirm' ? resolve(instance) : reject(instance);
},
},
options
)
);
} }, options));
wx.nextTick(() => {
dialog.setData({ show: true });
});
queue.push(dialog);
} else {
console.warn(
'未找到 van-dialog 节点,请确认 selector 及 context 是否正确'
);
}
else {
console.warn('未找到 van-dialog 节点,请确认 selector 及 context 是否正确');
}
});
};
Dialog.alert = (options) => Dialog(options);
Dialog.confirm = (options) =>
Dialog(Object.assign({ showCancelButton: true }, options));
Dialog.confirm = (options) => Dialog(Object.assign({ showCancelButton: true }, options));
Dialog.close = () => {
queue.forEach((dialog) => {
dialog.close();

View File

@ -67,7 +67,7 @@ VantComponent({
confirm: false,
cancel: false,
},
callback: () => {},
callback: (() => { }),
},
methods: {
onConfirm() {
@ -111,7 +111,8 @@ VantComponent({
toPromise(beforeClose(action)).then((value) => {
if (value) {
this.close(action);
} else {
}
else {
this.stopLoading();
}
});

View File

@ -36,20 +36,12 @@ VantComponent({
rerender() {
wx.nextTick(() => {
var _a;
(_a = this.parent) === null || _a === void 0
? void 0
: _a.updateItemListData();
(_a = this.parent) === null || _a === void 0 ? void 0 : _a.updateItemListData();
});
},
updateDataFromParent() {
if (this.parent) {
const {
overlay,
duration,
activeColor,
closeOnClickOverlay,
direction,
} = this.parent.data;
const { overlay, duration, activeColor, closeOnClickOverlay, direction, } = this.parent.data;
this.setData({
overlay,
duration,
@ -97,13 +89,12 @@ VantComponent({
showPopup: show,
});
if (show) {
(_a = this.parent) === null || _a === void 0
? void 0
: _a.getChildWrapperStyle().then((wrapperStyle) => {
(_a = this.parent) === null || _a === void 0 ? void 0 : _a.getChildWrapperStyle().then((wrapperStyle) => {
this.setData({ wrapperStyle, showWrapper: true });
this.rerender();
});
} else {
}
else {
this.rerender();
}
},

View File

@ -68,7 +68,8 @@ VantComponent({
const { showPopup } = item.data;
if (index === active) {
item.toggle();
} else if (showPopup) {
}
else if (showPopup) {
item.toggle(false, { immediate: true });
}
});
@ -86,7 +87,8 @@ VantComponent({
let wrapperStyle = `z-index: ${zIndex};`;
if (direction === 'down') {
wrapperStyle += `top: ${addUnit(offset)};`;
} else {
}
else {
wrapperStyle += `bottom: ${addUnit(offset)};`;
}
return wrapperStyle;
@ -97,11 +99,9 @@ VantComponent({
const child = this.children[index];
if (!child.data.disabled) {
ARRAY.forEach((menuItem) => {
if (
menuItem &&
if (menuItem &&
menuItem.data.closeOnClickOutside &&
menuItem !== this
) {
menuItem !== this) {
menuItem.close();
}
});

50
dist/field/index.js vendored
View File

@ -4,56 +4,25 @@ import { commonProps, inputProps, textareaProps } from './props';
VantComponent({
field: true,
classes: ['input-class', 'right-icon-class', 'label-class'],
props: Object.assign(
Object.assign(
Object.assign(Object.assign({}, commonProps), inputProps),
textareaProps
),
{
size: String,
icon: String,
label: String,
error: Boolean,
center: Boolean,
isLink: Boolean,
leftIcon: String,
rightIcon: String,
autosize: null,
required: Boolean,
iconClass: String,
clickable: Boolean,
inputAlign: String,
customStyle: String,
errorMessage: String,
arrowDirection: String,
showWordLimit: Boolean,
errorMessageAlign: String,
readonly: {
props: Object.assign(Object.assign(Object.assign(Object.assign({}, commonProps), inputProps), textareaProps), { size: String, icon: String, label: String, error: Boolean, center: Boolean, isLink: Boolean, leftIcon: String, rightIcon: String, autosize: null, required: Boolean, iconClass: String, clickable: Boolean, inputAlign: String, customStyle: String, errorMessage: String, arrowDirection: String, showWordLimit: Boolean, errorMessageAlign: String, readonly: {
type: Boolean,
observer: 'setShowClear',
},
clearable: {
}, clearable: {
type: Boolean,
observer: 'setShowClear',
},
clearTrigger: {
}, clearTrigger: {
type: String,
value: 'focus',
},
border: {
}, border: {
type: Boolean,
value: true,
},
titleWidth: {
}, titleWidth: {
type: String,
value: '6.2em',
},
clearIcon: {
}, clearIcon: {
type: String,
value: 'clear',
},
}
),
} }),
data: {
focused: false,
innerValue: '',
@ -128,12 +97,11 @@ VantComponent({
let showClear = false;
if (clearable && !readonly) {
const hasValue = !!value;
const trigger =
clearTrigger === 'always' || (clearTrigger === 'focus' && focused);
const trigger = clearTrigger === 'always' || (clearTrigger === 'focus' && focused);
showClear = hasValue && trigger;
}
this.setData({ showClear });
},
noop() {},
noop() { },
},
});

View File

@ -30,17 +30,7 @@ VantComponent({
return;
}
const { data, children } = this.parent;
const {
columnNum,
border,
square,
gutter,
clickable,
center,
direction,
reverse,
iconSize,
} = data;
const { columnNum, border, square, gutter, clickable, center, direction, reverse, iconSize, } = data;
this.setData({
center,
border,

File diff suppressed because one or more lines are too long

View File

@ -39,8 +39,7 @@ VantComponent({
},
mixins: [
pageScrollMixin(function (event) {
this.scrollTop =
(event === null || event === void 0 ? void 0 : event.scrollTop) || 0;
this.scrollTop = (event === null || event === void 0 ? void 0 : event.scrollTop) || 0;
this.onScroll();
}),
],
@ -75,16 +74,12 @@ VantComponent({
]);
},
setAnchorsRect() {
return Promise.all(
this.children.map((anchor) =>
getRect(anchor, '.van-index-anchor-wrapper').then((rect) => {
return Promise.all(this.children.map((anchor) => getRect(anchor, '.van-index-anchor-wrapper').then((rect) => {
Object.assign(anchor, {
height: rect.height,
top: rect.top + this.scrollTop,
});
})
)
);
})));
},
setListRect() {
return getRect(this, '.van-index-bar').then((rect) => {
@ -178,11 +173,11 @@ VantComponent({
wrapperStyle,
},
});
} else if (index === active - 1) {
}
else if (index === active - 1) {
const currentAnchor = children[index];
const currentOffsetTop = currentAnchor.top;
const targetOffsetTop =
index === children.length - 1
const targetOffsetTop = index === children.length - 1
? this.top
: children[index + 1].top;
const parentOffsetHeight = targetOffsetTop - currentOffsetTop;
@ -200,7 +195,8 @@ VantComponent({
anchorStyle,
},
});
} else {
}
else {
this.setDiffData({
target: item,
data: {
@ -223,7 +219,8 @@ VantComponent({
let index = Math.floor((touch.clientY - this.sidebar.top) / itemHeight);
if (index < 0) {
index = 0;
} else if (index > sidebarLength - 1) {
}
else if (index > sidebarLength - 1) {
index = sidebarLength - 1;
}
this.scrollToAnchor(index);
@ -236,9 +233,7 @@ VantComponent({
return;
}
this.scrollToAnchorIndex = index;
const anchor = this.children.find(
(item) => item.data.index === this.data.indexList[index]
);
const anchor = this.children.find((item) => item.data.index === this.data.indexList[index]);
if (anchor) {
anchor.scrollIntoView(this.scrollTop);
this.$emit('select', anchor.data.index);

9
dist/mixins/link.js vendored
View File

@ -10,12 +10,11 @@ export const link = Behavior({
jumpLink(urlKey = 'url') {
const url = this.data[urlKey];
if (url) {
if (
this.data.linkType === 'navigateTo' &&
getCurrentPages().length > 9
) {
if (this.data.linkType === 'navigateTo' &&
getCurrentPages().length > 9) {
wx.redirectTo({ url });
} else {
}
else {
wx[this.data.linkType]({ url });
}
}

View File

@ -1,8 +1,5 @@
/// <reference types="miniprogram-api-typings" />
declare type IPageScrollOption = WechatMiniprogram.Page.IPageScrollOption;
declare type Scroller = (
this: WechatMiniprogram.Component.TrivialInstance,
event?: IPageScrollOption
) => void;
declare type Scroller = (this: WechatMiniprogram.Component.TrivialInstance, event?: IPageScrollOption) => void;
export declare const pageScrollMixin: (scroller: Scroller) => string;
export {};

View File

@ -8,13 +8,13 @@ function onPageScroll(event) {
}
});
}
export const pageScrollMixin = (scroller) =>
Behavior({
export const pageScrollMixin = (scroller) => Behavior({
attached() {
const page = getCurrentPage();
if (Array.isArray(page.vanPageScroller)) {
page.vanPageScroller.push(scroller.bind(this));
} else {
}
else {
page.vanPageScroller =
typeof page.onPageScroll === 'function'
? [page.onPageScroll.bind(page), scroller.bind(this)]
@ -27,9 +27,7 @@ export const pageScrollMixin = (scroller) =>
const page = getCurrentPage();
if (isDef(page)) {
page.vanPageScroller =
((_a = page.vanPageScroller) === null || _a === void 0
? void 0
: _a.filter((item) => item !== scroller)) || [];
((_a = page.vanPageScroller) === null || _a === void 0 ? void 0 : _a.filter((item) => item !== scroller)) || [];
}
},
});
});

View File

@ -62,18 +62,15 @@ VantComponent({
]).then((rects) => {
const [contentRect, wrapRect] = rects;
const { speed, scrollable, delay } = this.data;
if (
contentRect == null ||
if (contentRect == null ||
wrapRect == null ||
!contentRect.width ||
!wrapRect.width ||
scrollable === false
) {
scrollable === false) {
return;
}
if (scrollable || wrapRect.width < contentRect.width) {
const duration =
((wrapRect.width + contentRect.width) / speed) * 1000;
const duration = ((wrapRect.width + contentRect.width) / speed) * 1000;
this.wrapWidth = wrapRect.width;
this.contentWidth = contentRect.width;
this.duration = duration;

16
dist/notify/notify.js vendored
View File

@ -9,9 +9,9 @@ const defaultOptions = {
top: 0,
color: WHITE,
safeAreaInsetTop: false,
onClick: () => {},
onOpened: () => {},
onClose: () => {},
onClick: () => { },
onOpened: () => { },
onClose: () => { },
};
function parseOptions(message) {
if (message == null) {
@ -24,10 +24,7 @@ function getContext() {
return pages[pages.length - 1];
}
export default function Notify(options) {
options = Object.assign(
Object.assign({}, defaultOptions),
parseOptions(options)
);
options = Object.assign(Object.assign({}, defaultOptions), parseOptions(options));
const context = options.context || getContext();
const notify = context.selectComponent(options.selector);
delete options.context;
@ -40,10 +37,7 @@ export default function Notify(options) {
console.warn('未找到 van-notify 节点,请确认 selector 及 context 是否正确');
}
Notify.clear = function (options) {
options = Object.assign(
Object.assign({}, defaultOptions),
parseOptions(options)
);
options = Object.assign(Object.assign({}, defaultOptions), parseOptions(options));
const context = options.context || getContext();
const notify = context.selectComponent(options.selector);
if (notify) {

View File

@ -21,6 +21,6 @@ VantComponent({
this.$emit('click');
},
// for prevent touchmove
noop() {},
noop() { },
},
});

View File

@ -53,22 +53,14 @@ VantComponent({
const { data } = this;
const deltaY = event.touches[0].clientY - data.startY;
this.setData({
offset: range(
data.startOffset + deltaY,
-(this.getCount() * data.itemHeight),
data.itemHeight
),
offset: range(data.startOffset + deltaY, -(this.getCount() * data.itemHeight), data.itemHeight),
});
},
onTouchEnd() {
const { data } = this;
if (data.offset !== data.startOffset) {
this.setData({ duration: DEFAULT_DURATION });
const index = range(
Math.round(-data.offset / data.itemHeight),
0,
this.getCount() - 1
);
const index = range(Math.round(-data.offset / data.itemHeight), 0, this.getCount() - 1);
this.setIndex(index, true);
}
},
@ -81,10 +73,12 @@ VantComponent({
const count = this.getCount();
index = range(index, 0, count);
for (let i = index; i < count; i++) {
if (!this.isDisabled(data.options[i])) return i;
if (!this.isDisabled(data.options[i]))
return i;
}
for (let i = index - 1; i >= 0; i--) {
if (!this.isDisabled(data.options[i])) return i;
if (!this.isDisabled(data.options[i]))
return i;
}
},
isDisabled(option) {

40
dist/picker/index.js vendored
View File

@ -2,43 +2,36 @@ import { VantComponent } from '../common/component';
import { pickerProps } from './shared';
VantComponent({
classes: ['active-class', 'toolbar-class', 'column-class'],
props: Object.assign(Object.assign({}, pickerProps), {
valueKey: {
props: Object.assign(Object.assign({}, pickerProps), { valueKey: {
type: String,
value: 'text',
},
toolbarPosition: {
}, toolbarPosition: {
type: String,
value: 'top',
},
defaultIndex: {
}, defaultIndex: {
type: Number,
value: 0,
},
columns: {
}, columns: {
type: Array,
value: [],
observer(columns = []) {
this.simple = columns.length && !columns[0].values;
if (Array.isArray(this.children) && this.children.length) {
this.setColumns().catch(() => {});
this.setColumns().catch(() => { });
}
},
},
}),
} }),
beforeCreate() {
Object.defineProperty(this, 'children', {
get: () => this.selectAllComponents('.van-picker__column') || [],
});
},
methods: {
noop() {},
noop() { },
setColumns() {
const { data } = this;
const columns = this.simple ? [{ values: data.columns }] : data.columns;
const stack = columns.map((column, index) =>
this.setColumnValues(index, column.values)
);
const stack = columns.map((column, index) => this.setColumnValues(index, column.values));
return Promise.all(stack);
},
emit(event) {
@ -48,7 +41,8 @@ VantComponent({
value: this.getColumnValue(0),
index: this.getColumnIndex(0),
});
} else {
}
else {
this.$emit(type, {
value: this.getValues(),
index: this.getIndexes(),
@ -62,7 +56,8 @@ VantComponent({
value: this.getColumnValue(0),
index: this.getColumnIndex(0),
});
} else {
}
else {
this.$emit('change', {
picker: this,
value: this.getValues(),
@ -109,8 +104,7 @@ VantComponent({
if (column == null) {
return Promise.reject(new Error('setColumnValues: 对应列不存在'));
}
const isSame =
JSON.stringify(column.data.options) === JSON.stringify(options);
const isSame = JSON.stringify(column.data.options) === JSON.stringify(options);
if (isSame) {
return Promise.resolve();
}
@ -126,9 +120,7 @@ VantComponent({
},
// set values of all columns
setValues(values) {
const stack = values.map((value, index) =>
this.setColumnValue(index, value)
);
const stack = values.map((value, index) => this.setColumnValue(index, value));
return Promise.all(stack);
},
// get indexes of all columns
@ -137,9 +129,7 @@ VantComponent({
},
// set indexes of all columns
setIndexes(indexes) {
const stack = indexes.map((optionIndex, columnIndex) =>
this.setColumnIndex(columnIndex, optionIndex)
);
const stack = indexes.map((optionIndex, columnIndex) => this.setColumnIndex(columnIndex, optionIndex));
return Promise.all(stack);
},
},

3
dist/popup/index.js vendored
View File

@ -79,7 +79,8 @@ VantComponent({
if (transition === 'none') {
updateData.duration = 0;
this.originDuration = duration;
} else if (this.originDuration != null) {
}
else if (this.originDuration != null) {
updateData.duration = this.originDuration;
}
this.setData(updateData);

7
dist/rate/index.js vendored
View File

@ -62,16 +62,15 @@ VantComponent({
},
onTouchMove(event) {
const { touchable } = this.data;
if (!touchable) return;
if (!touchable)
return;
const { clientX } = event.touches[0];
getAllRect(this, '.van-rate__icon').then((list) => {
const target = list
.sort((cur, next) => cur.dataset.score - next.dataset.score)
.find((item) => clientX >= item.left && clientX <= item.right);
if (target != null) {
this.onSelect(
Object.assign(Object.assign({}, event), { currentTarget: target })
);
this.onSelect(Object.assign(Object.assign({}, event), { currentTarget: target }));
}
});
},

30
dist/slider/index.js vendored
View File

@ -38,7 +38,8 @@ VantComponent({
},
methods: {
onTouchStart(event) {
if (this.data.disabled) return;
if (this.data.disabled)
return;
const { index } = event.currentTarget.dataset;
if (typeof index === 'number') {
this.buttonIndex = index;
@ -48,13 +49,15 @@ VantComponent({
this.newValue = this.value;
if (this.isRange(this.newValue)) {
this.startValue = this.newValue.map((val) => this.format(val));
} else {
}
else {
this.startValue = this.format(this.newValue);
}
this.dragStatus = 'start';
},
onTouchMove(event) {
if (this.data.disabled) return;
if (this.data.disabled)
return;
if (this.dragStatus === 'start') {
this.$emit('drag-start');
}
@ -65,34 +68,38 @@ VantComponent({
if (this.isRange(this.startValue)) {
this.newValue[this.buttonIndex] =
this.startValue[this.buttonIndex] + diff;
} else {
}
else {
this.newValue = this.startValue + diff;
}
this.updateValue(this.newValue, false, true);
});
},
onTouchEnd() {
if (this.data.disabled) return;
if (this.data.disabled)
return;
if (this.dragStatus === 'draging') {
this.updateValue(this.newValue, true);
this.$emit('drag-end');
}
},
onClick(event) {
if (this.data.disabled) return;
if (this.data.disabled)
return;
const { min } = this.data;
getRect(this, '.van-slider').then((rect) => {
const value =
((event.detail.x - rect.left) / rect.width) * this.getRange() + min;
const value = ((event.detail.x - rect.left) / rect.width) * this.getRange() + min;
if (this.isRange(this.value)) {
const [left, right] = this.value;
const middle = (left + right) / 2;
if (value <= middle) {
this.updateValue([value, right], true);
} else {
}
else {
this.updateValue([left, value], true);
}
} else {
}
else {
this.updateValue(value, true);
}
});
@ -110,7 +117,8 @@ VantComponent({
updateValue(value, end, drag) {
if (this.isRange(value)) {
value = this.handleOverlap(value).map((val) => this.format(val));
} else {
}
else {
value = this.format(value);
}
this.value = value;

14
dist/stepper/index.js vendored
View File

@ -84,14 +84,7 @@ VantComponent({
}
},
isDisabled(type) {
const {
disabled,
disablePlus,
disableMinus,
currentValue,
max,
min,
} = this.data;
const { disabled, disablePlus, disableMinus, currentValue, max, min, } = this.data;
if (type === 'plus') {
return disabled || disablePlus || currentValue >= max;
}
@ -103,10 +96,7 @@ VantComponent({
onBlur(event) {
const value = this.format(event.detail.value);
this.emitChange(value);
this.$emit(
'blur',
Object.assign(Object.assign({}, event.detail), { value })
);
this.$emit('blur', Object.assign(Object.assign({}, event.detail), { value }));
},
// filter illegal characters
filter(value) {

13
dist/sticky/index.js vendored
View File

@ -66,13 +66,15 @@ VantComponent({
fixed: false,
transform: container.height - root.height,
});
} else if (offsetTop >= root.top) {
}
else if (offsetTop >= root.top) {
this.setDataAfterDiff({
fixed: true,
height: root.height,
transform: 0,
});
} else {
}
else {
this.setDataAfterDiff({ fixed: false, transform: 0 });
}
});
@ -85,7 +87,8 @@ VantComponent({
if (offsetTop >= root.top) {
this.setDataAfterDiff({ fixed: true, height: root.height });
this.transform = 0;
} else {
}
else {
this.setDataAfterDiff({ fixed: false });
}
});
@ -109,9 +112,7 @@ VantComponent({
},
getContainerRect() {
const nodesRef = this.data.container();
return new Promise((resolve) =>
nodesRef.boundingClientRect(resolve).exec()
);
return new Promise((resolve) => nodesRef.boundingClientRect(resolve).exec());
},
},
});

View File

@ -38,8 +38,7 @@ VantComponent({
methods: {
updatePrice() {
const { price, decimalLength } = this.data;
const priceStrArr =
typeof price === 'number' &&
const priceStrArr = typeof price === 'number' &&
(price / 100).toFixed(decimalLength).split('.');
this.setData({
hasPrice: typeof price === 'number',

View File

@ -75,9 +75,11 @@ VantComponent({
const { offset } = this;
if (rightWidth > 0 && -offset > rightWidth * THRESHOLD) {
this.open('right');
} else if (leftWidth > 0 && offset > leftWidth * THRESHOLD) {
}
else if (leftWidth > 0 && offset > leftWidth * THRESHOLD) {
this.open('left');
} else {
}
else {
this.swipeMove(0);
}
this.setData({ catchMove: false });
@ -89,7 +91,7 @@ VantComponent({
this.startOffset = this.offset;
this.touchStart(event);
},
noop() {},
noop() { },
onDrag(event) {
if (this.data.disabled) {
return;
@ -99,9 +101,7 @@ VantComponent({
return;
}
this.dragging = true;
ARRAY.filter(
(item) => item !== this && item.offset !== 0
).forEach((item) => item.close());
ARRAY.filter((item) => item !== this && item.offset !== 0).forEach((item) => item.close());
this.setData({ catchMove: true });
this.swipeMove(this.startOffset + this.deltaX);
},
@ -124,7 +124,8 @@ VantComponent({
instance: this,
name: this.data.name,
});
} else {
}
else {
this.swipeMove(0);
}
},

49
dist/tabs/index.js vendored
View File

@ -1,12 +1,6 @@
import { VantComponent } from '../common/component';
import { touch } from '../mixins/touch';
import {
getAllRect,
getRect,
groupSetData,
nextTick,
requestAnimationFrame,
} from '../common/utils';
import { getAllRect, getRect, groupSetData, nextTick, requestAnimationFrame, } from '../common/utils';
import { isDef } from '../common/validator';
import { useChildren } from '../common/relation';
VantComponent({
@ -25,9 +19,7 @@ VantComponent({
animated: {
type: Boolean,
observer() {
this.children.forEach((child, index) =>
child.updateRender(index === this.data.currentIndex, this)
);
this.children.forEach((child, index) => child.updateRender(index === this.data.currentIndex, this));
},
},
lineWidth: {
@ -111,8 +103,7 @@ VantComponent({
const { children = [], data } = this;
this.setData({
tabs: children.map((child) => child.data),
scrollable:
this.children.length > data.swipeThreshold || !data.ellipsis,
scrollable: this.children.length > data.swipeThreshold || !data.ellipsis,
});
this.setCurrentIndexByName(data.active || this.getCurrentName());
},
@ -133,7 +124,8 @@ VantComponent({
const child = this.children[index];
if (child.data.disabled) {
this.trigger('disabled', child);
} else {
}
else {
this.setCurrentIndex(index);
nextTick(() => {
this.trigger('click');
@ -143,20 +135,16 @@ VantComponent({
// correct the index of active tab
setCurrentIndexByName(name) {
const { children = [] } = this;
const matched = children.filter(
(child) => child.getComputedName() === name
);
const matched = children.filter((child) => child.getComputedName() === name);
if (matched.length) {
this.setCurrentIndex(matched[0].index);
}
},
setCurrentIndex(currentIndex) {
const { data, children = [] } = this;
if (
!isDef(currentIndex) ||
if (!isDef(currentIndex) ||
currentIndex >= children.length ||
currentIndex < 0
) {
currentIndex < 0) {
return;
}
groupSetData(this, () => {
@ -243,16 +231,19 @@ VantComponent({
this.$emit('scroll', event.detail);
},
onTouchStart(event) {
if (!this.data.swipeable) return;
if (!this.data.swipeable)
return;
this.touchStart(event);
},
onTouchMove(event) {
if (!this.data.swipeable) return;
if (!this.data.swipeable)
return;
this.touchMove(event);
},
// watch swipe touch end
onTouchEnd() {
if (!this.data.swipeable) return;
if (!this.data.swipeable)
return;
const { direction, deltaX, offsetX } = this;
const minSwipeDistance = 50;
if (direction === 'horizontal' && offsetX >= minSwipeDistance) {
@ -265,18 +256,12 @@ VantComponent({
getAvaiableTab(direction) {
const { tabs, currentIndex } = this.data;
const step = direction > 0 ? -1 : 1;
for (
let i = step;
currentIndex + i < tabs.length && currentIndex + i >= 0;
i += step
) {
for (let i = step; currentIndex + i < tabs.length && currentIndex + i >= 0; i += step) {
const index = currentIndex + i;
if (
index >= 0 &&
if (index >= 0 &&
index < tabs.length &&
tabs[index] &&
!tabs[index].disabled
) {
!tabs[index].disabled) {
return index;
}
}

2
dist/toast/index.js vendored
View File

@ -24,6 +24,6 @@ VantComponent({
},
methods: {
// for prevent touchmove
noop() {},
noop() { },
},
});

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

@ -5,9 +5,7 @@ interface ToastOptions {
type?: string;
mask?: boolean;
zIndex?: number;
context?:
| WechatMiniprogram.Component.TrivialInstance
| WechatMiniprogram.Page.TrivialInstance;
context?: WechatMiniprogram.Component.TrivialInstance | WechatMiniprogram.Page.TrivialInstance;
position?: string;
duration?: number;
selector?: string;
@ -16,19 +14,11 @@ interface ToastOptions {
message?: ToastMessage;
onClose?: () => void;
}
declare function Toast(
toastOptions: ToastOptions | ToastMessage
): WechatMiniprogram.Component.TrivialInstance | undefined;
declare function Toast(toastOptions: ToastOptions | ToastMessage): WechatMiniprogram.Component.TrivialInstance | undefined;
declare namespace Toast {
var loading: (
options: ToastMessage | ToastOptions
) => WechatMiniprogram.Component.TrivialInstance | undefined;
var success: (
options: ToastMessage | ToastOptions
) => WechatMiniprogram.Component.TrivialInstance | undefined;
var fail: (
options: ToastMessage | ToastOptions
) => WechatMiniprogram.Component.TrivialInstance | undefined;
var loading: (options: ToastMessage | ToastOptions) => WechatMiniprogram.Component.TrivialInstance | undefined;
var success: (options: ToastMessage | ToastOptions) => WechatMiniprogram.Component.TrivialInstance | undefined;
var fail: (options: ToastMessage | ToastOptions) => WechatMiniprogram.Component.TrivialInstance | undefined;
var clear: () => void;
var setDefaultOptions: (options: ToastOptions) => void;
var resetDefaultOptions: () => void;

8
dist/toast/toast.js vendored
View File

@ -21,10 +21,7 @@ function getContext() {
return pages[pages.length - 1];
}
function Toast(toastOptions) {
const options = Object.assign(
Object.assign({}, currentOptions),
parseOptions(toastOptions)
);
const options = Object.assign(Object.assign({}, currentOptions), parseOptions(toastOptions));
const context = options.context || getContext();
const toast = context.selectComponent(options.selector);
if (!toast) {
@ -50,8 +47,7 @@ function Toast(toastOptions) {
}
return toast;
}
const createMethod = (type) => (options) =>
Toast(Object.assign({ type }, parseOptions(options)));
const createMethod = (type) => (options) => Toast(Object.assign({ type }, parseOptions(options)));
Toast.loading = createMethod('loading');
Toast.success = createMethod('success');
Toast.fail = createMethod('fail');

102
dist/uploader/index.js vendored
View File

@ -3,69 +3,44 @@ import { isImageFile, chooseFile, isVideoFile } from './utils';
import { chooseImageProps, chooseVideoProps } from './shared';
import { isBoolean, isPromise } from '../common/validator';
VantComponent({
props: Object.assign(
Object.assign(
{
disabled: Boolean,
multiple: Boolean,
uploadText: String,
useBeforeRead: Boolean,
afterRead: null,
beforeRead: null,
previewSize: {
props: Object.assign(Object.assign({ disabled: Boolean, multiple: Boolean, uploadText: String, useBeforeRead: Boolean, afterRead: null, beforeRead: null, previewSize: {
type: null,
value: 80,
},
name: {
}, name: {
type: null,
value: '',
},
accept: {
}, accept: {
type: String,
value: 'image',
},
fileList: {
}, fileList: {
type: Array,
value: [],
observer: 'formatFileList',
},
maxSize: {
}, maxSize: {
type: Number,
value: Number.MAX_VALUE,
},
maxCount: {
}, maxCount: {
type: Number,
value: 100,
},
deletable: {
}, deletable: {
type: Boolean,
value: true,
},
showUpload: {
}, showUpload: {
type: Boolean,
value: true,
},
previewImage: {
}, previewImage: {
type: Boolean,
value: true,
},
previewFullImage: {
}, previewFullImage: {
type: Boolean,
value: true,
},
imageFit: {
}, imageFit: {
type: String,
value: 'scaleToFill',
},
uploadIcon: {
}, uploadIcon: {
type: String,
value: 'photograph',
},
},
chooseImageProps
),
chooseVideoProps
),
} }, chooseImageProps), chooseVideoProps),
data: {
lists: [],
isInCount: true,
@ -73,13 +48,7 @@ VantComponent({
methods: {
formatFileList() {
const { fileList = [], maxCount } = this.data;
const lists = fileList.map((item) =>
Object.assign(Object.assign({}, item), {
isImage: isImageFile(item),
isVideo: isVideoFile(item),
deletable: isBoolean(item.deletable) ? item.deletable : true,
})
);
const lists = fileList.map((item) => (Object.assign(Object.assign({}, item), { isImage: isImageFile(item), isVideo: isVideoFile(item), deletable: isBoolean(item.deletable) ? item.deletable : true })));
this.setData({ lists, isInCount: lists.length < maxCount });
},
getDetail(index) {
@ -90,12 +59,9 @@ VantComponent({
},
startUpload() {
const { maxCount, multiple, lists, disabled } = this.data;
if (disabled) return;
chooseFile(
Object.assign(Object.assign({}, this.data), {
maxCount: maxCount - lists.length,
})
)
if (disabled)
return;
chooseFile(Object.assign(Object.assign({}, this.data), { maxCount: maxCount - lists.length }))
.then((res) => {
this.onBeforeRead(multiple ? res : res[0]);
})
@ -111,14 +77,9 @@ VantComponent({
}
if (useBeforeRead) {
res = new Promise((resolve, reject) => {
this.$emit(
'before-read',
Object.assign(Object.assign({ file }, this.getDetail()), {
callback: (ok) => {
this.$emit('before-read', Object.assign(Object.assign({ file }, this.getDetail()), { callback: (ok) => {
ok ? resolve() : reject();
},
})
);
} }));
});
}
if (!res) {
@ -126,7 +87,8 @@ VantComponent({
}
if (isPromise(res)) {
res.then((data) => this.onAfterRead(data || file));
} else {
}
else {
this.onAfterRead(file);
}
},
@ -146,15 +108,11 @@ VantComponent({
},
deleteItem(event) {
const { index } = event.currentTarget.dataset;
this.$emit(
'delete',
Object.assign(Object.assign({}, this.getDetail(index)), {
file: this.data.fileList[index],
})
);
this.$emit('delete', Object.assign(Object.assign({}, this.getDetail(index)), { file: this.data.fileList[index] }));
},
onPreviewImage(event) {
if (!this.data.previewFullImage) return;
if (!this.data.previewFullImage)
return;
const { index } = event.currentTarget.dataset;
const { lists } = this.data;
const item = lists[index];
@ -167,15 +125,14 @@ VantComponent({
});
},
onPreviewVideo(event) {
if (!this.data.previewFullImage) return;
if (!this.data.previewFullImage)
return;
const { index } = event.currentTarget.dataset;
const { lists } = this.data;
wx.previewMedia({
sources: lists
.filter((item) => isVideoFile(item))
.map((item) =>
Object.assign(Object.assign({}, item), { type: 'video' })
),
.map((item) => (Object.assign(Object.assign({}, item), { type: 'video' }))),
current: index,
fail() {
wx.showToast({ title: '预览视频失败', icon: 'none' });
@ -192,10 +149,7 @@ VantComponent({
onClickPreview(event) {
const { index } = event.currentTarget.dataset;
const item = this.data.lists[index];
this.$emit(
'click-preview',
Object.assign(Object.assign({}, item), this.getDetail(index))
);
this.$emit('click-preview', Object.assign(Object.assign({}, item), this.getDetail(index)));
},
},
});

View File

@ -10,16 +10,7 @@ export interface File {
}
export declare function isImageFile(item: File): boolean;
export declare function isVideoFile(item: File): boolean;
export declare function chooseFile({
accept,
multiple,
capture,
compressed,
maxDuration,
sizeType,
camera,
maxCount,
}: {
export declare function chooseFile({ accept, multiple, capture, compressed, maxDuration, sizeType, camera, maxCount, }: {
accept: any;
multiple: any;
capture: any;

View File

@ -25,58 +25,20 @@ export function isVideoFile(item) {
return false;
}
function formatImage(res) {
return res.tempFiles.map((item) =>
Object.assign(Object.assign({}, pickExclude(item, ['path'])), {
type: 'image',
url: item.path,
thumb: item.path,
})
);
return res.tempFiles.map((item) => (Object.assign(Object.assign({}, pickExclude(item, ['path'])), { type: 'image', url: item.path, thumb: item.path })));
}
function formatVideo(res) {
return [
Object.assign(
Object.assign(
{},
pickExclude(res, ['tempFilePath', 'thumbTempFilePath', 'errMsg'])
),
{ type: 'video', url: res.tempFilePath, thumb: res.thumbTempFilePath }
),
Object.assign(Object.assign({}, pickExclude(res, ['tempFilePath', 'thumbTempFilePath', 'errMsg'])), { type: 'video', url: res.tempFilePath, thumb: res.thumbTempFilePath }),
];
}
function formatMedia(res) {
return res.tempFiles.map((item) =>
Object.assign(
Object.assign(
{},
pickExclude(item, ['fileType', 'thumbTempFilePath', 'tempFilePath'])
),
{
type: res.type,
url: item.tempFilePath,
thumb:
res.type === 'video' ? item.thumbTempFilePath : item.tempFilePath,
}
)
);
return res.tempFiles.map((item) => (Object.assign(Object.assign({}, pickExclude(item, ['fileType', 'thumbTempFilePath', 'tempFilePath'])), { type: res.type, url: item.tempFilePath, thumb: res.type === 'video' ? item.thumbTempFilePath : item.tempFilePath })));
}
function formatFile(res) {
return res.tempFiles.map((item) =>
Object.assign(Object.assign({}, pickExclude(item, ['path'])), {
url: item.path,
})
);
return res.tempFiles.map((item) => (Object.assign(Object.assign({}, pickExclude(item, ['path'])), { url: item.path })));
}
export function chooseFile({
accept,
multiple,
capture,
compressed,
maxDuration,
sizeType,
camera,
maxCount,
}) {
export function chooseFile({ accept, multiple, capture, compressed, maxDuration, sizeType, camera, maxCount, }) {
return new Promise((resolve, reject) => {
switch (accept) {
case 'image':

View File

@ -1,7 +1,7 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component');
var button_1 = require('../mixins/button');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
var button_1 = require("../mixins/button");
component_1.VantComponent({
mixins: [button_1.button],
props: {
@ -42,10 +42,7 @@ component_1.VantComponent({
onSelect: function (event) {
var _this = this;
var index = event.currentTarget.dataset.index;
var _a = this.data,
actions = _a.actions,
closeOnClickAction = _a.closeOnClickAction,
canIUseGetUserProfile = _a.canIUseGetUserProfile;
var _a = this.data, actions = _a.actions, closeOnClickAction = _a.closeOnClickAction, canIUseGetUserProfile = _a.canIUseGetUserProfile;
var item = actions[index];
if (item) {
this.$emit('select', item);

View File

@ -1,44 +1,36 @@
'use strict';
var __assign =
(this && this.__assign) ||
function () {
__assign =
Object.assign ||
function (t) {
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component');
var shared_1 = require('../picker/shared');
var utils_1 = require('../common/utils');
};
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
var shared_1 = require("../picker/shared");
var utils_1 = require("../common/utils");
var EMPTY_CODE = '000000';
component_1.VantComponent({
classes: ['active-class', 'toolbar-class', 'column-class'],
props: __assign(__assign({}, shared_1.pickerProps), {
value: {
props: __assign(__assign({}, shared_1.pickerProps), { value: {
type: String,
observer: function (value) {
this.code = value;
this.setValues();
},
},
areaList: {
}, areaList: {
type: Object,
value: {},
observer: 'setValues',
},
columnsNum: {
}, columnsNum: {
type: null,
value: 3,
},
columnsPlaceholder: {
}, columnsPlaceholder: {
type: Array,
observer: function (val) {
this.setData({
@ -49,8 +41,7 @@ component_1.VantComponent({
},
});
},
},
}),
} }),
data: {
columns: [{ values: [] }, { values: [] }, { values: [] }],
typeToColumnsPlaceholder: {},
@ -85,10 +76,8 @@ component_1.VantComponent({
parseValues: function (values) {
var columnsPlaceholder = this.data.columnsPlaceholder;
return values.map(function (value, index) {
if (
value &&
(!value.code || value.name === columnsPlaceholder[index])
) {
if (value &&
(!value.code || value.name === columnsPlaceholder[index])) {
return __assign(__assign({}, value), { code: '', name: '' });
}
return value;
@ -97,14 +86,9 @@ component_1.VantComponent({
onChange: function (event) {
var _this = this;
var _a;
var _b = event.detail,
index = _b.index,
picker = _b.picker,
value = _b.value;
var _b = event.detail, index = _b.index, picker = _b.picker, value = _b.value;
this.code = value[index].code;
(_a = this.setValues()) === null || _a === void 0
? void 0
: _a.then(function () {
(_a = this.setValues()) === null || _a === void 0 ? void 0 : _a.then(function () {
_this.$emit('change', {
picker: picker,
values: _this.parseValues(picker.getValues()),
@ -114,7 +98,7 @@ component_1.VantComponent({
},
getConfig: function (type) {
var areaList = this.data.areaList;
return (areaList && areaList[type + '_list']) || {};
return (areaList && areaList[type + "_list"]) || {};
},
getList: function (type, code) {
if (type !== 'province' && !code) {
@ -122,31 +106,26 @@ component_1.VantComponent({
}
var typeToColumnsPlaceholder = this.data.typeToColumnsPlaceholder;
var list = this.getConfig(type);
var result = Object.keys(list).map(function (code) {
return {
var result = Object.keys(list).map(function (code) { return ({
code: code,
name: list[code],
};
});
}); });
if (code != null) {
// oversea code
if (code[0] === '9' && type === 'city') {
code = '9';
}
result = result.filter(function (item) {
return item.code.indexOf(code) === 0;
});
result = result.filter(function (item) { return item.code.indexOf(code) === 0; });
}
if (typeToColumnsPlaceholder[type] && result.length) {
// set columns placeholder
var codeFill =
type === 'province'
var codeFill = type === 'province'
? ''
: type === 'city'
? EMPTY_CODE.slice(2, 4)
: EMPTY_CODE.slice(4, 6);
result.unshift({
code: '' + code + codeFill,
code: "" + code + codeFill,
name: typeToColumnsPlaceholder[type],
});
}
@ -190,21 +169,13 @@ component_1.VantComponent({
}
}
if (columnsNum === 3) {
stack.push(
picker.setColumnValues(
2,
this.getList('county', code.slice(0, 4)),
false
)
);
stack.push(picker.setColumnValues(2, this.getList('county', code.slice(0, 4)), false));
indexes.push(this.getIndex('county', code));
}
return Promise.all(stack)
.catch(function () {})
.then(function () {
return picker.setIndexes(indexes);
})
.catch(function () {});
.catch(function () { })
.then(function () { return picker.setIndexes(indexes); })
.catch(function () { });
},
getDefaultCode: function () {
var columnsPlaceholder = this.data.columnsPlaceholder;
@ -226,11 +197,7 @@ component_1.VantComponent({
if (!picker) {
return [];
}
return this.parseValues(
picker.getValues().filter(function (value) {
return !!value;
})
);
return this.parseValues(picker.getValues().filter(function (value) { return !!value; }));
},
getDetail: function () {
var values = this.getValues();
@ -244,14 +211,13 @@ component_1.VantComponent({
if (!values.length) {
return area;
}
var names = values.map(function (item) {
return item.name;
});
var names = values.map(function (item) { return item.name; });
area.code = values[values.length - 1].code;
if (area.code[0] === '9') {
area.country = names[1] || '';
area.province = names[2] || '';
} else {
}
else {
area.province = names[0] || '';
area.city = names[1] || '';
area.county = names[2] || '';

View File

@ -1,8 +1,8 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component');
var button_1 = require('../mixins/button');
var version_1 = require('../common/version');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
var button_1 = require("../mixins/button");
var version_1 = require("../common/version");
var mixins = [button_1.button];
if (version_1.canIUseFormFieldButton()) {
mixins.push('wx://form-field-button');
@ -52,11 +52,7 @@ component_1.VantComponent({
onClick: function (event) {
var _this = this;
this.$emit('click', event);
var _a = this.data,
canIUseGetUserProfile = _a.canIUseGetUserProfile,
openType = _a.openType,
getUserProfileDesc = _a.getUserProfileDesc,
lang = _a.lang;
var _a = this.data, canIUseGetUserProfile = _a.canIUseGetUserProfile, openType = _a.openType, getUserProfileDesc = _a.getUserProfileDesc, lang = _a.lang;
if (openType === 'getUserInfo' && canIUseGetUserProfile) {
wx.getUserProfile({
desc: getUserProfileDesc || ' ',

View File

@ -1,13 +1,11 @@
'use strict';
var __spreadArray =
(this && this.__spreadArray) ||
function (to, from) {
"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');
};
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../../../common/component");
component_1.VantComponent({
props: {
title: {
@ -33,10 +31,7 @@ component_1.VantComponent({
var defaultWeeks = ['日', '一', '二', '三', '四', '五', '六'];
var firstDayOfWeek = this.data.firstDayOfWeek || 0;
this.setData({
weekdays: __spreadArray(
__spreadArray([], defaultWeeks.slice(firstDayOfWeek, 7)),
defaultWeeks.slice(0, firstDayOfWeek)
),
weekdays: __spreadArray(__spreadArray([], defaultWeeks.slice(firstDayOfWeek, 7)), defaultWeeks.slice(0, firstDayOfWeek)),
});
},
onClickSubtitle: function (event) {

View File

@ -1,7 +1,7 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../../../common/component');
var utils_1 = require('../../utils');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../../../common/component");
var utils_1 = require("../../utils");
component_1.VantComponent({
props: {
date: {
@ -56,10 +56,7 @@ component_1.VantComponent({
var startDate = new Date(this.data.date);
var year = startDate.getFullYear();
var month = startDate.getMonth();
var totalDay = utils_1.getMonthEndDay(
startDate.getFullYear(),
startDate.getMonth() + 1
);
var totalDay = utils_1.getMonthEndDay(startDate.getFullYear(), startDate.getMonth() + 1);
for (var day = 1; day <= totalDay; day++) {
var date = new Date(year, month, day);
var type = this.getDayType(date);
@ -82,9 +79,7 @@ component_1.VantComponent({
return '';
}
var isSelected = function (date) {
return currentDate.some(function (item) {
return utils_1.compareDay(item, date) === 0;
});
return currentDate.some(function (item) { return utils_1.compareDay(item, date) === 0; });
};
if (isSelected(day)) {
var prevDay = utils_1.getPrevDay(day);
@ -102,14 +97,11 @@ component_1.VantComponent({
return '';
},
getRangeDayType: function (day) {
var _a = this.data,
currentDate = _a.currentDate,
allowSameDay = _a.allowSameDay;
var _a = this.data, currentDate = _a.currentDate, allowSameDay = _a.allowSameDay;
if (!Array.isArray(currentDate)) {
return '';
}
var startDay = currentDate[0],
endDay = currentDate[1];
var startDay = currentDate[0], endDay = currentDate[1];
if (!startDay) {
return '';
}
@ -133,15 +125,8 @@ component_1.VantComponent({
return '';
},
getDayType: function (day) {
var _a = this.data,
type = _a.type,
minDate = _a.minDate,
maxDate = _a.maxDate,
currentDate = _a.currentDate;
if (
utils_1.compareDay(day, minDate) < 0 ||
utils_1.compareDay(day, maxDate) > 0
) {
var _a = this.data, type = _a.type, minDate = _a.minDate, maxDate = _a.maxDate, currentDate = _a.currentDate;
if (utils_1.compareDay(day, minDate) < 0 || utils_1.compareDay(day, maxDate) > 0) {
return 'disabled';
}
if (type === 'single') {

View File

@ -1,29 +1,21 @@
'use strict';
var __spreadArray =
(this && this.__spreadArray) ||
function (to, from) {
"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;
};
var __importDefault =
(this && this.__importDefault) ||
function (mod) {
return mod && mod.__esModule ? mod : { default: mod };
};
Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component');
var utils_1 = require('./utils');
var toast_1 = __importDefault(require('../toast/toast'));
var utils_2 = require('../common/utils');
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
var utils_1 = require("./utils");
var toast_1 = __importDefault(require("../toast/toast"));
var utils_2 = require("../common/utils");
var initialMinDate = utils_1.getToday().getTime();
var initialMaxDate = (function () {
var now = utils_1.getToday();
return new Date(
now.getFullYear(),
now.getMonth() + 6,
now.getDate()
).getTime();
return new Date(now.getFullYear(), now.getMonth() + 6, now.getDate()).getTime();
})();
component_1.VantComponent({
props: {
@ -160,19 +152,13 @@ component_1.VantComponent({
contentObserver.observe('.month', function (res) {
if (res.boundingClientRect.top <= res.relativeRect.top) {
// @ts-ignore
_this.setData({
subtitle: utils_1.formatMonthTitle(res.dataset.date),
});
_this.setData({ subtitle: utils_1.formatMonthTitle(res.dataset.date) });
}
});
},
limitDateRange: function (date, minDate, maxDate) {
if (minDate === void 0) {
minDate = null;
}
if (maxDate === void 0) {
maxDate = null;
}
if (minDate === void 0) { minDate = null; }
if (maxDate === void 0) { maxDate = null; }
minDate = minDate || this.data.minDate;
maxDate = maxDate || this.data.maxDate;
if (utils_1.compareDay(date, minDate) === -1) {
@ -185,37 +171,21 @@ component_1.VantComponent({
},
getInitialDate: function (defaultDate) {
var _this = this;
if (defaultDate === void 0) {
defaultDate = null;
}
var _a = this.data,
type = _a.type,
minDate = _a.minDate,
maxDate = _a.maxDate;
if (defaultDate === void 0) { defaultDate = null; }
var _a = this.data, type = _a.type, minDate = _a.minDate, maxDate = _a.maxDate;
var now = utils_1.getToday().getTime();
if (type === 'range') {
if (!Array.isArray(defaultDate)) {
defaultDate = [];
}
var _b = defaultDate || [],
startDay = _b[0],
endDay = _b[1];
var start = this.limitDateRange(
startDay || now,
minDate,
utils_1.getPrevDay(new Date(maxDate)).getTime()
);
var end = this.limitDateRange(
endDay || now,
utils_1.getNextDay(new Date(minDate)).getTime()
);
var _b = defaultDate || [], startDay = _b[0], endDay = _b[1];
var start = this.limitDateRange(startDay || now, minDate, utils_1.getPrevDay(new Date(maxDate)).getTime());
var end = this.limitDateRange(endDay || now, utils_1.getNextDay(new Date(minDate)).getTime());
return [start, end];
}
if (type === 'multiple') {
if (Array.isArray(defaultDate)) {
return defaultDate.map(function (date) {
return _this.limitDateRange(date);
});
return defaultDate.map(function (date) { return _this.limitDateRange(date); });
}
return [this.limitDateRange(now)];
}
@ -227,13 +197,7 @@ component_1.VantComponent({
scrollIntoView: function () {
var _this = this;
utils_2.requestAnimationFrame(function () {
var _a = _this.data,
currentDate = _a.currentDate,
type = _a.type,
show = _a.show,
poppable = _a.poppable,
minDate = _a.minDate,
maxDate = _a.maxDate;
var _a = _this.data, currentDate = _a.currentDate, type = _a.type, show = _a.show, poppable = _a.poppable, minDate = _a.minDate, maxDate = _a.maxDate;
// @ts-ignore
var targetDate = type === 'single' ? currentDate : currentDate[0];
var displayed = show || !poppable;
@ -243,7 +207,7 @@ component_1.VantComponent({
var months = utils_1.getMonths(minDate, maxDate);
months.some(function (month, index) {
if (utils_1.compareMonth(month, targetDate) === 0) {
_this.setData({ scrollIntoView: 'month' + index });
_this.setData({ scrollIntoView: "month" + index });
return true;
}
return false;
@ -264,27 +228,27 @@ component_1.VantComponent({
},
onClickDay: function (event) {
var date = event.detail.date;
var _a = this.data,
type = _a.type,
currentDate = _a.currentDate,
allowSameDay = _a.allowSameDay;
var _a = this.data, type = _a.type, currentDate = _a.currentDate, allowSameDay = _a.allowSameDay;
if (type === 'range') {
// @ts-ignore
var startDay = currentDate[0],
endDay = currentDate[1];
var startDay = currentDate[0], endDay = currentDate[1];
if (startDay && !endDay) {
var compareToStart = utils_1.compareDay(date, startDay);
if (compareToStart === 1) {
this.select([startDay, date], true);
} else if (compareToStart === -1) {
}
else if (compareToStart === -1) {
this.select([date, null]);
} else if (allowSameDay) {
}
else if (allowSameDay) {
this.select([date, date]);
}
} else {
}
else {
this.select([date, null]);
}
} else if (type === 'multiple') {
}
else if (type === 'multiple') {
var selectedIndex_1;
// @ts-ignore
var selected = currentDate.some(function (dateItem, index) {
@ -299,11 +263,13 @@ component_1.VantComponent({
var cancelDate = currentDate.splice(selectedIndex_1, 1);
this.setData({ currentDate: currentDate });
this.unselect(cancelDate);
} else {
}
else {
// @ts-ignore
this.select(__spreadArray(__spreadArray([], currentDate), [date]));
}
} else {
}
else {
this.select(date, true);
}
},
@ -323,7 +289,8 @@ component_1.VantComponent({
date[0],
utils_1.getDayByOffset(date[0], this.data.maxRange - 1),
]);
} else {
}
else {
this.emit(date);
}
return;
@ -344,19 +311,12 @@ component_1.VantComponent({
this.$emit('select', utils_1.copyDates(date));
},
checkRange: function (date) {
var _a = this.data,
maxRange = _a.maxRange,
rangePrompt = _a.rangePrompt,
showRangePrompt = _a.showRangePrompt;
var _a = this.data, maxRange = _a.maxRange, rangePrompt = _a.rangePrompt, showRangePrompt = _a.showRangePrompt;
if (maxRange && utils_1.calcDateNum(date) > maxRange) {
if (showRangePrompt) {
toast_1.default({
context: this,
message:
rangePrompt ||
'\u9009\u62E9\u5929\u6570\u4E0D\u80FD\u8D85\u8FC7 ' +
maxRange +
' \u5929',
message: rangePrompt || "\u9009\u62E9\u5929\u6570\u4E0D\u80FD\u8D85\u8FC7 " + maxRange + " \u5929",
});
}
this.$emit('over-range');
@ -366,10 +326,8 @@ component_1.VantComponent({
},
onConfirm: function () {
var _this = this;
if (
this.data.type === 'range' &&
!this.checkRange(this.data.currentDate)
) {
if (this.data.type === 'range' &&
!this.checkRange(this.data.currentDate)) {
return;
}
wx.nextTick(function () {

View File

@ -1,12 +1,12 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getMonths = exports.getMonthEndDay = exports.copyDates = exports.calcDateNum = exports.getToday = exports.getNextDay = exports.getPrevDay = exports.getDayByOffset = exports.compareDay = exports.compareMonth = exports.formatMonthTitle = exports.ROW_HEIGHT = void 0;
exports.ROW_HEIGHT = 64;
function formatMonthTitle(date) {
if (!(date instanceof Date)) {
date = new Date(date);
}
return date.getFullYear() + '\u5E74' + (date.getMonth() + 1) + '\u6708';
return date.getFullYear() + "\u5E74" + (date.getMonth() + 1) + "\u6708";
}
exports.formatMonthTitle = formatMonthTitle;
function compareMonth(date1, date2) {

View File

@ -1,7 +1,7 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var link_1 = require('../mixins/link');
var component_1 = require('../common/component');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var link_1 = require("../mixins/link");
var component_1 = require("../common/component");
component_1.VantComponent({
classes: [
'num-class',
@ -41,7 +41,7 @@ component_1.VantComponent({
var priceArr = price.toString().split('.');
this.setData({
integerStr: priceArr[0],
decimalStr: priceArr[1] ? '.' + priceArr[1] : '',
decimalStr: priceArr[1] ? "." + priceArr[1] : '',
});
},
onClickThumb: function () {

View File

@ -1,6 +1,6 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
component_1.VantComponent({
props: {
title: String,

View File

@ -1,7 +1,7 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var link_1 = require('../mixins/link');
var component_1 = require('../common/component');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var link_1 = require("../mixins/link");
var component_1 = require("../common/component");
component_1.VantComponent({
classes: [
'title-class',

View File

@ -1,7 +1,7 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var relation_1 = require('../common/relation');
var component_1 = require('../common/component');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var relation_1 = require("../common/relation");
var component_1 = require("../common/component");
component_1.VantComponent({
field: true,
relation: relation_1.useChildren('checkbox', function (target) {
@ -25,15 +25,10 @@ component_1.VantComponent({
methods: {
updateChildren: function () {
var _this = this;
this.children.forEach(function (child) {
return _this.updateChild(child);
});
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;
var _a = this.data, value = _a.value, disabled = _a.disabled, direction = _a.direction;
child.setData({
value: value.indexOf(child.data.name) !== -1,
parentDisabled: disabled,

View File

@ -1,7 +1,7 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var relation_1 = require('../common/relation');
var component_1 = require('../common/component');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var relation_1 = require("../common/relation");
var component_1 = require("../common/component");
function emit(target, value) {
target.$emit('input', value);
target.$emit('change', value);
@ -37,25 +37,19 @@ component_1.VantComponent({
emitChange: function (value) {
if (this.parent) {
this.setParentValue(this.parent, value);
} else {
}
else {
emit(this, value);
}
},
toggle: function () {
var _a = this.data,
parentDisabled = _a.parentDisabled,
disabled = _a.disabled,
value = _a.value;
var _a = this.data, parentDisabled = _a.parentDisabled, disabled = _a.disabled, value = _a.value;
if (!disabled && !parentDisabled) {
this.emitChange(!value);
}
},
onClickLabel: function () {
var _a = this.data,
labelDisabled = _a.labelDisabled,
parentDisabled = _a.parentDisabled,
disabled = _a.disabled,
value = _a.value;
var _a = this.data, labelDisabled = _a.labelDisabled, parentDisabled = _a.parentDisabled, disabled = _a.disabled, value = _a.value;
if (!disabled && !labelDisabled && !parentDisabled) {
this.emitChange(!value);
}
@ -72,7 +66,8 @@ component_1.VantComponent({
parentValue.push(name);
emit(parent, parentValue);
}
} else {
}
else {
var index = parentValue.indexOf(name);
if (index !== -1) {
parentValue.splice(index, 1);

View File

@ -1,5 +1,5 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.adaptor = void 0;
function adaptor(ctx) {
// @ts-ignore
@ -40,8 +40,8 @@ function adaptor(ctx) {
setTextBaseline: function (val) {
ctx.textBaseline = val;
},
createCircularGradient: function () {},
draw: function () {},
createCircularGradient: function () { },
draw: function () { },
});
}
exports.adaptor = adaptor;

View File

@ -1,11 +1,11 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var color_1 = require('../common/color');
var component_1 = require('../common/component');
var utils_1 = require('../common/utils');
var validator_1 = require('../common/validator');
var version_1 = require('../common/version');
var canvas_1 = require('./canvas');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var color_1 = require("../common/color");
var component_1 = require("../common/component");
var utils_1 = require("../common/utils");
var validator_1 = require("../common/validator");
var version_1 = require("../common/version");
var canvas_1 = require("./canvas");
function format(rate) {
return Math.min(Math.max(rate, 0), 100);
}
@ -69,9 +69,7 @@ component_1.VantComponent({
methods: {
getContext: function () {
var _this = this;
var _a = this.data,
type = _a.type,
size = _a.size;
var _a = this.data, type = _a.type, size = _a.size;
if (type === '' || !version_1.canIUseCanvas2d()) {
var ctx = wx.createCanvasContext('van-circle', this);
return Promise.resolve(ctx);
@ -97,21 +95,14 @@ component_1.VantComponent({
},
setHoverColor: function () {
var _this = this;
var _a = this.data,
color = _a.color,
size = _a.size;
var _a = this.data, color = _a.color, size = _a.size;
if (validator_1.isObj(color)) {
return this.getContext().then(function (context) {
var LinearColor = context.createLinearGradient(size, 0, 0, 0);
Object.keys(color)
.sort(function (a, b) {
return parseFloat(a) - parseFloat(b);
})
.sort(function (a, b) { return parseFloat(a) - parseFloat(b); })
.map(function (key) {
return LinearColor.addColorStop(
parseFloat(key) / 100,
color[key]
);
return LinearColor.addColorStop(parseFloat(key) / 100, color[key]);
});
_this.hoverColor = LinearColor;
});
@ -120,11 +111,7 @@ component_1.VantComponent({
return Promise.resolve();
},
presetCanvas: function (context, strokeStyle, beginAngle, endAngle, fill) {
var _a = this.data,
strokeWidth = _a.strokeWidth,
lineCap = _a.lineCap,
clockwise = _a.clockwise,
size = _a.size;
var _a = this.data, strokeWidth = _a.strokeWidth, lineCap = _a.lineCap, clockwise = _a.clockwise, size = _a.size;
var position = size / 2;
var radius = position - strokeWidth / 2;
context.setStrokeStyle(strokeStyle);
@ -139,9 +126,7 @@ component_1.VantComponent({
}
},
renderLayerCircle: function (context) {
var _a = this.data,
layerColor = _a.layerColor,
fill = _a.fill;
var _a = this.data, layerColor = _a.layerColor, fill = _a.fill;
this.presetCanvas(context, layerColor, 0, PERIMETER, fill);
},
renderHoverCircle: function (context, formatValue) {
@ -169,9 +154,7 @@ component_1.VantComponent({
reRender: function () {
var _this = this;
// tofector 动画暂时没有想到好的解决方案
var _a = this.data,
value = _a.value,
speed = _a.speed;
var _a = this.data, value = _a.value, speed = _a.speed;
if (speed <= 0 || speed > 1000) {
this.drawCircle(value);
return;
@ -183,14 +166,17 @@ component_1.VantComponent({
if (_this.currentValue !== value) {
if (Math.abs(_this.currentValue - value) < STEP) {
_this.currentValue = value;
} else if (_this.currentValue < value) {
}
else if (_this.currentValue < value) {
_this.currentValue += STEP;
} else {
}
else {
_this.currentValue -= STEP;
}
_this.drawCircle(_this.currentValue);
run();
} else {
}
else {
_this.clearMockInterval();
}
}, 1000 / speed);

View File

@ -1,7 +1,7 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var relation_1 = require('../common/relation');
var component_1 = require('../common/component');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var relation_1 = require("../common/relation");
var component_1 = require("../common/component");
component_1.VantComponent({
relation: relation_1.useParent('row'),
props: {

View File

@ -1,36 +1,26 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setContentAnimate = void 0;
var version_1 = require('../common/version');
var utils_1 = require('../common/utils');
var version_1 = require("../common/version");
var utils_1 = require("../common/utils");
function useAnimate(context, expanded, mounted, height) {
var selector = '.van-collapse-item__wrapper';
if (expanded) {
context.animate(
selector,
[
context.animate(selector, [
{ height: 0, ease: 'ease-in-out', offset: 0 },
{ height: height + 'px', ease: 'ease-in-out', offset: 1 },
{ height: 'auto', ease: 'ease-in-out', offset: 1 },
],
mounted ? 300 : 0,
function () {
{ height: height + "px", ease: 'ease-in-out', offset: 1 },
{ height: "auto", ease: 'ease-in-out', offset: 1 },
], mounted ? 300 : 0, function () {
context.clearAnimation(selector);
}
);
});
return;
}
context.animate(
selector,
[
{ height: height + 'px', ease: 'ease-in-out', offset: 0 },
context.animate(selector, [
{ height: height + "px", ease: 'ease-in-out', offset: 0 },
{ height: 0, ease: 'ease-in-out', offset: 1 },
],
300,
function () {
], 300, function () {
context.clearAnimation(selector);
}
);
});
}
function useAnimation(context, expanded, mounted, height) {
var animation = wx.createAnimation({
@ -40,7 +30,8 @@ function useAnimation(context, expanded, mounted, height) {
if (expanded) {
if (height === 0) {
animation.height('auto').top(1).step();
} else {
}
else {
animation
.height(height)
.top(1)
@ -63,11 +54,8 @@ function useAnimation(context, expanded, mounted, height) {
});
}
function setContentAnimate(context, expanded, mounted) {
utils_1
.getRect(context, '.van-collapse-item__content')
.then(function (rect) {
return rect.height;
})
utils_1.getRect(context, '.van-collapse-item__content')
.then(function (rect) { return rect.height; })
.then(function (height) {
version_1.canIUseAnimate()
? useAnimate(context, expanded, mounted, height)

View File

@ -1,8 +1,8 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component');
var relation_1 = require('../common/relation');
var animate_1 = require('./animate');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
var relation_1 = require("../common/relation");
var animate_1 = require("./animate");
component_1.VantComponent({
classes: ['title-class', 'content-class'],
relation: relation_1.useParent('collapse'),
@ -35,19 +35,14 @@ component_1.VantComponent({
if (!this.parent) {
return;
}
var _a = this.parent.data,
value = _a.value,
accordion = _a.accordion;
var _b = this.parent.children,
children = _b === void 0 ? [] : _b;
var _a = this.parent.data, value = _a.value, accordion = _a.accordion;
var _b = this.parent.children, children = _b === void 0 ? [] : _b;
var name = this.data.name;
var index = children.indexOf(this);
var currentName = name == null ? index : name;
var expanded = accordion
? value === currentName
: (value || []).some(function (name) {
return name === currentName;
});
: (value || []).some(function (name) { return name === currentName; });
if (expanded !== this.data.expanded) {
animate_1.setContentAnimate(this, expanded, this.mounted);
}
@ -57,9 +52,7 @@ component_1.VantComponent({
if (this.data.disabled) {
return;
}
var _a = this.data,
name = _a.name,
expanded = _a.expanded;
var _a = this.data, name = _a.name, expanded = _a.expanded;
var index = this.parent.children.indexOf(this);
var currentName = name == null ? index : name;
this.parent.switch(currentName, !expanded);

View File

@ -1,7 +1,7 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component');
var relation_1 = require('../common/relation');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
var relation_1 = require("../common/relation");
component_1.VantComponent({
relation: relation_1.useChildren('collapse-item'),
props: {
@ -25,22 +25,20 @@ component_1.VantComponent({
});
},
switch: function (name, expanded) {
var _a = this.data,
accordion = _a.accordion,
value = _a.value;
var _a = this.data, accordion = _a.accordion, value = _a.value;
var changeItem = name;
if (!accordion) {
name = expanded
? (value || []).concat(name)
: (value || []).filter(function (activeName) {
return activeName !== name;
});
} else {
: (value || []).filter(function (activeName) { return activeName !== name; });
}
else {
name = expanded ? name : '';
}
if (expanded) {
this.$emit('open', changeItem);
} else {
}
else {
this.$emit('close', changeItem);
}
this.$emit('change', name);

View File

@ -1,5 +1,5 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GRAY_DARK = exports.GRAY = exports.ORANGE = exports.GREEN = exports.WHITE = exports.BLUE = exports.RED = void 0;
exports.RED = '#ee0a24';
exports.BLUE = '#1989fa';

View File

@ -1,7 +1,7 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VantComponent = void 0;
var basic_1 = require('../mixins/basic');
var basic_1 = require("../mixins/basic");
function mapKeys(source, target, map) {
Object.keys(map).forEach(function (key) {
if (source[key]) {

View File

@ -1,13 +1,12 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useChildren = exports.useParent = void 0;
function useParent(name, onEffect) {
var _a;
var path = '../' + name + '/index';
var path = "../" + name + "/index";
return {
relations:
((_a = {}),
(_a[path] = {
relations: (_a = {},
_a[path] = {
type: 'ancestor',
linked: function () {
onEffect && onEffect.call(this);
@ -18,27 +17,17 @@ function useParent(name, onEffect) {
unlinked: function () {
onEffect && onEffect.call(this);
},
}),
},
_a),
mixin: Behavior({
created: function () {
var _this = this;
Object.defineProperty(this, 'parent', {
get: function () {
return _this.getRelationNodes(path)[0];
},
get: function () { return _this.getRelationNodes(path)[0]; },
});
Object.defineProperty(this, 'index', {
// @ts-ignore
get: function () {
var _a, _b;
return (_b =
(_a = _this.parent) === null || _a === void 0
? void 0
: _a.children) === null || _b === void 0
? void 0
: _b.indexOf(_this);
},
get: function () { var _a, _b; return (_b = (_a = _this.parent) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.indexOf(_this); },
});
},
}),
@ -47,11 +36,10 @@ function useParent(name, onEffect) {
exports.useParent = useParent;
function useChildren(name, onEffect) {
var _a;
var path = '../' + name + '/index';
var path = "../" + name + "/index";
return {
relations:
((_a = {}),
(_a[path] = {
relations: (_a = {},
_a[path] = {
type: 'descendant',
linked: function (target) {
onEffect && onEffect.call(this, target);
@ -62,15 +50,13 @@ function useChildren(name, onEffect) {
unlinked: function (target) {
onEffect && onEffect.call(this, target);
},
}),
},
_a),
mixin: Behavior({
created: function () {
var _this = this;
Object.defineProperty(this, 'children', {
get: function () {
return _this.getRelationNodes(path) || [];
},
get: function () { return _this.getRelationNodes(path) || []; },
});
},
}),

View File

@ -1,15 +1,10 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCurrentPage = exports.toPromise = exports.groupSetData = exports.getAllRect = exports.getRect = exports.pickExclude = exports.requestAnimationFrame = exports.addUnit = exports.getSystemInfoSync = exports.nextTick = exports.range = exports.isDef = void 0;
var validator_1 = require('./validator');
var version_1 = require('./version');
var validator_2 = require('./validator');
Object.defineProperty(exports, 'isDef', {
enumerable: true,
get: function () {
return validator_2.isDef;
},
});
var validator_1 = require("./validator");
var version_1 = require("./version");
var validator_2 = require("./validator");
Object.defineProperty(exports, "isDef", { enumerable: true, get: function () { return validator_2.isDef; } });
function range(num, min, max) {
return Math.min(Math.max(num, min), max);
}
@ -17,7 +12,8 @@ exports.range = range;
function nextTick(cb) {
if (version_1.canIUseNextTick()) {
wx.nextTick(cb);
} else {
}
else {
setTimeout(function () {
cb();
}, 1000 / 30);
@ -37,7 +33,7 @@ function addUnit(value) {
return undefined;
}
value = String(value);
return validator_1.isNumber(value) ? value + 'px' : value;
return validator_1.isNumber(value) ? value + "px" : value;
}
exports.addUnit = addUnit;
function requestAnimationFrame(cb) {
@ -75,9 +71,7 @@ function getRect(context, selector) {
.select(selector)
.boundingClientRect()
.exec(function (rect) {
if (rect === void 0) {
rect = [];
}
if (rect === void 0) { rect = []; }
return resolve(rect[0]);
});
});
@ -90,9 +84,7 @@ function getAllRect(context, selector) {
.selectAll(selector)
.boundingClientRect()
.exec(function (rect) {
if (rect === void 0) {
rect = [];
}
if (rect === void 0) { rect = []; }
return resolve(rect[0]);
});
});
@ -101,7 +93,8 @@ exports.getAllRect = getAllRect;
function groupSetData(context, cb) {
if (version_1.canIUseGroupSetData()) {
context.groupSetData(cb);
} else {
}
else {
cb();
}
}

View File

@ -1,5 +1,5 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
"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) {

View File

@ -1,7 +1,7 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
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) {
v1 = v1.split('.');
v2 = v2.split('.');

View File

@ -1,6 +1,6 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
component_1.VantComponent({
props: {
themeVars: {

View File

@ -1,7 +1,7 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component');
var utils_1 = require('./utils');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
var utils_1 = require("./utils");
function simpleTick(fn) {
return setTimeout(fn, 30);
}
@ -57,7 +57,8 @@ component_1.VantComponent({
tick: function () {
if (this.data.millisecond) {
this.microTick();
} else {
}
else {
this.macroTick();
}
},

View File

@ -1,10 +1,8 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isSameSecond = exports.parseFormat = exports.parseTimeData = void 0;
function padZero(num, targetLength) {
if (targetLength === void 0) {
targetLength = 2;
}
if (targetLength === void 0) { targetLength = 2; }
var str = num + '';
while (str.length < targetLength) {
str = '0' + str;
@ -32,28 +30,29 @@ function parseTimeData(time) {
exports.parseTimeData = parseTimeData;
function parseFormat(format, timeData) {
var days = timeData.days;
var hours = timeData.hours,
minutes = timeData.minutes,
seconds = timeData.seconds,
milliseconds = timeData.milliseconds;
var hours = timeData.hours, minutes = timeData.minutes, seconds = timeData.seconds, milliseconds = timeData.milliseconds;
if (format.indexOf('DD') === -1) {
hours += days * 24;
} else {
}
else {
format = format.replace('DD', padZero(days));
}
if (format.indexOf('HH') === -1) {
minutes += hours * 60;
} else {
}
else {
format = format.replace('HH', padZero(hours));
}
if (format.indexOf('mm') === -1) {
seconds += minutes * 60;
} else {
}
else {
format = format.replace('mm', padZero(minutes));
}
if (format.indexOf('ss') === -1) {
milliseconds += seconds * 1000;
} else {
}
else {
format = format.replace('ss', padZero(seconds));
}
return format.replace('SSS', padZero(milliseconds, 3));

View File

@ -1,30 +1,24 @@
'use strict';
var __assign =
(this && this.__assign) ||
function () {
__assign =
Object.assign ||
function (t) {
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __spreadArray =
(this && this.__spreadArray) ||
function (to, from) {
};
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');
var validator_1 = require('../common/validator');
var shared_1 = require('../picker/shared');
};
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
var validator_1 = require("../common/validator");
var shared_1 = require("../picker/shared");
var currentYear = new Date().getFullYear();
function isValidDate(date) {
return validator_1.isDef(date) && !isNaN(new Date(date).getTime());
@ -33,7 +27,7 @@ function range(num, min, max) {
return Math.min(Math.max(num, min), max);
}
function padZero(val) {
return ('00' + val).slice(-2);
return ("00" + val).slice(-2);
}
function times(n, iteratee) {
var index = -1;
@ -55,61 +49,47 @@ function getTrueValue(formattedValue) {
function getMonthEndDay(year, month) {
return 32 - new Date(year, month - 1, 32).getDate();
}
var defaultFormatter = function (type, value) {
return value;
};
var defaultFormatter = function (type, value) { return value; };
component_1.VantComponent({
classes: ['active-class', 'toolbar-class', 'column-class'],
props: __assign(__assign({}, shared_1.pickerProps), {
value: {
props: __assign(__assign({}, shared_1.pickerProps), { value: {
type: null,
observer: 'updateValue',
},
filter: null,
type: {
}, filter: null, type: {
type: String,
value: 'datetime',
observer: 'updateValue',
},
showToolbar: {
}, showToolbar: {
type: Boolean,
value: true,
},
formatter: {
}, formatter: {
type: null,
value: defaultFormatter,
},
minDate: {
}, minDate: {
type: Number,
value: new Date(currentYear - 10, 0, 1).getTime(),
observer: 'updateValue',
},
maxDate: {
}, maxDate: {
type: Number,
value: new Date(currentYear + 10, 11, 31).getTime(),
observer: 'updateValue',
},
minHour: {
}, minHour: {
type: Number,
value: 0,
observer: 'updateValue',
},
maxHour: {
}, maxHour: {
type: Number,
value: 23,
observer: 'updateValue',
},
minMinute: {
}, minMinute: {
type: Number,
value: 0,
observer: 'updateValue',
},
maxMinute: {
}, maxMinute: {
type: Number,
value: 59,
observer: 'updateValue',
},
}),
} }),
data: {
innerValue: Date.now(),
columns: [],
@ -136,34 +116,25 @@ component_1.VantComponent({
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return setColumnValues_1.apply(
picker_1,
__spreadArray(__spreadArray([], args), [false])
);
return setColumnValues_1.apply(picker_1, __spreadArray(__spreadArray([], args), [false]));
};
}
return this.picker;
},
updateColumns: function () {
var _a = this.data.formatter,
formatter = _a === void 0 ? defaultFormatter : _a;
var results = this.getOriginColumns().map(function (column) {
return {
values: column.values.map(function (value) {
return formatter(column.type, value);
}),
};
});
var _a = this.data.formatter, formatter = _a === void 0 ? defaultFormatter : _a;
var results = this.getOriginColumns().map(function (column) { return ({
values: column.values.map(function (value) { return formatter(column.type, value); }),
}); });
return this.set({ columns: results });
},
getOriginColumns: function () {
var filter = this.data.filter;
var results = this.getRanges().map(function (_a) {
var type = _a.type,
range = _a.range;
var type = _a.type, range = _a.range;
var values = times(range[1] - range[0] + 1, function (index) {
var value = range[0] + index;
return type === 'year' ? '' + value : padZero(value);
return type === 'year' ? "" + value : padZero(value);
});
if (filter) {
values = filter(type, values);
@ -186,18 +157,8 @@ component_1.VantComponent({
},
];
}
var _a = this.getBoundary('max', data.innerValue),
maxYear = _a.maxYear,
maxDate = _a.maxDate,
maxMonth = _a.maxMonth,
maxHour = _a.maxHour,
maxMinute = _a.maxMinute;
var _b = this.getBoundary('min', data.innerValue),
minYear = _b.minYear,
minDate = _b.minDate,
minMonth = _b.minMonth,
minHour = _b.minHour,
minMinute = _b.minMinute;
var _a = this.getBoundary('max', data.innerValue), maxYear = _a.maxYear, maxDate = _a.maxDate, maxMonth = _a.maxMonth, maxHour = _a.maxHour, maxMinute = _a.maxMinute;
var _b = this.getBoundary('min', data.innerValue), minYear = _b.minYear, minDate = _b.minDate, minMonth = _b.minMonth, minHour = _b.minHour, minMinute = _b.minMinute;
var result = [
{
type: 'year',
@ -220,8 +181,10 @@ component_1.VantComponent({
range: [minMinute, maxMinute],
},
];
if (data.type === 'date') result.splice(3, 2);
if (data.type === 'year-month') result.splice(2, 3);
if (data.type === 'date')
result.splice(3, 2);
if (data.type === 'year-month')
result.splice(2, 3);
return result;
},
correctValue: function (value) {
@ -230,18 +193,17 @@ component_1.VantComponent({
var isDateType = data.type !== 'time';
if (isDateType && !isValidDate(value)) {
value = data.minDate;
} else if (!isDateType && !value) {
}
else if (!isDateType && !value) {
var minHour = data.minHour;
value = padZero(minHour) + ':00';
value = padZero(minHour) + ":00";
}
// time type
if (!isDateType) {
var _a = value.split(':'),
hour = _a[0],
minute = _a[1];
var _a = value.split(':'), hour = _a[0], minute = _a[1];
hour = padZero(range(hour, data.minHour, data.maxHour));
minute = padZero(range(minute, data.minMinute, data.maxMinute));
return hour + ':' + minute;
return hour + ":" + minute;
}
// date type
value = Math.max(value, data.minDate);
@ -251,7 +213,7 @@ component_1.VantComponent({
getBoundary: function (type, innerValue) {
var _a;
var value = new Date(innerValue);
var boundary = new Date(this.data[type + 'Date']);
var boundary = new Date(this.data[type + "Date"]);
var year = boundary.getFullYear();
var month = 1;
var date = 1;
@ -275,15 +237,13 @@ component_1.VantComponent({
}
}
}
return (
(_a = {}),
(_a[type + 'Year'] = year),
(_a[type + 'Month'] = month),
(_a[type + 'Date'] = date),
(_a[type + 'Hour'] = hour),
(_a[type + 'Minute'] = minute),
_a
);
return _a = {},
_a[type + "Year"] = year,
_a[type + "Month"] = month,
_a[type + "Date"] = date,
_a[type + "Hour"] = hour,
_a[type + "Minute"] = minute,
_a;
},
onCancel: function () {
this.$emit('cancel');
@ -299,15 +259,12 @@ component_1.VantComponent({
var originColumns = this.getOriginColumns();
if (data.type === 'time') {
var indexes = picker.getIndexes();
value =
+originColumns[0].values[indexes[0]] +
':' +
+originColumns[1].values[indexes[1]];
} else {
value = +originColumns[0].values[indexes[0]] + ":" + +originColumns[1]
.values[indexes[1]];
}
else {
var indexes = picker.getIndexes();
var values = indexes.map(function (value, index) {
return originColumns[index].values[value];
});
var values = indexes.map(function (value, index) { return originColumns[index].values[value]; });
var year = getTrueValue(values[0]);
var month = getTrueValue(values[1]);
var maxDate = getMonthEndDay(year, month);
@ -339,30 +296,23 @@ component_1.VantComponent({
if (type === 'time') {
var pair = value.split(':');
values = [formatter('hour', pair[0]), formatter('minute', pair[1])];
} else {
}
else {
var date = new Date(value);
values = [
formatter('year', '' + date.getFullYear()),
formatter('year', "" + date.getFullYear()),
formatter('month', padZero(date.getMonth() + 1)),
];
if (type === 'date') {
values.push(formatter('day', padZero(date.getDate())));
}
if (type === 'datetime') {
values.push(
formatter('day', padZero(date.getDate())),
formatter('hour', padZero(date.getHours())),
formatter('minute', padZero(date.getMinutes()))
);
values.push(formatter('day', padZero(date.getDate())), formatter('hour', padZero(date.getHours())), formatter('minute', padZero(date.getMinutes())));
}
}
return this.set({ innerValue: value })
.then(function () {
return _this.updateColumns();
})
.then(function () {
return picker.setValues(values);
});
.then(function () { return _this.updateColumns(); })
.then(function () { return picker.setValues(values); });
},
},
created: function () {

View File

@ -1,20 +1,16 @@
'use strict';
var __assign =
(this && this.__assign) ||
function () {
__assign =
Object.assign ||
function (t) {
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, '__esModule', { value: true });
};
Object.defineProperty(exports, "__esModule", { value: true });
var queue = [];
var defaultOptions = {
show: false,
@ -52,30 +48,20 @@ var Dialog = function (options) {
delete options.context;
delete options.selector;
if (dialog) {
dialog.setData(
__assign(
{
callback: function (action, instance) {
dialog.setData(__assign({ callback: function (action, instance) {
action === 'confirm' ? resolve(instance) : reject(instance);
},
},
options
)
);
} }, options));
wx.nextTick(function () {
dialog.setData({ show: true });
});
queue.push(dialog);
} else {
console.warn(
'未找到 van-dialog 节点,请确认 selector 及 context 是否正确'
);
}
else {
console.warn('未找到 van-dialog 节点,请确认 selector 及 context 是否正确');
}
});
};
Dialog.alert = function (options) {
return Dialog(options);
};
Dialog.alert = function (options) { return Dialog(options); };
Dialog.confirm = function (options) {
return Dialog(__assign({ showCancelButton: true }, options));
};

View File

@ -1,9 +1,9 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component');
var button_1 = require('../mixins/button');
var color_1 = require('../common/color');
var utils_1 = require('../common/utils');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
var button_1 = require("../mixins/button");
var color_1 = require("../common/color");
var utils_1 = require("../common/utils");
component_1.VantComponent({
mixins: [button_1.button],
props: {
@ -69,7 +69,7 @@ component_1.VantComponent({
confirm: false,
cancel: false,
},
callback: function () {},
callback: (function () { }),
},
methods: {
onConfirm: function () {
@ -104,19 +104,20 @@ component_1.VantComponent({
var _a;
var _this = this;
this.$emit(action, { dialog: this });
var _b = this.data,
asyncClose = _b.asyncClose,
beforeClose = _b.beforeClose;
var _b = this.data, asyncClose = _b.asyncClose, beforeClose = _b.beforeClose;
if (!asyncClose && !beforeClose) {
this.close(action);
return;
}
this.setData(((_a = {}), (_a['loading.' + action] = true), _a));
this.setData((_a = {},
_a["loading." + action] = true,
_a));
if (beforeClose) {
utils_1.toPromise(beforeClose(action)).then(function (value) {
if (value) {
_this.close(action);
} else {
}
else {
_this.stopLoading();
}
});

View File

@ -1,6 +1,6 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
component_1.VantComponent({
props: {
dashed: Boolean,

View File

@ -1,7 +1,7 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var relation_1 = require('../common/relation');
var component_1 = require('../common/component');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var relation_1 = require("../common/relation");
var component_1 = require("../common/component");
component_1.VantComponent({
field: true,
relation: relation_1.useParent('dropdown-menu', function () {
@ -39,19 +39,12 @@ component_1.VantComponent({
var _this = this;
wx.nextTick(function () {
var _a;
(_a = _this.parent) === null || _a === void 0
? void 0
: _a.updateItemListData();
(_a = _this.parent) === null || _a === void 0 ? void 0 : _a.updateItemListData();
});
},
updateDataFromParent: function () {
if (this.parent) {
var _a = this.parent.data,
overlay = _a.overlay,
duration = _a.duration,
activeColor = _a.activeColor,
closeOnClickOverlay = _a.closeOnClickOverlay,
direction = _a.direction;
var _a = this.parent.data, overlay = _a.overlay, duration = _a.duration, activeColor = _a.activeColor, closeOnClickOverlay = _a.closeOnClickOverlay, direction = _a.direction;
this.setData({
overlay: overlay,
duration: duration,
@ -88,9 +81,7 @@ component_1.VantComponent({
toggle: function (show, options) {
var _this = this;
var _a;
if (options === void 0) {
options = {};
}
if (options === void 0) { options = {}; }
var showPopup = this.data.showPopup;
if (typeof show !== 'boolean') {
show = !showPopup;
@ -103,13 +94,12 @@ component_1.VantComponent({
showPopup: show,
});
if (show) {
(_a = this.parent) === null || _a === void 0
? void 0
: _a.getChildWrapperStyle().then(function (wrapperStyle) {
(_a = this.parent) === null || _a === void 0 ? void 0 : _a.getChildWrapperStyle().then(function (wrapperStyle) {
_this.setData({ wrapperStyle: wrapperStyle, showWrapper: true });
_this.rerender();
});
} else {
}
else {
this.rerender();
}
},

View File

@ -1,2 +1,2 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@ -1,8 +1,8 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component');
var relation_1 = require('../common/relation');
var utils_1 = require('../common/utils');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
var relation_1 = require("../common/relation");
var utils_1 = require("../common/utils");
var ARRAY = [];
component_1.VantComponent({
field: true,
@ -53,16 +53,12 @@ component_1.VantComponent({
},
destroyed: function () {
var _this = this;
ARRAY = ARRAY.filter(function (item) {
return item !== _this;
});
ARRAY = ARRAY.filter(function (item) { return item !== _this; });
},
methods: {
updateItemListData: function () {
this.setData({
itemListData: this.children.map(function (child) {
return child.data;
}),
itemListData: this.children.map(function (child) { return child.data; }),
});
},
updateChildrenData: function () {
@ -75,7 +71,8 @@ component_1.VantComponent({
var showPopup = item.data.showPopup;
if (index === active) {
item.toggle();
} else if (showPopup) {
}
else if (showPopup) {
item.toggle(false, { immediate: true });
}
});
@ -87,20 +84,16 @@ component_1.VantComponent({
},
getChildWrapperStyle: function () {
var _this = this;
var _a = this.data,
zIndex = _a.zIndex,
direction = _a.direction;
var _a = this.data, zIndex = _a.zIndex, direction = _a.direction;
return utils_1.getRect(this, '.van-dropdown-menu').then(function (rect) {
var _a = rect.top,
top = _a === void 0 ? 0 : _a,
_b = rect.bottom,
bottom = _b === void 0 ? 0 : _b;
var _a = rect.top, top = _a === void 0 ? 0 : _a, _b = rect.bottom, bottom = _b === void 0 ? 0 : _b;
var offset = direction === 'down' ? bottom : _this.windowHeight - top;
var wrapperStyle = 'z-index: ' + zIndex + ';';
var wrapperStyle = "z-index: " + zIndex + ";";
if (direction === 'down') {
wrapperStyle += 'top: ' + utils_1.addUnit(offset) + ';';
} else {
wrapperStyle += 'bottom: ' + utils_1.addUnit(offset) + ';';
wrapperStyle += "top: " + utils_1.addUnit(offset) + ";";
}
else {
wrapperStyle += "bottom: " + utils_1.addUnit(offset) + ";";
}
return wrapperStyle;
});
@ -111,11 +104,9 @@ component_1.VantComponent({
var child = this.children[index];
if (!child.data.disabled) {
ARRAY.forEach(function (menuItem) {
if (
menuItem &&
if (menuItem &&
menuItem.data.closeOnClickOutside &&
menuItem !== _this
) {
menuItem !== _this) {
menuItem.close();
}
});

View File

@ -1,6 +1,6 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
component_1.VantComponent({
props: {
description: String,

View File

@ -1,76 +1,41 @@
'use strict';
var __assign =
(this && this.__assign) ||
function () {
__assign =
Object.assign ||
function (t) {
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, '__esModule', { value: true });
var utils_1 = require('../common/utils');
var component_1 = require('../common/component');
var props_1 = require('./props');
};
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("../common/utils");
var component_1 = require("../common/component");
var props_1 = require("./props");
component_1.VantComponent({
field: true,
classes: ['input-class', 'right-icon-class', 'label-class'],
props: __assign(
__assign(
__assign(__assign({}, props_1.commonProps), props_1.inputProps),
props_1.textareaProps
),
{
size: String,
icon: String,
label: String,
error: Boolean,
center: Boolean,
isLink: Boolean,
leftIcon: String,
rightIcon: String,
autosize: null,
required: Boolean,
iconClass: String,
clickable: Boolean,
inputAlign: String,
customStyle: String,
errorMessage: String,
arrowDirection: String,
showWordLimit: Boolean,
errorMessageAlign: String,
readonly: {
props: __assign(__assign(__assign(__assign({}, props_1.commonProps), props_1.inputProps), props_1.textareaProps), { size: String, icon: String, label: String, error: Boolean, center: Boolean, isLink: Boolean, leftIcon: String, rightIcon: String, autosize: null, required: Boolean, iconClass: String, clickable: Boolean, inputAlign: String, customStyle: String, errorMessage: String, arrowDirection: String, showWordLimit: Boolean, errorMessageAlign: String, readonly: {
type: Boolean,
observer: 'setShowClear',
},
clearable: {
}, clearable: {
type: Boolean,
observer: 'setShowClear',
},
clearTrigger: {
}, clearTrigger: {
type: String,
value: 'focus',
},
border: {
}, border: {
type: Boolean,
value: true,
},
titleWidth: {
}, titleWidth: {
type: String,
value: '6.2em',
},
clearIcon: {
}, clearIcon: {
type: String,
value: 'clear',
},
}
),
} }),
data: {
focused: false,
innerValue: '',
@ -82,8 +47,7 @@ component_1.VantComponent({
},
methods: {
onInput: function (event) {
var _a = (event.detail || {}).value,
value = _a === void 0 ? '' : _a;
var _a = (event.detail || {}).value, value = _a === void 0 ? '' : _a;
this.value = value;
this.setShowClear();
this.emitChange();
@ -115,8 +79,7 @@ component_1.VantComponent({
});
},
onConfirm: function (event) {
var _a = (event.detail || {}).value,
value = _a === void 0 ? '' : _a;
var _a = (event.detail || {}).value, value = _a === void 0 ? '' : _a;
this.value = value;
this.setShowClear();
this.$emit('confirm', value);
@ -144,22 +107,16 @@ component_1.VantComponent({
});
},
setShowClear: function () {
var _a = this.data,
clearable = _a.clearable,
readonly = _a.readonly,
clearTrigger = _a.clearTrigger;
var _b = this,
focused = _b.focused,
value = _b.value;
var _a = this.data, clearable = _a.clearable, readonly = _a.readonly, clearTrigger = _a.clearTrigger;
var _b = this, focused = _b.focused, value = _b.value;
var showClear = false;
if (clearable && !readonly) {
var hasValue = !!value;
var trigger =
clearTrigger === 'always' || (clearTrigger === 'focus' && focused);
var trigger = clearTrigger === 'always' || (clearTrigger === 'focus' && focused);
showClear = hasValue && trigger;
}
this.setData({ showClear: showClear });
},
noop: function () {},
noop: function () { },
},
});

View File

@ -1,5 +1,5 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.textareaProps = exports.inputProps = exports.commonProps = void 0;
exports.commonProps = {
value: {

View File

@ -1,9 +1,9 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component');
var relation_1 = require('../common/relation');
var button_1 = require('../mixins/button');
var link_1 = require('../mixins/link');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
var relation_1 = require("../common/relation");
var button_1 = require("../mixins/button");
var link_1 = require("../mixins/link");
component_1.VantComponent({
mixins: [link_1.link, button_1.button],
relation: relation_1.useParent('goods-action'),
@ -28,8 +28,7 @@ component_1.VantComponent({
return;
}
var index = this.index;
var _a = this.parent.children,
children = _a === void 0 ? [] : _a;
var _a = this.parent.children, children = _a === void 0 ? [] : _a;
this.setData({
isFirst: index === 0,
isLast: index === children.length - 1,

View File

@ -1,8 +1,8 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component');
var button_1 = require('../mixins/button');
var link_1 = require('../mixins/link');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
var button_1 = require("../mixins/button");
var link_1 = require("../mixins/link");
component_1.VantComponent({
classes: ['icon-class', 'text-class'],
mixins: [link_1.link, button_1.button],

View File

@ -1,7 +1,7 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component');
var relation_1 = require('../common/relation');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
var relation_1 = require("../common/relation");
component_1.VantComponent({
relation: relation_1.useChildren('goods-action-button', function () {
this.children.forEach(function (item) {

View File

@ -1,8 +1,8 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component');
var relation_1 = require('../common/relation');
var link_1 = require('../mixins/link');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
var relation_1 = require("../common/relation");
var link_1 = require("../mixins/link");
component_1.VantComponent({
relation: relation_1.useParent('grid'),
classes: ['content-class', 'icon-class', 'text-class'],
@ -31,18 +31,8 @@ component_1.VantComponent({
if (!this.parent) {
return;
}
var _a = this.parent,
data = _a.data,
children = _a.children;
var columnNum = data.columnNum,
border = data.border,
square = data.square,
gutter = data.gutter,
clickable = data.clickable,
center = data.center,
direction = data.direction,
reverse = data.reverse,
iconSize = data.iconSize;
var _a = this.parent, data = _a.data, children = _a.children;
var columnNum = data.columnNum, border = data.border, square = data.square, gutter = data.gutter, clickable = data.clickable, center = data.center, direction = data.direction, reverse = data.reverse, iconSize = data.iconSize;
this.setData({
center: center,
border: border,

View File

@ -1,7 +1,7 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component');
var relation_1 = require('../common/relation');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
var relation_1 = require("../common/relation");
component_1.VantComponent({
relation: relation_1.useChildren('grid-item'),
props: {

View File

@ -1,6 +1,6 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
component_1.VantComponent({
props: {
dot: Boolean,

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var component_1 = require('../common/component');
var button_1 = require('../mixins/button');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
var button_1 = require("../mixins/button");
component_1.VantComponent({
mixins: [button_1.button],
classes: ['custom-class', 'loading-class', 'error-class', 'image-class'],

View File

@ -1,8 +1,8 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var utils_1 = require('../common/utils');
var component_1 = require('../common/component');
var relation_1 = require('../common/relation');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("../common/utils");
var component_1 = require("../common/component");
var relation_1 = require("../common/relation");
component_1.VantComponent({
relation: relation_1.useParent('index-bar'),
props: {

View File

@ -1,10 +1,10 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var color_1 = require('../common/color');
var component_1 = require('../common/component');
var relation_1 = require('../common/relation');
var utils_1 = require('../common/utils');
var page_scroll_1 = require('../mixins/page-scroll');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var color_1 = require("../common/color");
var component_1 = require("../common/component");
var relation_1 = require("../common/relation");
var utils_1 = require("../common/utils");
var page_scroll_1 = require("../mixins/page-scroll");
var indexList = function () {
var indexList = [];
var charCodeOfA = 'A'.charCodeAt(0);
@ -41,8 +41,7 @@ component_1.VantComponent({
},
mixins: [
page_scroll_1.pageScrollMixin(function (event) {
this.scrollTop =
(event === null || event === void 0 ? void 0 : event.scrollTop) || 0;
this.scrollTop = (event === null || event === void 0 ? void 0 : event.scrollTop) || 0;
this.onScroll();
}),
],
@ -79,18 +78,14 @@ component_1.VantComponent({
},
setAnchorsRect: function () {
var _this = this;
return Promise.all(
this.children.map(function (anchor) {
return utils_1
.getRect(anchor, '.van-index-anchor-wrapper')
.then(function (rect) {
return Promise.all(this.children.map(function (anchor) {
return utils_1.getRect(anchor, '.van-index-anchor-wrapper').then(function (rect) {
Object.assign(anchor, {
height: rect.height,
top: rect.top + _this.scrollTop,
});
});
})
);
}));
},
setListRect: function () {
var _this = this;
@ -103,9 +98,7 @@ component_1.VantComponent({
},
setSiderbarRect: function () {
var _this = this;
return utils_1
.getRect(this, '.van-index-bar__sidebar')
.then(function (res) {
return utils_1.getRect(this, '.van-index-bar__sidebar').then(function (res) {
if (!utils_1.isDef(res)) {
return;
}
@ -116,8 +109,7 @@ component_1.VantComponent({
});
},
setDiffData: function (_a) {
var target = _a.target,
data = _a.data;
var target = _a.target, data = _a.data;
var diffData = {};
Object.keys(data).forEach(function (key) {
if (target.data[key] !== data[key]) {
@ -129,22 +121,14 @@ component_1.VantComponent({
}
},
getAnchorRect: function (anchor) {
return utils_1
.getRect(anchor, '.van-index-anchor-wrapper')
.then(function (rect) {
return {
return utils_1.getRect(anchor, '.van-index-anchor-wrapper').then(function (rect) { return ({
height: rect.height,
top: rect.top,
};
});
}); });
},
getActiveAnchorIndex: function () {
var _a = this,
children = _a.children,
scrollTop = _a.scrollTop;
var _b = this.data,
sticky = _b.sticky,
stickyOffsetTop = _b.stickyOffsetTop;
var _a = this, children = _a.children, scrollTop = _a.scrollTop;
var _b = this.data, sticky = _b.sticky, stickyOffsetTop = _b.stickyOffsetTop;
for (var i = this.children.length - 1; i >= 0; i--) {
var preAnchorHeight = i > 0 ? children[i - 1].height : 0;
var reachTop = sticky ? preAnchorHeight + stickyOffsetTop : 0;
@ -156,18 +140,11 @@ component_1.VantComponent({
},
onScroll: function () {
var _this = this;
var _a = this,
_b = _a.children,
children = _b === void 0 ? [] : _b,
scrollTop = _a.scrollTop;
var _a = this, _b = _a.children, children = _b === void 0 ? [] : _b, scrollTop = _a.scrollTop;
if (!children.length) {
return;
}
var _c = this.data,
sticky = _c.sticky,
stickyOffsetTop = _c.stickyOffsetTop,
zIndex = _c.zIndex,
highlightColor = _c.highlightColor;
var _c = this.data, sticky = _c.sticky, stickyOffsetTop = _c.stickyOffsetTop, zIndex = _c.zIndex, highlightColor = _c.highlightColor;
var active = this.getActiveAnchorIndex();
this.setDiffData({
target: this,
@ -184,21 +161,10 @@ component_1.VantComponent({
children.forEach(function (item, index) {
if (index === active) {
var wrapperStyle = '';
var anchorStyle =
'\n color: ' + highlightColor + ';\n ';
var anchorStyle = "\n color: " + highlightColor + ";\n ";
if (isActiveAnchorSticky_1) {
wrapperStyle =
'\n height: ' +
children[index].height +
'px;\n ';
anchorStyle =
'\n position: fixed;\n top: ' +
stickyOffsetTop +
'px;\n z-index: ' +
zIndex +
';\n color: ' +
highlightColor +
';\n ';
wrapperStyle = "\n height: " + children[index].height + "px;\n ";
anchorStyle = "\n position: fixed;\n top: " + stickyOffsetTop + "px;\n z-index: " + zIndex + ";\n color: " + highlightColor + ";\n ";
}
_this.setDiffData({
target: item,
@ -208,23 +174,16 @@ component_1.VantComponent({
wrapperStyle: wrapperStyle,
},
});
} else if (index === active - 1) {
}
else if (index === active - 1) {
var currentAnchor = children[index];
var currentOffsetTop = currentAnchor.top;
var targetOffsetTop =
index === children.length - 1
var targetOffsetTop = index === children.length - 1
? _this.top
: children[index + 1].top;
var parentOffsetHeight = targetOffsetTop - currentOffsetTop;
var translateY = parentOffsetHeight - currentAnchor.height;
var anchorStyle =
'\n position: relative;\n transform: translate3d(0, ' +
translateY +
'px, 0);\n z-index: ' +
zIndex +
';\n color: ' +
highlightColor +
';\n ';
var anchorStyle = "\n position: relative;\n transform: translate3d(0, " + translateY + "px, 0);\n z-index: " + zIndex + ";\n color: " + highlightColor + ";\n ";
_this.setDiffData({
target: item,
data: {
@ -232,7 +191,8 @@ component_1.VantComponent({
anchorStyle: anchorStyle,
},
});
} else {
}
else {
_this.setDiffData({
target: item,
data: {
@ -255,7 +215,8 @@ component_1.VantComponent({
var index = Math.floor((touch.clientY - this.sidebar.top) / itemHeight);
if (index < 0) {
index = 0;
} else if (index > sidebarLength - 1) {
}
else if (index > sidebarLength - 1) {
index = sidebarLength - 1;
}
this.scrollToAnchor(index);
@ -269,9 +230,7 @@ component_1.VantComponent({
return;
}
this.scrollToAnchorIndex = index;
var anchor = this.children.find(function (item) {
return item.data.index === _this.data.indexList[index];
});
var anchor = this.children.find(function (item) { return item.data.index === _this.data.indexList[index]; });
if (anchor) {
anchor.scrollIntoView(this.scrollTop);
this.$emit('select', anchor.data.index);

Some files were not shown because too many files have changed in this diff Show More