Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
Revert "fix: update rangepicker disabled"
Browse files Browse the repository at this point in the history
This reverts commit 5bed207.
  • Loading branch information
dangyuzheng committed Aug 9, 2023
1 parent 4c0f1fd commit ff1b0fb
Showing 1 changed file with 1 addition and 34 deletions.
35 changes: 1 addition & 34 deletions src/components/RangePicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import CALENDAR_EN from 'rc-calendar/lib/locale/en_US';
import moment, { Moment, DurationInputArg1, DurationInputArg2 } from 'moment';
import { RangePickerProps, RangePickerState } from '../../interface';
import isEmpty from 'lodash/isEmpty';
import pick from 'lodash/pick';
import Icon from '../Icon';

import './style.scss';
Expand Down Expand Up @@ -47,36 +46,6 @@ function disabledDate(current: Moment) {
return current.isAfter(date); // can not select days after today
}

function disabledTime(current:any, type:string) {
const now = moment();
const result = {
disabledHours: () => [...Array(24).keys()].slice(now.hour() + 1),
disabledMinutes: () => [...Array(60).keys()].slice(now.minute() + 1),
disabledSeconds: () => [...Array(60).keys()],
}

function getRes(type: string) {
const index = type === 'start' ? 0: 1;

if(current[index]?.isSame(now, 'day') && current[index]?.isSame(now, 'hour') && current[index]?.isSame(now, 'minute')) {
return result;
}
if(current[index]?.isSame(now, 'day') && current[index]?.isSame(now, 'hour')) {
return pick(result, 'disabledHours','disabledMinutes');
}
if(current[index]?.isSame(now, 'day')) {
return pick(result, 'disabledHours');
}

return null;
}
if (current) {
return getRes(type)
}

return null;
}

export default class RangePicker extends React.PureComponent<RangePickerProps, RangePickerState> {
static defaultProps = {
disabled: false,
Expand Down Expand Up @@ -199,7 +168,6 @@ export default class RangePicker extends React.PureComponent<RangePickerProps, R
};
renderCalendar = () => {
const { onOk, format } = this.props;

return (
<RangeCalendar
seperator={this.seperator}
Expand All @@ -208,10 +176,9 @@ export default class RangePicker extends React.PureComponent<RangePickerProps, R
format={format}
onOk={onOk}
disabledDate={disabledDate}
timePicker={<TimePickerPanel />}
timePicker={<TimePickerPanel />}
renderFooter={this.renderFooter}
showToday={false}
disabledTime={disabledTime}
/>
);
};
Expand Down

0 comments on commit ff1b0fb

Please sign in to comment.