nz-json-schema-form
Version:
Schema form for JSON schema
1,174 lines • 94.4 kB
JavaScript
import * as i0 from '@angular/core';
import { Injectable, InjectionToken, inject, ChangeDetectorRef, EventEmitter, SimpleChange, ViewChild, Directive, Input, Component, ChangeDetectionStrategy, Injector } from '@angular/core';
import * as i4 from '@angular/forms';
import { Validators, AbstractControl, UntypedFormControl, UntypedFormGroup, UntypedFormArray, ReactiveFormsModule } from '@angular/forms';
import * as i2 from 'ng-zorro-antd/form';
import { NzFormModule } from 'ng-zorro-antd/form';
import { Subject } from 'rxjs';
import { NgComponentOutlet } from '@angular/common';
import * as i2$1 from 'ng-zorro-antd/button';
import { NzButtonModule } from 'ng-zorro-antd/button';
import * as i1$1 from 'ng-zorro-antd/divider';
import { NzDividerModule } from 'ng-zorro-antd/divider';
import * as i3 from 'ng-zorro-antd/switch';
import { NzSwitchModule } from 'ng-zorro-antd/switch';
import * as i1 from 'ng-zorro-antd/grid';
import * as i3$1 from 'ng-zorro-antd/input-number-legacy';
import { NzInputNumberLegacyModule } from 'ng-zorro-antd/input-number-legacy';
import * as i3$2 from 'ng-zorro-antd/input';
import { NzInputModule } from 'ng-zorro-antd/input';
import * as i5 from 'ng-zorro-antd/auto-complete';
import { NzAutocompleteModule } from 'ng-zorro-antd/auto-complete';
import * as i3$3 from 'ng-zorro-antd/cascader';
import { NzCascaderModule } from 'ng-zorro-antd/cascader';
import * as i3$4 from 'ng-zorro-antd/checkbox';
import { NzCheckboxModule } from 'ng-zorro-antd/checkbox';
import * as i3$5 from 'ng-zorro-antd/date-picker';
import { NzDatePickerModule } from 'ng-zorro-antd/date-picker';
import * as i3$6 from 'ng-zorro-antd/mention';
import { NzMentionModule } from 'ng-zorro-antd/mention';
import * as i3$7 from 'ng-zorro-antd/select';
import { NzSelectModule } from 'ng-zorro-antd/select';
import * as i3$8 from 'ng-zorro-antd/core/transition-patch';
import * as i4$1 from 'ng-zorro-antd/core/wave';
// from @types/json-schema
var JSONSchemaTypes;
(function (JSONSchemaTypes) {
JSONSchemaTypes["STRING"] = "string";
JSONSchemaTypes["NUMBER"] = "number";
JSONSchemaTypes["INTEGER"] = "integer";
JSONSchemaTypes["BOOLEAN"] = "boolean";
JSONSchemaTypes["OBJECT"] = "object";
JSONSchemaTypes["ARRAY"] = "array";
JSONSchemaTypes["NULL"] = "null";
})(JSONSchemaTypes || (JSONSchemaTypes = {}));
const formats = {
email: /^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,
date: /^\d\d\d\d-[0-1]\d-[0-3]\d$/,
time: /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d:\d\d)?$/i,
'date-time': /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d:\d\d)$/i,
uri: /^(?:[a-z][a-z0-9+-.]*:)(?:\/?\/)?[^\s]*$/i,
// eslint-disable-next-line no-control-regex
url: /^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i,
hostname: /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*$/i,
ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
regex: null,
uuid: /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i
};
function isSchemaObject(schema) {
const type = getSchemaType(schema);
return type === JSONSchemaTypes.OBJECT;
}
function isSchemaArray(schema) {
if (schema.ui && schema.ui.widget) {
return false;
}
const type = getSchemaType(schema);
return type === JSONSchemaTypes.ARRAY;
}
function getSchemaType(schema) {
const type = schema.type;
if (!type) {
if (schema.const) {
return guessType(schema.const);
}
if (schema.enum) {
return schema.enum.length ? guessType(schema.enum[0]) : JSONSchemaTypes.STRING;
}
if (schema.properties || schema.additionalProperties) {
return JSONSchemaTypes.OBJECT;
}
return undefined;
}
else {
return type;
}
}
function guessType(value) {
if (Array.isArray(value)) {
return JSONSchemaTypes.ARRAY;
}
else if (typeof value === 'string') {
return JSONSchemaTypes.STRING;
}
else if (value == null) {
return JSONSchemaTypes.NULL;
}
else if (typeof value === 'boolean') {
return JSONSchemaTypes.BOOLEAN;
}
else if (!isNaN(value)) {
return JSONSchemaTypes.NULL;
}
else if (typeof value === 'object') {
return JSONSchemaTypes.OBJECT;
}
return JSONSchemaTypes.STRING;
}
function getWidgetName(schema) {
if (schema.ui) {
return typeof schema.ui === 'object' ? schema.ui.widget || null : typeof schema.ui === 'string' ? schema.ui : null;
}
else {
if (Array.isArray(schema.enum)) {
return 'select';
}
return null;
}
}
function setRequiredProperties(properties, schema) {
if (!schema.required || !Array.isArray(schema.required)) {
return;
}
schema.required.forEach(name => {
const control = properties[name];
if (control) {
const validators = control.validator ? [control.validator] : [];
validators.push(Validators.required);
control.setValidators(validators);
}
});
}
function getItemSchema(schema, index, value) {
if (Array.isArray(schema.items)) {
if (schema.items[index]) {
return {
default: value,
...schema.items[index]
};
}
else {
if (schema.additionalItems) {
return {
default: value,
...schema.additionalItems
};
}
else {
return {
default: value
};
}
}
}
else {
return {
default: value,
...schema.items
};
}
}
function getSchema(schema, root) {
if (schema && typeof schema.$ref === 'string') {
const def = getDefinition(root, schema.$ref);
return Object.assign(def, schema, { $ref: undefined });
}
else {
return schema || root;
}
}
function getDefinition(schema, ref) {
if (ref[0] !== '#') {
throw new Error(`Invalid $ref path ${ref}.`);
}
else {
let definition = schema;
const paths = ref.split('/').slice(1);
if (paths.length === 0) {
return {};
}
paths.forEach(ptr => {
if (ptr && definition[ptr]) {
definition = definition[ptr];
}
else {
throw new Error(`Could not find definition ${ref}.`);
}
});
return definition;
}
}
function isEmptyInputValue(value) {
return value == null || value.length === 0;
}
function isRequiredSchema(context) {
const parentSchema = getSchema(context.parent, context.root);
return (parentSchema &&
isSchemaObject(parentSchema) &&
parentSchema.required &&
Array.isArray(parentSchema.required) &&
parentSchema.required.indexOf(context.name) !== -1);
}
function getSchemaValidators(context) {
const schema = context.schema;
const validators = [];
if (isRequiredSchema(context)) {
validators.push(Validators.required);
}
if (schema.type === JSONSchemaTypes.NUMBER || schema.type === JSONSchemaTypes.INTEGER) {
if (typeof schema.maximum === 'number') {
validators.push(SchemaValidators.maximum(schema.maximum));
}
if (typeof schema.minimum === 'number') {
validators.push(SchemaValidators.minimum(schema.minimum));
}
if (typeof schema.exclusiveMaximum === 'number') {
validators.push(SchemaValidators.exclusiveMaximum(schema.exclusiveMaximum));
}
if (typeof schema.exclusiveMinimum === 'number') {
validators.push(SchemaValidators.exclusiveMinimum(schema.exclusiveMinimum));
}
if (typeof schema.multipleOf === 'number') {
validators.push(SchemaValidators.multipleOf(schema.multipleOf));
}
if (schema.type === JSONSchemaTypes.INTEGER) {
validators.push(SchemaValidators.integer);
}
}
if (schema.type === JSONSchemaTypes.STRING) {
if (typeof schema.minLength === 'number') {
validators.push(Validators.minLength(schema.minLength));
}
if (typeof schema.maxLength === 'number') {
validators.push(Validators.maxLength(schema.maxLength));
}
if (schema.pattern) {
validators.push(Validators.pattern(schema.pattern));
}
const formatKey = schema.format;
if (formatKey && formatKey === 'regex') {
validators.push(SchemaValidators.regex);
}
else {
if (formatKey && formats[formatKey]) {
validators.push(SchemaValidators.format(formatKey, formats[formatKey]));
}
else if (formatKey) {
console.warn(`unsupported format ${formatKey}`, schema);
}
}
}
if (Array.isArray(schema.enum) && schema.enum.length !== 0) {
validators.push(SchemaValidators.enum(schema.enum));
}
return validators;
}
// @dynamic
class SchemaValidators {
static multipleOf(multipleOf) {
return (control) => {
if (isEmptyInputValue(control.value) || isEmptyInputValue(multipleOf)) {
return null;
}
const value = parseFloat(control.value);
return !isNaN(value) && value % multipleOf !== 0 ? { multipleOf: { multipleOf, actual: control.value } } : null;
};
}
static maximum(maximum) {
return (control) => {
if (isEmptyInputValue(control.value) || isEmptyInputValue(maximum)) {
return null;
}
const value = parseFloat(control.value);
return !isNaN(value) && value > maximum ? { maximum: { maximum, actual: control.value } } : null;
};
}
static minimum(minimum) {
return (control) => {
if (isEmptyInputValue(control.value) || isEmptyInputValue(minimum)) {
return null;
}
const value = parseFloat(control.value);
return !isNaN(value) && value < minimum ? { minimum: { minimum, actual: control.value } } : null;
};
}
static exclusiveMinimum(exclusiveMinimum) {
return (control) => {
if (isEmptyInputValue(control.value) || isEmptyInputValue(exclusiveMinimum)) {
return null;
}
const value = parseFloat(control.value);
return !isNaN(value) && value <= exclusiveMinimum
? { exclusiveMinimum: { exclusiveMinimum, actual: control.value } }
: null;
};
}
static exclusiveMaximum(exclusiveMaximum) {
return (control) => {
if (isEmptyInputValue(control.value) || isEmptyInputValue(exclusiveMaximum)) {
return null;
}
const value = parseFloat(control.value);
return !isNaN(value) && value >= exclusiveMaximum
? { exclusiveMaximum: { exclusiveMaximum, actual: control.value } }
: null;
};
}
static integer(control) {
if (isEmptyInputValue(control.value)) {
return null;
}
return Number.isInteger(control.value) ? null : { integer: true };
}
static format(format, regex) {
return (control) => {
if (isEmptyInputValue(control.value)) {
return null;
}
const value = control.value;
return regex.test(value) ? null : { format: { requiredPattern: regex.toString(), actualValue: value, format } };
};
}
static enum(enumValues) {
return (control) => {
const value = control.value;
if (isEmptyInputValue(value)) {
return null;
}
return enumValues.some(e => e === value) ? null : { enum: { enum: enumValues, actualValue: value } };
};
}
static regex(control) {
if (isEmptyInputValue(control.value)) {
return null;
}
try {
new RegExp(control.value);
return null;
}
catch {
return { format: { actualValue: control.value, format: 'regex' } };
}
}
}
function updateSchemaFactor(schemaContext, subject) {
return (schemaOrFun) => {
if (typeof schemaOrFun === 'function') {
const newSchema = schemaOrFun({ ...schemaContext.schema });
subject.next(newSchema);
}
else {
subject.next(schemaOrFun);
}
};
}
class AbstractSchemaControl extends AbstractControl {
}
class SchemaFormControl extends UntypedFormControl {
constructor() {
super(...arguments);
this.onUpdateSchema$ = new Subject();
}
get updateSchema() {
return updateSchemaFactor(this.schemaContext, this.onUpdateSchema$);
}
get(path) {
return super.get(path);
}
setValue(value, options) {
super.setValue(value, options);
}
}
class SchemaFormGroup extends UntypedFormGroup {
constructor() {
super(...arguments);
this.onUpdateSchema$ = new Subject();
}
get updateSchema() {
return updateSchemaFactor(this.schemaContext, this.onUpdateSchema$);
}
get(path) {
return super.get(path);
}
}
class SchemaFormArray extends UntypedFormArray {
constructor() {
super(...arguments);
this.onUpdateSchema$ = new Subject();
this.onControlsChange = new Subject();
}
get updateSchema() {
return updateSchemaFactor(this.schemaContext, this.onUpdateSchema$);
}
get(path) {
return super.get(path);
}
setValue(value, options) {
this.clear();
const schema = this.schemaContext.schema;
value.forEach((newValue, index) => {
const itemSchema = this.schemaContext.child(getItemSchema(schema, index), index);
const control = this._builder.createControl(itemSchema, newValue);
this.push(control);
});
this.updateValueAndValidity(options);
this.onControlsChange.next();
}
}
class SchemaContext {
constructor(schema) {
this.schema = schema;
this.name = '__root__';
this.root = schema;
}
child(schema, name) {
const schemaContext = new SchemaContext(schema);
schemaContext.root = this.root;
schemaContext.parent = this.schema;
schemaContext.name = name;
return schemaContext;
}
}
class SchemaFormBuilder {
build(schema, value) {
const context = new SchemaContext(schema);
return this.object(context, value);
}
object(context, value) {
const group = this.reduceControls(context, value);
const control = new SchemaFormGroup(group);
control.schemaContext = context;
return control;
}
array(context, value) {
const schema = context.schema;
let control;
if (!Array.isArray(schema.default) && !Array.isArray(value)) {
control = new SchemaFormArray([]);
}
else {
const controls = [];
const formValues = Array.isArray(value) ? value : Array.isArray(schema.default) ? schema.default : [];
formValues.forEach((item, index) => {
controls[index] = this.createControl(context.child(getItemSchema(schema, index, item), index), formValues[index]);
});
control = new SchemaFormArray(controls);
}
control.schemaContext = context;
control._builder = this;
return control;
}
control(context, value) {
const formValue = typeof value === 'undefined' ? context.schema.default : value;
const control = new SchemaFormControl(formValue, getSchemaValidators(context));
control.schemaContext = context;
return control;
}
createControl(context, value) {
const schema = getSchema(context.schema, context.root);
if (isSchemaObject(schema)) {
return this.object(context, value);
}
else if (isSchemaArray(schema)) {
return this.array(context, value);
}
else {
return this.control(context, value);
}
}
reduceControls(context, value) {
const controls = {};
const normalizeSchema = getSchema(context.schema, context.root);
if (normalizeSchema.properties !== undefined) {
Object.keys(normalizeSchema.properties).forEach(key => {
controls[key] = this.createControl(context.child(normalizeSchema.properties[key], key), value ? value[key] : undefined);
});
}
return controls;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormBuilder, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormBuilder, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormBuilder, decorators: [{
type: Injectable,
args: [{
providedIn: 'root'
}]
}] });
const zhCH = {
// TODO
additionalItems: '不允许超过 {{n}} 个元素',
// TODO
additionalProperties: '不允许有额外的属性',
// TODO
anyOf: '数据应为 anyOf 所指定的其中一个',
// TODO
dependencies: '应当拥有属性{{=e.params.property}}的依赖属性{{=e.params.deps}}',
// TODO
enum: '应当是预设定的枚举值之一',
// TODO
format: '应当匹配格式 "{{format}}"',
maximum: '不能大于最大值 {{maximum}}',
minimum: '不能小于最小值 {{minimum}}',
exclusiveMinimum: '不能小于等于 {{exclusiveMinimum}}',
exclusiveMaximum: '不能大于等于 {{exclusiveMaximum}}',
integer: '应为整数值',
// TODO
maxItems: '不应多于 {{n}} 个项',
// TODO
minItems: '不应少于 {{n}} 个项',
maxlength: '不应超过 {{requiredLength}} 个字符',
minlength: '不应低于 {{requiredLength}} 个字符',
// TODO
maxProperties: '不应多于 {{n}} 个属性',
// TODO
minProperties: '不应少于 {{n}} 个属性',
multipleOf: '应当是 {{multipleOf}} 的整数倍',
// TODO
oneOf: '只能匹配一个 "oneOf" 中的 schema',
// TODO
pattern: '应当匹配模式 "{{requiredPattern}}"',
required: `必填项`,
// TODO
uniqueItems: `第 {{j}} 项与第 {{i}} 不应重复`,
// TODO
propertyNames: `属性名 {{propertyName}} 无效`,
// TODO
const: `应当等于常量 {{const}}`,
// TODO
contains: `应当包含一个有效项`
};
const NZ_SCHEMA_ERROR_MESSAGES = new InjectionToken('nz-schema-error-messages', {
providedIn: 'root',
factory: NZ_SCHEMA_DEFAULT_ERROR_MESSAGES_FACTORY
});
function NZ_SCHEMA_DEFAULT_ERROR_MESSAGES_FACTORY() {
return zhCH;
}
class NzSchemaErrorMessageService {
constructor() {
this.errorMessages = inject(NZ_SCHEMA_ERROR_MESSAGES, { optional: true });
}
getErrorMessage(form) {
const errors = form.errors;
if (!errors || Object.keys(errors).length === 0) {
return null;
}
const schema = getSchema(form.schemaContext.schema, form.schemaContext.root);
const schemaMessages = typeof schema.ui === 'object' ? schema.ui.messages || {} : {};
const messages = { ...(this.errorMessages || zhCH), ...schemaMessages };
const errorKey = Object.keys(errors)[0];
if (!messages.hasOwnProperty(errorKey)) {
// TODO
console.warn(`error type not found: ${errorKey}`, errors);
return null;
}
const error = errors[errorKey];
const message = messages[errorKey];
let errorMessage = '';
if (typeof error === 'object') {
if (typeof message === 'function') {
return message(error, form);
}
else {
errorMessage = message;
Object.keys(error).forEach(key => {
errorMessage = errorMessage.replace(new RegExp(`{{${key}}}`, 'g'), `${error[key]}`);
});
return errorMessage;
}
}
else {
// @ts-ignore
return message.toString();
}
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: NzSchemaErrorMessageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: NzSchemaErrorMessageService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: NzSchemaErrorMessageService, decorators: [{
type: Injectable,
args: [{
providedIn: 'root'
}]
}] });
const SCHEMA = new InjectionToken('NzSchemaToken');
const SCHEMA_FORM = new InjectionToken('NzSchemaFormToken');
class BaseField {
constructor() {
this.required = false;
this.errorMessageService = inject(NzSchemaErrorMessageService);
this.cdr = inject(ChangeDetectorRef);
}
get schema() {
return this.schemaForm.schemaContext.schema;
}
get userInterfaceSchema() {
return typeof this.schema.ui === 'object' ? this.schema.ui : {};
}
get widgetOptions() {
return this.userInterfaceSchema.options || {};
}
get ngClass() {
return this.userInterfaceSchema.klass || '';
}
get ngStyle() {
return this.userInterfaceSchema.style || {};
}
get size() {
return this.userInterfaceSchema.size || 'default';
}
get placeholder() {
return this.userInterfaceSchema.placeholder || '';
}
get type() {
return this.userInterfaceSchema.type;
}
get widgetData() {
return this.userInterfaceSchema.widgetData;
}
get disabled() {
return !!this.userInterfaceSchema.disabled;
}
get enum() {
return this.schema.enum || [];
}
get label() {
return this.schema.title || '';
}
get description() {
return this.schema.description || '';
}
// abstract update(): void;
init() {
this.required = isRequiredSchema(this.schemaForm.schemaContext);
if (this.disabled) {
this.schemaForm.disable({ emitEvent: false });
}
this.schemaForm.statusChanges.subscribe(() => {
this.errorMessage = this.errorMessageService.getErrorMessage(this.schemaForm) || undefined;
});
this.schemaForm.onUpdateSchema$.subscribe(schema => {
this.schemaForm.schemaContext.schema = schema;
this.cdr.markForCheck();
});
}
setInputElementOptions(firstChange = false) {
if (!this.inputElement) {
console.warn('inputElement not found');
return;
}
const keys = Object.keys(this.widgetOptions);
const changes = {};
keys.forEach(key => {
if (this.inputElement[key] instanceof EventEmitter && typeof this.widgetOptions[key] === 'function') {
const event = this.inputElement[key];
const fun = this.widgetOptions[key];
event.subscribe(data => {
fun(data, this.schemaForm);
});
}
else if (this.inputElement[key] !== this.widgetOptions[key]) {
changes[key] = new SimpleChange(this.inputElement[key], this.widgetOptions[key], firstChange);
this.inputElement[key] = this.widgetOptions[key];
}
});
if (Object.keys(changes).length) {
if (typeof this.inputElement.ngOnChanges === 'function') {
this.inputElement.ngOnChanges(changes);
}
this.cdr.markForCheck();
}
}
ngAfterViewInit() {
this.setInputElementOptions(true);
}
ngOnInit() {
this.init();
}
ngOnDestroy() {
this.schemaForm.onUpdateSchema$.complete();
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: BaseField, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.2", type: BaseField, isStandalone: true, viewQueries: [{ propertyName: "inputElement", first: true, predicate: ["inputElement"], descendants: true }], ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: BaseField, decorators: [{
type: Directive
}], propDecorators: { inputElement: [{
type: ViewChild,
args: ['inputElement', { static: false }]
}] } });
class BooleanFieldComponent extends BaseField {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: BooleanFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.2", type: BooleanFieldComponent, isStandalone: true, selector: "nz-boolean-field", inputs: { schemaForm: "schemaForm" }, usesInheritance: true, ngImport: i0, template: "<nz-form-item>\n @if (label || required) {\n <nz-form-label [nzRequired]=\"required\">\n {{ label }}\n </nz-form-label>\n }\n <nz-form-control [nzExtra]=\"description\" [nzErrorTip]=\"errorMessage\">\n <nz-switch\n #inputElement\n [formControl]=\"schemaForm\"\n [class]=\"ngClass\"\n [style]=\"ngStyle\"\n ></nz-switch>\n </nz-form-control>\n</nz-form-item>\n", dependencies: [{ kind: "ngmodule", type: NzFormModule }, { kind: "directive", type: i1.NzColDirective, selector: "[nz-col],nz-col,nz-form-control,nz-form-label", inputs: ["nzFlex", "nzSpan", "nzOrder", "nzOffset", "nzPush", "nzPull", "nzXs", "nzSm", "nzMd", "nzLg", "nzXl", "nzXXl"], exportAs: ["nzCol"] }, { kind: "directive", type: i1.NzRowDirective, selector: "[nz-row],nz-row,nz-form-item", inputs: ["nzAlign", "nzJustify", "nzGutter"], exportAs: ["nzRow"] }, { kind: "component", type: i2.NzFormItemComponent, selector: "nz-form-item", exportAs: ["nzFormItem"] }, { kind: "component", type: i2.NzFormLabelComponent, selector: "nz-form-label", inputs: ["nzFor", "nzRequired", "nzNoColon", "nzTooltipTitle", "nzTooltipIcon", "nzLabelAlign", "nzLabelWrap"], exportAs: ["nzFormLabel"] }, { kind: "component", type: i2.NzFormControlComponent, selector: "nz-form-control", inputs: ["nzSuccessTip", "nzWarningTip", "nzErrorTip", "nzValidatingTip", "nzExtra", "nzAutoTips", "nzDisableAutoTips", "nzHasFeedback", "nzValidateStatus"], exportAs: ["nzFormControl"] }, { kind: "ngmodule", type: NzSwitchModule }, { kind: "component", type: i3.NzSwitchComponent, selector: "nz-switch", inputs: ["nzLoading", "nzDisabled", "nzControl", "nzCheckedChildren", "nzUnCheckedChildren", "nzSize", "nzId"], exportAs: ["nzSwitch"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: BooleanFieldComponent, decorators: [{
type: Component,
args: [{ selector: 'nz-boolean-field', imports: [NzFormModule, NzSwitchModule, ReactiveFormsModule], template: "<nz-form-item>\n @if (label || required) {\n <nz-form-label [nzRequired]=\"required\">\n {{ label }}\n </nz-form-label>\n }\n <nz-form-control [nzExtra]=\"description\" [nzErrorTip]=\"errorMessage\">\n <nz-switch\n #inputElement\n [formControl]=\"schemaForm\"\n [class]=\"ngClass\"\n [style]=\"ngStyle\"\n ></nz-switch>\n </nz-form-control>\n</nz-form-item>\n" }]
}], propDecorators: { schemaForm: [{
type: Input
}] } });
class NumberFieldComponent extends BaseField {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: NumberFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.2", type: NumberFieldComponent, isStandalone: true, selector: "nz-number-field", inputs: { schemaForm: "schemaForm" }, usesInheritance: true, ngImport: i0, template: "<nz-form-item>\n @if (label || required) {\n <nz-form-label [nzRequired]=\"required\">\n {{ label }}\n </nz-form-label>\n }\n <nz-form-control [nzExtra]=\"description\" [nzErrorTip]=\"errorMessage\">\n <nz-input-number\n #inputElement\n [formControl]=\"schemaForm\"\n [nzPlaceHolder]=\"placeholder\"\n [nzSize]=\"size\"\n [class]=\"ngClass\"\n [style]=\"ngStyle\"\n ></nz-input-number>\n </nz-form-control>\n</nz-form-item>\n", dependencies: [{ kind: "ngmodule", type: NzFormModule }, { kind: "directive", type: i1.NzColDirective, selector: "[nz-col],nz-col,nz-form-control,nz-form-label", inputs: ["nzFlex", "nzSpan", "nzOrder", "nzOffset", "nzPush", "nzPull", "nzXs", "nzSm", "nzMd", "nzLg", "nzXl", "nzXXl"], exportAs: ["nzCol"] }, { kind: "directive", type: i1.NzRowDirective, selector: "[nz-row],nz-row,nz-form-item", inputs: ["nzAlign", "nzJustify", "nzGutter"], exportAs: ["nzRow"] }, { kind: "component", type: i2.NzFormItemComponent, selector: "nz-form-item", exportAs: ["nzFormItem"] }, { kind: "component", type: i2.NzFormLabelComponent, selector: "nz-form-label", inputs: ["nzFor", "nzRequired", "nzNoColon", "nzTooltipTitle", "nzTooltipIcon", "nzLabelAlign", "nzLabelWrap"], exportAs: ["nzFormLabel"] }, { kind: "component", type: i2.NzFormControlComponent, selector: "nz-form-control", inputs: ["nzSuccessTip", "nzWarningTip", "nzErrorTip", "nzValidatingTip", "nzExtra", "nzAutoTips", "nzDisableAutoTips", "nzHasFeedback", "nzValidateStatus"], exportAs: ["nzFormControl"] }, { kind: "ngmodule", type: NzInputNumberLegacyModule }, { kind: "component", type: i3$1.NzInputNumberLegacyComponent, selector: "nz-input-number", inputs: ["nzSize", "nzMin", "nzMax", "nzParser", "nzPrecision", "nzPrecisionMode", "nzPlaceHolder", "nzStatus", "nzStep", "nzInputMode", "nzId", "nzDisabled", "nzReadOnly", "nzAutoFocus", "nzBorderless", "nzFormatter"], outputs: ["nzBlur", "nzFocus"], exportAs: ["nzInputNumber"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: NumberFieldComponent, decorators: [{
type: Component,
args: [{ selector: 'nz-number-field', imports: [NzFormModule, NzInputNumberLegacyModule, ReactiveFormsModule], template: "<nz-form-item>\n @if (label || required) {\n <nz-form-label [nzRequired]=\"required\">\n {{ label }}\n </nz-form-label>\n }\n <nz-form-control [nzExtra]=\"description\" [nzErrorTip]=\"errorMessage\">\n <nz-input-number\n #inputElement\n [formControl]=\"schemaForm\"\n [nzPlaceHolder]=\"placeholder\"\n [nzSize]=\"size\"\n [class]=\"ngClass\"\n [style]=\"ngStyle\"\n ></nz-input-number>\n </nz-form-control>\n</nz-form-item>\n" }]
}], propDecorators: { schemaForm: [{
type: Input
}] } });
class StringFieldComponent extends BaseField {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: StringFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.2", type: StringFieldComponent, isStandalone: true, selector: "nz-string-field", inputs: { schemaForm: "schemaForm" }, usesInheritance: true, ngImport: i0, template: "<nz-form-item>\n @if (label || required) {\n <nz-form-label [nzRequired]=\"required\">\n {{ label }}\n </nz-form-label>\n }\n <nz-form-control [nzExtra]=\"description\" [nzErrorTip]=\"errorMessage\">\n <input\n nz-input\n #inputElement\n [formControl]=\"schemaForm\"\n [class]=\"ngClass\"\n [style]=\"ngStyle\"\n [nzSize]=\"size\"\n [type]=\"type\"\n [placeholder]=\"placeholder\"\n />\n </nz-form-control>\n</nz-form-item>\n", dependencies: [{ kind: "ngmodule", type: NzFormModule }, { kind: "directive", type: i1.NzColDirective, selector: "[nz-col],nz-col,nz-form-control,nz-form-label", inputs: ["nzFlex", "nzSpan", "nzOrder", "nzOffset", "nzPush", "nzPull", "nzXs", "nzSm", "nzMd", "nzLg", "nzXl", "nzXXl"], exportAs: ["nzCol"] }, { kind: "directive", type: i1.NzRowDirective, selector: "[nz-row],nz-row,nz-form-item", inputs: ["nzAlign", "nzJustify", "nzGutter"], exportAs: ["nzRow"] }, { kind: "component", type: i2.NzFormItemComponent, selector: "nz-form-item", exportAs: ["nzFormItem"] }, { kind: "component", type: i2.NzFormLabelComponent, selector: "nz-form-label", inputs: ["nzFor", "nzRequired", "nzNoColon", "nzTooltipTitle", "nzTooltipIcon", "nzLabelAlign", "nzLabelWrap"], exportAs: ["nzFormLabel"] }, { kind: "component", type: i2.NzFormControlComponent, selector: "nz-form-control", inputs: ["nzSuccessTip", "nzWarningTip", "nzErrorTip", "nzValidatingTip", "nzExtra", "nzAutoTips", "nzDisableAutoTips", "nzHasFeedback", "nzValidateStatus"], exportAs: ["nzFormControl"] }, { kind: "ngmodule", type: NzInputModule }, { kind: "directive", type: i3$2.NzInputDirective, selector: "input[nz-input],textarea[nz-input]", inputs: ["nzBorderless", "nzVariant", "nzSize", "nzStepperless", "nzStatus", "disabled"], exportAs: ["nzInput"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: StringFieldComponent, decorators: [{
type: Component,
args: [{ selector: 'nz-string-field', imports: [NzFormModule, NzInputModule, ReactiveFormsModule], template: "<nz-form-item>\n @if (label || required) {\n <nz-form-label [nzRequired]=\"required\">\n {{ label }}\n </nz-form-label>\n }\n <nz-form-control [nzExtra]=\"description\" [nzErrorTip]=\"errorMessage\">\n <input\n nz-input\n #inputElement\n [formControl]=\"schemaForm\"\n [class]=\"ngClass\"\n [style]=\"ngStyle\"\n [nzSize]=\"size\"\n [type]=\"type\"\n [placeholder]=\"placeholder\"\n />\n </nz-form-control>\n</nz-form-item>\n" }]
}], propDecorators: { schemaForm: [{
type: Input
}] } });
class SchemaFormAutocompleteComponent extends BaseField {
constructor() {
super(...arguments);
this.schemaForm = inject(SCHEMA_FORM);
this.options = [];
}
get widgetOptions() {
return super.widgetOptions;
}
setOption() {
const widgetData = this.widgetData;
if (Array.isArray(widgetData)) {
if (widgetData.every(e => typeof e === 'object' && e.hasOwnProperty('value') && e.hasOwnProperty('label'))) {
this.options = widgetData;
}
else {
console.warn(`property widgetData is invalid`, widgetData);
}
return;
}
if (this.enum) {
this.options = this.enum.map(e => ({ value: e, label: `${e}` }));
}
}
ngOnInit() {
super.ngOnInit();
this.setOption();
this.schemaForm.onUpdateSchema$.subscribe(() => {
this.setOption();
this.cdr.markForCheck();
});
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormAutocompleteComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.2", type: SchemaFormAutocompleteComponent, isStandalone: true, selector: "nz-schema-form-autocomplete", usesInheritance: true, ngImport: i0, template: "<nz-form-item>\n @if (label || required) {\n <nz-form-label [nzRequired]=\"required\">{{ label }}</nz-form-label>\n }\n <nz-form-control [nzErrorTip]=\"errorMessage\" [nzExtra]=\"description\">\n <input\n #inputElement\n nz-input\n autocomplete=\"on\"\n [placeholder]=\"placeholder\"\n [type]=\"type\"\n [nzSize]=\"size\"\n [formControl]=\"schemaForm\"\n [nzAutocomplete]=\"auto\"\n />\n <nz-autocomplete\n #auto\n [nzBackfill]=\"widgetOptions.backfill\"\n [nzWidth]=\"widgetOptions.width\"\n [nzOverlayStyle]=\"widgetOptions.overlayStyle || {}\"\n [nzOverlayClassName]=\"widgetOptions.overlayClassName || ''\"\n [nzDefaultActiveFirstOption]=\"widgetOptions.defaultActiveFirstOption\"\n >\n @for (option of options; track option) {\n <nz-auto-option [nzValue]=\"option.value\">\n {{ option.label }}\n </nz-auto-option>\n }\n </nz-autocomplete>\n </nz-form-control>\n</nz-form-item>\n", dependencies: [{ kind: "ngmodule", type: NzFormModule }, { kind: "directive", type: i1.NzColDirective, selector: "[nz-col],nz-col,nz-form-control,nz-form-label", inputs: ["nzFlex", "nzSpan", "nzOrder", "nzOffset", "nzPush", "nzPull", "nzXs", "nzSm", "nzMd", "nzLg", "nzXl", "nzXXl"], exportAs: ["nzCol"] }, { kind: "directive", type: i1.NzRowDirective, selector: "[nz-row],nz-row,nz-form-item", inputs: ["nzAlign", "nzJustify", "nzGutter"], exportAs: ["nzRow"] }, { kind: "component", type: i2.NzFormItemComponent, selector: "nz-form-item", exportAs: ["nzFormItem"] }, { kind: "component", type: i2.NzFormLabelComponent, selector: "nz-form-label", inputs: ["nzFor", "nzRequired", "nzNoColon", "nzTooltipTitle", "nzTooltipIcon", "nzLabelAlign", "nzLabelWrap"], exportAs: ["nzFormLabel"] }, { kind: "component", type: i2.NzFormControlComponent, selector: "nz-form-control", inputs: ["nzSuccessTip", "nzWarningTip", "nzErrorTip", "nzValidatingTip", "nzExtra", "nzAutoTips", "nzDisableAutoTips", "nzHasFeedback", "nzValidateStatus"], exportAs: ["nzFormControl"] }, { kind: "ngmodule", type: NzInputModule }, { kind: "directive", type: i3$2.NzInputDirective, selector: "input[nz-input],textarea[nz-input]", inputs: ["nzBorderless", "nzVariant", "nzSize", "nzStepperless", "nzStatus", "disabled"], exportAs: ["nzInput"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: NzAutocompleteModule }, { kind: "component", type: i5.NzAutocompleteComponent, selector: "nz-autocomplete", inputs: ["nzWidth", "nzOverlayClassName", "nzOverlayStyle", "nzDefaultActiveFirstOption", "nzBackfill", "compareWith", "nzDataSource"], outputs: ["selectionChange"], exportAs: ["nzAutocomplete"] }, { kind: "component", type: i5.NzAutocompleteOptionComponent, selector: "nz-auto-option", inputs: ["nzValue", "nzLabel", "nzDisabled"], outputs: ["selectionChange", "mouseEntered"], exportAs: ["nzAutoOption"] }, { kind: "directive", type: i5.NzAutocompleteTriggerDirective, selector: "input[nzAutocomplete], textarea[nzAutocomplete]", inputs: ["nzAutocomplete"], exportAs: ["nzAutocompleteTrigger"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormAutocompleteComponent, decorators: [{
type: Component,
args: [{ selector: 'nz-schema-form-autocomplete', changeDetection: ChangeDetectionStrategy.OnPush, imports: [NzFormModule, NzInputModule, ReactiveFormsModule, NzAutocompleteModule], template: "<nz-form-item>\n @if (label || required) {\n <nz-form-label [nzRequired]=\"required\">{{ label }}</nz-form-label>\n }\n <nz-form-control [nzErrorTip]=\"errorMessage\" [nzExtra]=\"description\">\n <input\n #inputElement\n nz-input\n autocomplete=\"on\"\n [placeholder]=\"placeholder\"\n [type]=\"type\"\n [nzSize]=\"size\"\n [formControl]=\"schemaForm\"\n [nzAutocomplete]=\"auto\"\n />\n <nz-autocomplete\n #auto\n [nzBackfill]=\"widgetOptions.backfill\"\n [nzWidth]=\"widgetOptions.width\"\n [nzOverlayStyle]=\"widgetOptions.overlayStyle || {}\"\n [nzOverlayClassName]=\"widgetOptions.overlayClassName || ''\"\n [nzDefaultActiveFirstOption]=\"widgetOptions.defaultActiveFirstOption\"\n >\n @for (option of options; track option) {\n <nz-auto-option [nzValue]=\"option.value\">\n {{ option.label }}\n </nz-auto-option>\n }\n </nz-autocomplete>\n </nz-form-control>\n</nz-form-item>\n" }]
}] });
class SchemaFormCascaderComponent extends BaseField {
constructor() {
super(...arguments);
this.schemaForm = inject(SCHEMA_FORM);
}
get widgetData() {
return super.widgetData;
}
get widgetOptions() {
return super.widgetOptions;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormCascaderComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.2", type: SchemaFormCascaderComponent, isStandalone: true, selector: "nz-schema-form-cascader", usesInheritance: true, ngImport: i0, template: "<nz-form-item>\n @if (label || required) {\n <nz-form-label [nzRequired]=\"required\">{{ label }}</nz-form-label>\n }\n <nz-form-control [nzErrorTip]=\"errorMessage\" [nzExtra]=\"description\">\n <nz-cascader\n #inputElement\n [nzOptions]=\"widgetData\"\n [formControl]=\"schemaForm\"\n [class]=\"ngClass\"\n [style]=\"ngStyle\"\n [nzSize]=\"size\"\n [nzPlaceHolder]=\"placeholder\"\n ></nz-cascader>\n </nz-form-control>\n</nz-form-item>\n", dependencies: [{ kind: "ngmodule", type: NzFormModule }, { kind: "directive", type: i1.NzColDirective, selector: "[nz-col],nz-col,nz-form-control,nz-form-label", inputs: ["nzFlex", "nzSpan", "nzOrder", "nzOffset", "nzPush", "nzPull", "nzXs", "nzSm", "nzMd", "nzLg", "nzXl", "nzXXl"], exportAs: ["nzCol"] }, { kind: "directive", type: i1.NzRowDirective, selector: "[nz-row],nz-row,nz-form-item", inputs: ["nzAlign", "nzJustify", "nzGutter"], exportAs: ["nzRow"] }, { kind: "component", type: i2.NzFormItemComponent, selector: "nz-form-item", exportAs: ["nzFormItem"] }, { kind: "component", type: i2.NzFormLabelComponent, selector: "nz-form-label", inputs: ["nzFor", "nzRequired", "nzNoColon", "nzTooltipTitle", "nzTooltipIcon", "nzLabelAlign", "nzLabelWrap"], exportAs: ["nzFormLabel"] }, { kind: "component", type: i2.NzFormControlComponent, selector: "nz-form-control", inputs: ["nzSuccessTip", "nzWarningTip", "nzErrorTip", "nzValidatingTip", "nzExtra", "nzAutoTips", "nzDisableAutoTips", "nzHasFeedback", "nzValidateStatus"], exportAs: ["nzFormControl"] }, { kind: "ngmodule", type: NzCascaderModule }, { kind: "component", type: i3$3.NzCascaderComponent, selector: "nz-cascader, [nz-cascader]", inputs: ["nzOptionRender", "nzShowInput", "nzShowArrow", "nzAllowClear", "nzAutoFocus", "nzChangeOnSelect", "nzDisabled", "nzColumnClassName", "nzExpandTrigger", "nzValueProperty", "nzLabelProperty", "nzLabelRender", "nzVariant", "nzNotFoundContent", "nzSize", "nzBackdrop", "nzShowSearch", "nzPlaceHolder", "nzMenuClassName", "nzMenuStyle", "nzMouseLeaveDelay", "nzMouseEnterDelay", "nzStatus", "nzMultiple", "nzMaxTagCount", "nzPlacement", "nzTriggerAction", "nzChangeOn", "nzLoadData", "nzDisplayWith", "nzSuffixIcon", "nzExpandIcon", "nzOptions"], outputs: ["nzVisibleChange", "nzSelectionChange", "nzRemoved", "nzClear"], exportAs: ["nzCascader"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormCascaderComponent, decorators: [{
type: Component,
args: [{ selector: 'nz-schema-form-cascader', changeDetection: ChangeDetectionStrategy.OnPush, imports: [NzFormModule, NzCascaderModule, ReactiveFormsModule], template: "<nz-form-item>\n @if (label || required) {\n <nz-form-label [nzRequired]=\"required\">{{ label }}</nz-form-label>\n }\n <nz-form-control [nzErrorTip]=\"errorMessage\" [nzExtra]=\"description\">\n <nz-cascader\n #inputElement\n [nzOptions]=\"widgetData\"\n [formControl]=\"schemaForm\"\n [class]=\"ngClass\"\n [style]=\"ngStyle\"\n [nzSize]=\"size\"\n [nzPlaceHolder]=\"placeholder\"\n ></nz-cascader>\n </nz-form-control>\n</nz-form-item>\n" }]
}] });
class SchemaFormCheckboxComponent extends BaseField {
constructor() {
super(...arguments);
this.schemaForm = inject(SCHEMA_FORM);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormCheckboxComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.2", type: SchemaFormCheckboxComponent, isStandalone: true, selector: "nz-schema-form-checkbox", usesInheritance: true, ngImport: i0, template: "<nz-form-item>\n <nz-form-control [nzErrorTip]=\"errorMessage\" [nzExtra]=\"description\">\n <span [class.ant-form-item-required]=\"required\">\n \n <label nz-checkbox [formControl]=\"schemaForm\">\n {{ label }}\n </label>\n </span>\n </nz-form-control>\n</nz-form-item>\n", dependencies: [{ kind: "ngmodule", type: NzFormModule }, { kind: "directive", type: i1.NzColDirective, selector: "[nz-col],nz-col,nz-form-control,nz-form-label", inputs: ["nzFlex", "nzSpan", "nzOrder", "nzOffset", "nzPush", "nzPull", "nzXs", "nzSm", "nzMd", "nzLg", "nzXl", "nzXXl"], exportAs: ["nzCol"] }, { kind: "directive", type: i1.NzRowDirective, selector: "[nz-row],nz-row,nz-form-item", inputs: ["nzAlign", "nzJustify", "nzGutter"], exportAs: ["nzRow"] }, { kind: "component", type: i2.NzFormItemComponent, selector: "nz-form-item", exportAs: ["nzFormItem"] }, { kind: "component", type: i2.NzFormControlComponent, selector: "nz-form-control", inputs: ["nzSuccessTip", "nzWarningTip", "nzErrorTip", "nzValidatingTip", "nzExtra", "nzAutoTips", "nzDisableAutoTips", "nzHasFeedback", "nzValidateStatus"], exportAs: ["nzFormControl"] }, { kind: "ngmodule", type: NzCheckboxModule }, { kind: "component", type: i3$4.NzCheckboxComponent, selector: "[nz-checkbox]", inputs: ["nzValue", "nzAutoFocus", "nzDisabled", "nzIndeterminate", "nzChecked", "nzId", "nzName"], outputs: ["nzCheckedChange"], exportAs: ["nzCheckbox"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormCheckboxComponent, decorators: [{
type: Component,
args: [{ selector: 'nz-schema-form-checkbox', changeDetection: ChangeDetectionStrategy.OnPush, imports: [NzFormModule, NzCheckboxModule, ReactiveFormsModule], template: "<nz-form-item>\n <nz-form-control [nzErrorTip]=\"errorMessage\" [nzExtra]=\"description\">\n <span [class.ant-form-item-required]=\"required\">\n \n <label nz-checkbox [formControl]=\"schemaForm\">\n {{ label }}\n </label>\n </span>\n </nz-form-control>\n</nz-form-item>\n" }]
}] });
class SchemaFormDatePickerComponent extends BaseField {
constructor() {
super(...arguments);
this.schemaForm = inject(SCHEMA_FORM);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormDatePickerComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.2", type: SchemaFormDatePickerComponent, isStandalone: true, selector: "nz-schema-form-date-picker", usesInheritance: true, ngImport: i0, template: "<nz-form-item>\n @if (label || required) {\n <nz-form-label [nzRequired]=\"required\">{{ label }}</nz-form-label>\n }\n <nz-form-control [nzErrorTip]=\"errorMessage\" [nzExtra]=\"description\">\n <nz-date-picker\n #inputElement\n [formControl]=\"schemaForm\"\n [class]=\"ngClass\"\n [style]=\"ngStyle\"\n [nzSize]=\"size\"\n [nzPlaceHolder]=\"placeholder\"\n ></nz-date-picker>\n </nz-form-control>\n</nz-form-item>\n", dependencies: [{ kind: "ngmodule", type: NzFormModule }, { kind: "directive", type: i1.NzColDirective, selector: "[nz-col],nz-col,nz-form-control,nz-form-label", inputs: ["nzFlex", "nzSpan", "nzOrder", "nzOffset", "nzPush", "nzPull", "nzXs", "nzSm", "nzMd", "nzLg", "nzXl", "nzXXl"], exportAs: ["nzCol"] }, { kind: "directive", type: i1.NzRowDirective, selector: "[nz-row],nz-row,nz-form-item", inputs: ["nzAlign", "nzJustify", "nzGutter"], exportAs: ["nzRow"] }, { kind: "component", type: i2.NzFormItemComponent, selector: "nz-form-item", exportAs: ["nzFormItem"] }, { kind: "component", type: i2.NzFormLabelComponent, selector: "nz-form-label", inputs: ["nzFor", "nzRequired", "nzNoColon", "nzTooltipTitle", "nzTooltipIcon", "nzLabelAlign", "nzLabelWrap"], exportAs: ["nzFormLabel"] }, { kind: "component", type: i2.NzFormControlComponent, selector: "nz-form-control", inputs: ["nzSuccessTip", "nzWarningTip", "nzErrorTip", "nzValidatingTip", "nzExtra", "nzAutoTips", "nzDisableAutoTips", "nzHasFeedback", "nzValidateStatus"], exportAs: ["nzFormControl"] }, { kind: "ngmodule", type: NzDatePickerModule }, { kind: "component", type: i3$5.NzDatePickerComponent, selector: "nz-date-picker,nz-week-picker,nz-month-picker,nz-quarter-picker,nz-year-picker,nz-range-picker", inputs: ["nzAllowClear", "nzAutoFocus", "nzDisabled", "nzBorderless", "nzInputReadOnly", "nzInline", "nzOpen", "nzDisabledDate", "nzLocale", "nzPlaceHolder", "nzPopupStyle", "nzDropdownClassName", "nzSize", "nzStatus", "nzFormat", "nzVariant", "nzDateRender", "nzDisabledTime", "nzRenderExtraFooter", "nzShowToday", "nzMode", "nzShowNow", "nzRanges", "nzDefaultPickerValue", "nzSeparator", "nzSuffixIcon", "nzBackdrop", "nzId", "nzPlacement", "nzShowWeekNumber", "nzShowTime"], outputs: ["nzOnPanelChange", "nzOnCalendarChange", "nzOnOk", "nzOnOpenChange"], exportAs: ["nzDatePicker"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormDatePickerComponent, decorators: [{
type: Component,
args: [{ selector: 'nz-schema-form-date-picker', changeDetection: ChangeDetectionStrategy.OnPush, imports: [NzFormModule, NzDatePickerModule, ReactiveFormsModule], template: "<nz-form-item>\n @if (label || required) {\n <nz-form-label [nzRequired]=\"required\">{{ label }}</nz-form-label>\n }\n <nz-form-control [nzErrorTip]=\"errorMessage\" [nzExtra]=\"description\">\n <nz-date-picker\n #inputElement\n [formControl]=\"schemaForm\"\n [class]=\"ngClass\"\n [style]=\"ngStyle\"\n [nzSize]=\"size\"\n [nzPlaceHolder]=\"placeholder\"\n ></nz-date-picker>\n </nz-form-control>\n</nz-form-item>\n" }]
}] });
class SchemaFormMentionComponent extends BaseField {
constructor() {
super(...arguments);
this.schemaForm = inject(SCHEMA_FORM);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormMentionComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.2", type: SchemaFormMentionComponent, isStandalone: true, selector: "nz-schema-form-mention", usesInheritance: true, ngImport: i0, template: "<nz-form-item>\n @if (label || required) {\n <nz-form-label [nzRequired]=\"required\">{{ label }}</nz-form-label>\n }\n <nz-form-control [nzErrorTip]=\"errorMessage\" [nzExtra]=\"description\">\n <nz-mention #inputElement [nzSuggestions]=\"widgetData\">\n <input\n nz-input\n [formControl]=\"schemaForm\"\n [class]=\"ngClass\"\n [style]=\"ngStyle\"\n [nzSize]=\"size\"\n [type]=\"type\"\n [placeholder]=\"placeholder\"\n nzMentionTrigger\n />\n </nz-mention>\n </nz-form-control>\n</nz-form-item>\n", dependencies: [{ kind: "ngmodule", type: NzFormModule }, { kind: "directive", type: i1.NzColDirective, selector: "[nz-col],nz-col,nz-form-control,nz-form-label", inputs: ["nzFlex", "nzSpan", "nzOrder", "nzOffset", "nzPush", "nzPull", "nzXs", "nzSm", "nzMd", "nzLg", "nzXl", "nzXXl"], exportAs: ["nzCol"] }, { kind: "directive", type: i1.NzRowDirective, selector: "[nz-row],nz-row,nz-form-item", inputs: ["nzAlign", "nzJustify", "nzGutter"], exportAs: ["nzRow"] }, { kind: "component", type: i2.NzFormItemComponent, selector: "nz-form-item", exportAs: ["nzFormItem"] }, { kind: "component", type: i2.NzFormLabelComponent, selector: "nz-form-label", inputs: ["nzFor", "nzRequired", "nzNoColon", "nzTooltipTitle", "nzTooltipIcon", "nzLabelAlign", "nzLabelWrap"], exportAs: ["nzFormLabel"] }, { kind: "component", type: i2.NzFormControlComponent, selector: "nz-form-control", inputs: ["nzSuccessTip", "nzWarningTip", "nzErrorTip", "nzValidatingTip", "nzExtra", "nzAutoTips", "nzDisableAutoTips", "nzHasFeedback", "nzValidateStatus"], exportAs: ["nzFormControl"] }, { kind: "ngmodule", type: NzMentionModule }, { kind: "component", type: i3$6.NzMentionComponent, selector: "nz-mention", inputs: ["nzValueWith", "nzPrefix", "nzLoading", "nzNotFoundContent", "nzPlacement", "nzSuggestions", "nzStatus"], outputs: ["nzOnSelect", "nzOnSearchChange"], exportAs: ["nzMention"] }, { kind: "directive", type: i3$6.NzMentionTriggerDirective, selector: "input[nzMentionTrigger], textarea[nzMentionTrigger]", outputs: ["onFocusin", "onBlur", "onInput", "onKeydown", "onClick"], exportAs: ["nzMentionTrigger"] }, { kind: "ngmodule", type: NzInputModule }, { kind: "directive", type: i3$2.NzInputDirective, selector: "input[nz-input],textarea[nz-input]", inputs: ["nzBorderless", "nzVariant", "nzSize", "nzStepperless", "nzStatus", "disabled"], exportAs: ["nzInput"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormMentionComponent, decorators: [{
type: Component,
args: [{ selector: 'nz-schema-form-mention', changeDetection: ChangeDetectionStrategy.OnPush, imports: [NzFormModule, NzMentionModule, NzInputModule, ReactiveFormsModule], template: "<nz-form-item>\n @if (label || required) {\n <nz-form-label [nzRequired]=\"required\">{{ label }}</nz-form-label>\n }\n <nz-form-control [nzErrorTip]=\"errorMessage\" [nzExtra]=\"description\">\n <nz-mention #inputElement [nzSuggestions]=\"widgetData\">\n <input\n nz-input\n [formControl]=\"schemaForm\"\n [class]=\"ngClass\"\n [style]=\"ngStyle\"\n [nzSize]=\"size\"\n [type]=\"type\"\n [placeholder]=\"placeholder\"\n nzMentionTrigger\n />\n </nz-mention>\n </nz-form-control>\n</nz-form-item>\n" }]
}] });
class SchemaFormRadioComponent extends BaseField {
constructor() {
super(...arguments);
this.schemaForm = inject(SCHEMA_FORM);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormRadioComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.2", type: SchemaFormRadioComponent, isStandalone: true, selector: "nz-schema-form-radio", usesInheritance: true, ngImport: i0, template: "<p>radio works!</p>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormRadioComponent, decorators: [{
type: Component,
args: [{ selector: 'nz-schema-form-radio', changeDetection: ChangeDetectionStrategy.OnPush, template: "<p>radio works!</p>\n" }]
}] });
class SchemaFormRateComponent extends BaseField {
constructor() {
super(...arguments);
this.schemaForm = inject(SCHEMA_FORM);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormRateComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.2", type: SchemaFormRateComponent, isStandalone: true, selector: "nz-schema-form-rate", usesInheritance: true, ngImport: i0, template: "<p>rate works!</p>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormRateComponent, decorators: [{
type: Component,
args: [{ selector: 'nz-schema-form-rate', changeDetection: ChangeDetectionStrategy.OnPush, template: "<p>rate works!</p>\n" }]
}] });
class SchemaFormSelectComponent extends BaseField {
constructor() {
super(...arguments);
this.options = [];
this.schemaForm = inject(SCHEMA_FORM);
}
setOption() {
const widgetData = this.widgetData;
if (Array.isArray(widgetData)) {
if (widgetData.every(e => typeof e === 'object' && e.hasOwnProperty('value') && e.hasOwnProperty('label'))) {
this.options = widgetData;
}
else {
console.warn(`property widgetData is invalid`, widgetData);
}
return;
}
if (this.enum) {
this.options = this.enum.map(e => ({ value: e, label: `${e}` }));
}
}
ngOnInit() {
super.ngOnInit();
this.setOption();
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormSelectComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.2", type: SchemaFormSelectComponent, isStandalone: true, selector: "nz-schema-form-select", usesInheritance: true, ngImport: i0, template: "<nz-form-item>\n @if (label || required) {\n <nz-form-label [nzRequired]=\"required\">{{ label }}</nz-form-label>\n }\n <nz-form-control [nzErrorTip]=\"errorMessage\" [nzExtra]=\"description\">\n <nz-select\n #inputElement\n [formControl]=\"schemaForm\"\n [class]=\"ngClass\"\n [style]=\"ngStyle\"\n [nzSize]=\"size\"\n [nzPlaceHolder]=\"placeholder\"\n >\n @for (option of options; track option) {\n <nz-option [nzValue]=\"option.value\" [nzLabel]=\"option.label\"></nz-option>\n }\n </nz-select>\n </nz-form-control>\n</nz-form-item>\n", dependencies: [{ kind: "ngmodule", type: NzFormModule }, { kind: "directive", type: i1.NzColDirective, selector: "[nz-col],nz-col,nz-form-control,nz-form-label", inputs: ["nzFlex", "nzSpan", "nzOrder", "nzOffset", "nzPush", "nzPull", "nzXs", "nzSm", "nzMd", "nzLg", "nzXl", "nzXXl"], exportAs: ["nzCol"] }, { kind: "directive", type: i1.NzRowDirective, selector: "[nz-row],nz-row,nz-form-item", inputs: ["nzAlign", "nzJustify", "nzGutter"], exportAs: ["nzRow"] }, { kind: "component", type: i2.NzFormItemComponent, selector: "nz-form-item", exportAs: ["nzFormItem"] }, { kind: "component", type: i2.NzFormLabelComponent, selector: "nz-form-label", inputs: ["nzFor", "nzRequired", "nzNoColon", "nzTooltipTitle", "nzTooltipIcon", "nzLabelAlign", "nzLabelWrap"], exportAs: ["nzFormLabel"] }, { kind: "component", type: i2.NzFormControlComponent, selector: "nz-form-control", inputs: ["nzSuccessTip", "nzWarningTip", "nzErrorTip", "nzValidatingTip", "nzExtra", "nzAutoTips", "nzDisableAutoTips", "nzHasFeedback", "nzValidateStatus"], exportAs: ["nzFormControl"] }, { kind: "ngmodule", type: NzSelectModule }, { kind: "component", type: i3$7.NzOptionComponent, selector: "nz-option", inputs: ["nzTitle", "nzLabel", "nzValue", "nzKey", "nzDisabled", "nzHide", "nzCustomContent"], exportAs: ["nzOption"] }, { kind: "component", type: i3$7.NzSelectComponent, selector: "nz-select", inputs: ["nzId", "nzSize", "nzStatus", "nzVariant", "nzOptionHeightPx", "nzOptionOverflowSize", "nzDropdownClassName", "nzDropdownMatchSelectWidth", "nzDropdownStyle", "nzNotFoundContent", "nzPlaceHolder", "nzPlacement", "nzMaxTagCount", "nzDropdownRender", "nzCustomTemplate", "nzSuffixIcon", "nzClearIcon", "nzRemoveIcon", "nzMenuItemSelectedIcon", "nzTokenSeparators", "nzMaxTagPlaceholder", "nzMaxMultipleCount", "nzMode", "nzFilterOption", "compareWith", "nzAllowClear", "nzBorderless", "nzShowSearch", "nzLoading", "nzAutoFocus", "nzAutoClearSearchValue", "nzServerSearch", "nzDisabled", "nzOpen", "nzSelectOnTab", "nzBackdrop", "nzOptions", "nzShowArrow"], outputs: ["nzOnSearch", "nzScrollToBottom", "nzOpenChange", "nzBlur", "nzFocus", "nzOnClear"], exportAs: ["nzSelect"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormSelectComponent, decorators: [{
type: Component,
args: [{ selector: 'nz-schema-form-select', changeDetection: ChangeDetectionStrategy.OnPush, imports: [NzFormModule, NzSelectModule, ReactiveFormsModule], template: "<nz-form-item>\n @if (label || required) {\n <nz-form-label [nzRequired]=\"required\">{{ label }}</nz-form-label>\n }\n <nz-form-control [nzErrorTip]=\"errorMessage\" [nzExtra]=\"description\">\n <nz-select\n #inputElement\n [formControl]=\"schemaForm\"\n [class]=\"ngClass\"\n [style]=\"ngStyle\"\n [nzSize]=\"size\"\n [nzPlaceHolder]=\"placeholder\"\n >\n @for (option of options; track option) {\n <nz-option [nzValue]=\"option.value\" [nzLabel]=\"option.label\"></nz-option>\n }\n </nz-select>\n </nz-form-control>\n</nz-form-item>\n" }]
}] });
class SchemaFormSliderComponent extends BaseField {
constructor() {
super(...arguments);
this.schemaForm = inject(SCHEMA_FORM);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormSliderComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.2", type: SchemaFormSliderComponent, isStandalone: true, selector: "nz-schema-form-slider", usesInheritance: true, ngImport: i0, template: "<p>slider works!</p>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormSliderComponent, decorators: [{
type: Component,
args: [{ selector: 'nz-schema-form-slider', changeDetection: ChangeDetectionStrategy.OnPush, template: "<p>slider works!</p>\n" }]
}] });
class SchemaFormTextComponent extends BaseField {
constructor() {
super(...arguments);
this.schemaForm = inject(SCHEMA_FORM);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormTextComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.2", type: SchemaFormTextComponent, isStandalone: true, selector: "nz-schema-form-text", usesInheritance: true, ngImport: i0, template: "<p>text works!</p>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormTextComponent, decorators: [{
type: Component,
args: [{ selector: 'nz-schema-form-text', changeDetection: ChangeDetectionStrategy.OnPush, template: "<p>text works!</p>\n" }]
}] });
class SchemaFormTextareaComponent extends BaseField {
constructor() {
super(...arguments);
this.schemaForm = inject(SCHEMA_FORM);
}
get widgetOptions() {
return super.widgetOptions;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormTextareaComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.2", type: SchemaFormTextareaComponent, isStandalone: true, selector: "nz-schema-form-textarea", usesInheritance: true, ngImport: i0, template: "<nz-form-item>\n @if (label || required) {\n <nz-form-label [nzRequired]=\"required\">\n {{ label }}\n </nz-form-label>\n }\n <nz-form-control [nzExtra]=\"description\" [nzErrorTip]=\"errorMessage\">\n <textarea\n nz-input\n #inputElement\n [formControl]=\"schemaForm\"\n [class]=\"ngClass\"\n [style]=\"ngStyle\"\n [nzSize]=\"size\"\n [rows]=\"widgetOptions.rows\"\n [nzAutosize]=\"widgetOptions.autosize || false\"\n [placeholder]=\"placeholder\"\n ></textarea>\n </nz-form-control>\n</nz-form-item>\n", dependencies: [{ kind: "ngmodule", type: NzFormModule }, { kind: "directive", type: i1.NzColDirective, selector: "[nz-col],nz-col,nz-form-control,nz-form-label", inputs: ["nzFlex", "nzSpan", "nzOrder", "nzOffset", "nzPush", "nzPull", "nzXs", "nzSm", "nzMd", "nzLg", "nzXl", "nzXXl"], exportAs: ["nzCol"] }, { kind: "directive", type: i1.NzRowDirective, selector: "[nz-row],nz-row,nz-form-item", inputs: ["nzAlign", "nzJustify", "nzGutter"], exportAs: ["nzRow"] }, { kind: "component", type: i2.NzFormItemComponent, selector: "nz-form-item", exportAs: ["nzFormItem"] }, { kind: "component", type: i2.NzFormLabelComponent, selector: "nz-form-label", inputs: ["nzFor", "nzRequired", "nzNoColon", "nzTooltipTitle", "nzTooltipIcon", "nzLabelAlign", "nzLabelWrap"], exportAs: ["nzFormLabel"] }, { kind: "component", type: i2.NzFormControlComponent, selector: "nz-form-control", inputs: ["nzSuccessTip", "nzWarningTip", "nzErrorTip", "nzValidatingTip", "nzExtra", "nzAutoTips", "nzDisableAutoTips", "nzHasFeedback", "nzValidateStatus"], exportAs: ["nzFormControl"] }, { kind: "ngmodule", type: NzInputModule }, { kind: "directive", type: i3$2.NzInputDirective, selector: "input[nz-input],textarea[nz-input]", inputs: ["nzBorderless", "nzVariant", "nzSize", "nzStepperless", "nzStatus", "disabled"], exportAs: ["nzInput"] }, { kind: "directive", type: i3$2.NzAutosizeDirective, selector: "textarea[nzAutosize]", inputs: ["nzAutosize"], exportAs: ["nzAutosize"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormTextareaComponent, decorators: [{
type: Component,
args: [{ selector: 'nz-schema-form-textarea', changeDetection: ChangeDetectionStrategy.OnPush, imports: [NzFormModule, NzInputModule, ReactiveFormsModule], template: "<nz-form-item>\n @if (label || required) {\n <nz-form-label [nzRequired]=\"required\">\n {{ label }}\n </nz-form-label>\n }\n <nz-form-control [nzExtra]=\"description\" [nzErrorTip]=\"errorMessage\">\n <textarea\n nz-input\n #inputElement\n [formControl]=\"schemaForm\"\n [class]=\"ngClass\"\n [style]=\"ngStyle\"\n [nzSize]=\"size\"\n [rows]=\"widgetOptions.rows\"\n [nzAutosize]=\"widgetOptions.autosize || false\"\n [placeholder]=\"placeholder\"\n ></textarea>\n </nz-form-control>\n</nz-form-item>\n" }]
}] });
class SchemaFormTimePickerComponent extends BaseField {
constructor() {
super(...arguments);
this.schemaForm = inject(SCHEMA_FORM);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormTimePickerComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.2", type: SchemaFormTimePickerComponent, isStandalone: true, selector: "nz-schema-form-time-picker", usesInheritance: true, ngImport: i0, template: "<p>time-picker works!</p>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormTimePickerComponent, decorators: [{
type: Component,
args: [{ selector: 'nz-schema-form-time-picker', changeDetection: ChangeDetectionStrategy.OnPush, template: "<p>time-picker works!</p>\n" }]
}] });
class SchemaFormTransferComponent extends BaseField {
constructor() {
super(...arguments);
this.schemaForm = inject(SCHEMA_FORM);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormTransferComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.2", type: SchemaFormTransferComponent, isStandalone: true, selector: "nz-schema-form-transfer", usesInheritance: true, ngImport: i0, template: "<p>transfer works!</p>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormTransferComponent, decorators: [{
type: Component,
args: [{ selector: 'nz-schema-form-transfer', changeDetection: ChangeDetectionStrategy.OnPush, template: "<p>transfer works!</p>\n" }]
}] });
class SchemaFormTreeSelectComponent extends BaseField {
constructor() {
super(...arguments);
this.schemaForm = inject(SCHEMA_FORM);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormTreeSelectComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.2", type: SchemaFormTreeSelectComponent, isStandalone: true, selector: "nz-schema-form-tree-select", usesInheritance: true, ngImport: i0, template: "<p>tree-select works!</p>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormTreeSelectComponent, decorators: [{
type: Component,
args: [{ selector: 'nz-schema-form-tree-select', changeDetection: ChangeDetectionStrategy.OnPush, template: "<p>tree-select works!</p>\n" }]
}] });
class SchemaFormUploadComponent extends BaseField {
constructor() {
super(...arguments);
this.schemaForm = inject(SCHEMA_FORM);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormUploadComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.2", type: SchemaFormUploadComponent, isStandalone: true, selector: "nz-schema-form-upload", usesInheritance: true, ngImport: i0, template: "<p>upload works!</p>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFormUploadComponent, decorators: [{
type: Component,
args: [{ selector: 'nz-schema-form-upload', changeDetection: ChangeDetectionStrategy.OnPush, template: "<p>upload works!</p>\n" }]
}] });
class SchemaWidgetRegistryService {
constructor() {
this.widgetMap = {
[JSONSchemaTypes.ARRAY]: {
select: SchemaFormSelectComponent,
cascader: SchemaFormCascaderComponent
},
[JSONSchemaTypes.BOOLEAN]: {
checkbox: SchemaFormCheckboxComponent,
select: SchemaFormSelectComponent
},
[JSONSchemaTypes.NUMBER]: {
select: SchemaFormSelectComponent,
'date-picker': SchemaFormDatePickerComponent
},
[JSONSchemaTypes.OBJECT]: {},
[JSONSchemaTypes.STRING]: {
select: SchemaFormSelectComponent,
autocomplete: SchemaFormAutocompleteComponent,
textarea: SchemaFormTextareaComponent,
'date-picker': SchemaFormDatePickerComponent,
mention: SchemaFormMentionComponent
},
[JSONSchemaTypes.NULL]: {},
[JSONSchemaTypes.INTEGER]: {}
};
}
getWidget(schema) {
const type = getSchemaType(schema);
const widgetName = getWidgetName(schema);
if (type && widgetName) {
const widgetMapType = this.widgetMap[type];
if (widgetMapType[widgetName]) {
return widgetMapType[widgetName];
}
}
return null;
}
setWidget(type, widgetName, widgetComponent) {
if (this.widgetMap.hasOwnProperty(type)) {
this.widgetMap[type][widgetName] = widgetComponent;
}
else {
throw new Error(`${type} is not a valid type.`);
}
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaWidgetRegistryService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaWidgetRegistryService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaWidgetRegistryService, decorators: [{
type: Injectable,
args: [{
providedIn: 'root'
}]
}] });
const FIELD_ROOT_NAME = '__root__';
class SchemaFieldComponent {
constructor() {
this.name = FIELD_ROOT_NAME;
this.schemaTypes = JSONSchemaTypes;
this.controls = [];
this.narrowGroup = (form) => form;
this.narrowArray = (form) => form;
this.narrowControl = (form) => form;
this.schemaWidgetRegistryService = inject(SchemaWidgetRegistryService);
this.injector = inject(Injector);
this.schemaFormBuilder = inject(SchemaFormBuilder);
this.cdr = inject(ChangeDetectorRef);
}
ngOnChanges(changes) {
if (changes.schema) {
const value = changes.schema.currentValue;
this.type = value.type || JSONSchemaTypes.OBJECT;
this.setWidgetIfNeed();
this.cdr.markForCheck();
}
if (changes.schemaForm && this.type === JSONSchemaTypes.OBJECT) {
this.controls = Object.values(this.narrowGroup(this.schemaForm).controls);
this.cdr.markForCheck();
}
}
setWidgetIfNeed() {
const widgetName = getWidgetName(this.schema);
if (!widgetName) {
this.widgetInjector = null;
this.WidgetComponent = null;
return;
}
const widgetComponent = this.schemaWidgetRegistryService.getWidget(this.schema);
if (widgetComponent) {
this.createWidgetInjector();
this.WidgetComponent = widgetComponent;
}
else {
this.widgetInjector = null;
this.WidgetComponent = null;
}
}
createWidgetInjector() {
this.widgetInjector = Injector.create({
providers: [{ provide: SCHEMA_FORM, useValue: this.schemaForm }],
parent: this.injector
});
}
push(formArray) {
const schema = getItemSchema(getSchema(this.schema, formArray.schemaContext.root), formArray.length);
formArray.push(this.schemaFormBuilder.createControl(formArray.schemaContext.child(schema, formArray.length)));
}
removeAt(formArray, index) {
formArray.removeAt(index);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.2", type: SchemaFieldComponent, isStandalone: true, selector: "nz-schema-field", inputs: { name: "name", schema: "schema", schemaForm: "schemaForm" }, usesOnChanges: true, ngImport: i0, template: "@if (!WidgetComponent) {\n @switch (type) {\n @case (schemaTypes.OBJECT) {\n @if (schema.title) {\n <nz-divider [nzText]=\"schema.title\" nzOrientation=\"left\"></nz-divider>\n }\n @for (item of controls; track item) {\n <nz-schema-field [schemaForm]=\"item\" [schema]=\"item.schemaContext.schema\"></nz-schema-field>\n }\n }\n @case (schemaTypes.ARRAY) {\n @if (schema.title) {\n <nz-divider [nzText]=\"schema.title\" nzOrientation=\"left\"></nz-divider>\n }\n @for (item of narrowArray(schemaForm).controls; track item) {\n <div class=\"array-item\">\n <nz-schema-field [schemaForm]=\"item\" [schema]=\"item.schemaContext.schema\"></nz-schema-field>\n <button\n nz-button\n nzType=\"default\"\n nzShape=\"circle\"\n (click)=\"removeAt(narrowArray(schemaForm), $index)\"\n >\n -\n </button>\n </div>\n }\n <button\n class=\"add-btn\"\n nz-button\n nzType=\"default\"\n nzShape=\"circle\"\n (click)=\"push(narrowArray(schemaForm))\"\n >\n +\n </button>\n }\n @case (schemaTypes.NUMBER) {\n <nz-number-field [schemaForm]=\"narrowControl(schemaForm)\"></nz-number-field>\n }\n @case (schemaTypes.INTEGER) {\n <nz-number-field [schemaForm]=\"narrowControl(schemaForm)\"></nz-number-field>\n }\n @case (schemaTypes.BOOLEAN) {\n <nz-boolean-field [schemaForm]=\"narrowControl(schemaForm)\"></nz-boolean-field>\n }\n @case (schemaTypes.STRING) {\n <nz-string-field [schemaForm]=\"narrowControl(schemaForm)\"></nz-string-field>\n }\n @case (schemaTypes.NULL) {\n <nz-string-field [schemaForm]=\"narrowControl(schemaForm)\"></nz-string-field>\n }\n }\n} @else if (widgetInjector) {\n <ng-container *ngComponentOutlet=\"WidgetComponent; injector: widgetInjector\"></ng-container>\n}\n", styles: [":host .array-item{display:flex}:host .array-item nz-schema-field{flex:1}:host .array-item button{flex:0 0 32px;margin-left:12px}:host button.add-btn{margin-bottom:12px}\n"], dependencies: [{ kind: "component", type: SchemaFieldComponent, selector: "nz-schema-field", inputs: ["name", "schema", "schemaForm"] }, { kind: "ngmodule", type: NzDividerModule }, { kind: "component", type: i1$1.NzDividerComponent, selector: "nz-divider", inputs: ["nzText", "nzType", "nzOrientation", "nzVariant", "nzDashed", "nzPlain"], exportAs: ["nzDivider"] }, { kind: "ngmodule", type: NzButtonModule }, { kind: "component", type: i2$1.NzButtonComponent, selector: "button[nz-button], a[nz-button]", inputs: ["nzBlock", "nzGhost", "nzSearch", "nzLoading", "nzDanger", "disabled", "tabIndex", "nzType", "nzShape", "nzSize"], exportAs: ["nzButton"] }, { kind: "directive", type: i3$8.ɵNzTransitionPatchDirective, selector: "[nz-button], [nz-icon], nz-icon, [nz-menu-item], [nz-submenu], nz-select-top-control, nz-select-placeholder, nz-input-group", inputs: ["hidden"] }, { kind: "directive", type: i4$1.NzWaveDirective, selector: "[nz-wave],button[nz-button]:not([nzType=\"link\"]):not([nzType=\"text\"])", inputs: ["nzWaveExtraNode"], exportAs: ["nzWave"] }, { kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule", "ngComponentOutletNgModuleFactory"], exportAs: ["ngComponentOutlet"] }, { kind: "component", type: NumberFieldComponent, selector: "nz-number-field", inputs: ["schemaForm"] }, { kind: "component", type: BooleanFieldComponent, selector: "nz-boolean-field", inputs: ["schemaForm"] }, { kind: "component", type: StringFieldComponent, selector: "nz-string-field", inputs: ["schemaForm"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: SchemaFieldComponent, decorators: [{
type: Component,
args: [{ selector: 'nz-schema-field', changeDetection: ChangeDetectionStrategy.OnPush, imports: [
NzDividerModule,
NzButtonModule,
NgComponentOutlet,
NumberFieldComponent,
BooleanFieldComponent,
StringFieldComponent
], template: "@if (!WidgetComponent) {\n @switch (type) {\n @case (schemaTypes.OBJECT) {\n @if (schema.title) {\n <nz-divider [nzText]=\"schema.title\" nzOrientation=\"left\"></nz-divider>\n }\n @for (item of controls; track item) {\n <nz-schema-field [schemaForm]=\"item\" [schema]=\"item.schemaContext.schema\"></nz-schema-field>\n }\n }\n @case (schemaTypes.ARRAY) {\n @if (schema.title) {\n <nz-divider [nzText]=\"schema.title\" nzOrientation=\"left\"></nz-divider>\n }\n @for (item of narrowArray(schemaForm).controls; track item) {\n <div class=\"array-item\">\n <nz-schema-field [schemaForm]=\"item\" [schema]=\"item.schemaContext.schema\"></nz-schema-field>\n <button\n nz-button\n nzType=\"default\"\n nzShape=\"circle\"\n (click)=\"removeAt(narrowArray(schemaForm), $index)\"\n >\n -\n </button>\n </div>\n }\n <button\n class=\"add-btn\"\n nz-button\n nzType=\"default\"\n nzShape=\"circle\"\n (click)=\"push(narrowArray(schemaForm))\"\n >\n +\n </button>\n }\n @case (schemaTypes.NUMBER) {\n <nz-number-field [schemaForm]=\"narrowControl(schemaForm)\"></nz-number-field>\n }\n @case (schemaTypes.INTEGER) {\n <nz-number-field [schemaForm]=\"narrowControl(schemaForm)\"></nz-number-field>\n }\n @case (schemaTypes.BOOLEAN) {\n <nz-boolean-field [schemaForm]=\"narrowControl(schemaForm)\"></nz-boolean-field>\n }\n @case (schemaTypes.STRING) {\n <nz-string-field [schemaForm]=\"narrowControl(schemaForm)\"></nz-string-field>\n }\n @case (schemaTypes.NULL) {\n <nz-string-field [schemaForm]=\"narrowControl(schemaForm)\"></nz-string-field>\n }\n }\n} @else if (widgetInjector) {\n <ng-container *ngComponentOutlet=\"WidgetComponent; injector: widgetInjector\"></ng-container>\n}\n", styles: [":host .array-item{display:flex}:host .array-item nz-schema-field{flex:1}:host .array-item button{flex:0 0 32px;margin-left:12px}:host button.add-btn{margin-bottom:12px}\n"] }]
}], propDecorators: { name: [{
type: Input
}], schema: [{
type: Input
}], schemaForm: [{
type: Input
}] } });
class NzSchemaComponent {
constructor() {
this.schemaFormBuilder = inject(SchemaFormBuilder);
}
ngOnChanges(changes) {
const { nzSchema: schema, nzFormValue: formValue } = changes;
if (!schema && formValue) {
this.setFormValue();
}
else if (schema) {
this.buildForm();
}
}
buildForm() {
this.form = this.schemaFormBuilder.build(this.nzSchema, this.nzFormValue);
}
setFormValue() {
if (this.nzFormValue && this.form) {
this.form.setValue(this.nzFormValue, { emitEvent: false });
}
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: NzSchemaComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.2", type: NzSchemaComponent, isStandalone: true, selector: "nz-schema", inputs: { nzSchema: "nzSchema", nzFormValue: "nzFormValue" }, usesOnChanges: true, ngImport: i0, template: `
<form nz-form [formGroup]="form">
<nz-schema-field [schema]="nzSchema" [schemaForm]="form"></nz-schema-field>
</form>
`, isInline: true, dependencies: [{ kind: "component", type: SchemaFieldComponent, selector: "nz-schema-field", inputs: ["name", "schema", "schemaForm"] }, { kind: "ngmodule", type: NzFormModule }, { kind: "directive", type: i2.NzFormDirective, selector: "[nz-form]", inputs: ["nzLayout", "nzNoColon", "nzAutoTips", "nzDisableAutoTips", "nzTooltipIcon", "nzLabelAlign", "nzLabelWrap"], exportAs: ["nzForm"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i4.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i4.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i4.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: NzSchemaComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-schema',
template: `
<form nz-form [formGroup]="form">
<nz-schema-field [schema]="nzSchema" [schemaForm]="form"></nz-schema-field>
</form>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [SchemaFieldComponent, NzFormModule, ReactiveFormsModule]
}]
}], propDecorators: { nzSchema: [{
type: Input
}], nzFormValue: [{
type: Input
}] } });
/*
* Public API Surface of nz-schema
*/
/**
* Generated bundle index. Do not edit.
*/
export { BaseField, JSONSchemaTypes, NzSchemaComponent, SCHEMA, SCHEMA_FORM, SchemaFormArray, SchemaFormControl, SchemaFormGroup, SchemaWidgetRegistryService };
//# sourceMappingURL=nz-json-schema-form.mjs.map