@centreon/ui 24.4.44 → 24.4.45-develop.0
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 +19 -14
- package/public/mockServiceWorker.js +1 -1
- package/src/Button/Icon/index.tsx +1 -1
- package/src/Button/Save/StartIcon.tsx +3 -3
- package/src/Button/Save/index.tsx +9 -5
- package/src/Checkbox/Checkbox.tsx +2 -2
- package/src/Checkbox/CheckboxGroup/index.tsx +2 -2
- package/src/Dashboard/Item.tsx +1 -1
- package/src/Dashboard/Layout.tsx +2 -2
- package/src/Dialog/index.tsx +1 -1
- package/src/FallbackPage/FallbackPage.tsx +3 -3
- package/src/FileDropZone/index.tsx +3 -1
- package/src/Form/Form.cypress.spec.tsx +133 -0
- package/src/Form/Inputs/CheckboxGroup.tsx +1 -4
- package/src/Form/Inputs/List/Content.tsx +62 -0
- package/src/Form/Inputs/List/List.styles.ts +29 -0
- package/src/Form/Inputs/List/List.tsx +58 -0
- package/src/Form/Inputs/List/useList.ts +81 -0
- package/src/Form/Inputs/index.tsx +3 -1
- package/src/Form/Inputs/models.ts +9 -1
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/Circle.tsx +2 -2
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/index.tsx +5 -4
- package/src/Graph/LineChart/BasicComponents/Thresholds.tsx +2 -2
- package/src/Graph/LineChart/BasicComponents/useFilterLines.ts +1 -1
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/GuidingLines.tsx +2 -2
- package/src/Graph/LineChart/InteractiveComponents/Annotations/Annotation/index.tsx +2 -3
- package/src/Graph/LineChart/InteractiveComponents/Annotations/EventAnnotations.tsx +1 -1
- package/src/Graph/LineChart/Legend/useLegend.ts +3 -3
- package/src/Graph/LineChart/helpers/doc.ts +16 -13
- package/src/Graph/LineChart/helpers/index.ts +1 -1
- package/src/Graph/LineChart/index.stories.tsx +4 -2
- package/src/Graph/SingleBar/Thresholds.tsx +2 -2
- package/src/Graph/Text/Text.stories.tsx +60 -4
- package/src/Graph/common/timeSeries/index.ts +3 -3
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +10 -7
- package/src/InputField/Select/Autocomplete/Draggable/SortableList.tsx +1 -1
- package/src/InputField/Select/Autocomplete/Draggable/SortableListContent.tsx +1 -1
- package/src/InputField/Select/Autocomplete/Draggable/index.tsx +1 -1
- package/src/InputField/Select/Autocomplete/index.tsx +121 -115
- package/src/InputField/Select/IconPopover/index.tsx +2 -2
- package/src/InputField/Select/index.tsx +1 -1
- package/src/InputField/Text/index.tsx +2 -2
- package/src/Listing/Cell/DataCell.tsx +15 -1
- package/src/Listing/Header/ListingHeader.tsx +1 -1
- package/src/Listing/Listing.styles.ts +2 -3
- package/src/Listing/index.stories.tsx +12 -1
- package/src/Listing/index.tsx +1 -2
- package/src/Module/Module.cypress.spec.tsx +129 -0
- package/src/Module/index.tsx +2 -4
- package/src/RichTextEditor/RichTextEditor.tsx +12 -1
- package/src/SortableItems/index.tsx +2 -7
- package/src/ThemeProvider/index.tsx +24 -0
- package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.styles.ts +6 -7
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +8 -3
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +0 -2
- package/src/TimePeriods/DateTimePickerInput.tsx +56 -19
- package/src/TimePeriods/ResolutionTimePeriod.cypress.spec.tsx +12 -9
- package/src/TimePeriods/TimePeriods.cypress.spec.tsx +9 -33
- package/src/TimePeriods/helpers/index.ts +1 -1
- package/src/TimePeriods/index.stories.tsx +12 -4
- package/src/TimePeriods/index.tsx +2 -2
- package/src/api/QueryProvider.tsx +1 -1
- package/src/api/TestQueryProvider.tsx +1 -1
- package/src/api/useFetchQuery/index.ts +27 -23
- package/src/api/useMutationQuery/index.ts +45 -21
- package/src/components/Button/Icon/IconButton.tsx +6 -2
- package/src/components/DataTable/DataListing.tsx +6 -0
- package/src/components/DataTable/DataTable.cypress.spec.tsx +193 -0
- package/src/components/DataTable/DataTable.stories.tsx +40 -0
- package/src/components/DataTable/DataTable.styles.ts +3 -0
- package/src/components/DataTable/DataTable.tsx +3 -3
- package/src/components/DataTable/Item/DataTableItem.styles.ts +7 -2
- package/src/components/DataTable/Item/DataTableItem.tsx +4 -4
- package/src/components/DataTable/index.ts +3 -1
- package/src/components/Form/Dashboard/DashboardForm.tsx +15 -12
- package/src/components/Layout/PageLayout/PageLayout.tsx +1 -1
- package/src/components/Layout/PageLayout/PageLayoutActions.tsx +1 -0
- package/src/components/Layout/PageLayout/PageLayoutBody.tsx +1 -0
- package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +5 -1
- package/src/components/Layout/PageLayout/PageQuickAccess.tsx +76 -0
- package/src/components/Layout/PageLayout/index.ts +3 -1
- package/src/components/Layout/PageLayout.cypress.spec.tsx +66 -0
- package/src/components/Modal/Modal.styles.ts +1 -1
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.stories.tsx +3 -3
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.tsx +1 -1
- package/src/components/Tooltip/ConfirmationTooltip/models.ts +1 -1
- package/src/index.ts +2 -2
- package/src/queryParameters/url/index.ts +5 -1
- package/src/utils/index.ts +2 -1
- package/src/utils/{useLicenseExpirationWarning.cypress.spec.tsx → useLicenseExpirationWarning.test.tsx} +48 -37
- package/src/utils/useLicenseExpirationWarning.ts +18 -18
- package/src/utils/usePluralizedTranslation.ts +21 -0
- package/src/screens/dashboard/DashboardsDetail.stories.tsx +0 -108
- package/src/screens/dashboard/DashboardsOverview.stories.tsx +0 -281
- package/src/utils/useDateTimePickerAdapter.ts +0 -309
|
@@ -18,7 +18,8 @@ export enum InputType {
|
|
|
18
18
|
Grid,
|
|
19
19
|
Custom,
|
|
20
20
|
Checkbox,
|
|
21
|
-
CheckboxGroup
|
|
21
|
+
CheckboxGroup,
|
|
22
|
+
List
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
interface FieldsTableGetRequiredProps {
|
|
@@ -76,6 +77,13 @@ export interface InputProps {
|
|
|
76
77
|
hideInput?: (values: FormikValues) => boolean;
|
|
77
78
|
inputClassName?: string;
|
|
78
79
|
label: string;
|
|
80
|
+
list?: {
|
|
81
|
+
AddItem: React.ComponentType<{ addItem }>;
|
|
82
|
+
SortContent: React.ComponentType<object>;
|
|
83
|
+
addItemLabel?: string;
|
|
84
|
+
itemProps: Array<string>;
|
|
85
|
+
sortLabel?: string;
|
|
86
|
+
};
|
|
79
87
|
radio?: {
|
|
80
88
|
options?: Array<{
|
|
81
89
|
label: string | JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Shape } from '@visx/visx';
|
|
2
2
|
import { isEmpty, isNil } from 'ramda';
|
|
3
3
|
|
|
4
|
-
import { Circle } from './models';
|
|
4
|
+
import { Circle as CircleModel } from './models';
|
|
5
5
|
import useCoordinateCircle from './useCoordinateCircle';
|
|
6
6
|
|
|
7
7
|
const Circle = ({
|
|
@@ -11,7 +11,7 @@ const Circle = ({
|
|
|
11
11
|
timeSeries,
|
|
12
12
|
getX,
|
|
13
13
|
getCountDisplayedCircles
|
|
14
|
-
}:
|
|
14
|
+
}: CircleModel): JSX.Element | null => {
|
|
15
15
|
const coordinates = useCoordinateCircle({
|
|
16
16
|
getCountDisplayedCircles,
|
|
17
17
|
getX,
|
|
@@ -130,10 +130,11 @@ const WrapperThresholdLines = ({
|
|
|
130
130
|
|
|
131
131
|
return (
|
|
132
132
|
<g>
|
|
133
|
-
{filteredThresholdLines.map(
|
|
134
|
-
element
|
|
135
|
-
|
|
136
|
-
|
|
133
|
+
{filteredThresholdLines.map(
|
|
134
|
+
(element) =>
|
|
135
|
+
element?.map(({ Component, props, key }) => (
|
|
136
|
+
<Component {...props} id={key} key={key} />
|
|
137
|
+
))
|
|
137
138
|
)}
|
|
138
139
|
</g>
|
|
139
140
|
);
|
|
@@ -2,7 +2,7 @@ import { equals, isNil } from 'ramda';
|
|
|
2
2
|
|
|
3
3
|
import { getUnits, getYScale } from '../../common/timeSeries';
|
|
4
4
|
import { Line } from '../../common/timeSeries/models';
|
|
5
|
-
import { Thresholds } from '../../common/models';
|
|
5
|
+
import { Thresholds as ThresholdsModel } from '../../common/models';
|
|
6
6
|
|
|
7
7
|
import { ThresholdLine } from './ThresholdLine';
|
|
8
8
|
|
|
@@ -13,7 +13,7 @@ interface Props {
|
|
|
13
13
|
rightScale: (value: number) => number;
|
|
14
14
|
showTooltip: (props) => void;
|
|
15
15
|
thresholdUnit?: string;
|
|
16
|
-
thresholds:
|
|
16
|
+
thresholds: ThresholdsModel;
|
|
17
17
|
width: number;
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -28,7 +28,7 @@ const useFilterLines = ({
|
|
|
28
28
|
linesGraph,
|
|
29
29
|
setLinesGraph
|
|
30
30
|
}: UseFilterLines): Result => {
|
|
31
|
-
const displayedLines = reject(propEq('display'
|
|
31
|
+
const displayedLines = reject(propEq(false, 'display'), linesGraph ?? lines);
|
|
32
32
|
const filterLines = (): Array<Line> => {
|
|
33
33
|
const lineOriginMetric = findLineOfOriginMetricThreshold(lines);
|
|
34
34
|
|
|
@@ -2,7 +2,7 @@ import { Shape } from '@visx/visx';
|
|
|
2
2
|
|
|
3
3
|
import { grey } from '@mui/material/colors';
|
|
4
4
|
|
|
5
|
-
import { GuidingLines } from './models';
|
|
5
|
+
import { GuidingLines as GuidingLinesModel } from './models';
|
|
6
6
|
import useTickGraph from './useTickGraph';
|
|
7
7
|
|
|
8
8
|
const GuidingLines = ({
|
|
@@ -10,7 +10,7 @@ const GuidingLines = ({
|
|
|
10
10
|
xScale,
|
|
11
11
|
graphHeight,
|
|
12
12
|
graphWidth
|
|
13
|
-
}:
|
|
13
|
+
}: GuidingLinesModel): JSX.Element | null => {
|
|
14
14
|
const { positionX, positionY } = useTickGraph({
|
|
15
15
|
timeSeries,
|
|
16
16
|
xScale
|
|
@@ -43,9 +43,8 @@ const Annotation = ({
|
|
|
43
43
|
|
|
44
44
|
const setAnnotationHovered = useSetAtom(annotationHoveredAtom);
|
|
45
45
|
|
|
46
|
-
const content = `${truncate(event.content)} (${t(labelBy)} ${
|
|
47
|
-
|
|
48
|
-
})`;
|
|
46
|
+
const content = `${truncate(event.content)} (${t(labelBy)} ${event.contact
|
|
47
|
+
?.name})`;
|
|
49
48
|
|
|
50
49
|
return (
|
|
51
50
|
<g>
|
|
@@ -27,9 +27,9 @@ interface Props {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
const useLegend = ({ lines, setLinesGraph }: Props): LegendActions => {
|
|
30
|
-
const displayedLines = reject(propEq('display'
|
|
30
|
+
const displayedLines = reject(propEq(false, 'display'), lines);
|
|
31
31
|
const getLineByMetric = (metric_id: number): Line =>
|
|
32
|
-
find(propEq(
|
|
32
|
+
find(propEq(metric_id, 'metric_id'), lines) as Line;
|
|
33
33
|
|
|
34
34
|
const toggleMetricLine = (metric_id): void => {
|
|
35
35
|
const data = lines.map((line) => ({
|
|
@@ -92,7 +92,7 @@ const useLegend = ({ lines, setLinesGraph }: Props): LegendActions => {
|
|
|
92
92
|
|
|
93
93
|
const newLines = lines.map((line) => ({
|
|
94
94
|
...line,
|
|
95
|
-
display: find(propEq(
|
|
95
|
+
display: find(propEq(line.metric_id, 'metric_id'), lines)?.display ?? true
|
|
96
96
|
}));
|
|
97
97
|
|
|
98
98
|
setLinesGraph(newLines);
|
|
@@ -69,21 +69,24 @@ export const getDescription = ({ sections }: Description): string => {
|
|
|
69
69
|
})}<br></details>`;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
const formattedProps = props.reduce(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
72
|
+
const formattedProps = props.reduce(
|
|
73
|
+
(accumulator, currentValue, index) => {
|
|
74
|
+
const key = Object.keys(currentValue)[0];
|
|
75
|
+
const { description, type } = currentValue[key];
|
|
76
|
+
const body = `${accumulator} ${getBodyDescription({
|
|
77
|
+
description,
|
|
78
|
+
key,
|
|
79
|
+
type
|
|
80
|
+
})}`;
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
if (!equals(index, props.length - 1)) {
|
|
83
|
+
return body;
|
|
84
|
+
}
|
|
84
85
|
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
return `${body}</details>`;
|
|
87
|
+
},
|
|
88
|
+
getInitialValue({ section: name, type: item?.type })
|
|
89
|
+
);
|
|
87
90
|
|
|
88
91
|
return formattedProps as string;
|
|
89
92
|
});
|
|
@@ -14,7 +14,7 @@ import { LineChartData } from '../../common/models';
|
|
|
14
14
|
export const adjustGraphData = (graphData: LineChartData): LinesData => {
|
|
15
15
|
const lines = getLineData(graphData);
|
|
16
16
|
const sortedLines = sortBy(prop('name'), lines);
|
|
17
|
-
const displayedLines = reject(propEq('display'
|
|
17
|
+
const displayedLines = reject(propEq(false, 'display'), sortedLines);
|
|
18
18
|
|
|
19
19
|
const timeSeries = getTimeSeries(graphData);
|
|
20
20
|
|
|
@@ -39,8 +39,7 @@ import { Interval, ThresholdType, TooltipData } from './models';
|
|
|
39
39
|
import WrapperLineChart from './index';
|
|
40
40
|
|
|
41
41
|
const meta: Meta<typeof WrapperLineChart> = {
|
|
42
|
-
component: WrapperLineChart
|
|
43
|
-
tags: ['autodocs']
|
|
42
|
+
component: WrapperLineChart
|
|
44
43
|
};
|
|
45
44
|
export default meta;
|
|
46
45
|
|
|
@@ -353,6 +352,9 @@ export const LineChartWithTimePeriod: Story = {
|
|
|
353
352
|
end: defaultEnd,
|
|
354
353
|
height: 500,
|
|
355
354
|
start: defaultStart
|
|
355
|
+
},
|
|
356
|
+
parameters: {
|
|
357
|
+
chromatic: { diffThreshold: 0.1 }
|
|
356
358
|
}
|
|
357
359
|
};
|
|
358
360
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Thresholds } from '../common/models';
|
|
1
|
+
import { Thresholds as ThresholdsModel } from '../common/models';
|
|
2
2
|
|
|
3
3
|
import { ThresholdLine } from './ThresholdLine';
|
|
4
4
|
|
|
@@ -8,7 +8,7 @@ interface Props {
|
|
|
8
8
|
hideTooltip: () => void;
|
|
9
9
|
showTooltip: (args) => void;
|
|
10
10
|
size: 'small' | 'medium';
|
|
11
|
-
thresholds:
|
|
11
|
+
thresholds: ThresholdsModel;
|
|
12
12
|
xScale: (value: number) => number;
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -24,7 +24,21 @@ export const success: Story = {
|
|
|
24
24
|
critical: 'Critical',
|
|
25
25
|
warning: 'Warning'
|
|
26
26
|
},
|
|
27
|
-
thresholds:
|
|
27
|
+
thresholds: {
|
|
28
|
+
critical: [
|
|
29
|
+
{
|
|
30
|
+
label: 'Critical',
|
|
31
|
+
value: 1.5
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
enabled: true,
|
|
35
|
+
warning: [
|
|
36
|
+
{
|
|
37
|
+
label: 'Warning',
|
|
38
|
+
value: 0.5
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
28
42
|
},
|
|
29
43
|
render: Template
|
|
30
44
|
};
|
|
@@ -36,7 +50,21 @@ export const warning: Story = {
|
|
|
36
50
|
critical: 'Critical',
|
|
37
51
|
warning: 'Warning'
|
|
38
52
|
},
|
|
39
|
-
thresholds:
|
|
53
|
+
thresholds: {
|
|
54
|
+
critical: [
|
|
55
|
+
{
|
|
56
|
+
label: 'Critical',
|
|
57
|
+
value: 1.5
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
enabled: true,
|
|
61
|
+
warning: [
|
|
62
|
+
{
|
|
63
|
+
label: 'Warning',
|
|
64
|
+
value: 0.4
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
40
68
|
},
|
|
41
69
|
render: Template
|
|
42
70
|
};
|
|
@@ -48,7 +76,21 @@ export const critical: Story = {
|
|
|
48
76
|
critical: 'Critical',
|
|
49
77
|
warning: 'Warning'
|
|
50
78
|
},
|
|
51
|
-
thresholds:
|
|
79
|
+
thresholds: {
|
|
80
|
+
critical: [
|
|
81
|
+
{
|
|
82
|
+
label: 'Critical',
|
|
83
|
+
value: 0.3
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
enabled: true,
|
|
87
|
+
warning: [
|
|
88
|
+
{
|
|
89
|
+
label: 'Warning',
|
|
90
|
+
value: 0.2
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
}
|
|
52
94
|
},
|
|
53
95
|
render: Template
|
|
54
96
|
};
|
|
@@ -61,7 +103,21 @@ export const rawValue: Story = {
|
|
|
61
103
|
critical: 'Critical',
|
|
62
104
|
warning: 'Warning'
|
|
63
105
|
},
|
|
64
|
-
thresholds:
|
|
106
|
+
thresholds: {
|
|
107
|
+
critical: [
|
|
108
|
+
{
|
|
109
|
+
label: 'Critical',
|
|
110
|
+
value: 1.5
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
enabled: true,
|
|
114
|
+
warning: [
|
|
115
|
+
{
|
|
116
|
+
label: 'Warning',
|
|
117
|
+
value: 0.5
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
}
|
|
65
121
|
},
|
|
66
122
|
render: Template
|
|
67
123
|
};
|
|
@@ -179,7 +179,7 @@ const getMetricValuesForUnit = ({
|
|
|
179
179
|
) as Array<number>;
|
|
180
180
|
|
|
181
181
|
return pipe(
|
|
182
|
-
filter(propEq(
|
|
182
|
+
filter(propEq(unit, 'unit')) as (line) => Array<Line>,
|
|
183
183
|
map(prop('metric_id')),
|
|
184
184
|
map(getTimeSeriesValuesForMetric),
|
|
185
185
|
flatten,
|
|
@@ -203,7 +203,7 @@ const getLineForMetric = ({
|
|
|
203
203
|
lines,
|
|
204
204
|
metric_id
|
|
205
205
|
}: LineForMetricProps): Line | undefined =>
|
|
206
|
-
find(propEq(
|
|
206
|
+
find(propEq(metric_id, 'metric_id'), lines);
|
|
207
207
|
|
|
208
208
|
interface LinesTimeSeries {
|
|
209
209
|
lines: Array<Line>;
|
|
@@ -275,7 +275,7 @@ interface HasStackedLines {
|
|
|
275
275
|
}
|
|
276
276
|
|
|
277
277
|
const hasUnitStackedLines = ({ lines, unit }: HasStackedLines): boolean =>
|
|
278
|
-
pipe(getSortedStackedLines, any(propEq(
|
|
278
|
+
pipe(getSortedStackedLines, any(propEq(unit, 'unit')))(lines);
|
|
279
279
|
|
|
280
280
|
const getTimeSeriesForLines = ({
|
|
281
281
|
lines,
|
|
@@ -292,13 +292,16 @@ const ConnectedAutocompleteField = (
|
|
|
292
292
|
}
|
|
293
293
|
}, [optionsOpen]);
|
|
294
294
|
|
|
295
|
-
useEffect(
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
295
|
+
useEffect(
|
|
296
|
+
() => {
|
|
297
|
+
setSearchParameter(
|
|
298
|
+
!isEmpty(searchConditions)
|
|
299
|
+
? { conditions: searchConditions }
|
|
300
|
+
: undefined
|
|
301
|
+
);
|
|
302
|
+
},
|
|
303
|
+
useDeepCompare([searchConditions])
|
|
304
|
+
);
|
|
302
305
|
|
|
303
306
|
useEffect(() => {
|
|
304
307
|
if (!autocompleteChangedValue && !props?.value) {
|
|
@@ -49,7 +49,7 @@ const SortableListContent = ({
|
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
const itemIndex = findIndex(propEq(
|
|
52
|
+
const itemIndex = findIndex(propEq(id, 'id'), items);
|
|
53
53
|
|
|
54
54
|
itemHover?.(null);
|
|
55
55
|
itemClick?.({ index: itemIndex, item: { createOption, id, name } });
|
|
@@ -77,7 +77,7 @@ const DraggableAutocomplete = (
|
|
|
77
77
|
const deleteValue = (id): void => {
|
|
78
78
|
itemHover?.(null);
|
|
79
79
|
setSelectedValues((values: Array<DraggableSelectEntry>) => {
|
|
80
|
-
const index = findIndex(propEq(
|
|
80
|
+
const index = findIndex(propEq(id, 'id'), values);
|
|
81
81
|
|
|
82
82
|
const newSelectedValues = remove(index, 1, values);
|
|
83
83
|
|
|
@@ -141,126 +141,132 @@ type Multiple = boolean;
|
|
|
141
141
|
type DisableClearable = boolean;
|
|
142
142
|
type FreeSolo = boolean;
|
|
143
143
|
|
|
144
|
-
const AutocompleteField = (
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
144
|
+
const AutocompleteField = React.forwardRef(
|
|
145
|
+
(
|
|
146
|
+
{
|
|
147
|
+
options,
|
|
148
|
+
label,
|
|
149
|
+
placeholder,
|
|
150
|
+
loading = false,
|
|
151
|
+
onTextChange = (): void => undefined,
|
|
152
|
+
endAdornment = undefined,
|
|
153
|
+
inputValue,
|
|
154
|
+
displayOptionThumbnail = false,
|
|
155
|
+
required = false,
|
|
156
|
+
error,
|
|
157
|
+
displayPopupIcon = true,
|
|
158
|
+
autoFocus = false,
|
|
159
|
+
hideInput = false,
|
|
160
|
+
dataTestId,
|
|
161
|
+
autoSize = false,
|
|
162
|
+
autoSizeDefaultWidth = 0,
|
|
163
|
+
autoSizeCustomPadding,
|
|
164
|
+
getOptionItemLabel = (option) => option.name,
|
|
165
|
+
...autocompleteProps
|
|
166
|
+
}: Props,
|
|
167
|
+
ref?: React.ForwardedRef<HTMLDivElement>
|
|
168
|
+
): JSX.Element => {
|
|
169
|
+
const { classes, cx } = useStyles({ hideInput });
|
|
170
|
+
const { t } = useTranslation();
|
|
171
|
+
const theme = useTheme();
|
|
168
172
|
|
|
169
|
-
|
|
170
|
-
|
|
173
|
+
const areSelectEntriesEqual = (option, value): boolean => {
|
|
174
|
+
const identifyingProps = ['id', 'name'];
|
|
171
175
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
176
|
+
return equals(
|
|
177
|
+
pick(identifyingProps, option),
|
|
178
|
+
pick(identifyingProps, value)
|
|
179
|
+
);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const renderInput = (params): JSX.Element => (
|
|
183
|
+
<TextField
|
|
184
|
+
{...params}
|
|
185
|
+
InputLabelProps={{
|
|
186
|
+
classes: {
|
|
187
|
+
marginDense: classes.inputLabel,
|
|
188
|
+
shrink: classes.inputLabelShrink
|
|
189
|
+
}
|
|
190
|
+
}}
|
|
191
|
+
InputProps={{
|
|
192
|
+
...params.InputProps,
|
|
193
|
+
endAdornment: (
|
|
194
|
+
<>
|
|
195
|
+
{endAdornment && (
|
|
196
|
+
<InputAdornment position="end">{endAdornment}</InputAdornment>
|
|
197
|
+
)}
|
|
198
|
+
{params.InputProps.endAdornment}
|
|
199
|
+
</>
|
|
200
|
+
),
|
|
201
|
+
style: {
|
|
202
|
+
background: 'transparent',
|
|
203
|
+
paddingRight: theme.spacing(5)
|
|
204
|
+
}
|
|
205
|
+
}}
|
|
206
|
+
autoFocus={autoFocus}
|
|
207
|
+
autoSize={autoSize}
|
|
208
|
+
autoSizeCustomPadding={7 + (autoSizeCustomPadding || 0)}
|
|
209
|
+
autoSizeDefaultWidth={autoSizeDefaultWidth}
|
|
210
|
+
classes={{
|
|
211
|
+
root: classes.textfield
|
|
212
|
+
}}
|
|
213
|
+
error={error}
|
|
214
|
+
externalValueForAutoSize={autocompleteProps?.value?.name}
|
|
215
|
+
inputProps={{
|
|
216
|
+
...params.inputProps,
|
|
217
|
+
'aria-label': label,
|
|
218
|
+
'data-testid': dataTestId || label,
|
|
219
|
+
id: getNormalizedId(label || '')
|
|
220
|
+
}}
|
|
221
|
+
label={label}
|
|
222
|
+
placeholder={isNil(placeholder) ? t(searchLabel) : placeholder}
|
|
223
|
+
required={required}
|
|
224
|
+
value={inputValue || undefined}
|
|
225
|
+
onChange={onTextChange}
|
|
226
|
+
/>
|
|
175
227
|
);
|
|
176
|
-
};
|
|
177
228
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
)}
|
|
194
|
-
{params.InputProps.endAdornment}
|
|
195
|
-
</>
|
|
196
|
-
),
|
|
197
|
-
style: {
|
|
198
|
-
background: 'transparent',
|
|
199
|
-
paddingRight: theme.spacing(5)
|
|
229
|
+
return (
|
|
230
|
+
<Autocomplete
|
|
231
|
+
disableClearable
|
|
232
|
+
classes={{
|
|
233
|
+
groupLabel: classes.inputLabel,
|
|
234
|
+
inputRoot: cx([
|
|
235
|
+
classes.input,
|
|
236
|
+
label ? classes.inputWithLabel : classes.inputWithoutLabel
|
|
237
|
+
]),
|
|
238
|
+
popper: classes.popper,
|
|
239
|
+
root: classes.textfield
|
|
240
|
+
}}
|
|
241
|
+
forcePopupIcon={displayPopupIcon}
|
|
242
|
+
getOptionLabel={(option): string =>
|
|
243
|
+
(option as SelectEntry)?.name?.toString() || ''
|
|
200
244
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
...params.inputProps,
|
|
213
|
-
'aria-label': label,
|
|
214
|
-
'data-testid': dataTestId || label,
|
|
215
|
-
id: getNormalizedId(label || '')
|
|
216
|
-
}}
|
|
217
|
-
label={label}
|
|
218
|
-
placeholder={isNil(placeholder) ? t(searchLabel) : placeholder}
|
|
219
|
-
required={required}
|
|
220
|
-
value={inputValue || undefined}
|
|
221
|
-
onChange={onTextChange}
|
|
222
|
-
/>
|
|
223
|
-
);
|
|
224
|
-
|
|
225
|
-
return (
|
|
226
|
-
<Autocomplete
|
|
227
|
-
disableClearable
|
|
228
|
-
classes={{
|
|
229
|
-
groupLabel: classes.inputLabel,
|
|
230
|
-
inputRoot: cx([
|
|
231
|
-
classes.input,
|
|
232
|
-
label ? classes.inputWithLabel : classes.inputWithoutLabel
|
|
233
|
-
]),
|
|
234
|
-
popper: classes.popper,
|
|
235
|
-
root: classes.textfield
|
|
236
|
-
}}
|
|
237
|
-
forcePopupIcon={displayPopupIcon}
|
|
238
|
-
getOptionLabel={(option): string =>
|
|
239
|
-
(option as SelectEntry)?.name?.toString() || ''
|
|
240
|
-
}
|
|
241
|
-
isOptionEqualToValue={areSelectEntriesEqual}
|
|
242
|
-
loading={loading}
|
|
243
|
-
loadingText={<LoadingIndicator />}
|
|
244
|
-
options={options}
|
|
245
|
-
renderInput={renderInput}
|
|
246
|
-
renderOption={(props, option): JSX.Element => {
|
|
247
|
-
return (
|
|
248
|
-
<li
|
|
249
|
-
className={classes.options}
|
|
250
|
-
{...(props as React.HTMLAttributes<HTMLLIElement>)}
|
|
251
|
-
>
|
|
252
|
-
<Option
|
|
253
|
-
thumbnailUrl={displayOptionThumbnail ? option.url : undefined}
|
|
245
|
+
isOptionEqualToValue={areSelectEntriesEqual}
|
|
246
|
+
loading={loading}
|
|
247
|
+
loadingText={<LoadingIndicator />}
|
|
248
|
+
options={options}
|
|
249
|
+
ref={ref}
|
|
250
|
+
renderInput={renderInput}
|
|
251
|
+
renderOption={(props, option): JSX.Element => {
|
|
252
|
+
return (
|
|
253
|
+
<li
|
|
254
|
+
className={classes.options}
|
|
255
|
+
{...(props as React.HTMLAttributes<HTMLLIElement>)}
|
|
254
256
|
>
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
}
|
|
257
|
+
<Option
|
|
258
|
+
thumbnailUrl={displayOptionThumbnail ? option.url : undefined}
|
|
259
|
+
>
|
|
260
|
+
{getOptionItemLabel(option)}
|
|
261
|
+
</Option>
|
|
262
|
+
</li>
|
|
263
|
+
);
|
|
264
|
+
}}
|
|
265
|
+
size="small"
|
|
266
|
+
{...autocompleteProps}
|
|
267
|
+
/>
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
);
|
|
265
271
|
|
|
266
272
|
export default AutocompleteField;
|