@centreon/ui 24.4.57 → 24.4.59

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.
Files changed (147) hide show
  1. package/package.json +31 -38
  2. package/public/mockServiceWorker.js +1 -1
  3. package/src/Button/Icon/index.tsx +1 -1
  4. package/src/Button/Save/StartIcon.tsx +3 -3
  5. package/src/Button/Save/index.tsx +5 -9
  6. package/src/Checkbox/Checkbox.tsx +2 -2
  7. package/src/Checkbox/CheckboxGroup/index.tsx +2 -2
  8. package/src/Dashboard/Item.tsx +1 -1
  9. package/src/Dashboard/Layout.tsx +2 -2
  10. package/src/Dialog/Confirm/index.tsx +2 -10
  11. package/src/Dialog/index.tsx +2 -9
  12. package/src/FallbackPage/FallbackPage.tsx +3 -3
  13. package/src/FileDropZone/index.tsx +1 -3
  14. package/src/Form/Inputs/index.tsx +1 -3
  15. package/src/Form/Inputs/models.ts +1 -9
  16. package/src/Graph/Gauge/Gauge.tsx +1 -1
  17. package/src/Graph/HeatMap/HeatMap.stories.tsx +25 -0
  18. package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +2 -8
  19. package/src/Graph/LineChart/BasicComponents/Lines/Threshold/Circle.tsx +2 -2
  20. package/src/Graph/LineChart/BasicComponents/Thresholds.tsx +2 -2
  21. package/src/Graph/LineChart/BasicComponents/useFilterLines.ts +1 -1
  22. package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/GuidingLines.tsx +2 -2
  23. package/src/Graph/LineChart/InteractiveComponents/Annotations/EventAnnotations.tsx +1 -1
  24. package/src/Graph/LineChart/Legend/Legend.styles.ts +1 -1
  25. package/src/Graph/LineChart/Legend/LegendHeader.tsx +1 -1
  26. package/src/Graph/LineChart/Legend/useInteractiveValues.ts +2 -2
  27. package/src/Graph/LineChart/Legend/useLegend.ts +3 -3
  28. package/src/Graph/LineChart/helpers/doc.ts +13 -16
  29. package/src/Graph/LineChart/helpers/index.ts +1 -1
  30. package/src/Graph/LineChart/index.stories.tsx +2 -4
  31. package/src/Graph/LineChart/index.tsx +1 -1
  32. package/src/Graph/SingleBar/Thresholds.tsx +2 -2
  33. package/src/Graph/Text/Text.stories.tsx +4 -60
  34. package/src/Graph/Text/Text.tsx +1 -1
  35. package/src/Graph/common/timeSeries/index.ts +14 -22
  36. package/src/Graph/common/utils.ts +0 -19
  37. package/src/Graph/index.ts +0 -3
  38. package/src/InputField/Select/Autocomplete/Connected/index.tsx +7 -10
  39. package/src/InputField/Select/Autocomplete/Draggable/SortableList.tsx +1 -1
  40. package/src/InputField/Select/Autocomplete/Draggable/SortableListContent.tsx +1 -1
  41. package/src/InputField/Select/Autocomplete/Draggable/index.tsx +1 -1
  42. package/src/InputField/Select/Autocomplete/Multi/index.tsx +2 -4
  43. package/src/InputField/Select/Autocomplete/index.tsx +116 -129
  44. package/src/InputField/Select/IconPopover/index.tsx +2 -2
  45. package/src/InputField/Select/index.tsx +1 -12
  46. package/src/InputField/Text/index.tsx +2 -2
  47. package/src/Listing/ActionBar/index.tsx +8 -9
  48. package/src/Listing/Cell/DataCell.styles.ts +0 -3
  49. package/src/Listing/Cell/DataCell.tsx +5 -23
  50. package/src/Listing/Header/ListingHeader.tsx +1 -1
  51. package/src/Listing/Listing.cypress.spec.tsx +4 -80
  52. package/src/Listing/Listing.styles.ts +7 -4
  53. package/src/Listing/index.stories.tsx +3 -37
  54. package/src/Listing/index.test.tsx +1 -1
  55. package/src/Listing/index.tsx +3 -4
  56. package/src/Listing/models.ts +0 -1
  57. package/src/Module/index.tsx +4 -2
  58. package/src/PopoverMenu/index.tsx +5 -6
  59. package/src/RichTextEditor/RichTextEditor.tsx +1 -12
  60. package/src/SortableItems/index.tsx +7 -2
  61. package/src/ThemeProvider/index.tsx +0 -24
  62. package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.styles.ts +7 -6
  63. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +3 -8
  64. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +2 -0
  65. package/src/TimePeriods/DateTimePickerInput.tsx +19 -56
  66. package/src/TimePeriods/ResolutionTimePeriod.cypress.spec.tsx +9 -12
  67. package/src/TimePeriods/TimePeriods.cypress.spec.tsx +33 -9
  68. package/src/TimePeriods/helpers/index.ts +1 -1
  69. package/src/TimePeriods/index.stories.tsx +4 -12
  70. package/src/TimePeriods/index.tsx +2 -2
  71. package/src/Typography/FluidTypography/index.stories.tsx +2 -2
  72. package/src/Typography/FluidTypography/index.tsx +28 -21
  73. package/src/Typography/FluidTypography/useFluidResizeObserver.ts +56 -0
  74. package/src/api/QueryProvider.tsx +1 -1
  75. package/src/api/TestQueryProvider.tsx +1 -1
  76. package/src/api/index.ts +3 -3
  77. package/src/api/useFetchQuery/index.ts +23 -27
  78. package/src/api/useMutationQuery/index.test.ts +4 -4
  79. package/src/api/useMutationQuery/index.ts +25 -60
  80. package/src/components/Button/Icon/IconButton.tsx +2 -6
  81. package/src/components/DataTable/DataTable.stories.tsx +0 -40
  82. package/src/components/DataTable/DataTable.styles.ts +0 -3
  83. package/src/components/DataTable/DataTable.tsx +3 -3
  84. package/src/components/DataTable/Item/DataTableItem.styles.ts +2 -7
  85. package/src/components/DataTable/Item/DataTableItem.tsx +28 -9
  86. package/src/components/DataTable/index.ts +1 -3
  87. package/src/components/Form/AccessRights/ShareInput/ContactSwitch.tsx +3 -3
  88. package/src/components/Form/AccessRights/ShareInput/ShareInput.tsx +0 -1
  89. package/src/components/Form/Dashboard/DashboardForm.tsx +12 -15
  90. package/src/components/Layout/PageLayout/PageLayout.tsx +1 -1
  91. package/src/components/Layout/PageLayout/PageLayoutActions.tsx +0 -1
  92. package/src/components/Layout/PageLayout/PageLayoutBody.tsx +0 -1
  93. package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +1 -5
  94. package/src/components/Layout/PageLayout/index.ts +1 -3
  95. package/src/components/List/Item/ListItem.tsx +3 -3
  96. package/src/components/Modal/Modal.styles.ts +3 -8
  97. package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.stories.tsx +3 -3
  98. package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.tsx +1 -1
  99. package/src/components/Tooltip/ConfirmationTooltip/models.ts +1 -1
  100. package/src/index.ts +2 -2
  101. package/src/queryParameters/url/index.ts +1 -5
  102. package/src/screens/dashboard/DashboardsDetail.stories.tsx +108 -0
  103. package/src/screens/dashboard/DashboardsOverview.stories.tsx +281 -0
  104. package/src/utils/index.ts +1 -1
  105. package/src/utils/useDateTimePickerAdapter.ts +309 -0
  106. package/src/utils/useFullscreen/Fullscreen.cypress.spec.tsx +3 -1
  107. package/src/utils/useFullscreen/useFullscreenListener.ts +7 -10
  108. package/src/utils/useInfiniteScrollListing.ts +1 -4
  109. package/src/utils/{useLicenseExpirationWarning.test.tsx → useLicenseExpirationWarning.cypress.spec.tsx} +37 -48
  110. package/src/utils/useLicenseExpirationWarning.ts +18 -18
  111. package/src/Form/Form.cypress.spec.tsx +0 -133
  112. package/src/Form/Inputs/List/Content.tsx +0 -62
  113. package/src/Form/Inputs/List/List.styles.ts +0 -29
  114. package/src/Form/Inputs/List/List.tsx +0 -58
  115. package/src/Form/Inputs/List/useList.ts +0 -81
  116. package/src/Graph/BarStack/BarStack.cypress.spec.tsx +0 -154
  117. package/src/Graph/BarStack/BarStack.stories.tsx +0 -123
  118. package/src/Graph/BarStack/BarStack.styles.ts +0 -37
  119. package/src/Graph/BarStack/BarStack.tsx +0 -14
  120. package/src/Graph/BarStack/ResponsiveBarStack.tsx +0 -222
  121. package/src/Graph/BarStack/index.ts +0 -1
  122. package/src/Graph/BarStack/models.ts +0 -20
  123. package/src/Graph/BarStack/useResponsiveBarStack.ts +0 -137
  124. package/src/Graph/Gauge/Gauge.cypress.spec.tsx +0 -102
  125. package/src/Graph/HeatMap/HeatMap.cypress.spec.tsx +0 -145
  126. package/src/Graph/Legend/Legend.tsx +0 -21
  127. package/src/Graph/Legend/index.ts +0 -1
  128. package/src/Graph/Legend/models.ts +0 -11
  129. package/src/Graph/PieChart/PieChart.cypress.spec.tsx +0 -169
  130. package/src/Graph/PieChart/PieChart.stories.tsx +0 -194
  131. package/src/Graph/PieChart/PieChart.styles.ts +0 -39
  132. package/src/Graph/PieChart/PieChart.tsx +0 -14
  133. package/src/Graph/PieChart/ResponsivePie.tsx +0 -254
  134. package/src/Graph/PieChart/index.ts +0 -1
  135. package/src/Graph/PieChart/models.ts +0 -20
  136. package/src/Graph/PieChart/useResponsivePie.ts +0 -85
  137. package/src/Graph/SingleBar/SingleBar.cypress.spec.tsx +0 -121
  138. package/src/Graph/Text/Text.cypress.spec.tsx +0 -101
  139. package/src/Graph/common/testUtils.ts +0 -71
  140. package/src/Graph/translatedLabels.ts +0 -1
  141. package/src/Module/Module.cypress.spec.tsx +0 -129
  142. package/src/Typography/FluidTypography/FluidTypography.cypress.spec.tsx +0 -27
  143. package/src/components/DataTable/DataListing.tsx +0 -6
  144. package/src/components/DataTable/DataTable.cypress.spec.tsx +0 -193
  145. package/src/components/Layout/PageLayout/PageQuickAccess.tsx +0 -76
  146. package/src/components/Layout/PageLayout.cypress.spec.tsx +0 -66
  147. package/src/utils/usePluralizedTranslation.ts +0 -21
