[Canvas] Number format argument refactor. (#106502)
* Refactored number format argument. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
0ebe3657c1
commit
6fafe87627
|
@ -5,8 +5,9 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { compose, withProps } from 'recompose';
|
||||
import { NumberFormatArgInput as Component, Props as ComponentProps } from './number_format';
|
||||
import React from 'react';
|
||||
import { Assign } from '@kbn/utility-types';
|
||||
import { NumberFormatArgInput, Props as ComponentProps } from './number_format';
|
||||
import { templateFromReactComponent } from '../../../../public/lib/template_from_react_component';
|
||||
import { ArgumentFactory } from '../../../../types/arguments';
|
||||
import { ArgumentStrings } from '../../../../i18n';
|
||||
|
@ -15,6 +16,10 @@ import { FORMATS_UI_SETTINGS } from '../../../../../../../src/plugins/field_form
|
|||
|
||||
const { NumberFormat: strings } = ArgumentStrings;
|
||||
|
||||
const getNumberFormatArgInput = (defaultNumberFormats: ComponentProps['numberFormats']) => (
|
||||
props: Assign<ComponentProps, { numberFormats?: ComponentProps['numberFormats'] }>
|
||||
) => <NumberFormatArgInput numberFormats={defaultNumberFormats} {...props} />;
|
||||
|
||||
export const numberFormatInitializer: SetupInitializer<ArgumentFactory<ComponentProps>> = (
|
||||
core,
|
||||
plugins
|
||||
|
@ -35,14 +40,10 @@ export const numberFormatInitializer: SetupInitializer<ArgumentFactory<Component
|
|||
{ value: formatMap.BYTES, text: strings.getFormatBytes() },
|
||||
];
|
||||
|
||||
const NumberFormatArgInput = compose<ComponentProps, null>(withProps({ numberFormats }))(
|
||||
Component
|
||||
);
|
||||
|
||||
return () => ({
|
||||
name: 'numberFormat',
|
||||
displayName: strings.getDisplayName(),
|
||||
help: strings.getHelp(),
|
||||
simpleTemplate: templateFromReactComponent(NumberFormatArgInput),
|
||||
simpleTemplate: templateFromReactComponent(getNumberFormatArgInput(numberFormats)),
|
||||
});
|
||||
};
|
Loading…
Reference in a new issue