Skip to content

Commit ad5a0bb

Browse files
Merge pull request #38 from juanjotorres90/feature/output-number-format
feat: ✨ add 'outputNumberFormat' option
2 parents 6c47e91 + ccd2887 commit ad5a0bb

File tree

16 files changed

+1917
-1988
lines changed

16 files changed

+1917
-1988
lines changed

.all-contributorsrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@
6060
"maintenance",
6161
"review"
6262
]
63+
},
64+
{
65+
"login": "Kamma31",
66+
"name": "Rant",
67+
"avatar_url": "https://avatars.githubusercontent.com/u/50776388?v=4?s=100",
68+
"profile": "https://github.com/Kamma31",
69+
"contributions": [
70+
"code",
71+
"doc",
72+
"ideas",
73+
"question",
74+
"maintenance",
75+
"review"
76+
]
6377
}
6478
],
6579
"contributorsPerLine": 7,

.github/workflows/ci.yml

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,34 @@ on:
66
pull_request:
77
branches: ['develop', 'main']
88

9+
permissions:
10+
actions: read
11+
contents: read
12+
913
jobs:
10-
build:
14+
main:
1115
runs-on: ubuntu-latest
12-
13-
strategy:
14-
matrix:
15-
node-version: [22.x]
1616
steps:
17-
- uses: actions/checkout@v3
18-
- name: Use Node.js ${{ matrix.node-version }}
19-
uses: actions/setup-node@v3
17+
- uses: actions/checkout@v4
2018
with:
21-
node-version: ${{ matrix.node-version }}
19+
fetch-depth: 0
20+
21+
# This enables task distribution via Nx Cloud
22+
# Run this command as early as possible, before dependencies are installed
23+
# Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun
24+
# Uncomment this line to enable task distribution
25+
# - run: npx nx-cloud start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="build"
26+
27+
# Cache node_modules
28+
- uses: actions/setup-node@v4
29+
with:
30+
node-version: 22
2231
cache: 'npm'
23-
- run: npm install
24-
- run: npm run lint:all --if-present
25-
- run: npm run unit-tests:all --if-present
26-
- run: npm run build:all --if-present
32+
33+
- run: npm ci --legacy-peer-deps
34+
- uses: nrwl/nx-set-shas@v4
35+
36+
# Prepend any command with "nx-cloud record --" to record its logs to Nx Cloud
37+
# - run: npx nx-cloud record -- echo Hello World
38+
# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected
39+
- run: npx nx affected -t lint test build

