build: compile 1.7.2

This commit is contained in:
nemo-shen 2021-07-19 23:40:05 +08:00
parent 98721b7b7e
commit 1bbc24b742
13 changed files with 132 additions and 40 deletions

View File

@ -1,7 +1,9 @@
import { VantComponent } from '../common/component'; import { VantComponent } from '../common/component';
import { import {
ROW_HEIGHT, ROW_HEIGHT,
getPrevDay,
getNextDay, getNextDay,
getToday,
compareDay, compareDay,
copyDates, copyDates,
calcDateNum, calcDateNum,
@ -12,6 +14,15 @@ import {
} from './utils'; } from './utils';
import Toast from '../toast/toast'; import Toast from '../toast/toast';
import { requestAnimationFrame } from '../common/utils'; 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({ VantComponent({
props: { props: {
title: { title: {
@ -54,15 +65,11 @@ VantComponent({
}, },
minDate: { minDate: {
type: null, type: null,
value: Date.now(), value: initialMinDate,
}, },
maxDate: { maxDate: {
type: null, type: null,
value: new Date( value: initialMaxDate,
new Date().getFullYear(),
new Date().getMonth() + 6,
new Date().getDate()
).getTime(),
}, },
position: { position: {
type: String, type: String,
@ -151,19 +158,46 @@ VantComponent({
} }
}); });
}, },
getInitialDate() { limitDateRange(date, minDate = null, maxDate = null) {
const { type, defaultDate, minDate } = this.data; 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 (type === 'range') {
if (!Array.isArray(defaultDate)) {
defaultDate = [];
}
const [startDay, endDay] = defaultDate || []; const [startDay, endDay] = defaultDate || [];
return [ const start = this.limitDateRange(
startDay || minDate, startDay || now,
endDay || getNextDay(new Date(minDate)).getTime(), minDate,
]; getPrevDay(maxDate).getTime()
);
const end = this.limitDateRange(
endDay || now,
getNextDay(minDate).getTime()
);
return [start, end];
} }
if (type === 'multiple') { if (type === 'multiple') {
return defaultDate || [minDate]; if (Array.isArray(defaultDate)) {
return defaultDate.map((date) => this.limitDateRange(date));
} }
return defaultDate || minDate; return [this.limitDateRange(now)];
}
if (!defaultDate || Array.isArray(defaultDate)) {
defaultDate = now;
}
return this.limitDateRange(defaultDate);
}, },
scrollIntoView() { scrollIntoView() {
requestAnimationFrame(() => { requestAnimationFrame(() => {

View File

@ -11,6 +11,7 @@ export declare function compareDay(
export declare function getDayByOffset(date: Date, offset: number): Date; export declare function getDayByOffset(date: Date, offset: number): Date;
export declare function getPrevDay(date: Date): Date; export declare function getPrevDay(date: Date): Date;
export declare function getNextDay(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 calcDateNum(date: [Date, Date]): number;
export declare function copyDates(dates: Date | Date[]): Date | Date[]; export declare function copyDates(dates: Date | Date[]): Date | Date[];
export declare function getMonthEndDay(year: number, month: number): number; export declare function getMonthEndDay(year: number, month: number): number;

View File

@ -47,6 +47,11 @@ export function getPrevDay(date) {
export function getNextDay(date) { export function getNextDay(date) {
return getDayByOffset(date, 1); return getDayByOffset(date, 1);
} }
export function getToday() {
const today = new Date();
today.setHours(0, 0, 0, 0);
return today;
}
export function calcDateNum(date) { export function calcDateNum(date) {
const day1 = new Date(date[0]).getTime(); const day1 = new Date(date[0]).getTime();
const day2 = new Date(date[1]).getTime(); const day2 = new Date(date[1]).getTime();

View File

@ -6,5 +6,6 @@ VantComponent({
type: Boolean, type: Boolean,
value: true, value: true,
}, },
inset: Boolean,
}, },
}); });

View File

@ -1,9 +1,11 @@
<wxs src="../wxs/utils.wxs" module="utils" />
<view <view
wx:if="{{ title }}" wx:if="{{ title }}"
class="van-cell-group__title" class="{{ utils.bem('cell-group__title', { inset }) }}"
> >
{{ title }} {{ title }}
</view> </view>
<view class="custom-class van-cell-group {{ border ? 'van-hairline--top-bottom' : '' }}"> <view class="custom-class {{ utils.bem('cell-group', { inset }) }} {{ border ? 'van-hairline--top-bottom' : '' }}">
<slot /> <slot />
</view> </view>

View File

@ -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)} @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)}

View File

@ -16,6 +16,15 @@ var component_1 = require('../common/component');
var utils_1 = require('./utils'); var utils_1 = require('./utils');
var toast_1 = __importDefault(require('../toast/toast')); var toast_1 = __importDefault(require('../toast/toast'));
var utils_2 = require('../common/utils'); 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({ component_1.VantComponent({
props: { props: {
title: { title: {
@ -58,15 +67,11 @@ component_1.VantComponent({
}, },
minDate: { minDate: {
type: null, type: null,
value: Date.now(), value: initialMinDate,
}, },
maxDate: { maxDate: {
type: null, type: null,
value: new Date( value: initialMaxDate,
new Date().getFullYear(),
new Date().getMonth() + 6,
new Date().getDate()
).getTime(),
}, },
position: { position: {
type: String, 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, var _a = this.data,
type = _a.type, 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 (type === 'range') {
if (!Array.isArray(defaultDate)) {
defaultDate = [];
}
var _b = defaultDate || [], var _b = defaultDate || [],
startDay = _b[0], startDay = _b[0],
endDay = _b[1]; endDay = _b[1];
return [ var start = this.limitDateRange(
startDay || minDate, startDay || now,
endDay || utils_1.getNextDay(new Date(minDate)).getTime(), minDate,
]; utils_1.getPrevDay(maxDate).getTime()
);
var end = this.limitDateRange(
endDay || now,
utils_1.getNextDay(minDate).getTime()
);
return [start, end];
} }
if (type === 'multiple') { if (type === 'multiple') {
return defaultDate || [minDate]; if (Array.isArray(defaultDate)) {
return defaultDate.map(function (date) {
return _this.limitDateRange(date);
});
} }
return defaultDate || minDate; return [this.limitDateRange(now)];
}
if (!defaultDate || Array.isArray(defaultDate)) {
defaultDate = now;
}
return this.limitDateRange(defaultDate);
}, },
scrollIntoView: function () { scrollIntoView: function () {
var _this = this; var _this = this;

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
Object.defineProperty(exports, '__esModule', { value: true }); 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; exports.ROW_HEIGHT = 64;
function formatMonthTitle(date) { function formatMonthTitle(date) {
if (!(date instanceof Date)) { if (!(date instanceof Date)) {
@ -56,6 +56,12 @@ function getNextDay(date) {
return getDayByOffset(date, 1); return getDayByOffset(date, 1);
} }
exports.getNextDay = getNextDay; exports.getNextDay = getNextDay;
function getToday() {
var today = new Date();
today.setHours(0, 0, 0, 0);
return today;
}
exports.getToday = getToday;
function calcDateNum(date) { function calcDateNum(date) {
var day1 = new Date(date[0]).getTime(); var day1 = new Date(date[0]).getTime();
var day2 = new Date(date[1]).getTime(); var day2 = new Date(date[1]).getTime();

View File

@ -8,5 +8,6 @@ component_1.VantComponent({
type: Boolean, type: Boolean,
value: true, value: true,
}, },
inset: Boolean,
}, },
}); });

View File

@ -1,9 +1,11 @@
<wxs src="../wxs/utils.wxs" module="utils" />
<view <view
wx:if="{{ title }}" wx:if="{{ title }}"
class="van-cell-group__title" class="{{ utils.bem('cell-group__title', { inset }) }}"
> >
{{ title }} {{ title }}
</view> </view>
<view class="custom-class van-cell-group {{ border ? 'van-hairline--top-bottom' : '' }}"> <view class="custom-class {{ utils.bem('cell-group', { inset }) }} {{ border ? 'van-hairline--top-bottom' : '' }}">
<slot /> <slot />
</view> </view>

View File

@ -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)} @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)}

View File

@ -77,8 +77,5 @@ component_1.VantComponent({
onClear: function (event) { onClear: function (event) {
this.$emit('clear', event.detail); this.$emit('clear', event.detail);
}, },
onClickInput: function (event) {
this.$emit('click-input', event.detail);
},
}, },
}); });

View File

@ -32,7 +32,6 @@
bind:change="onChange" bind:change="onChange"
bind:confirm="onSearch" bind:confirm="onSearch"
bind:clear="onClear" bind:clear="onClear"
bind:click-input="onClickInput"
> >
<slot wx:if="{{ useLeftIconSlot }}" name="left-icon" slot="left-icon" /> <slot wx:if="{{ useLeftIconSlot }}" name="left-icon" slot="left-icon" />
<slot wx:if="{{ useRightIconSlot }}" name="right-icon" slot="right-icon" /> <slot wx:if="{{ useRightIconSlot }}" name="right-icon" slot="right-icon" />