ngx-wapp-components 3.4.1 → 3.4.3-alpha.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngx-wapp-components",
3
- "version": "3.4.1",
3
+ "version": "3.4.3-alpha.1",
4
4
  "description": "This is a Wapping reusable component library published by Wapping.",
5
5
  "keywords": [
6
6
  "code",
@@ -27,6 +27,9 @@
27
27
  "@angular/platform-browser": "^21.1.1",
28
28
  "@angular/platform-browser-dynamic": "^21.1.1",
29
29
  "@angular/router": "^21.1.1",
30
+ "@ngx-formly/core": "~10.0.1",
31
+ "@ngx-formly/primeng": "~10.0.1",
32
+ "ajv": "^8.18.0",
30
33
  "chart.js": "^4.4.3",
31
34
  "chartjs-plugin-datalabels": "^2.2.0",
32
35
  "cron-parser": "^5.0.4",
@@ -44,6 +47,17 @@
44
47
  "primeng": "^21.0.4",
45
48
  "xlsx": "^0.18.5"
46
49
  },
50
+ "peerDependenciesMeta": {
51
+ "@ngx-formly/core": {
52
+ "optional": true
53
+ },
54
+ "@ngx-formly/primeng": {
55
+ "optional": true
56
+ },
57
+ "ajv": {
58
+ "optional": true
59
+ }
60
+ },
47
61
  "dependencies": {
48
62
  "tslib": "^2.3.0"
49
63
  },
@@ -57,7 +71,11 @@
57
71
  ".": {
58
72
  "types": "./types/ngx-wapp-components.d.ts",
59
73
  "default": "./fesm2022/ngx-wapp-components.mjs"
74
+ },
75
+ "./schema-form": {
76
+ "types": "./types/ngx-wapp-components-schema-form.d.ts",
77
+ "default": "./fesm2022/ngx-wapp-components-schema-form.mjs"
60
78
  }
61
79
  },
62
80
  "type": "module"
