ngx-iso-form 3.1.0 → 3.2.1

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/README.md CHANGED
@@ -1,11 +1,9 @@
1
1
  <div align="center">
2
- <a href="https://https://github.com/pixelbyaj/ngx-iso-form">
3
- <img src="https://raw.githubusercontent.com/pixelbyaj/ngx-form/main/anguar_logo.svg?sanitize=true" />
2
+ <a href="https://github.com/pixelbyaj/ngx-iso-form">
3
+ <img src="https://raw.githubusercontent.com/pixelbyaj/ngx-form/main/anguar_logo.svg?sanitize=true" alt="Angular Logo" />
4
4
  </a>
5
5
  <br />
6
- <h1>
7
- XSD - JSON powered / Dynamic ISO 20022 forms in Angular v19
8
- </h1>
6
+ <h1>XSD - JSON Powered / Dynamic ISO 20022 Forms in Angular v19</h1>
9
7
 
10
8
  ![npm](https://img.shields.io/npm/v/ngx-iso-form)
11
9
  ![NPM](https://img.shields.io/npm/l/ngx-iso-form)
@@ -16,17 +14,17 @@
16
14
 
17
15
  # NgxIsoForm
18
16
 
19
- This form is used to design Angular Reactive Form using any given JSON - XSD. The primary use of this UI library is to design ISO 20022 forms dynamically.
17
+ NgxIsoForm is a library for dynamically generating Angular Reactive Forms using JSON derived from XSD. It is primarily designed for ISO 20022 forms.
20
18
 
21
19
  ## Features
22
20
 
23
- - 🔥 Automatic forms generation
24
- - 📝 Easy to extend with custom field types
21
+ - 🔥 Automatic form generation
22
+ - 📝 Extendable with custom field types
25
23
  - ⚡️ Supports ISO 20022 schemas:
26
- - XSD - JSON Schema using XSDService nuget
27
- - Support all validation like required, pattern, minlength, maxlength
28
- - Support translation labels, errors and date formats.
29
- - 💪 Built on top of [Angular Reactive Forms](https://angular.dev/guide/forms/reactive-forms)
24
+ - XSD to JSON Schema conversion using XSDService NuGet
25
+ - Validation support: required, pattern, minlength, maxlength
26
+ - Translation support for labels, errors, and date formats
27
+ - 💪 Built on [Angular Reactive Forms](https://angular.dev/guide/forms/reactive-forms)
30
28
 
31
29
  ## [Live Demo](https://iso20022.in/#/ngx-iso-form-demo?json=pacs.009.001.10)
32
30
 
@@ -34,36 +32,36 @@ This form is used to design Angular Reactive Form using any given JSON - XSD. Th
34
32
 
35
33
  ## **NOTE**
36
34
 
37
- **The library don't support direct execution of XSD and user need to convert XSD to JSON using [xsd-json-converter](https://www.npmjs.com/package/xsd-json-converter) npm package**
35
+ The library does not directly execute XSD. Users must convert XSD to JSON using the [xsd-json-converter](https://www.npmjs.com/package/xsd-json-converter) npm package or the [.NET ISO20022.XSD](https://www.nuget.org/packages/iSO20022.XSD) NuGet package.
38
36
 
39
- ## How to consume
37
+ ## New Version
40
38
 
41
- ### Add angular material v19
39
+ **Version 3.2.0** introduces support for using ISO 20022 XML messages as a model.
42
40
 
43
- ```console
41
+ ## How to Use
42
+
43
+ ### Add Angular Material v19
44
+
45
+ ```bash
44
46
  ng add @angular/material
45
47
  ```
46
48
 
47
- ### Install npm package ngx-iso-form.
49
+ ### Install the Library
48
50
 
49
- ```console
50
- npm i ngx-iso-form
51
+ ```bash
52
+ npm install ngx-iso-form
51
53
  ```
52
54
 
53
- ### Import Module & SCSS
55
+ ### Import Module and SCSS
54
56
 
55
57
  ```typescript
56
58
  import { NgxIsoFormModule } from 'ngx-iso-form';
57
59
  import { HttpClient, provideHttpClient } from '@angular/common/http';
58
60
 
59
61
  @NgModule({
60
- ...
61
62
  imports: [
62
- ...
63
- NgxIsoFormModule
64
- ],
65
- provider:[provideHttpClient()]
66
- TranslateModule.forRoot({
63
+ NgxIsoFormModule,
64
+ TranslateModule.forRoot({
67
65
  defaultLanguage: 'en',
68
66
  loader: {
69
67
  provide: TranslateLoader,
@@ -71,80 +69,87 @@ import { HttpClient, provideHttpClient } from '@angular/common/http';
71
69
  deps: [HttpClient]
72
70
  }
73
71
  })
74
- ...
72
+ ],
73
+ providers: [provideHttpClient()]
75
74
  })
76
-
77
75
  export function HttpLoaderFactory(http: HttpClient) {
78
76
  return new TranslateHttpLoader(http, '/i18n/', '.json');
79
77
  }
80
-
81
78
  ```
82
79
 
83
- Add style file to angular.json file
80
+ Add the style file to `angular.json`:
84
81
 
85
82
  ```json
86
- styles:[
87
- "node_modules/ngx-iso-form/lib/styles/index.scss"
83
+ "styles": [
84
+ "node_modules/ngx-iso-form/lib/styles/index.scss"
88
85
  ]
89
86
  ```
90
87
 
91
- ### View
88
+ ### Usage
92
89
 
93
- **New Option `excludes`**
90
+ #### New Option: `excludes`
94
91
 
95
92
  ```html
96
93
  <ngx-iso-form #isoForm [schema]="schema" [form]="form" [excludes]="excludes"></ngx-iso-form>
97
94
  ```
98
95
 
99
- **NOTE: `excludes` (optional) takes string[] and excludes all the mentioned Ids from the form. It will help you to minimize the form and include only the required fields for your business requirements.
96
+ **Note:** `excludes` (optional) accepts a `string[]` to exclude specific IDs from the form, allowing customization for business requirements.
100
97
 
101
98
  ### Public APIs
102
99
 
103
- - model: Get the form data in the json format
104
- - invalid: Get the validation status of the form. true | false
100
+ - `model`: Retrieves form data in JSON format.
101
+ - `invalid`: Returns the form's validation status (`true` or `false`).
105
102
 
106
- ```ts
103
+ ```typescript
107
104
  @ViewChild('isoForm') isoForm: NgxIsoFormComponent;
108
105
 
109
- get model():string {
110
- const data = this.isoForm.model;
111
- this.formData = JSON.stringify(data)
112
- }
113
- get invalid():boolean {
106
+ get model(): string {
107
+ return JSON.stringify(this.isoForm.model);
108
+ }
109
+
110
+ get invalid(): boolean {
114
111
  return this.isoForm.invalid;
115
112
  }
116
113
  ```
117
114
 
118
- ### Component
115
+ ### Component Example
119
116
 
120
117
  ```typescript
121
118
  export class AppComponent implements OnInit {
122
- @ViewChild('isoForm') isoForm: NgxIsoFormComponent;
123
-
124
- form: IsoForm;
125
- schema: SchemaElement;
126
- // exclude the MsgId field from loading
127
- excludes:['Document_BkToCstmrStmt_GrpHdr_MsgId']
128
-
129
- this.httpClient.get(sample).subscribe((data) => {
130
- this.schema = data as SchemaElement
119
+ @ViewChild('isoForm') isoForm: NgxIsoFormComponent;
120
+
121
+ form: IsoForm;
122
+ schema: SchemaElement;
123
+ excludes: string[] = [];
124
+
125
+ constructor(private httpClient: HttpClient) {}
126
+
127
+ ngOnInit() {
128
+ this.httpClient.get('path/to/schema.json').subscribe((data) => {
129
+ this.schema = data as SchemaElement;
131
130
  });
131
+ }
132
132
 
133
- this.httpClient.get(sampleLoad).subscribe((model) => {
134
- this.form = new IsoForm(model)
133
+ setWithJsonModel() {
134
+ this.httpClient.get('path/to/model.json').subscribe((model) => {
135
+ this.form = new IsoForm(model);
135
136
  });
137
+ }
136
138
 
137
- //To get the form object
138
- get model():string {
139
- const data = this.isoForm.model;
140
- this.formData = JSON.stringify(data)
141
- }
139
+ // New Support of XML Message as a model
140
+ setWithXmlMessage() {
141
+ this.httpClient.get('path/to/message.xml').subscribe((xmlMessage) => {
142
+ this.form = new IsoForm(null, xmlMessage);
143
+ });
144
+ }
142
145
 
143
- //To get the form validation status
144
- get invalid():boolean {
145
- return this.isoForm.invalid;
146
- }
146
+ get model(): string {
147
+ return JSON.stringify(this.isoForm.model);
148
+ }
147
149
 
150
+ get invalid(): boolean {
151
+ return this.isoForm.invalid;
152
+ }
148
153
  }
149
154
  ```
150
155
 
@@ -174,8 +179,7 @@ export interface SchemaElement {
174
179
 
175
180
  ### Translation Support
176
181
 
177
- It support name and id properties of the SchemaElement
178
- Please declare all your translation rules under 'iso' object.
182
+ Translation is supported for the `name` and `id` properties of `SchemaElement`. Declare translation rules under the `iso` object.
179
183
 
180
184
  ```json
181
185
  {
@@ -198,8 +202,67 @@ Please declare all your translation rules under 'iso' object.
198
202
  }
199
203
  }
200
204
  ```
201
- # Output JSON
202
- Example pain.001.001.12
205
+
206
+ ### Sample XML Model
207
+
208
+ ```xml
209
+ <?xml version="1.0" encoding="UTF-8"?>
210
+ <Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.09">
211
+ <CstmrCdtTrfInitn>
212
+ <GrpHdr>
213
+ <MsgId>123456</MsgId>
214
+ <CreDtTm>2025-03-27T10:00:00</CreDtTm>
215
+ <NbOfTxs>1</NbOfTxs>
216
+ <CtrlSum>1000.00</CtrlSum>
217
+ <InitgPty>
218
+ <Nm>Sender Company</Nm>
219
+ </InitgPty>
220
+ </GrpHdr>
221
+ <PmtInf>
222
+ <PmtInfId>PAY001</PmtInfId>
223
+ <PmtMtd>TRF</PmtMtd>
224
+ <BtchBookg>false</BtchBookg>
225
+ <Dbtr>
226
+ <Nm>John Doe</Nm>
227
+ </Dbtr>
228
+ <DbtrAcct>
229
+ <Id>
230
+ <IBAN>DE89370400440532013000</IBAN>
231
+ </Id>
232
+ </DbtrAcct>
233
+ <DbtrAgt>
234
+ <FinInstnId>
235
+ <BICFI>DEUTDEFFXXX</BICFI>
236
+ </FinInstnId>
237
+ </DbtrAgt>
238
+ <CdtTrfTxInf>
239
+ <PmtId>
240
+ <EndToEndId>TX123</EndToEndId>
241
+ </PmtId>
242
+ <Amt>
243
+ <InstdAmt Ccy="EUR">1000.00</InstdAmt>
244
+ </Amt>
245
+ <Cdtr>
246
+ <Nm>Jane Smith</Nm>
247
+ </Cdtr>
248
+ <CdtrAcct>
249
+ <Id>
250
+ <IBAN>FR7630006000011234567890189</IBAN>
251
+ </Id>
252
+ </CdtrAcct>
253
+ <CdtrAgt>
254
+ <FinInstnId>
255
+ <BICFI>BNPAFRPPXXX</BICFI>
256
+ </FinInstnId>
257
+ </CdtrAgt>
258
+ </CdtTrfTxInf>
259
+ </PmtInf>
260
+ </CstmrCdtTrfInitn>
261
+ </Document>
262
+ ```
263
+
264
+ ### Output JSON Example (pain.001.001.12)
265
+
203
266
  ```json
204
267
  {
205
268
  "Document": {
@@ -262,23 +325,24 @@ Example pain.001.001.12
262
325
  }
263
326
  }
264
327
  ```
265
- # Convert XSD to JSON
266
328
 
267
- Global (For CLI)
329
+ ## Convert XSD to JSON
330
+
331
+ ### Global Installation (CLI)
268
332
 
269
- ```console
270
- npm install -g xsd-json-converter
333
+ ```bash
334
+ npm install -g xsd-json-converter
271
335
  ```
272
336
 
273
- Local (For SCRIPT)
337
+ ### Local Installation (Script)
274
338
 
275
- ```console
276
- npm install xsd-json-converter
339
+ ```bash
340
+ npm install xsd-json-converter
277
341
  ```
278
342
 
279
- ### CLI
343
+ ### CLI Usage
280
344
 
281
- ```console
345
+ ```bash
282
346
  xjc <source-path> <output-path>
283
347
  ```
284
348
 
@@ -286,21 +350,21 @@ xjc <source-path> <output-path>
286
350
 
287
351
  ##### Linux
288
352
 
289
- ```console
353
+ ```bash
290
354
  xjc /mnt/c/source/xsd/camt.053.001.10.xsd /mnt/c/source/xsd/camt.053.json
291
355
  ```
292
356
 
293
357
  ##### Windows
294
358
 
295
- ```console
359
+ ```bash
296
360
  xjc C:/source/xsd/camt.053.001.10.xsd C:/source/xsd/camt.053.json
297
361
  ```
298
362
 
299
- ### Script
363
+ ### Script Usage
300
364
 
301
- JavaScript
365
+ #### JavaScript
302
366
 
303
- ```js
367
+ ```javascript
304
368
  const xsd = require("xsd-json-converter").default;
305
369
 
306
370
  xsd
@@ -309,9 +373,9 @@ xsd
309
373
  .catch((error) => console.error(error));
310
374
  ```
311
375
 
312
- TypeScript
376
+ #### TypeScript
313
377
 
314
- ```ts
378
+ ```typescript
315
379
  import xsd from "xsd-json-converter";
316
380
 
317
381
  xsd
@@ -320,6 +384,4 @@ xsd
320
384
  .catch((error) => console.error(error));
321
385
  ```
322
386
 
323
- **NOTE**: For script please install the package locally
324
-
325
-
387
+ **Note:** For scripts, install the package locally.