Skip to content

Commit

Permalink
fix(addon-mobile): emit TuiDay on first click in mobile-calendar[sing…
Browse files Browse the repository at this point in the history
…le=false]
  • Loading branch information
MillerSvt committed Aug 1, 2024
1 parent 3356d63 commit 3e54360
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,14 @@ export class TuiMobileCalendarComponent implements AfterViewInit {
this.value = day;
} else if (this.isMultiValue(this.value)) {
this.value = tuiImmutableUpdateInputDateMulti(this.value, day);
} else if (this.isSingleValue(this.value)) {
this.value = new TuiDayRange(day, day);
} else if (this.value instanceof TuiDay) {
this.value = TuiDayRange.sort(this.value, day);
} else if (this.value instanceof TuiDayRange && !this.value.isSingleDay) {
this.value = day;
} else if (this.value instanceof TuiDayRange) {
this.value = TuiDayRange.sort(this.value.from, day);
} else if (!this.value) {
this.value = new TuiDayRange(day, day);
this.value = day;
}
}

Expand Down Expand Up @@ -279,10 +281,6 @@ export class TuiMobileCalendarComponent implements AfterViewInit {
return !(day instanceof TuiDay) && !(day instanceof TuiDayRange) && this.multi;
}

private isSingleValue(day: any): day is TuiDay {
return day instanceof TuiDay || (day instanceof TuiDayRange && !day.isSingleDay);
}

private get initialYear(): number {
if (!this.value) {
return this.today.year;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ export class ExampleTuiMobileCalendarComponent {

single = true;

multi = false;

readonly disabledItemHandlerVariants: ReadonlyArray<TuiBooleanHandler<TuiDay>> = [
ALWAYS_FALSE_HANDLER,
({day}) => day % 3 === 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
[disabledItemHandler]="disabledItemHandler"
[max]="max"
[min]="min"
[multi]="multi"
[single]="single"
(cancel)="documentationPropertyCancel.emitEvent($event)"
(confirm)="documentationPropertyConfirm.emitEvent($event)"
Expand Down Expand Up @@ -151,6 +152,14 @@
>
Single date or a range
</ng-template>
<ng-template
documentationPropertyMode="input"
documentationPropertyName="multi"
documentationPropertyType="boolean"
[(documentationPropertyValue)]="multi"
>
Multi date or a range
</ng-template>
<ng-template
#documentationPropertyCancel="documentationProperty"
documentationPropertyMode="output"
Expand Down

0 comments on commit 3e54360

Please sign in to comment.