import { useMlKibana } from './kibana_context' ; import { FIELD_FORMAT_IDS } from '../../../../../../../src/plugins/field_formats/common' ; /**
 * Set of reasonable defaults for formatters for the ML app.
 */ const defaultParam = { [ FIELD_FORMAT_IDS . DURATION ] : { inputFormat : 'milliseconds' , outputFormat : 'humanizePrecise' , } , } as Record < FIELD_FORMAT_IDS , object | undefined > ; export function useFieldFormatter ( fieldType ) { const { services : { fieldFormats } , } = useMlKibana ( ) ; const fieldFormatter = fieldFormats . deserialize ( { id : fieldType , params : defaultParam [ fieldType ] , } ) ; return fieldFormatter . convert . bind ( fieldFormatter ) ; }