From 1bbc24b7422d3df0486f2da7c3ace77e8b1df744 Mon Sep 17 00:00:00 2001 From: nemo-shen Date: Mon, 19 Jul 2021 23:40:05 +0800 Subject: [PATCH] build: compile 1.7.2 --- dist/calendar/index.js | 62 ++++++++++++++++++++++++-------- dist/calendar/utils.d.ts | 1 + dist/calendar/utils.js | 5 +++ dist/cell-group/index.js | 1 + dist/cell-group/index.wxml | 6 ++-- dist/cell-group/index.wxss | 2 +- lib/calendar/index.js | 74 ++++++++++++++++++++++++++++++-------- lib/calendar/utils.js | 8 ++++- lib/cell-group/index.js | 1 + lib/cell-group/index.wxml | 6 ++-- lib/cell-group/index.wxss | 2 +- lib/search/index.js | 3 -- lib/search/index.wxml | 1 - 13 files changed, 132 insertions(+), 40 deletions(-) diff --git a/dist/calendar/index.js b/dist/calendar/index.js index 08dad0be..7fa6a5d0 100644 --- a/dist/calendar/index.js +++ b/dist/calendar/index.js @@ -1,7 +1,9 @@ import { VantComponent } from '../common/component'; import { ROW_HEIGHT, + getPrevDay, getNextDay, + getToday, compareDay, copyDates, calcDateNum, @@ -12,6 +14,15 @@ import { } 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(); +})(); VantComponent({ props: { title: { @@ -54,15 +65,11 @@ VantComponent({ }, minDate: { type: null, - value: Date.now(), + value: initialMinDate, }, maxDate: { type: null, - value: new Date( - new Date().getFullYear(), - new Date().getMonth() + 6, - new Date().getDate() - ).getTime(), + value: initialMaxDate, }, position: { type: String, @@ -151,19 +158,46 @@ VantComponent({ } }); }, - getInitialDate() { - const { type, defaultDate, minDate } = this.data; + limitDateRange(date, minDate = null, maxDate = null) { + minDate = minDate || this.data.minDate; + maxDate = maxDate || this.data.maxDate; + if (compareDay(date, minDate) === -1) { + return minDate; + } + if (compareDay(date, maxDate) === 1) { + return maxDate; + } + return date; + }, + getInitialDate(defaultDate = null) { + const { type, minDate, maxDate } = this.data; + const now = getToday().getTime(); if (type === 'range') { + if (!Array.isArray(defaultDate)) { + defaultDate = []; + } const [startDay, endDay] = defaultDate || []; - return [ - startDay || minDate, - endDay || getNextDay(new Date(minDate)).getTime(), - ]; + const start = this.limitDateRange( + startDay || now, + minDate, + getPrevDay(maxDate).getTime() + ); + const end = this.limitDateRange( + endDay || now, + getNextDay(minDate).getTime() + ); + return [start, end]; } if (type === 'multiple') { - return defaultDate || [minDate]; + if (Array.isArray(defaultDate)) { + return defaultDate.map((date) => this.limitDateRange(date)); + } + return [this.limitDateRange(now)]; } - return defaultDate || minDate; + if (!defaultDate || Array.isArray(defaultDate)) { + defaultDate = now; + } + return this.limitDateRange(defaultDate); }, scrollIntoView() { requestAnimationFrame(() => { diff --git a/dist/calendar/utils.d.ts b/dist/calendar/utils.d.ts index 17fc0779..ec7cf3f4 100644 --- a/dist/calendar/utils.d.ts +++ b/dist/calendar/utils.d.ts @@ -11,6 +11,7 @@ export declare function compareDay( export declare function getDayByOffset(date: Date, offset: number): Date; export declare function getPrevDay(date: Date): Date; export declare function getNextDay(date: Date): Date; +export declare function getToday(): Date; export declare function calcDateNum(date: [Date, Date]): number; export declare function copyDates(dates: Date | Date[]): Date | Date[]; export declare function getMonthEndDay(year: number, month: number): number; diff --git a/dist/calendar/utils.js b/dist/calendar/utils.js index 281a35c9..f773e7f5 100644 --- a/dist/calendar/utils.js +++ b/dist/calendar/utils.js @@ -47,6 +47,11 @@ export function getPrevDay(date) { export function getNextDay(date) { return getDayByOffset(date, 1); } +export function getToday() { + const today = new Date(); + today.setHours(0, 0, 0, 0); + return today; +} export function calcDateNum(date) { const day1 = new Date(date[0]).getTime(); const day2 = new Date(date[1]).getTime(); diff --git a/dist/cell-group/index.js b/dist/cell-group/index.js index 99bcdb9e..5f76bb55 100644 --- a/dist/cell-group/index.js +++ b/dist/cell-group/index.js @@ -6,5 +6,6 @@ VantComponent({ type: Boolean, value: true, }, + inset: Boolean, }, }); diff --git a/dist/cell-group/index.wxml b/dist/cell-group/index.wxml index 6e0b471d..311e064a 100644 --- a/dist/cell-group/index.wxml +++ b/dist/cell-group/index.wxml @@ -1,9 +1,11 @@ + + {{ title }} - + diff --git a/dist/cell-group/index.wxss b/dist/cell-group/index.wxss index edbccd59..5bc5d0f4 100644 --- a/dist/cell-group/index.wxss +++ b/dist/cell-group/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-cell-group__title{padding:16px 16px 8px;padding:var(--cell-group-title-padding,16px 16px 8px);font-size:14px;font-size:var(--cell-group-title-font-size,14px);line-height:16px;line-height:var(--cell-group-title-line-height,16px);color:#969799;color:var(--cell-group-title-color,#969799)} \ No newline at end of file +@import '../common/index.wxss';.van-cell-group--inset{margin:0 16px;margin:var(--cell-group-inset-padding,0 16px);border-radius:8px;border-radius:var(--cell-group-inset-border-radius,8px);overflow:hidden}.van-cell-group__title{padding:16px 16px 8px;padding:var(--cell-group-title-padding,16px 16px 8px);font-size:14px;font-size:var(--cell-group-title-font-size,14px);line-height:16px;line-height:var(--cell-group-title-line-height,16px);color:#969799;color:var(--cell-group-title-color,#969799)}.van-cell-group__title--inset{padding:16px 16px 8px 32px;padding:var(--cell-group-inset-title-padding,16px 16px 8px 32px)} \ No newline at end of file diff --git a/lib/calendar/index.js b/lib/calendar/index.js index 1db8d75e..1dafdad3 100644 --- a/lib/calendar/index.js +++ b/lib/calendar/index.js @@ -16,6 +16,15 @@ 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(); +})(); component_1.VantComponent({ props: { title: { @@ -58,15 +67,11 @@ component_1.VantComponent({ }, minDate: { type: null, - value: Date.now(), + value: initialMinDate, }, maxDate: { type: null, - value: new Date( - new Date().getFullYear(), - new Date().getMonth() + 6, - new Date().getDate() - ).getTime(), + value: initialMaxDate, }, position: { type: String, @@ -158,24 +163,63 @@ component_1.VantComponent({ } }); }, - getInitialDate: function () { + limitDateRange: function (date, minDate, maxDate) { + 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) { + return minDate; + } + if (utils_1.compareDay(date, maxDate) === 1) { + return maxDate; + } + return date; + }, + getInitialDate: function (defaultDate) { + var _this = this; + if (defaultDate === void 0) { + defaultDate = null; + } var _a = this.data, type = _a.type, - defaultDate = _a.defaultDate, - minDate = _a.minDate; + 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]; - return [ - startDay || minDate, - endDay || utils_1.getNextDay(new Date(minDate)).getTime(), - ]; + var start = this.limitDateRange( + startDay || now, + minDate, + utils_1.getPrevDay(maxDate).getTime() + ); + var end = this.limitDateRange( + endDay || now, + utils_1.getNextDay(minDate).getTime() + ); + return [start, end]; } if (type === 'multiple') { - return defaultDate || [minDate]; + if (Array.isArray(defaultDate)) { + return defaultDate.map(function (date) { + return _this.limitDateRange(date); + }); + } + return [this.limitDateRange(now)]; } - return defaultDate || minDate; + if (!defaultDate || Array.isArray(defaultDate)) { + defaultDate = now; + } + return this.limitDateRange(defaultDate); }, scrollIntoView: function () { var _this = this; diff --git a/lib/calendar/utils.js b/lib/calendar/utils.js index cdd1a0cb..37e14c2a 100644 --- a/lib/calendar/utils.js +++ b/lib/calendar/utils.js @@ -1,6 +1,6 @@ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); -exports.getMonths = exports.getMonthEndDay = exports.copyDates = exports.calcDateNum = exports.getNextDay = exports.getPrevDay = exports.getDayByOffset = exports.compareDay = exports.compareMonth = exports.formatMonthTitle = exports.ROW_HEIGHT = void 0; +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)) { @@ -56,6 +56,12 @@ function getNextDay(date) { return getDayByOffset(date, 1); } exports.getNextDay = getNextDay; +function getToday() { + var today = new Date(); + today.setHours(0, 0, 0, 0); + return today; +} +exports.getToday = getToday; function calcDateNum(date) { var day1 = new Date(date[0]).getTime(); var day2 = new Date(date[1]).getTime(); diff --git a/lib/cell-group/index.js b/lib/cell-group/index.js index 7d934870..fc0f6645 100644 --- a/lib/cell-group/index.js +++ b/lib/cell-group/index.js @@ -8,5 +8,6 @@ component_1.VantComponent({ type: Boolean, value: true, }, + inset: Boolean, }, }); diff --git a/lib/cell-group/index.wxml b/lib/cell-group/index.wxml index 6e0b471d..311e064a 100644 --- a/lib/cell-group/index.wxml +++ b/lib/cell-group/index.wxml @@ -1,9 +1,11 @@ + + {{ title }} - + diff --git a/lib/cell-group/index.wxss b/lib/cell-group/index.wxss index edbccd59..5bc5d0f4 100644 --- a/lib/cell-group/index.wxss +++ b/lib/cell-group/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-cell-group__title{padding:16px 16px 8px;padding:var(--cell-group-title-padding,16px 16px 8px);font-size:14px;font-size:var(--cell-group-title-font-size,14px);line-height:16px;line-height:var(--cell-group-title-line-height,16px);color:#969799;color:var(--cell-group-title-color,#969799)} \ No newline at end of file +@import '../common/index.wxss';.van-cell-group--inset{margin:0 16px;margin:var(--cell-group-inset-padding,0 16px);border-radius:8px;border-radius:var(--cell-group-inset-border-radius,8px);overflow:hidden}.van-cell-group__title{padding:16px 16px 8px;padding:var(--cell-group-title-padding,16px 16px 8px);font-size:14px;font-size:var(--cell-group-title-font-size,14px);line-height:16px;line-height:var(--cell-group-title-line-height,16px);color:#969799;color:var(--cell-group-title-color,#969799)}.van-cell-group__title--inset{padding:16px 16px 8px 32px;padding:var(--cell-group-inset-title-padding,16px 16px 8px 32px)} \ No newline at end of file diff --git a/lib/search/index.js b/lib/search/index.js index d2ba33b9..2e61ab9b 100644 --- a/lib/search/index.js +++ b/lib/search/index.js @@ -77,8 +77,5 @@ component_1.VantComponent({ onClear: function (event) { this.$emit('clear', event.detail); }, - onClickInput: function (event) { - this.$emit('click-input', event.detail); - }, }, }); diff --git a/lib/search/index.wxml b/lib/search/index.wxml index 5d77fca8..1d0e6f1f 100644 --- a/lib/search/index.wxml +++ b/lib/search/index.wxml @@ -32,7 +32,6 @@ bind:change="onChange" bind:confirm="onSearch" bind:clear="onClear" - bind:click-input="onClickInput" >