-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add example with maskito and input-tag
- Loading branch information
Showing
5 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
projects/demo/src/modules/components/input-tag/examples/9/index.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,9 @@ | ||
<tui-input-tag | ||
tuiTextfieldIcon="tuiIconCalendarLarge" | ||
[formControl]="control" | ||
[maskito]="options" | ||
[tagValidator]="tagValidator" | ||
[tuiTextfieldLabelOutside]="true" | ||
> | ||
dd.mm.yyyy | ||
</tui-input-tag> |
36 changes: 36 additions & 0 deletions
36
projects/demo/src/modules/components/input-tag/examples/9/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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import {Component} from '@angular/core'; | ||
import {FormControl} from '@angular/forms'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
import {MaskitoOptions} from '@maskito/core'; | ||
import {maskitoDateOptionsGenerator} from '@maskito/kit'; | ||
import {TuiBooleanHandler, TuiDay} from '@taiga-ui/cdk'; | ||
|
||
@Component({ | ||
selector: 'tui-input-tag-example-9', | ||
templateUrl: './index.html', | ||
changeDetection, | ||
encapsulation, | ||
}) | ||
export class TuiInputTagExample9 { | ||
readonly control = new FormControl([]); | ||
readonly min = new Date(2000, 0, 1); | ||
readonly max = new Date(2025, 4, 10); | ||
|
||
readonly options: MaskitoOptions = maskitoDateOptionsGenerator({ | ||
mode: 'dd/mm/yyyy', | ||
separator: '.', | ||
min: this.min, | ||
max: this.max, | ||
}); | ||
|
||
tagValidator: TuiBooleanHandler<string> = (tag: string) => { | ||
const {year, month, day} = TuiDay.parseRawDateString(tag); | ||
|
||
return ( | ||
TuiDay.isValidDay(year, month, day) && | ||
TuiDay.normalizeOf(year, month, day).toLocalNativeDate() >= this.min && | ||
TuiDay.normalizeOf(year, month, day).toLocalNativeDate() <= this.max | ||
); | ||
}; | ||
} |
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