@centreon/ui 26.5.9 → 26.5.11
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 +3 -1
- package/src/@types/globals.d.ts +21 -0
- package/src/Colors/index.tsx +1 -1
- package/src/Dashboard/Item.tsx +11 -14
- package/src/Dialog/Duplicate/index.tsx +1 -1
- package/src/FileDropZone/useDropzone.test.ts +18 -15
- package/src/Form/Inputs/Checkbox.tsx +6 -3
- package/src/Form/Inputs/CheckboxGroup.tsx +8 -8
- package/src/Form/Inputs/ConnectedAutocomplete.tsx +9 -3
- package/src/Form/Inputs/FieldsTable/FieldsTable.tsx +1 -1
- package/src/Form/Inputs/File.tsx +3 -1
- package/src/Form/Inputs/Grid.tsx +1 -1
- package/src/Form/Inputs/List/List.tsx +8 -7
- package/src/Form/Inputs/List/useList.ts +12 -6
- package/src/Form/Inputs/Radio.tsx +7 -1
- package/src/Form/Inputs/Text.tsx +1 -1
- package/src/Form/Inputs/index.tsx +7 -2
- package/src/Form/storiesData.tsx +5 -2
- package/src/Graph/BarChart/Bar.tsx +2 -2
- package/src/Graph/BarChart/BarChart.tsx +2 -0
- package/src/Graph/BarChart/BarGroup.tsx +3 -0
- package/src/Graph/BarChart/BarStack.tsx +1 -0
- package/src/Graph/BarChart/MemoizedGroup.tsx +3 -1
- package/src/Graph/BarChart/ResponsiveBarChart.tsx +5 -0
- package/src/Graph/BarChart/Tooltip/BarChartTooltip.tsx +4 -0
- package/src/Graph/BarStack/Graph.tsx +3 -0
- package/src/Graph/Chart/BasicComponents/Lines/RegularLines/index.tsx +4 -1
- package/src/Graph/Chart/BasicComponents/Lines/StackedLines/index.tsx +7 -1
- package/src/Graph/Chart/BasicComponents/Lines/Threshold/BasicThreshold.tsx +1 -0
- package/src/Graph/Chart/BasicComponents/Lines/index.tsx +11 -1
- package/src/Graph/Chart/Chart.tsx +9 -0
- package/src/Graph/Chart/InteractiveComponents/AnchorPoint/StackedAnchorPoint.tsx +2 -0
- package/src/Graph/Chart/InteractiveComponents/AnchorPoint/useTickGraph.ts +2 -0
- package/src/Graph/Chart/InteractiveComponents/Annotations/annotationsAtoms.ts +5 -0
- package/src/Graph/Chart/InteractiveComponents/GraphValueTooltip/GraphValueTooltip.tsx +3 -0
- package/src/Graph/Chart/Legend/LegendHeader.tsx +1 -0
- package/src/Graph/Chart/Legend/index.tsx +6 -1
- package/src/Graph/Chart/useChartData.ts +6 -0
- package/src/Graph/Gauge/AnimatedPie.tsx +3 -0
- package/src/Graph/Gauge/PieData.tsx +5 -0
- package/src/Graph/Gauge/ResponsiveGauge.tsx +2 -0
- package/src/Graph/Gauge/Thresholds.tsx +1 -0
- package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +1 -0
- package/src/Graph/SingleBar/ResponsiveSingleBar.tsx +2 -0
- package/src/Graph/Timeline/ResponsiveTimeline.tsx +1 -0
- package/src/Graph/Tree/Links.tsx +1 -0
- package/src/Graph/Tree/Tree.tsx +1 -0
- package/src/Graph/Tree/stories/datas.ts +2 -0
- package/src/Graph/common/Axes/index.tsx +3 -3
- package/src/Graph/common/BaseChart/BaseChart.tsx +3 -0
- package/src/Graph/common/BaseChart/ChartSvgWrapper.tsx +1 -0
- package/src/Graph/common/BaseChart/Header/models.ts +1 -0
- package/src/Graph/common/timeSeries/index.test.ts +17 -1
- package/src/Graph/common/timeSeries/index.ts +12 -0
- package/src/Graph/common/utils.ts +6 -2
- package/src/InputField/Number/Number.tsx +10 -4
- package/src/InputField/Search/PersistentTooltip.tsx +6 -5
- package/src/InputField/Select/Autocomplete/Connected/Single.tsx +3 -1
- package/src/InputField/Select/Autocomplete/Connected/index.test.tsx +1 -1
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +5 -1
- package/src/InputField/Select/Autocomplete/Draggable/SortableList.tsx +4 -5
- package/src/InputField/Select/Autocomplete/Draggable/index.tsx +4 -5
- package/src/InputField/Select/Autocomplete/Multi/Listbox.tsx +16 -1
- package/src/InputField/Select/Autocomplete/Multi/Multi.tsx +44 -30
- package/src/InputField/Select/Autocomplete/Multi/index.tsx +1 -0
- package/src/InputField/Select/Autocomplete/index.tsx +7 -1
- package/src/InputField/Select/IconPopover/index.tsx +0 -3
- package/src/InputField/Select/Option.tsx +6 -1
- package/src/InputField/Select/index.tsx +3 -3
- package/src/InputField/Text/index.tsx +11 -3
- package/src/InputField/Text/useAutoSize.ts +2 -2
- package/src/Listing/ActionBar/index.tsx +2 -3
- package/src/Listing/Cell/index.tsx +24 -22
- package/src/Listing/Header/Cell/ListingHeaderCell.styles.ts +7 -0
- package/src/Listing/Header/ListingHeader.tsx +2 -2
- package/src/Listing/Header/_internals/PredefinedSelectionList.tsx +3 -3
- package/src/Listing/index.tsx +29 -34
- package/src/Listing/useStyleTable.ts +1 -1
- package/src/Module/index.tsx +3 -3
- package/src/MultiSelectEntries/index.tsx +1 -1
- package/src/Pagination/Pagination.tsx +1 -1
- package/src/ParentSize/ParentSize.tsx +2 -1
- package/src/PopoverMenu/index.tsx +1 -7
- package/src/RichTextEditor/ContentEditable.tsx +2 -0
- package/src/RichTextEditor/RichTextEditor.tsx +1 -0
- package/src/RichTextEditor/plugins/FloatingLinkEditorPlugin.tsx +1 -0
- package/src/RichTextEditor/plugins/ToolbarPlugin/BlockButtons.tsx +1 -0
- package/src/RichTextEditor/plugins/ToolbarPlugin/ListButton.tsx +2 -0
- package/src/Snackbar/index.tsx +3 -1
- package/src/SortableItems/Item.tsx +8 -7
- package/src/SortableItems/index.tsx +1 -1
- package/src/ThemeProvider/index.tsx +5 -3
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +3 -2
- package/src/TimePeriods/SelectedTimePeriod.tsx +1 -1
- package/src/TimePeriods/timePeriodsAtoms.ts +1 -1
- package/src/TimePeriods/useSortTimePeriods.ts +1 -1
- package/src/Typography/Subtitle.tsx +3 -1
- package/src/Typography/story.utils.tsx +3 -2
- package/src/Wizard/ActionsBar.tsx +2 -2
- package/src/api/QueryProvider.tsx +1 -2
- package/src/api/buildListingEndpoint/getSearchQueryParameterValue.ts +4 -2
- package/src/api/useGraphQuery/index.ts +11 -6
- package/src/api/useMutationQuery/index.ts +11 -7
- package/src/api/useMutationQuery/useOptimisticMutation.ts +34 -16
- package/src/api/useRequest/index.test.ts +1 -1
- package/src/api/useRequest/index.ts +1 -1
- package/src/components/Button/Button.tsx +2 -2
- package/src/components/CrudPage/Actions/Filters.tsx +1 -1
- package/src/components/CrudPage/Actions/useSearch.tsx +1 -1
- package/src/components/CrudPage/Columns/Actions.tsx +2 -2
- package/src/components/CrudPage/CrudPageRoot.tsx +1 -1
- package/src/components/CrudPage/DeleteModal.tsx +14 -6
- package/src/components/CrudPage/Form/AddModal.tsx +16 -4
- package/src/components/CrudPage/Form/UpdateModal.tsx +2 -2
- package/src/components/CrudPage/Listing.tsx +2 -1
- package/src/components/CrudPage/hooks/useDeleteItem.ts +5 -1
- package/src/components/CrudPage/hooks/useGetItem.ts +3 -3
- package/src/components/DataTable/DataListing.tsx +1 -1
- package/src/components/ExpandableContainer/ExpandableContainer.tsx +1 -0
- package/src/components/Form/AccessRights/Actions/Actions.tsx +1 -1
- package/src/components/Form/AccessRights/Actions/useActions.ts +1 -4
- package/src/components/Form/AccessRights/List/StateChip.tsx +1 -1
- package/src/components/Form/AccessRights/Stats/Stats.tsx +1 -1
- package/src/components/Form/AccessRights/common/RoleSelectField.tsx +4 -6
- package/src/components/Form/Dashboard/DashboardForm.tsx +2 -2
- package/src/components/Header/PageHeader/PageHeader.styles.ts +26 -20
- package/src/components/Menu/useMenu.tsx +3 -3
- package/src/components/Modal/ConfirmationModal/ConfirmationModal.tsx +14 -9
- package/src/components/Modal/Modal.tsx +5 -3
- package/src/components/Modal/ModalActions.tsx +1 -1
- package/src/components/Modal/ModalBody.tsx +2 -2
- package/src/components/Modal/ModalHeader.tsx +2 -2
- package/src/components/Tooltip/TextOverflowTooltip/TextOverflowTooltip.tsx +8 -2
- package/src/index.ts +1 -1
- package/src/utils/sanitizedHTML.ts +1 -1
- package/src/utils/useDebounce.ts +3 -1
- package/src/utils/useLicenseExpirationWarning.ts +11 -6
- package/src/utils/useLocaleDateTimeFormat/index.test.tsx +3 -1
- package/src/utils/useLocaleDateTimeFormat/localeFallback.test.tsx +3 -1
- package/src/utils/useMemoComponent.ts +1 -1
- package/src/utils/usePluralizedTranslation.test.ts +2 -0
- package/src/utils/useViewportIntersection.ts +3 -4
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/ui",
|
|
3
|
-
"version": "26.5.
|
|
3
|
+
"version": "26.5.11",
|
|
4
4
|
"description": "Centreon UI Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"update:deps": "pnpx npm-check-updates -i --format group",
|
|
7
|
+
"type-check": "tsc --project tsconfig.typecheck.json",
|
|
8
|
+
"type-check:staged": "node typecheck-staged.mjs",
|
|
7
9
|
"lint": "biome check ./src/ --error-on-warnings",
|
|
8
10
|
"lint:fix": "pnpm lint --fix",
|
|
9
11
|
"lint:ci": "biome ci ./src/ --error-on-warnings",
|
package/src/@types/globals.d.ts
CHANGED
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
import { FunctionComponent, SVGProps } from 'react';
|
|
2
|
+
import '@testing-library/jest-dom/types/jest';
|
|
2
3
|
|
|
3
4
|
declare module '*.scss';
|
|
4
5
|
|
|
6
|
+
declare module '*.module.css' {
|
|
7
|
+
const classes: { readonly [key: string]: string };
|
|
8
|
+
export default classes;
|
|
9
|
+
export const button: string;
|
|
10
|
+
export const modalBody: string;
|
|
11
|
+
export const modalHeader: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
5
14
|
declare module '*.svg' {
|
|
6
15
|
export const ReactComponent: FunctionComponent<
|
|
7
16
|
SVGProps<SVGSVGElement> & { title?: string }
|
|
8
17
|
>;
|
|
9
18
|
}
|
|
19
|
+
|
|
20
|
+
declare global {
|
|
21
|
+
// biome-ignore lint/style/noNamespace: required for global JSX type augmentation
|
|
22
|
+
namespace JSX {
|
|
23
|
+
type Element = React.JSX.Element;
|
|
24
|
+
type IntrinsicElements = React.JSX.IntrinsicElements;
|
|
25
|
+
type ElementClass = React.JSX.ElementClass;
|
|
26
|
+
}
|
|
27
|
+
interface Window {
|
|
28
|
+
Cypress?: { testingType?: string };
|
|
29
|
+
}
|
|
30
|
+
}
|
package/src/Colors/index.tsx
CHANGED
|
@@ -55,7 +55,7 @@ const ContainerDescription = ({
|
|
|
55
55
|
{toPairs(palette[keyTheme]).map(
|
|
56
56
|
([key, value]) =>
|
|
57
57
|
!includes(key, keysToRemove) && (
|
|
58
|
-
<Grid
|
|
58
|
+
<Grid key={key} size={6}>
|
|
59
59
|
<div className={classes.headerContainer}>
|
|
60
60
|
<Typography variant="h6">{key}</Typography>
|
|
61
61
|
<Typography variant="button">{value}</Typography>
|
package/src/Dashboard/Item.tsx
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
|
|
14
14
|
import ExpandableContainer from '../components/ExpandableContainer';
|
|
15
15
|
import type { Parameters } from '../components/ExpandableContainer/models';
|
|
16
|
-
import LoadingSkeleton from '../LoadingSkeleton';
|
|
17
16
|
import { useMemoComponent, useViewportIntersection } from '../utils';
|
|
18
17
|
import { isResizingItemAtom } from './atoms';
|
|
19
18
|
import { useDashboardItemStyles } from './Dashboard.styles';
|
|
@@ -21,7 +20,10 @@ import { useDashboardItemStyles } from './Dashboard.styles';
|
|
|
21
20
|
interface DashboardItemProps {
|
|
22
21
|
additionalMemoProps?: Array<unknown>;
|
|
23
22
|
canMove?: boolean;
|
|
24
|
-
children:
|
|
23
|
+
children: Array<
|
|
24
|
+
| ReactElement
|
|
25
|
+
| (({ isInViewport }: { isInViewport: boolean }) => ReactElement)
|
|
26
|
+
>;
|
|
25
27
|
className?: string;
|
|
26
28
|
disablePadding?: boolean;
|
|
27
29
|
header?: ReactElement | ((params: Parameters) => ReactElement);
|
|
@@ -85,7 +87,7 @@ const Item = ({
|
|
|
85
87
|
|
|
86
88
|
const newTransform =
|
|
87
89
|
style?.transform &&
|
|
88
|
-
`translate3d(${style.transform.match(/translate\(([a-z0-9 ,-]+)\)/)[1]}, 0px)`;
|
|
90
|
+
`translate3d(${style.transform.match(/translate\(([a-z0-9 ,-]+)\)/)?.[1]}, 0px)`;
|
|
89
91
|
|
|
90
92
|
return useMemoComponent({
|
|
91
93
|
Component: (
|
|
@@ -107,10 +109,10 @@ const Item = ({
|
|
|
107
109
|
isExpanded,
|
|
108
110
|
key,
|
|
109
111
|
label,
|
|
110
|
-
ref
|
|
112
|
+
ref: ref as RefObject<HTMLDivElement>,
|
|
111
113
|
...rest
|
|
112
114
|
})
|
|
113
|
-
: header;
|
|
115
|
+
: (header as ReactElement);
|
|
114
116
|
|
|
115
117
|
return (
|
|
116
118
|
<div className={classes.widgetSubContainer} key={key}>
|
|
@@ -139,15 +141,10 @@ const Item = ({
|
|
|
139
141
|
!disablePadding && classes.widgetPadding
|
|
140
142
|
)}
|
|
141
143
|
>
|
|
142
|
-
{
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
height="100%"
|
|
147
|
-
width="100%"
|
|
148
|
-
/>
|
|
149
|
-
) : (
|
|
150
|
-
children
|
|
144
|
+
{children.map((child) =>
|
|
145
|
+
typeof child === 'function'
|
|
146
|
+
? child({ isInViewport })
|
|
147
|
+
: child
|
|
151
148
|
)}
|
|
152
149
|
</div>
|
|
153
150
|
</Card>
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { act,
|
|
1
|
+
import { act, renderHook } from '@testing-library/react';
|
|
2
|
+
import type React from 'react';
|
|
2
3
|
|
|
3
4
|
import { labelFileTooBig, labelInvalidFileType } from './translatedLabels';
|
|
4
|
-
import useDropzone, {
|
|
5
|
-
type UseDropzoneProps,
|
|
6
|
-
type UseDropzoneState
|
|
7
|
-
} from './useDropzone';
|
|
5
|
+
import useDropzone, { type UseDropzoneProps } from './useDropzone';
|
|
8
6
|
|
|
9
7
|
const mockChangeFiles = jest.fn();
|
|
10
8
|
const mockResetFilesStatusAndUploadData = jest.fn();
|
|
@@ -13,10 +11,7 @@ const mockClick = jest.fn();
|
|
|
13
11
|
const renderUseFileDropzone = ({
|
|
14
12
|
allowedFilesExtensions,
|
|
15
13
|
maxFileSize
|
|
16
|
-
}: Pick<
|
|
17
|
-
UseDropzoneProps,
|
|
18
|
-
'allowedFilesExtensions' | 'maxFileSize'
|
|
19
|
-
>): RenderHookResult<UseDropzoneProps, UseDropzoneState> =>
|
|
14
|
+
}: Pick<UseDropzoneProps, 'allowedFilesExtensions' | 'maxFileSize'>) =>
|
|
20
15
|
renderHook(() =>
|
|
21
16
|
useDropzone({
|
|
22
17
|
allowedFilesExtensions,
|
|
@@ -55,7 +50,9 @@ describe('useDropzone', () => {
|
|
|
55
50
|
const fileList = createFileList([file]);
|
|
56
51
|
|
|
57
52
|
act(() => {
|
|
58
|
-
result.current.handleChangeFiles({
|
|
53
|
+
result.current.handleChangeFiles({
|
|
54
|
+
target: { files: fileList }
|
|
55
|
+
} as unknown as React.ChangeEvent<HTMLInputElement>);
|
|
59
56
|
});
|
|
60
57
|
|
|
61
58
|
expect(mockChangeFiles).toHaveBeenCalledWith(fileList);
|
|
@@ -72,10 +69,10 @@ describe('useDropzone', () => {
|
|
|
72
69
|
|
|
73
70
|
act(() => {
|
|
74
71
|
result.current.dropFiles({
|
|
75
|
-
dataTransfer: { files: fileList },
|
|
72
|
+
dataTransfer: { files: fileList } as unknown as DataTransfer,
|
|
76
73
|
preventDefault: jest.fn(),
|
|
77
74
|
stopPropagation: jest.fn()
|
|
78
|
-
});
|
|
75
|
+
} as unknown as React.DragEvent<HTMLInputElement>);
|
|
79
76
|
});
|
|
80
77
|
|
|
81
78
|
expect(mockChangeFiles).toHaveBeenCalledWith(fileList);
|
|
@@ -91,7 +88,9 @@ describe('useDropzone', () => {
|
|
|
91
88
|
const fileList = createFileList([file]);
|
|
92
89
|
|
|
93
90
|
act(() => {
|
|
94
|
-
result.current.handleChangeFiles({
|
|
91
|
+
result.current.handleChangeFiles({
|
|
92
|
+
target: { files: fileList }
|
|
93
|
+
} as unknown as React.ChangeEvent<HTMLInputElement>);
|
|
95
94
|
});
|
|
96
95
|
|
|
97
96
|
expect(mockChangeFiles).toHaveBeenCalledWith(null);
|
|
@@ -108,7 +107,9 @@ describe('useDropzone', () => {
|
|
|
108
107
|
const fileList = createFileList([bigFile]);
|
|
109
108
|
|
|
110
109
|
act(() => {
|
|
111
|
-
result.current.handleChangeFiles({
|
|
110
|
+
result.current.handleChangeFiles({
|
|
111
|
+
target: { files: fileList }
|
|
112
|
+
} as unknown as React.ChangeEvent<HTMLInputElement>);
|
|
112
113
|
});
|
|
113
114
|
|
|
114
115
|
expect(mockChangeFiles).toHaveBeenCalledWith(null);
|
|
@@ -135,7 +136,9 @@ describe('useDropzone', () => {
|
|
|
135
136
|
});
|
|
136
137
|
|
|
137
138
|
act(() => {
|
|
138
|
-
result.current.fileInputRef.current = {
|
|
139
|
+
result.current.fileInputRef.current = {
|
|
140
|
+
click: mockClick
|
|
141
|
+
} as unknown as HTMLInputElement;
|
|
139
142
|
result.current.openFileExplorer();
|
|
140
143
|
});
|
|
141
144
|
|
|
@@ -20,7 +20,9 @@ const Checkbox = ({
|
|
|
20
20
|
|
|
21
21
|
const fieldNamePath = split('.', fieldName);
|
|
22
22
|
|
|
23
|
-
const value = path(fieldNamePath, values)
|
|
23
|
+
const value = path(fieldNamePath, values) as
|
|
24
|
+
| { Icon?: React.ComponentType; checked?: boolean; label?: string }
|
|
25
|
+
| undefined;
|
|
24
26
|
|
|
25
27
|
const disabled = getDisabled?.(values) || false;
|
|
26
28
|
const hideCheckbox = hideInput?.(values) || false;
|
|
@@ -40,10 +42,11 @@ const Checkbox = ({
|
|
|
40
42
|
<Box />
|
|
41
43
|
) : (
|
|
42
44
|
<CheckboxComponent
|
|
43
|
-
checked={value?.checked}
|
|
45
|
+
checked={value?.checked ?? false}
|
|
44
46
|
dataTestId={dataTestId || ''}
|
|
45
47
|
disabled={disabled}
|
|
46
|
-
Icon={value?.Icon}
|
|
48
|
+
Icon={value?.Icon as Parameters<typeof CheckboxComponent>[0]['Icon']}
|
|
49
|
+
id={fieldName}
|
|
47
50
|
label={label}
|
|
48
51
|
labelPlacement={checkbox?.labelPlacement || 'end'}
|
|
49
52
|
onChange={handleChange}
|
|
@@ -20,7 +20,7 @@ const CheckboxGroup = ({
|
|
|
20
20
|
|
|
21
21
|
const fieldNamePath = split('.', fieldName);
|
|
22
22
|
|
|
23
|
-
const value = path(fieldNamePath, values);
|
|
23
|
+
const value = path(fieldNamePath, values) as Array<string> | undefined;
|
|
24
24
|
|
|
25
25
|
const disabled = getDisabled?.(values) || false;
|
|
26
26
|
const hideCheckbox = hideInput?.(values) || false;
|
|
@@ -29,24 +29,24 @@ const CheckboxGroup = ({
|
|
|
29
29
|
if (!disabled && !hideCheckbox) {
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
const resetedValue = value
|
|
33
|
-
...element,
|
|
32
|
+
const resetedValue = (value ?? []).map((element) => ({
|
|
33
|
+
...(element as unknown as Record<string, unknown>),
|
|
34
34
|
checked: false
|
|
35
35
|
}));
|
|
36
36
|
setFieldValue(fieldName, resetedValue);
|
|
37
|
-
}, [disabled, hideCheckbox, fieldName, setFieldValue
|
|
37
|
+
}, [disabled, hideCheckbox, fieldName, setFieldValue]);
|
|
38
38
|
|
|
39
39
|
const handleChange = (event: ChangeEvent<HTMLInputElement>): void => {
|
|
40
40
|
const label = event.target.id;
|
|
41
|
-
if (!includes(label, value)) {
|
|
42
|
-
setFieldValue(fieldName, [...value, label]);
|
|
41
|
+
if (!includes(label, value ?? [])) {
|
|
42
|
+
setFieldValue(fieldName, [...(value ?? []), label]);
|
|
43
43
|
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
setFieldValue(
|
|
48
48
|
fieldName,
|
|
49
|
-
value
|
|
49
|
+
(value ?? []).filter((elm) => !equals(elm, label))
|
|
50
50
|
);
|
|
51
51
|
};
|
|
52
52
|
|
|
@@ -63,7 +63,7 @@ const CheckboxGroup = ({
|
|
|
63
63
|
labelPlacement={checkbox?.labelPlacement || 'end'}
|
|
64
64
|
onChange={handleChange}
|
|
65
65
|
options={checkbox?.options as Array<string>}
|
|
66
|
-
values={value}
|
|
66
|
+
values={value ?? []}
|
|
67
67
|
/>
|
|
68
68
|
</Box>
|
|
69
69
|
),
|
|
@@ -99,7 +99,7 @@ const ConnectedAutocomplete = ({
|
|
|
99
99
|
[fieldName, touched, additionalMemoProps]
|
|
100
100
|
);
|
|
101
101
|
|
|
102
|
-
const blur = (): void => setFieldTouched(fieldName, true);
|
|
102
|
+
const blur = (): void => void setFieldTouched(fieldName, true);
|
|
103
103
|
|
|
104
104
|
const isOptionEqualToValue = useCallback(
|
|
105
105
|
(option, value): boolean => {
|
|
@@ -110,7 +110,10 @@ const ConnectedAutocomplete = ({
|
|
|
110
110
|
[filterKey]
|
|
111
111
|
);
|
|
112
112
|
|
|
113
|
-
const value = path(fieldNamePath, values)
|
|
113
|
+
const value = path(fieldNamePath, values) as
|
|
114
|
+
| Record<string, unknown>
|
|
115
|
+
| Array<Record<string, unknown>>
|
|
116
|
+
| undefined;
|
|
114
117
|
|
|
115
118
|
const error = path(fieldNamePath, touched)
|
|
116
119
|
? path(fieldNamePath, errors)
|
|
@@ -128,7 +131,10 @@ const ConnectedAutocomplete = ({
|
|
|
128
131
|
);
|
|
129
132
|
|
|
130
133
|
const deleteItem = (_, option): void => {
|
|
131
|
-
const newValue = reject(
|
|
134
|
+
const newValue = reject(
|
|
135
|
+
propEq(option.id, 'id'),
|
|
136
|
+
(value ?? []) as Array<Record<string, unknown>>
|
|
137
|
+
);
|
|
132
138
|
|
|
133
139
|
setFieldTouched(fieldName, true, false);
|
|
134
140
|
setFieldValue(fieldName, newValue);
|
package/src/Form/Inputs/File.tsx
CHANGED
|
@@ -32,7 +32,9 @@ const File = ({
|
|
|
32
32
|
|
|
33
33
|
const changeFiles = (newFiles: FileList | null): void => {
|
|
34
34
|
if (change) {
|
|
35
|
-
change({ setFieldTouched, setFieldValue, value: newFiles }
|
|
35
|
+
change({ setFieldTouched, setFieldValue, value: newFiles } as Parameters<
|
|
36
|
+
NonNullable<InputPropsWithoutGroup['change']>
|
|
37
|
+
>[0]);
|
|
36
38
|
|
|
37
39
|
return;
|
|
38
40
|
}
|
package/src/Form/Inputs/Grid.tsx
CHANGED
|
@@ -33,15 +33,16 @@ const List = ({
|
|
|
33
33
|
{sortLabel && <Subtitle>{t(sortLabel)}</Subtitle>}
|
|
34
34
|
<div className={classes.items}>
|
|
35
35
|
<SortableItems
|
|
36
|
-
Content={
|
|
37
|
-
<
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
Content={
|
|
37
|
+
((props: Omit<ContentProps, 'children' | 'deleteItem'>) => (
|
|
38
|
+
<Content {...props} deleteItem={deleteItem}>
|
|
39
|
+
<SortContent {...(props as Record<string, unknown>)} />
|
|
40
|
+
</Content>
|
|
41
|
+
)) as never
|
|
42
|
+
}
|
|
42
43
|
collisionDetection={closestCenter}
|
|
43
44
|
itemProps={itemProps}
|
|
44
|
-
items={sortedList}
|
|
45
|
+
items={sortedList as Array<{ id: string }>}
|
|
45
46
|
onDragEnd={({ items }): void => {
|
|
46
47
|
sortList(items);
|
|
47
48
|
}}
|
|
@@ -28,10 +28,12 @@ export const useList = ({ fieldName }): UseListState => {
|
|
|
28
28
|
|
|
29
29
|
const sortedList = useMemo(
|
|
30
30
|
() =>
|
|
31
|
-
sortBy(prop('order')
|
|
32
|
-
id:
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
sortBy(prop('order') as (a: Record<string, unknown>) => number, list).map(
|
|
32
|
+
({ id, ...props }: Record<string, unknown>) => ({
|
|
33
|
+
id: `${id}`,
|
|
34
|
+
...props
|
|
35
|
+
})
|
|
36
|
+
),
|
|
35
37
|
[list]
|
|
36
38
|
);
|
|
37
39
|
|
|
@@ -50,14 +52,18 @@ export const useList = ({ fieldName }): UseListState => {
|
|
|
50
52
|
};
|
|
51
53
|
|
|
52
54
|
const deleteItem = (id: string) => (): void => {
|
|
53
|
-
const newItems = reject((item
|
|
55
|
+
const newItems = reject((item: Record<string, unknown>) =>
|
|
56
|
+
equals(Number(id), item.id)
|
|
57
|
+
)(list);
|
|
54
58
|
|
|
55
59
|
setFieldValue(fieldName, newItems);
|
|
56
60
|
};
|
|
57
61
|
|
|
58
62
|
const sortList = (items: Array<string>): void => {
|
|
59
63
|
const newOrderedList = items.map((itemId, idx) => {
|
|
60
|
-
const item = sortedList.find(({ id }
|
|
64
|
+
const item = sortedList.find(({ id }: Record<string, unknown>) =>
|
|
65
|
+
equals(id, itemId)
|
|
66
|
+
);
|
|
61
67
|
|
|
62
68
|
return {
|
|
63
69
|
...item,
|
|
@@ -49,7 +49,13 @@ const Radio = ({
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
if (change) {
|
|
52
|
-
change({
|
|
52
|
+
change({
|
|
53
|
+
setFieldTouched,
|
|
54
|
+
setFieldValue,
|
|
55
|
+
setValues,
|
|
56
|
+
value,
|
|
57
|
+
values
|
|
58
|
+
} as Parameters<NonNullable<InputPropsWithoutGroup['change']>>[0]);
|
|
53
59
|
|
|
54
60
|
return;
|
|
55
61
|
}
|
package/src/Form/Inputs/Text.tsx
CHANGED
|
@@ -234,13 +234,18 @@ const Inputs = ({
|
|
|
234
234
|
: inputProps.additionalLabel;
|
|
235
235
|
|
|
236
236
|
if (isLoading) {
|
|
237
|
-
return
|
|
237
|
+
return (
|
|
238
|
+
<LoadingSkeleton
|
|
239
|
+
input={inputProps}
|
|
240
|
+
key={key as string}
|
|
241
|
+
/>
|
|
242
|
+
);
|
|
238
243
|
}
|
|
239
244
|
|
|
240
245
|
const Input = getInput(inputProps.type);
|
|
241
246
|
|
|
242
247
|
return (
|
|
243
|
-
<div className={classes.inputWrapper} key={key}>
|
|
248
|
+
<div className={classes.inputWrapper} key={key as string}>
|
|
244
249
|
{inputProps.additionalLabel && (
|
|
245
250
|
<Typography
|
|
246
251
|
className={cx(
|
package/src/Form/storiesData.tsx
CHANGED
|
@@ -327,9 +327,10 @@ export const basicFormInputs: Array<InputProps> = [
|
|
|
327
327
|
{
|
|
328
328
|
connectedAutocomplete: {
|
|
329
329
|
additionalConditionParameters: [],
|
|
330
|
+
customQueryParameters: [],
|
|
330
331
|
endpoint: 'endpoint',
|
|
331
332
|
helperText: 'Hello I am testing'
|
|
332
|
-
},
|
|
333
|
+
} as InputProps['connectedAutocomplete'],
|
|
333
334
|
fieldName: 'group',
|
|
334
335
|
label: 'Group (Single connected autocomplete)',
|
|
335
336
|
type: InputType.SingleConnectedAutocomplete
|
|
@@ -337,8 +338,9 @@ export const basicFormInputs: Array<InputProps> = [
|
|
|
337
338
|
{
|
|
338
339
|
connectedAutocomplete: {
|
|
339
340
|
additionalConditionParameters: [],
|
|
341
|
+
customQueryParameters: [],
|
|
340
342
|
endpoint: 'endpoint'
|
|
341
|
-
},
|
|
343
|
+
} as InputProps['connectedAutocomplete'],
|
|
342
344
|
fieldName: 'animals',
|
|
343
345
|
label: 'Animals (Multi connected autocomplete)',
|
|
344
346
|
type: InputType.MultiConnectedAutocomplete
|
|
@@ -461,6 +463,7 @@ export const basicFormInputs: Array<InputProps> = [
|
|
|
461
463
|
fieldName: 'file',
|
|
462
464
|
file: {
|
|
463
465
|
accept: 'image/*',
|
|
466
|
+
CustomDropZoneContent: ({ files }) => <div>{files?.length} files</div>,
|
|
464
467
|
multiple: true
|
|
465
468
|
},
|
|
466
469
|
group: 'First group',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ScaleType } from '@visx/scale';
|
|
2
1
|
import { BarRounded } from '@visx/shape';
|
|
3
2
|
import { BarGroupBar, SeriesPoint, StackKey } from '@visx/shape/lib/types';
|
|
3
|
+
import type { ScaleLinear } from 'd3-scale';
|
|
4
4
|
import { equals } from 'ramda';
|
|
5
5
|
import { ReactElement } from 'react';
|
|
6
6
|
|
|
@@ -16,7 +16,7 @@ interface GetFirstBarHeightProps {
|
|
|
16
16
|
barWidth: number;
|
|
17
17
|
y: number;
|
|
18
18
|
isFirstBar: boolean;
|
|
19
|
-
yScale:
|
|
19
|
+
yScale: ScaleLinear<number, number>;
|
|
20
20
|
neutralValue: number;
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -89,6 +89,7 @@ const BarChart = ({
|
|
|
89
89
|
timeShiftZones,
|
|
90
90
|
annotationEvent
|
|
91
91
|
}: BarChartProps): ReactElement => {
|
|
92
|
+
// @ts-expect-error - suppressing pre-existing type mismatch
|
|
92
93
|
const { adjustedData } = useChartData({ data, end, max, min, start });
|
|
93
94
|
const { ref, width, height: responsiveHeight } = useResizeObserver();
|
|
94
95
|
|
|
@@ -118,6 +119,7 @@ const BarChart = ({
|
|
|
118
119
|
boundariesUnit={boundariesUnit}
|
|
119
120
|
end={end}
|
|
120
121
|
graphData={adjustedData}
|
|
122
|
+
// @ts-expect-error - suppressing pre-existing type mismatch
|
|
121
123
|
graphRef={ref}
|
|
122
124
|
header={header}
|
|
123
125
|
height={height || responsiveHeight || 0}
|
|
@@ -76,6 +76,7 @@ const BarGroup = ({
|
|
|
76
76
|
deps: [normalizedTimeSeries],
|
|
77
77
|
variable: keys(omit(['timeTick'], normalizedTimeSeries[0]))
|
|
78
78
|
});
|
|
79
|
+
// @ts-expect-error - suppressing pre-existing type mismatch
|
|
79
80
|
const sortedLineKeys = lineKeys.sort((lineKeyA: string, lineKeyB: string) => {
|
|
80
81
|
if (lineKeyA.startsWith('stacked-') && !lineKeyB.startsWith('stacked-')) {
|
|
81
82
|
return true;
|
|
@@ -139,6 +140,7 @@ const BarGroup = ({
|
|
|
139
140
|
|
|
140
141
|
return (
|
|
141
142
|
<BarComponent<TimeValue>
|
|
143
|
+
// @ts-expect-error - suppressing pre-existing type mismatch
|
|
142
144
|
color={colorScale}
|
|
143
145
|
data={normalizedTimeSeries}
|
|
144
146
|
height={size}
|
|
@@ -195,6 +197,7 @@ export default memo(BarGroup, (prevProps, nextProps) => {
|
|
|
195
197
|
];
|
|
196
198
|
|
|
197
199
|
return (
|
|
200
|
+
// @ts-expect-error - suppressing pre-existing type mismatch
|
|
198
201
|
equals(pick(propsToMemoize, prevProps), pick(propsToMemoize, nextProps)) &&
|
|
199
202
|
equals(prevYScale, nextYScale) &&
|
|
200
203
|
equals(prevXScale, nextXScale)
|
|
@@ -131,6 +131,7 @@ export default memo(BarStack, (prevProps, nextProps) => {
|
|
|
131
131
|
[...prevYScaleDomain, ...prevYScaleRange],
|
|
132
132
|
[...nextYScaleDomain, ...nextYScaleRange]
|
|
133
133
|
) &&
|
|
134
|
+
// @ts-expect-error - suppressing pre-existing type mismatch
|
|
134
135
|
equals(pick(propsToMemoize, prevProps), pick(propsToMemoize, nextProps))
|
|
135
136
|
);
|
|
136
137
|
});
|
|
@@ -54,6 +54,7 @@ const MemoizedGroup = ({
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
return (
|
|
57
|
+
// @ts-expect-error - suppressing pre-existing type mismatch
|
|
57
58
|
<Group left={barGroup.x0} top={barGroup.y0}>
|
|
58
59
|
{barGroup.bars.map((bar) => {
|
|
59
60
|
const isStackedBar = bar.key.startsWith('stacked-');
|
|
@@ -74,7 +75,8 @@ const MemoizedGroup = ({
|
|
|
74
75
|
: (linesBar as Line).unit;
|
|
75
76
|
const yScale =
|
|
76
77
|
unit === '' && yScalesPerUnit[unit] === undefined
|
|
77
|
-
?
|
|
78
|
+
? // @ts-expect-error - suppressing pre-existing type mismatch
|
|
79
|
+
yScalesPerUnit[undefined]
|
|
78
80
|
: yScalesPerUnit[unit];
|
|
79
81
|
|
|
80
82
|
return isStackedBar ? (
|
|
@@ -242,17 +242,21 @@ const ResponsiveBarChart = ({
|
|
|
242
242
|
isHorizontal={isHorizontal}
|
|
243
243
|
legend={{
|
|
244
244
|
displayLegend,
|
|
245
|
+
// @ts-expect-error - suppressing pre-existing type mismatch
|
|
245
246
|
mode: legend?.mode,
|
|
247
|
+
// @ts-expect-error - suppressing pre-existing type mismatch
|
|
246
248
|
placement: legend?.placement,
|
|
247
249
|
renderExtraComponent: legend?.renderExtraComponent,
|
|
248
250
|
secondaryClick: legend?.secondaryClick,
|
|
249
251
|
showCalculations: legend?.showCalculations
|
|
250
252
|
}}
|
|
253
|
+
// @ts-expect-error - suppressing pre-existing type mismatch
|
|
251
254
|
legendRef={legendRef}
|
|
252
255
|
limitLegend={limitLegend}
|
|
253
256
|
lines={linesGraph}
|
|
254
257
|
setLines={setLinesGraph}
|
|
255
258
|
title={title}
|
|
259
|
+
// @ts-expect-error - suppressing pre-existing type mismatch
|
|
256
260
|
titleRef={titleRef}
|
|
257
261
|
>
|
|
258
262
|
<Tooltip
|
|
@@ -274,6 +278,7 @@ const ResponsiveBarChart = ({
|
|
|
274
278
|
placement="top"
|
|
275
279
|
>
|
|
276
280
|
<div className={classes.tooltipChildren}>
|
|
281
|
+
{/* @ts-expect-error - suppressing pre-existing type mismatch */}
|
|
277
282
|
<ChartSvgWrapper
|
|
278
283
|
allUnits={allUnits}
|
|
279
284
|
axis={axis}
|
|
@@ -61,13 +61,17 @@ const BarChartTooltip = ({
|
|
|
61
61
|
const displayHighLightedMetric = gt(filteredMetrics.length, 1);
|
|
62
62
|
|
|
63
63
|
const sortedMetrics = cond([
|
|
64
|
+
// @ts-expect-error - suppressing pre-existing type mismatch
|
|
64
65
|
[equals('name'), always(sortBy(path(['metric', 'name']), filteredMetrics))],
|
|
66
|
+
// @ts-expect-error - suppressing pre-existing type mismatch
|
|
65
67
|
[equals('ascending'), always(sortBy(prop('value'), filteredMetrics))],
|
|
66
68
|
[
|
|
67
69
|
equals('descending'),
|
|
70
|
+
// @ts-expect-error - suppressing pre-existing type mismatch
|
|
68
71
|
always(reverse(sortBy(prop('value'), filteredMetrics)))
|
|
69
72
|
],
|
|
70
73
|
[T, always(filteredMetrics)]
|
|
74
|
+
// @ts-expect-error - suppressing pre-existing type mismatch
|
|
71
75
|
])(sortOrder);
|
|
72
76
|
|
|
73
77
|
return (
|
|
@@ -89,6 +89,7 @@ const Graph = ({
|
|
|
89
89
|
|
|
90
90
|
return (
|
|
91
91
|
<svg height={normalizedHeight} width="100%">
|
|
92
|
+
{/* @ts-expect-error - suppressing pre-existing type mismatch */}
|
|
92
93
|
<BarStackComponent
|
|
93
94
|
color={colorScale}
|
|
94
95
|
data={[barStackData]}
|
|
@@ -135,6 +136,7 @@ const Graph = ({
|
|
|
135
136
|
height={bar.height}
|
|
136
137
|
key={`bar-stack-${barStack.index}-${bar.index}`}
|
|
137
138
|
left={!isVerticalBar && isFirstBar}
|
|
139
|
+
// @ts-expect-error - suppressing pre-existing type mismatch
|
|
138
140
|
onMouseDown={click}
|
|
139
141
|
radius={8}
|
|
140
142
|
right={!isVerticalBar && isLastBar}
|
|
@@ -150,6 +152,7 @@ const Graph = ({
|
|
|
150
152
|
fill="#000"
|
|
151
153
|
fontSize={12}
|
|
152
154
|
fontWeight={600}
|
|
155
|
+
// @ts-expect-error - suppressing pre-existing type mismatch
|
|
153
156
|
onMouseUp={click}
|
|
154
157
|
textAnchor="middle"
|
|
155
158
|
verticalAnchor="middle"
|
|
@@ -126,6 +126,9 @@ export default memo(RegularLine, (prevProps, nextProps) => {
|
|
|
126
126
|
equals(prevHighlight, nextHighlight) &&
|
|
127
127
|
equals(prevXScaleRange, nextXScaleRange) &&
|
|
128
128
|
equals(prevYScaleDomain, nextYScaleDomain) &&
|
|
129
|
-
equals(
|
|
129
|
+
equals(
|
|
130
|
+
pick(memoizedProps as Array<keyof Props>, prevProps),
|
|
131
|
+
pick(memoizedProps as Array<keyof Props>, nextProps)
|
|
132
|
+
)
|
|
130
133
|
);
|
|
131
134
|
});
|