From 270384f7998b93581c4270cb86ec7a5c7f408b59 Mon Sep 17 00:00:00 2001 From: Nikita Barsukov Date: Thu, 29 Aug 2024 14:52:18 +0300 Subject: [PATCH 1/5] feat(kit): `InputPhoneInternational` can be customized with `Icon` / `Tooltip` --- .../examples/4/index.html | 14 ++++ .../examples/4/index.less | 3 + .../examples/4/index.ts | 40 +++++++++ .../input-phone-international/index.html | 83 ++++++++++++++----- .../input-phone-international/index.ts | 7 +- .../input-phone-international.template.html | 2 + 6 files changed, 125 insertions(+), 24 deletions(-) create mode 100644 projects/demo/src/modules/components/input-phone-international/examples/4/index.html create mode 100644 projects/demo/src/modules/components/input-phone-international/examples/4/index.less create mode 100644 projects/demo/src/modules/components/input-phone-international/examples/4/index.ts diff --git a/projects/demo/src/modules/components/input-phone-international/examples/4/index.html b/projects/demo/src/modules/components/input-phone-international/examples/4/index.html new file mode 100644 index 000000000000..b5b633bb89dc --- /dev/null +++ b/projects/demo/src/modules/components/input-phone-international/examples/4/index.html @@ -0,0 +1,14 @@ + + Phone number + + + diff --git a/projects/demo/src/modules/components/input-phone-international/examples/4/index.less b/projects/demo/src/modules/components/input-phone-international/examples/4/index.less new file mode 100644 index 000000000000..2724b03b8733 --- /dev/null +++ b/projects/demo/src/modules/components/input-phone-international/examples/4/index.less @@ -0,0 +1,3 @@ +tui-input-phone-international { + min-width: min(20rem, 80vw); +} diff --git a/projects/demo/src/modules/components/input-phone-international/examples/4/index.ts b/projects/demo/src/modules/components/input-phone-international/examples/4/index.ts new file mode 100644 index 000000000000..119cb742e459 --- /dev/null +++ b/projects/demo/src/modules/components/input-phone-international/examples/4/index.ts @@ -0,0 +1,40 @@ +import {Component} from '@angular/core'; +import {FormsModule} from '@angular/forms'; +import {changeDetection} from '@demo/emulate/change-detection'; +import {encapsulation} from '@demo/emulate/encapsulation'; +import {TuiIcon} from '@taiga-ui/core'; +import type {TuiCountryIsoCode} from '@taiga-ui/i18n'; +import { + TuiInputPhoneInternational, + tuiInputPhoneInternationalOptionsProvider, + TuiTooltip, +} from '@taiga-ui/kit'; +import {defer} from 'rxjs'; + +@Component({ + standalone: true, + imports: [FormsModule, TuiInputPhoneInternational, TuiIcon, TuiTooltip], + templateUrl: './index.html', + styleUrls: ['./index.less'], + encapsulation, + changeDetection, + providers: [ + tuiInputPhoneInternationalOptionsProvider({ + metadata: defer(async () => + import('libphonenumber-js/max/metadata').then((m) => m.default), + ), + }), + ], +}) +export default class Example { + protected readonly countries: readonly TuiCountryIsoCode[] = [ + 'TR', + 'IR', + 'IQ', + 'SA', + 'YE', + ]; + + protected countryIsoCode: TuiCountryIsoCode = 'TR'; + protected value = ''; +} diff --git a/projects/demo/src/modules/components/input-phone-international/index.html b/projects/demo/src/modules/components/input-phone-international/index.html index 1ffc35d0e36f..161541ccfd3c 100644 --- a/projects/demo/src/modules/components/input-phone-international/index.html +++ b/projects/demo/src/modules/components/input-phone-international/index.html @@ -64,36 +64,47 @@ [description]="metadataDescription" > -

The first step is to choose the size of metadata.

+

+ The first step is to choose the size of + + metadata + - -

