@centreon/ui 25.2.4 → 25.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@ import { baseEndpoint, getEndpoint, label, optionsData } from './utils';
|
|
|
13
13
|
|
|
14
14
|
import MultiConnectedAutocompleteField from '.';
|
|
15
15
|
|
|
16
|
-
const renderMultiAutocompleteField = (): RenderResult =>
|
|
16
|
+
const renderMultiAutocompleteField = (customRenderTags?): RenderResult =>
|
|
17
17
|
render(
|
|
18
18
|
<TestQueryProvider>
|
|
19
19
|
<MultiConnectedAutocompleteField
|
|
@@ -23,6 +23,7 @@ const renderMultiAutocompleteField = (): RenderResult =>
|
|
|
23
23
|
label={label}
|
|
24
24
|
placeholder="Type here..."
|
|
25
25
|
value={[optionsData.result[0]]}
|
|
26
|
+
customRenderTags={customRenderTags}
|
|
26
27
|
/>
|
|
27
28
|
</TestQueryProvider>
|
|
28
29
|
);
|
|
@@ -42,4 +43,22 @@ describe(MultiConnectedAutocompleteField, () => {
|
|
|
42
43
|
expect(getFetchCall(0)).toEqual(`${baseEndpoint}?page=1`);
|
|
43
44
|
});
|
|
44
45
|
});
|
|
46
|
+
|
|
47
|
+
it('display tags when customTagsRender is defined', async () => {
|
|
48
|
+
const customRender = (tags: React.ReactNode): React.ReactNode => (
|
|
49
|
+
<div data-testid="custom-tags-wrapper">
|
|
50
|
+
{tags}
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const { getByLabelText, getByTestId } = renderMultiAutocompleteField(customRender);
|
|
55
|
+
|
|
56
|
+
fireEvent.click(getByLabelText('Open'));
|
|
57
|
+
|
|
58
|
+
await waitFor(() => {
|
|
59
|
+
const tagChip = getByTestId(`tag-option-chip-${optionsData.result[0].id}`);
|
|
60
|
+
expect(tagChip).toBeVisible();
|
|
61
|
+
expect(tagChip).toHaveTextContent(optionsData.result[0].name);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
45
64
|
});
|
|
@@ -58,3 +58,22 @@ export const popoverWithoutInput = (): JSX.Element => {
|
|
|
58
58
|
/>
|
|
59
59
|
);
|
|
60
60
|
};
|
|
61
|
+
|
|
62
|
+
export const customRenderedTags = (): JSX.Element => {
|
|
63
|
+
const customRender = (tags: React.ReactNode): React.ReactNode => (
|
|
64
|
+
<div style={{ display: 'flex' }}>
|
|
65
|
+
{tags}
|
|
66
|
+
<span style={{ color: '#999' }}>Custom wrapper</span>
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<MultiAutocompleteField
|
|
72
|
+
label="Custom Tags Render"
|
|
73
|
+
options={options}
|
|
74
|
+
placeholder="Type here..."
|
|
75
|
+
value={[options[0], options[1]]}
|
|
76
|
+
customRenderTags={customRender}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
@@ -9,10 +9,6 @@ import { SelectEntry } from '../..';
|
|
|
9
9
|
import Option from '../../Option';
|
|
10
10
|
|
|
11
11
|
const useStyles = makeStyles()((theme) => ({
|
|
12
|
-
checkbox: {
|
|
13
|
-
marginRight: theme.spacing(1),
|
|
14
|
-
padding: 0
|
|
15
|
-
},
|
|
16
12
|
deleteIcon: {
|
|
17
13
|
height: theme.spacing(1.5),
|
|
18
14
|
width: theme.spacing(1.5)
|
|
@@ -37,6 +33,7 @@ export interface Props
|
|
|
37
33
|
getOptionTooltipLabel?: (option) => string;
|
|
38
34
|
getTagLabel?: (option) => string;
|
|
39
35
|
optionProperty?: string;
|
|
36
|
+
customRenderTags?: (tags: React.ReactNode) => React.ReactNode;
|
|
40
37
|
}
|
|
41
38
|
|
|
42
39
|
const MultiAutocompleteField = ({
|
|
@@ -48,6 +45,7 @@ const MultiAutocompleteField = ({
|
|
|
48
45
|
getTagLabel = (option): string => option[optionProperty],
|
|
49
46
|
getOptionTooltipLabel,
|
|
50
47
|
chipProps,
|
|
48
|
+
customRenderTags,
|
|
51
49
|
...props
|
|
52
50
|
}: Props): JSX.Element => {
|
|
53
51
|
const { classes } = useStyles();
|
|
@@ -65,6 +63,7 @@ const MultiAutocompleteField = ({
|
|
|
65
63
|
deleteIcon: classes.deleteIcon,
|
|
66
64
|
root: classes.tag
|
|
67
65
|
}}
|
|
66
|
+
data-testid={`tag-option-chip-${option.id}`}
|
|
68
67
|
label={getTagLabel(option)}
|
|
69
68
|
size="medium"
|
|
70
69
|
{...getTagProps({ index })}
|
|
@@ -106,7 +105,11 @@ const MultiAutocompleteField = ({
|
|
|
106
105
|
<Option checkboxSelected={selected}>{getOptionLabel(option)}</Option>
|
|
107
106
|
</li>
|
|
108
107
|
)}
|
|
109
|
-
renderTags={
|
|
108
|
+
renderTags={(renderedValue, getTagProps): React.ReactNode =>
|
|
109
|
+
customRenderTags
|
|
110
|
+
? customRenderTags(renderTags(renderedValue, getTagProps))
|
|
111
|
+
: renderTags(renderedValue, getTagProps)
|
|
112
|
+
}
|
|
110
113
|
value={value}
|
|
111
114
|
{...props}
|
|
112
115
|
/>
|
package/src/Listing/index.tsx
CHANGED