Compare commits

..

No commits in common. "acdf1ad280913ef17efde5ba7ec55ee68038e180" and "231aa05e8d9ceac32ade0c3c94da4668668b8fde" have entirely different histories.

18 changed files with 53 additions and 153 deletions

View File

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

View File

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

View File

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

View File

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

19
dist/field/index.js vendored
View File

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

View File

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

1
dist/field/types.js vendored
View File

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

12
dist/stepper/index.js vendored
View File

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

View File

@ -1,22 +1,4 @@
# 更新日志
### [v1.10.12](https://github.com/youzan/vant-weapp/compare/v1.10.11...v1.10.12)
`2023-01-16`
**Bug Fixes**
- calendar: 修复在 allow-same-day 情况下初始不能选择同一天 [#5193](https://github.com/youzan/vant-weapp/issues/5193)
- stepper: 修复在 async change 情况下外部无法更新 input 值 [#5191](https://github.com/youzan/vant-weapp/issues/5191)
**Document**
- docs(action-sheet): 修复close-on-click-overlay初始值书写错误 [b2fabe](https://github.com/youzan/vant-weapp/commit/b2fabe6b2b72ce1734b9123b00e78a854111d240)
**Feature**
- dropdown-menu: 增加 use-before-toggle 属性支持 [#5190](https://github.com/youzan/vant-weapp/issues/5190)
- field: 增加 extra-event-params 属性支持 [#5184](https://github.com/youzan/vant-weapp/issues/5184)
### [v1.10.11](https://github.com/youzan/vant-weapp/compare/v1.10.10...v1.10.11)
`2023-01-03`

View File

@ -180,7 +180,7 @@ var getTime = function (date) {
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, allowSameDay = _a.allowSameDay;
var _a = this.data, type = _a.type, minDate = _a.minDate, maxDate = _a.maxDate;
var now = (0, utils_1.getToday)().getTime();
if (type === 'range') {
if (!Array.isArray(defaultDate)) {
@ -188,8 +188,7 @@ var getTime = function (date) {
}
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 date = getTime(endDay || now);
var end = this.limitDateRange(date, allowSameDay ? date : (0, utils_1.getNextDay)(new Date(minDate)).getTime());
var end = this.limitDateRange(endDay || now, (0, utils_1.getNextDay)(new Date(minDate)).getTime());
return [start, end];
}
if (type === 'multiple') {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@vant/weapp",
"version": "1.10.12",
"version": "1.10.11",
"author": "vant-ui",
"license": "MIT",
"miniprogram": "lib",