@elle96/ng-json-schema-manager 0.1.2 → 0.1.4
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/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractControl, FormGroup, FormArray, FormControl } from '@angular/forms';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { OnChanges, OnDestroy, EventEmitter, SimpleChanges, OnInit } from '@angular/core';
|
|
3
|
+
import { OnChanges, OnDestroy, EventEmitter, ChangeDetectorRef, SimpleChanges, OnInit } from '@angular/core';
|
|
4
4
|
import { ErrorObject } from 'ajv';
|
|
5
5
|
|
|
6
6
|
type JsonSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
|
|
@@ -123,10 +123,20 @@ declare class JsonSchemaValidationService {
|
|
|
123
123
|
static ɵprov: i0.ɵɵInjectableDeclaration<JsonSchemaValidationService>;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
declare class JsonSchemaStylesService {
|
|
127
|
+
private platformId;
|
|
128
|
+
private injected;
|
|
129
|
+
constructor(platformId: object);
|
|
130
|
+
inject(): void;
|
|
131
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<JsonSchemaStylesService, never>;
|
|
132
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<JsonSchemaStylesService>;
|
|
133
|
+
}
|
|
134
|
+
|
|
126
135
|
declare class JsonSchemaFormComponent implements OnChanges, OnDestroy {
|
|
127
136
|
private readonly schemaService;
|
|
128
137
|
private readonly resolver;
|
|
129
138
|
private readonly validation;
|
|
139
|
+
private readonly cdr;
|
|
130
140
|
schema: JsonSchema;
|
|
131
141
|
value?: unknown;
|
|
132
142
|
data?: unknown;
|
|
@@ -141,21 +151,36 @@ declare class JsonSchemaFormComponent implements OnChanges, OnDestroy {
|
|
|
141
151
|
errorsMap: Map<string, string[]>;
|
|
142
152
|
schemaErrorList: SchemaError[];
|
|
143
153
|
loading: boolean;
|
|
154
|
+
/** When true, all field errors are shown regardless of touched/dirty state. */
|
|
155
|
+
showErrors: boolean;
|
|
144
156
|
private valueSub?;
|
|
145
|
-
constructor(schemaService: JsonSchemaFormService, resolver: JsonSchemaResolverService, validation: JsonSchemaValidationService);
|
|
157
|
+
constructor(schemaService: JsonSchemaFormService, resolver: JsonSchemaResolverService, validation: JsonSchemaValidationService, cdr: ChangeDetectorRef, stylesService: JsonSchemaStylesService);
|
|
146
158
|
ngOnChanges(changes: SimpleChanges): void;
|
|
147
159
|
ngOnDestroy(): void;
|
|
160
|
+
/**
|
|
161
|
+
* Marks all fields as touched and forces error display across the entire form.
|
|
162
|
+
* Call this from an external "Save" or "Submit" button to show all validation errors at once.
|
|
163
|
+
* Returns true if the form is valid, false otherwise.
|
|
164
|
+
*/
|
|
165
|
+
validate(): boolean;
|
|
148
166
|
private buildForm;
|
|
149
167
|
private updateErrors;
|
|
168
|
+
/**
|
|
169
|
+
* Recursively coerces string values to numbers/booleans where the schema declares
|
|
170
|
+
* type "number" or "integer". This is needed because <input type="number"> always
|
|
171
|
+
* returns a string to Angular's FormControl, but Ajv validates against the JSON type.
|
|
172
|
+
*/
|
|
173
|
+
private normalizeValue;
|
|
150
174
|
onRootReplaced(control: AbstractControl): void;
|
|
151
175
|
private attachValueSub;
|
|
152
176
|
static ɵfac: i0.ɵɵFactoryDeclaration<JsonSchemaFormComponent, never>;
|
|
153
177
|
static ɵcmp: i0.ɵɵComponentDeclaration<JsonSchemaFormComponent, "jsm-json-schema-form", never, { "schema": { "alias": "schema"; "required": true; }; "value": { "alias": "value"; "required": false; }; "data": { "alias": "data"; "required": false; }; "allowAdditionalProperties": { "alias": "allowAdditionalProperties"; "required": false; }; }, { "formReady": "formReady"; "valueChange": "valueChange"; "schemaReady": "schemaReady"; "schemaErrors": "schemaErrors"; }, never, never, true, never>;
|
|
154
178
|
}
|
|
155
179
|
|
|
156
|
-
declare class JsonSchemaNodeComponent implements OnInit {
|
|
180
|
+
declare class JsonSchemaNodeComponent implements OnInit, OnDestroy {
|
|
157
181
|
private readonly schemaService;
|
|
158
182
|
private readonly validation;
|
|
183
|
+
private readonly cdr;
|
|
159
184
|
schema: JsonSchema;
|
|
160
185
|
control: AbstractControl;
|
|
161
186
|
label: string;
|
|
@@ -165,20 +190,23 @@ declare class JsonSchemaNodeComponent implements OnInit {
|
|
|
165
190
|
parent?: FormGroup | FormArray;
|
|
166
191
|
controlKey?: string | number;
|
|
167
192
|
allowAdditionalProperties: boolean;
|
|
193
|
+
/** When true, errors are shown regardless of touched/dirty state (e.g. triggered by an external save button). */
|
|
194
|
+
showErrors: boolean;
|
|
168
195
|
controlReplaced: EventEmitter<AbstractControl<any, any, any>>;
|
|
169
196
|
selectedOneOf: number;
|
|
170
197
|
selectedAnyOf: Set<number>;
|
|
171
198
|
newPropertyKey: string;
|
|
172
199
|
propertyError: string;
|
|
173
|
-
|
|
200
|
+
/** Tracks whether this primitive control has been touched (for OnPush CD). */
|
|
201
|
+
isTouched: boolean;
|
|
202
|
+
private valueSub?;
|
|
203
|
+
constructor(schemaService: JsonSchemaFormService, validation: JsonSchemaValidationService, cdr: ChangeDetectorRef);
|
|
174
204
|
ngOnInit(): void;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
* che deve occupare la larghezza piena.
|
|
179
|
-
*/
|
|
205
|
+
ngOnDestroy(): void;
|
|
206
|
+
/** Called on blur of primitive inputs to trigger CD after Angular marks the control as touched. */
|
|
207
|
+
onBlur(): void;
|
|
180
208
|
isSimpleChild(key: string): boolean;
|
|
181
|
-
badgeClass(badge: string):
|
|
209
|
+
badgeClass(badge: string): string;
|
|
182
210
|
get nodeKind(): 'oneOf' | 'anyOf' | 'allOf' | 'object' | 'array' | 'primitive';
|
|
183
211
|
get resolvedType(): JsonSchema['type'] | 'enum';
|
|
184
212
|
get inputKind(): 'text' | 'textarea' | 'select' | 'checkbox';
|
|
@@ -192,6 +220,8 @@ declare class JsonSchemaNodeComponent implements OnInit {
|
|
|
192
220
|
get complexKeys(): string[];
|
|
193
221
|
get canAddProperty(): boolean;
|
|
194
222
|
get errorsForPath(): string[];
|
|
223
|
+
/** Combined errors: Ajv errors from errorsMap + Angular validator errors on the control. */
|
|
224
|
+
get allErrors(): string[];
|
|
195
225
|
get metaBadges(): string[];
|
|
196
226
|
get activeVariant(): JsonSchema | null;
|
|
197
227
|
get mergedAllOf(): JsonSchema[];
|
|
@@ -214,7 +244,7 @@ declare class JsonSchemaNodeComponent implements OnInit {
|
|
|
214
244
|
private applyDependencies;
|
|
215
245
|
private mergeSchemas;
|
|
216
246
|
static ɵfac: i0.ɵɵFactoryDeclaration<JsonSchemaNodeComponent, never>;
|
|
217
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<JsonSchemaNodeComponent, "jsm-schema-node", never, { "schema": { "alias": "schema"; "required": true; }; "control": { "alias": "control"; "required": true; }; "label": { "alias": "label"; "required": false; }; "required": { "alias": "required"; "required": false; }; "path": { "alias": "path"; "required": false; }; "errorsMap": { "alias": "errorsMap"; "required": false; }; "parent": { "alias": "parent"; "required": false; }; "controlKey": { "alias": "controlKey"; "required": false; }; "allowAdditionalProperties": { "alias": "allowAdditionalProperties"; "required": false; }; }, { "controlReplaced": "controlReplaced"; }, never, never, true, never>;
|
|
247
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<JsonSchemaNodeComponent, "jsm-schema-node", never, { "schema": { "alias": "schema"; "required": true; }; "control": { "alias": "control"; "required": true; }; "label": { "alias": "label"; "required": false; }; "required": { "alias": "required"; "required": false; }; "path": { "alias": "path"; "required": false; }; "errorsMap": { "alias": "errorsMap"; "required": false; }; "parent": { "alias": "parent"; "required": false; }; "controlKey": { "alias": "controlKey"; "required": false; }; "allowAdditionalProperties": { "alias": "allowAdditionalProperties"; "required": false; }; "showErrors": { "alias": "showErrors"; "required": false; }; }, { "controlReplaced": "controlReplaced"; }, never, never, true, never>;
|
|
218
248
|
}
|
|
219
249
|
|
|
220
250
|
declare class JsonSchemaFormModule {
|
|
@@ -223,5 +253,5 @@ declare class JsonSchemaFormModule {
|
|
|
223
253
|
static ɵinj: i0.ɵɵInjectorDeclaration<JsonSchemaFormModule>;
|
|
224
254
|
}
|
|
225
255
|
|
|
226
|
-
export { JsonSchemaFormComponent, JsonSchemaFormModule, JsonSchemaFormService, JsonSchemaNodeComponent, JsonSchemaResolverService, JsonSchemaValidationService };
|
|
256
|
+
export { JsonSchemaFormComponent, JsonSchemaFormModule, JsonSchemaFormService, JsonSchemaNodeComponent, JsonSchemaResolverService, JsonSchemaStylesService, JsonSchemaValidationService };
|
|
227
257
|
export type { JsonSchema, JsonSchemaArray, JsonSchemaBase, JsonSchemaCombinators, JsonSchemaDraft, JsonSchemaObject, JsonSchemaPrimitive, JsonSchemaType, SchemaError, SchemaFieldContext };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elle96/ng-json-schema-manager",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Angular JSON Schema form renderer with Tailwind styling, external $ref support, and reactive forms.",
|
|
5
5
|
"homepage": "https://luigiellebalotta.github.io/json-schema-manager/",
|
|
6
6
|
"repository": {
|