Skip to content

Commit

Permalink
feat(module:datepicker): support input
Browse files Browse the repository at this point in the history
  • Loading branch information
hsuanxyz committed Dec 19, 2017
1 parent 424fb7b commit 697d1cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/calendar/nz-calendar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ export class NzCalendarComponent implements OnInit {
return false;
}
}

_buildMonth(d: Moment): WeekInterface[] {
const weeks: WeekInterface[] = [];
const _rawDate = this._removeTime(d);
Expand Down
14 changes: 12 additions & 2 deletions src/components/datepicker/nz-rangepicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,11 @@ import { toBoolean } from '../util/convert';
[class.ant-calendar-range-right]="part === _part.End">
<div class="ant-calendar-input-wrap">
<div class="ant-calendar-date-input-wrap">
<input class="ant-calendar-input" [placeholder]="nzPlaceholder[part]"
[value]="_value[part] | nzDate: nzFormat">
<input class="ant-calendar-input"
[placeholder]="nzPlaceholder[part]"
[value]="_value[part] | nzDate: nzFormat"
#dateBox
(blur)="_blurInput(dateBox, part)">
</div>
</div>
<div class="ant-calendar-header">
Expand Down Expand Up @@ -399,6 +402,13 @@ export class NzRangePickerComponent implements ControlValueAccessor, OnInit {
this._value[part] = $event;
}

_blurInput(box: HTMLInputElement, part: RangePart): void {
if (Date.parse(box.value)) {
this._value[part] = new Date(box.value);
this.onChange(this._value);
}
}

_hoverDay(day: DayInterface): void {
if (!this._isComplete() && this._value.some(e => moment(e).isValid())) {
this._hoveringSelectValue = day.date.toDate();
Expand Down

0 comments on commit 697d1cb

Please sign in to comment.