build: compile 1.10.12

This commit is contained in:
landluck 2023-01-16 10:45:36 +08:00
parent 231aa05e8d
commit 7cec5690ce
16 changed files with 134 additions and 52 deletions

View File

@ -159,7 +159,7 @@ VantComponent({
return date; return date;
}, },
getInitialDate(defaultDate = null) { getInitialDate(defaultDate = null) {
const { type, minDate, maxDate } = this.data; const { type, minDate, maxDate, allowSameDay } = this.data;
const now = getToday().getTime(); const now = getToday().getTime();
if (type === 'range') { if (type === 'range') {
if (!Array.isArray(defaultDate)) { if (!Array.isArray(defaultDate)) {
@ -167,7 +167,8 @@ VantComponent({
} }
const [startDay, endDay] = defaultDate || []; const [startDay, endDay] = defaultDate || [];
const start = this.limitDateRange(startDay || now, minDate, getPrevDay(new Date(maxDate)).getTime()); const start = this.limitDateRange(startDay || now, minDate, getPrevDay(new Date(maxDate)).getTime());
const end = this.limitDateRange(endDay || now, getNextDay(new Date(minDate)).getTime()); const date = getTime(endDay || now);
const end = this.limitDateRange(date, allowSameDay ? date : getNextDay(new Date(minDate)).getTime());
return [start, end]; return [start, end];
} }
if (type === 'multiple') { if (type === 'multiple') {

View File

@ -11,6 +11,7 @@ function VantComponent(vantOptions) {
mapKeys(vantOptions, options, { mapKeys(vantOptions, options, {
data: 'data', data: 'data',
props: 'properties', props: 'properties',
watch: 'observers',
mixins: 'behaviors', mixins: 'behaviors',
methods: 'methods', methods: 'methods',
beforeCreate: 'created', beforeCreate: 'created',

View File

@ -15,6 +15,7 @@ export declare type VantComponentOptions<Data extends WechatMiniprogram.Componen
relations: Record<string, WechatMiniprogram.Component.RelationOption>; relations: Record<string, WechatMiniprogram.Component.RelationOption>;
mixin: string; mixin: string;
}; };
watch?: Record<string, (...args: any[]) => any>;
methods?: Methods; methods?: Methods;
beforeCreate?: () => void; beforeCreate?: () => void;
created?: () => void; created?: () => void;

View File

@ -26,6 +26,10 @@ VantComponent({
observer: 'rerender', observer: 'rerender',
}, },
popupStyle: String, popupStyle: String,
useBeforeToggle: {
type: Boolean,
value: false,
},
}, },
data: { data: {
transition: true, transition: true,
@ -77,7 +81,6 @@ VantComponent({
} }
}, },
toggle(show, options = {}) { toggle(show, options = {}) {
var _a;
const { showPopup } = this.data; const { showPopup } = this.data;
if (typeof show !== 'boolean') { if (typeof show !== 'boolean') {
show = !showPopup; show = !showPopup;
@ -85,19 +88,37 @@ VantComponent({
if (show === showPopup) { if (show === showPopup) {
return; return;
} }
this.setData({ this.onBeforeToggle(show).then((status) => {
transition: !options.immediate, var _a;
showPopup: show, if (!status) {
}); return;
if (show) { }
(_a = this.parent) === null || _a === void 0 ? void 0 : _a.getChildWrapperStyle().then((wrapperStyle) => { this.setData({
this.setData({ wrapperStyle, showWrapper: true }); transition: !options.immediate,
this.rerender(); showPopup: show,
}); });
if (show) {
(_a = this.parent) === null || _a === void 0 ? void 0 : _a.getChildWrapperStyle().then((wrapperStyle) => {
this.setData({ wrapperStyle, showWrapper: true });
this.rerender();
});
}
else {
this.rerender();
}
});
},
onBeforeToggle(status) {
const { useBeforeToggle } = this.data;
if (!useBeforeToggle) {
return Promise.resolve(true);
} }
else { return new Promise((resolve) => {
this.rerender(); this.$emit('before-toggle', {
} status,
callback: (value) => resolve(value),
});
});
}, },
}, },
}); });

19
dist/field/index.js vendored
View File

@ -22,6 +22,9 @@ VantComponent({
}, clearIcon: { }, clearIcon: {
type: String, type: String,
value: 'clear', value: 'clear',
}, extraEventParams: {
type: Boolean,
value: false,
} }), } }),
data: { data: {
focused: false, focused: false,
@ -37,7 +40,7 @@ VantComponent({
const { value = '' } = event.detail || {}; const { value = '' } = event.detail || {};
this.value = value; this.value = value;
this.setShowClear(); this.setShowClear();
this.emitChange(); this.emitChange(event.detail);
}, },
onFocus(event) { onFocus(event) {
this.focused = true; this.focused = true;
@ -60,7 +63,7 @@ VantComponent({
this.value = ''; this.value = '';
this.setShowClear(); this.setShowClear();
nextTick(() => { nextTick(() => {
this.emitChange(); this.emitChange({ value: '' });
this.$emit('clear', ''); this.$emit('clear', '');
}); });
}, },
@ -76,7 +79,7 @@ VantComponent({
if (value === '') { if (value === '') {
this.setData({ innerValue: '' }); this.setData({ innerValue: '' });
} }
this.emitChange(); this.emitChange({ value });
}, },
onLineChange(event) { onLineChange(event) {
this.$emit('linechange', event.detail); this.$emit('linechange', event.detail);
@ -84,11 +87,13 @@ VantComponent({
onKeyboardHeightChange(event) { onKeyboardHeightChange(event) {
this.$emit('keyboardheightchange', event.detail); this.$emit('keyboardheightchange', event.detail);
}, },
emitChange() { emitChange(detail) {
this.setData({ value: this.value }); const { extraEventParams } = this.data;
this.setData({ value: detail.value });
nextTick(() => { nextTick(() => {
this.$emit('input', this.value); const data = extraEventParams ? detail : detail.value;
this.$emit('change', this.value); this.$emit('input', data);
this.$emit('change', data);
}); });
}, },
setShowClear() { setShowClear() {

8
dist/field/types.d.ts vendored Normal file
View File

@ -0,0 +1,8 @@
export interface InputDetails {
/** 输入框内容 */
value: string;
/** 光标位置 */
cursor?: number;
/** keyCode 为键值 (目前工具还不支持返回keyCode参数) `2.1.0` 起支持 */
keyCode?: number;
}

1
dist/field/types.js vendored Normal file
View File

@ -0,0 +1 @@
export {};

12
dist/stepper/index.js vendored
View File

@ -16,7 +16,6 @@ VantComponent({
props: { props: {
value: { value: {
type: null, type: null,
observer: 'observeValue',
}, },
integer: { integer: {
type: Boolean, type: Boolean,
@ -66,6 +65,11 @@ VantComponent({
data: { data: {
currentValue: '', currentValue: '',
}, },
watch: {
value() {
this.observeValue();
},
},
created() { created() {
this.setData({ this.setData({
currentValue: this.format(this.data.value), currentValue: this.format(this.data.value),
@ -73,10 +77,8 @@ VantComponent({
}, },
methods: { methods: {
observeValue() { observeValue() {
const { value, currentValue } = this.data; const { value } = this.data;
if (!equal(value, currentValue)) { this.setData({ currentValue: this.format(value) });
this.setData({ currentValue: this.format(value) });
}
}, },
check() { check() {
const val = this.format(this.data.currentValue); const val = this.format(this.data.currentValue);

View File

@ -180,7 +180,7 @@ var getTime = function (date) {
getInitialDate: function (defaultDate) { getInitialDate: function (defaultDate) {
var _this = this; var _this = this;
if (defaultDate === void 0) { defaultDate = null; } if (defaultDate === void 0) { defaultDate = null; }
var _a = this.data, type = _a.type, minDate = _a.minDate, maxDate = _a.maxDate; var _a = this.data, type = _a.type, minDate = _a.minDate, maxDate = _a.maxDate, allowSameDay = _a.allowSameDay;
var now = (0, utils_1.getToday)().getTime(); var now = (0, utils_1.getToday)().getTime();
if (type === 'range') { if (type === 'range') {
if (!Array.isArray(defaultDate)) { if (!Array.isArray(defaultDate)) {
@ -188,7 +188,8 @@ var getTime = function (date) {
} }
var _b = defaultDate || [], startDay = _b[0], endDay = _b[1]; var _b = defaultDate || [], startDay = _b[0], endDay = _b[1];
var start = this.limitDateRange(startDay || now, minDate, (0, utils_1.getPrevDay)(new Date(maxDate)).getTime()); var start = this.limitDateRange(startDay || now, minDate, (0, utils_1.getPrevDay)(new Date(maxDate)).getTime());
var end = this.limitDateRange(endDay || now, (0, utils_1.getNextDay)(new Date(minDate)).getTime()); var date = getTime(endDay || now);
var end = this.limitDateRange(date, allowSameDay ? date : (0, utils_1.getNextDay)(new Date(minDate)).getTime());
return [start, end]; return [start, end];
} }
if (type === 'multiple') { if (type === 'multiple') {

View File

@ -14,6 +14,7 @@ function VantComponent(vantOptions) {
mapKeys(vantOptions, options, { mapKeys(vantOptions, options, {
data: 'data', data: 'data',
props: 'properties', props: 'properties',
watch: 'observers',
mixins: 'behaviors', mixins: 'behaviors',
methods: 'methods', methods: 'methods',
beforeCreate: 'created', beforeCreate: 'created',

View File

@ -15,6 +15,7 @@ export declare type VantComponentOptions<Data extends WechatMiniprogram.Componen
relations: Record<string, WechatMiniprogram.Component.RelationOption>; relations: Record<string, WechatMiniprogram.Component.RelationOption>;
mixin: string; mixin: string;
}; };
watch?: Record<string, (...args: any[]) => any>;
methods?: Methods; methods?: Methods;
beforeCreate?: () => void; beforeCreate?: () => void;
created?: () => void; created?: () => void;

View File

@ -28,6 +28,10 @@ var component_1 = require("../common/component");
observer: 'rerender', observer: 'rerender',
}, },
popupStyle: String, popupStyle: String,
useBeforeToggle: {
type: Boolean,
value: false,
},
}, },
data: { data: {
transition: true, transition: true,
@ -81,7 +85,6 @@ var component_1 = require("../common/component");
}, },
toggle: function (show, options) { toggle: function (show, options) {
var _this = this; var _this = this;
var _a;
if (options === void 0) { options = {}; } if (options === void 0) { options = {}; }
var showPopup = this.data.showPopup; var showPopup = this.data.showPopup;
if (typeof show !== 'boolean') { if (typeof show !== 'boolean') {
@ -90,19 +93,38 @@ var component_1 = require("../common/component");
if (show === showPopup) { if (show === showPopup) {
return; return;
} }
this.setData({ this.onBeforeToggle(show).then(function (status) {
transition: !options.immediate, var _a;
showPopup: show, if (!status) {
}); return;
if (show) { }
(_a = this.parent) === null || _a === void 0 ? void 0 : _a.getChildWrapperStyle().then(function (wrapperStyle) { _this.setData({
_this.setData({ wrapperStyle: wrapperStyle, showWrapper: true }); transition: !options.immediate,
_this.rerender(); showPopup: show,
}); });
if (show) {
(_a = _this.parent) === null || _a === void 0 ? void 0 : _a.getChildWrapperStyle().then(function (wrapperStyle) {
_this.setData({ wrapperStyle: wrapperStyle, showWrapper: true });
_this.rerender();
});
}
else {
_this.rerender();
}
});
},
onBeforeToggle: function (status) {
var _this = this;
var useBeforeToggle = this.data.useBeforeToggle;
if (!useBeforeToggle) {
return Promise.resolve(true);
} }
else { return new Promise(function (resolve) {
this.rerender(); _this.$emit('before-toggle', {
} status: status,
callback: function (value) { return resolve(value); },
});
});
}, },
}, },
}); });

View File

@ -35,6 +35,9 @@ var props_1 = require("./props");
}, clearIcon: { }, clearIcon: {
type: String, type: String,
value: 'clear', value: 'clear',
}, extraEventParams: {
type: Boolean,
value: false,
} }), } }),
data: { data: {
focused: false, focused: false,
@ -50,7 +53,7 @@ var props_1 = require("./props");
var _a = (event.detail || {}).value, value = _a === void 0 ? '' : _a; var _a = (event.detail || {}).value, value = _a === void 0 ? '' : _a;
this.value = value; this.value = value;
this.setShowClear(); this.setShowClear();
this.emitChange(); this.emitChange(event.detail);
}, },
onFocus: function (event) { onFocus: function (event) {
this.focused = true; this.focused = true;
@ -74,7 +77,7 @@ var props_1 = require("./props");
this.value = ''; this.value = '';
this.setShowClear(); this.setShowClear();
(0, utils_1.nextTick)(function () { (0, utils_1.nextTick)(function () {
_this.emitChange(); _this.emitChange({ value: '' });
_this.$emit('clear', ''); _this.$emit('clear', '');
}); });
}, },
@ -90,7 +93,7 @@ var props_1 = require("./props");
if (value === '') { if (value === '') {
this.setData({ innerValue: '' }); this.setData({ innerValue: '' });
} }
this.emitChange(); this.emitChange({ value: value });
}, },
onLineChange: function (event) { onLineChange: function (event) {
this.$emit('linechange', event.detail); this.$emit('linechange', event.detail);
@ -98,12 +101,14 @@ var props_1 = require("./props");
onKeyboardHeightChange: function (event) { onKeyboardHeightChange: function (event) {
this.$emit('keyboardheightchange', event.detail); this.$emit('keyboardheightchange', event.detail);
}, },
emitChange: function () { emitChange: function (detail) {
var _this = this; var _this = this;
this.setData({ value: this.value }); var extraEventParams = this.data.extraEventParams;
this.setData({ value: detail.value });
(0, utils_1.nextTick)(function () { (0, utils_1.nextTick)(function () {
_this.$emit('input', _this.value); var data = extraEventParams ? detail : detail.value;
_this.$emit('change', _this.value); _this.$emit('input', data);
_this.$emit('change', data);
}); });
}, },
setShowClear: function () { setShowClear: function () {

8
lib/field/types.d.ts vendored Normal file
View File

@ -0,0 +1,8 @@
export interface InputDetails {
/** 输入框内容 */
value: string;
/** 光标位置 */
cursor?: number;
/** keyCode 为键值 (目前工具还不支持返回keyCode参数) `2.1.0` 起支持 */
keyCode?: number;
}

2
lib/field/types.js Normal file
View File

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

View File

@ -29,7 +29,6 @@ function equal(value1, value2) {
props: { props: {
value: { value: {
type: null, type: null,
observer: 'observeValue',
}, },
integer: { integer: {
type: Boolean, type: Boolean,
@ -79,6 +78,11 @@ function equal(value1, value2) {
data: { data: {
currentValue: '', currentValue: '',
}, },
watch: {
value: function () {
this.observeValue();
},
},
created: function () { created: function () {
this.setData({ this.setData({
currentValue: this.format(this.data.value), currentValue: this.format(this.data.value),
@ -86,10 +90,8 @@ function equal(value1, value2) {
}, },
methods: { methods: {
observeValue: function () { observeValue: function () {
var _a = this.data, value = _a.value, currentValue = _a.currentValue; var value = this.data.value;
if (!equal(value, currentValue)) { this.setData({ currentValue: this.format(value) });
this.setData({ currentValue: this.format(value) });
}
}, },
check: function () { check: function () {
var val = this.format(this.data.currentValue); var val = this.format(this.data.currentValue);