-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e5f250
commit 7d3a750
Showing
5 changed files
with
96 additions
and
15 deletions.
There are no files selected for viewing
20 changes: 17 additions & 3 deletions
20
projects/demo/src/modules/components/textfield/examples/5/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 |
---|---|---|
@@ -1,11 +1,25 @@ | ||
<tui-textfield> | ||
<strong>π</strong> | ||
-value | ||
<tui-textfield [tuiTextfieldCleaner]="false"> | ||
<label tuiLabel>Flat angle</label> | ||
|
||
<input | ||
#input | ||
placeholder="3,14" | ||
tuiTextfield | ||
[maskito]="options" | ||
[(ngModel)]="value" | ||
/> | ||
|
||
<button | ||
*ngIf="value" | ||
appearance="icon" | ||
iconStart="@tui.x" | ||
size="xs" | ||
tabindex="-1" | ||
tuiIconButton | ||
type="button" | ||
(click)="clear()" | ||
(pointerdown.silent.prevent)="input.focus()" | ||
> | ||
Clear | ||
</button> | ||
</tui-textfield> |
Empty file.
42 changes: 32 additions & 10 deletions
42
projects/demo/src/modules/components/textfield/examples/5/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,24 +1,46 @@ | ||
import {NgIf} from '@angular/common'; | ||
import {Component} from '@angular/core'; | ||
import {FormsModule} from '@angular/forms'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
import {MaskitoDirective} from '@maskito/angular'; | ||
import {maskitoNumberOptionsGenerator} from '@maskito/kit'; | ||
import {TuiTextfield} from '@taiga-ui/core'; | ||
import type {MaskitoOptions} from '@maskito/core'; | ||
import { | ||
maskitoAddOnFocusPlugin, | ||
maskitoCaretGuard, | ||
maskitoNumberOptionsGenerator, | ||
maskitoRemoveOnBlurPlugin, | ||
} from '@maskito/kit'; | ||
import {TuiButton, TuiTextfield} from '@taiga-ui/core'; | ||
|
||
const postfix = ' rad'; | ||
const numberOptions = maskitoNumberOptionsGenerator({ | ||
postfix, | ||
decimalSeparator: ',', | ||
precision: 8, | ||
min: 0, | ||
}); | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [FormsModule, MaskitoDirective, TuiTextfield], | ||
imports: [FormsModule, MaskitoDirective, NgIf, TuiButton, TuiTextfield], | ||
templateUrl: './index.html', | ||
styleUrls: ['./index.less'], | ||
encapsulation, | ||
changeDetection, | ||
}) | ||
export default class Example { | ||
protected value = Math.PI.toFixed(48); | ||
protected readonly options = maskitoNumberOptionsGenerator({ | ||
decimalSeparator: ',', | ||
precision: Infinity, | ||
min: 0, | ||
}); | ||
protected value = Math.PI.toFixed(8); | ||
protected readonly options: MaskitoOptions = { | ||
...numberOptions, | ||
plugins: [ | ||
...numberOptions.plugins, | ||
maskitoCaretGuard((value) => [0, value.length - postfix.length]), | ||
maskitoAddOnFocusPlugin(postfix), | ||
maskitoRemoveOnBlurPlugin(postfix), | ||
], | ||
}; | ||
|
||
protected clear(): void { | ||
this.value = postfix; | ||
} | ||
} |
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