@elle96/ng-json-schema-manager 0.2.0 → 0.3.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/index.d.ts CHANGED
@@ -132,6 +132,56 @@ declare class JsonSchemaStylesService {
132
132
  static ɵprov: i0.ɵɵInjectableDeclaration<JsonSchemaStylesService>;
133
133
  }
134
134
 
135
+ /**
136
+ * Texts shown by the form. Every value can be overridden through the `labels` input of `jsm-json-schema-form`
137
+ * (e.g. to translate them); omitted keys keep the English default.
138
+ * `{n}` and `{name}` placeholders are replaced with the item number / field name.
139
+ */
140
+ interface JsonSchemaFormLabels {
141
+ /** Title used when the schema has none. */
142
+ formTitle: string;
143
+ resolving: string;
144
+ schemaErrorsTitle: string;
145
+ schemaErrorsHint: string;
146
+ addItem: string;
147
+ /** Hidden name of an array item, announced by screen readers ("Item {n}"). */
148
+ arrayItem: string;
149
+ remove: string;
150
+ add: string;
151
+ addProperty: string;
152
+ propertyName: string;
153
+ noItems: string;
154
+ mustContain: string;
155
+ min: string;
156
+ max: string;
157
+ /** "Option {n}" for oneOf/anyOf entries without a title. */
158
+ option: string;
159
+ /** "Section {n}" for allOf entries without a title. */
160
+ section: string;
161
+ example: string;
162
+ propertyNameRequired: string;
163
+ propertyNameInvalid: string;
164
+ propertyExists: string;
165
+ propertyNotAllowed: string;
166
+ errorRequired: string;
167
+ errorMinLength: string;
168
+ errorMaxLength: string;
169
+ errorMin: string;
170
+ errorMax: string;
171
+ errorEmail: string;
172
+ errorPattern: string;
173
+ errorInteger: string;
174
+ errorExclusiveMin: string;
175
+ errorExclusiveMax: string;
176
+ errorMultipleOf: string;
177
+ errorMinItems: string;
178
+ errorMaxItems: string;
179
+ errorUniqueItems: string;
180
+ }
181
+ declare const DEFAULT_LABELS: JsonSchemaFormLabels;
182
+ /** Replaces `{key}` placeholders in a label template. */
183
+ declare function formatLabel(template: string, values?: Record<string, string | number>): string;
184
+
135
185
  /** Character shown between the integer and decimal part of a number. */
136
186
  type DecimalSeparator = '.' | ',';
137
187
  /**
@@ -139,6 +189,7 @@ type DecimalSeparator = '.' | ',';
139
189
  */
140
190
  declare class JsonSchemaFormOptions {
141
191
  decimalSeparator: DecimalSeparator;
192
+ labels: JsonSchemaFormLabels;
142
193
  static ɵfac: i0.ɵɵFactoryDeclaration<JsonSchemaFormOptions, never>;
143
194
  static ɵprov: i0.ɵɵInjectableDeclaration<JsonSchemaFormOptions>;
144
195
  }
@@ -183,7 +234,7 @@ declare class JsonSchemaFormComponent implements OnChanges, OnDestroy {
183
234
  private readonly resolver;
184
235
  private readonly validation;
185
236
  private readonly cdr;
186
- private readonly options;
237
+ protected readonly options: JsonSchemaFormOptions;
187
238
  schema: JsonSchema;
188
239
  value?: unknown;
189
240
  data?: unknown;
@@ -193,6 +244,8 @@ declare class JsonSchemaFormComponent implements OnChanges, OnDestroy {
193
244
  * either way); the emitted value is always a JSON number.
194
245
  */
195
246
  decimalSeparator: DecimalSeparator;
247
+ /** Texts shown by the form (translate them here); omitted keys keep the English default. */
248
+ labels: Partial<JsonSchemaFormLabels>;
196
249
  formReady: EventEmitter<FormGroup<any>>;
197
250
  valueChange: EventEmitter<unknown>;
198
251
  schemaReady: EventEmitter<JsonSchema>;
@@ -206,6 +259,8 @@ declare class JsonSchemaFormComponent implements OnChanges, OnDestroy {
206
259
  /** When true, all field errors are shown regardless of touched/dirty state. */
207
260
  showErrors: boolean;
208
261
  private valueSub?;
262
+ /** Last value emitted through valueChange (same reference the parent gets back through `data`/`value`). */
263
+ private lastEmitted;
209
264
  constructor(schemaService: JsonSchemaFormService, resolver: JsonSchemaResolverService, validation: JsonSchemaValidationService, cdr: ChangeDetectorRef, options: JsonSchemaFormOptions, stylesService: JsonSchemaStylesService);
210
265
  ngOnChanges(changes: SimpleChanges): void;
211
266
  ngOnDestroy(): void;
@@ -220,7 +275,7 @@ declare class JsonSchemaFormComponent implements OnChanges, OnDestroy {
220
275
  onRootReplaced(control: AbstractControl): void;
221
276
  private attachValueSub;
222
277
  static ɵfac: i0.ɵɵFactoryDeclaration<JsonSchemaFormComponent, never>;
223
- 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; }; "decimalSeparator": { "alias": "decimalSeparator"; "required": false; }; }, { "formReady": "formReady"; "valueChange": "valueChange"; "schemaReady": "schemaReady"; "schemaErrors": "schemaErrors"; }, never, never, true, never>;
278
+ 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; }; "decimalSeparator": { "alias": "decimalSeparator"; "required": false; }; "labels": { "alias": "labels"; "required": false; }; }, { "formReady": "formReady"; "valueChange": "valueChange"; "schemaReady": "schemaReady"; "schemaErrors": "schemaErrors"; }, never, never, true, never>;
224
279
  }
