Skip to content

Commit 986b3e1

Browse files
committed
feat(project): delete dependancy to primeng
1 parent e57a2aa commit 986b3e1

20 files changed

+266
-61
lines changed

apps/angular/di/.eslintrc.json

+1-18
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,7 @@
44
"overrides": [
55
{
66
"files": ["*.ts"],
7-
"rules": {
8-
"@angular-eslint/directive-selector": [
9-
"error",
10-
{
11-
"type": "attribute",
12-
"prefix": "app",
13-
"style": "camelCase"
14-
}
15-
],
16-
"@angular-eslint/component-selector": [
17-
"error",
18-
{
19-
"type": "element",
20-
"prefix": "app",
21-
"style": "kebab-case"
22-
}
23-
]
24-
},
7+
"rules": {},
258
"extends": [
269
"plugin:@nx/angular",
2710
"plugin:@angular-eslint/template/process-inline-templates"

apps/angular/di/project.json

+1-6
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@
1919
"apps/angular/di/src/favicon.ico",
2020
"apps/angular/di/src/assets"
2121
],
22-
"styles": [
23-
"apps/angular/di/src/styles.scss",
24-
"node_modules/primeicons/primeicons.css",
25-
"node_modules/primeng/resources/themes/lara-light-blue/theme.css",
26-
"node_modules/primeng/resources/primeng.min.css"
27-
],
22+
"styles": ["apps/angular/di/src/styles.scss"],
2823
"scripts": []
2924
},
3025
"configurations": {

apps/angular/di/src/app/app.component.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
/* eslint-disable @angular-eslint/directive-selector */
1+
import { TableComponent } from '@angular-challenges/angular/di';
22
import { AsyncPipe, NgFor } from '@angular/common';
33
import { Component, Directive } from '@angular/core';
4-
import { TableModule } from 'primeng/table';
54
import { CurrencyPipe } from './currency.pipe';
65
import { CurrencyService } from './currency.service';
76
import { Product, products } from './product.model';
@@ -11,7 +10,7 @@ interface ProductContext {
1110
}
1211

1312
@Directive({
14-
selector: 'ng-template[pTemplate="body"]',
13+
selector: 'ng-template[product]',
1514
standalone: true,
1615
})
1716
export class ProductDirective {
@@ -25,27 +24,27 @@ export class ProductDirective {
2524

2625
@Component({
2726
standalone: true,
28-
imports: [TableModule, CurrencyPipe, AsyncPipe, NgFor, ProductDirective],
27+
imports: [TableComponent, CurrencyPipe, AsyncPipe, NgFor, ProductDirective],
2928
providers: [CurrencyService],
3029
selector: 'app-root',
3130
template: `
32-
<p-table [value]="products">
33-
<ng-template pTemplate="header">
31+
<table [items]="products">
32+
<ng-template #header>
3433
<tr>
3534
<th *ngFor="let col of displayedColumns">
3635
{{ col }}
3736
</th>
3837
</tr>
3938
</ng-template>
40-
<ng-template pTemplate="body" let-product>
39+
<ng-template #body product let-product>
4140
<tr>
4241
<td>{{ product.name }}</td>
4342
<td>{{ product.priceA | currency | async }}</td>
4443
<td>{{ product.priceB | currency | async }}</td>
4544
<td>{{ product.priceC | currency | async }}</td>
4645
</tr>
4746
</ng-template>
48-
</p-table>
47+
</table>
4948
`,
5049
})
5150
export class AppComponent {

apps/angular/di/src/styles.scss

+21-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,21 @@
1-
/* You can add global styles to this file, and also import other style files */
1+
table {
2+
width: 100%;
3+
}
4+
5+
table thead > tr > th {
6+
text-align: left;
7+
padding: 1rem 1rem;
8+
border: 1px solid #dee2e6;
9+
border-width: 0 0 1px 0;
10+
font-weight: 700;
11+
color: #343a40;
12+
background: #f8f9fa;
13+
transition: box-shadow 0.2s;
14+
}
15+
16+
table tbody > tr > td {
17+
text-align: left;
18+
border: 1px solid #dee2e6;
19+
border-width: 0 0 1px 0;
20+
padding: 1rem 1rem;
21+
}

libs/angular/di/.eslintrc.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"extends": ["../../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts"],
7+
"extends": [
8+
"plugin:@nx/angular",
9+
"plugin:@angular-eslint/template/process-inline-templates"
10+
],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.html"],
15+
"extends": ["plugin:@nx/angular-template"],
16+
"rules": {}
17+
},
18+
{
19+
"files": ["*.json"],
20+
"parser": "jsonc-eslint-parser",
21+
"rules": {
22+
"@nx/dependency-checks": "error"
23+
}
24+
}
25+
]
26+
}

libs/angular/di/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# angular/di
2+
3+
This library was generated with [Nx](https://nx.dev).
4+
5+
## Running unit tests
6+
7+
Run `nx test angular/di` to execute the unit tests.

libs/angular/di/jest.config.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* eslint-disable */
2+
export default {
3+
displayName: 'angular/di',
4+
preset: '../../../jest.preset.js',
5+
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
6+
coverageDirectory: '../../../coverage/libs/angular/di',
7+
transform: {
8+
'^.+\\.(ts|mjs|js|html)$': [
9+
'jest-preset-angular',
10+
{
11+
tsconfig: '<rootDir>/tsconfig.spec.json',
12+
stringifyContentPathRegex: '\\.(html|svg)$',
13+
},
14+
],
15+
},
16+
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
17+
snapshotSerializers: [
18+
'jest-preset-angular/build/serializers/no-ng-attributes',
19+
'jest-preset-angular/build/serializers/ng-snapshot',
20+
'jest-preset-angular/build/serializers/html-comment',
21+
],
22+
};

libs/angular/di/ng-package.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "../../../node_modules/ng-packagr/ng-package.schema.json",
3+
"dest": "../../../dist/libs/angular/di",
4+
"lib": {
5+
"entryFile": "src/index.ts"
6+
}
7+
}

libs/angular/di/package.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "angular/di",
3+
"version": "0.0.1",
4+
"peerDependencies": {
5+
"@angular/common": "^16.2.0",
6+
"@angular/core": "^16.2.0"
7+
},
8+
"dependencies": {
9+
"tslib": "^2.3.0"
10+
},
11+
"sideEffects": false
12+
}

libs/angular/di/project.json

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "angular/di",
3+
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "libs/angular/di/src",
5+
"prefix": "lib",
6+
"tags": [],
7+
"projectType": "library",
8+
"targets": {
9+
"build": {
10+
"executor": "@nx/angular:ng-packagr-lite",
11+
"outputs": ["{workspaceRoot}/dist/{projectRoot}"],
12+
"options": {
13+
"project": "libs/angular/di/ng-package.json"
14+
},
15+
"configurations": {
16+
"production": {
17+
"tsConfig": "libs/angular/di/tsconfig.lib.prod.json"
18+
},
19+
"development": {
20+
"tsConfig": "libs/angular/di/tsconfig.lib.json"
21+
}
22+
},
23+
"defaultConfiguration": "production"
24+
},
25+
"test": {
26+
"executor": "@nx/jest:jest",
27+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
28+
"options": {
29+
"jestConfig": "libs/angular/di/jest.config.ts",
30+
"passWithNoTests": true
31+
},
32+
"configurations": {
33+
"ci": {
34+
"ci": true,
35+
"codeCoverage": true
36+
}
37+
}
38+
},
39+
"lint": {
40+
"executor": "@nx/eslint:lint",
41+
"outputs": ["{options.outputFile}"],
42+
"options": {
43+
"lintFilePatterns": [
44+
"libs/angular/di/**/*.ts",
45+
"libs/angular/di/**/*.html",
46+
"libs/angular/di/package.json"
47+
]
48+
}
49+
}
50+
}
51+
}

