ngx-json-schema-viewer
Version:
<h1 align="center">ngx-json-schema-viewer</h1>
1,122 lines (1,069 loc) • 227 kB
JavaScript
import * as i0 from '@angular/core';
import { InjectionToken, Injectable, Inject, Component, ChangeDetectionStrategy, Input, forwardRef, Pipe, signal, computed } from '@angular/core';
import * as i1$2 from '@angular/material/expansion';
import { MatExpansionModule } from '@angular/material/expansion';
import * as i1$1 from '@angular/material/tabs';
import { MatTabsModule } from '@angular/material/tabs';
import * as i1 from '@angular/common';
import { NgTemplateOutlet, CommonModule } from '@angular/common';
import { Highlight } from 'ngx-highlightjs';
import { Resolver } from '@stoplight/json-ref-resolver';
import { Observable } from 'rxjs';
// Define an InjectionToken for JSVOptions
const JSV_OPTIONS = new InjectionToken('JSVOptions');
class JSVOptionsService {
constructor(userOptions) {
// Set default options
this.options = {
showExamples: false,
qualifierMessagesOrder: [
"nullable",
"deprecated",
"readOnly",
"writeOnly",
"enum",
"stringLength",
"objectProperties",
"no-extra-properties",
"arrayItems",
"arrayContains",
"no-extra-items",
"number-range",
"pattern",
"multipleOf",
"uniqueItems",
"contentEncoding",
"contentMediaType",
"contentSchema",
"default",
"const",
"examples"
]
};
// Apply user provided options
this.setOptions(userOptions);
}
setOptions(userOptions) {
this.options = {
...this.options,
...userOptions
};
}
getOptions() {
return this.options;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: JSVOptionsService, deps: [{ token: JSV_OPTIONS }], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: JSVOptionsService, providedIn: "root" }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: JSVOptionsService, decorators: [{
type: Injectable,
args: [{
providedIn: "root"
}]
}], ctorParameters: () => [{ type: undefined, decorators: [{
type: Inject,
args: [JSV_OPTIONS]
}] }] });
class DeprecatedLabelComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: DeprecatedLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: DeprecatedLabelComponent, isStandalone: true, selector: "labels-deprecated", ngImport: i0, template: "<strong class=\"deprecated\">\n deprecated\n</strong> ", styles: [".deprecated{font-size:90%;color:#ffba00;margin-right:4px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: DeprecatedLabelComponent, decorators: [{
type: Component,
args: [{ selector: 'labels-deprecated', standalone: true, imports: [], changeDetection: ChangeDetectionStrategy.OnPush, template: "<strong class=\"deprecated\">\n deprecated\n</strong> ", styles: [".deprecated{font-size:90%;color:#ffba00;margin-right:4px}\n"] }]
}] });
class ReadOnlyLabelComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: ReadOnlyLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: ReadOnlyLabelComponent, isStandalone: true, selector: "labels-read-only", ngImport: i0, template: "<strong class=\"readOnly\">\n readOnly\n</strong>\n ", styles: [".readOnly{font-size:90%;color:#47a9c9;margin-right:4px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: ReadOnlyLabelComponent, decorators: [{
type: Component,
args: [{ selector: 'labels-read-only', standalone: true, imports: [], changeDetection: ChangeDetectionStrategy.OnPush, template: "<strong class=\"readOnly\">\n readOnly\n</strong>\n ", styles: [".readOnly{font-size:90%;color:#47a9c9;margin-right:4px}\n"] }]
}] });
class RequiredLabelComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: RequiredLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: RequiredLabelComponent, isStandalone: true, selector: "labels-required", ngImport: i0, template: "<strong class=\"required\">\n required\n</strong> ", styles: [".required{font-size:90%;color:#fa383e;margin-right:4px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: RequiredLabelComponent, decorators: [{
type: Component,
args: [{ selector: 'labels-required', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: "<strong class=\"required\">\n required\n</strong> ", styles: [".required{font-size:90%;color:#fa383e;margin-right:4px}\n"] }]
}] });
class WriteOnlyLabelComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: WriteOnlyLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: WriteOnlyLabelComponent, isStandalone: true, selector: "labels-write-only", ngImport: i0, template: "<strong class=\"writeOnly\">\n writeOnly\n</strong>\n ", styles: [".writeOnly{font-size:90%;color:#2d66c3;margin-right:4px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: WriteOnlyLabelComponent, decorators: [{
type: Component,
args: [{ selector: 'labels-write-only', standalone: true, imports: [], changeDetection: ChangeDetectionStrategy.OnPush, template: "<strong class=\"writeOnly\">\n writeOnly\n</strong>\n ", styles: [".writeOnly{font-size:90%;color:#2d66c3;margin-right:4px}\n"] }]
}] });
class AndLabelComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: AndLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: AndLabelComponent, isStandalone: true, selector: "labels-and", ngImport: i0, template: `
<ng-container *ngTemplateOutlet="spaceTemplate"></ng-container>
<strong>AND</strong>
<ng-container *ngTemplateOutlet="spaceTemplate"></ng-container>
<ng-template #spaceTemplate>
</ng-template>
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: AndLabelComponent, decorators: [{
type: Component,
args: [{
selector: 'labels-and',
standalone: true,
imports: [NgTemplateOutlet],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-container *ngTemplateOutlet="spaceTemplate"></ng-container>
<strong>AND</strong>
<ng-container *ngTemplateOutlet="spaceTemplate"></ng-container>
<ng-template #spaceTemplate>
</ng-template>
`,
}]
}] });
class OrLabelComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: OrLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: OrLabelComponent, isStandalone: true, selector: "labels-or", ngImport: i0, template: `
<ng-container *ngTemplateOutlet="spaceTemplate"></ng-container>
<strong>OR</strong>
<ng-container *ngTemplateOutlet="spaceTemplate"></ng-container>
<ng-template #spaceTemplate>
</ng-template>
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: OrLabelComponent, decorators: [{
type: Component,
args: [{
selector: 'labels-or',
standalone: true,
imports: [NgTemplateOutlet],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-container *ngTemplateOutlet="spaceTemplate"></ng-container>
<strong>OR</strong>
<ng-container *ngTemplateOutlet="spaceTemplate"></ng-container>
<ng-template #spaceTemplate>
</ng-template>
`,
}]
}] });
class XorLabelComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: XorLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: XorLabelComponent, isStandalone: true, selector: "labels-xor", ngImport: i0, template: `
<ng-container *ngTemplateOutlet="spaceTemplate"></ng-container>
<strong>XOR</strong>
<ng-container *ngTemplateOutlet="spaceTemplate"></ng-container>
<ng-template #spaceTemplate>
</ng-template>
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: XorLabelComponent, decorators: [{
type: Component,
args: [{
selector: 'labels-xor',
standalone: true,
imports: [
NgTemplateOutlet
],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-container *ngTemplateOutlet="spaceTemplate"></ng-container>
<strong>XOR</strong>
<ng-container *ngTemplateOutlet="spaceTemplate"></ng-container>
<ng-template #spaceTemplate>
</ng-template>
`,
}]
}] });
class IfLabelComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: IfLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: IfLabelComponent, isStandalone: true, selector: "labels-if", ngImport: i0, template: `
<strong>
If
</strong>
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: IfLabelComponent, decorators: [{
type: Component,
args: [{
selector: 'labels-if',
standalone: true,
imports: [],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<strong>
If
</strong>
`,
}]
}] });
class ElseLabelComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: ElseLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: ElseLabelComponent, isStandalone: true, selector: "labels-else", ngImport: i0, template: `
<strong>
Else
</strong>
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: ElseLabelComponent, decorators: [{
type: Component,
args: [{
selector: 'labels-else',
standalone: true,
imports: [],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<strong>
Else
</strong>
`,
}]
}] });
class ThenLabelComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: ThenLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: ThenLabelComponent, isStandalone: true, selector: "labels-then", ngImport: i0, template: `
<strong>
Then
</strong>
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: ThenLabelComponent, decorators: [{
type: Component,
args: [{
selector: 'labels-then',
standalone: true,
imports: [],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<strong>
Then
</strong>
`,
}]
}] });
class NotLabelComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: NotLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: NotLabelComponent, isStandalone: true, selector: "labels-not", ngImport: i0, template: `
<strong>
NOT
</strong>
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: NotLabelComponent, decorators: [{
type: Component,
args: [{
selector: 'labels-not',
standalone: true,
imports: [],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<strong>
NOT
</strong>
`,
}]
}] });
class ErrorOccurredLabelComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: ErrorOccurredLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.1", type: ErrorOccurredLabelComponent, isStandalone: true, selector: "labels-error-occurred", inputs: { error: "error" }, ngImport: i0, template: `
@if (error) {
<strong>Something bad happens : </strong> {{ error.message }}
}
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: ErrorOccurredLabelComponent, decorators: [{
type: Component,
args: [{
selector: 'labels-error-occurred',
standalone: true,
imports: [],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
@if (error) {
<strong>Something bad happens : </strong> {{ error.message }}
}
`,
}]
}], propDecorators: { error: [{
type: Input,
args: [{ required: true }]
}] } });
class LoadingLabelComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: LoadingLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: LoadingLabelComponent, isStandalone: true, selector: "labels-loading", ngImport: i0, template: `
<div>
Loading ....
</div>
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: LoadingLabelComponent, decorators: [{
type: Component,
args: [{
selector: 'labels-loading',
standalone: true,
imports: [],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div>
Loading ....
</div>
`,
}]
}] });
class TypeLabelComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: TypeLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: TypeLabelComponent, isStandalone: true, selector: "labels-type", ngImport: i0, template: `
<strong>
type
</strong>
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: TypeLabelComponent, decorators: [{
type: Component,
args: [{
selector: 'labels-type',
standalone: true,
imports: [],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<strong>
type
</strong>
`,
}]
}] });
class ArrayLabelComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: ArrayLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: ArrayLabelComponent, isStandalone: true, selector: "labels-array", ngImport: i0, template: `
<span style="opacity: 0.6">
array
</span>
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: ArrayLabelComponent, decorators: [{
type: Component,
args: [{
selector: 'labels-array',
standalone: true,
imports: [],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<span style="opacity: 0.6">
array
</span>
`,
}]
}] });
class BooleanLabelComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: BooleanLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: BooleanLabelComponent, isStandalone: true, selector: "labels-boolean", ngImport: i0, template: `
<span style="opacity: 0.6">
boolean
</span>
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: BooleanLabelComponent, decorators: [{
type: Component,
args: [{
selector: 'labels-boolean',
standalone: true,
imports: [],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<span style="opacity: 0.6">
boolean
</span>
`,
}]
}] });
class TrueLabelComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: TrueLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: TrueLabelComponent, isStandalone: true, selector: "labels-true", ngImport: i0, template: `
<span style="opacity: 0.6">
any
</span>
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: TrueLabelComponent, decorators: [{
type: Component,
args: [{
selector: 'labels-true',
standalone: true,
imports: [],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<span style="opacity: 0.6">
any
</span>
`,
}]
}] });
class FalseLabelComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: FalseLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: FalseLabelComponent, isStandalone: true, selector: "labels-false", ngImport: i0, template: `
<span style="opacity: 0.6">
none
</span>
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: FalseLabelComponent, decorators: [{
type: Component,
args: [{
selector: 'labels-false',
standalone: true,
imports: [],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<span style="opacity: 0.6">
none
</span>
`,
}]
}] });
class IntegerLabelComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: IntegerLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: IntegerLabelComponent, isStandalone: true, selector: "labels-integer", ngImport: i0, template: `
<span style="opacity: 0.6">
integer
</span>
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: IntegerLabelComponent, decorators: [{
type: Component,
args: [{
selector: 'labels-integer',
standalone: true,
imports: [],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<span style="opacity: 0.6">
integer
</span>
`,
}]
}] });
class NullLabelComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: NullLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: NullLabelComponent, isStandalone: true, selector: "labels-null", ngImport: i0, template: `
<span style="opacity: 0.6">
null
</span>
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: NullLabelComponent, decorators: [{
type: Component,
args: [{
selector: 'labels-null',
standalone: true,
imports: [],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<span style="opacity: 0.6">
null
</span>
`,
}]
}] });
class NumberLabelComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: NumberLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: NumberLabelComponent, isStandalone: true, selector: "labels-number", ngImport: i0, template: `
<span style="opacity: 0.6">
number
</span>
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: NumberLabelComponent, decorators: [{
type: Component,
args: [{
selector: 'labels-number',
standalone: true,
imports: [],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<span style="opacity: 0.6">
number
</span>
`,
}]
}] });
class ObjectLabelComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: ObjectLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: ObjectLabelComponent, isStandalone: true, selector: "labels-object", ngImport: i0, template: `
<span style="opacity: 0.6">
object
</span>
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: ObjectLabelComponent, decorators: [{
type: Component,
args: [{
selector: 'labels-object',
standalone: true,
imports: [],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<span style="opacity: 0.6">
object
</span>
`,
}]
}] });
class StringLabelComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: StringLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: StringLabelComponent, isStandalone: true, selector: "labels-string", ngImport: i0, template: `
<span style="opacity: 0.6">
string
</span>
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: StringLabelComponent, decorators: [{
type: Component,
args: [{
selector: 'labels-string',
standalone: true,
imports: [],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<span style="opacity: 0.6">
string
</span>
`,
}]
}] });
// Re-export labels
// Utility functions to know which case we have
const isObjectType = (schema) => typeof schema !== "boolean" &&
(schema.type === "object" ||
schema.properties !== undefined ||
schema.additionalProperties !== undefined ||
schema.patternProperties !== undefined ||
schema.propertyNames !== undefined ||
schema.minProperties !== undefined ||
schema.maxProperties !== undefined ||
schema.required !== undefined ||
schema.unevaluatedProperties !== undefined);
const isArrayType = (schema) => typeof schema !== "boolean" &&
(schema.type === "array" ||
schema.items !== undefined ||
schema.minItems !== undefined ||
schema.maxItems !== undefined ||
schema.additionalItems !== undefined ||
schema.contains !== undefined ||
schema.minContains !== undefined ||
schema.maxContains !== undefined ||
schema.prefixItems !== undefined ||
schema.unevaluatedItems !== undefined ||
Array.isArray(schema.const) ||
schema.enum?.some((s) => Array.isArray(s)));
const isStringType = (schema) => typeof schema !== "boolean" &&
(schema.type === "string" ||
schema.minLength !== undefined ||
schema.maxLength !== undefined ||
schema.pattern !== undefined ||
schema.enum?.some((val) => typeof val === "string") ||
typeof schema.const === "string");
const isNumeric = (schema) => typeof schema !== "boolean" &&
(schema.type === "number" ||
schema.multipleOf !== undefined ||
schema.minimum !== undefined ||
schema.exclusiveMinimum !== undefined ||
schema.maximum !== undefined ||
schema.exclusiveMaximum !== undefined ||
schema.enum?.some((val) => typeof val === "number") ||
typeof schema.const === "number");
// To detect integer, which is a subtype of "number"
const isInteger = (schema) => typeof schema !== "boolean" &&
(schema.type === "integer" ||
schema.multipleOf === 1 ||
schema.enum?.some((val) => typeof val === "bigint") ||
typeof schema.const === "bigint");
const isSchemaComposition = (schema) => typeof schema !== "boolean" &&
(schema.allOf !== undefined ||
schema.anyOf !== undefined ||
schema.oneOf !== undefined ||
schema.not !== undefined);
const isSchemaConditional = (schema) => typeof schema !== "boolean" &&
(schema.if !== undefined ||
schema.dependencies !== undefined ||
schema.dependentRequired !== undefined ||
schema.dependentSchemas !== undefined);
const isBoolean = (schema) => typeof schema !== "boolean" &&
(schema.type === "boolean" ||
schema.enum?.some((val) => typeof val === "boolean") ||
typeof schema.const === "boolean");
const isNull = (schema) => typeof schema !== "boolean" &&
(schema.type === "null" ||
schema.enum?.some((val) => val === null) ||
schema.const === null);
// Detect types in schema
// Zero, One or multiple types can match
function* foundUndeclaredTypes(schema) {
if (isNull(schema)) {
yield "null";
}
if (isObjectType(schema)) {
yield "object";
}
if (isArrayType(schema)) {
yield "array";
}
if (isStringType(schema)) {
yield "string";
}
if (isBoolean(schema)) {
yield "boolean";
}
if (isInteger(schema)) {
yield "integer";
}
if (!isInteger(schema) && isNumeric(schema)) {
yield "number";
}
// Job finished
return undefined;
}
// Return unique types provided by user or detected by this library
function detectedTypes(schema) {
// Find declarated type(s) provided by user
const declaredTypes = Array.isArray(schema.type)
? schema.type
: schema.type !== undefined
? [schema.type]
: [];
// If not empty, return it as it
if (declaredTypes.length !== 0) {
return [...new Set(declaredTypes)];
}
// Find undeclared type(s)
// If array is empty, it could mean that it is either "any" or "nothing"
return [...foundUndeclaredTypes(schema)];
}
class TypeLabelSwitchComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: TypeLabelSwitchComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.1", type: TypeLabelSwitchComponent, isStandalone: true, selector: "jsv-type-label-switch", inputs: { type: "type" }, ngImport: i0, template: `
@switch (type) {
@case ('string') {
<labels-string />
}
@case ('number') {
<labels-number />
}
@case ('boolean') {
<labels-boolean />
}
@case ('object') {
<labels-object />
}
@case ('array') {
<labels-array />
}
@case ('integer') {
<labels-integer />
}
@case ('null') {
<labels-null />
}
@case (true) {
<labels-true />
}
@case (false) {
<labels-false />
}
@default {
<span style="opacity: 0.6">{{ type }}</span>
}
}
`, isInline: true, dependencies: [{ kind: "component", type: StringLabelComponent, selector: "labels-string" }, { kind: "component", type: NumberLabelComponent, selector: "labels-number" }, { kind: "component", type: BooleanLabelComponent, selector: "labels-boolean" }, { kind: "component", type: ObjectLabelComponent, selector: "labels-object" }, { kind: "component", type: ArrayLabelComponent, selector: "labels-array" }, { kind: "component", type: IntegerLabelComponent, selector: "labels-integer" }, { kind: "component", type: NullLabelComponent, selector: "labels-null" }, { kind: "component", type: TrueLabelComponent, selector: "labels-true" }, { kind: "component", type: FalseLabelComponent, selector: "labels-false" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: TypeLabelSwitchComponent, decorators: [{
type: Component,
args: [{
selector: 'jsv-type-label-switch',
standalone: true,
imports: [
StringLabelComponent,
NumberLabelComponent,
BooleanLabelComponent,
ObjectLabelComponent,
ArrayLabelComponent,
IntegerLabelComponent,
NullLabelComponent,
TrueLabelComponent,
FalseLabelComponent
],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
@switch (type) {
@case ('string') {
<labels-string />
}
@case ('number') {
<labels-number />
}
@case ('boolean') {
<labels-boolean />
}
@case ('object') {
<labels-object />
}
@case ('array') {
<labels-array />
}
@case ('integer') {
<labels-integer />
}
@case ('null') {
<labels-null />
}
@case (true) {
<labels-true />
}
@case (false) {
<labels-false />
}
@default {
<span style="opacity: 0.6">{{ type }}</span>
}
}
`,
}]
}], propDecorators: { type: [{
type: Input,
args: [{ required: true }]
}] } });
class GenerateFriendlyNameComponent {
get foundTypes() {
return (typeof this.schema !== "boolean") ? detectedTypes(this.schema) : [];
}
get isBoolean() {
return typeof this.schema === 'boolean';
}
get typedBoolean() {
return this.schema;
}
get typedSchema() {
return this.schema;
}
// To know which template to render
get selectTemplate() {
if (this.isBoolean) {
return "booleanSchema";
}
else {
let castSchema = this.typedSchema;
if (castSchema.title !== undefined) {
return "schemaTitle";
}
if (this.foundTypes.length !== 0) {
return "schemaTypes";
}
return "schemaFallback";
}
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: GenerateFriendlyNameComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.1", type: GenerateFriendlyNameComponent, isStandalone: true, selector: "jsv-friendly-name", inputs: { schema: "schema" }, ngImport: i0, template: `
<!-- Final rendered friendly name -->
@switch (selectTemplate) {
@case ('booleanSchema') {
<ng-container *ngTemplateOutlet="booleanSchema"></ng-container>
}
@case ('schemaTitle') {
<ng-container *ngTemplateOutlet="schemaTitle"></ng-container>
}
@case ('schemaTypes') {
<ng-container *ngTemplateOutlet="schemaTypes"></ng-container>
}
@default {
<ng-container *ngTemplateOutlet="schemaFallback"></ng-container>
}
}
<!-- Templates -->
<!-- In case the schema is always valid or not -->
<ng-template #booleanSchema>
<jsv-type-label-switch [type]="typedBoolean" />
</ng-template>
<!-- Some people maintaining schemas provide a friendly name by themself -->
<ng-template #schemaTitle>
{{ typedSchema.title! }}
</ng-template>
<!-- Default strategy, when types are known -->
<ng-template #schemaTypes>
@for (type of foundTypes; track type; let isLast = $last) {
<jsv-friendly-name-custom [schema]="typedSchema" [type]="type"/>
@if (!isLast) {
<labels-or />
}
}
</ng-template>
<!-- Fallback, when none of the previous rules matched -->
<ng-template #schemaFallback>
<jsv-friendly-name-fallback [schema]="typedSchema" />
</ng-template>
`, isInline: true, dependencies: [{ kind: "ngmodule", type: i0.forwardRef(() => CommonModule) }, { kind: "directive", type: i0.forwardRef(() => i1.NgTemplateOutlet), selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: i0.forwardRef(() => OrLabelComponent), selector: "labels-or" }, { kind: "component", type: i0.forwardRef(() => TypeLabelSwitchComponent), selector: "jsv-type-label-switch", inputs: ["type"] }, { kind: "component", type: i0.forwardRef(() => GenerateFriendlyNameFallbackComponent), selector: "jsv-friendly-name-fallback", inputs: ["schema"] }, { kind: "component", type: i0.forwardRef(() => GenerateFriendlyNameCustomComponent), selector: "jsv-friendly-name-custom", inputs: ["schema", "type"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: GenerateFriendlyNameComponent, decorators: [{
type: Component,
args: [{
selector: 'jsv-friendly-name',
standalone: true,
imports: [
CommonModule,
OrLabelComponent,
TypeLabelSwitchComponent,
forwardRef(() => GenerateFriendlyNameFallbackComponent),
forwardRef(() => GenerateFriendlyNameCustomComponent)
],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<!-- Final rendered friendly name -->
@switch (selectTemplate) {
@case ('booleanSchema') {
<ng-container *ngTemplateOutlet="booleanSchema"></ng-container>
}
@case ('schemaTitle') {
<ng-container *ngTemplateOutlet="schemaTitle"></ng-container>
}
@case ('schemaTypes') {
<ng-container *ngTemplateOutlet="schemaTypes"></ng-container>
}
@default {
<ng-container *ngTemplateOutlet="schemaFallback"></ng-container>
}
}
<!-- Templates -->
<!-- In case the schema is always valid or not -->
<ng-template #booleanSchema>
<jsv-type-label-switch [type]="typedBoolean" />
</ng-template>
<!-- Some people maintaining schemas provide a friendly name by themself -->
<ng-template #schemaTitle>
{{ typedSchema.title! }}
</ng-template>
<!-- Default strategy, when types are known -->
<ng-template #schemaTypes>
@for (type of foundTypes; track type; let isLast = $last) {
<jsv-friendly-name-custom [schema]="typedSchema" [type]="type"/>
@if (!isLast) {
<labels-or />
}
}
</ng-template>
<!-- Fallback, when none of the previous rules matched -->
<ng-template #schemaFallback>
<jsv-friendly-name-fallback [schema]="typedSchema" />
</ng-template>
`,
}]
}], propDecorators: { schema: [{
type: Input,
args: [{ required: true }]
}] } });
class GenerateFriendlyNameFallbackComponent {
// has a "...Of" keyword ?
get hasOfKeyword() {
return this.schema.allOf !== undefined || this.schema.anyOf !== undefined || this.schema.oneOf !== undefined;
}
// has a "not" keyword ?
get hasNotKeyword() {
return this.schema.not !== undefined;
}
// Kind of operators to use ?
get linkword() {
return this.schema.anyOf ? "OR" : this.schema.oneOf ? "XOR" : "AND";
}
// allOf / anyOf / oneOf
get elementsOf() {
return (this.schema.allOf || this.schema.anyOf || this.schema.oneOf || []);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: GenerateFriendlyNameFallbackComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.1", type: GenerateFriendlyNameFallbackComponent, isStandalone: true, selector: "jsv-friendly-name-fallback", inputs: { schema: "schema" }, ngImport: i0, template: `
<!-- 1. we have a Schema Composition case (not, allOf, ...) -->
<!-- 1A) the "not" case -->
@if (hasNotKeyword) {
<labels-not />
{{ ' (' }}
<jsv-friendly-name [schema]="schema.not!" />
{{ ' ) ' }}
}
<!-- 1B) the "allOf" / "oneOf" / "anyOf" -->
@if (hasOfKeyword) {
@for (elem of elementsOf; track elem; let isLast = $last) {
<jsv-friendly-name [schema]="elem" />
@if (!isLast) {
@switch (linkword) {
@case ('OR') {
<labels-or />
}
@case ('XOR') {
<labels-xor />
}
@case ('AND') {
<labels-and />
}
}
}
}
} @else {
<jsv-type-label-switch [type]="true" />
}
<!-- 2. Assume it is "any" by default -->
`, isInline: true, dependencies: [{ kind: "component", type: i0.forwardRef(() => NotLabelComponent), selector: "labels-not" }, { kind: "component", type: i0.forwardRef(() => AndLabelComponent), selector: "labels-and" }, { kind: "component", type: i0.forwardRef(() => XorLabelComponent), selector: "labels-xor" }, { kind: "component", type: i0.forwardRef(() => OrLabelComponent), selector: "labels-or" }, { kind: "component", type: i0.forwardRef(() => GenerateFriendlyNameComponent), selector: "jsv-friendly-name", inputs: ["schema"] }, { kind: "component", type: i0.forwardRef(() => TypeLabelSwitchComponent), selector: "jsv-type-label-switch", inputs: ["type"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: GenerateFriendlyNameFallbackComponent, decorators: [{
type: Component,
args: [{
selector: 'jsv-friendly-name-fallback',
standalone: true,
imports: [
NotLabelComponent,
AndLabelComponent,
XorLabelComponent,
OrLabelComponent,
forwardRef(() => GenerateFriendlyNameComponent),
TypeLabelSwitchComponent
],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<!-- 1. we have a Schema Composition case (not, allOf, ...) -->
<!-- 1A) the "not" case -->
@if (hasNotKeyword) {
<labels-not />
{{ ' (' }}
<jsv-friendly-name [schema]="schema.not!" />
{{ ' ) ' }}
}
<!-- 1B) the "allOf" / "oneOf" / "anyOf" -->
@if (hasOfKeyword) {
@for (elem of elementsOf; track elem; let isLast = $last) {
<jsv-friendly-name [schema]="elem" />
@if (!isLast) {
@switch (linkword) {
@case ('OR') {
<labels-or />
}
@case ('XOR') {
<labels-xor />
}
@case ('AND') {
<labels-and />
}
}
}
}
} @else {
<jsv-type-label-switch [type]="true" />
}
<!-- 2. Assume it is "any" by default -->
`
}]
}], propDecorators: { schema: [{
type: Input,
args: [{ required: true }]
}] } });
class GenerateFriendlyNameCustomComponent {
get asTypedArray() {
return this.schema;
}
get stringOrFormat() {
return this.schema.format ? this.schema.format : "string";
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: GenerateFriendlyNameCustomComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.1", type: GenerateFriendlyNameCustomComponent, isStandalone: true, selector: "jsv-friendly-name-custom", inputs: { schema: "schema", type: "type" }, ngImport: i0, template: `
@switch (type) {
@case ('string') {
<jsv-type-label-switch [type]="stringOrFormat" />
}
@case ('array') {
<jsv-friendly-name-custom-array [schema]="asTypedArray" />
}
@default {
<jsv-type-label-switch [type]="type" />
}
}
`, isInline: true, dependencies: [{ kind: "component", type: i0.forwardRef(() => TypeLabelSwitchComponent), selector: "jsv-type-label-switch", inputs: ["type"] }, { kind: "component", type: i0.forwardRef(() => GenerateFriendlyNameCustomArrayComponent), selector: "jsv-friendly-name-custom-array", inputs: ["schema"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: GenerateFriendlyNameCustomComponent, decorators: [{
type: Component,
args: [{
selector: 'jsv-friendly-name-custom',
standalone: true,
imports: [
TypeLabelSwitchComponent,
forwardRef(() => GenerateFriendlyNameCustomArrayComponent)
],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
@switch (type) {
@case ('string') {
<jsv-type-label-switch [type]="stringOrFormat" />
}
@case ('array') {
<jsv-friendly-name-custom-array [schema]="asTypedArray" />
}
@default {
<jsv-type-label-switch [type]="type" />
}
}
`
}]
}], propDecorators: { schema: [{
type: Input,
args: [{ required: true }]
}], type: [{
type: Input
}] } });
class GenerateFriendlyNameCustomArrayComponent {
// For separators
get firstSeparator() {
return this.isPrefixItemsArray && this.hasItems;
}
get secondSeparator() {
return this.hasItems && this.hasAdditionalItems;
}
get thirdSeparator() {
return this.hasAdditionalItems && this.hasUnevaluatedItems;
}
get fourSeparator() {
return this.hasUnevaluatedItems && this.hasContains;
}
get fithSeparator() {
return this.hasContains && this.isOpenTuple;
}
// No clear specifications about the contents of the array ?
get noClearSpecs() {
return [undefined, false].includes(this.schema.items) &&
[undefined, false].includes(this.schema.prefixItems) &&
this.schema.contains === undefined;
}
get isPrefixItemsArray() {
return Array.isArray(this.schema.prefixItems);
}
get typedPrefixItemsArray() {
return this.schema.prefixItems;
}
get hasItems() {
return this.schema.items !== undefined && typeof this.schema.items !== "boolean";
}
get itemsAsArray() {
return (Array.isArray(this.schema.items) ? this.schema.items : [this.schema.items]);
}
get hasAdditionalItems() {
return this.schema.additionalItems !== undefined && typeof this.schema.additionalItems !== "boolean";
}
get hasUnevaluatedItems() {
return this.schema.unevaluatedItems !== undefined && typeof this.schema.unevaluatedItems !== "boolean";
}
get hasContains() {
return this.schema.contains !== undefined;
}
get isOpenTuple() {
return !(this.schema.unevaluatedItems === false ||
this.schema.items === false ||
this.schema.additionalItems