Skip to content

Commit

Permalink
feat(ui5-daterange-picker): initial implementation (#1785)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsanislavgatev authored Jun 30, 2020
1 parent 77e8886 commit 4c11286
Show file tree
Hide file tree
Showing 11 changed files with 677 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/main/bundle.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import Carousel from "./dist/Carousel.js";
import CheckBox from "./dist/CheckBox.js";
import ComboBox from "./dist/ComboBox.js";
import DatePicker from "./dist/DatePicker.js";
import DateRangePicker from "./dist/DateRangePicker.js";
import DateTimePicker from "./dist/DateTimePicker.js";
import DurationPicker from "./dist/DurationPicker.js";
import Dialog from "./dist/Dialog.js";
Expand Down
13 changes: 8 additions & 5 deletions packages/main/src/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ class DatePicker extends UI5Element {
this.maxDate = null;
console.warn(`In order for the "maxDate" property to have effect, you should enter valid date format`); // eslint-disable-line
}
if (this.isValid(this.value) && this.isInValidRange(this._getTimeStampFromString(this.value))) {
if (this._checkValueValidity(this.value)) {
this._changeCalendarSelection();
} else {
this._calendar.selectedDates = [];
Expand Down Expand Up @@ -462,10 +462,9 @@ class DatePicker extends UI5Element {
_handleInputChange() {
let nextValue = this._getInput().getInputValue();
const emptyValue = nextValue === "";
const isValid = emptyValue || this.isValid(nextValue);
const isInValidRange = this.isInValidRange(this._getTimeStampFromString(nextValue));
const isValid = emptyValue || this._checkValueValidity(nextValue);

if (isValid && isInValidRange) {
if (isValid) {
nextValue = this.normalizeValue(nextValue);
this.valueState = ValueState.None;
} else {
Expand All @@ -482,12 +481,16 @@ class DatePicker extends UI5Element {
_handleInputLiveChange() {
const nextValue = this._getInput().getInputValue();
const emptyValue = nextValue === "";
const isValid = emptyValue || (this.isValid(nextValue) && this.isInValidRange(this._getTimeStampFromString(nextValue)));
const isValid = emptyValue || this._checkValueValidity(nextValue);

this.value = nextValue;
this.fireEvent("input", { value: nextValue, valid: isValid });
}

_checkValueValidity(value) {
return this.isValid(value) && this.isInValidRange(this._getTimeStampFromString(value));
}

_click(event) {
if (isPhone()) {
this.responsivePopover.open(this);
Expand Down
1 change: 1 addition & 0 deletions packages/main/src/DateRangePicker.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{>include "./DatePicker.hbs"}}
Loading

0 comments on commit 4c11286

Please sign in to comment.