UNPKG

nz-json-schema-form

Version:

Schema form for JSON schema

1 lines 116 kB
{"version":3,"file":"nz-json-schema-form.mjs","sources":["../../../projects/nz-schema/src/lib/interfaces/json-schema.ts","../../../projects/nz-schema/src/lib/utils.ts","../../../projects/nz-schema/src/lib/forms/forms.ts","../../../projects/nz-schema/src/lib/forms/schema-context.ts","../../../projects/nz-schema/src/lib/forms/schema-form-builder.ts","../../../projects/nz-schema/src/lib/error-message/zh_CN.ts","../../../projects/nz-schema/src/lib/error-message/error-message.ts","../../../projects/nz-schema/src/lib/fields/base-field.ts","../../../projects/nz-schema/src/lib/fields/boolean-field/boolean-field.component.ts","../../../projects/nz-schema/src/lib/fields/boolean-field/boolean-field.component.html","../../../projects/nz-schema/src/lib/fields/number-field/number-field.component.ts","../../../projects/nz-schema/src/lib/fields/number-field/number-field.component.html","../../../projects/nz-schema/src/lib/fields/string-field/string-field.component.ts","../../../projects/nz-schema/src/lib/fields/string-field/string-field.component.html","../../../projects/nz-schema/src/lib/widgets/autocomplete/autocomplete.component.ts","../../../projects/nz-schema/src/lib/widgets/autocomplete/autocomplete.component.html","../../../projects/nz-schema/src/lib/widgets/cascader/cascader.component.ts","../../../projects/nz-schema/src/lib/widgets/cascader/cascader.component.html","../../../projects/nz-schema/src/lib/widgets/checkbox/checkbox.component.ts","../../../projects/nz-schema/src/lib/widgets/checkbox/checkbox.component.html","../../../projects/nz-schema/src/lib/widgets/date-picker/date-picker.component.ts","../../../projects/nz-schema/src/lib/widgets/date-picker/date-picker.component.html","../../../projects/nz-schema/src/lib/widgets/mention/mention.component.ts","../../../projects/nz-schema/src/lib/widgets/mention/mention.component.html","../../../projects/nz-schema/src/lib/widgets/radio/radio.component.ts","../../../projects/nz-schema/src/lib/widgets/radio/radio.component.html","../../../projects/nz-schema/src/lib/widgets/rate/rate.component.ts","../../../projects/nz-schema/src/lib/widgets/rate/rate.component.html","../../../projects/nz-schema/src/lib/widgets/select/select.component.ts","../../../projects/nz-schema/src/lib/widgets/select/select.component.html","../../../projects/nz-schema/src/lib/widgets/slider/slider.component.ts","../../../projects/nz-schema/src/lib/widgets/slider/slider.component.html","../../../projects/nz-schema/src/lib/widgets/text/text.component.ts","../../../projects/nz-schema/src/lib/widgets/text/text.component.html","../../../projects/nz-schema/src/lib/widgets/textarea/textarea.component.ts","../../../projects/nz-schema/src/lib/widgets/textarea/textarea.component.html","../../../projects/nz-schema/src/lib/widgets/time-picker/time-picker.component.ts","../../../projects/nz-schema/src/lib/widgets/time-picker/time-picker.component.html","../../../projects/nz-schema/src/lib/widgets/transfer/transfer.component.ts","../../../projects/nz-schema/src/lib/widgets/transfer/transfer.component.html","../../../projects/nz-schema/src/lib/widgets/tree-select/tree-select.component.ts","../../../projects/nz-schema/src/lib/widgets/tree-select/tree-select.component.html","../../../projects/nz-schema/src/lib/widgets/upload/upload.component.ts","../../../projects/nz-schema/src/lib/widgets/upload/upload.component.html","../../../projects/nz-schema/src/lib/schema-widget-registry.service.ts","../../../projects/nz-schema/src/lib/schema-field/schema-field.component.ts","../../../projects/nz-schema/src/lib/schema-field/schema-field.component.html","../../../projects/nz-schema/src/lib/nz-schema.component.ts","../../../projects/nz-schema/src/public-api.ts","../../../projects/nz-schema/src/nz-json-schema-form.ts"],"sourcesContent":["// from @types/json-schema\n\nexport enum JSONSchemaTypes {\n STRING = 'string',\n NUMBER = 'number',\n INTEGER = 'integer',\n BOOLEAN = 'boolean',\n OBJECT = 'object',\n ARRAY = 'array',\n NULL = 'null'\n}\n\nexport type JSONSchemaTypeName = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';\nexport type JSONSchemaType = JSONSchemaArray[] | boolean | number | null | object | string;\nexport interface JSONSchemaArray extends Array<JSONSchemaType> {}\nexport type JSONSchemaVersion = string;\nexport type JSONSchemaDefinition = JSONSchema;\nexport interface JSONSchema {\n $id?: string;\n $ref?: string;\n $schema?: JSONSchemaVersion;\n $comment?: string;\n type?: JSONSchemaTypeName;\n enum?: JSONSchemaType[];\n const?: JSONSchemaType;\n multipleOf?: number;\n maximum?: number;\n exclusiveMaximum?: number;\n minimum?: number;\n exclusiveMinimum?: number;\n maxLength?: number;\n minLength?: number;\n pattern?: string;\n items?: JSONSchemaDefinition | JSONSchemaDefinition[];\n additionalItems?: JSONSchemaDefinition;\n maxItems?: number;\n minItems?: number;\n uniqueItems?: boolean;\n contains?: JSONSchema;\n maxProperties?: number;\n minProperties?: number;\n required?: string[];\n properties?: {\n [key: string]: JSONSchemaDefinition;\n };\n patternProperties?: {\n [key: string]: JSONSchemaDefinition;\n };\n additionalProperties?: JSONSchemaDefinition;\n dependencies?: {\n [key: string]: JSONSchemaDefinition | string[];\n };\n propertyNames?: JSONSchemaDefinition;\n if?: JSONSchemaDefinition;\n then?: JSONSchemaDefinition;\n else?: JSONSchemaDefinition;\n allOf?: JSONSchemaDefinition[];\n anyOf?: JSONSchemaDefinition[];\n oneOf?: JSONSchemaDefinition[];\n not?: JSONSchemaDefinition;\n format?: string;\n contentMediaType?: string;\n contentEncoding?: string;\n definitions?: {\n [key: string]: JSONSchemaDefinition;\n };\n title?: string;\n description?: string;\n default?: JSONSchemaType;\n readOnly?: boolean;\n writeOnly?: boolean;\n examples?: JSONSchemaType;\n}\n","import { AbstractControl, ValidationErrors, ValidatorFn, Validators } from '@angular/forms';\n\nimport { AbstractSchemaControl } from './forms/forms';\nimport { SchemaContext } from './forms/schema-context';\nimport { JSONSchemaType, JSONSchemaTypeName, JSONSchemaTypes } from './interfaces/json-schema';\nimport { NzSchema, NZSchemaDefinition } from './interfaces/nz-schema';\n\nconst formats = {\n email:\n /^[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,\n date: /^\\d\\d\\d\\d-[0-1]\\d-[0-3]\\d$/,\n time: /^(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)(?:\\.\\d+)?(?:z|[+-]\\d\\d:\\d\\d)?$/i,\n '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,\n uri: /^(?:[a-z][a-z0-9+-.]*:)(?:\\/?\\/)?[^\\s]*$/i,\n // eslint-disable-next-line no-control-regex\n 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,\n hostname: /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*$/i,\n ipv4: /^(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$/,\n 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,\n regex: null,\n uuid: /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i\n} as const;\n\nexport function isSchemaObject(schema: NZSchemaDefinition): boolean {\n const type = getSchemaType(schema);\n return type === JSONSchemaTypes.OBJECT;\n}\n\nexport function isSchemaArray(schema: NZSchemaDefinition): boolean {\n if (schema.ui && schema.ui.widget) {\n return false;\n }\n const type = getSchemaType(schema);\n return type === JSONSchemaTypes.ARRAY;\n}\n\nexport function getSchemaType(schema: NzSchema): JSONSchemaTypeName | undefined {\n const type = schema.type;\n if (!type) {\n if (schema.const) {\n return guessType(schema.const);\n }\n\n if (schema.enum) {\n return schema.enum.length ? guessType(schema.enum[0]) : JSONSchemaTypes.STRING;\n }\n\n if (schema.properties || schema.additionalProperties) {\n return JSONSchemaTypes.OBJECT;\n }\n return undefined;\n } else {\n return type;\n }\n}\n\nexport function guessType(value: any): JSONSchemaTypes {\n if (Array.isArray(value)) {\n return JSONSchemaTypes.ARRAY;\n } else if (typeof value === 'string') {\n return JSONSchemaTypes.STRING;\n } else if (value == null) {\n return JSONSchemaTypes.NULL;\n } else if (typeof value === 'boolean') {\n return JSONSchemaTypes.BOOLEAN;\n } else if (!isNaN(value)) {\n return JSONSchemaTypes.NULL;\n } else if (typeof value === 'object') {\n return JSONSchemaTypes.OBJECT;\n }\n return JSONSchemaTypes.STRING;\n}\n\nexport function getWidgetName(schema: NzSchema): string | null {\n if (schema.ui) {\n return typeof schema.ui === 'object' ? schema.ui.widget || null : typeof schema.ui === 'string' ? schema.ui : null;\n } else {\n if (Array.isArray(schema.enum)) {\n return 'select';\n }\n return null;\n }\n}\n\nexport function setRequiredProperties(properties: { [key: string]: AbstractSchemaControl }, schema: NzSchema): void {\n if (!schema.required || !Array.isArray(schema.required)) {\n return;\n }\n schema.required.forEach(name => {\n const control = properties[name];\n if (control) {\n const validators = control.validator ? [control.validator] : [];\n validators.push(Validators.required);\n control.setValidators(validators);\n }\n });\n}\n\nexport function getItemSchema(schema: NZSchemaDefinition, index: number, value?: JSONSchemaType): NZSchemaDefinition {\n if (Array.isArray(schema.items)) {\n if (schema.items[index]) {\n return {\n default: value,\n ...schema.items[index]\n };\n } else {\n if (schema.additionalItems) {\n return {\n default: value,\n ...schema.additionalItems\n };\n } else {\n return {\n default: value\n };\n }\n }\n } else {\n return {\n default: value,\n ...schema.items\n };\n }\n}\n\nexport function getSchema(schema: NzSchema, root: NzSchema): NzSchema {\n if (schema && typeof schema.$ref === 'string') {\n const def = getDefinition(root, schema.$ref);\n return Object.assign(def, schema, { $ref: undefined });\n } else {\n return schema || root;\n }\n}\n\nexport function getDefinition(schema: NzSchema, ref: string): NZSchemaDefinition {\n if (ref[0] !== '#') {\n throw new Error(`Invalid $ref path ${ref}.`);\n } else {\n let definition: any = schema;\n const paths = ref.split('/').slice(1);\n if (paths.length === 0) {\n return {};\n }\n paths.forEach(ptr => {\n if (ptr && definition[ptr]) {\n definition = definition[ptr];\n } else {\n throw new Error(`Could not find definition ${ref}.`);\n }\n });\n return definition;\n }\n}\n\nfunction isEmptyInputValue(value: any): boolean {\n return value == null || value.length === 0;\n}\n\nexport function isRequiredSchema(context: SchemaContext): boolean | undefined {\n const parentSchema = getSchema(context.parent, context.root);\n return (\n parentSchema &&\n isSchemaObject(parentSchema) &&\n parentSchema.required &&\n Array.isArray(parentSchema.required) &&\n parentSchema.required.indexOf(context.name as string) !== -1\n );\n}\n\nexport function getSchemaValidators(context: SchemaContext): ValidatorFn[] {\n const schema = context.schema;\n const validators = [];\n if (isRequiredSchema(context)) {\n validators.push(Validators.required);\n }\n if (schema.type === JSONSchemaTypes.NUMBER || schema.type === JSONSchemaTypes.INTEGER) {\n if (typeof schema.maximum === 'number') {\n validators.push(SchemaValidators.maximum(schema.maximum));\n }\n\n if (typeof schema.minimum === 'number') {\n validators.push(SchemaValidators.minimum(schema.minimum));\n }\n\n if (typeof schema.exclusiveMaximum === 'number') {\n validators.push(SchemaValidators.exclusiveMaximum(schema.exclusiveMaximum));\n }\n\n if (typeof schema.exclusiveMinimum === 'number') {\n validators.push(SchemaValidators.exclusiveMinimum(schema.exclusiveMinimum));\n }\n\n if (typeof schema.multipleOf === 'number') {\n validators.push(SchemaValidators.multipleOf(schema.multipleOf));\n }\n\n if (schema.type === JSONSchemaTypes.INTEGER) {\n validators.push(SchemaValidators.integer);\n }\n }\n\n if (schema.type === JSONSchemaTypes.STRING) {\n if (typeof schema.minLength === 'number') {\n validators.push(Validators.minLength(schema.minLength));\n }\n\n if (typeof schema.maxLength === 'number') {\n validators.push(Validators.maxLength(schema.maxLength));\n }\n\n if (schema.pattern) {\n validators.push(Validators.pattern(schema.pattern));\n }\n\n const formatKey = schema.format as keyof typeof formats;\n if (formatKey && formatKey === 'regex') {\n validators.push(SchemaValidators.regex);\n } else {\n if (formatKey && formats[formatKey]) {\n validators.push(SchemaValidators.format(formatKey, formats[formatKey]));\n } else if (formatKey) {\n console.warn(`unsupported format ${formatKey}`, schema);\n }\n }\n }\n\n if (Array.isArray(schema.enum) && schema.enum.length !== 0) {\n validators.push(SchemaValidators.enum(schema.enum));\n }\n\n return validators;\n}\n\n// @dynamic\nexport class SchemaValidators {\n static multipleOf(multipleOf: number) {\n return (control: AbstractControl): ValidationErrors | null => {\n if (isEmptyInputValue(control.value) || isEmptyInputValue(multipleOf)) {\n return null;\n }\n const value = parseFloat(control.value);\n return !isNaN(value) && value % multipleOf !== 0 ? { multipleOf: { multipleOf, actual: control.value } } : null;\n };\n }\n\n static maximum(maximum: number) {\n return (control: AbstractControl): ValidationErrors | null => {\n if (isEmptyInputValue(control.value) || isEmptyInputValue(maximum)) {\n return null;\n }\n const value = parseFloat(control.value);\n return !isNaN(value) && value > maximum ? { maximum: { maximum, actual: control.value } } : null;\n };\n }\n\n static minimum(minimum: number) {\n return (control: AbstractControl): ValidationErrors | null => {\n if (isEmptyInputValue(control.value) || isEmptyInputValue(minimum)) {\n return null;\n }\n const value = parseFloat(control.value);\n return !isNaN(value) && value < minimum ? { minimum: { minimum, actual: control.value } } : null;\n };\n }\n\n static exclusiveMinimum(exclusiveMinimum: number) {\n return (control: AbstractControl): ValidationErrors | null => {\n if (isEmptyInputValue(control.value) || isEmptyInputValue(exclusiveMinimum)) {\n return null;\n }\n const value = parseFloat(control.value);\n return !isNaN(value) && value <= exclusiveMinimum\n ? { exclusiveMinimum: { exclusiveMinimum, actual: control.value } }\n : null;\n };\n }\n\n static exclusiveMaximum(exclusiveMaximum: number) {\n return (control: AbstractControl): ValidationErrors | null => {\n if (isEmptyInputValue(control.value) || isEmptyInputValue(exclusiveMaximum)) {\n return null;\n }\n const value = parseFloat(control.value);\n return !isNaN(value) && value >= exclusiveMaximum\n ? { exclusiveMaximum: { exclusiveMaximum, actual: control.value } }\n : null;\n };\n }\n\n static integer(control: AbstractControl): ValidationErrors | null {\n if (isEmptyInputValue(control.value)) {\n return null;\n }\n\n return Number.isInteger(control.value) ? null : { integer: true };\n }\n\n static format(format: string, regex: RegExp) {\n return (control: AbstractControl): ValidationErrors | null => {\n if (isEmptyInputValue(control.value)) {\n return null;\n }\n const value: string = control.value;\n return regex.test(value) ? null : { format: { requiredPattern: regex.toString(), actualValue: value, format } };\n };\n }\n\n static enum(enumValues: any[]) {\n return (control: AbstractControl): ValidationErrors | null => {\n const value = control.value;\n if (isEmptyInputValue(value)) {\n return null;\n }\n return enumValues.some(e => e === value) ? null : { enum: { enum: enumValues, actualValue: value } };\n };\n }\n\n static regex(control: AbstractControl): ValidationErrors | null {\n if (isEmptyInputValue(control.value)) {\n return null;\n }\n\n try {\n new RegExp(control.value);\n return null;\n } catch {\n return { format: { actualValue: control.value, format: 'regex' } };\n }\n }\n}\n","import { AbstractControl, UntypedFormArray, UntypedFormControl, UntypedFormGroup } from '@angular/forms';\nimport { Subject } from 'rxjs';\n\nimport { NzSchema } from '../interfaces/nz-schema';\nimport { getItemSchema } from '../utils';\nimport { SchemaContext } from './schema-context';\nimport { SchemaFormBuilder } from './schema-form-builder';\n\nexport type UpdateSchemaFun = (schema: NzSchema) => NzSchema;\n\nfunction updateSchemaFactor(schemaContext: SchemaContext, subject: Subject<NzSchema>) {\n return (schemaOrFun: NzSchema | UpdateSchemaFun) => {\n if (typeof schemaOrFun === 'function') {\n const newSchema = schemaOrFun({ ...schemaContext.schema });\n subject.next(newSchema);\n } else {\n subject.next(schemaOrFun);\n }\n };\n}\n\nexport abstract class AbstractSchemaControl extends AbstractControl {\n // root: AbstractSchemaControl;\n schemaContext!: SchemaContext;\n onUpdateSchema$!: Subject<NzSchema>;\n abstract updateSchema(schemaOrFun: NzSchema | UpdateSchemaFun): void;\n}\n\nexport class SchemaFormControl extends UntypedFormControl implements AbstractSchemaControl {\n // root: AbstractSchemaControl;\n schemaContext!: SchemaContext;\n onUpdateSchema$ = new Subject<NzSchema>();\n get updateSchema(): (schemaOrFun: NzSchema | UpdateSchemaFun) => void {\n return updateSchemaFactor(this.schemaContext, this.onUpdateSchema$);\n }\n\n get(path: Array<string | number> | string): AbstractSchemaControl | null {\n return super.get(path) as AbstractSchemaControl | null;\n }\n\n setValue(\n value: any,\n options?: {\n onlySelf?: boolean;\n emitEvent?: boolean;\n emitModelToViewChange?: boolean;\n emitViewToModelChange?: boolean;\n }\n ): void {\n super.setValue(value, options);\n }\n}\n\nexport class SchemaFormGroup extends UntypedFormGroup implements AbstractSchemaControl {\n // root: AbstractSchemaControl;\n schemaContext!: SchemaContext;\n controls!: {\n [key: string]: AbstractSchemaControl;\n };\n onUpdateSchema$ = new Subject<NzSchema>();\n get updateSchema(): (schemaOrFun: NzSchema | UpdateSchemaFun) => void {\n return updateSchemaFactor(this.schemaContext, this.onUpdateSchema$);\n }\n get(path: Array<string | number> | string): AbstractSchemaControl | null {\n return super.get(path) as AbstractSchemaControl | null;\n }\n}\n\nexport class SchemaFormArray extends UntypedFormArray implements AbstractSchemaControl {\n // root: AbstractSchemaControl;\n schemaContext!: SchemaContext;\n controls!: AbstractSchemaControl[];\n onUpdateSchema$ = new Subject<NzSchema>();\n onControlsChange = new Subject<void>();\n _builder!: SchemaFormBuilder;\n get updateSchema(): (schemaOrFun: NzSchema | UpdateSchemaFun) => void {\n return updateSchemaFactor(this.schemaContext, this.onUpdateSchema$);\n }\n get(path: Array<string | number> | string): AbstractSchemaControl | null {\n return super.get(path) as AbstractSchemaControl | null;\n }\n\n setValue(value: any[], options?: { onlySelf?: boolean; emitEvent?: boolean }): void {\n this.clear();\n const schema = this.schemaContext.schema;\n value.forEach((newValue: any, index: number) => {\n const itemSchema = this.schemaContext.child(getItemSchema(schema, index), index);\n const control = this._builder.createControl(itemSchema, newValue);\n this.push(control);\n });\n this.updateValueAndValidity(options);\n this.onControlsChange.next();\n }\n}\n","import { NzSchema } from '../interfaces/nz-schema';\n\nexport class SchemaContext {\n parent!: NzSchema;\n root: NzSchema;\n name: string | number = '__root__';\n constructor(public schema: NzSchema) {\n this.root = schema;\n }\n\n child(schema: NzSchema, name: string | number): SchemaContext {\n const schemaContext = new SchemaContext(schema);\n schemaContext.root = this.root;\n schemaContext.parent = this.schema;\n schemaContext.name = name;\n return schemaContext;\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport { NzSchema } from '../interfaces/nz-schema';\nimport { getItemSchema, getSchema, getSchemaValidators, isSchemaArray, isSchemaObject } from '../utils';\nimport { AbstractSchemaControl, SchemaFormArray, SchemaFormControl, SchemaFormGroup } from './forms';\nimport { SchemaContext } from './schema-context';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class SchemaFormBuilder {\n build(schema: NzSchema, value?: any): SchemaFormGroup {\n const context = new SchemaContext(schema);\n return this.object(context, value);\n }\n\n object(context: SchemaContext, value?: any): SchemaFormGroup {\n const group = this.reduceControls(context, value);\n const control = new SchemaFormGroup(group);\n control.schemaContext = context;\n return control;\n }\n\n array(context: SchemaContext, value?: any[]): SchemaFormArray {\n const schema = context.schema;\n let control: SchemaFormArray;\n if (!Array.isArray(schema.default) && !Array.isArray(value)) {\n control = new SchemaFormArray([]);\n } else {\n const controls: AbstractSchemaControl[] = [];\n const formValues = Array.isArray(value) ? value : Array.isArray(schema.default) ? schema.default : [];\n formValues.forEach((item, index) => {\n controls[index] = this.createControl(\n context.child(getItemSchema(schema, index, item), index),\n formValues[index]\n );\n });\n control = new SchemaFormArray(controls);\n }\n control.schemaContext = context;\n control._builder = this;\n return control;\n }\n\n control(context: SchemaContext, value?: any): SchemaFormControl {\n const formValue = typeof value === 'undefined' ? context.schema.default : value;\n const control = new SchemaFormControl(formValue, getSchemaValidators(context));\n control.schemaContext = context;\n return control;\n }\n\n createControl(context: SchemaContext, value?: any): AbstractSchemaControl {\n const schema = getSchema(context.schema, context.root);\n if (isSchemaObject(schema)) {\n return this.object(context, value);\n } else if (isSchemaArray(schema)) {\n return this.array(context, value);\n } else {\n return this.control(context, value);\n }\n }\n\n private reduceControls(context: SchemaContext, value?: any): { [key: string]: AbstractSchemaControl } {\n const controls: { [key: string]: AbstractSchemaControl } = {};\n const normalizeSchema = getSchema(context.schema, context.root);\n if (normalizeSchema.properties !== undefined) {\n Object.keys(normalizeSchema.properties).forEach(key => {\n controls[key] = this.createControl(\n context.child(normalizeSchema.properties![key], key),\n value ? value[key] : undefined\n );\n });\n }\n return controls;\n }\n}\n","import { NzSchemaErrorMessageItem } from './error-message';\n\nconst zhCH: NzSchemaErrorMessageItem = {\n // TODO\n additionalItems: '不允许超过 {{n}} 个元素',\n // TODO\n additionalProperties: '不允许有额外的属性',\n // TODO\n anyOf: '数据应为 anyOf 所指定的其中一个',\n // TODO\n dependencies: '应当拥有属性{{=e.params.property}}的依赖属性{{=e.params.deps}}',\n // TODO\n enum: '应当是预设定的枚举值之一',\n // TODO\n format: '应当匹配格式 \"{{format}}\"',\n maximum: '不能大于最大值 {{maximum}}',\n minimum: '不能小于最小值 {{minimum}}',\n exclusiveMinimum: '不能小于等于 {{exclusiveMinimum}}',\n exclusiveMaximum: '不能大于等于 {{exclusiveMaximum}}',\n integer: '应为整数值',\n // TODO\n maxItems: '不应多于 {{n}} 个项',\n // TODO\n minItems: '不应少于 {{n}} 个项',\n maxlength: '不应超过 {{requiredLength}} 个字符',\n minlength: '不应低于 {{requiredLength}} 个字符',\n // TODO\n maxProperties: '不应多于 {{n}} 个属性',\n // TODO\n minProperties: '不应少于 {{n}} 个属性',\n multipleOf: '应当是 {{multipleOf}} 的整数倍',\n // TODO\n oneOf: '只能匹配一个 \"oneOf\" 中的 schema',\n // TODO\n pattern: '应当匹配模式 \"{{requiredPattern}}\"',\n required: `必填项`,\n // TODO\n uniqueItems: `第 {{j}} 项与第 {{i}} 不应重复`,\n // TODO\n propertyNames: `属性名 {{propertyName}} 无效`,\n // TODO\n const: `应当等于常量 {{const}}`,\n // TODO\n contains: `应当包含一个有效项`\n};\n\nexport default zhCH;\n","import { inject, Injectable, InjectionToken } from '@angular/core';\nimport { ValidationErrors } from '@angular/forms';\n\nimport { AbstractSchemaControl } from '../forms/forms';\nimport { getSchema } from '../utils';\nimport defaultMessage from './zh_CN';\n\nexport interface NzSchemaErrorMessageItem {\n [key: string]: ((error: ValidationErrors, form: AbstractSchemaControl) => string) | string;\n}\n\nexport const NZ_SCHEMA_ERROR_MESSAGES = new InjectionToken<NzSchemaErrorMessageItem>('nz-schema-error-messages', {\n providedIn: 'root',\n factory: NZ_SCHEMA_DEFAULT_ERROR_MESSAGES_FACTORY\n});\n\nexport function NZ_SCHEMA_DEFAULT_ERROR_MESSAGES_FACTORY(): NzSchemaErrorMessageItem {\n return defaultMessage;\n}\n\n@Injectable({\n providedIn: 'root'\n})\nexport class NzSchemaErrorMessageService {\n private errorMessages = inject(NZ_SCHEMA_ERROR_MESSAGES, { optional: true });\n\n getErrorMessage(form: AbstractSchemaControl): string | null {\n const errors = form.errors;\n if (!errors || Object.keys(errors).length === 0) {\n return null;\n }\n const schema = getSchema(form.schemaContext.schema, form.schemaContext.root);\n const schemaMessages = typeof schema.ui === 'object' ? schema.ui.messages || {} : {};\n const messages = { ...(this.errorMessages || defaultMessage), ...schemaMessages };\n const errorKey = Object.keys(errors)[0];\n if (!messages.hasOwnProperty(errorKey)) {\n // TODO\n console.warn(`error type not found: ${errorKey}`, errors);\n return null;\n }\n const error = errors[errorKey];\n const message = messages[errorKey];\n let errorMessage = '';\n if (typeof error === 'object') {\n if (typeof message === 'function') {\n return message(error, form);\n } else {\n errorMessage = message as string;\n Object.keys(error).forEach(key => {\n errorMessage = errorMessage.replace(new RegExp(`{{${key}}}`, 'g'), `${error[key]}`);\n });\n return errorMessage;\n }\n } else {\n // @ts-ignore\n return message.toString();\n }\n }\n}\n","import {\n AfterViewInit,\n ChangeDetectorRef,\n Directive,\n EventEmitter,\n inject,\n InjectionToken,\n OnDestroy,\n OnInit,\n SimpleChange,\n SimpleChanges,\n ViewChild\n} from '@angular/core';\n\nimport { NgClassType, NgStyleInterface } from 'ng-zorro-antd/core/types';\n\nimport { NzSchemaErrorMessageService } from '../error-message/error-message';\nimport { AbstractSchemaControl, SchemaFormControl } from '../forms/forms';\nimport { JSONSchemaType } from '../interfaces/json-schema';\nimport { NzSchema, UISchema } from '../interfaces/nz-schema';\nimport { isRequiredSchema } from '../utils';\n\nexport const SCHEMA = new InjectionToken<NzSchema>('NzSchemaToken');\nexport const SCHEMA_FORM = new InjectionToken<AbstractSchemaControl>('NzSchemaFormToken');\n\n@Directive()\nexport abstract class BaseField<T extends AbstractSchemaControl = SchemaFormControl>\n implements OnInit, AfterViewInit, OnDestroy\n{\n abstract schemaForm: T;\n required: boolean | undefined = false;\n errorMessage?: string;\n @ViewChild('inputElement', { static: false }) inputElement: any;\n\n protected errorMessageService = inject(NzSchemaErrorMessageService);\n protected cdr = inject(ChangeDetectorRef);\n\n get schema(): NzSchema {\n return this.schemaForm.schemaContext.schema;\n }\n\n get userInterfaceSchema(): UISchema {\n return typeof this.schema.ui === 'object' ? this.schema.ui : {};\n }\n\n get widgetOptions(): { [p: string]: any } {\n return this.userInterfaceSchema.options || {};\n }\n\n get ngClass(): NgClassType {\n return this.userInterfaceSchema.klass || '';\n }\n\n get ngStyle(): NgStyleInterface {\n return this.userInterfaceSchema.style || {};\n }\n\n get size(): 'large' | 'default' | 'small' {\n return this.userInterfaceSchema.size || 'default';\n }\n\n get placeholder(): string {\n return this.userInterfaceSchema.placeholder || '';\n }\n\n get type(): string | undefined {\n return this.userInterfaceSchema.type;\n }\n\n get widgetData(): any {\n return this.userInterfaceSchema.widgetData;\n }\n\n get disabled(): boolean | undefined {\n return !!this.userInterfaceSchema.disabled;\n }\n\n get enum(): JSONSchemaType[] {\n return this.schema.enum || [];\n }\n\n get label(): string {\n return this.schema.title || '';\n }\n\n get description(): string {\n return this.schema.description || '';\n }\n\n // abstract update(): void;\n init(): void {\n this.required = isRequiredSchema(this.schemaForm.schemaContext);\n if (this.disabled) {\n this.schemaForm.disable({ emitEvent: false });\n }\n this.schemaForm.statusChanges.subscribe(() => {\n this.errorMessage = this.errorMessageService.getErrorMessage(this.schemaForm) || undefined;\n });\n this.schemaForm.onUpdateSchema$.subscribe(schema => {\n this.schemaForm.schemaContext.schema = schema;\n this.cdr.markForCheck();\n });\n }\n\n setInputElementOptions(firstChange = false): void {\n if (!this.inputElement) {\n console.warn('inputElement not found');\n return;\n }\n const keys = Object.keys(this.widgetOptions);\n const changes: SimpleChanges = {};\n keys.forEach(key => {\n if (this.inputElement[key] instanceof EventEmitter && typeof this.widgetOptions[key] === 'function') {\n const event = this.inputElement[key] as EventEmitter<any>;\n const fun = this.widgetOptions[key] as (data?: any, form?: AbstractSchemaControl) => any;\n event.subscribe(data => {\n fun(data, this.schemaForm);\n });\n } else if (this.inputElement[key] !== this.widgetOptions[key]) {\n changes[key] = new SimpleChange(this.inputElement[key], this.widgetOptions[key], firstChange);\n this.inputElement[key] = this.widgetOptions[key];\n }\n });\n if (Object.keys(changes).length) {\n if (typeof this.inputElement.ngOnChanges === 'function') {\n this.inputElement.ngOnChanges(changes);\n }\n this.cdr.markForCheck();\n }\n }\n\n ngAfterViewInit(): void {\n this.setInputElementOptions(true);\n }\n\n ngOnInit(): void {\n this.init();\n }\n\n ngOnDestroy(): void {\n this.schemaForm.onUpdateSchema$.complete();\n }\n}\n","import { Component, Input } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\n\nimport { NzFormModule } from 'ng-zorro-antd/form';\nimport { NzSwitchModule } from 'ng-zorro-antd/switch';\n\nimport { SchemaFormControl } from '../../forms/forms';\nimport { BaseField } from '../base-field';\n\n@Component({\n selector: 'nz-boolean-field',\n templateUrl: './boolean-field.component.html',\n imports: [NzFormModule, NzSwitchModule, ReactiveFormsModule]\n})\nexport class BooleanFieldComponent extends BaseField<SchemaFormControl> {\n @Input() schemaForm!: SchemaFormControl;\n}\n","<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","import { Component, Input } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\n\nimport { NzFormModule } from 'ng-zorro-antd/form';\nimport { NzInputNumberLegacyModule } from 'ng-zorro-antd/input-number-legacy';\n\nimport { SchemaFormControl } from '../../forms/forms';\nimport { BaseField } from '../base-field';\n\n@Component({\n selector: 'nz-number-field',\n templateUrl: './number-field.component.html',\n imports: [NzFormModule, NzInputNumberLegacyModule, ReactiveFormsModule]\n})\nexport class NumberFieldComponent extends BaseField<SchemaFormControl> {\n @Input() schemaForm!: SchemaFormControl;\n}\n","<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","import { Component, Input } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\n\nimport { NzFormModule } from 'ng-zorro-antd/form';\nimport { NzInputModule } from 'ng-zorro-antd/input';\n\nimport { SchemaFormControl } from '../../forms/forms';\nimport { BaseField } from '../base-field';\n\n@Component({\n selector: 'nz-string-field',\n templateUrl: './string-field.component.html',\n imports: [NzFormModule, NzInputModule, ReactiveFormsModule]\n})\nexport class StringFieldComponent extends BaseField<SchemaFormControl> {\n @Input() schemaForm!: SchemaFormControl;\n}\n","<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","import { ChangeDetectionStrategy, Component, inject, OnInit } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\n\nimport { NzAutocompleteModule } from 'ng-zorro-antd/auto-complete';\nimport { NzFormModule } from 'ng-zorro-antd/form';\nimport { NzInputModule } from 'ng-zorro-antd/input';\n\nimport { AutocompleteOptions } from './autocomplete-options';\nimport { BaseField, SCHEMA_FORM } from '../../fields/base-field';\nimport { SchemaFormControl } from '../../forms/forms';\n\n@Component({\n selector: 'nz-schema-form-autocomplete',\n templateUrl: './autocomplete.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [NzFormModule, NzInputModule, ReactiveFormsModule, NzAutocompleteModule]\n})\nexport class SchemaFormAutocompleteComponent extends BaseField implements OnInit {\n get widgetOptions(): AutocompleteOptions {\n return super.widgetOptions as AutocompleteOptions;\n }\n\n schemaForm = inject(SCHEMA_FORM) as SchemaFormControl;\n options: Array<{ label: string; value: any }> = [];\n\n setOption(): void {\n const widgetData = this.widgetData;\n if (Array.isArray(widgetData)) {\n if (widgetData.every(e => typeof e === 'object' && e.hasOwnProperty('value') && e.hasOwnProperty('label'))) {\n this.options = widgetData;\n } else {\n console.warn(`property widgetData is invalid`, widgetData);\n }\n return;\n }\n if (this.enum) {\n this.options = this.enum.map(e => ({ value: e, label: `${e}` }));\n }\n }\n\n ngOnInit(): void {\n super.ngOnInit();\n this.setOption();\n this.schemaForm.onUpdateSchema$.subscribe(() => {\n this.setOption();\n this.cdr.markForCheck();\n });\n }\n}\n","<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","import { ChangeDetectionStrategy, Component, inject } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\n\nimport { NzCascaderModule, NzCascaderOption } from 'ng-zorro-antd/cascader';\nimport { NzFormModule } from 'ng-zorro-antd/form';\n\nimport { CascaderOptions } from './cascader-options';\nimport { BaseField, SCHEMA_FORM } from '../../fields/base-field';\nimport { SchemaFormControl } from '../../forms/forms';\n\n@Component({\n selector: 'nz-schema-form-cascader',\n templateUrl: './cascader.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [NzFormModule, NzCascaderModule, ReactiveFormsModule]\n})\nexport class SchemaFormCascaderComponent extends BaseField {\n get widgetData(): NzCascaderOption[] {\n return super.widgetData as NzCascaderOption[];\n }\n\n get widgetOptions(): CascaderOptions {\n return super.widgetOptions;\n }\n\n schemaForm = inject(SCHEMA_FORM) as SchemaFormControl;\n}\n","<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","import { ChangeDetectionStrategy, Component, inject } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\n\nimport { NzCheckboxModule } from 'ng-zorro-antd/checkbox';\nimport { NzFormModule } from 'ng-zorro-antd/form';\n\nimport { BaseField, SCHEMA_FORM } from '../../fields/base-field';\nimport { SchemaFormControl } from '../../forms/forms';\n\n@Component({\n selector: 'nz-schema-form-checkbox',\n templateUrl: './checkbox.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [NzFormModule, NzCheckboxModule, ReactiveFormsModule]\n})\nexport class SchemaFormCheckboxComponent extends BaseField {\n schemaForm = inject(SCHEMA_FORM) as SchemaFormControl;\n}\n","<nz-form-item>\n <nz-form-control [nzErrorTip]=\"errorMessage\" [nzExtra]=\"description\">\n <span [class.ant-form-item-required]=\"required\">\n &nbsp;\n <label nz-checkbox [formControl]=\"schemaForm\">\n {{ label }}\n </label>\n </span>\n </nz-form-control>\n</nz-form-item>\n","import { ChangeDetectionStrategy, Component, inject } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\n\nimport { NzDatePickerModule } from 'ng-zorro-antd/date-picker';\nimport { NzFormModule } from 'ng-zorro-antd/form';\n\nimport { BaseField, SCHEMA_FORM } from '../../fields/base-field';\nimport { SchemaFormControl } from '../../forms/forms';\n\n@Component({\n selector: 'nz-schema-form-date-picker',\n templateUrl: './date-picker.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [NzFormModule, NzDatePickerModule, ReactiveFormsModule]\n})\nexport class SchemaFormDatePickerComponent extends BaseField {\n schemaForm = inject(SCHEMA_FORM) as SchemaFormControl;\n}\n","<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","import { ChangeDetectionStrategy, Component, inject } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\n\nimport { NzFormModule } from 'ng-zorro-antd/form';\nimport { NzInputModule } from 'ng-zorro-antd/input';\nimport { NzMentionModule } from 'ng-zorro-antd/mention';\n\nimport { BaseField, SCHEMA_FORM } from '../../fields/base-field';\nimport { SchemaFormControl } from '../../forms/forms';\n\n@Component({\n selector: 'nz-schema-form-mention',\n templateUrl: './mention.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [NzFormModule, NzMentionModule, NzInputModule, ReactiveFormsModule]\n})\nexport class SchemaFormMentionComponent extends BaseField {\n schemaForm = inject(SCHEMA_FORM) as SchemaFormControl;\n}\n","<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","import { ChangeDetectionStrategy, Component, inject } from '@angular/core';\n\nimport { BaseField, SCHEMA_FORM } from '../../fields/base-field';\nimport { SchemaFormControl } from '../../forms/forms';\n\n@Component({\n selector: 'nz-schema-form-radio',\n templateUrl: './radio.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class SchemaFormRadioComponent extends BaseField {\n schemaForm = inject(SCHEMA_FORM) as SchemaFormControl;\n}\n","<p>radio works!</p>\n","import { ChangeDetectionStrategy, Component, inject } from '@angular/core';\n\nimport { BaseField, SCHEMA_FORM } from '../../fields/base-field';\nimport { SchemaFormControl } from '../../forms/forms';\n\n@Component({\n selector: 'nz-schema-form-rate',\n templateUrl: './rate.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class SchemaFormRateComponent extends BaseField {\n schemaForm = inject(SCHEMA_FORM) as SchemaFormControl;\n}\n","<p>rate works!</p>\n","import { ChangeDetectionStrategy, Component, inject, OnInit } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\n\nimport { NzFormModule } from 'ng-zorro-antd/form';\nimport { NzSelectModule } from 'ng-zorro-antd/select';\n\nimport { BaseField, SCHEMA_FORM } from '../../fields/base-field';\nimport { SchemaFormControl } from '../../forms/forms';\n\n@Component({\n selector: 'nz-schema-form-select',\n templateUrl: './select.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [NzFormModule, NzSelectModule, ReactiveFormsModule]\n})\nexport class SchemaFormSelectComponent extends BaseField implements OnInit {\n options: Array<{ label: string; value: any }> = [];\n schemaForm = inject(SCHEMA_FORM) as SchemaFormControl;\n\n setOption(): void {\n const widgetData = this.widgetData;\n if (Array.isArray(widgetData)) {\n if (widgetData.every(e => typeof e === 'object' && e.hasOwnProperty('value') && e.hasOwnProperty('label'))) {\n this.options = widgetData;\n } else {\n console.warn(`property widgetData is invalid`, widgetData);\n }\n return;\n }\n if (this.enum) {\n this.options = this.enum.map(e => ({ value: e, label: `${e}` }));\n }\n }\n\n ngOnInit(): void {\n super.ngOnInit();\n this.setOption();\n }\n}\n","<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","import { ChangeDetectionStrategy, Component, inject } from '@angular/core';\n\nimport { BaseField, SCHEMA_FORM } from '../../fields/base-field';\nimport { SchemaFormControl } from '../../forms/forms';\n\n@Component({\n selector: 'nz-schema-form-slider',\n templateUrl: './slider.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class SchemaFormSliderComponent extends BaseField {\n schemaForm = inject(SCHEMA_FORM) as SchemaFormControl;\n}\n","<p>slider works!</p>\n","import { ChangeDetectionStrategy, Component, inject } from '@angular/core';\n\nimport { BaseField, SCHEMA_FORM } from '../../fields/base-field';\nimport { SchemaFormControl } from '../../forms/forms';\n\n@Component({\n selector: 'nz-schema-form-text',\n templateUrl: './text.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class SchemaFormTextComponent extends BaseField {\n schemaForm = inject(SCHEMA_FORM) as SchemaFormControl;\n}\n","<p>text works!</p>\n","import { ChangeDetectionStrategy, Component, inject } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\n\nimport { NzFormModule } from 'ng-zorro-antd/form';\nimport { NzInputModule } from 'ng-zorro-antd/input';\n\nimport { TextareaOptions } from './textarea-options';\nimport { BaseField, SCHEMA_FORM } from '../../fields/base-field';\nimport { SchemaFormControl } from '../../forms/forms';\n\n@Component({\n selector: 'nz-schema-form-textarea',\n templateUrl: './textarea.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [NzFormModule, NzInputModule, ReactiveFormsModule]\n})\nexport class SchemaFormTextareaComponent extends BaseField {\n get widgetOptions(): TextareaOptions {\n return super.widgetOptions as Textar