63
- }
81
+ }
@@ -0,0 +1,50 @@
1
+ # ngx-wapp-components/schema-form
2
+
3
+ `w-schema-form` renders a closed subset of JSON Schema (draft-07 by default, or 2020-12) with Formly and
4
+ PrimeNG. It emits `{ configuration, secrets }` and never preloads, stores or reports secret values
5
+ (change `schema-form-component`, SF-001..SF-009).
6
+
7
+ ```ts
8
+ import { WSchemaFormComponent, WSchemaFormSubmit } from 'ngx-wapp-components/schema-form';
9
+ ```
10
+
11
+ ```html
12
+ <w-schema-form
13
+ [schema]="schema"
14
+ [values]="values"
15
+ [secretStates]="secretStates"
16
+ [translations]="translations"
17
+ (stateChange)="onState($event)"
18
+ (validSubmit)="onSubmit($event)">
19
+ </w-schema-form>
20
+ ```
21
+
22
+ The public API is the inputs, the outputs and `submit()`. The Formly form, fields and model are internal.
23
+
24
+ ## Optional peer dependencies
25
+
26
+ Install them only if you use this entry point: `@ngx-formly/core ~10.0.1`, `@ngx-formly/primeng ~10.0.1`
27
+ and `ajv ^8.18.0`. The primary entry point `ngx-wapp-components` does not import them.
28
+
29
+ ## Formly types registered in your application
30
+
31
+ The component imports `FormlyPrimeNGModule` and an internal `FormlyModule.forChild(...)` module. Formly keeps
32
+ one `FormlyConfig` per application (provided in `root`), so the first time `w-schema-form` is created these
33
+ registrations are added to the root Formly configuration of the consumer application:
34
+
35
+ | Kind | Names | Origin |
36
+ |---|---|---|
37
+ | Types | `input`, `string`, `number`, `integer`, `checkbox`, `boolean`, `select`, `enum`, `radio`, `textarea`, `datepicker` | `@ngx-formly/primeng` |
38
+ | Wrapper | `form-field` | `@ngx-formly/primeng` |
39
+ | Type | `w-schema-form-secret` | this entry point (secret entry) |
40
+ | Wrapper | `w-schema-form-field` | this entry point (label, required marker, description tooltip, errors) |
41
+
42
+ If your application registers its own Formly types or wrappers with the same names, the last registration
43
+ wins for the whole application. Use other names for your own types, or register the same PrimeNG types.
44
+ The internal names are prefixed with `w-schema-form` to avoid collisions.
45
+
46
+ ## Translations
47
+
48
+ `W_SCHEMA_FORM_DEFAULT_TRANSLATIONS` (Spanish) is frozen. Pass your own `WSchemaFormTranslations` object;
49
+ `null` falls back to the defaults. `fields` overrides labels and descriptions by JSON Pointer (also for
50
+ objects reached through a local `$ref`). Descriptions are shown as a help tooltip next to the label.
@@ -0,0 +1,146 @@
1
+ import * as i0 from '@angular/core';
2
+ import { OnChanges, OnDestroy, EventEmitter } from '@angular/core';
3
+ import { FormGroup, AbstractControl } from '@angular/forms';
4
+ import { FormlyFieldConfig } from '@ngx-formly/core';
5
+
6
+ /** JSON Schema dialects accepted by `w-schema-form`. */
7
+ type WSchemaFormDialect = 'draft-07' | '2020-12';
8
+ /** Single types accepted by `w-schema-form`. Arrays only as `uniqueItems` + `items.enum`. */
9
+ type WJsonSchemaType = 'object' | 'string' | 'number' | 'integer' | 'boolean' | 'array';
10
+ /**
11
+ * `x-wapping-secret` annotation (central design of connectors-management).
12
+ * The browser ignores its content; it only marks the field as a secret.
13
+ */
14
+ interface WJsonSchemaSecretAnnotation {
15
+ vaultProfile?: string;
16
+ nameTemplate?: string;
17
+ }
18
+ /**
19
+ * JSON Schema accepted as input. Only the keywords listed in the design are supported;
20
+ * any other keyword is reported as a configuration error at runtime.
21
+ */
22
+ interface WJsonSchema {
23
+ $schema?: string;
24
+ $id?: string;
25
+ $comment?: string;
26
+ title?: string;
27
+ description?: string;
28
+ type?: WJsonSchemaType;
29
+ properties?: Record<string, WJsonSchema>;
30
+ required?: string[];
31
+ additionalProperties?: false;
32
+ enum?: unknown[];
33
+ const?: unknown;
34
+ default?: unknown;
35
+ minimum?: number;
36
+ maximum?: number;
37
+ minLength?: number;
38
+ maxLength?: number;
39
+ pattern?: string;
40
+ items?: WJsonSchema;
41
+ uniqueItems?: boolean;
42
+ $ref?: string;
43
+ $defs?: Record<string, WJsonSchema>;
44
+ definitions?: Record<string, WJsonSchema>;
45
+ readOnly?: boolean;
46
+ writeOnly?: boolean;
47
+ 'x-wapping-secret'?: WJsonSchemaSecretAnnotation;
48
+ /** Unsupported keywords are accepted by the type and rejected explicitly at runtime. */
49
+ [keyword: string]: unknown;
50
+ }
51
+
52
+ /** Server state of a secret field. `path` is a JSON Pointer of the schema property. */
53
+ interface WSchemaFormSecretState {
54
+ path: string;
55
+ hasValue: boolean;
56
+ }
57
+
58
+ /** Diagnostic without values: JSON Pointer of the instance, keyword and validator message. */
59
+ interface WSchemaFormError {
60
+ instancePath: string;
61
+ keyword: string;
62
+ message?: string;
63
+ }
64
+ /** Secret field status. Never contains the secret value. */
65
+ interface WSchemaFormSecretStatus {
66
+ path: string;
67
+ hasValue: boolean;
68
+ replacementPending: boolean;
69
+ }
70
+ type WSchemaFormStatus = 'valid' | 'invalid' | 'error';
71
+ interface WSchemaFormState {
72
+ status: WSchemaFormStatus;
73
+ errors: ReadonlyArray<WSchemaFormError>;
74
+ secrets: ReadonlyArray<WSchemaFormSecretStatus>;
75
+ }
76
+
77
+ /** Replacement of a secret value. `path` is a JSON Pointer of the schema property. */
78
+ interface WSchemaFormSecretReplacement {
79
+ path: string;
80
+ value: string;
81
+ }
82
+ /** Valid submission: public configuration without secret paths and non-empty secret replacements. */
83
+ interface WSchemaFormSubmit {
84
+ configuration: Record<string, unknown>;
85
+ secrets: ReadonlyArray<WSchemaFormSecretReplacement>;
86
+ }
87
+
88
+ /** Label and help text override for a field identified by JSON Pointer (SFC-D07). */
89
+ interface WSchemaFormFieldTranslation {
90
+ label?: string;
91
+ description?: string;
92
+ }
93
+ interface WSchemaFormTranslations {
94
+ configurationError: string;
95
+ invalidValues: string;
96
+ secretConfigured: string;
97
+ secretPending: string;
98
+ secretReplaceHint: string;
99
+ showSecret: string;
100
+ hideSecret: string;
101
+ /** Optional overrides of schema `title`/`description`, keyed by JSON Pointer (e.g. `/account/clientId`). */
102
+ fields?: Readonly<Record<string, WSchemaFormFieldTranslation>>;
103
+ }
104
+ /** Default Spanish texts. Frozen: consumers must pass their own object instead of mutating this one. */
105
+ declare const W_SCHEMA_FORM_DEFAULT_TRANSLATIONS: Readonly<WSchemaFormTranslations>;
106
+
107
+ /**
108
+ * JSON Schema form (CM-007). Emits the public configuration and the secret replacements separately and
109
+ * never preloads, stores or reports secret values (SF-001..SF-009).
110
+ */
111
+ declare class WSchemaFormComponent implements OnChanges, OnDestroy {
112
+ schema: WJsonSchema | null;
113
+ values: Record<string, unknown> | null;
114
+ dialect?: WSchemaFormDialect;
115
+ secretStates: ReadonlyArray<WSchemaFormSecretState> | null;
116
+ translations: Readonly<WSchemaFormTranslations> | null;
117
+ stateChange: EventEmitter<WSchemaFormState>;
118
+ validSubmit: EventEmitter<WSchemaFormSubmit>;
119
+ protected form: FormGroup<Record<string, AbstractControl<unknown, unknown, any>>>;
120
+ protected fields: FormlyFieldConfig[];
121
+ protected model: Record<string, unknown>;
122
+ protected state: WSchemaFormState;
123
+ /** Consumer translations merged over the defaults (a null or partial input never breaks the template). */
124
+ protected texts: Readonly<WSchemaFormTranslations>;
125
+ private readonly formlyJsonschema;
126
+ private validator?;
127
+ private secrets;
128
+ private secretSubscriptions;
129
+ ngOnChanges(): void;
130
+ ngOnDestroy(): void;
131
+ protected onModelChange(model: Record<string, unknown>): void;
132
+ submit(): void;
133
+ private validate;
134
+ private fail;
135
+ /** Discards controls, validators and typed secret values (SF-003, SF-008). */
136
+ private reset;
137
+ /** SF-006/SF-007: secret states must target declared secrets and values must not carry secrets. */
138
+ private assertSecretInputs;
139
+ private mapField;
140
+ private mapSecretField;
141
+ static ɵfac: i0.ɵɵFactoryDeclaration<WSchemaFormComponent, never>;
142
+ static ɵcmp: i0.ɵɵComponentDeclaration<WSchemaFormComponent, "w-schema-form", never, { "schema": { "alias": "schema"; "required": true; }; "values": { "alias": "values"; "required": true; }; "dialect": { "alias": "dialect"; "required": false; }; "secretStates": { "alias": "secretStates"; "required": false; }; "translations": { "alias": "translations"; "required": false; }; }, { "stateChange": "stateChange"; "validSubmit": "validSubmit"; }, never, never, true, never>;
143
+ }
144
+
145
+ export { WSchemaFormComponent, W_SCHEMA_FORM_DEFAULT_TRANSLATIONS };
146
+ export type { WJsonSchema, WJsonSchemaSecretAnnotation, WJsonSchemaType, WSchemaFormDialect, WSchemaFormError, WSchemaFormFieldTranslation, WSchemaFormSecretReplacement, WSchemaFormSecretState, WSchemaFormSecretStatus, WSchemaFormState, WSchemaFormStatus, WSchemaFormSubmit, WSchemaFormTranslations };