@@ -27,9 +27,9 @@ interface Props {
27
27
  }
28
28
 
29
29
  const useLegend = ({ lines, setLinesGraph }: Props): LegendActions => {
30
- const displayedLines = reject(propEq(false, 'display'), lines);
30
+ const displayedLines = reject(propEq('display', false), lines);
31
31
  const getLineByMetric = (metric_id: number): Line =>
32
- find(propEq(metric_id, 'metric_id'), lines) as Line;
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(line.metric_id, 'metric_id'), lines)?.display ?? true
95
+ display: find(propEq('metric_id', line.metric_id), lines)?.display ?? true
96
96
  }));
97
97
 
98
98
  setLinesGraph(newLines);
@@ -69,24 +69,21 @@ export const getDescription = ({ sections }: Description): string => {
69
69
  })}<br></details>`;
70
70
  }
71
71
 
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
- })}`;
72
+ const formattedProps = props.reduce((accumulator, currentValue, index) => {
73
+ const key = Object.keys(currentValue)[0];
74
+ const { description, type } = currentValue[key];
75
+ const body = `${accumulator} ${getBodyDescription({
76
+ description,
77
+ key,
78
+ type
79
+ })}`;
81
80
 
82
- if (!equals(index, props.length - 1)) {
83
- return body;
84
- }
81
+ if (!equals(index, props.length - 1)) {
82
+ return body;
83
+ }
85
84
 
86
- return `${body}</details>`;
87
- },
88
- getInitialValue({ section: name, type: item?.type })
89
- );
85
+ return `${body}</details>`;
86
+ }, getInitialValue({ section: name, type: item?.type }));
90
87
 
