@rero/ng-core
Version:
RERO angular core library.
102 lines (101 loc) • 3.23 kB
TypeScript
import { FormlyExtension, FormlyFieldConfig, FormlyFieldProps } from '@ngx-formly/core';
import { TranslateService } from '@ngx-translate/core';
import { RecordService } from '../record.service';
export declare class NgCoreFormlyExtension {
protected recordService: RecordService;
private _fieldWrapperTypes;
/**
* prePopulate Formly hook
* @param field - FormlyFieldConfig
*/
prePopulate(field: FormlyFieldConfig): void;
/**
* onPopulate Formly hook
* @param field - FormlyFieldConfig
*/
onPopulate(field: FormlyFieldConfig): void;
/**
* Add formly wrappers
* @param field - FormlyFieldConfig
*/
private _setWrappers;
/**
* Create an id html attribute by joining field and parents keys
* @param field formly field config
* @returns array - keys to create the id html attribute
*/
private _getKey;
/**
* Check if the given field or one of his parents has a hide wrapper
* @param field - FormlyFieldConfig
* @return boolean - true if has a hide wrapper
*/
private _hasHideWrapper;
/**
* Check if the given field has at least on parent marked as hidden.
* The model should be empty.
*
* @param field - FormlyFieldConfig
* @return boolean - true has a parent marked as hidden.
*/
private _hasHiddenParent;
/**
* Check if a field has an empty model.
*
* @param field formly field config
* @returns true if the given field has an empty model.
*/
private _modelIsEmpty;
/**
* Hide or show field depending of the data content and the hide property
* @param field - FormlyFieldConfig
*/
private _hideEmptyField;
/**
* Set custom validators from the props configuration.
* @param field - FormlyFieldConfig
*/
private _setCustomValidators;
}
export declare class TranslateExtension implements FormlyExtension {
protected translate: TranslateService;
prePopulate(field: FormlyFieldConfig<FormlyFieldProps & {
[additionalProperties: string]: any;
}>): void;
private processAllAddon;
private processAddon;
}
export declare class FormOptionsProcessExtension implements FormlyExtension {
prePopulate(field: FormlyFieldConfig<FormlyFieldProps & {
[additionalProperties: string]: any;
}>): void;
private processOptions;
private processUntranslatedLabel;
private sortOptions;
}
/**
* To register an ngx-formly translations extension.
*
* @param translate ngx-translate service
* @param recordService - ng core record service
* @returns FormlyConfig object configuration
*/
export declare function registerNgCoreFormlyExtension(translate: TranslateService, recordService: RecordService): {
validationMessages: {
name: string;
message: (_err: any, field: FormlyFieldConfig) => any;
}[];
extensions: ({
name: string;
extension: FormOptionsProcessExtension;
priority: number;
} | {
name: string;
extension: TranslateExtension;
priority: number;
} | {
name: string;
extension: NgCoreFormlyExtension;
priority: number;
})[];
};