xt-plugin-finance 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +16 -0
- package/.postcssrc.json +1 -0
- package/.rush/temp/chunked-rush-logs/xt-plugin-finance.build-deploy-latest.chunks.jsonl +79 -0
- package/.rush/temp/chunked-rush-logs/xt-plugin-finance.build-deploy-next.chunks.jsonl +29 -0
- package/.rush/temp/chunked-rush-logs/xt-plugin-finance.build.chunks.jsonl +24 -0
- package/.rush/temp/chunked-rush-logs/xt-plugin-finance.test.chunks.jsonl +36 -0
- package/.rush/temp/package-deps_test.json +55 -0
- package/.rush/temp/shrinkwrap-deps.json +1082 -0
- package/CHANGELOG.md +13 -0
- package/README.md +17 -0
- package/angular.json +164 -0
- package/package.json +62 -0
- package/projects/finance/README.md +17 -0
- package/projects/finance/ng-package.json +7 -0
- package/projects/finance/node_modules/.vite/results.json +1 -0
- package/projects/finance/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/projects/finance/package.json +22 -0
- package/projects/finance/src/lib/finance-amount/finance-amount.component.css +0 -0
- package/projects/finance/src/lib/finance-amount/finance-amount.component.html +18 -0
- package/projects/finance/src/lib/finance-amount/finance-amount.component.spec.ts +38 -0
- package/projects/finance/src/lib/finance-amount/finance-amount.component.ts +68 -0
- package/projects/finance/src/lib/money-handler/money-amount-handler.ts +21 -0
- package/projects/finance/src/lib/money-handler/money-amount.ts +15 -0
- package/projects/finance/src/lib/register.ts +54 -0
- package/projects/finance/src/public-api.ts +6 -0
- package/projects/finance/src/test-setup.ts +18 -0
- package/projects/finance/tsconfig.lib.json +15 -0
- package/projects/finance/tsconfig.lib.prod.json +11 -0
- package/projects/finance/tsconfig.spec.json +18 -0
- package/projects/finance/vitest.config.ts +19 -0
- package/projects/finance-plugin/federation.config.js +43 -0
- package/projects/finance-plugin/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/projects/finance-plugin/public/favicon.ico +0 -0
- package/projects/finance-plugin/public/pluginicon.png +0 -0
- package/projects/finance-plugin/src/app/app.component.css +0 -0
- package/projects/finance-plugin/src/app/app.component.html +3 -0
- package/projects/finance-plugin/src/app/app.component.spec.ts +42 -0
- package/projects/finance-plugin/src/app/app.component.ts +37 -0
- package/projects/finance-plugin/src/app/app.config.ts +21 -0
- package/projects/finance-plugin/src/app/app.routes.ts +6 -0
- package/projects/finance-plugin/src/app/dummy-currency/dummy-currency.component.css +0 -0
- package/projects/finance-plugin/src/app/dummy-currency/dummy-currency.component.html +7 -0
- package/projects/finance-plugin/src/app/dummy-currency/dummy-currency.component.ts +36 -0
- package/projects/finance-plugin/src/app/test-component/test.component.css +0 -0
- package/projects/finance-plugin/src/app/test-component/test.component.html +24 -0
- package/projects/finance-plugin/src/app/test-component/test.component.spec.ts +46 -0
- package/projects/finance-plugin/src/app/test-component/test.component.ts +35 -0
- package/projects/finance-plugin/src/bootstrap.ts +6 -0
- package/projects/finance-plugin/src/index.html +13 -0
- package/projects/finance-plugin/src/main.ts +6 -0
- package/projects/finance-plugin/src/styles.css +12 -0
- package/projects/finance-plugin/src/test-setup.ts +18 -0
- package/projects/finance-plugin/tsconfig.app.json +15 -0
- package/projects/finance-plugin/tsconfig.federation.json +13 -0
- package/projects/finance-plugin/tsconfig.spec.json +18 -0
- package/projects/finance-plugin/vitest.config.ts +19 -0
- package/rush-logs/xt-plugin-finance.build-deploy-latest.error.log +42 -0
- package/rush-logs/xt-plugin-finance.build-deploy-latest.log +79 -0
- package/rush-logs/xt-plugin-finance.build-deploy-next.error.log +10 -0
- package/rush-logs/xt-plugin-finance.build-deploy-next.log +29 -0
- package/rush-logs/xt-plugin-finance.build.error.log +9 -0
- package/rush-logs/xt-plugin-finance.build.log +24 -0
- package/rush-logs/xt-plugin-finance.test.log +36 -0
- package/tsconfig.json +36 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.6.0](https://github.com/dont-code/ng-xtend/compare/xt-plugin-finance-v0.5.5...xt-plugin-finance-v0.6.0) (2026-01-07)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* all plugins, libs to release please ([35ddd53](https://github.com/dont-code/ng-xtend/commit/35ddd5362c3350572f44ebe79824e297fd03c7eb))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* reworked publish & deploy scripts with release-please ([aed0d88](https://github.com/dont-code/ng-xtend/commit/aed0d884c0a8bfcc85645e87d19480939737bdf6))
|
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
# Plugin xt-default
|
|
4
|
+
|
|
5
|
+
This plugin is part of the [ng-xtend framework](https://github.com/dont-code/ng-xtend/blob/main/README.md)
|
|
6
|
+
|
|
7
|
+
It enable [xt-components](https://github.com/dont-code/ng-xtend/tree/main/libs/xt-components) to
|
|
8
|
+
|
|
9
|
+
- Display and edit any primitive value
|
|
10
|
+

|
|
11
|
+
- or complex object
|
|
12
|
+

|
|
13
|
+
- or list of objects
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
With it you are sure you can display / edit any type within any xt-components application like [xt-host](https://github.com/dont-code/ng-xtend/tree/main/libs/xt-host).
|
|
17
|
+
|
package/angular.json
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
|
3
|
+
"version": 1,
|
|
4
|
+
"cli": {
|
|
5
|
+
"packageManager": "pnpm",
|
|
6
|
+
"analytics": "8440f8d0-3f6c-4758-b71e-f9ee11217c7f",
|
|
7
|
+
"cache": {
|
|
8
|
+
"enabled": true
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"newProjectRoot": "projects",
|
|
12
|
+
"projects": {
|
|
13
|
+
"finance": {
|
|
14
|
+
"projectType": "library",
|
|
15
|
+
"root": "projects/finance",
|
|
16
|
+
"sourceRoot": "projects/finance/src",
|
|
17
|
+
"prefix": "lib",
|
|
18
|
+
"architect": {
|
|
19
|
+
"build": {
|
|
20
|
+
"builder": "@angular-devkit/build-angular:ng-packagr",
|
|
21
|
+
"options": {
|
|
22
|
+
"project": "projects/finance/ng-package.json"
|
|
23
|
+
},
|
|
24
|
+
"configurations": {
|
|
25
|
+
"production": {
|
|
26
|
+
"tsConfig": "projects/finance/tsconfig.lib.prod.json"
|
|
27
|
+
},
|
|
28
|
+
"development": {
|
|
29
|
+
"tsConfig": "projects/finance/tsconfig.lib.json"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"defaultConfiguration": "development"
|
|
33
|
+
},
|
|
34
|
+
"test": {
|
|
35
|
+
"builder": "@analogjs/vitest-angular:test",
|
|
36
|
+
"options": {
|
|
37
|
+
"tsConfig": "projects/finance/tsconfig.spec.json",
|
|
38
|
+
"polyfills": [
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"finance-plugin": {
|
|
45
|
+
"projectType": "application",
|
|
46
|
+
"schematics": {
|
|
47
|
+
"@schematics/angular:component": {
|
|
48
|
+
"style": "css"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"root": "projects/finance-plugin",
|
|
52
|
+
"sourceRoot": "projects/finance-plugin/src",
|
|
53
|
+
"prefix": "app",
|
|
54
|
+
"architect": {
|
|
55
|
+
"build": {
|
|
56
|
+
"builder": "@angular-architects/native-federation:build",
|
|
57
|
+
"options": {},
|
|
58
|
+
"configurations": {
|
|
59
|
+
"production": {
|
|
60
|
+
"target": "finance-plugin:esbuild:production"
|
|
61
|
+
},
|
|
62
|
+
"development": {
|
|
63
|
+
"target": "finance-plugin:esbuild:development",
|
|
64
|
+
"dev": true
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"defaultConfiguration": "production"
|
|
68
|
+
},
|
|
69
|
+
"serve": {
|
|
70
|
+
"builder": "@angular-architects/native-federation:build",
|
|
71
|
+
"options": {
|
|
72
|
+
"target": "finance-plugin:serve-original:development",
|
|
73
|
+
"rebuildDelay": 0,
|
|
74
|
+
"dev": true,
|
|
75
|
+
"port": 0
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"esbuild": {
|
|
79
|
+
"builder": "@angular-devkit/build-angular:application",
|
|
80
|
+
"options": {
|
|
81
|
+
"outputPath": "dist/xt-finance-plugin",
|
|
82
|
+
"index": "projects/finance-plugin/src/index.html",
|
|
83
|
+
"browser": "projects/finance-plugin/src/main.ts",
|
|
84
|
+
"preserveSymlinks": true,
|
|
85
|
+
"polyfills": [
|
|
86
|
+
"es-module-shims"
|
|
87
|
+
],
|
|
88
|
+
"tsConfig": "projects/finance-plugin/tsconfig.app.json",
|
|
89
|
+
"inlineStyleLanguage": "css",
|
|
90
|
+
"assets": [
|
|
91
|
+
{
|
|
92
|
+
"glob": "**/*",
|
|
93
|
+
"input": "projects/finance-plugin/public"
|
|
94
|
+
}
|
|
95
|
+
],
|
|
96
|
+
"styles": [
|
|
97
|
+
"projects/finance-plugin/src/styles.css"
|
|
98
|
+
],
|
|
99
|
+
"scripts": []
|
|
100
|
+
},
|
|
101
|
+
"configurations": {
|
|
102
|
+
"production": {
|
|
103
|
+
"budgets": [
|
|
104
|
+
{
|
|
105
|
+
"type": "initial",
|
|
106
|
+
"maximumWarning": "1MB",
|
|
107
|
+
"maximumError": "2MB"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"type": "anyComponentStyle",
|
|
111
|
+
"maximumWarning": "4kB",
|
|
112
|
+
"maximumError": "8kB"
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
"outputHashing": "all"
|
|
116
|
+
},
|
|
117
|
+
"development": {
|
|
118
|
+
"optimization": false,
|
|
119
|
+
"extractLicenses": false,
|
|
120
|
+
"sourceMap": true
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"defaultConfiguration": "development"
|
|
124
|
+
},
|
|
125
|
+
"serve-original": {
|
|
126
|
+
"builder": "@angular-devkit/build-angular:dev-server",
|
|
127
|
+
"configurations": {
|
|
128
|
+
"production": {
|
|
129
|
+
"buildTarget": "finance-plugin:esbuild:production"
|
|
130
|
+
},
|
|
131
|
+
"development": {
|
|
132
|
+
"buildTarget": "finance-plugin:esbuild:development"
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
"defaultConfiguration": "development",
|
|
136
|
+
"options": {
|
|
137
|
+
"port": 4204
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"extract-i18n": {
|
|
141
|
+
"builder": "@angular-devkit/build-angular:extract-i18n"
|
|
142
|
+
},
|
|
143
|
+
"test": {
|
|
144
|
+
"builder": "@analogjs/vitest-angular:test",
|
|
145
|
+
"options": {
|
|
146
|
+
"polyfills": [],
|
|
147
|
+
"tsConfig": "projects/finance-plugin/tsconfig.spec.json",
|
|
148
|
+
"inlineStyleLanguage": "css",
|
|
149
|
+
"assets": [
|
|
150
|
+
{
|
|
151
|
+
"glob": "**/*",
|
|
152
|
+
"input": "projects/finance-plugin/public"
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
"styles": [
|
|
156
|
+
"projects/finance-plugin/src/styles.css"
|
|
157
|
+
],
|
|
158
|
+
"scripts": []
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "xt-plugin-finance",
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"ng": "ng",
|
|
6
|
+
"start": "ng serve",
|
|
7
|
+
"build": "ng build finance",
|
|
8
|
+
"build-deploy": "APP=finance-plugin && MAIN_LIB=finance && ng build $MAIN_LIB --configuration=$BUILD && ng build $APP --configuration=$BUILD --output-path=\"../../dist/$STAGE/$APP\" --base-href=\"https://test.dont-code.net/apps/$STAGE/$APP/\"",
|
|
9
|
+
"watch": "ng build --watch --configuration development",
|
|
10
|
+
"test": "cd projects/finance && ../../node_modules/.bin/vitest && cd ../finance-plugin && ../../node_modules/.bin/vitest"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"directory": "dist/xt-plugin-finance",
|
|
14
|
+
"linkDirectory": true
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"url": "https://github.com/dont-code/ng-xtend.git"
|
|
18
|
+
},
|
|
19
|
+
"private": false,
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@angular/animations": "^20.3.9",
|
|
22
|
+
"@angular/common": "^20.3.9",
|
|
23
|
+
"@angular/compiler": "^20.3.9",
|
|
24
|
+
"@angular/core": "^20.3.9",
|
|
25
|
+
"@angular/forms": "^20.3.9",
|
|
26
|
+
"@angular/platform-browser": "^20.3.9",
|
|
27
|
+
"@angular/platform-browser-dynamic": "^20.3.9",
|
|
28
|
+
"@angular/router": "^20.3.9",
|
|
29
|
+
"@angular/cdk": "^20.2.4",
|
|
30
|
+
"xt-components": "workspace:^",
|
|
31
|
+
"xt-type": "workspace:^",
|
|
32
|
+
"rxjs": "^7.8.2",
|
|
33
|
+
"primeng": "^20.3.0",
|
|
34
|
+
"primeicons": "^7.0.0",
|
|
35
|
+
"@primeuix/themes": "^1.2.5",
|
|
36
|
+
"tslib": "^2.8.1",
|
|
37
|
+
"tailwindcss": "~4.1.16",
|
|
38
|
+
"es-module-shims": "^2.6.2",
|
|
39
|
+
"@angular-architects/native-federation": "^20.1.7",
|
|
40
|
+
"@softarc/native-federation-runtime": "^3.3.6"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@primeuix/utils": "^0.6.1",
|
|
44
|
+
"@primeuix/styled": "^0.7.2",
|
|
45
|
+
"@angular-devkit/build-angular": "^20.3.8",
|
|
46
|
+
"@angular/cli": "^20.3.8",
|
|
47
|
+
"@angular/compiler-cli": "^20.3.9",
|
|
48
|
+
"@angular/build": "^20.3.8",
|
|
49
|
+
"ng-packagr": "^20.3.0",
|
|
50
|
+
"typescript": "^5.9.3",
|
|
51
|
+
"@analogjs/vite-plugin-angular": "^1.22.4",
|
|
52
|
+
"@analogjs/vitest-angular": "^1.22.4",
|
|
53
|
+
"jsdom": "^26.1.0",
|
|
54
|
+
"vite": "^7.1.12",
|
|
55
|
+
"vitest": "^3.2.4",
|
|
56
|
+
"vite-tsconfig-paths": "~5.1.4",
|
|
57
|
+
"happy-dom": "^18.0.1",
|
|
58
|
+
"@tailwindcss/postcss": "~4.1.16",
|
|
59
|
+
"postcss": "~8.5.6"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
# Plugin xt-default
|
|
4
|
+
|
|
5
|
+
This plugin is part of the [ng-xtend framework](https://github.com/dont-code/ng-xtend/blob/main/README.md)
|
|
6
|
+
|
|
7
|
+
It enable [xt-components](https://github.com/dont-code/ng-xtend/tree/main/libs/xt-components) to
|
|
8
|
+
|
|
9
|
+
- Display and edit any primitive value
|
|
10
|
+

|
|
11
|
+
- or complex object
|
|
12
|
+

|
|
13
|
+
- or list of objects
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
With it you are sure you can display / edit any type within any xt-components application like [xt-host](https://github.com/dont-code/ng-xtend/tree/main/libs/xt-host).
|
|
17
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"3.1.4","results":[[":src/lib/finance-amount/finance-amount.component.spec.ts",{"duration":585.6307770000021,"failed":false}]]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"3.2.4","results":[[":src/lib/finance-amount/finance-amount.component.spec.ts",{"duration":458.79492799999935,"failed":false}]]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "xt-plugin-finance",
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"@angular/animations": "^19.0.5",
|
|
6
|
+
"@angular/common": "^19.0.5",
|
|
7
|
+
"@angular/compiler": "^19.0.5",
|
|
8
|
+
"@angular/core": "^19.0.5",
|
|
9
|
+
"@angular/forms": "^19.0.5",
|
|
10
|
+
"@angular/platform-browser": "^19.0.5",
|
|
11
|
+
"@angular/platform-browser-dynamic": "^19.0.5",
|
|
12
|
+
"@angular/router": "^19.0.5",
|
|
13
|
+
"xt-components": "workspace:^",
|
|
14
|
+
"rxjs": "^7.8.0",
|
|
15
|
+
"primeng": "^19.0.2",
|
|
16
|
+
"primeicons": "^7.0.0"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"tslib": "^2.3.0"
|
|
20
|
+
},
|
|
21
|
+
"sideEffects": false
|
|
22
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
@if (isInForm() ) {
|
|
2
|
+
@let cur = currency();
|
|
3
|
+
<ng-container [formGroup]="formGroup()">
|
|
4
|
+
@if (!isFixedCurrency) {
|
|
5
|
+
<xt-render-sub [context]="subContext('currency', 'currency')" (outputs)="outputChanged($event)" />
|
|
6
|
+
}
|
|
7
|
+
@if (cur != null) {
|
|
8
|
+
<p-inputNumber mode="currency" [currency]="cur" formControlName="amount" />
|
|
9
|
+
} @else {
|
|
10
|
+
<p-inputNumber mode="decimal" formControlName="amount" />
|
|
11
|
+
}
|
|
12
|
+
</ng-container>
|
|
13
|
+
} @else {
|
|
14
|
+
@let displayAmount = displayValue();
|
|
15
|
+
@if ((displayAmount) && (displayAmount.amount!=null)) {
|
|
16
|
+
<span>{{ displayAmount.amount | currency : displayAmount.currency }}</span>
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { FinanceAmountComponent } from './finance-amount.component';
|
|
4
|
+
import { beforeEach, describe, expect, it } from 'vitest';
|
|
5
|
+
import { XtBaseContext } from 'xt-components';
|
|
6
|
+
import { MoneyAmount } from '../money-handler/money-amount';
|
|
7
|
+
import { By } from '@angular/platform-browser';
|
|
8
|
+
|
|
9
|
+
describe('FinanceAmountComponent', () => {
|
|
10
|
+
let component: FinanceAmountComponent;
|
|
11
|
+
let fixture: ComponentFixture<FinanceAmountComponent>;
|
|
12
|
+
|
|
13
|
+
beforeEach(async () => {
|
|
14
|
+
await TestBed.configureTestingModule({
|
|
15
|
+
imports: [FinanceAmountComponent]
|
|
16
|
+
})
|
|
17
|
+
.compileComponents();
|
|
18
|
+
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should display amount', () => {
|
|
22
|
+
fixture = TestBed.createComponent(FinanceAmountComponent);
|
|
23
|
+
const context=new XtBaseContext<MoneyAmount>('FULL_VIEW');
|
|
24
|
+
context.setDisplayValue({
|
|
25
|
+
currency:'EUR',
|
|
26
|
+
amount:12.4
|
|
27
|
+
});
|
|
28
|
+
fixture.componentRef.setInput("context", context);
|
|
29
|
+
component = fixture.componentInstance;
|
|
30
|
+
fixture.detectChanges();
|
|
31
|
+
expect(component).toBeTruthy();
|
|
32
|
+
const textContent=fixture.debugElement.query(By.css('span') ).nativeElement.textContent;
|
|
33
|
+
expect(textContent).contains('12');
|
|
34
|
+
expect(textContent).contains('40');
|
|
35
|
+
expect(textContent).contains('€');
|
|
36
|
+
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
computed,
|
|
5
|
+
inject,
|
|
6
|
+
Injector,
|
|
7
|
+
OnInit,
|
|
8
|
+
runInInjectionContext,
|
|
9
|
+
signal
|
|
10
|
+
} from '@angular/core';
|
|
11
|
+
import { XtComponentOutput, XtCompositeComponent, XtRenderSubComponent, XtResolverService } from 'xt-components';
|
|
12
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
13
|
+
import { InputNumber } from 'primeng/inputnumber';
|
|
14
|
+
import { CurrencyPipe } from '@angular/common';
|
|
15
|
+
import { ReactiveFormsModule } from '@angular/forms';
|
|
16
|
+
import { MoneyAmount } from '../money-handler/money-amount';
|
|
17
|
+
|
|
18
|
+
@Component({
|
|
19
|
+
selector: 'xt-finance-amount',
|
|
20
|
+
imports: [
|
|
21
|
+
InputNumber,
|
|
22
|
+
CurrencyPipe,
|
|
23
|
+
XtRenderSubComponent,
|
|
24
|
+
ReactiveFormsModule
|
|
25
|
+
],
|
|
26
|
+
templateUrl: './finance-amount.component.html',
|
|
27
|
+
styleUrl: './finance-amount.component.css',
|
|
28
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
29
|
+
})
|
|
30
|
+
export class FinanceAmountComponent extends XtCompositeComponent<MoneyAmount> implements OnInit {
|
|
31
|
+
isFixedCurrency=true;
|
|
32
|
+
currency= signal<string|undefined>( undefined );
|
|
33
|
+
|
|
34
|
+
override ngOnInit(): void {
|
|
35
|
+
super.ngOnInit();
|
|
36
|
+
|
|
37
|
+
// The same components support multiple types: money-amount (with currency selection), eur-amount or usd-amount
|
|
38
|
+
let value=this.context().value();
|
|
39
|
+
if ((this.context().valueType=='money-amount') || (this.context().valueType==null)) {
|
|
40
|
+
this.isFixedCurrency=false;
|
|
41
|
+
this.currency.set(value?.currency);
|
|
42
|
+
}else if (this.context().valueType?.endsWith('-amount')) {
|
|
43
|
+
this.isFixedCurrency=true;
|
|
44
|
+
const currency=this.context().valueType?.substring(0,3).toUpperCase();
|
|
45
|
+
// Enforce the currency if needed
|
|
46
|
+
if (this.isInForm()) {
|
|
47
|
+
if (value==null) {
|
|
48
|
+
value=this.resolverService.findTypeHandlerOf(this.context()).handler?.createNew()??{};
|
|
49
|
+
this.context().setFormValue(value, true);
|
|
50
|
+
}else if (value.currency==null) {
|
|
51
|
+
value.currency=currency;
|
|
52
|
+
this.context().setFormValue(value, true);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
this.currency.set(currency);
|
|
56
|
+
}
|
|
57
|
+
this.manageFormControl('amount');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
outputChanged($output:XtComponentOutput | null) {
|
|
61
|
+
if ($output?.valueSelected!=null) {
|
|
62
|
+
$output?.valueSelected.subscribe (selected => {
|
|
63
|
+
this.currency.set(selected);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AbstractTypeHandler, XtTypeHierarchy } from 'xt-type';
|
|
2
|
+
import { MoneyAmount } from './money-amount';
|
|
3
|
+
|
|
4
|
+
export class MoneyAmountHandler extends AbstractTypeHandler<MoneyAmount> {
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
this.fields.addOldField('currencyCode','currency');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
override createNew(): MoneyAmount {
|
|
12
|
+
const ret:MoneyAmount = {} as unknown as MoneyAmount;
|
|
13
|
+
if (this.type?.type?.endsWith('-amount')) {
|
|
14
|
+
if (this.type.type!='money-amount') {
|
|
15
|
+
ret.currency=this.type.type.substring(0,3).toUpperCase();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return ret;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { XtResolverService } from 'xt-components';
|
|
2
|
+
import { MoneyAmountHandler } from './money-handler/money-amount-handler';
|
|
3
|
+
import { FinanceAmountComponent } from './finance-amount/finance-amount.component';
|
|
4
|
+
|
|
5
|
+
export function registerFinancePlugin (resolverService:XtResolverService):string {
|
|
6
|
+
const pluginName = "Plugin Finance";
|
|
7
|
+
console.info ('Registering '+pluginName);
|
|
8
|
+
resolverService.registerPlugin ({
|
|
9
|
+
name:pluginName,
|
|
10
|
+
uriLogo:'pluginicon.png',
|
|
11
|
+
components: [
|
|
12
|
+
{
|
|
13
|
+
componentName:'FinanceAmount',
|
|
14
|
+
componentClass:FinanceAmountComponent,
|
|
15
|
+
typesHandled: ['money-amount','eur-amount','usd-amount'],
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
types: {
|
|
19
|
+
"money-amount":{
|
|
20
|
+
numericField: 'amount',
|
|
21
|
+
children:{
|
|
22
|
+
currency:'currency',
|
|
23
|
+
amount:'number'
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"eur-amount":{
|
|
27
|
+
numericField: 'amount',
|
|
28
|
+
children: {
|
|
29
|
+
currency: 'currency',
|
|
30
|
+
amount: 'number'
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"usd-amount":{
|
|
34
|
+
numericField: 'amount',
|
|
35
|
+
children: {
|
|
36
|
+
currency: 'currency',
|
|
37
|
+
amount: 'number'
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
,typeHandlers:[
|
|
42
|
+
{
|
|
43
|
+
typesHandled: ['money-amount', 'eur-amount', 'usd-amount'],
|
|
44
|
+
handlerClass: MoneyAmountHandler
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
});
|
|
49
|
+
return pluginName;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function registerPlugin (resolverService:XtResolverService):string {
|
|
53
|
+
return registerFinancePlugin(resolverService);
|
|
54
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import "@angular/compiler";
|
|
2
|
+
|
|
3
|
+
import { BrowserTestingModule, platformBrowserTesting } from '@angular/platform-browser/testing';
|
|
4
|
+
|
|
5
|
+
import { getTestBed } from '@angular/core/testing';
|
|
6
|
+
import { NgModule, provideZonelessChangeDetection } from '@angular/core';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@NgModule({
|
|
10
|
+
imports: [BrowserTestingModule],
|
|
11
|
+
providers: [provideZonelessChangeDetection()],
|
|
12
|
+
})
|
|
13
|
+
export class TestingModule {}
|
|
14
|
+
|
|
15
|
+
getTestBed().initTestEnvironment(
|
|
16
|
+
[TestingModule],
|
|
17
|
+
platformBrowserTesting()
|
|
18
|
+
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"extends": "../../tsconfig.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"outDir": "../../out-tsc/lib",
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"declarationMap": true,
|
|
9
|
+
"inlineSources": true,
|
|
10
|
+
"types": []
|
|
11
|
+
},
|
|
12
|
+
"exclude": [
|
|
13
|
+
"**/*.spec.ts"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"extends": "./tsconfig.lib.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"declarationMap": false
|
|
7
|
+
},
|
|
8
|
+
"angularCompilerOptions": {
|
|
9
|
+
"compilationMode": "partial"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"extends": "../../tsconfig.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"outDir": "../../out-tsc/spec",
|
|
7
|
+
"target": "es2016",
|
|
8
|
+
"types": [
|
|
9
|
+
"vitest/globals","node"
|
|
10
|
+
],
|
|
11
|
+
"emitDecoratorMetadata": true
|
|
12
|
+
},
|
|
13
|
+
"files": ["src/test-setup.ts"],
|
|
14
|
+
"include": [
|
|
15
|
+
"src/**/*.spec.ts",
|
|
16
|
+
"src/**/*.d.ts"
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="vitest" />
|
|
2
|
+
import { defineConfig } from 'vite';
|
|
3
|
+
|
|
4
|
+
import angular from '@analogjs/vite-plugin-angular';
|
|
5
|
+
import tsconfigPaths from 'vite-tsconfig-paths';
|
|
6
|
+
|
|
7
|
+
export default defineConfig(({ mode }) => ({
|
|
8
|
+
plugins: [angular(), tsconfigPaths()],
|
|
9
|
+
test: {
|
|
10
|
+
globals: true,
|
|
11
|
+
setupFiles: ['src/test-setup.ts'],
|
|
12
|
+
environment: 'jsdom',
|
|
13
|
+
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
14
|
+
reporters: ['default']
|
|
15
|
+
},
|
|
16
|
+
define: {
|
|
17
|
+
'import.meta.vitest': mode !== 'production',
|
|
18
|
+
},
|
|
19
|
+
}));
|