.husky/pre-push

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
npm run lint:all && npm run unit-tests:all && npm run build:all
1+
npx nx affected -t lint test build

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## [19.2.0] - 2025-01-25
9+
10+
### Added
11+
12+
- Add 'outputNumberFormat' option to set the output number to INTERNATIONAL, E164, or RFC3966 format.
13+
- Add css variables to customize the input field appearance ([#34](https://github.com/juanjotorres90/ngx-material-intl-tel-input/pull/34)).
14+
15+
### Fixed
16+
17+
- Clear the number input field when a form reset is triggered ([#37](https://github.com/juanjotorres90/ngx-material-intl-tel-input/issues/37)).
18+
- Fix cursor position when editing the number from the middle or start position ([#37](https://github.com/juanjotorres90/ngx-material-intl-tel-input/issues/37)).
19+
820
## [19.1.0] - 2024-12-21
921

1022
### Added

README.md

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors)
1+
[![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors)
22

33
[![npm version](https://img.shields.io/npm/v/ngx-material-intl-tel-input.svg?style=flat-square)](https://www.npmjs.com/package/ngx-material-intl-tel-input)
44
[![npm downloads total](https://img.shields.io/npm/dt/ngx-material-intl-tel-input.svg?style=flat-square)](https://www.npmjs.com/package/ngx-material-intl-tel-input)
@@ -20,7 +20,7 @@ Validation with [google-libphonenumber](https://github.com/google/libphonenumber
2020

2121
| ngx-material-intl-tel-input | Angular |
2222
| --------------------------- | --------- |
23-
| 19.0.0 - 19.1.0 | >= 19.0.0 |
23+
| 19.0.0 - 19.2.0 | >= 19.0.0 |
2424
| 18.0.0 - 18.2.1 | >= 18.0.0 |
2525
| 0.0.1 - 17.3.0 | >= 17.2.0 |
2626

@@ -76,6 +76,7 @@ imports: [NgxMaterialIntlTelInputComponent];
7676
| useMask | `boolean` | `false` | Use mask for phone number input. |
7777
| forceSelectedCountryCode | `boolean` | `false` | If useMask is active it forces the selected country code to be displayed |
7878
| showMaskPlaceholder | `boolean` | `false` | If useMask is active it shows the placeholder for the mask |
79+
| outputNumberFormat | `PhoneNumberFormat` | `PhoneNumberFormat.INTERNATIONAL` | Sets the output number format to INTERNATIONAL, E164, or RFC3966 format |
7980
| textLabels | `TextLabels` | {mainLabel: 'Phone number', codePlaceholder: 'Code', searchPlaceholderLabel: 'Search', noEntriesFoundLabel: 'No countries found', nationalNumberLabel: 'Number', hintLabel: 'Select country and type your phone number', invalidNumberError: 'Number is not valid', requiredError: 'This field is required'} | Overrides all component text labels |
8081

8182
## Events
@@ -86,6 +87,69 @@ imports: [NgxMaterialIntlTelInputComponent];
8687
| currentCountryCode | `string` | `''` | Country code value emitted when the value of the input changes. |
8788
| currentCountryISO | `string` | `''` | Country ISO value emitted when the value of the input changes. |
8889

90+
# CSS Custom Properties Reference
91+
92+
## 🎨 Component Styling Variables
93+
94+
### Container Styles
95+
96+
- `--mdc-filled-tel-form-outline-width`: Outline width (`default: 1px`)
97+
- `--mdc-filled-tel-form-outline-color`: Border color (`default: #d8d8d8`)
98+
- `--mdc-filled-tel-form-background`: Background color (`default: #fbfbfb`)
99+
- `--mdc-filled-tel-form-container-shape`: Border radius (`default: 8px`)
100+
101+
### Focus States
102+
103+
- `--mdc-filled-tel-form-focus-outline-color`: Focus border color (`default: rgb(32, 159, 252)`)
104+
- `--mdc-filled-tel-form-focus-background`: Focus background (`default: #fff`)
105+
106+
### Hover States
107+
108+
- `--mdc-filled-tel-form-hover-background`: Hover background (`default: #f5f5f5`)
109+
- `--mdc-outline-tel-form-hover-background`: Outline variant hover background (`default: #f5f5f5`)
110+
111+
## 📱 Input Field Customization
112+
113+
### Appearance
114+
115+
- `--mdc-outline-tel-form-background`: Outline variant background (`default: #fbfbfb`)
116+
- `--mdc-tel-form-placeholder-color`: Input placeholder color (`default: #ccc`)
117+
- `--mdc-tel-form-icon-color`: Action icon color (`default: #909090`)
118+
119+
### Shape Customization
120+
121+
- `--mdc-outlined-tel-form-container-shape`: Outline field border radius (`default: Material system variable`)
122+
- `--mdc-outlined-text-field-container-shape`: Text field border radius (`default: Material system variable`)
123+
124+
## 🔍 Validation & Feedback
125+
126+
- `--mdc-tel-form-hint-color`: Hint text color (`default: #b2b2b2`)
127+
- `--mdc-tel-form-error-color`: Error message color (`default: Material system error`)
128+
- `--mat-sys-error`: Material system error fallback (`default: #f44336`)
129+
130+
## 🖌️ Theme Integration
131+
132+
- `--mdc-theme-primary`: Primary theme color (`default: rgb(32, 159, 252)`)
133+
- `--mdc-theme-error`: Error state color (`default: #f44336`)
134+
- `--mat-sys-corner-extra-small`: Material system small corner radius
135+
136+
## Example Configuration
137+
138+
```css
139+
:root {
140+
/* Container Customization */
141+
--mdc-filled-tel-form-background: #f8f9fa;
142+
--mdc-filled-tel-form-container-shape: 6px;
143+
144+
/* Theme Colors */
145+
--mdc-theme-primary: #2a7de1;
146+
--mdc-tel-form-error-color: #dc3545;
147+
148+
/* Input Styling */
149+
--mdc-tel-form-placeholder-color: #a0aec0;
150+
}
151+
```
152+
89153
## Contribute and develop locally
90154

91155
<a alt="Nx logo" href="https://nx.dev" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="45"></a>
@@ -148,6 +212,7 @@ Thanks goes to these wonderful people:
148212
<td align="center"><a href="https://github.com/whegar"><img src="https://avatars3.githubusercontent.com/u/5524772?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Rafa Hernández</b></sub></a><br /> <a href="https://github.com/juanjotorres90/ngx-material-intl-tel-input/commits?author=whegar" title="Code">💻</a> <a href="#ideas-whegar" title="Ideas, Planning, & Feedback">🤔</a> <a href="#question-whegar" title="Answering Questions">💬</a> <a href="#infra-whegar" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-whegar" title="Maintenance">🚧</a> <a href="https://github.com/juanjotorres90/ngx-material-intl-tel-input/pulls?q=is%3Apr+reviewed-by%whegar" title="Reviewed Pull Requests">👀</a></td>
149213
<td align="center"><a href="https://github.com/ghollingworthh"><img src="https://avatars.githubusercontent.com/u/26550815?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Glen Hollingworth</b></sub></a><br /> <a href="https://github.com/juanjotorres90/ngx-material-intl-tel-input/commits?author=ghollingworthh" title="Code">💻</a> <a href="#ideas-ghollingworthh" title="Ideas, Planning, & Feedback">🤔</a> <a href="#question-ghollingworthh" title="Answering Questions">💬</a> <a href="#example-ghollingworthh" title="Examples">💡</a> <a href="#maintenance-ghollingworthh" title="Maintenance">🚧</a> <a href="https://github.com/juanjotorres90/ngx-material-intl-tel-input/pulls?q=is%3Apr+reviewed-by%ghollingworthh" title="Reviewed Pull Requests">👀</a></td>
150214
<td align="center"><a href="https://github.com/EphraimHaber"><img src="https://avatars.githubusercontent.com/u/61934858?v=4?s=100" width="100px;" alt=""/><br /><sub><b>EphraimHaber</b></sub></a><br /> <a href="https://github.com/juanjotorres90/ngx-material-intl-tel-input/commits?author=EphraimHaber" title="Code">💻</a> <a href="#ideas-EphraimHaber" title="Ideas, Planning, & Feedback">🤔</a> <a href="#question-EphraimHaber" title="Answering Questions">💬</a> <a href="#example-EphraimHaber" title="Examples">💡</a> <a href="#maintenance-EphraimHaber" title="Maintenance">🚧</a> <a href="https://github.com/juanjotorres90/ngx-material-intl-tel-input/pulls?q=is%3Apr+reviewed-by%EphraimHaber" title="Reviewed Pull Requests">👀</a></td>
215+
<td align="center"><a href="https://github.com/Kamma31"><img src="https://avatars.githubusercontent.com/u/50776388?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Rant</b></sub></a><br /> <a href="https://github.com/juanjotorres90/ngx-material-intl-tel-input/commits?author=Kamma31" title="Code">💻</a> <a href="#ideas-Kamma31" title="Ideas, Planning, & Feedback">🤔</a> <a href="#question-Kamma31" title="Answering Questions">💬</a> <a href="#example-Kamma31" title="Examples">💡</a> <a href="#maintenance-Kamma31" title="Maintenance">🚧</a> <a href="https://github.com/juanjotorres90/ngx-material-intl-tel-input/pulls?q=is%3Apr+reviewed-by%Kamma31" title="Reviewed Pull Requests">👀</a></td>
151216
</table>
152217

153218
<!-- markdownlint-restore -->

apps/ngx-material-intl-tel-input/src/app/app.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010
[useMask]="false"
1111
[forceSelectedCountryCode]="false"
1212
[showMaskPlaceholder]="true"
13+
[outputNumberFormat]="PhoneNumberFormat.INTERNATIONAL"
14+
[appearance]="'fill'"
1315
></ngx-material-intl-tel-input>
1416
<button mat-flat-button type="submit" [disabled]="!formTestGroup.valid">
1517
Submit
1618
</button>
19+
<button mat-flat-button (click)="resetForm()" type="button">Reset</button>
1720

1821
<mat-checkbox (change)="toggleShowSetPhoneInput()"
1922
>Show input to change number</mat-checkbox

apps/ngx-material-intl-tel-input/src/app/app.component.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { MatChipsModule } from '@angular/material/chips';
1111
import { MatFormFieldModule } from '@angular/material/form-field';
1212
import { MatInputModule } from '@angular/material/input';
1313
import { RouterModule } from '@angular/router';
14+
import { PhoneNumberFormat } from 'google-libphonenumber';
1415
import { NgxMaterialIntlTelInputComponent } from 'ngx-material-intl-tel-input';
1516

1617
@Component({
@@ -37,6 +38,7 @@ export class AppComponent {
3738
submittedPhoneValue = signal<string>('');
3839
formTestGroup: FormGroup;
3940
showSetPhoneInput = signal<boolean>(false);
41+
PhoneNumberFormat = PhoneNumberFormat;
4042

4143
constructor(private fb: FormBuilder) {
4244
this.formTestGroup = this.fb.group({
@@ -94,4 +96,11 @@ export class AppComponent {
9496
getCountryISO(value: string): void {
9597
this.currentCountryISO.set(value);
9698
}
99+
100+
/**
101+
* Resets the form group to its initial state, clearing all form controls.
102+
*/
103+
resetForm(): void {
104+
this.formTestGroup.reset();
105+
}
97106
}

0 commit comments

Comments
 (0)