91
88
  return formattedProps as string;
92
89
  });
@@ -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(false, 'display'), sortedLines);
17
+ const displayedLines = reject(propEq('display', false), sortedLines);
18
18
 
19
19
  const timeSeries = getTimeSeries(graphData);
20
20
 
@@ -39,7 +39,8 @@ import { Interval, ThresholdType, TooltipData } from './models';
39
39
  import WrapperLineChart from './index';
40
40
 
41
41
  const meta: Meta<typeof WrapperLineChart> = {
42
- component: WrapperLineChart
42
+ component: WrapperLineChart,
43
+ tags: ['autodocs']
43
44
  };
44
45
  export default meta;
45
46
 
@@ -352,9 +353,6 @@ export const LineChartWithTimePeriod: Story = {
352
353
  end: defaultEnd,
353
354
  height: 500,
354
355
  start: defaultStart
355
- },
356
- parameters: {
357
- chromatic: { diffThreshold: 0.1 }
358
356
  }
359
357
  };
360
358
 
@@ -78,7 +78,7 @@ const WrapperLineChart = ({
78
78
  return (
79
79
  <div
80
80
  ref={lineChartRef as MutableRefObject<HTMLDivElement>}
81
- style={{ height: '100%', overflowY: 'hidden', width: '100%' }}
81
+ style={{ height: '100%', width: '100%' }}
82
82
  >
83
83
  <ParentSize>
84
84
  {({
@@ -1,4 +1,4 @@
1
- import { Thresholds as ThresholdsModel } from '../common/models';
1
+ import { Thresholds } 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: ThresholdsModel;
11
+ thresholds: Thresholds;
12
12
  xScale: (value: number) => number;
13
13
  }
14
14
 
@@ -24,21 +24,7 @@ export const success: Story = {
24
24
  critical: 'Critical',
25
25
  warning: 'Warning'
26
26
  },
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
- }
27
+ thresholds: [0.5, 1.5]
42
28
  },
43
29
  render: Template
44
30
  };
@@ -50,21 +36,7 @@ export const warning: Story = {
50
36
  critical: 'Critical',
51
37
  warning: 'Warning'
52
38
  },
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
- }
39
+ thresholds: [0.2, 0.5]
68
40
  },
