Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ npm install angular-cc-library --save
## Version Compatibility

| Angular | Library |
| ------- | ------- |
|---------|---------|
| 20.x | 3.6.x |
| 19.x | 3.5.x |
| 18.x | 3.4.x |
| 17.x | 3.3.x |
Expand Down
44 changes: 35 additions & 9 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"builder": "@angular-devkit/build-angular:application",
"options": {
"outputPath": "dist/example",
"outputPath": {
"base": "dist/example"
},
"index": "projects/example/src/index.html",
"main": "projects/example/src/main.ts",
"polyfills": "projects/example/src/polyfills.ts",
"polyfills": [
"projects/example/src/polyfills.ts"
],
"tsConfig": "projects/example/tsconfig.app.json",
"assets": [
"projects/example/src/favicon.ico",
Expand All @@ -74,12 +77,11 @@
"projects/example/src/styles.css"
],
"scripts": [],
"vendorChunk": true,
"extractLicenses": false,
"buildOptimizer": false,
"sourceMap": true,
"optimization": false,
"namedChunks": true
"namedChunks": true,
"browser": "projects/example/src/main.ts"
},
"configurations": {
"production": {
Expand All @@ -94,8 +96,6 @@
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
Expand Down Expand Up @@ -152,5 +152,31 @@
}
}
}
},
"schematics": {
"@schematics/angular:component": {
"type": "component"
},
"@schematics/angular:directive": {
"type": "directive"
},
"@schematics/angular:service": {
"type": "service"
},
"@schematics/angular:guard": {
"typeSeparator": "."
},
"@schematics/angular:interceptor": {
"typeSeparator": "."
},
"@schematics/angular:module": {
"typeSeparator": "."
},
"@schematics/angular:pipe": {
"typeSeparator": "."
},
"@schematics/angular:resolver": {
"typeSeparator": "."
}
}
}
40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,41 @@
"prepare": "husky"
},
"dependencies": {
"@angular/common": "^19.1.5",
"@angular/compiler": "^19.1.5",
"@angular/core": "^19.1.5",
"@angular/forms": "^19.1.5",
"@angular/platform-browser": "^19.1.5",
"@angular/platform-browser-dynamic": "^19.1.5",
"@angular/common": "^20.3.13",
"@angular/compiler": "^20.3.13",
"@angular/core": "^20.3.13",
"@angular/forms": "^20.3.13",
"@angular/platform-browser": "^20.3.13",
"@angular/platform-browser-dynamic": "^20.3.13",
"rxjs": "~7.8.1",
"tslib": "^2.8.1",
"zone.js": "~0.15.0"
},
"devDependencies": {
"@angular-builders/jest": "19.0.0",
"@angular-devkit/build-angular": "^19.1.6",
"@angular-eslint/builder": "19.0.2",
"@angular-eslint/eslint-plugin": "19.0.2",
"@angular-eslint/eslint-plugin-template": "19.0.2",
"@angular-eslint/schematics": "19.0.2",
"@angular-eslint/template-parser": "19.0.2",
"@angular/cli": "^19.1.6",
"@angular/compiler-cli": "^19.1.5",
"@angular/language-service": "^19.1.5",
"@angular-builders/jest": "20.0.0",
"@angular-devkit/build-angular": "^20.3.11",
"@angular-eslint/builder": "20.6.0",
"@angular-eslint/eslint-plugin": "20.6.0",
"@angular-eslint/eslint-plugin-template": "20.6.0",
"@angular-eslint/schematics": "20.6.0",
"@angular-eslint/template-parser": "20.6.0",
"@angular/cli": "^20.3.11",
"@angular/compiler-cli": "^20.3.13",
"@angular/language-service": "^20.3.13",
"@release-it/bumper": "^6.0.1",
"@release-it/conventional-changelog": "^8.0.2",
"@types/jest": "^29.5.14",
"@types/node": "^22.13.1",
"@typescript-eslint/eslint-plugin": "8.23.0",
"@typescript-eslint/parser": "8.23.0",
"@typescript-eslint/eslint-plugin": "8.47.0",
"@typescript-eslint/parser": "8.47.0",
"eslint": "^8.57.1",
"husky": "^9.1.7",
"jest": "29.7.0",
"lint-staged": "^15.4.3",
"ng-packagr": "^19.1.2",
"ng-packagr": "^20.3.2",
"release-it": "^17.11.0",
"ts-node": "~10.9.2",
"typescript": "~5.7.3"
"typescript": "~5.9.3"
},
"lint-staged": {
"*.{ts,component.html}": [
Expand Down
4 changes: 2 additions & 2 deletions projects/angular-cc-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"tslib": "^2.8.1"
},
"peerDependencies": {
"@angular/common": "^19.1.4",
"@angular/core": "^19.1.4"
"@angular/common": "^19.0.0 || ^20.0.0",
"@angular/core": "^19.0.0 || ^20.0.0"
}
}
2 changes: 1 addition & 1 deletion projects/angular-cc-library/src/lib/credit-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export class CreditCard {

try {
cursor = target.selectionStart;
} catch (error) {
} catch {
// do nothing
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Directive, ElementRef, HostListener, Optional, Self } from '@angular/core';
import { Directive, ElementRef, HostListener, inject } from '@angular/core';
import { CreditCard } from '../credit-card';
import { NgControl } from '@angular/forms';
import { BehaviorSubject } from 'rxjs';
Expand All @@ -9,18 +9,13 @@ import { BehaviorSubject } from 'rxjs';
standalone: true,
})
export class CreditCardFormatDirective {
private target: HTMLInputElement;
private el = inject(ElementRef);
private target: HTMLInputElement = this.el.nativeElement;
private control = inject(NgControl, { optional: true, self: true });
private cards = CreditCard.cards();

public resolvedScheme$ = new BehaviorSubject<string>('unknown');

constructor(
private el: ElementRef,
@Self() @Optional() private control: NgControl,
) {
this.target = this.el.nativeElement;
}

/**
* Updates the value to target element, or FormControl if exists.
* @param value New input value.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Directive, ElementRef, HostListener, Optional, Self } from '@angular/core';
import { Directive, ElementRef, HostListener, inject } from '@angular/core';
import { CreditCard } from '../credit-card';
import { NgControl } from '@angular/forms';

Expand All @@ -7,14 +7,9 @@ import { NgControl } from '@angular/forms';
standalone: true,
})
export class CvcFormatDirective {
private target: HTMLInputElement;

constructor(
private el: ElementRef,
@Self() @Optional() private control: NgControl,
) {
this.target = this.el.nativeElement;
}
private el = inject(ElementRef);
private target: HTMLInputElement = this.el.nativeElement;
private control = inject(NgControl, { optional: true, self: true });

/**
* Updates the value to target element, or FormControl if exists.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Directive, ElementRef, HostListener, Optional, Self } from '@angular/core';
import { Directive, ElementRef, HostListener, inject } from '@angular/core';
import { CreditCard } from '../credit-card';
import { NgControl } from '@angular/forms';

Expand All @@ -7,14 +7,9 @@ import { NgControl } from '@angular/forms';
standalone: true,
})
export class ExpiryFormatDirective {
private target: HTMLInputElement;

constructor(
private el: ElementRef,
@Self() @Optional() private control: NgControl,
) {
this.target = this.el.nativeElement;
}
private el = inject(ElementRef);
private target: HTMLInputElement = this.el.nativeElement;
private control = inject(NgControl, { optional: true, self: true });

/**
* Updates the value to target element, or FormControl if exists.
Expand Down
6 changes: 3 additions & 3 deletions projects/example/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AsyncPipe } from '@angular/common';
import { Component } from '@angular/core';
import { Component, inject } from '@angular/core';
import { Validators, FormGroup, FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { CreditCardValidators, CreditCard, CreditCardDirectivesModule } from 'angular-cc-library';
import { defer } from 'rxjs';
Expand All @@ -11,6 +11,8 @@ import { map } from 'rxjs/operators';
imports: [FormsModule, ReactiveFormsModule, AsyncPipe, CreditCardDirectivesModule]
})
export class AppComponent {
private fb = inject(FormBuilder);

public demoForm = this.fb.group({
creditCard: ['', [CreditCardValidators.validateCCNumber]],
expDate: ['', [CreditCardValidators.validateExpDate]],
Expand All @@ -22,8 +24,6 @@ export class AppComponent {
public type$ = defer(() => this.demoForm.get('creditCard').valueChanges)
.pipe(map((num: string) => CreditCard.cardType(num)));

constructor(private fb: FormBuilder) {}

public goToNextField(controlName: string, nextField: HTMLInputElement) {
if (this.demoForm.get(controlName)?.valid) {
nextField.focus();
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"noImplicitAny": true,
"esModuleInterop": true,
"noImplicitReturns": false,
"noImplicitThis": true,
"noUnusedParameters": true,
Expand All @@ -12,10 +13,9 @@
"strictNullChecks": false,
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "es2020",
"moduleResolution": "node",
"moduleResolution": "bundler",
"importHelpers": true,
"target": "ES2022",
"lib": [
Expand Down
Loading