build: compile 1.10.6

This commit is contained in:
landluck 2022-11-06 16:15:30 +08:00
parent 93aafc4180
commit 3599fdab83
25 changed files with 131 additions and 91 deletions

2
.npmrc
View File

@ -1 +1 @@
registry=https://registry.npmmirror.com/
registry=https://registry.npmjs.org

View File

@ -5,7 +5,7 @@
id="{{ id }}"
data-detail="{{ dataset }}"
class="custom-class {{ utils.bem('button', [type, size, { block, round, plain, square, loading, disabled, hairline, unclickable: disabled || loading }]) }} {{ hairline ? 'van-hairline--surround' : '' }}"
hover-class="van-button--active hover-class"
hover-class="{{ disabled || loading ? '' : 'van-button--active hover-class'}}"
lang="{{ lang }}"
form-type="{{ formType }}"
style="{{ computed.rootStyle({ plain, color, customStyle }) }}"

View File

@ -1,7 +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): 0 | 1 | -1;
export declare function compareDay(day1: Date | number, day2: Date | number): 0 | 1 | -1;
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

@ -1,12 +1,12 @@
/// <reference types="miniprogram-api-typings" />
/// <reference types="node" />
/// <reference types="miniprogram-api-typings" />
/// <reference types="miniprogram-api-typings" />
/// <reference types="miniprogram-api-typings" />
/// <reference types="miniprogram-api-typings" />
export { isDef } from './validator';
export { getSystemInfoSync } from './version';
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): NodeJS.Timeout | WechatMiniprogram.NodesRef;
export declare function pickExclude(obj: unknown, keys: string[]): {};

10
dist/common/utils.js vendored
View File

