generated from Tinkoff/angular-open-source-starter
-
Notifications
You must be signed in to change notification settings - Fork 35
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
c25a088
commit 6ca60da
Showing
27 changed files
with
203 additions
and
85 deletions.
There are no files selected for viewing
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
4 changes: 2 additions & 2 deletions
4
projects/core/src/lib/classes/mask-model/utils/calibrate-value-by-mask.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
4 changes: 2 additions & 2 deletions
4
projects/core/src/lib/classes/mask-model/utils/remove-fixed-mask-characters.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
4 changes: 2 additions & 2 deletions
4
projects/core/src/lib/classes/mask-model/utils/validate-value-with-mask.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
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,7 +1,7 @@ | ||
import {ElementState} from './element-state'; | ||
|
||
export type MaskExpression = Array<RegExp | string> | RegExp; | ||
export type MaskitoMaskExpression = Array<RegExp | string> | RegExp; | ||
|
||
export type MaskitoMask = | ||
| MaskExpression | ||
| ((elementState: ElementState) => MaskExpression); | ||
| MaskitoMaskExpression | ||
| ((elementState: ElementState) => MaskitoMaskExpression); |
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
47 changes: 47 additions & 0 deletions
47
projects/demo/src/pages/phone/examples/2-validation/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,47 @@ | ||
import {ChangeDetectionStrategy, Component} from '@angular/core'; | ||
import { | ||
AbstractControl, | ||
FormControl, | ||
ValidationErrors, | ||
ValidatorFn, | ||
} from '@angular/forms'; | ||
import {TuiValidationError} from '@taiga-ui/cdk'; | ||
import {CountryCode, isValidPhoneNumber} from 'libphonenumber-js/max'; | ||
|
||
import mask from './mask'; | ||
|
||
function phoneValidator(countryCode: CountryCode): ValidatorFn { | ||
return (control: AbstractControl): ValidationErrors | null => { | ||
const valid = isValidPhoneNumber(control.value, countryCode); | ||
|
||
return valid ? null : new TuiValidationError('Invalid number'); | ||
}; | ||
} | ||
|
||
@Component({ | ||
selector: 'phone-doc-example-2', | ||
template: ` | ||
<tui-input | ||
tuiTextfieldCustomContent="tuiIconPhoneLarge" | ||
[style.max-width.rem]="30" | ||
[formControl]="value" | ||
> | ||
Basic | ||
<input | ||
tuiTextfield | ||
autocomplete="tel" | ||
inputmode="tel" | ||
[maskito]="mask" | ||
/> | ||
</tui-input> | ||
<tui-error | ||
[formControl]="value" | ||
[error]="[] | tuiFieldError | async" | ||
></tui-error> | ||
`, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class PhoneMaskDocExample2 { | ||
value = new FormControl('+36 20 123-3122', phoneValidator('HU')); | ||
readonly mask = mask; | ||
} |
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,4 @@ | ||
import {maskitoPhoneOptionsGenerator} from '@maskito/phone'; | ||
import metadata from 'libphonenumber-js/mobile/metadata'; | ||
|
||
export default maskitoPhoneOptionsGenerator({countryIsoCode: 'HU', metadata}); |
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
2 changes: 1 addition & 1 deletion
2
...cts/phone/src/lib/plugins/add-on-focus.ts → projects/kit/src/lib/plugins/add-on-focus.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
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,3 +1,5 @@ | ||
export {maskitoAddOnFocusPlugin} from './add-on-focus'; | ||
export {maskitoCaretGuard} from './caret-guard'; | ||
export {maskitoEventHandler} from './event-handler'; | ||
export {maskitoRejectEvent} from './reject-event'; | ||
export {maskitoRemoveOnBlurPlugin} from './remove-on-blur'; |
2 changes: 1 addition & 1 deletion
2
...s/phone/src/lib/plugins/remove-on-blur.ts → ...cts/kit/src/lib/plugins/remove-on-blur.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
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
export * from './lib/masks'; | ||
export * from './lib/plugins'; |
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
Oops, something went wrong.