@elle96/ng-json-schema-manager 0.2.1 → 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>;
@@ -222,7 +275,7 @@ declare class JsonSchemaFormComponent implements OnChanges, OnDestroy {
222
275
  onRootReplaced(control: AbstractControl): void;
223
276
  private attachValueSub;
224
277
  static ɵfac: i0.ɵɵFactoryDeclaration<JsonSchemaFormComponent, never>;
225
- 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>;
226
279
  }
227
280
 
228
281
  declare class JsonSchemaNodeComponent implements OnInit, OnDestroy {
@@ -248,6 +301,8 @@ declare class JsonSchemaNodeComponent implements OnInit, OnDestroy {
248
301
  propertyError: string;
249
302
  /** Tracks whether this primitive control has been touched (for OnPush CD). */
250
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;
251
306
  private valueSub?;
252
307
  constructor(schemaService: JsonSchemaFormService, validation: JsonSchemaValidationService, cdr: ChangeDetectorRef, options: JsonSchemaFormOptions | null);
253
308
  ngOnInit(): void;
@@ -259,6 +314,21 @@ declare class JsonSchemaNodeComponent implements OnInit, OnDestroy {
259
314
  get nodeKind(): 'oneOf' | 'anyOf' | 'allOf' | 'object' | 'array' | 'primitive';
260
315
  get resolvedType(): JsonSchema['type'] | 'enum';
261
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;
262
332
  /** `multipleOf` of this node's own schema, exposed as step metadata. */
263
333
  get numericStep(): string;
264
334
  get inputKind(): 'text' | 'number' | 'textarea' | 'select' | 'checkbox';
@@ -276,6 +346,10 @@ declare class JsonSchemaNodeComponent implements OnInit, OnDestroy {
276
346
  get allErrors(): string[];
277
347
  get metaBadges(): string[];
278
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
+ */
279
353
  get mergedAllOf(): JsonSchema[];
280
354
  isRequired(key: string): boolean;
281
355
  schemaForKey(key: string): JsonSchema;
@@ -316,5 +390,5 @@ declare class JsonSchemaFormModule {
316
390
  */
317
391
  declare function normalizeValue(schema: JsonSchema, value: unknown): unknown;
318
392
 
319
- export { JsonSchemaFormComponent, JsonSchemaFormModule, JsonSchemaFormOptions, JsonSchemaFormService, JsonSchemaNodeComponent, JsonSchemaResolverService, JsonSchemaStylesService, JsonSchemaValidationService, NumericInputDirective, formatNumeric, localizeNumbers, normalizeValue, parseNumericText, sanitizeNumericText };
320
- 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.1",
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": {