225
280
 
226
281
  declare class JsonSchemaNodeComponent implements OnInit, OnDestroy {
@@ -246,6 +301,8 @@ declare class JsonSchemaNodeComponent implements OnInit, OnDestroy {
246
301
  propertyError: string;
247
302
  /** Tracks whether this primitive control has been touched (for OnPush CD). */
248
303
  isTouched: boolean;
304
+ /** Unique DOM id base of this node: links labels, hints and errors to the control (WCAG 1.3.1, 4.1.2). */
305
+ readonly nodeId: string;
249
306
  private valueSub?;
250
307
  constructor(schemaService: JsonSchemaFormService, validation: JsonSchemaValidationService, cdr: ChangeDetectorRef, options: JsonSchemaFormOptions | null);
251
308
  ngOnInit(): void;
@@ -257,6 +314,21 @@ declare class JsonSchemaNodeComponent implements OnInit, OnDestroy {
257
314
  get nodeKind(): 'oneOf' | 'anyOf' | 'allOf' | 'object' | 'array' | 'primitive';
258
315
  get resolvedType(): JsonSchema['type'] | 'enum';
259
316
  get decimalSeparator(): DecimalSeparator;
317
+ /** Texts shown by the form (see `labels` of `jsm-json-schema-form`). */
318
+ get l(): JsonSchemaFormLabels;
319
+ fmt(template: string, values?: Record<string, string | number>): string;
320
+ localize(message: string): string;
321
+ optionLabel(index: number): string;
322
+ sectionLabel(index: number): string;
323
+ /** DOM id of a dynamic key label (keys may contain characters that are not valid in ids). */
324
+ keyId(key: string): string;
325
+ /** True when the error list of this primitive is shown (same gate as the error styling). */
326
+ get visibleError(): boolean;
327
+ /** Ids of the hint, example, media type and error texts that describe this control. */
328
+ get describedBy(): string | null;
329
+ selectOneOf(index: number): void;
330
+ /** WAI-ARIA tabs keyboard support: arrows, Home and End move between the oneOf options. */
331
+ onOneOfKeydown(event: KeyboardEvent): void;
260
332
  /** `multipleOf` of this node's own schema, exposed as step metadata. */
261
333
  get numericStep(): string;
262
334
  get inputKind(): 'text' | 'number' | 'textarea' | 'select' | 'checkbox';
@@ -274,6 +346,10 @@ declare class JsonSchemaNodeComponent implements OnInit, OnDestroy {
274
346
  get allErrors(): string[];
275
347
  get metaBadges(): string[];
276
348
  get activeVariant(): JsonSchema | null;
349
+ /**
350
+ * Sections rendered for an allOf: the schema's own keywords (without the allOf itself, which would render
351
+ * this node again forever) when it declares any, followed by every allOf entry.
352
+ */
277
353
  get mergedAllOf(): JsonSchema[];
278
354
  isRequired(key: string): boolean;
279
355
  schemaForKey(key: string): JsonSchema;
@@ -314,5 +390,5 @@ declare class JsonSchemaFormModule {
314
390
  */
315
391
  declare function normalizeValue(schema: JsonSchema, value: unknown): unknown;
316
392
 
317
- export { JsonSchemaFormComponent, JsonSchemaFormModule, JsonSchemaFormOptions, JsonSchemaFormService, JsonSchemaNodeComponent, JsonSchemaResolverService, JsonSchemaStylesService, JsonSchemaValidationService, NumericInputDirective, formatNumeric, localizeNumbers, normalizeValue, parseNumericText, sanitizeNumericText };
318
- export type { DecimalSeparator, JsonSchema, JsonSchemaArray, JsonSchemaBase, JsonSchemaCombinators, JsonSchemaDraft, JsonSchemaObject, JsonSchemaPrimitive, JsonSchemaType, SchemaError, SchemaFieldContext };
393
+ export { DEFAULT_LABELS, JsonSchemaFormComponent, JsonSchemaFormModule, JsonSchemaFormOptions, JsonSchemaFormService, JsonSchemaNodeComponent, JsonSchemaResolverService, JsonSchemaStylesService, JsonSchemaValidationService, NumericInputDirective, formatLabel, formatNumeric, localizeNumbers, normalizeValue, parseNumericText, sanitizeNumericText };
394
+ export type { DecimalSeparator, JsonSchema, JsonSchemaArray, JsonSchemaBase, JsonSchemaCombinators, JsonSchemaDraft, JsonSchemaFormLabels, 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.2.0",
3
+ "version": "0.3.0",
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": {