@centreon/ui 26.5.14 → 26.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Typography } from '@mui/material';
|
|
2
|
+
import type { AutocompleteRenderInputParams } from '@mui/material/Autocomplete';
|
|
2
3
|
|
|
3
4
|
import {
|
|
4
5
|
equals,
|
|
@@ -15,7 +16,12 @@ import {
|
|
|
15
16
|
propEq,
|
|
16
17
|
remove
|
|
17
18
|
} from 'ramda';
|
|
18
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
type ChangeEvent,
|
|
21
|
+
type HTMLAttributes,
|
|
22
|
+
useEffect,
|
|
23
|
+
useState
|
|
24
|
+
} from 'react';
|
|
19
25
|
|
|
20
26
|
import TextField from '../../../Text';
|
|
21
27
|
import type { Props as SingleAutocompletefieldProps } from '..';
|
|
@@ -41,9 +47,15 @@ interface Props {
|
|
|
41
47
|
required?: boolean;
|
|
42
48
|
}
|
|
43
49
|
|
|
50
|
+
// biome-ignore lint/suspicious/noExplicitAny: HOC accepts varied multi-autocomplete shapes
|
|
51
|
+
type MultiAutocompleteLike = (props: any) => JSX.Element;
|
|
52
|
+
|
|
44
53
|
const DraggableAutocomplete = (
|
|
45
|
-
MultiAutocomplete:
|
|
46
|
-
): ((
|
|
54
|
+
MultiAutocomplete: MultiAutocompleteLike
|
|
55
|
+
): ((
|
|
56
|
+
props: Props &
|
|
57
|
+
(ConnectedAutoCompleteFieldProps<string> | SingleAutocompletefieldProps)
|
|
58
|
+
) => JSX.Element) => {
|
|
47
59
|
const InnerDraggableAutocompleteField = ({
|
|
48
60
|
onSelectedValuesChange,
|
|
49
61
|
initialValues,
|
|
@@ -66,12 +78,14 @@ const DraggableAutocomplete = (
|
|
|
66
78
|
);
|
|
67
79
|
const [inputText, setInputText] = useState<string | null>(null);
|
|
68
80
|
|
|
69
|
-
const onChangeSelectedValuesOrder = (
|
|
81
|
+
const onChangeSelectedValuesOrder = (
|
|
82
|
+
newSelectedValues: Array<DraggableSelectEntry>
|
|
83
|
+
): void => {
|
|
70
84
|
setSelectedValues(newSelectedValues);
|
|
71
85
|
onSelectedValuesChange?.(newSelectedValues);
|
|
72
86
|
};
|
|
73
87
|
|
|
74
|
-
const deleteValue = (id): void => {
|
|
88
|
+
const deleteValue = (id: string | number): void => {
|
|
75
89
|
itemHover?.(null);
|
|
76
90
|
setSelectedValues((values: Array<DraggableSelectEntry>) => {
|
|
77
91
|
const index = findIndex(propEq(id, 'id'), values);
|
|
@@ -84,7 +98,10 @@ const DraggableAutocomplete = (
|
|
|
84
98
|
});
|
|
85
99
|
};
|
|
86
100
|
|
|
87
|
-
const onChange = (
|
|
101
|
+
const onChange = (
|
|
102
|
+
_: React.SyntheticEvent,
|
|
103
|
+
newValue: Array<DraggableSelectEntry | string>
|
|
104
|
+
): void => {
|
|
88
105
|
if (isEmpty(newValue)) {
|
|
89
106
|
setInputText(null);
|
|
90
107
|
onSelectedValuesChange?.([]);
|
|
@@ -110,8 +127,8 @@ const DraggableAutocomplete = (
|
|
|
110
127
|
|
|
111
128
|
return;
|
|
112
129
|
}
|
|
113
|
-
const lastItem = last
|
|
114
|
-
newValue
|
|
130
|
+
const lastItem = last(
|
|
131
|
+
newValue as Array<DraggableSelectEntry>
|
|
115
132
|
) as DraggableSelectEntry;
|
|
116
133
|
|
|
117
134
|
const lastDraggableItem: DraggableSelectEntry = {
|
|
@@ -166,7 +183,10 @@ const DraggableAutocomplete = (
|
|
|
166
183
|
setInputText(null);
|
|
167
184
|
};
|
|
168
185
|
|
|
169
|
-
const renderOption = (
|
|
186
|
+
const renderOption = (
|
|
187
|
+
renderProps: HTMLAttributes<HTMLLIElement>,
|
|
188
|
+
option: DraggableSelectEntry
|
|
189
|
+
): JSX.Element => (
|
|
170
190
|
<div key={option.id} style={{ width: '100%' }}>
|
|
171
191
|
<li {...renderProps}>
|
|
172
192
|
<Typography variant="body2">{option.name}</Typography>
|
|
@@ -174,9 +194,14 @@ const DraggableAutocomplete = (
|
|
|
174
194
|
</div>
|
|
175
195
|
);
|
|
176
196
|
|
|
177
|
-
const renderInput = (
|
|
197
|
+
const renderInput = (
|
|
198
|
+
renderProps: AutocompleteRenderInputParams & {
|
|
199
|
+
inputLabel?: Record<string, unknown>;
|
|
200
|
+
}
|
|
201
|
+
): JSX.Element => (
|
|
178
202
|
<TextField
|
|
179
203
|
{...renderProps}
|
|
204
|
+
dataTestId={label}
|
|
180
205
|
error={error}
|
|
181
206
|
helperText={error}
|
|
182
207
|
label={label}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ListSubheader, Typography } from '@mui/material';
|
|
2
2
|
|
|
3
3
|
import type React from 'react';
|
|
4
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
4
5
|
import { useTranslation } from 'react-i18next';
|
|
5
6
|
|
|
6
7
|
import { Button } from '../../../../components/Button';
|
|
@@ -12,13 +13,20 @@ import {
|
|
|
12
13
|
import type { SelectEntry } from '../..';
|
|
13
14
|
import { useListboxStyles } from './Multi.styles';
|
|
14
15
|
|
|
16
|
+
interface CustomListboxProps extends HTMLAttributes<HTMLUListElement> {
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
label: string;
|
|
19
|
+
labelTotal: string;
|
|
20
|
+
handleSelectAllToggle: () => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
15
23
|
const CustomListbox = ({
|
|
16
24
|
children,
|
|
17
25
|
label,
|
|
18
26
|
labelTotal,
|
|
19
27
|
handleSelectAllToggle,
|
|
20
28
|
...props
|
|
21
|
-
}) => {
|
|
29
|
+
}: CustomListboxProps) => {
|
|
22
30
|
const { classes } = useListboxStyles();
|
|
23
31
|
|
|
24
32
|
return (
|
|
@@ -63,7 +71,9 @@ const ListboxComponent = ({
|
|
|
63
71
|
return;
|
|
64
72
|
}
|
|
65
73
|
|
|
66
|
-
return (
|
|
74
|
+
return (
|
|
75
|
+
listboxProps: HTMLAttributes<HTMLUListElement>
|
|
76
|
+
): JSX.Element | undefined => {
|
|
67
77
|
const allSelected =
|
|
68
78
|
options.length > 0 && options.every((opt) => isOptionSelected(opt));
|
|
69
79
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Chip, type ChipProps, Tooltip } from '@mui/material';
|
|
2
|
+
import type { AutocompleteRenderGetTagProps } from '@mui/material/Autocomplete';
|
|
2
3
|
import type { UseAutocompleteProps } from '@mui/material/useAutocomplete';
|
|
3
4
|
|
|
4
5
|
import { compose, includes, map, prop, reject, sortBy, toLower } from 'ramda';
|
|
@@ -23,8 +24,8 @@ export interface Props
|
|
|
23
24
|
chipProps?: ChipProps;
|
|
24
25
|
disableSortedOptions?: boolean;
|
|
25
26
|
disableSelectAll?: boolean;
|
|
26
|
-
getOptionTooltipLabel?: (option) => string;
|
|
27
|
-
getTagLabel?: (option) => string;
|
|
27
|
+
getOptionTooltipLabel?: (option: SelectEntry) => string;
|
|
28
|
+
getTagLabel?: (option: SelectEntry) => string;
|
|
28
29
|
optionProperty?: string;
|
|
29
30
|
customRenderTags?: (tags: React.ReactNode) => React.ReactNode;
|
|
30
31
|
total?: number;
|
|
@@ -36,9 +37,10 @@ const MultiAutocompleteField = ({
|
|
|
36
37
|
disableSortedOptions = false,
|
|
37
38
|
disableSelectAll = true,
|
|
38
39
|
optionProperty = 'name',
|
|
39
|
-
getOptionLabel = (option): string =>
|
|
40
|
+
getOptionLabel = (option: SelectEntry | string): string =>
|
|
40
41
|
typeof option === 'string' ? option : option?.name,
|
|
41
|
-
getTagLabel = (option): string =>
|
|
42
|
+
getTagLabel = (option: SelectEntry): string =>
|
|
43
|
+
(option as unknown as Record<string, string>)[optionProperty],
|
|
42
44
|
getOptionTooltipLabel,
|
|
43
45
|
chipProps,
|
|
44
46
|
customRenderTags,
|
|
@@ -48,8 +50,11 @@ const MultiAutocompleteField = ({
|
|
|
48
50
|
}: Props): JSX.Element => {
|
|
49
51
|
const { classes } = useStyles();
|
|
50
52
|
|
|
51
|
-
const renderTags = (
|
|
52
|
-
renderedValue
|
|
53
|
+
const renderTags = (
|
|
54
|
+
renderedValue: Array<SelectEntry>,
|
|
55
|
+
getTagProps: AutocompleteRenderGetTagProps
|
|
56
|
+
): Array<JSX.Element> =>
|
|
57
|
+
renderedValue.map((option: SelectEntry, index: number) => {
|
|
53
58
|
return (
|
|
54
59
|
<Tooltip
|
|
55
60
|
key={option.id}
|
|
@@ -78,11 +83,13 @@ const MultiAutocompleteField = ({
|
|
|
78
83
|
);
|
|
79
84
|
});
|
|
80
85
|
|
|
81
|
-
const getLimitTagsText = (more): JSX.Element =>
|
|
86
|
+
const getLimitTagsText = (more: number): JSX.Element => (
|
|
87
|
+
<Option>{`+${more}`}</Option>
|
|
88
|
+
);
|
|
82
89
|
|
|
83
90
|
const values = (value as Array<SelectEntry>) || [];
|
|
84
91
|
|
|
85
|
-
const isOptionSelected = ({ id }): boolean => {
|
|
92
|
+
const isOptionSelected = ({ id }: { id: SelectEntry['id'] }): boolean => {
|
|
86
93
|
const valueIds = map(prop('id'), values);
|
|
87
94
|
|
|
88
95
|
return includes(id, valueIds);
|
|
@@ -42,9 +42,12 @@ const useStyles = makeStyles()((theme) => ({
|
|
|
42
42
|
}
|
|
43
43
|
}));
|
|
44
44
|
|
|
45
|
+
// biome-ignore lint/suspicious/noExplicitAny: HOC accepts varied autocomplete shapes
|
|
46
|
+
type AutocompleteLike = (props: any) => JSX.Element;
|
|
47
|
+
|
|
45
48
|
const PopoverAutocomplete = (
|
|
46
|
-
AutocompleteField:
|
|
47
|
-
): ((props) => JSX.Element) => {
|
|
49
|
+
AutocompleteField: AutocompleteLike
|
|
50
|
+
): ((props: Props) => JSX.Element) => {
|
|
48
51
|
const InnerAutocomplete = ({
|
|
49
52
|
value,
|
|
50
53
|
label,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Autocomplete,
|
|
3
3
|
type AutocompleteProps,
|
|
4
|
+
type AutocompleteRenderInputParams,
|
|
4
5
|
CircularProgress,
|
|
5
6
|
InputAdornment,
|
|
6
7
|
type InputProps,
|
|
@@ -41,7 +42,7 @@ export type Props = {
|
|
|
41
42
|
displayPopupIcon?: boolean;
|
|
42
43
|
endAdornment?: ReactElement;
|
|
43
44
|
error?: string;
|
|
44
|
-
getOptionItemLabel?: (option) => string;
|
|
45
|
+
getOptionItemLabel?: (option: SelectEntry | undefined) => string | undefined;
|
|
45
46
|
hideInput?: boolean;
|
|
46
47
|
renderOption?: (
|
|
47
48
|
renderProps: HTMLAttributes<HTMLLIElement>,
|
|
@@ -50,7 +51,7 @@ export type Props = {
|
|
|
50
51
|
) => ReactElement;
|
|
51
52
|
label: string;
|
|
52
53
|
loading?: boolean;
|
|
53
|
-
onTextChange
|
|
54
|
+
onTextChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
54
55
|
placeholder?: string | undefined;
|
|
55
56
|
required?: boolean;
|
|
56
57
|
forceInputRenderValue?: boolean;
|
|
@@ -115,8 +116,11 @@ const AutocompleteField = forwardRef(
|
|
|
115
116
|
const { t } = useTranslation();
|
|
116
117
|
const theme = useTheme();
|
|
117
118
|
|
|
118
|
-
const areSelectEntriesEqual = (
|
|
119
|
-
|
|
119
|
+
const areSelectEntriesEqual = (
|
|
120
|
+
option: SelectEntry,
|
|
121
|
+
value: SelectEntry
|
|
122
|
+
): boolean => {
|
|
123
|
+
const identifyingProps: Array<keyof SelectEntry> = ['id', 'name'];
|
|
120
124
|
|
|
121
125
|
return equals(
|
|
122
126
|
pick(identifyingProps, option),
|
|
@@ -126,7 +130,10 @@ const AutocompleteField = forwardRef(
|
|
|
126
130
|
|
|
127
131
|
const renderOptions = renderOption
|
|
128
132
|
? renderOption
|
|
129
|
-
: (
|
|
133
|
+
: (
|
|
134
|
+
props: HTMLAttributes<HTMLLIElement>,
|
|
135
|
+
option: SelectEntry
|
|
136
|
+
): ReactElement => {
|
|
130
137
|
return (
|
|
131
138
|
<li
|
|
132
139
|
className={classes.options}
|
|
@@ -135,13 +142,15 @@ const AutocompleteField = forwardRef(
|
|
|
135
142
|
<Option
|
|
136
143
|
thumbnailUrl={displayOptionThumbnail ? option.url : undefined}
|
|
137
144
|
>
|
|
138
|
-
{getOptionItemLabel(option)}
|
|
145
|
+
{getOptionItemLabel(option) || ''}
|
|
139
146
|
</Option>
|
|
140
147
|
</li>
|
|
141
148
|
);
|
|
142
149
|
};
|
|
143
150
|
|
|
144
|
-
const renderInput = (
|
|
151
|
+
const renderInput = (
|
|
152
|
+
params: AutocompleteRenderInputParams
|
|
153
|
+
): ReactElement => {
|
|
145
154
|
return (
|
|
146
155
|
<TextField
|
|
147
156
|
{...params}
|
|
@@ -174,7 +183,8 @@ const AutocompleteField = forwardRef(
|
|
|
174
183
|
...(forceInputRenderValue
|
|
175
184
|
? {
|
|
176
185
|
value: getOptionItemLabel(
|
|
177
|
-
autocompleteProps?.value
|
|
186
|
+
(autocompleteProps?.value as SelectEntry | undefined) ||
|
|
187
|
+
undefined
|
|
178
188
|
)
|
|
179
189
|
}
|
|
180
190
|
: {}),
|
|
@@ -207,13 +217,16 @@ const AutocompleteField = forwardRef(
|
|
|
207
217
|
classes: {
|
|
208
218
|
marginDense: classes.inputLabel,
|
|
209
219
|
shrink: classes.inputLabelShrink
|
|
210
|
-
}
|
|
220
|
+
} as unknown as Record<string, string>
|
|
211
221
|
}
|
|
212
222
|
}}
|
|
213
223
|
value={
|
|
214
224
|
inputValue ||
|
|
215
225
|
(forceInputRenderValue
|
|
216
|
-
? getOptionItemLabel(
|
|
226
|
+
? getOptionItemLabel(
|
|
227
|
+
(autocompleteProps?.value as SelectEntry | undefined) ||
|
|
228
|
+
undefined
|
|
229
|
+
)
|
|
217
230
|
: undefined) ||
|
|
218
231
|
undefined
|
|
219
232
|
}
|
|
@@ -47,11 +47,11 @@ const IconPopoverMultiAutocomplete = ({
|
|
|
47
47
|
const theme = useTheme();
|
|
48
48
|
const { classes } = useStyles();
|
|
49
49
|
const { t } = useTranslation();
|
|
50
|
-
const [anchorEl, setAnchorEl] = useState();
|
|
50
|
+
const [anchorEl, setAnchorEl] = useState<HTMLElement | undefined>();
|
|
51
51
|
|
|
52
52
|
const isOpen = Boolean(anchorEl);
|
|
53
53
|
|
|
54
|
-
const close = (reason
|
|
54
|
+
const close = (reason?: { type?: string }): void => {
|
|
55
55
|
const isClosedByInputClick = reason?.type === 'mousedown';
|
|
56
56
|
|
|
57
57
|
if (isClosedByInputClick) {
|
|
@@ -60,14 +60,14 @@ const IconPopoverMultiAutocomplete = ({
|
|
|
60
60
|
setAnchorEl(undefined);
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
const toggle = (event): void => {
|
|
63
|
+
const toggle = (event: React.MouseEvent): void => {
|
|
64
64
|
if (isOpen) {
|
|
65
65
|
close();
|
|
66
66
|
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
setAnchorEl(event.currentTarget);
|
|
70
|
+
setAnchorEl(event.currentTarget as HTMLElement);
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
const isSelected = (id: number | string): boolean => {
|
|
@@ -89,7 +89,10 @@ const IconPopoverMultiAutocomplete = ({
|
|
|
89
89
|
<div>
|
|
90
90
|
<IconButton
|
|
91
91
|
ariaLabel={title}
|
|
92
|
-
onClick={
|
|
92
|
+
onClick={
|
|
93
|
+
toggle as ((event: React.MouseEvent) => void) &
|
|
94
|
+
React.MouseEventHandler<HTMLButtonElement>
|
|
95
|
+
}
|
|
93
96
|
size="large"
|
|
94
97
|
title={title}
|
|
95
98
|
>
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
ListSubheader,
|
|
8
8
|
MenuItem,
|
|
9
9
|
Select,
|
|
10
|
+
type SelectChangeEvent,
|
|
10
11
|
type SelectProps,
|
|
11
12
|
type Theme
|
|
12
13
|
} from '@mui/material';
|
|
@@ -78,13 +79,13 @@ const SelectField = ({
|
|
|
78
79
|
}: Props): JSX.Element => {
|
|
79
80
|
const { classes, cx } = useStyles();
|
|
80
81
|
|
|
81
|
-
const getOption = (id): SelectEntry => {
|
|
82
|
+
const getOption = (id: unknown): SelectEntry => {
|
|
82
83
|
return options.find(propEq(id, 'id')) as SelectEntry;
|
|
83
84
|
};
|
|
84
85
|
|
|
85
|
-
const changeOption = (event): void => {
|
|
86
|
+
const changeOption = (event: SelectChangeEvent<unknown>): void => {
|
|
86
87
|
if (!isNil(event.target.value)) {
|
|
87
|
-
onChange(event);
|
|
88
|
+
onChange(event as unknown as React.ChangeEvent<HTMLInputElement>);
|
|
88
89
|
}
|
|
89
90
|
};
|
|
90
91
|
|
|
@@ -34,8 +34,8 @@ const ColumnMultiSelect = ({
|
|
|
34
34
|
columns
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
const selectColumnIds = (updatedColumns): void => {
|
|
38
|
-
onSelectColumns?.(updatedColumns.map(prop('id')));
|
|
37
|
+
const selectColumnIds = (updatedColumns: Array<SelectEntry>): void => {
|
|
38
|
+
onSelectColumns?.(updatedColumns.map(prop('id')) as Array<string>);
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
return (
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import TablePagination
|
|
1
|
+
import TablePagination, {
|
|
2
|
+
type TablePaginationProps
|
|
3
|
+
} from '@mui/material/TablePagination';
|
|
2
4
|
|
|
3
5
|
import { equals } from 'ramda';
|
|
4
6
|
import { memo } from 'react';
|
|
5
7
|
|
|
6
|
-
const Pagination = (props): JSX.Element => (
|
|
8
|
+
const Pagination = (props: TablePaginationProps): JSX.Element => (
|
|
7
9
|
<TablePagination
|
|
8
10
|
classes={{
|
|
9
11
|
toolbar: 'pl-1 overflow-hidden h-8'
|
|
@@ -22,15 +22,21 @@ const PaginationActions = ({
|
|
|
22
22
|
}: TablePaginationActionsProps): JSX.Element => {
|
|
23
23
|
const { t } = useTranslation();
|
|
24
24
|
|
|
25
|
-
const changeToFirstPage = (
|
|
25
|
+
const changeToFirstPage = (
|
|
26
|
+
event: React.MouseEvent<HTMLButtonElement>
|
|
27
|
+
): void => {
|
|
26
28
|
onPageChange(event, 0);
|
|
27
29
|
};
|
|
28
30
|
|
|
29
|
-
const changeToPreviousPage = (
|
|
31
|
+
const changeToPreviousPage = (
|
|
32
|
+
event: React.MouseEvent<HTMLButtonElement>
|
|
33
|
+
): void => {
|
|
30
34
|
onPageChange(event, page - 1);
|
|
31
35
|
};
|
|
32
36
|
|
|
33
|
-
const changeToNextPage = (
|
|
37
|
+
const changeToNextPage = (
|
|
38
|
+
event: React.MouseEvent<HTMLButtonElement>
|
|
39
|
+
): void => {
|
|
34
40
|
onPageChange(event, page + 1);
|
|
35
41
|
};
|
|
36
42
|
|
|
@@ -39,7 +45,9 @@ const PaginationActions = ({
|
|
|
39
45
|
const isFirstPage = page === 0;
|
|
40
46
|
const isLastPage = page >= lastPage;
|
|
41
47
|
|
|
42
|
-
const changeToLastPage = (
|
|
48
|
+
const changeToLastPage = (
|
|
49
|
+
event: React.MouseEvent<HTMLButtonElement>
|
|
50
|
+
): void => {
|
|
43
51
|
onPageChange(event, Math.max(0, lastPage));
|
|
44
52
|
};
|
|
45
53
|
|
|
@@ -117,17 +117,29 @@ const MemoListingActionBar = ({
|
|
|
117
117
|
|
|
118
118
|
const { themeMode } = useAtomValue(userAtom);
|
|
119
119
|
|
|
120
|
-
const changeRowPerPage = (
|
|
120
|
+
const changeRowPerPage = (
|
|
121
|
+
event: React.ChangeEvent<HTMLInputElement>
|
|
122
|
+
): void => {
|
|
121
123
|
onLimitChange?.(event.target.value);
|
|
122
124
|
onPaginate?.(0);
|
|
123
125
|
};
|
|
124
126
|
|
|
125
|
-
const changePage = (
|
|
127
|
+
const changePage = (
|
|
128
|
+
_: React.MouseEvent<HTMLButtonElement> | null,
|
|
129
|
+
value: number
|
|
130
|
+
): void => {
|
|
126
131
|
onPaginate?.(value);
|
|
127
132
|
};
|
|
128
133
|
|
|
129
|
-
const labelDisplayedRows = ({
|
|
130
|
-
|
|
134
|
+
const labelDisplayedRows = ({
|
|
135
|
+
from,
|
|
136
|
+
to,
|
|
137
|
+
count
|
|
138
|
+
}: {
|
|
139
|
+
from: number;
|
|
140
|
+
to: number;
|
|
141
|
+
count: number;
|
|
142
|
+
}): string => `${from}-${to} ${t(labelOf)} ${count}`;
|
|
131
143
|
|
|
132
144
|
return useMemoComponent({
|
|
133
145
|
Component: (
|
|
@@ -188,13 +200,13 @@ const MemoListingActionBar = ({
|
|
|
188
200
|
[classes.moving]: moveTablePagination
|
|
189
201
|
})}
|
|
190
202
|
colSpan={3}
|
|
191
|
-
count={totalRows}
|
|
203
|
+
count={totalRows ?? 0}
|
|
192
204
|
labelDisplayedRows={labelDisplayedRows}
|
|
193
205
|
labelRowsPerPage={null}
|
|
194
206
|
onPageChange={changePage}
|
|
195
207
|
onRowsPerPageChange={changeRowPerPage}
|
|
196
|
-
page={currentPage}
|
|
197
|
-
rowsPerPage={limit}
|
|
208
|
+
page={currentPage ?? 0}
|
|
209
|
+
rowsPerPage={limit ?? 10}
|
|
198
210
|
rowsPerPageOptions={[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]}
|
|
199
211
|
SelectProps={{
|
|
200
212
|
id: labelRowsPerPage,
|
|
@@ -17,14 +17,14 @@ import EllipsisTypography from './EllipsisTypography';
|
|
|
17
17
|
|
|
18
18
|
interface Props {
|
|
19
19
|
column: Column;
|
|
20
|
-
disableRowCondition: (row) => boolean;
|
|
21
|
-
getHighlightRowCondition?: (row) => boolean;
|
|
20
|
+
disableRowCondition: (row: Record<string, unknown>) => boolean;
|
|
21
|
+
getHighlightRowCondition?: (row: Record<string, unknown>) => boolean;
|
|
22
22
|
isRowHovered: boolean;
|
|
23
23
|
isRowSelected: boolean;
|
|
24
24
|
labelCollapse?: string;
|
|
25
25
|
labelExpand?: string;
|
|
26
26
|
listingVariant?: ListingVariant;
|
|
27
|
-
row
|
|
27
|
+
row: Record<string, unknown>;
|
|
28
28
|
rowColorConditions?: Array<RowColorCondition>;
|
|
29
29
|
subItemsRowProperty?: string;
|
|
30
30
|
}
|
|
@@ -27,8 +27,8 @@ interface GetBackgroundColorProps extends Omit<Props, 'isRowHighlighted'> {
|
|
|
27
27
|
interface GetRowHighlightStyleProps {
|
|
28
28
|
isRowHighlighted?: boolean;
|
|
29
29
|
theme: Theme;
|
|
30
|
-
disableRowCondition;
|
|
31
|
-
row
|
|
30
|
+
disableRowCondition: (row: Record<string, unknown>) => boolean;
|
|
31
|
+
row?: Record<string, unknown>;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const getBackgroundColor = ({
|
|
@@ -38,7 +38,7 @@ const getBackgroundColor = ({
|
|
|
38
38
|
disableRowCondition,
|
|
39
39
|
theme
|
|
40
40
|
}: GetBackgroundColorProps): string => {
|
|
41
|
-
if (disableRowCondition(row)) {
|
|
41
|
+
if (disableRowCondition(row as Record<string, unknown>)) {
|
|
42
42
|
return alpha(theme.palette.common.black, theme.palette.action.focusOpacity);
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -47,7 +47,7 @@ const getBackgroundColor = ({
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
const foundCondition = rowColorConditions?.find(({ condition }) =>
|
|
50
|
-
condition(row)
|
|
50
|
+
condition(row as Record<string, unknown>)
|
|
51
51
|
);
|
|
52
52
|
|
|
53
53
|
if (!isNil(foundCondition)) {
|
|
@@ -67,15 +67,17 @@ const getRowTextColor = ({
|
|
|
67
67
|
return { color: theme.palette.text.primary };
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
if (disableRowCondition(row)) {
|
|
70
|
+
if (disableRowCondition(row as Record<string, unknown>)) {
|
|
71
71
|
return { color: alpha(theme.palette.text.secondary, 0.5) };
|
|
72
72
|
}
|
|
73
|
+
|
|
74
|
+
return undefined;
|
|
73
75
|
};
|
|
74
76
|
|
|
75
77
|
interface Props
|
|
76
78
|
extends Pick<
|
|
77
79
|
DataCellProps,
|
|
78
|
-
'isRowHovered' | '
|
|
80
|
+
'isRowHovered' | 'rowColorConditions' | 'disableRowCondition'
|
|
79
81
|
>,
|
|
80
82
|
TableCellProps {
|
|
81
83
|
displaySubItemsCaret?: boolean;
|
|
@@ -83,16 +85,20 @@ interface Props
|
|
|
83
85
|
labelCollapse?: string;
|
|
84
86
|
labelExpand?: string;
|
|
85
87
|
listingVariant?: ListingVariant;
|
|
88
|
+
row?: Record<string, unknown>;
|
|
86
89
|
subItemsRowProperty?: string;
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
const isPivotExistInTheList = (
|
|
90
|
-
id
|
|
93
|
+
id: number | string
|
|
91
94
|
): ((list: Array<number | string>) => boolean) => includes(id);
|
|
92
95
|
|
|
93
96
|
const handleSubItems = ({
|
|
94
97
|
currentSubItemsPivots,
|
|
95
98
|
id
|
|
99
|
+
}: {
|
|
100
|
+
currentSubItemsPivots: Array<number | string>;
|
|
101
|
+
id: number | string;
|
|
96
102
|
}): Array<number | string> => {
|
|
97
103
|
if (isPivotExistInTheList(id)(currentSubItemsPivots)) {
|
|
98
104
|
return reject(equals(id), currentSubItemsPivots);
|
|
@@ -121,20 +127,27 @@ const Cell = ({
|
|
|
121
127
|
|
|
122
128
|
const { children } = props;
|
|
123
129
|
|
|
124
|
-
const rowId = row?.id;
|
|
130
|
+
const rowId = row?.id as number | string | undefined;
|
|
125
131
|
|
|
126
|
-
const click = (e): void => {
|
|
132
|
+
const click = (e: React.MouseEvent): void => {
|
|
127
133
|
e.preventDefault();
|
|
128
134
|
e.stopPropagation();
|
|
129
135
|
|
|
130
136
|
setSubItemsPivots((currentSubItemsPivots) =>
|
|
131
|
-
handleSubItems({
|
|
137
|
+
handleSubItems({
|
|
138
|
+
currentSubItemsPivots,
|
|
139
|
+
id: rowId as number | string
|
|
140
|
+
})
|
|
132
141
|
);
|
|
133
142
|
};
|
|
134
143
|
|
|
135
|
-
const isSubItemsExpanded = isPivotExistInTheList(rowId)(
|
|
144
|
+
const isSubItemsExpanded = isPivotExistInTheList(rowId as number | string)(
|
|
145
|
+
subItemsPivots
|
|
146
|
+
);
|
|
136
147
|
|
|
137
|
-
const hasSubItems =
|
|
148
|
+
const hasSubItems = Boolean(
|
|
149
|
+
subItemsRowProperty && row?.[subItemsRowProperty]
|
|
150
|
+
);
|
|
138
151
|
|
|
139
152
|
return (
|
|
140
153
|
<TableCell
|
|
@@ -169,7 +182,7 @@ const Cell = ({
|
|
|
169
182
|
{displaySubItemsCaret && hasSubItems && (
|
|
170
183
|
<IconButton
|
|
171
184
|
ariaLabel={`${isSubItemsExpanded ? labelCollapse : labelExpand} ${
|
|
172
|
-
row
|
|
185
|
+
row?.id
|
|
173
186
|
}`}
|
|
174
187
|
onClick={click}
|
|
175
188
|
size="small"
|
|
@@ -19,10 +19,10 @@ type Props = Pick<
|
|
|
19
19
|
'columnConfiguration' | 'sortField' | 'sortOrder' | 'onSort'
|
|
20
20
|
> & {
|
|
21
21
|
areColumnsEditable: boolean;
|
|
22
|
-
className
|
|
22
|
+
className?: string;
|
|
23
23
|
column: Column;
|
|
24
24
|
itemRef: React.RefObject<HTMLDivElement>;
|
|
25
|
-
style;
|
|
25
|
+
style: React.CSSProperties;
|
|
26
26
|
} & StylesProps;
|
|
27
27
|
|
|
28
28
|
const ListingHeaderCell = ({
|