69
41
  render: Template
70
42
  };
@@ -76,21 +48,7 @@ export const critical: Story = {
76
48
  critical: 'Critical',
77
49
  warning: 'Warning'
78
50
  },
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
- }
51
+ thresholds: [0.13, 0.35]
94
52
  },
95
53
  render: Template
96
54
  };
@@ -103,21 +61,7 @@ export const rawValue: Story = {
103
61
  critical: 'Critical',
104
62
  warning: 'Warning'
105
63
  },
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
- }
64
+ thresholds: [0.5, 1.5]
121
65
  },
122
66
  render: Template
123
67
  };
@@ -11,7 +11,7 @@ import { getColorFromDataAndTresholds } from '../common/utils';
11
11
 
12
12
  import { useTextStyles } from './Text.styles';
13
13
 
14
- export interface Props {
14
+ interface Props {
15
15
  baseColor?: string;
16
16
  data?: LineChartData;
17
17
  displayAsRaw?: boolean;
@@ -179,7 +179,7 @@ const getMetricValuesForUnit = ({
179
179
  ) as Array<number>;
180
180
 
181
181
  return pipe(
182
- filter(propEq(unit, 'unit')) as (line) => Array<Line>,
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(metric_id, 'metric_id'), lines);
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(unit, 'unit')))(lines);
278
+ pipe(getSortedStackedLines, any(propEq('unit', unit)))(lines);
279
279
 
280
280
  const getTimeSeriesForLines = ({
281
281
  lines,
@@ -476,7 +476,15 @@ const registerMsUnitToNumeral = (): null => {
476
476
 
477
477
  registerMsUnitToNumeral();
478
478
 
479
- const getBase1024 = ({ unit, base }): boolean => {
479
+ const formatMetricValue = ({
480
+ value,
481
+ unit,
482
+ base = 1000
483
+ }: FormatMetricValueProps): string | null => {
484
+ if (isNil(value)) {
485
+ return null;
486
+ }
487
+
480
488
  const base2Units = [
481
489
  'B',
482
490
  'bytes',
@@ -489,19 +497,7 @@ const getBase1024 = ({ unit, base }): boolean => {
489
497
  'b'
490
498
  ];
491
499
 
492
- return base2Units.includes(unit) || Number(base) === 1024;
493
- };
494
-
495
- const formatMetricValue = ({
496
- value,
497
- unit,
498
- base = 1000
499
- }: FormatMetricValueProps): string | null => {
500
- if (isNil(value)) {
501
- return null;
502
- }
503
-
504
- const base1024 = getBase1024({ base, unit });
500
+ const base1024 = base2Units.includes(unit) || Number(base) === 1024;
505
501
 
506
502
  const formatSuffix = cond([
507
503
  [equals('ms'), always(' ms')],
@@ -529,8 +525,6 @@ const formatMetricValueWithUnit = ({
529
525
  return null;
530
526
  }
531
527
 
532
- const base1024 = getBase1024({ base, unit });
533
-
534
528
  if (isRaw) {
535
529
  const unitText = equals('%', unit) ? unit : ` ${unit}`;
536
530
 
@@ -543,9 +537,7 @@ const formatMetricValueWithUnit = ({
543
537
 
544
538
  const formattedMetricValue = formatMetricValue({ base, unit, value });
545
539
 
546
- return base1024 || !unit || equals(unit, 'ms')
547
- ? formattedMetricValue
548
- : `${formattedMetricValue} ${unit}`;
540
+ return formattedMetricValue;
549
541
  };
550
542
 
551
543
  const getStackedYScale = ({
@@ -11,7 +11,6 @@ import {
11
11
  lte,
12
12
  pluck
13
13
  } from 'ramda';
14
- import numeral from 'numeral';
15
14
 
16
15
  import { Theme } from '@mui/material';
17
16
 
@@ -74,21 +73,3 @@ export const getColorFromDataAndTresholds = ({
74
73
  [T, always(theme.palette.error.main)]
75
74
  ])(data);
76
75
  };
77
-
78
- interface ValueByUnitProps {
79
- total: number;
80
- unit: 'percentage' | 'number';
81
- value: number;
82
- }
83
-
84
- export const getValueByUnit = ({
85
- unit,
86
- value,
87
- total
88
- }: ValueByUnitProps): string => {
89
- if (equals(unit, 'number')) {
90
- return numeral(value).format('0a').toUpperCase();
91
- }
92
-
93
- return `${((value * 100) / total).toFixed(1)}%`;
94
- };
@@ -2,7 +2,4 @@ export { default as LineChart } from './LineChart';
2
2
  export { Gauge } from './Gauge';
3
3
  export { SingleBar } from './SingleBar';
4
4
  export { Text as GraphText } from './Text';
5
-
6
5
  export { HeatMap } from './HeatMap';
7
- export { BarStack } from './BarStack';
8
- export { PieChart } from './PieChart';
@@ -292,16 +292,13 @@ const ConnectedAutocompleteField = (
292
292
  }
293
293
  }, [optionsOpen]);
294
294
 
295
- useEffect(
296
- () => {
297
- setSearchParameter(
298
- !isEmpty(searchConditions)
299
- ? { conditions: searchConditions }
300
- : undefined
301
- );
302
- },
303
- useDeepCompare([searchConditions])
304
- );
295
+ useEffect(() => {
296
+ setSearchParameter(
297
+ !isEmpty(searchConditions)
298
+ ? { conditions: searchConditions }
299
+ : undefined
300
+ );
301
+ }, useDeepCompare([searchConditions]));
305
302
 
306
303
  useEffect(() => {
307
304
  if (!autocompleteChangedValue && !props?.value) {
@@ -49,7 +49,7 @@ const SortableList = ({
49
49
  const dragEnd = ({ items: newItems }): void =>
50
50
  changeItemsOrder(
51
51
  map(
52
- (item) => find(propEq(item, 'id'), items),
52
+ (item) => find(propEq('id', item), items),
53
53
  newItems
54
54
  ) as Array<DraggableSelectEntry>
55
55
  );
@@ -49,7 +49,7 @@ const SortableListContent = ({
49
49
  return;
50
50
  }
51
51
 
52
- const itemIndex = findIndex(propEq(id, 'id'), items);
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(id, 'id'), values);
80
+ const index = findIndex(propEq('id', id), values);
81
81
 
82
82
  const newSelectedValues = remove(index, 1, values);
83
83
 
@@ -1,4 +1,4 @@
1
- import { includes, map, prop, reject, sortBy, toLower, compose } from 'ramda';
1
+ import { includes, map, prop, reject } from 'ramda';
2
2
  import { makeStyles } from 'tss-react/mui';
3
3
 
4
4
  import { Chip, ChipProps, Tooltip } from '@mui/material';
@@ -85,11 +85,9 @@ const MultiAutocompleteField = ({
85
85
  return includes(id, valueIds);
86
86
  };
87
87
 
88
- const sortByName = sortBy(compose(toLower, prop(optionProperty)));
89
-
90
88
  const autocompleteOptions = disableSortedOptions
91
89
  ? options
92
- : sortByName([...values, ...reject(isOptionSelected, options)]);
90
+ : [...values, ...reject(isOptionSelected, options)];
93
91
 
94
92
  return (
95
93
  <Autocomplete
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
 
3
- import { equals, isEmpty, isNil, pick } from 'ramda';
3
+ import { equals, isNil, pick } from 'ramda';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { makeStyles } from 'tss-react/mui';
6
6
 
@@ -141,139 +141,126 @@ type Multiple = boolean;
141
141
  type DisableClearable = boolean;
142
142
  type FreeSolo = boolean;
143
143
 
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();
144
+ const AutocompleteField = ({
145
+ options,
146
+ label,
147
+ placeholder,
148
+ loading = false,
149
+ onTextChange = (): void => undefined,
150
+ endAdornment = undefined,
151
+ inputValue,
152
+ displayOptionThumbnail = false,
153
+ required = false,
154
+ error,
155
+ displayPopupIcon = true,
156
+ autoFocus = false,
157
+ hideInput = false,
158
+ dataTestId,
159
+ autoSize = false,
160
+ autoSizeDefaultWidth = 0,
161
+ autoSizeCustomPadding,
162
+ getOptionItemLabel = (option) => option.name,
163
+ ...autocompleteProps
164
+ }: Props): JSX.Element => {
165
+ const { classes, cx } = useStyles({ hideInput });
166
+ const { t } = useTranslation();
167
+ const theme = useTheme();
172
168
 
173
- const areSelectEntriesEqual = (option, value): boolean => {
174
- const identifyingProps = ['id', 'name'];
169
+ const areSelectEntriesEqual = (option, value): boolean => {
170
+ const identifyingProps = ['id', 'name'];
175
171
 
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
- minWidth: 0,
204
- padding: theme.spacing(
205
- 0.75,
206
- isEmpty(placeholder) ? 0 : 5,
207
- 0.75,
208
- 0.75
209
- )
210
- }
211
- }}
212
- autoFocus={autoFocus}
213
- autoSize={autoSize}
214
- autoSizeCustomPadding={7 + (autoSizeCustomPadding || 0)}
215
- autoSizeDefaultWidth={autoSizeDefaultWidth}
216
- classes={{
217
- root: classes.textfield
218
- }}
219
- error={error}
220
- externalValueForAutoSize={autocompleteProps?.value?.name}
221
- inputProps={{
222
- ...params.inputProps,
223
- 'aria-label': label,
224
- 'data-testid': dataTestId || label,
225
- id: getNormalizedId(label || ''),
226
- ...autocompleteProps?.inputProps
227
- }}
228
- label={label}
229
- placeholder={isNil(placeholder) ? t(searchLabel) : placeholder}
230
- required={required}
231
- value={inputValue || undefined}
232
- onChange={onTextChange}
233
- />
172
+ return equals(
173
+ pick(identifyingProps, option),
174
+ pick(identifyingProps, value)
234
175
  );
176
+ };
235
177
 
236
- return (
237
- <Autocomplete
238
- disableClearable
239
- classes={{
240
- groupLabel: classes.inputLabel,
241
- inputRoot: cx([
242
- classes.input,
243
- label ? classes.inputWithLabel : classes.inputWithoutLabel
244
- ]),
245
- popper: classes.popper,
246
- root: classes.textfield
247
- }}
248
- forcePopupIcon={displayPopupIcon}
249
- getOptionLabel={(option): string =>
250
- (option as SelectEntry)?.name?.toString() || ''
178
+ const renderInput = (params): JSX.Element => (
179
+ <TextField
180
+ {...params}
181
+ InputLabelProps={{
182
+ classes: {
183
+ marginDense: classes.inputLabel,
184
+ shrink: classes.inputLabelShrink
185
+ }
186
+ }}
187
+ InputProps={{
188
+ ...params.InputProps,
189
+ endAdornment: (
190
+ <>
191
+ {endAdornment && (
192
+ <InputAdornment position="end">{endAdornment}</InputAdornment>
193
+ )}
194
+ {params.InputProps.endAdornment}
195
+ </>
196
+ ),
197
+ style: {
198
+ background: 'transparent',
199
+ paddingRight: theme.spacing(5)
251
200
  }
252
- isOptionEqualToValue={areSelectEntriesEqual}
253
- loading={loading}
254
- loadingText={<LoadingIndicator />}
255
- options={options}
256
- ref={ref}
257
- renderInput={renderInput}
258
- renderOption={(props, option): JSX.Element => {
259
- return (
260
- <li
261
- className={classes.options}
262
- {...(props as React.HTMLAttributes<HTMLLIElement>)}
201
+ }}
202
+ autoFocus={autoFocus}
203
+ autoSize={autoSize}
204
+ autoSizeCustomPadding={7 + (autoSizeCustomPadding || 0)}
205
+ autoSizeDefaultWidth={autoSizeDefaultWidth}
206
+ classes={{
207
+ root: classes.textfield
208
+ }}
209
+ error={error}
210
+ externalValueForAutoSize={autocompleteProps?.value?.name}
211
+ inputProps={{
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}
263
254
  >
264
- <Option
265
- thumbnailUrl={displayOptionThumbnail ? option.url : undefined}
266
- >
267
- {getOptionItemLabel(option)}
268
- </Option>
269
- </li>
270
- );
271
- }}
272
- size="small"
273
- {...autocompleteProps}
274
- />
275
- );
276
- }
277
- );
255
+ {getOptionItemLabel(option)}
256
+ </Option>
257
+ </li>
258
+ );
259
+ }}
260
+ size="small"
261
+ {...autocompleteProps}
262
+ />
263
+ );
264
+ };
278
265
 
279
266
  export default AutocompleteField;