import { PipeTransform } from '@angular/core'; import { FormlyFieldConfig } from '@ngx-formly/core'; import { FileParams } from '../../types/file'; import { BpmnFormJsonField } from '../../types/json'; import { PythonService } from '../../services/python.service'; import * as i0 from "@angular/core"; export declare function checkNumeric(field: any, event: any): void; /*** * Convert the given BPMN form JSON value to Formly JSON * Usage: * value | toFormly * * Example: jsonValue = { field: [ { id: 'should_ask_color', label: 'Does color affect your mood?', type: 'boolean', default_value: 'false', validation: [ {name: 'required', config: 'true'} ] }, { id: 'favorite_color', label: 'What is your favorite color?', type: 'enum', default_value: 'indigo', value: [ {id: 'red', name: 'Red'}, {id: 'orange', name: 'Orange'}, ... {id: 'violet', name: 'Violet'}, {id: 'other', name: 'Other'}, ], properties: [ {id: 'hide_expression', value: '!should_ask_color'}, {id: 'description', value: '...'}, {id: 'help', value: '...'}, ] }, { id: 'other_color', label: 'Enter other color', type: 'text', properties: [ {id: 'hide_expression', value: '!(should_ask_color && (favorite_color === "other"))'}, {id: 'required_expression', value: 'should_ask_color && (favorite_color === "other")'}, ] } ] } {{ jsonValue | toFormly }} Outputs: { fields: [ { key: 'should_ask_color', type: 'boolean', defaultValue: 'false', templateOptions: { label: 'Does color affect your mood?', }, }, { key: 'favorite_color', type: 'select', templateOptions: { label: 'What is your favorite color?', options: [ {value: 'red', label: 'Red'}, {value: 'orange', label: 'Orange'}, ... {value: 'violet', label: 'Violet'}, {value: 'other', label: 'Other'} ], hideExpression: '!(should_ask_color && (favorite_color === "other"))' }, }, { key: 'other_color', type: 'text', templateOptions: { label: 'Enter other color', hideExpression: '!(should_ask_color && (favorite_color === "other"))' } expressionProperties: { 'templateOptions.required': 'should_ask_color && (favorite_color === "other")' } } ] } */ export interface PythonEvaluation { expression: string; data?: any; key: string; } export declare class ToFormlyPipe implements PipeTransform { private pythonService?; private defaultFileParams; /** * For evaluations to work correctly, the python service must be loaded, and ready to execute at the time of construction. * @param apiService * @param pythonService */ constructor(pythonService?: PythonService); transform(value: BpmnFormJsonField[], fileParams?: FileParams, model?: [], ...args: any[]): FormlyFieldConfig[]; private _stringToBool; /** Convert group names into actual Formly fieldGroups */ private _makeGroups; /** Convert repeating section names into actual Formly repeating sections */ private _makeRepeats; protected setDefaultValue(model: any, resultField: FormlyFieldConfig, field: BpmnFormJsonField, def_value: any): void; protected getPythonEvalFunction(field: BpmnFormJsonField, expression: string, defaultValue?: any): (model: any, formState: any, fieldConfig: FormlyFieldConfig) => any; /** * The context for any python evaluation will be the model. But repeating sections really only have a porition of * the model to reference in Formly, so we have to add the parent models context back in so we can make reference * to other data in the model/task.data * @private */ private getEvalContext; /** Get num_results property from given field, or return the given default if no num_results property found. */ private _getAutocompleteNumResults; private _addClassName; private _readonlyClassName; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } //# sourceMappingURL=to-formly.pipe.d.ts.map