-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(addon-mobile):
MobileCalendar
switch to dropdown (#7254)
Signed-off-by: waterplea <[email protected]>
- Loading branch information
Showing
21 changed files
with
246 additions
and
126 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
projects/addon-mobile/components/mobile-calendar-dialog/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './mobile-calendar-dialog.component'; | ||
export * from './mobile-calendar-dialog.module'; | ||
export * from './mobile-calendar-dropdown.component'; |
8 changes: 5 additions & 3 deletions
8
projects/addon-mobile/components/mobile-calendar-dialog/mobile-calendar-dialog.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
...ects/addon-mobile/components/mobile-calendar-dialog/mobile-calendar-dropdown.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
HostBinding, | ||
Inject, | ||
Optional, | ||
} from '@angular/core'; | ||
import {TuiKeyboardService} from '@taiga-ui/addon-mobile/services'; | ||
import { | ||
ALWAYS_FALSE_HANDLER, | ||
TUI_FIRST_DAY, | ||
TUI_LAST_DAY, | ||
TuiActiveZoneDirective, | ||
} from '@taiga-ui/cdk'; | ||
import { | ||
TUI_ANIMATIONS_DURATION, | ||
tuiFadeIn, | ||
TuiHostedDropdownComponent, | ||
tuiSlideInTop, | ||
} from '@taiga-ui/core'; | ||
import { | ||
TuiInputDateComponent, | ||
TuiInputDateMultiComponent, | ||
TuiInputDateRangeComponent, | ||
} from '@taiga-ui/kit'; | ||
|
||
@Component({ | ||
selector: 'tui-mobile-calendar-dropdown', | ||
templateUrl: './mobile-calendar-dropdown.template.html', | ||
styleUrls: ['./mobile-calendar-dropdown.style.less'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
animations: [tuiSlideInTop, tuiFadeIn], | ||
}) | ||
export class TuiMobileCalendarDropdownComponent { | ||
@HostBinding('@tuiSlideInTop') | ||
@HostBinding('@tuiFadeIn') | ||
readonly animation = { | ||
value: '', | ||
params: { | ||
start: '100vh', | ||
duration: this.duration, | ||
}, | ||
} as const; | ||
|
||
readonly min = | ||
this.single?.min || | ||
this.multi?.min || | ||
this.range?.maxLengthMapper( | ||
this.range.computedMin, | ||
this.range.value, | ||
this.range.maxLength, | ||
true, | ||
) || | ||
TUI_FIRST_DAY; | ||
|
||
readonly max = | ||
this.single?.max || | ||
this.multi?.max || | ||
this.range?.maxLengthMapper( | ||
this.range.computedMax, | ||
this.range.value, | ||
this.range.maxLength, | ||
false, | ||
) || | ||
TUI_LAST_DAY; | ||
|
||
readonly disabledItemHandler = | ||
this.single?.disabledItemHandler || | ||
this.multi?.disabledItemHandler || | ||
this.range?.disabledItemHandler || | ||
ALWAYS_FALSE_HANDLER; | ||
|
||
constructor( | ||
@Inject(TuiActiveZoneDirective) readonly zone: TuiActiveZoneDirective, | ||
@Inject(TUI_ANIMATIONS_DURATION) private readonly duration: number, | ||
@Optional() | ||
@Inject(TuiInputDateComponent) | ||
readonly single: TuiInputDateComponent | null, | ||
@Optional() | ||
@Inject(TuiInputDateMultiComponent) | ||
readonly multi: TuiInputDateMultiComponent | null, | ||
@Optional() | ||
@Inject(TuiInputDateRangeComponent) | ||
private readonly range: TuiInputDateRangeComponent | null, | ||
@Inject(TuiHostedDropdownComponent) | ||
private readonly dropdown: TuiHostedDropdownComponent, | ||
@Inject(TuiKeyboardService) | ||
private readonly keyboard: TuiKeyboardService, | ||
) { | ||
this.keyboard.hide(); | ||
} | ||
|
||
close(): void { | ||
this.dropdown.computedHost.focus(); | ||
this.dropdown.updateOpen(false); | ||
this.keyboard.show(); | ||
} | ||
|
||
confirm(value: any): void { | ||
const control = this.single || this.multi || this.range; | ||
|
||
if (control) { | ||
control.value = value; | ||
} | ||
|
||
this.close(); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
projects/addon-mobile/components/mobile-calendar-dialog/mobile-calendar-dropdown.style.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@import '@taiga-ui/core/styles/taiga-ui-local'; | ||
|
||
/* stylelint-disable */ | ||
:host { | ||
.fullsize(fixed); | ||
background: var(--tui-elevation-01); | ||
box-shadow: | ||
0 10rem var(--tui-elevation-01), | ||
0 -90vh 1rem 2rem rgba(0, 0, 0, 0.75); | ||
} |
10 changes: 10 additions & 0 deletions
10
...cts/addon-mobile/components/mobile-calendar-dialog/mobile-calendar-dropdown.template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<tui-mobile-calendar | ||
tuiActiveZone | ||
[disabledItemHandler]="disabledItemHandler" | ||
[max]="max" | ||
[min]="min" | ||
[multi]="!!multi" | ||
[single]="!!single" | ||
(cancel)="close()" | ||
(confirm)="confirm($event)" | ||
></tui-mobile-calendar> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ | |
|
||
.t-group { | ||
display: flex; | ||
align-items: stretch; | ||
} |
Oops, something went wrong.