- Google - - uses - - the word - "metadata" - to refer to all information about phone numbering in a particular country - what the country - code, international and national dialling prefixes are, what carrier codes are operational, - which phone numbers are possible or valid for a particular country, how to optimally format - them, which prefixes represent a particular geographical area, etc. -
- + + Google + + uses + + the word + "metadata" + to refer to all information about phone numbering in a particular country - what the country + code, international and national dialling prefixes are, what carrier codes are operational, + which phone numbers are possible or valid for a particular country, how to optimally format + them, which prefixes represent a particular geographical area, etc. + + + . +

The complete list of all phone rules is huge, so libphonenumber-js provides different "metadata" sets to provides a way to optimize bundle size by choosing between - max + max , - min + min (default value) and - mobile + mobile sets.

@@ -155,6 +166,32 @@ Don't hesitate to use it too to manually format any phone number.
+ + + + You can put static + + Icon + + or even interactive + + Tooltip + + at the right side of the textfield. + + @@ -209,7 +246,7 @@ ISO-code of selected country - + diff --git a/projects/demo/src/modules/components/input-phone-international/index.ts b/projects/demo/src/modules/components/input-phone-international/index.ts index a1ae046b9bbd..8130d053a4ff 100644 --- a/projects/demo/src/modules/components/input-phone-international/index.ts +++ b/projects/demo/src/modules/components/input-phone-international/index.ts @@ -1,13 +1,15 @@ import {Component} from '@angular/core'; import {FormControl, ReactiveFormsModule, Validators} from '@angular/forms'; import {changeDetection} from '@demo/emulate/change-detection'; +import {DemoRoute} from '@demo/routes'; import {TuiDemo} from '@demo/utils'; import {tuiProvide} from '@taiga-ui/cdk'; -import {TuiDropdown, TuiHint, TuiTextfield} from '@taiga-ui/core'; +import {TuiDropdown, TuiHint, TuiIcon, TuiTextfield} from '@taiga-ui/core'; import type {TuiCountryIsoCode} from '@taiga-ui/i18n'; import { TuiInputPhoneInternational, tuiInputPhoneInternationalOptionsProvider, + TuiTooltip, } from '@taiga-ui/kit'; import {getCountries} from 'libphonenumber-js'; @@ -25,6 +27,8 @@ import {InheritedDocumentation} from '../abstract/inherited-documentation'; TuiInputPhoneInternational, TuiTextfield, ReactiveFormsModule, + TuiIcon, + TuiTooltip, ], templateUrl: './index.html', changeDetection, @@ -36,6 +40,7 @@ import {InheritedDocumentation} from '../abstract/inherited-documentation'; ], }) export default class PageComponent extends AbstractExampleTuiControl { + protected readonly routes = DemoRoute; protected readonly countriesVariants: ReadonlyArray = [ ['RU', 'KZ', 'UA', 'BY'], getCountries(), diff --git a/projects/kit/components/input-phone-international/input-phone-international.template.html b/projects/kit/components/input-phone-international/input-phone-international.template.html index 6fe976f9c575..50181aac141d 100644 --- a/projects/kit/components/input-phone-international/input-phone-international.template.html +++ b/projects/kit/components/input-phone-international/input-phone-international.template.html @@ -37,6 +37,8 @@ (ngModelChange)="onValueChange($event)" /> + + From d0a0948d983015bd91011a9be14ca1363df6c504 Mon Sep 17 00:00:00 2001 From: Nikita Barsukov Date: Fri, 30 Aug 2024 15:30:41 +0300 Subject: [PATCH 2/5] chore(kit): add `TODO` comment for `5.0` --- .../input-phone-international.template.html | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/projects/kit/components/input-phone-international/input-phone-international.template.html b/projects/kit/components/input-phone-international/input-phone-international.template.html index 50181aac141d..4b32fa8d309c 100644 --- a/projects/kit/components/input-phone-international/input-phone-international.template.html +++ b/projects/kit/components/input-phone-international/input-phone-international.template.html @@ -37,6 +37,14 @@ (ngModelChange)="onValueChange($event)" /> +