svogv
Version:
A decorator based approach for model driven forms, including an advanced DataGrid and a TreeView component.
172 lines (171 loc) • 4.61 kB
TypeScript
/**
* This element describes the grouping of elements in fieldset-controls. Each
* field that is decorated in an DisplayGroup with the very same name is grouped
* into that part. The name appears in the fieldsets legend-control. The
* description makes a tooltip. If there are more groups the order is controlled
* by the {@link order}element.
*/
export declare type displayGroupType = {
displaygroup: {
name: string;
order?: number;
description?: string;
};
};
/**
* This element describes the UI elements label, tooltip, and order.
*/
export declare type displayType = {
display: {
name: string;
order?: number;
description?: string;
};
};
/**
* A pipe driven formatting instruction.
*/
export declare type formatType = {
format: {
pipeName: any;
pipeParams?: any[];
};
};
/**
* The field will not appear in autoforms if decorated as hidden. If the parameter
* is omitted the type returns true due to its pure existence.
*/
export declare type hiddenType = {
hidden?: boolean;
};
/**
* A watermark can be applied. The {@link name property is the value that}appears
* in the field. This may not work for specific controls, such as list boxes.
*/
export declare type placeHolderType = {
placeholder: {
name: string;
};
};
/**
* The field in rendered as readonly, if possible.
*/
export declare type readonlyType = {
readonly: boolean;
};
/**
* This controls the actual control type. The default values are (TypeScript type: decorator type: rendered element):
*
* * string: text: <input type="text">
* * date: calendar: <input type="date">
* * boolean: boolean: <input type="checkbox">
* * number: number: <input type="number">
*
* This is the formatting that's automatically applied. The template hint goes after and can change any of these values.
* The allows values are:
*
* * any: textarea: <textarea>
* * array: enum: <select>
* * array: list: <select>
* * any: template: The content of the editor element (does not work with <ac-autoform>)
*
*/
export declare type templateHintType = {
templatehint: {
hint: string;
};
};
/**
* Base type for validators.
*
* Give a private error message in @param msg. If omitted a error message will be generated.
* Set to active by using @param active. Default is true.
* Active i18n by using the @param translate. The translation module must be used separately.
*/
export declare type validatorType = {
msg?: string;
active?: boolean;
translate?: boolean;
};
/**
* Compare to fields.
*/
export declare type compareType = {
compare: {
fieldToCompare: string;
} | validatorType;
};
/**
* Email
*/
export declare type emailType = {
email: validatorType;
};
/**
* Maximum allowed length (string only)
*/
export declare type maxlengthType = {
maxlength: {
max: number;
} | validatorType;
};
/**
* Minimum allowed length (string only)
*/
export declare type minlengthType = {
minlength: {
min: number;
} | validatorType;
};
/**
* Any regex pattern
*/
export declare type patternType = {
pattern: {
pattern: string | RegExp;
} | validatorType;
};
/**
* A range for number or Date only.
*/
export declare type rangeType = {
range: {
from: number | Date;
to: number | Date;
} | validatorType;
};
/**
* This field is mandatory.
*/
export declare type requiredType = {
required: validatorType;
};
/**
* Maximal and minimal allowed length (string only).
*/
export declare type stringLengthType = {
stringlength: {
min: number;
max: number;
} | validatorType;
};
/**
* The form description model. Use this to have a valid JSON object that can be used
* instead of the decorators. Each type represents a single decorator. The basic
* structure looks like this shown in the example.
*
* See the different type's descriptions for detailled information.
*
* @example
{
"fieldName": {
"display": {
"name": "The field's human readible name"
}
}
}
*
*/
export interface FormValidatorModel {
[field: string]: displayType | displayGroupType | formatType | hiddenType | placeHolderType | compareType | maxlengthType | minlengthType | patternType | stringLengthType | emailType | requiredType;
}