Compare commits

...

2 Commits

Author SHA1 Message Date
nemo-shen
47c66d38e3
feat(Field): add always-embed prop (#4571) 2021-10-20 09:30:42 +08:00
nemo-shen
1ab6abfc19
fix(Calendar): select min effective range (#4569)
* fix(Calendar): select min effective range

* fix(Calendar): fix prefer-destructuring
2021-10-20 09:30:20 +08:00
5 changed files with 22 additions and 14 deletions

View File

@ -6,7 +6,7 @@ import {
getNextDay,
} from '../../utils';
interface Day {
export interface Day {
date: Date;
type: string;
text: number;

View File

@ -12,6 +12,7 @@ import {
getMonths,
getDayByOffset,
} from './utils';
import { Day } from './components/month/index';
import Toast from '../toast/toast';
import { requestAnimationFrame } from '../common/utils';
@ -25,6 +26,8 @@ const initialMaxDate = (() => {
now.getDate()
).getTime();
})();
const getTime = (date: Date | number) =>
date instanceof Date ? date.getTime() : date;
VantComponent({
props: {
@ -230,14 +233,8 @@ VantComponent({
scrollIntoView() {
requestAnimationFrame(() => {
const {
currentDate,
type,
show,
poppable,
minDate,
maxDate,
} = this.data;
const { currentDate, type, show, poppable, minDate, maxDate } =
this.data;
// @ts-ignore
const targetDate = type === 'single' ? currentDate : currentDate[0];
const displayed = show || !poppable;
@ -278,8 +275,8 @@ VantComponent({
if (this.data.readonly) {
return;
}
const { date } = event.detail;
let { date } = event.detail;
const { type, currentDate, allowSameDay } = this.data;
if (type === 'range') {
@ -290,6 +287,17 @@ VantComponent({
const compareToStart = compareDay(date, startDay);
if (compareToStart === 1) {
const { days } = this.selectComponent('.month').data;
days.some((day: Day, index) => {
const isDisabled =
day.type === 'disabled' &&
getTime(startDay) < getTime(day.date) &&
getTime(day.date) < getTime(date);
if (isDisabled) {
({ date } = days[index - 1]);
}
return isDisabled;
});
this.select([startDay, date], true);
} else if (compareToStart === -1) {
this.select([date, null]);
@ -358,9 +366,6 @@ VantComponent({
},
emit(date) {
const getTime = (date: Date | number) =>
date instanceof Date ? date.getTime() : date;
this.setData({
currentDate: Array.isArray(date) ? date.map(getTime) : getTime(date),
});

View File

@ -257,6 +257,7 @@ Page({
| disable-default-padding | 是否去掉 iOS 下的默认内边距,只对 textarea 有效 | _boolean_ | `true` |
| cursor | 指定 focus 时的光标位置 | _number_ | `-1` |
| clear-trigger `v1.8.4` | 显示清除图标的时机,`always` 表示输入框不为空时展示,<br>`focus` 表示输入框聚焦且不为空时展示 | _string_ | `focus` |
| always-embed `v1.9.2` | 强制 input 处于同层状态,默认 focus 时 input 会切到非同层状态 (仅在 iOS 下生效) | _boolean_ | `false` |
### Events

View File

@ -17,6 +17,7 @@
adjust-position="{{ adjustPosition }}"
selection-end="{{ selectionEnd }}"
selection-start="{{ selectionStart }}"
always-embed="{{ alwaysEmbed }}"
password="{{ password || type === 'password' }}"
bindinput="onInput"
bindtap="onClickInput"

View File

@ -49,6 +49,7 @@ export const inputProps: WechatMiniprogram.Component.PropertyOption = {
password: Boolean,
confirmType: String,
confirmHold: Boolean,
alwaysEmbed: Boolean,
};
export const textareaProps: WechatMiniprogram.Component.PropertyOption = {