libs/angular/di/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { TableComponent } from './lib/table.component';
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { NgFor, NgTemplateOutlet } from '@angular/common';
2+
import { Component, ContentChild, Input, TemplateRef } from '@angular/core';
3+
4+
@Component({
5+
selector: 'table',
6+
standalone: true,
7+
imports: [NgTemplateOutlet, NgFor],
8+
template: `
9+
<thead>
10+
<ng-container *ngTemplateOutlet="headerTemplate"></ng-container>
11+
</thead>
12+
<tbody *ngFor="let item of items">
13+
<ng-container
14+
*ngTemplateOutlet="
15+
bodyTemplate;
16+
context: { $implicit: item }
17+
"></ng-container>
18+
</tbody>
19+
`,
20+
})
21+
export class TableComponent<T> {
22+
@Input() items!: T[];
23+
24+
@ContentChild('header', { read: TemplateRef })
25+
headerTemplate!: TemplateRef<void>;
26+
27+
@ContentChild('body', { read: TemplateRef })
28+
bodyTemplate!: TemplateRef<{ $implicit: T }>;
29+
}

libs/angular/di/src/test-setup.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment
2+
globalThis.ngJest = {
3+
testEnvironmentOptions: {
4+
errorOnUnknownElements: true,
5+
errorOnUnknownProperties: true,
6+
},
7+
};
8+
import 'jest-preset-angular/setup-jest';

libs/angular/di/tsconfig.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2022",
4+
"useDefineForClassFields": false,
5+
"forceConsistentCasingInFileNames": true,
6+
"strict": true,
7+
"noImplicitOverride": true,
8+
"noPropertyAccessFromIndexSignature": true,
9+
"noImplicitReturns": true,
10+
"noFallthroughCasesInSwitch": true
11+
},
12+
"files": [],
13+
"include": [],
14+
"references": [
15+
{
16+
"path": "./tsconfig.lib.json"
17+
},
18+
{
19+
"path": "./tsconfig.spec.json"
20+
}
21+
],
22+
"extends": "../../../tsconfig.base.json",
23+
"angularCompilerOptions": {
24+
"enableI18nLegacyMessageIdFormat": false,
25+
"strictInjectionParameters": true,
26+
"strictInputAccessModifiers": true,
27+
"strictTemplates": true
28+
}
29+
}

libs/angular/di/tsconfig.lib.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../../dist/out-tsc",
5+
"declaration": true,
6+
"declarationMap": true,
7+
"inlineSources": true,
8+
"types": []
9+
},
10+
"exclude": [
11+
"src/**/*.spec.ts",
12+
"src/test-setup.ts",
13+
"jest.config.ts",
14+
"src/**/*.test.ts"
15+
],
16+
"include": ["src/**/*.ts"]
17+
}
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.lib.json",
3+
"compilerOptions": {
4+
"declarationMap": false
5+
},
6+
"angularCompilerOptions": {}
7+
}

libs/angular/di/tsconfig.spec.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../../dist/out-tsc",
5+
"module": "commonjs",
6+
"target": "es2016",
7+
"types": ["jest", "node"]
8+
},
9+
"files": ["src/test-setup.ts"],
10+
"include": [
11+
"jest.config.ts",
12+
"src/**/*.test.ts",
13+
"src/**/*.spec.ts",
14+
"src/**/*.d.ts"
15+
]
16+
}

0 commit comments

Comments
 (0)