Skip to content

Commit

Permalink
Allow to select date or range dates programatically with value attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoprietog committed Mar 6, 2024
1 parent 2e5076b commit ce8df1d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/components/inclusive-dates/inclusive-dates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,17 @@ export class InclusiveDates {
}

@Watch("value")
watchValue() {
if (Boolean(this.value) && !this.isRangeValue(this.value)) {
this.internalValue = this.value as string;
watchValue(newValue) {
// Range
if (Array.isArray(newValue)) {
this.internalValue = newValue.map((date) => getISODateString(date));
}
// Single
else {
this.internalValue = getISODateString(newValue);
}
this.pickerRef.value = newValue;
this.errorState = false;
}

private getClassName(element?: string) {
Expand Down

0 comments on commit ce8df1d

Please sign in to comment.