@centreon/ui 26.5.14 → 26.5.15
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 +6 -1
- package/src/ActionsList/ActionsList.styles.ts +2 -1
- package/src/ActionsList/index.tsx +1 -1
- package/src/Button/Icon/index.tsx +1 -1
- package/src/Button/Save/useSave.tsx +2 -1
- package/src/Checkbox/Checkbox.tsx +14 -9
- package/src/Checkbox/CheckboxGroup/index.tsx +1 -1
- package/src/Colors/index.tsx +12 -2
- package/src/Dashboard/Item.tsx +1 -1
- package/src/Dialog/Duplicate/index.tsx +5 -3
- package/src/Dialog/index.tsx +4 -1
- package/src/Form/Inputs/Autocomplete.tsx +30 -19
- package/src/Form/Inputs/ConnectedAutocomplete.tsx +27 -9
- package/src/Form/Inputs/FieldsTable/FieldsTable.tsx +24 -13
- package/src/Form/Inputs/FieldsTable/Row.tsx +7 -1
- package/src/Form/Inputs/List/Content.tsx +2 -2
- package/src/Form/Inputs/List/List.tsx +2 -1
- package/src/Form/Inputs/List/useList.ts +1 -1
- package/src/Form/Inputs/Radio.tsx +4 -1
- package/src/Form/Inputs/models.ts +42 -8
- package/src/Form/Section/PanelTabs.tsx +1 -1
- package/src/Form/storiesData.tsx +2 -2
- package/src/Graph/BarChart/Bar.tsx +39 -5
- package/src/Graph/BarChart/BarGroup.tsx +9 -5
- package/src/Graph/BarChart/BarStack.tsx +17 -4
- package/src/Graph/BarChart/useBarStack.ts +16 -8
- package/src/Graph/BarStack/Graph.tsx +21 -5
- package/src/Graph/BarStack/GraphAndLegend.tsx +2 -1
- package/src/Graph/BarStack/models.ts +23 -3
- package/src/Graph/BarStack/useGraphAndLegend.ts +10 -6
- package/src/Graph/BarStack/useResponsiveBarStack.ts +2 -1
- package/src/Graph/Chart/BasicComponents/Lines/Point.tsx +2 -1
- package/src/Graph/Chart/BasicComponents/Lines/RegularLines/index.tsx +4 -3
- package/src/Graph/Chart/BasicComponents/Lines/RegularLines/useRegularLines.ts +1 -1
- package/src/Graph/Chart/BasicComponents/Lines/StackedLines/index.tsx +4 -5
- package/src/Graph/Chart/BasicComponents/Lines/StackedLines/useStackedLines.ts +10 -1
- package/src/Graph/Chart/BasicComponents/Lines/Threshold/index.tsx +13 -4
- package/src/Graph/Chart/BasicComponents/Lines/Threshold/models.ts +2 -2
- package/src/Graph/Chart/BasicComponents/Lines/index.tsx +2 -10
- package/src/Graph/Chart/InteractiveComponents/AnchorPoint/StackedAnchorPoint.tsx +7 -3
- package/src/Graph/Chart/InteractiveComponents/AnchorPoint/models.ts +2 -2
- package/src/Graph/Chart/InteractiveComponents/AnchorPoint/useTickGraph.ts +4 -4
- package/src/Graph/Chart/InteractiveComponents/Annotations/Annotation/Area.tsx +9 -1
- package/src/Graph/Chart/InteractiveComponents/Annotations/Annotation/Line.tsx +9 -1
- package/src/Graph/Chart/InteractiveComponents/Annotations/EventAnnotations.tsx +9 -1
- package/src/Graph/Chart/InteractiveComponents/Annotations/useAnnotation.ts +1 -5
- package/src/Graph/Chart/InteractiveComponents/Tooltip/useGraphTooltip.ts +2 -2
- package/src/Graph/Chart/InteractiveComponents/index.tsx +8 -8
- package/src/Graph/Chart/Legend/LegendHeader.tsx +6 -1
- package/src/Graph/Chart/Legend/index.tsx +4 -1
- package/src/Graph/Chart/Legend/useLegend.ts +2 -2
- package/src/Graph/Chart/helpers/doc.ts +11 -1
- package/src/Graph/Chart/models.ts +2 -2
- package/src/Graph/Chart/useChartData.ts +4 -3
- package/src/Graph/Chart/useChartIntersection.ts +5 -1
- package/src/Graph/Gauge/AnimatedPie.tsx +7 -2
- package/src/Graph/Gauge/models.ts +7 -1
- package/src/Graph/PieChart/ResponsivePie.tsx +7 -1
- package/src/Graph/PieChart/models.ts +22 -3
- package/src/Graph/PieChart/useResponsivePie.ts +3 -2
- package/src/Graph/SingleBar/ThresholdLine.tsx +5 -1
- package/src/Graph/SingleBar/Thresholds.tsx +5 -1
- package/src/Graph/Timeline/ResponsiveTimeline.tsx +2 -2
- package/src/Graph/Timeline/useTimeline.ts +2 -1
- package/src/Graph/Tree/DescendantNodes.tsx +4 -3
- package/src/Graph/Tree/Tree.tsx +7 -1
- package/src/Graph/Tree/models.ts +2 -2
- package/src/Graph/common/Axes/UnitLabel.tsx +1 -1
- package/src/Graph/common/Axes/index.tsx +15 -6
- package/src/Graph/common/Axes/useAxisY.ts +3 -3
- package/src/Graph/common/BaseChart/AdditionalLine.tsx +2 -1
- package/src/Graph/common/BaseChart/ChartSvgWrapper.tsx +7 -3
- package/src/Graph/common/Grids/index.tsx +9 -3
- package/src/Graph/common/Thresholds/ThresholdLine.tsx +7 -1
- package/src/Graph/common/Thresholds/Thresholds.tsx +7 -1
- package/src/Graph/common/models.ts +9 -1
- package/src/Graph/common/timeSeries/index.test.ts +1 -1
- package/src/Graph/common/timeSeries/index.ts +72 -26
- package/src/Graph/common/timeSeries/models.ts +1 -1
- package/src/Graph/common/utils.ts +3 -1
- package/src/Image/useLoadImage.ts +6 -1
- package/src/InputField/Search/RegexpHelpTooltip.tsx +3 -1
- package/src/InputField/Select/Autocomplete/Connected/Multi/utils/index.ts +4 -1
- package/src/InputField/Select/Autocomplete/Connected/index.test.tsx +7 -2
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +70 -26
- package/src/InputField/Select/Autocomplete/Draggable/SortableList.tsx +2 -2
- package/src/InputField/Select/Autocomplete/Draggable/SortableListContent.tsx +6 -4
- package/src/InputField/Select/Autocomplete/Draggable/index.tsx +35 -10
- package/src/InputField/Select/Autocomplete/Multi/Listbox.tsx +12 -2
- package/src/InputField/Select/Autocomplete/Multi/Multi.tsx +15 -8
- package/src/InputField/Select/Autocomplete/Popover/index.tsx +5 -2
- package/src/InputField/Select/Autocomplete/index.tsx +23 -10
- package/src/InputField/Select/IconPopover/index.tsx +8 -5
- package/src/InputField/Select/index.tsx +4 -3
- package/src/InputField/Text/index.tsx +1 -1
- package/src/InputField/Text/useAutoSize.ts +0 -2
- package/src/Listing/ActionBar/ColumnMultiSelect.tsx +2 -2
- package/src/Listing/ActionBar/Pagination.tsx +4 -2
- package/src/Listing/ActionBar/PaginationActions.tsx +12 -4
- package/src/Listing/ActionBar/index.tsx +19 -7
- package/src/Listing/Cell/DataCell.tsx +3 -3
- package/src/Listing/Cell/index.tsx +26 -13
- package/src/Listing/Header/Cell/ListingHeaderCell.tsx +2 -2
- package/src/Listing/Header/Cell/SelectActionListingHeaderCell.tsx +6 -4
- package/src/Listing/Header/ListingHeader.tsx +2 -2
- package/src/Listing/Header/_internals/PredefinedSelectionList.tsx +3 -1
- package/src/Listing/Row/Row.tsx +3 -3
- package/src/Listing/index.tsx +48 -28
- package/src/Listing/models.ts +11 -9
- package/src/MultiSelectEntries/index.tsx +3 -3
- package/src/Pagination/Pagination.tsx +3 -1
- package/src/Panel/index.tsx +2 -2
- package/src/PopoverMenu/index.tsx +3 -3
- package/src/RichTextEditor/ContentEditable.tsx +2 -1
- package/src/RichTextEditor/RichTextEditor.tsx +1 -1
- package/src/RichTextEditor/plugins/FloatingLinkEditorPlugin.tsx +16 -14
- package/src/RichTextEditor/plugins/ToolbarPlugin/BlockButtons.tsx +3 -3
- package/src/RichTextEditor/plugins/ToolbarPlugin/ListButton.tsx +1 -1
- package/src/RichTextEditor/plugins/ToolbarPlugin/MacrosButton.tsx +1 -1
- package/src/Snackbar/SnackbarProvider.tsx +1 -1
- package/src/Snackbar/index.tsx +4 -2
- package/src/Snackbar/useSnackbar.tsx +14 -4
- package/src/SortableItems/index.tsx +4 -4
- package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.tsx +1 -1
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +1 -1
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/usePickersStartEndDate.ts +9 -3
- package/src/TimePeriods/CustomTimePeriod/index.tsx +7 -2
- package/src/TimePeriods/helpers/index.ts +7 -2
- package/src/TimePeriods/models.ts +4 -1
- package/src/TimePeriods/useTimePeriod.ts +0 -2
- package/src/Wizard/ActionsBar.tsx +1 -1
- package/src/Wizard/index.test.tsx +0 -66
- package/src/Wizard/index.tsx +10 -5
- package/src/Wizard/models.ts +1 -1
- package/src/api/buildListingEndpoint/getSearchQueryParameterValue.ts +2 -1
- package/src/api/buildListingEndpoint/index.ts +7 -1
- package/src/api/customFetch.ts +3 -3
- package/src/api/useBulkResponse.ts +31 -9
- package/src/api/useFetchQuery/index.ts +28 -6
- package/src/api/useGraphQuery/index.ts +1 -1
- package/src/api/useRequest/index.ts +7 -7
- package/src/components/Button/Button.tsx +1 -1
- package/src/components/Button/Icon/IconButton.tsx +1 -1
- package/src/components/CrudPage/Listing.tsx +3 -3
- package/src/components/CrudPage/utils.ts +1 -1
- package/src/components/Form/AccessRights/AccessRights.tsx +4 -1
- package/src/components/Form/AccessRights/Actions/Actions.tsx +4 -1
- package/src/components/Form/AccessRights/ShareInput/ShareInput.tsx +1 -1
- package/src/components/Form/AccessRights/ShareInput/useShareInput.tsx +35 -13
- package/src/components/Form/AccessRights/common/RoleSelectField.tsx +1 -1
- package/src/components/Form/AccessRights/storiesData.ts +2 -2
- package/src/components/ItemComposition/ItemComposition.tsx +1 -1
- package/src/components/Menu/Button/MenuButton.tsx +1 -1
- package/src/components/Menu/useMenu.tsx +3 -1
- package/src/components/Tabs/Tabs.tsx +1 -1
- package/src/components/Tooltip/ConfirmationTooltip/models.ts +5 -1
- package/src/components/Zoom/useMinimap.ts +16 -10
- package/src/components/Zoom/useZoom.ts +12 -6
- package/src/components/Zoom/utils.ts +3 -1
- package/src/queryParameters/index.ts +8 -2
- package/src/utils/resourcesStatusURL.ts +20 -3
- package/src/utils/translatedLabel.ts +4 -2
- package/src/utils/useDebounce.ts +10 -9
- package/src/utils/useInfiniteScrollListing.ts +2 -2
- package/src/utils/useIntersectionObserver.ts +2 -2
- package/src/utils/useLicenseExpirationWarning.test.tsx +4 -2
- package/src/utils/useLoadImage.tsx +7 -2
- package/src/utils/useLocaleDateTimeFormat/index.test.tsx +2 -3
- package/src/utils/useLocaleDateTimeFormat/localeFallback.test.tsx +2 -3
- package/test/testRenderer.tsx +9 -5
|
@@ -4,11 +4,17 @@ import { equals } from 'ramda';
|
|
|
4
4
|
|
|
5
5
|
import { margin } from '../../Chart/common';
|
|
6
6
|
|
|
7
|
+
interface ShowTooltipArgs {
|
|
8
|
+
tooltipData: string;
|
|
9
|
+
tooltipLeft: number;
|
|
10
|
+
tooltipTop: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
7
13
|
interface Props {
|
|
8
14
|
hideTooltip: () => void;
|
|
9
15
|
isHorizontal: boolean;
|
|
10
16
|
label: string;
|
|
11
|
-
showTooltip: (args) => void;
|
|
17
|
+
showTooltip: (args: ShowTooltipArgs) => void;
|
|
12
18
|
thresholdType: string;
|
|
13
19
|
value: number;
|
|
14
20
|
width: number;
|
|
@@ -6,11 +6,17 @@ import { getUnits, getYScale } from '../timeSeries';
|
|
|
6
6
|
import type { Line } from '../timeSeries/models';
|
|
7
7
|
import { ThresholdLine } from './ThresholdLine';
|
|
8
8
|
|
|
9
|
+
interface ShowTooltipArgs {
|
|
10
|
+
tooltipData: string;
|
|
11
|
+
tooltipLeft: number;
|
|
12
|
+
tooltipTop: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
interface Props {
|
|
10
16
|
displayedLines: Array<Line>;
|
|
11
17
|
hideTooltip: () => void;
|
|
12
18
|
isHorizontal?: boolean;
|
|
13
|
-
showTooltip: (props) => void;
|
|
19
|
+
showTooltip: (props: ShowTooltipArgs) => void;
|
|
14
20
|
thresholdUnit?: string;
|
|
15
21
|
thresholds: ThresholdsModel;
|
|
16
22
|
width: number;
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import type { Metric } from './timeSeries/models';
|
|
2
2
|
|
|
3
|
+
export interface LineChartGlobal {
|
|
4
|
+
base?: number;
|
|
5
|
+
title?: string;
|
|
6
|
+
'lower-limit'?: number;
|
|
7
|
+
'upper-limit'?: number;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
|
|
3
11
|
export interface LineChartData {
|
|
4
|
-
global;
|
|
12
|
+
global: LineChartGlobal;
|
|
5
13
|
metrics: Array<Metric>;
|
|
6
14
|
times: Array<string>;
|
|
7
15
|
}
|
|
@@ -68,10 +68,12 @@ const defaultDsData = {
|
|
|
68
68
|
const toTimeTickWithMetrics = ({
|
|
69
69
|
metrics,
|
|
70
70
|
times
|
|
71
|
+
}: {
|
|
72
|
+
metrics: Array<Metric>;
|
|
73
|
+
times: Array<string>;
|
|
71
74
|
}): Array<TimeTickWithMetrics> =>
|
|
72
|
-
// @ts-expect-error - suppressing pre-existing type mismatch
|
|
73
75
|
map(
|
|
74
|
-
(timeTick) => ({
|
|
76
|
+
(timeTick: string) => ({
|
|
75
77
|
metrics,
|
|
76
78
|
timeTick
|
|
77
79
|
}),
|
|
@@ -83,10 +85,14 @@ const toTimeTickValue = (
|
|
|
83
85
|
timeIndex: number
|
|
84
86
|
): TimeValue => {
|
|
85
87
|
const getMetricsForIndex = (): Omit<TimeValue, 'timeTick'> => {
|
|
86
|
-
const addMetricForTimeIndex = (
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
const addMetricForTimeIndex = (
|
|
89
|
+
acc: TimeValue,
|
|
90
|
+
{ metric_id, data }: Metric
|
|
91
|
+
): TimeValue =>
|
|
92
|
+
({
|
|
93
|
+
...acc,
|
|
94
|
+
[metric_id]: data[timeIndex] === undefined ? null : data[timeIndex]
|
|
95
|
+
}) as TimeValue;
|
|
90
96
|
|
|
91
97
|
return reduce(addMetricForTimeIndex, {} as TimeValue, metrics);
|
|
92
98
|
};
|
|
@@ -95,14 +101,14 @@ const toTimeTickValue = (
|
|
|
95
101
|
};
|
|
96
102
|
|
|
97
103
|
const getTimeSeries = (graphData: LineChartData): Array<TimeValue> => {
|
|
98
|
-
const isGreaterThanLowerLimit = (value): boolean => {
|
|
104
|
+
const isGreaterThanLowerLimit = (value: number | null): boolean => {
|
|
99
105
|
const lowerLimit = path<number>(['global', 'lower-limit'], graphData);
|
|
100
106
|
|
|
101
107
|
if (isNil(lowerLimit)) {
|
|
102
108
|
return true;
|
|
103
109
|
}
|
|
104
110
|
|
|
105
|
-
return value >= lowerLimit;
|
|
111
|
+
return value !== null && value >= lowerLimit;
|
|
106
112
|
};
|
|
107
113
|
|
|
108
114
|
const rejectLowerThanLimit = ({
|
|
@@ -202,14 +208,14 @@ const getMetricValuesForUnit = ({
|
|
|
202
208
|
timeSeries,
|
|
203
209
|
unit
|
|
204
210
|
}: ValuesForUnitProps): Array<number> => {
|
|
205
|
-
const getTimeSeriesValuesForMetric = (metric_id): Array<number> =>
|
|
211
|
+
const getTimeSeriesValuesForMetric = (metric_id: number): Array<number> =>
|
|
206
212
|
map(
|
|
207
213
|
(timeValue) => getValueForMetric(timeValue)(metric_id),
|
|
208
214
|
timeSeries
|
|
209
215
|
) as Array<number>;
|
|
210
216
|
|
|
211
217
|
return pipe(
|
|
212
|
-
filter(propEq(unit, 'unit')) as (line) => Array<Line>,
|
|
218
|
+
filter(propEq(unit, 'unit')) as (line: Array<Line>) => Array<Line>,
|
|
213
219
|
map(prop('metric_id')),
|
|
214
220
|
map(getTimeSeriesValuesForMetric),
|
|
215
221
|
flatten,
|
|
@@ -266,7 +272,7 @@ const getStackedMetricValues = ({
|
|
|
266
272
|
lines,
|
|
267
273
|
timeSeries
|
|
268
274
|
}: LinesTimeSeries): Array<number> => {
|
|
269
|
-
const getTimeSeriesValuesForMetric = (metric_id): Array<number> =>
|
|
275
|
+
const getTimeSeriesValuesForMetric = (metric_id: number): Array<number> =>
|
|
270
276
|
map(
|
|
271
277
|
(timeValue) => getValueForMetric(timeValue)(metric_id) || 0,
|
|
272
278
|
timeSeries
|
|
@@ -274,7 +280,7 @@ const getStackedMetricValues = ({
|
|
|
274
280
|
|
|
275
281
|
const metricsValues = pipe(
|
|
276
282
|
// @ts-expect-error - suppressing pre-existing type mismatch
|
|
277
|
-
map(prop('metric_id')) as (metric) => Array<number>,
|
|
283
|
+
map(prop('metric_id')) as (metric: unknown) => Array<number>,
|
|
278
284
|
// @ts-expect-error - suppressing pre-existing type mismatch
|
|
279
285
|
map(getTimeSeriesValuesForMetric) as () => Array<Array<number>>
|
|
280
286
|
)(lines as Array<Line>);
|
|
@@ -295,7 +301,7 @@ const getStackedMetricValues = ({
|
|
|
295
301
|
const getSortedStackedLines = (lines: Array<Line>): Array<Line> =>
|
|
296
302
|
pipe(
|
|
297
303
|
reject(({ stackOrder }: Line): boolean => isNil(stackOrder)) as (
|
|
298
|
-
lines
|
|
304
|
+
lines: Array<Line>
|
|
299
305
|
) => Array<Line>,
|
|
300
306
|
sortBy(prop('stackOrder'))
|
|
301
307
|
)(lines);
|
|
@@ -303,14 +309,18 @@ const getSortedStackedLines = (lines: Array<Line>): Array<Line> =>
|
|
|
303
309
|
const getInvertedStackedLines = (lines: Array<Line>): Array<Line> =>
|
|
304
310
|
pipe(
|
|
305
311
|
// @ts-expect-error - suppressing pre-existing type mismatch
|
|
306
|
-
filter(({ invert }: Line): boolean => invert) as (
|
|
312
|
+
filter(({ invert }: Line): boolean => invert) as (
|
|
313
|
+
lines: Array<Line>
|
|
314
|
+
) => Array<Line>,
|
|
307
315
|
getSortedStackedLines
|
|
308
316
|
)(lines);
|
|
309
317
|
|
|
310
318
|
const getNotInvertedStackedLines = (lines: Array<Line>): Array<Line> =>
|
|
311
319
|
pipe(
|
|
312
320
|
// @ts-expect-error - suppressing pre-existing type mismatch
|
|
313
|
-
reject(({ invert }: Line): boolean => invert) as (
|
|
321
|
+
reject(({ invert }: Line): boolean => invert) as (
|
|
322
|
+
lines: Array<Line>
|
|
323
|
+
) => Array<Line>,
|
|
314
324
|
getSortedStackedLines
|
|
315
325
|
)(lines);
|
|
316
326
|
|
|
@@ -401,6 +411,23 @@ const getSanitizedValues = reject(
|
|
|
401
411
|
equals(value, Number.NEGATIVE_INFINITY)
|
|
402
412
|
);
|
|
403
413
|
|
|
414
|
+
interface GetScaleProps {
|
|
415
|
+
graphValues: Array<number>;
|
|
416
|
+
height: number;
|
|
417
|
+
stackedValues: Array<number>;
|
|
418
|
+
thresholds: Array<number>;
|
|
419
|
+
isCenteredZero?: boolean;
|
|
420
|
+
scale?: 'linear' | 'logarithmic';
|
|
421
|
+
scaleLogarithmicBase?: number;
|
|
422
|
+
isHorizontal: boolean;
|
|
423
|
+
invert?: boolean | string | null;
|
|
424
|
+
hasDisplayAsBar: boolean;
|
|
425
|
+
hasLineFilled: boolean;
|
|
426
|
+
hasStackedLines: boolean;
|
|
427
|
+
min?: number;
|
|
428
|
+
max?: number;
|
|
429
|
+
}
|
|
430
|
+
|
|
404
431
|
const getScale = ({
|
|
405
432
|
graphValues,
|
|
406
433
|
height,
|
|
@@ -416,7 +443,8 @@ const getScale = ({
|
|
|
416
443
|
hasStackedLines,
|
|
417
444
|
min,
|
|
418
445
|
max
|
|
419
|
-
|
|
446
|
+
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: scale calculation requires multiple branching conditions
|
|
447
|
+
}: GetScaleProps): ScaleLinear<number, number> => {
|
|
420
448
|
const isLogScale = equals(scale, 'logarithmic');
|
|
421
449
|
const sanitizedValuesForMinimum = min
|
|
422
450
|
? [min]
|
|
@@ -429,7 +457,9 @@ const getScale = ({
|
|
|
429
457
|
getMin([0, ...stackedValues]),
|
|
430
458
|
Math.min(...thresholds)
|
|
431
459
|
]);
|
|
432
|
-
const minValue = Math.min(
|
|
460
|
+
const minValue = Math.min(
|
|
461
|
+
...(sanitizedValuesForMinimum.filter(isNotNil) as Array<number>)
|
|
462
|
+
);
|
|
433
463
|
|
|
434
464
|
const sanitizedValuesForMaximum = max
|
|
435
465
|
? [max]
|
|
@@ -460,7 +490,7 @@ const getScale = ({
|
|
|
460
490
|
? 0
|
|
461
491
|
: maxValue + Math.abs(maxValue) * 0.05;
|
|
462
492
|
|
|
463
|
-
const scaleType = getScaleType(scale);
|
|
493
|
+
const scaleType = getScaleType(scale ?? 'linear');
|
|
464
494
|
|
|
465
495
|
const upperRangeValue = minValue === maxValue && maxValue === 0 ? height : 0;
|
|
466
496
|
const range = [height, upperRangeValue];
|
|
@@ -473,7 +503,7 @@ const getScale = ({
|
|
|
473
503
|
|
|
474
504
|
return scaleType<number>({
|
|
475
505
|
base: scaleLogarithmicBase || 2,
|
|
476
|
-
clamp: min || max,
|
|
506
|
+
clamp: Boolean(min || max),
|
|
477
507
|
domain: [-greatestValue, greatestValue],
|
|
478
508
|
range: isHorizontal ? range : range.reverse()
|
|
479
509
|
});
|
|
@@ -483,7 +513,7 @@ const getScale = ({
|
|
|
483
513
|
|
|
484
514
|
return scaleType<number>({
|
|
485
515
|
base: scaleLogarithmicBase || 2,
|
|
486
|
-
clamp: min || max,
|
|
516
|
+
clamp: Boolean(min || max),
|
|
487
517
|
domain,
|
|
488
518
|
range: isHorizontal ? range : range.reverse()
|
|
489
519
|
});
|
|
@@ -594,6 +624,10 @@ const boundaryToApplyToUnit = ({
|
|
|
594
624
|
boundary,
|
|
595
625
|
boundariesUnit,
|
|
596
626
|
unit
|
|
627
|
+
}: {
|
|
628
|
+
boundary?: number;
|
|
629
|
+
boundariesUnit?: string;
|
|
630
|
+
unit: string;
|
|
597
631
|
}): number | undefined => {
|
|
598
632
|
if (!boundariesUnit) {
|
|
599
633
|
return boundary;
|
|
@@ -655,21 +689,27 @@ const getYScalePerUnit = ({
|
|
|
655
689
|
return scalePerUnit;
|
|
656
690
|
};
|
|
657
691
|
|
|
658
|
-
const formatTime = ({
|
|
692
|
+
const formatTime = ({
|
|
693
|
+
value,
|
|
694
|
+
unit
|
|
695
|
+
}: {
|
|
696
|
+
value: number;
|
|
697
|
+
unit: string;
|
|
698
|
+
}): string => {
|
|
659
699
|
return `${numeral(value).format('0.[00]a')} ${unit}`;
|
|
660
700
|
};
|
|
661
701
|
|
|
662
702
|
const registerMsUnitToNumeral = (): null => {
|
|
663
703
|
try {
|
|
664
704
|
numeral.register('format', 'milliseconds', {
|
|
665
|
-
format: (value) => {
|
|
705
|
+
format: (value: number) => {
|
|
666
706
|
return formatTime({ unit: 'ms', value });
|
|
667
707
|
},
|
|
668
708
|
regexps: {
|
|
669
709
|
format: /(ms)/,
|
|
670
710
|
unformat: /(ms)/
|
|
671
711
|
},
|
|
672
|
-
unformat: () =>
|
|
712
|
+
unformat: () => 0
|
|
673
713
|
});
|
|
674
714
|
|
|
675
715
|
return null;
|
|
@@ -683,14 +723,14 @@ registerMsUnitToNumeral();
|
|
|
683
723
|
const registerSecondsUnitToNumeral = (): null => {
|
|
684
724
|
try {
|
|
685
725
|
numeral.register('format', 'seconds', {
|
|
686
|
-
format: (value) => {
|
|
726
|
+
format: (value: number) => {
|
|
687
727
|
return formatTime({ unit: 's', value });
|
|
688
728
|
},
|
|
689
729
|
regexps: {
|
|
690
730
|
format: /(s)/,
|
|
691
731
|
unformat: /(s)/
|
|
692
732
|
},
|
|
693
|
-
unformat: () =>
|
|
733
|
+
unformat: () => 0
|
|
694
734
|
});
|
|
695
735
|
|
|
696
736
|
return null;
|
|
@@ -701,7 +741,13 @@ const registerSecondsUnitToNumeral = (): null => {
|
|
|
701
741
|
|
|
702
742
|
registerSecondsUnitToNumeral();
|
|
703
743
|
|
|
704
|
-
const getBase1024 = ({
|
|
744
|
+
const getBase1024 = ({
|
|
745
|
+
unit,
|
|
746
|
+
base
|
|
747
|
+
}: {
|
|
748
|
+
unit: string;
|
|
749
|
+
base: number | string;
|
|
750
|
+
}): boolean => {
|
|
705
751
|
const base2Units = [
|
|
706
752
|
'B',
|
|
707
753
|
'bytes',
|
|
@@ -274,7 +274,9 @@ export const computeGElementMarginLeft = ({
|
|
|
274
274
|
}: ComputeGElementMarginLeftProps): number =>
|
|
275
275
|
maxCharacters * 5 + (hasSecondUnit ? margin.top * 0.8 : margin.top * 0.6);
|
|
276
276
|
|
|
277
|
-
export const computPixelsToShiftMouse = (
|
|
277
|
+
export const computPixelsToShiftMouse = (
|
|
278
|
+
xScale: import('d3-scale').ScaleTime<number, number>
|
|
279
|
+
): number => {
|
|
278
280
|
const domain = xScale.domain();
|
|
279
281
|
|
|
280
282
|
const hoursDiffInGraph = dayjs(domain[1]).diff(domain[0], 'h');
|
|
@@ -38,7 +38,12 @@ const createImage = ({
|
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
interface UseLoadImageProps {
|
|
42
|
+
alt: string;
|
|
43
|
+
imageSrc: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const useLoadImage = ({ imageSrc, alt }: UseLoadImageProps): boolean => {
|
|
42
47
|
const [images, setImages] = useAtom(imagesAtom);
|
|
43
48
|
|
|
44
49
|
const image = prop(alt, images);
|
|
@@ -47,7 +47,9 @@ const RegexpHelpTooltip = ({
|
|
|
47
47
|
urlTip,
|
|
48
48
|
labelUrlTip
|
|
49
49
|
}: TooltipProps): JSX.Element => {
|
|
50
|
-
const displayElement = (
|
|
50
|
+
const displayElement = (
|
|
51
|
+
element: ReactElement
|
|
52
|
+
): ((prop: unknown) => ReactElement | null) =>
|
|
51
53
|
ifElse(isNil, always(null), always(element));
|
|
52
54
|
|
|
53
55
|
const content = (
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { buildListingEndpoint } from '../../../../../..';
|
|
2
|
+
import type { BuildListingEndpointParameters } from '../../../../../../api/buildListingEndpoint/models';
|
|
2
3
|
|
|
3
4
|
export const baseEndpoint = './endpoint';
|
|
4
5
|
|
|
5
|
-
export const getEndpoint = (
|
|
6
|
+
export const getEndpoint = (
|
|
7
|
+
parameters: BuildListingEndpointParameters['parameters']
|
|
8
|
+
): string => {
|
|
6
9
|
return buildListingEndpoint({ baseEndpoint, parameters });
|
|
7
10
|
};
|
|
8
11
|
|
|
@@ -9,7 +9,10 @@ import {
|
|
|
9
9
|
waitFor,
|
|
10
10
|
} from "../../../../../test/testRenderer";
|
|
11
11
|
import buildListingEndpoint from "../../../../api/buildListingEndpoint";
|
|
12
|
-
import type {
|
|
12
|
+
import type {
|
|
13
|
+
BuildListingEndpointParameters,
|
|
14
|
+
ConditionsSearchParameter,
|
|
15
|
+
} from "../../../../api/buildListingEndpoint/models";
|
|
13
16
|
import TestQueryProvider from "../../../../api/TestQueryProvider";
|
|
14
17
|
|
|
15
18
|
import SingleConnectedAutocompleteField from "./Single";
|
|
@@ -31,7 +34,9 @@ const optionsData = {
|
|
|
31
34
|
|
|
32
35
|
const baseEndpoint = "endpoint";
|
|
33
36
|
|
|
34
|
-
const getEndpoint = (
|
|
37
|
+
const getEndpoint = (
|
|
38
|
+
parameters: BuildListingEndpointParameters["parameters"],
|
|
39
|
+
): string => {
|
|
35
40
|
return buildListingEndpoint({ baseEndpoint, parameters });
|
|
36
41
|
};
|
|
37
42
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CircularProgress, useTheme } from '@mui/material';
|
|
2
|
+
import type { AutocompleteRenderOptionState } from '@mui/material/Autocomplete';
|
|
2
3
|
|
|
3
4
|
import {
|
|
4
5
|
equals,
|
|
@@ -13,7 +14,14 @@ import {
|
|
|
13
14
|
prop,
|
|
14
15
|
uniqBy
|
|
15
16
|
} from 'ramda';
|
|
16
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
type HTMLAttributes,
|
|
19
|
+
type ReactElement,
|
|
20
|
+
useCallback,
|
|
21
|
+
useEffect,
|
|
22
|
+
useState
|
|
23
|
+
} from 'react';
|
|
24
|
+
import type { JsonDecoder } from 'ts.data.json';
|
|
17
25
|
|
|
18
26
|
import type { ListingMapModel, ListingModel, SelectEntry } from '../../../..';
|
|
19
27
|
import type {
|
|
@@ -35,26 +43,37 @@ interface OptionResult<T> {
|
|
|
35
43
|
total: number;
|
|
36
44
|
}
|
|
37
45
|
|
|
46
|
+
export interface GetEndpointParams {
|
|
47
|
+
page: number;
|
|
48
|
+
search?: SearchParameter;
|
|
49
|
+
}
|
|
50
|
+
|
|
38
51
|
export interface ConnectedAutoCompleteFieldProps<TData> {
|
|
39
52
|
allowUniqOption?: boolean;
|
|
40
53
|
baseEndpoint?: string;
|
|
41
|
-
changeIdValue
|
|
54
|
+
changeIdValue?: (item: TData) => number | string;
|
|
42
55
|
exclusionOptionProperty?: keyof SelectEntry;
|
|
43
56
|
field: string;
|
|
44
|
-
getEndpoint: (
|
|
45
|
-
decoder
|
|
57
|
+
getEndpoint: (params: GetEndpointParams) => string;
|
|
58
|
+
decoder?: JsonDecoder.Decoder<ListingModel<TData> | ListingMapModel<TData>>;
|
|
46
59
|
getRenderedOptionText?: (option: TData) => ReactElement | string;
|
|
47
60
|
getRequestHeaders?: HeadersInit;
|
|
48
|
-
initialPage
|
|
61
|
+
initialPage?: number;
|
|
49
62
|
labelKey?: string;
|
|
50
63
|
queryKey?: string;
|
|
51
64
|
searchConditions?: Array<ConditionsSearchParameter>;
|
|
52
65
|
}
|
|
53
66
|
|
|
67
|
+
// biome-ignore lint/suspicious/noExplicitAny: HOC accepts varied AutocompleteField shapes
|
|
68
|
+
type AutocompleteLikeComponent = (props: any) => ReactElement;
|
|
69
|
+
|
|
54
70
|
const ConnectedAutocompleteField = (
|
|
55
|
-
AutocompleteField:
|
|
71
|
+
AutocompleteField: AutocompleteLikeComponent,
|
|
56
72
|
multiple: boolean
|
|
57
|
-
): (
|
|
73
|
+
): (<TData extends { name: string }>(
|
|
74
|
+
props: ConnectedAutoCompleteFieldProps<TData> &
|
|
75
|
+
Omit<AutocompleteFieldProps, 'options'>
|
|
76
|
+
) => ReactElement) => {
|
|
58
77
|
const InnerConnectedAutocompleteField = <TData extends { name: string }>({
|
|
59
78
|
initialPage = 1,
|
|
60
79
|
getEndpoint,
|
|
@@ -85,8 +104,8 @@ const ConnectedAutocompleteField = (
|
|
|
85
104
|
const [autocompleteChangedValue, setAutocompleteChangedValue] =
|
|
86
105
|
useState<Array<SelectEntry>>();
|
|
87
106
|
const debounce = useDebounce({
|
|
88
|
-
functionToDebounce: (value): void => {
|
|
89
|
-
setSearchParameter(getSearchParameter(value));
|
|
107
|
+
functionToDebounce: (value: unknown): void => {
|
|
108
|
+
setSearchParameter(getSearchParameter(value as string));
|
|
90
109
|
setPage(1);
|
|
91
110
|
},
|
|
92
111
|
memoProps: [page, searchConditions],
|
|
@@ -216,26 +235,30 @@ const ConnectedAutocompleteField = (
|
|
|
216
235
|
};
|
|
217
236
|
};
|
|
218
237
|
|
|
219
|
-
const changeText = (event): void => {
|
|
238
|
+
const changeText = (event: React.ChangeEvent<HTMLInputElement>): void => {
|
|
220
239
|
debounce(event.target.value);
|
|
221
240
|
};
|
|
222
241
|
|
|
223
|
-
const renderOptions = (
|
|
242
|
+
const renderOptions = (
|
|
243
|
+
renderProps: HTMLAttributes<HTMLLIElement>,
|
|
244
|
+
option: SelectEntry,
|
|
245
|
+
{ selected }: AutocompleteRenderOptionState
|
|
246
|
+
): ReactElement => {
|
|
224
247
|
const { value } = props;
|
|
225
248
|
|
|
226
249
|
const lastValue = Array.isArray(value) ? last(value) : value;
|
|
227
250
|
|
|
228
251
|
const isLastValueWithoutOptions =
|
|
229
|
-
equals(option)(lastValue) && isEmpty(options);
|
|
252
|
+
equals(option as unknown)(lastValue as unknown) && isEmpty(options);
|
|
230
253
|
const lastOption = last(options);
|
|
231
254
|
|
|
232
|
-
const isLastOption = equals(lastOption)(option);
|
|
255
|
+
const isLastOption = equals(lastOption as unknown)(option as unknown);
|
|
233
256
|
|
|
234
257
|
const canTriggerInfiniteScroll = isLastOption && page <= maxPage;
|
|
235
258
|
|
|
236
259
|
const ref = canTriggerInfiniteScroll ? { ref: lastOptionRef } : {};
|
|
237
260
|
|
|
238
|
-
const optionText = getRenderedOptionText(option);
|
|
261
|
+
const optionText = getRenderedOptionText(option as unknown as TData);
|
|
239
262
|
|
|
240
263
|
const optionProps = {
|
|
241
264
|
checkboxSelected: multiple ? selected : undefined,
|
|
@@ -259,12 +282,26 @@ const ConnectedAutocompleteField = (
|
|
|
259
282
|
);
|
|
260
283
|
};
|
|
261
284
|
|
|
262
|
-
const renameKey = useCallback(
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
285
|
+
const renameKey = useCallback(
|
|
286
|
+
({
|
|
287
|
+
object,
|
|
288
|
+
key,
|
|
289
|
+
newKey
|
|
290
|
+
}: {
|
|
291
|
+
object: TData;
|
|
292
|
+
key: string;
|
|
293
|
+
newKey: string;
|
|
294
|
+
}): Partial<TData> => {
|
|
295
|
+
const oldKeyValue = (object as Record<string, unknown>)[key];
|
|
296
|
+
const newObject = {
|
|
297
|
+
...object,
|
|
298
|
+
[newKey]: oldKeyValue
|
|
299
|
+
} as Record<string, unknown>;
|
|
300
|
+
|
|
301
|
+
return omit([key], newObject) as Partial<TData>;
|
|
302
|
+
},
|
|
303
|
+
[]
|
|
304
|
+
);
|
|
268
305
|
|
|
269
306
|
const fetchOptionsAndPrefetchNextOptions = useCallback((): void => {
|
|
270
307
|
fetchQuery().then((newOptions) => {
|
|
@@ -305,7 +342,7 @@ const ConnectedAutocompleteField = (
|
|
|
305
342
|
}
|
|
306
343
|
|
|
307
344
|
prefetchNextPage({
|
|
308
|
-
getPrefetchQueryKey: (newPage) => [
|
|
345
|
+
getPrefetchQueryKey: (newPage: number) => [
|
|
309
346
|
`autocomplete-${props.label}`,
|
|
310
347
|
newPage,
|
|
311
348
|
searchParameter
|
|
@@ -361,18 +398,25 @@ const ConnectedAutocompleteField = (
|
|
|
361
398
|
fetchOptionsAndPrefetchNextOptions();
|
|
362
399
|
}, [optionsOpen, page, searchParameter]);
|
|
363
400
|
|
|
401
|
+
const handleChange = (
|
|
402
|
+
_: React.SyntheticEvent,
|
|
403
|
+
value: SelectEntry | Array<SelectEntry> | null
|
|
404
|
+
): void => {
|
|
405
|
+
setAutocompleteChangedValue(value as Array<SelectEntry> | undefined);
|
|
406
|
+
};
|
|
407
|
+
|
|
364
408
|
return (
|
|
365
409
|
<AutocompleteField
|
|
366
|
-
filterOptions={(opt): SelectEntry => opt}
|
|
410
|
+
filterOptions={(opt: Array<SelectEntry>): Array<SelectEntry> => opt}
|
|
367
411
|
loading={isFetching}
|
|
368
|
-
onChange={
|
|
369
|
-
setAutocompleteChangedValue(value);
|
|
370
|
-
}}
|
|
412
|
+
onChange={handleChange as unknown as AutocompleteFieldProps['onChange']}
|
|
371
413
|
onClose={(): void => setOptionsOpen(false)}
|
|
372
414
|
onOpen={(): void => setOptionsOpen(true)}
|
|
373
415
|
onTextChange={changeText}
|
|
374
416
|
options={
|
|
375
|
-
allowUniqOption
|
|
417
|
+
(allowUniqOption
|
|
418
|
+
? uniqBy(getRenderedOptionText, options)
|
|
419
|
+
: options) as unknown as Array<SelectEntry>
|
|
376
420
|
}
|
|
377
421
|
renderOption={renderOptions}
|
|
378
422
|
total={
|
|
@@ -44,9 +44,9 @@ const SortableList = ({
|
|
|
44
44
|
}: SortableListProps): JSX.Element => {
|
|
45
45
|
const { classes } = useStyles();
|
|
46
46
|
|
|
47
|
-
const dragEnd = ({ items: newItems }): void =>
|
|
47
|
+
const dragEnd = ({ items: newItems }: { items: Array<string> }): void =>
|
|
48
48
|
changeItemsOrder(
|
|
49
|
-
|
|
49
|
+
newItems.map(
|
|
50
50
|
(item) => find(propEq(item, 'id'), items) as DraggableSelectEntry
|
|
51
51
|
)
|
|
52
52
|
);
|
|
@@ -3,19 +3,21 @@ import { Chip, Typography, useTheme } from '@mui/material';
|
|
|
3
3
|
import type { DraggableSyntheticListeners } from '@dnd-kit/core';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { findIndex, not, propEq } from 'ramda';
|
|
6
|
-
import
|
|
6
|
+
import type React from 'react';
|
|
7
|
+
import { type CSSProperties, type RefObject, useRef } from 'react';
|
|
7
8
|
|
|
8
9
|
import type { DraggableSelectEntry, SortableListProps } from './SortableList';
|
|
9
10
|
|
|
10
11
|
interface ContentProps
|
|
11
12
|
extends Pick<DraggableSelectEntry, 'name' | 'createOption' | 'id'> {
|
|
12
|
-
attributes
|
|
13
|
+
// biome-ignore lint/suspicious/noExplicitAny: dnd-kit forwards arbitrary HTML attributes
|
|
14
|
+
attributes: Record<string, any>;
|
|
13
15
|
id: string;
|
|
14
16
|
index: number;
|
|
15
17
|
isDragging: boolean;
|
|
16
18
|
itemRef: RefObject<HTMLDivElement>;
|
|
17
19
|
listeners: DraggableSyntheticListeners;
|
|
18
|
-
style;
|
|
20
|
+
style: CSSProperties;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
interface Props extends Omit<SortableListProps, 'changeItemsOrder'> {
|
|
@@ -43,7 +45,7 @@ const SortableListContent = ({
|
|
|
43
45
|
const theme = useTheme();
|
|
44
46
|
const labelItemRef = useRef<HTMLElement | null>(null);
|
|
45
47
|
|
|
46
|
-
const mouseUp = (event: MouseEvent): void => {
|
|
48
|
+
const mouseUp = (event: React.MouseEvent<HTMLElement>): void => {
|
|
47
49
|
if (not(event.shiftKey)) {
|
|
48
50
|
return;
|
|
49
51
|
}
|