@ -1,6 +1,7 @@
import { isDef, isNumber, isPlainObject, isPromise } from './validator';
import { canIUseGroupSetData, canIUseNextTick } from './version';
import { canIUseGroupSetData, canIUseNextTick, getSystemInfoSync } from './version';
export { isDef } from './validator';
export { getSystemInfoSync } from './version';
export function range(num, min, max) {
return Math.min(Math.max(num, min), max);
}
@ -14,13 +15,6 @@ export function nextTick(cb) {
}, 1000 / 30);
}
}
let systemInfo;
export function getSystemInfoSync() {
if (systemInfo == null) {
systemInfo = wx.getSystemInfoSync();
}
return systemInfo;
}
export function addUnit(value) {
if (!isDef(value)) {
return undefined;

View File

@ -1,3 +1,5 @@
/// <reference types="miniprogram-api-typings" />
export declare function getSystemInfoSync(): WechatMiniprogram.SystemInfo;
export declare function canIUseModel(): boolean;
export declare function canIUseFormFieldButton(): boolean;
export declare function canIUseAnimate(): boolean;

View File

@ -1,4 +1,10 @@
import { getSystemInfoSync } from './utils';
let systemInfo;
export function getSystemInfoSync() {
if (systemInfo == null) {
systemInfo = wx.getSystemInfoSync();
}
return systemInfo;
}
function compareVersion(v1, v2) {
v1 = v1.split('.');
v2 = v2.split('.');
@ -38,7 +44,12 @@ export function canIUseGroupSetData() {
return gte('2.4.0');
}
export function canIUseNextTick() {
return wx.canIUse('nextTick');
try {
return wx.canIUse('nextTick');
}
catch (e) {
return gte('2.7.1');
}
}
export function canIUseCanvas2d() {
return gte('2.9.0');

View File

@ -1,6 +1,7 @@
/// <reference types="miniprogram-api-typings" />
/// <reference types="miniprogram-api-typings" />
export declare type Action = 'confirm' | 'cancel' | 'overlay';
declare type DialogContext = WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance;
interface DialogOptions {
lang?: string;
show?: boolean;
@ -8,7 +9,7 @@ interface DialogOptions {
width?: string | number | null;
zIndex?: number;
theme?: string;
context?: WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance;
context?: (() => DialogContext) | DialogContext;
message?: string;
overlay?: boolean;
selector?: string;

View File

@ -30,7 +30,9 @@ function getContext() {
const Dialog = (options) => {
options = Object.assign(Object.assign({}, currentOptions), options);
return new Promise((resolve, reject) => {
const context = options.context || getContext();
const context = (typeof options.context === 'function'
? options.context()
: options.context) || getContext();
const dialog = context.selectComponent(options.selector);
delete options.context;
delete options.selector;

View File

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

View File

@ -1,3 +1,4 @@
import { isFunction } from '../common/validator';
import { getCurrentPage, isDef } from '../common/utils';
function onPageScroll(event) {
const { vanPageScroller = [] } = getCurrentPage();
@ -8,29 +9,34 @@ function onPageScroll(event) {
}
});
}
export const pageScrollMixin = (scroller) => Behavior({
attached() {
const page = getCurrentPage();
if (!isDef(page)) {
return;
}
if (Array.isArray(page.vanPageScroller)) {
page.vanPageScroller.push(scroller.bind(this));
}
else {
page.vanPageScroller =
typeof page.onPageScroll === 'function'
? [page.onPageScroll.bind(page), scroller.bind(this)]
: [scroller.bind(this)];
}
page.onPageScroll = onPageScroll;
},
detached() {
var _a;
const page = getCurrentPage();
if (isDef(page)) {
page.vanPageScroller =
((_a = page.vanPageScroller) === null || _a === void 0 ? void 0 : _a.filter((item) => item !== scroller)) || [];
}
},
});
export function pageScrollMixin(scroller) {
return Behavior({
attached() {
const page = getCurrentPage();
if (!isDef(page)) {
return;
}
const _scroller = scroller.bind(this);
const { vanPageScroller = [] } = page;
if (!vanPageScroller.length && isFunction(page.onPageScroll)) {
vanPageScroller.push(page.onPageScroll.bind(page));
}
vanPageScroller.push(_scroller);
page.vanPageScroller = vanPageScroller;
page.onPageScroll = onPageScroll;
this._scroller = _scroller;
},
detached() {
const page = getCurrentPage();
if (!isDef(page) || !isDef(page.vanPageScroller)) {
return;
}
const { vanPageScroller } = page;
const index = vanPageScroller.findIndex(v => v === this._scroller);
if (index > -1) {
page.vanPageScroller.splice(index, 1);
}
this._scroller = undefined;
},
});
}

View File

@ -1,7 +1,7 @@
<van-transition
wx:if="{{ lockScroll }}"
show="{{ show }}"
custom-class="van-overlay"
custom-class="van-overlay custom-class"
custom-style="z-index: {{ zIndex }}; {{ customStyle }}"
duration="{{ duration }}"
bind:tap="onClick"
@ -12,7 +12,7 @@
<van-transition
wx:else
show="{{ show }}"
custom-class="van-overlay"
custom-class="van-overlay custom-class"
custom-style="z-index: {{ zIndex }}; {{ customStyle }}"
duration="{{ duration }}"
bind:tap="onClick"

10
dist/slider/index.js vendored
View File

@ -163,15 +163,19 @@ VantComponent({
const { max, min } = this.data;
return max - min;
},
getOffsetWidth(current, min) {
const scope = this.getScope();
// 避免最小值小于最小step时出现负数情况
return `${Math.max((current - min) * 100 / scope, 0)}%`;
},
// 计算选中条的长度百分比
calcMainAxis() {
const { value } = this;
const { min } = this.data;
const scope = this.getScope();
if (this.isRange(value)) {
return `${((value[1] - value[0]) * 100) / scope}%`;
return this.getOffsetWidth(value[1], value[0]);
}
return `${((value - Number(min)) * 100) / scope}%`;
return this.getOffsetWidth(value, Number(min));
},
// 计算选中条的开始位置的偏移量
calcOffset() {

View File

@ -5,7 +5,7 @@
id="{{ id }}"
data-detail="{{ dataset }}"
class="custom-class {{ utils.bem('button', [type, size, { block, round, plain, square, loading, disabled, hairline, unclickable: disabled || loading }]) }} {{ hairline ? 'van-hairline--surround' : '' }}"
hover-class="van-button--active hover-class"
hover-class="{{ disabled || loading ? '' : 'van-button--active hover-class'}}"
lang="{{ lang }}"
form-type="{{ formType }}"
style="{{ computed.rootStyle({ plain, color, customStyle }) }}"

View File

@ -1,7 +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): 0 | 1 | -1;
export declare function compareDay(day1: Date | number, day2: Date | number): 0 | 1 | -1;
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

@ -1,12 +1,12 @@
/// <reference types="miniprogram-api-typings" />
/// <reference types="node" />
/// <reference types="miniprogram-api-typings" />
/// <reference types="miniprogram-api-typings" />
/// <reference types="miniprogram-api-typings" />
/// <reference types="miniprogram-api-typings" />
export { isDef } from './validator';
export { getSystemInfoSync } from './version';
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): NodeJS.Timeout | WechatMiniprogram.NodesRef;
export declare function pickExclude(obj: unknown, keys: string[]): {};

View File

@ -1,10 +1,12 @@
"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;
exports.getCurrentPage = exports.toPromise = exports.groupSetData = exports.getAllRect = exports.getRect = exports.pickExclude = exports.requestAnimationFrame = exports.addUnit = exports.nextTick = exports.range = exports.getSystemInfoSync = 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 version_2 = require("./version");
Object.defineProperty(exports, "getSystemInfoSync", { enumerable: true, get: function () { return version_2.getSystemInfoSync; } });
function range(num, min, max) {
return Math.min(Math.max(num, min), max);
}
@ -20,14 +22,6 @@ function nextTick(cb) {
}
}
exports.nextTick = nextTick;
var systemInfo;
function getSystemInfoSync() {
if (systemInfo == null) {
systemInfo = wx.getSystemInfoSync();
}
return systemInfo;
}
exports.getSystemInfoSync = getSystemInfoSync;
function addUnit(value) {
if (!(0, validator_1.isDef)(value)) {
return undefined;
@ -37,7 +31,7 @@ function addUnit(value) {
}
exports.addUnit = addUnit;
function requestAnimationFrame(cb) {
var systemInfo = getSystemInfoSync();
var systemInfo = (0, version_1.getSystemInfoSync)();
if (systemInfo.platform === 'devtools') {
return setTimeout(function () {
cb();

View File

@ -1,3 +1,5 @@
/// <reference types="miniprogram-api-typings" />
export declare function getSystemInfoSync(): WechatMiniprogram.SystemInfo;
export declare function canIUseModel(): boolean;
export declare function canIUseFormFieldButton(): boolean;
export declare function canIUseAnimate(): boolean;

View File

@ -1,7 +1,14 @@
"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");
exports.canIUseGetUserProfile = exports.canIUseCanvas2d = exports.canIUseNextTick = exports.canIUseGroupSetData = exports.canIUseAnimate = exports.canIUseFormFieldButton = exports.canIUseModel = exports.getSystemInfoSync = void 0;
var systemInfo;
function getSystemInfoSync() {
if (systemInfo == null) {
systemInfo = wx.getSystemInfoSync();
}
return systemInfo;
}
exports.getSystemInfoSync = getSystemInfoSync;
function compareVersion(v1, v2) {
v1 = v1.split('.');
v2 = v2.split('.');
@ -25,7 +32,7 @@ function compareVersion(v1, v2) {
return 0;
}
function gte(version) {
var system = (0, utils_1.getSystemInfoSync)();
var system = getSystemInfoSync();
return compareVersion(system.SDKVersion, version) >= 0;
}
function canIUseModel() {
@ -45,7 +52,12 @@ function canIUseGroupSetData() {
}
exports.canIUseGroupSetData = canIUseGroupSetData;
function canIUseNextTick() {
return wx.canIUse('nextTick');
try {
return wx.canIUse('nextTick');
}
catch (e) {
return gte('2.7.1');
}
}
exports.canIUseNextTick = canIUseNextTick;
function canIUseCanvas2d() {

View File

@ -1,6 +1,7 @@
/// <reference types="miniprogram-api-typings" />
/// <reference types="miniprogram-api-typings" />
export declare type Action = 'confirm' | 'cancel' | 'overlay';
declare type DialogContext = WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance;
interface DialogOptions {
lang?: string;
show?: boolean;
@ -8,7 +9,7 @@ interface DialogOptions {
width?: string | number | null;
zIndex?: number;
theme?: string;
context?: WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance;
context?: (() => DialogContext) | DialogContext;
message?: string;
overlay?: boolean;
selector?: string;

View File

@ -43,7 +43,9 @@ function getContext() {
var Dialog = function (options) {
options = __assign(__assign({}, currentOptions), options);
return new Promise(function (resolve, reject) {
var context = options.context || getContext();
var context = (typeof options.context === 'function'
? options.context()
: options.context) || getContext();
var dialog = context.selectComponent(options.selector);
delete options.context;
delete options.selector;

View File

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

View File

@ -1,6 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.pageScrollMixin = void 0;
var validator_1 = require("../common/validator");
var utils_1 = require("../common/utils");
function onPageScroll(event) {
var _a = (0, utils_1.getCurrentPage)().vanPageScroller, vanPageScroller = _a === void 0 ? [] : _a;
@ -11,32 +12,36 @@ function onPageScroll(event) {
}
});
}
var pageScrollMixin = function (scroller) {
function pageScrollMixin(scroller) {
return Behavior({
attached: function () {
var page = (0, utils_1.getCurrentPage)();
if (!(0, utils_1.isDef)(page)) {
return;
}
if (Array.isArray(page.vanPageScroller)) {
page.vanPageScroller.push(scroller.bind(this));
}
else {
page.vanPageScroller =
typeof page.onPageScroll === 'function'
? [page.onPageScroll.bind(page), scroller.bind(this)]
: [scroller.bind(this)];
var _scroller = scroller.bind(this);
var _a = page.vanPageScroller, vanPageScroller = _a === void 0 ? [] : _a;
if (!vanPageScroller.length && (0, validator_1.isFunction)(page.onPageScroll)) {
vanPageScroller.push(page.onPageScroll.bind(page));
}
vanPageScroller.push(_scroller);
page.vanPageScroller = vanPageScroller;
page.onPageScroll = onPageScroll;
this._scroller = _scroller;
},
detached: function () {
var _a;
var _this = this;
var page = (0, utils_1.getCurrentPage)();
if ((0, utils_1.isDef)(page)) {
page.vanPageScroller =
((_a = page.vanPageScroller) === null || _a === void 0 ? void 0 : _a.filter(function (item) { return item !== scroller; })) || [];
if (!(0, utils_1.isDef)(page) || !(0, utils_1.isDef)(page.vanPageScroller)) {
return;
}
var vanPageScroller = page.vanPageScroller;
var index = vanPageScroller.findIndex(function (v) { return v === _this._scroller; });
if (index > -1) {
page.vanPageScroller.splice(index, 1);
}
this._scroller = undefined;
},
});
};
}
exports.pageScrollMixin = pageScrollMixin;

View File

@ -1,7 +1,7 @@
<van-transition
wx:if="{{ lockScroll }}"
show="{{ show }}"
custom-class="van-overlay"
custom-class="van-overlay custom-class"
custom-style="z-index: {{ zIndex }}; {{ customStyle }}"
duration="{{ duration }}"
bind:tap="onClick"
@ -12,7 +12,7 @@
<van-transition
wx:else
show="{{ show }}"
custom-class="van-overlay"
custom-class="van-overlay custom-class"
custom-style="z-index: {{ zIndex }}; {{ customStyle }}"
duration="{{ duration }}"
bind:tap="onClick"

View File

@ -161,15 +161,19 @@ var utils_1 = require("../common/utils");
var _a = this.data, max = _a.max, min = _a.min;
return max - min;
},
getOffsetWidth: function (current, min) {
var scope = this.getScope();
// 避免最小值小于最小step时出现负数情况
return "".concat(Math.max((current - min) * 100 / scope, 0), "%");
},
// 计算选中条的长度百分比
calcMainAxis: function () {
var value = this.value;
var min = this.data.min;
var scope = this.getScope();
if (this.isRange(value)) {
return "".concat(((value[1] - value[0]) * 100) / scope, "%");
return this.getOffsetWidth(value[1], value[0]);
}
return "".concat(((value - Number(min)) * 100) / scope, "%");
return this.getOffsetWidth(value, Number(min));
},
// 计算选中条的开始位置的偏移量
calcOffset: function () {