Skip to content

Commit 5ae5e80

Browse files
nerPatriciapatricia.costa
andauthored
Update to Angular 19 (#128)
* chore(packages): update angular builders/jest package to version 19 * chore(packages): update angular packages with schematics to v19 * chore(packages): update angular eslint to v19 * chore(packages): update typescript to v5.7.3 * chore(packages): update peer dependencies to angular v19 * chore(version): update lib version 3.5.0 * chore: update readme * test: fix tests with standalone component now * chore(packages): update outdated packages * chore(lock): update lock with new packages versions * chore(lint): add lint ignore and rmv deprecated ignorePatterns * chore: update lib version * chore: revert version number --------- Co-authored-by: patricia.costa <patricia.costa@telefonicabigdata.onmicrosoft.com>
1 parent 13bdb56 commit 5ae5e80

File tree

8 files changed

+3000
-2694
lines changed

8 files changed

+3000
-2694
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

.eslintrc.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
22
"root": true,
3-
"ignorePatterns": [
4-
"projects/**/*"
5-
],
63
"overrides": [
74
{
85
"files": [

README.md

Lines changed: 49 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@ Or run locally:
2424
# Usage
2525

2626
## Installation
27+
2728
```shell
2829
npm install angular-cc-library --save
2930
```
3031

3132
## Version Compatibility
3233

3334
| Angular | Library |
34-
|---------|---------|
35+
| ------- | ------- |
36+
| 19.x | 3.5.x |
3537
| 18.x | 3.4.x |
3638
| 17.x | 3.3.x |
3739
| 16.x | 3.2.x |
@@ -40,92 +42,103 @@ npm install angular-cc-library --save
4042
| 13.x | 3.0.0 |
4143
| 12.x | 2.1.3 |
4244

43-
4445
## Formatting Directive
46+
4547
On the input fields, add the specific directive to format inputs.
4648
All fields must be `type='tel'` in order to support spacing and additional characters.
4749

48-
Since `angular-cc-library@3.3.0` all directives declared as standalone,
50+
Since `angular-cc-library@3.3.0` all directives declared as standalone,
4951
so you can import them directly into your component:
5052

5153
```typescript
52-
import { Component } from '@angular/core';
53-
import { CreditCardFormatDirective } from 'angular-cc-library';
54+
import { Component } from "@angular/core";
55+
import { CreditCardFormatDirective } from "angular-cc-library";
5456

5557
@Component({
56-
selector: 'credit-card-number-input',
58+
selector: "credit-card-number-input",
5759
standalone: true,
5860
deps: [CreditCardFormatDirective],
59-
template: `<input id="cc-number" type="tel" autocomplete="cc-number" ccNumber>`
61+
template: `<input
62+
id="cc-number"
63+
type="tel"
64+
autocomplete="cc-number"
65+
ccNumber
66+
/>`,
6067
})
6168
export class CreditCardNumberInputComponent {}
6269
```
6370

6471
But you can still import them all at once using `CreditCardDirectivesModule`:
6572

6673
```typescript
67-
import { NgModule } from '@angular/core';
68-
import { BrowserModule } from '@angular/platform-browser';
69-
import { FormsModule } from '@angular/forms';
70-
import { CreditCardDirectivesModule } from 'angular-cc-library';
74+
import { NgModule } from "@angular/core";
75+
import { BrowserModule } from "@angular/platform-browser";
76+
import { FormsModule } from "@angular/forms";
77+
import { CreditCardDirectivesModule } from "angular-cc-library";
7178

72-
import { AppComponent } from './app.component';
79+
import { AppComponent } from "./app.component";
7380

7481
@NgModule({
75-
imports: [BrowserModule, FormsModule, CreditCardDirectivesModule],
76-
declarations: [AppComponent],
77-
bootstrap: [AppComponent]
82+
imports: [BrowserModule, FormsModule, CreditCardDirectivesModule],
83+
declarations: [AppComponent],
84+
bootstrap: [AppComponent],
7885
})
79-
export class AppModule {
80-
}
86+
export class AppModule {}
8187
```
8288

8389
**Credit Card Formatter**
84-
* add `ccNumber` directive:
90+
91+
- add `ccNumber` directive:
92+
8593
```html
86-
<input id="cc-number" type="tel" autocomplete="cc-number" ccNumber>
94+
<input id="cc-number" type="tel" autocomplete="cc-number" ccNumber />
8795
```
88-
* this will also apply a class name based off the card `.visa`, `.amex`, etc. See the array of card types in `credit-card.ts` for all available types
8996

90-
* You can get parsed card type by using export api:
97+
- this will also apply a class name based off the card `.visa`, `.amex`, etc. See the array of card types in `credit-card.ts` for all available types
98+
99+
- You can get parsed card type by using export api:
91100

92101
```html
93-
<input type="tel" ccNumber #ccNumber="ccNumber">
102+
<input type="tel" ccNumber #ccNumber="ccNumber" />
94103
<span class="scheme">{{ccNumber.resolvedScheme$ | async}}</span>
95104
```
96105

97106
`resolvedScheme$` will be populated with `visa`, `amex`, etc.
98107

99-
100108
**Expiration Date Formatter**
101109
Will support format of MM/YY or MM/YYYY
102-
* add `ccExp` directive:
110+
111+
- add `ccExp` directive:
112+
103113
```html
104-
<input id="cc-exp-date" type="tel" autocomplete="cc-exp" ccExp>
114+
<input id="cc-exp-date" type="tel" autocomplete="cc-exp" ccExp />
105115
```
106116

107117
**CVC Formater**
108-
* add `ccCVC` directive:
118+
119+
- add `ccCVC` directive:
120+
109121
```html
110-
<input id="cc-cvc" type="tel" autocomplete="off" ccCVC>
122+
<input id="cc-cvc" type="tel" autocomplete="off" ccCVC />
111123
```
112124

113125
### Validation
126+
114127
Current only Model Validation is supported.
115128
To implement, import the validator library and apply the specific validator on each form control
116129

117130
```typescript
118-
import { CreditCardValidators } from 'angular-cc-library';
131+
import { CreditCardValidators } from "angular-cc-library";
119132

120133
@Component({
121-
selector: 'app',
134+
selector: "app",
122135
template: `
123136
<form #demoForm="ngForm" (ngSubmit)="onSubmit(demoForm)" novalidate>
124137
<input id="cc-number" formControlName="creditCard" type="tel" autocomplete="cc-number" ccNumber>
125138
<input id="cc-exp-date" formControlName="expirationDate" type="tel" autocomplete="cc-exp" ccExp>
126139
<input id="cc-cvc" formControlName="cvc" type="tel" autocomplete="off" ccCVC>
127140
</form>
128-
`
141+
`,
129142
})
130143
export class AppComponent implements OnInit {
131144
form: FormGroup;
@@ -135,9 +148,12 @@ export class AppComponent implements OnInit {
135148

136149
ngOnInit() {
137150
this.form = this._fb.group({
138-
creditCard: ['', [CreditCardValidators.validateCCNumber]],
139-
expirationDate: ['', [CreditCardValidators.validateExpDate]],
140-
cvc: ['', [Validators.required, Validators.minLength(3), Validators.maxLength(4)]]
151+
creditCard: ["", [CreditCardValidators.validateCCNumber]],
152+
expirationDate: ["", [CreditCardValidators.validateExpDate]],
153+
cvc: [
154+
"",
155+
[Validators.required, Validators.minLength(3), Validators.maxLength(4)],
156+
],
141157
});
142158
}
143159

package.json

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,41 @@
1313
"prepare": "husky"
1414
},
1515
"dependencies": {
16-
"@angular/common": "^18.2.2",
17-
"@angular/compiler": "^18.2.2",
18-
"@angular/core": "^18.2.2",
19-
"@angular/forms": "^18.2.2",
20-
"@angular/platform-browser": "^18.2.2",
21-
"@angular/platform-browser-dynamic": "^18.2.2",
16+
"@angular/common": "^19.1.5",
17+
"@angular/compiler": "^19.1.5",
18+
"@angular/core": "^19.1.5",
19+
"@angular/forms": "^19.1.5",
20+
"@angular/platform-browser": "^19.1.5",
21+
"@angular/platform-browser-dynamic": "^19.1.5",
2222
"rxjs": "~7.8.1",
23-
"tslib": "^2.7.0",
24-
"zone.js": "~0.14.10"
23+
"tslib": "^2.8.1",
24+
"zone.js": "~0.15.0"
2525
},
2626
"devDependencies": {
27-
"@angular-builders/jest": "18.0.0",
28-
"@angular-devkit/build-angular": "^18.2.2",
29-
"@angular-eslint/builder": "18.3.0",
30-
"@angular-eslint/eslint-plugin": "18.3.0",
31-
"@angular-eslint/eslint-plugin-template": "18.3.0",
32-
"@angular-eslint/schematics": "18.3.0",
33-
"@angular-eslint/template-parser": "18.3.0",
34-
"@angular/cli": "^18.2.2",
35-
"@angular/compiler-cli": "^18.2.2",
36-
"@angular/language-service": "^18.2.2",
27+
"@angular-builders/jest": "19.0.0",
28+
"@angular-devkit/build-angular": "^19.1.6",
29+
"@angular-eslint/builder": "19.0.2",
30+
"@angular-eslint/eslint-plugin": "19.0.2",
31+
"@angular-eslint/eslint-plugin-template": "19.0.2",
32+
"@angular-eslint/schematics": "19.0.2",
33+
"@angular-eslint/template-parser": "19.0.2",
34+
"@angular/cli": "^19.1.6",
35+
"@angular/compiler-cli": "^19.1.5",
36+
"@angular/language-service": "^19.1.5",
3737
"@release-it/bumper": "^6.0.1",
38-
"@release-it/conventional-changelog": "^8.0.1",
39-
"@types/jest": "^29.5.12",
40-
"@types/node": "^22.5.3",
41-
"@typescript-eslint/eslint-plugin": "8.4.0",
42-
"@typescript-eslint/parser": "8.4.0",
43-
"eslint": "^8.56.0",
44-
"husky": "^9.1.5",
38+
"@release-it/conventional-changelog": "^8.0.2",
39+
"@types/jest": "^29.5.14",
40+
"@types/node": "^22.13.1",
41+
"@typescript-eslint/eslint-plugin": "8.23.0",
42+
"@typescript-eslint/parser": "8.23.0",
43+
"eslint": "^8.57.1",
44+
"husky": "^9.1.7",
4545
"jest": "29.7.0",
46-
"lint-staged": "^15.2.10",
47-
"ng-packagr": "^18.2.1",
48-
"release-it": "^17.6.0",
46+
"lint-staged": "^15.4.3",
47+
"ng-packagr": "^19.1.2",
48+
"release-it": "^17.11.0",
4949
"ts-node": "~10.9.2",
50-
"typescript": "~5.5.4"
50+
"typescript": "~5.7.3"
5151
},
5252
"lint-staged": {
5353
"*.{ts,component.html}": [

projects/angular-cc-library/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
"url": "git+https://github.com/timofei-iatsenko/angular-cc-library.git"
2121
},
2222
"dependencies": {
23-
"tslib": "^2.4.1"
23+
"tslib": "^2.8.1"
2424
},
2525
"peerDependencies": {
26-
"@angular/common": "^18.0.0",
27-
"@angular/core": "^18.0.0"
26+
"@angular/common": "^19.1.4",
27+
"@angular/core": "^19.1.4"
2828
}
2929
}

projects/angular-cc-library/src/lib/directives/credit-card-format.directive.spec.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testin
22
import { CreditCardFormatDirective } from './credit-card-format.directive';
33
import { Component, DebugElement } from '@angular/core';
44
import { By } from '@angular/platform-browser';
5+
import { CommonModule } from '@angular/common';
56

67
const KEY_MAP = {
78
ONE: 49, // input `1`
@@ -22,15 +23,15 @@ describe('Directive: CreditCardFormat', () => {
2223
describe('general cases', () => {
2324
@Component({
2425
template: `<input type="tel" ccNumber>`,
26+
imports: [CreditCardFormatDirective],
2527
})
2628
class TestCreditCardFormatComponent {}
2729

2830
let fixture: ComponentFixture<TestCreditCardFormatComponent>;
2931
let inputEl: DebugElement;
3032
beforeEach(() => {
3133
TestBed.configureTestingModule({
32-
declarations: [TestCreditCardFormatComponent],
33-
imports: [CreditCardFormatDirective]
34+
imports: [TestCreditCardFormatComponent]
3435
});
3536
fixture = TestBed.createComponent(TestCreditCardFormatComponent);
3637
inputEl = fixture.debugElement.query(By.css('input'));
@@ -144,7 +145,8 @@ describe('Directive: CreditCardFormat', () => {
144145
describe('exportAs cases', () => {
145146
@Component({
146147
template: `<input type="tel" ccNumber #ccNumber="ccNumber">
147-
<span class="scheme">{{ccNumber.resolvedScheme$ | async}}</span>`,
148+
<span class="scheme">{{ ccNumber.resolvedScheme$ | async }}</span>`,
149+
imports: [CreditCardFormatDirective, CommonModule],
148150
})
149151
class TestCreditCardFormatComponent {}
150152

@@ -153,8 +155,7 @@ describe('Directive: CreditCardFormat', () => {
153155

154156
beforeEach(() => {
155157
TestBed.configureTestingModule({
156-
declarations: [TestCreditCardFormatComponent],
157-
imports: [CreditCardFormatDirective],
158+
imports: [TestCreditCardFormatComponent],
158159
});
159160
fixture = TestBed.createComponent(TestCreditCardFormatComponent);
160161
inputEl = fixture.debugElement.query(By.css('input'));

projects/example/src/app/app.component.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ import { defer } from 'rxjs';
66
import { map } from 'rxjs/operators';
77

88
@Component({
9-
selector: 'app-root',
10-
templateUrl: './app.component.html',
11-
standalone: true,
12-
imports: [FormsModule, ReactiveFormsModule, AsyncPipe, CreditCardDirectivesModule]
9+
selector: 'app-root',
10+
templateUrl: './app.component.html',
11+
imports: [FormsModule, ReactiveFormsModule, AsyncPipe, CreditCardDirectivesModule]
1312
})
1413
export class AppComponent {
1514
public demoForm = this.fb.group({

0 commit comments

Comments
 (0)