From 84be47b11473b34948af0440fc24b3d25bbbc9f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Wed, 13 May 2020 15:24:56 +0200 Subject: [PATCH] Add custom renderers for react-select so we can show tags and counts [MAILPOET-2772] --- .../common/form/react_select/react_select.tsx | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/assets/js/src/common/form/react_select/react_select.tsx b/assets/js/src/common/form/react_select/react_select.tsx index 518ade4f1c..12a6d47e52 100644 --- a/assets/js/src/common/form/react_select/react_select.tsx +++ b/assets/js/src/common/form/react_select/react_select.tsx @@ -8,6 +8,54 @@ type Props = ReactSelectProps & { iconStart?: JSX.Element, }; +const LabelRenderer = (data: any) => ( +
+ {data.tag && {data.tag}} + {data.label} + {data.count && {data.count}} +
+); + +const Option = (props: any) => ( +
+ {LabelRenderer(props.data)} +
+); + +const SingleValue = (props: any) => ( +
+ {LabelRenderer(props.data)} +
+); + +const MultiValueLabel = (props: any) => ( +
+ {LabelRenderer(props.data)} +
+); + const ReactSelect = ({ dimension, isFullWidth, @@ -30,6 +78,7 @@ const ReactSelect = ({