Skip to content

Commit 46a1d36

Browse files
authored
Merge pull request #59 from mpalourdio/input
fix: Drop `model()` in favor of `input()`.
2 parents 6b9349a + 3c906b2 commit 46a1d36

File tree

5 files changed

+31
-27
lines changed

5 files changed

+31
-27
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v0.16.0
4+
5+
- Drop `model()` in favor of `input()`.
6+
37
## v0.15.0
48

59
- Drop `@Input` in favor of `signals`.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "intl-tel-input-ng",
3-
"version": "0.15.0",
3+
"version": "0.16.0",
44
"scripts": {
55
"ng": "ng",
66
"build": "ng build",

src/lib/components/intl-tel-input.component.spec.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('IntlTelInputComponent', () => {
4040
});
4141

4242
it('should convert phone number to E164 format', () => {
43-
component.options.set({
43+
fixture.componentRef.setInput('options', {
4444
preferredCountries: ['ch'],
4545
onlyCountries: ['ch', 'fr']
4646
});
@@ -52,7 +52,7 @@ describe('IntlTelInputComponent', () => {
5252
});
5353

5454
it('should re-set E164 phone number on countryChange', () => {
55-
component.options.set({
55+
fixture.componentRef.setInput('options', {
5656
preferredCountries: ['ch'],
5757
onlyCountries: ['ch', 'fr']
5858
});
@@ -70,7 +70,7 @@ describe('IntlTelInputComponent', () => {
7070

7171
it('should add a label tag if label attribute is set', () => {
7272
const labelText = 'label text';
73-
component.label.set(labelText);
73+
fixture.componentRef.setInput('label', labelText);
7474
fixture.detectChanges();
7575

7676
const element = fixture
@@ -91,7 +91,7 @@ describe('IntlTelInputComponent', () => {
9191
});
9292

9393
it('should not have a css class by default for the label', () => {
94-
component.label.set('label');
94+
fixture.componentRef.setInput('label', 'label');
9595
fixture.detectChanges();
9696

9797
const element = fixture
@@ -103,8 +103,8 @@ describe('IntlTelInputComponent', () => {
103103
});
104104

105105
it('should be possible to specify a css class for the label', () => {
106-
component.label.set('label');
107-
component.labelCssClass.set('label-css-class');
106+
fixture.componentRef.setInput('label', 'label');
107+
fixture.componentRef.setInput('labelCssClass', 'labelCssClass');
108108
fixture.detectChanges();
109109

110110
const element = fixture
@@ -116,7 +116,8 @@ describe('IntlTelInputComponent', () => {
116116
});
117117

118118
it('should set both required and aria-required if specified', () => {
119-
component.required.set(true);
119+
fixture.componentRef.setInput('required', true);
120+
120121
fixture.detectChanges();
121122

122123
const element: HTMLElement = fixture
@@ -139,21 +140,22 @@ describe('IntlTelInputComponent', () => {
139140
});
140141

141142
it('should set name and id to the same value', () => {
142-
component.name.set('custom-name');
143+
fixture.componentRef.setInput('name', 'custom-name');
143144
fixture.detectChanges();
144145

145146
const element: HTMLElement = fixture
146147
.debugElement
147148
.query(By.css('input'))
148149
.nativeElement;
149-
console.log(component.name());
150+
150151
expect(element.getAttribute('name')).toBe(component.name());
151152
expect(element.getAttribute('name')).toBe(element.getAttribute('id'));
152153
});
153154

154155
it('should allow specifying a css class', () => {
155156
const cssClass = 'my-css-class';
156-
component.cssClass.set(cssClass);
157+
fixture.componentRef.setInput('cssClass', cssClass);
158+
157159
fixture.detectChanges();
158160

159161
const element: HTMLElement = fixture
@@ -165,16 +167,14 @@ console.log(component.name());
165167
});
166168

167169
it('should be possible to set preferredCountries option', () => {
168-
component.options.set({
170+
fixture.componentRef.setInput('options', {
169171
countrySearch: false,
170172
preferredCountries: ['ch'],
171173
onlyCountries: ['ch']
172174
});
173175
component.ngAfterViewInit();
174-
175176
fixture.detectChanges();
176-
console.log(fixture
177-
.debugElement);
177+
178178
const element = fixture
179179
.debugElement
180180
.query(By.css('#intl-tel-input-name'))
@@ -187,7 +187,7 @@ console.log(fixture
187187

188188
it('should be possible to set i18n option', () => {
189189
const localizedCountryName = 'Suisse';
190-
component.options.set({
190+
fixture.componentRef.setInput('options', {
191191
preferredCountries: ['ch'],
192192
i18n: { ch: localizedCountryName },
193193
onlyCountries: ['ch']

src/lib/components/intl-tel-input.component.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
88
*/
99

10-
import { AfterViewInit, Component, ElementRef, model, ViewChild } from '@angular/core';
10+
import { NgClass } from '@angular/common';
11+
import { AfterViewInit, Component, ElementRef, input, model, ViewChild } from '@angular/core';
1112
import { ControlContainer, FormsModule, NgForm } from '@angular/forms';
1213
import intlTelInput from 'intl-tel-input';
14+
import { IntlTelInput } from '../model/intl-tel-input';
1315
import { IntlTelInputOptions } from '../model/intl-tel-input-options';
14-
import { IntlTelInput } from "../model/intl-tel-input";
15-
import { NgClass } from "@angular/common";
1616

1717
@Component({
1818
selector: 'intl-tel-input',
@@ -24,12 +24,12 @@ import { NgClass } from "@angular/common";
2424
})
2525
export class IntlTelInputComponent implements AfterViewInit {
2626

27-
readonly cssClass = model<string>();
28-
readonly label = model<string>();
29-
readonly labelCssClass = model<string>();
30-
readonly name = model<string>('intl-tel-input-name');
31-
readonly options = model<IntlTelInputOptions>({});
32-
readonly required = model<boolean>(false);
27+
readonly cssClass = input<string>();
28+
readonly label = input<string>();
29+
readonly labelCssClass = input<string>();
30+
readonly name = input<string>('intl-tel-input-name');
31+
readonly options = input<IntlTelInputOptions>({});
32+
readonly required = input<boolean>(false);
3333
readonly E164PhoneNumber = model<string | null>();
3434
@ViewChild('intlTelInput') private readonly _inputElement!: ElementRef;
3535
private _phoneNumber!: string;

0 commit comments

Comments
 (0)