nz-json-schema-form
Version:
Schema form for JSON schema
799 lines (785 loc) • 94.3 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: "19.2.3", ngImport: i0, type: SchemaFormBuilder, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: SchemaFormBuilder, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", 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: "19.2.3", ngImport: i0, type: NzSchemaErrorMessageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: NzSchemaErrorMessageService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", 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: "19.2.3", ngImport: i0, type: BaseField, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.3", type: BaseField, isStandalone: true, viewQueries: [{ propertyName: "inputElement", first: true, predicate: ["inputElement"], descendants: true }], ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", 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: "19.2.3", ngImport: i0, type: BooleanFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.3", 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: "19.2.3", 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: "19.2.3", ngImport: i0, type: NumberFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.3", 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: "19.2.3", 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: "19.2.3", ngImport: i0, type: StringFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.3", 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", "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: "19.2.3", 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: "19.2.3", ngImport: i0, type: SchemaFormAutocompleteComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.3", 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", "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: "19.2.3", 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: "19.2.3", ngImport: i0, type: SchemaFormCascaderComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.3", 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", "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: "19.2.3", 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: "19.2.3", ngImport: i0, type: SchemaFormCheckboxComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", ver