@centreon/ui 24.10.12 → 24.10.13
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 -2
- package/public/mockServiceWorker.js +1 -1
- package/src/Button/Icon/index.tsx +3 -1
- package/src/Dashboard/Dashboard.styles.ts +3 -4
- package/src/Dashboard/DashboardLayout.stories.tsx +1 -1
- package/src/Dashboard/Grid.tsx +11 -17
- package/src/Dashboard/Layout.tsx +27 -56
- package/src/Dialog/UnsavedChanges/index.tsx +15 -13
- package/src/Dialog/UnsavedChanges/translatedLabels.ts +15 -13
- package/src/Form/Form.tsx +0 -1
- package/src/Form/Inputs/Autocomplete.tsx +1 -1
- package/src/Form/Inputs/ConnectedAutocomplete.tsx +5 -2
- package/src/Form/Inputs/Grid.tsx +7 -1
- package/src/Form/Inputs/Radio.tsx +1 -1
- package/src/Form/Inputs/Switch.tsx +1 -1
- package/src/Form/Inputs/Text.tsx +1 -1
- package/src/Form/Inputs/index.tsx +25 -24
- package/src/Form/Inputs/models.ts +2 -0
- package/src/Graph/BarChart/BarChart.cypress.spec.tsx +3 -3
- package/src/Graph/BarChart/BarChart.tsx +24 -31
- package/src/Graph/BarChart/BarGroup.tsx +32 -59
- package/src/Graph/BarChart/BarStack.tsx +64 -13
- package/src/Graph/BarChart/MemoizedGroup.tsx +123 -0
- package/src/Graph/BarChart/ResponsiveBarChart.tsx +21 -7
- package/src/Graph/BarStack/BarStack.cypress.spec.tsx +87 -9
- package/src/Graph/BarStack/BarStack.stories.tsx +13 -4
- package/src/Graph/BarStack/BarStack.styles.ts +57 -33
- package/src/Graph/BarStack/Graph.tsx +173 -0
- package/src/Graph/BarStack/GraphAndLegend.tsx +117 -0
- package/src/Graph/BarStack/ResponsiveBarStack.tsx +61 -168
- package/src/Graph/BarStack/constants.ts +5 -0
- package/src/Graph/BarStack/models.ts +0 -1
- package/src/Graph/BarStack/useGraphAndLegend.ts +84 -0
- package/src/Graph/BarStack/useResponsiveBarStack.ts +73 -97
- package/src/Graph/Chart/Chart.cypress.spec.tsx +14 -26
- package/src/Graph/Chart/Chart.stories.tsx +1 -1
- package/src/Graph/Chart/Chart.tsx +53 -37
- package/src/Graph/Chart/InteractiveComponents/AnchorPoint/GuidingLines.tsx +3 -3
- package/src/Graph/Chart/InteractiveComponents/AnchorPoint/useTickGraph.ts +19 -6
- package/src/Graph/Chart/Legend/Legend.styles.ts +25 -11
- package/src/Graph/Chart/Legend/index.tsx +6 -24
- package/src/Graph/Chart/index.tsx +34 -43
- package/src/Graph/Chart/models.ts +0 -1
- package/src/Graph/Chart/useChartData.ts +19 -1
- package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +20 -2
- package/src/Graph/HeatMap/model.ts +6 -2
- package/src/Graph/Legend/Legend.styles.ts +10 -0
- package/src/Graph/Legend/Legend.tsx +6 -1
- package/src/Graph/SingleBar/ResponsiveSingleBar.tsx +9 -10
- package/src/Graph/SingleBar/ThresholdLine.tsx +6 -6
- package/src/Graph/Text/Text.styles.ts +2 -2
- package/src/Graph/Text/Text.tsx +23 -10
- package/src/Graph/Timeline/ResponsiveTimeline.tsx +152 -0
- package/src/Graph/Timeline/Timeline.cypress.spec.tsx +148 -0
- package/src/Graph/Timeline/Timeline.stories.tsx +91 -0
- package/src/Graph/Timeline/Timeline.tsx +28 -0
- package/src/Graph/Timeline/index.ts +1 -0
- package/src/Graph/Timeline/models.ts +20 -0
- package/src/Graph/Timeline/timeline.styles.ts +11 -0
- package/src/Graph/Timeline/translatedLabel.ts +6 -0
- package/src/Graph/Timeline/useTimeline.ts +90 -0
- package/src/Graph/Tree/Links.tsx +2 -2
- package/src/Graph/Tree/Tree.tsx +2 -2
- package/src/Graph/Tree/constants.ts +1 -1
- package/src/Graph/common/Axes/index.tsx +1 -1
- package/src/Graph/common/Axes/useAxisY.ts +8 -4
- package/src/Graph/common/BaseChart/BaseChart.tsx +3 -12
- package/src/Graph/common/BaseChart/ChartSvgWrapper.tsx +12 -4
- package/src/Graph/common/BaseChart/Header/index.tsx +3 -1
- package/src/Graph/common/BaseChart/useComputeBaseChartDimensions.ts +23 -11
- package/src/Graph/common/BaseChart/useComputeYAxisMaxCharacters.ts +92 -0
- package/src/Graph/common/models.ts +7 -8
- package/src/Graph/common/timeSeries/index.test.ts +1 -1
- package/src/Graph/common/timeSeries/index.ts +56 -29
- package/src/Graph/common/timeSeries/models.ts +2 -0
- package/src/Graph/common/utils.ts +51 -3
- package/src/Graph/index.ts +4 -1
- package/src/Graph/mockedData/lastDayWithNullValues.json +6 -6
- package/src/Graph/mockedData/pingServiceLinesBars.json +47 -47
- package/src/Icon/DowntimeIcon.tsx +8 -1
- package/src/Icon/FlappingIcon.tsx +22 -0
- package/src/Icon/index.ts +1 -0
- package/src/InputField/Select/Autocomplete/Connected/Multi/index.test.tsx +21 -1
- package/src/InputField/Select/Autocomplete/Connected/index.test.tsx +2 -2
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +52 -15
- package/src/InputField/Select/Autocomplete/Multi/index.stories.tsx +19 -0
- package/src/InputField/Select/Autocomplete/Multi/index.tsx +8 -5
- package/src/InputField/Select/Autocomplete/index.tsx +79 -54
- package/src/InputField/Text/index.tsx +6 -4
- package/src/InputField/translatedLabels.ts +2 -0
- package/src/Listing/ActionBar/index.tsx +1 -1
- package/src/Listing/Listing.styles.ts +3 -3
- package/src/Listing/index.tsx +40 -37
- package/src/Listing/models.ts +0 -8
- package/src/Listing/useStyleTable.ts +58 -32
- package/src/MultiSelectEntries/index.tsx +2 -0
- package/src/PopoverMenu/index.tsx +2 -9
- package/src/SortableItems/index.tsx +0 -1
- package/src/ThemeProvider/index.tsx +1 -1
- package/src/ThemeProvider/palettes.ts +6 -0
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +2 -3
- package/src/TimePeriods/DateTimePickerInput.tsx +3 -1
- package/src/api/buildListingEndpoint/getSearchQueryParameterValue.ts +7 -1
- package/src/api/buildListingEndpoint/models.ts +1 -0
- package/src/api/customFetch.ts +4 -1
- package/src/api/models.ts +9 -0
- package/src/api/useGraphQuery/index.ts +117 -20
- package/src/api/useGraphQuery/models.ts +1 -0
- package/src/api/useMutationQuery/index.ts +1 -1
- package/src/components/DataTable/DataTable.styles.ts +1 -1
- package/src/components/DataTable/EmptyState/DataTableEmptyState.styles.ts +2 -1
- package/src/components/DataTable/EmptyState/DataTableEmptyState.tsx +4 -1
- package/src/components/DataTable/Item/DataTableItem.styles.ts +28 -2
- package/src/components/DataTable/Item/DataTableItem.tsx +19 -4
- package/src/components/Form/FormActions.tsx +21 -12
- package/src/components/Layout/AreaIndicator.tsx +1 -1
- package/src/components/Layout/PageLayout/PageLayout.styles.ts +2 -7
- package/src/components/Layout/PageLayout/PageLayoutBody.tsx +0 -1
- package/src/components/Zoom/Zoom.tsx +9 -2
- package/src/components/Zoom/ZoomContent.tsx +143 -136
- package/src/components/Zoom/models.ts +18 -15
- package/src/components/Zoom/useMinimap.ts +5 -8
- package/src/components/Zoom/useZoom.ts +3 -3
- package/src/index.ts +2 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/useLocale/index.ts +9 -0
- package/src/utils/useLocale/useLocale.cypress.spec.tsx +38 -0
- package/src/utils/useLocaleDateTimeFormat/index.ts +4 -2
- package/src/utils/usePluralizedTranslation.ts +2 -3
- package/src/Graph/common/timeSeries/index.test.ts-E +0 -622
- package/src/components/CrudPage/Actions/Actions.styles.ts +0 -16
- package/src/components/CrudPage/Actions/Actions.tsx +0 -24
- package/src/components/CrudPage/Actions/AddButton.tsx +0 -23
- package/src/components/CrudPage/Actions/Filters.tsx +0 -25
- package/src/components/CrudPage/Actions/Search.tsx +0 -31
- package/src/components/CrudPage/Actions/useSearch.tsx +0 -24
- package/src/components/CrudPage/Columns/Actions.tsx +0 -88
- package/src/components/CrudPage/CrudPage.cypress.spec.tsx +0 -559
- package/src/components/CrudPage/CrudPage.stories.tsx +0 -278
- package/src/components/CrudPage/CrudPageRoot.tsx +0 -142
- package/src/components/CrudPage/DeleteModal.tsx +0 -77
- package/src/components/CrudPage/Form/AddModal.tsx +0 -35
- package/src/components/CrudPage/Form/Buttons.tsx +0 -98
- package/src/components/CrudPage/Form/UpdateModal.tsx +0 -60
- package/src/components/CrudPage/Listing.tsx +0 -63
- package/src/components/CrudPage/atoms.ts +0 -30
- package/src/components/CrudPage/hooks/useDeleteItem.ts +0 -53
- package/src/components/CrudPage/hooks/useGetItem.ts +0 -36
- package/src/components/CrudPage/hooks/useGetItems.ts +0 -67
- package/src/components/CrudPage/hooks/useListingQueryKey.ts +0 -31
- package/src/components/CrudPage/index.tsx +0 -7
- package/src/components/CrudPage/models.ts +0 -118
- package/src/components/CrudPage/utils.ts +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
equals,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import { CircularProgress, useTheme } from '@mui/material';
|
|
18
18
|
|
|
19
19
|
import { Props as AutocompleteFieldProps } from '..';
|
|
20
|
-
import { ListingModel, SelectEntry } from '../../../..';
|
|
20
|
+
import { ListingMapModel, ListingModel, SelectEntry } from '../../../..';
|
|
21
21
|
import {
|
|
22
22
|
ConditionsSearchParameter,
|
|
23
23
|
SearchParameter
|
|
@@ -30,13 +30,20 @@ import {
|
|
|
30
30
|
} from '../../../../utils';
|
|
31
31
|
import Option from '../../Option';
|
|
32
32
|
|
|
33
|
+
interface OptionResult<T> {
|
|
34
|
+
result: Array<T>;
|
|
35
|
+
limit: number;
|
|
36
|
+
total: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
33
39
|
export interface ConnectedAutoCompleteFieldProps<TData> {
|
|
34
40
|
allowUniqOption?: boolean;
|
|
35
41
|
baseEndpoint?: string;
|
|
36
42
|
changeIdValue: (item: TData) => number | string;
|
|
37
|
-
|
|
43
|
+
exclusionOptionProperty?: keyof SelectEntry;
|
|
38
44
|
field: string;
|
|
39
45
|
getEndpoint: ({ search, page }) => string;
|
|
46
|
+
decoder?;
|
|
40
47
|
getRenderedOptionText: (option: TData) => string;
|
|
41
48
|
getRequestHeaders?: HeadersInit;
|
|
42
49
|
initialPage: number;
|
|
@@ -52,10 +59,11 @@ const ConnectedAutocompleteField = (
|
|
|
52
59
|
const InnerConnectedAutocompleteField = <TData extends { name: string }>({
|
|
53
60
|
initialPage = 1,
|
|
54
61
|
getEndpoint,
|
|
62
|
+
decoder,
|
|
55
63
|
field,
|
|
56
64
|
labelKey,
|
|
57
65
|
open,
|
|
58
|
-
|
|
66
|
+
exclusionOptionProperty = 'id',
|
|
59
67
|
searchConditions = [],
|
|
60
68
|
getRenderedOptionText = (option): string => option.name?.toString(),
|
|
61
69
|
getRequestHeaders,
|
|
@@ -89,8 +97,9 @@ const ConnectedAutocompleteField = (
|
|
|
89
97
|
const theme = useTheme();
|
|
90
98
|
|
|
91
99
|
const { fetchQuery, isFetching, prefetchNextPage } = useFetchQuery<
|
|
92
|
-
ListingModel<TData>
|
|
100
|
+
ListingModel<TData> | ListingMapModel<TData>
|
|
93
101
|
>({
|
|
102
|
+
decoder,
|
|
94
103
|
baseEndpoint,
|
|
95
104
|
fetchHeaders: getRequestHeaders,
|
|
96
105
|
getEndpoint: (params) => {
|
|
@@ -106,13 +115,39 @@ const ConnectedAutocompleteField = (
|
|
|
106
115
|
],
|
|
107
116
|
isPaginated: true,
|
|
108
117
|
queryOptions: {
|
|
109
|
-
|
|
118
|
+
gcTime: 0,
|
|
110
119
|
enabled: false,
|
|
111
120
|
staleTime: 0,
|
|
112
121
|
suspense: false
|
|
113
122
|
}
|
|
114
123
|
});
|
|
115
124
|
|
|
125
|
+
const getOptionResult = useCallback(
|
|
126
|
+
(
|
|
127
|
+
newOptions: ListingModel<TData> | ListingMapModel<TData>
|
|
128
|
+
): OptionResult<TData> => {
|
|
129
|
+
if ('result' in newOptions)
|
|
130
|
+
return {
|
|
131
|
+
result: newOptions.result || [],
|
|
132
|
+
total: newOptions.meta.total || 1,
|
|
133
|
+
limit: newOptions.meta.limit || 1
|
|
134
|
+
};
|
|
135
|
+
if ('content' in newOptions)
|
|
136
|
+
return {
|
|
137
|
+
result: newOptions.content || [],
|
|
138
|
+
total: newOptions.totalElements || 1,
|
|
139
|
+
limit: newOptions.size || 1
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
return {
|
|
143
|
+
result: [],
|
|
144
|
+
total: 1,
|
|
145
|
+
limit: 1
|
|
146
|
+
};
|
|
147
|
+
},
|
|
148
|
+
[]
|
|
149
|
+
);
|
|
150
|
+
|
|
116
151
|
const lastOptionRef = useIntersectionObserver({
|
|
117
152
|
action: () => setPage(page + 1),
|
|
118
153
|
loading: isFetching,
|
|
@@ -134,10 +169,11 @@ const ConnectedAutocompleteField = (
|
|
|
134
169
|
: [selectedValue];
|
|
135
170
|
|
|
136
171
|
return {
|
|
137
|
-
|
|
172
|
+
operator: '$and',
|
|
173
|
+
field,
|
|
138
174
|
values: {
|
|
139
175
|
$ni: map(
|
|
140
|
-
prop(
|
|
176
|
+
prop(exclusionOptionProperty),
|
|
141
177
|
selectedValues as Array<
|
|
142
178
|
Record<keyof SelectEntry, string | undefined>
|
|
143
179
|
>
|
|
@@ -154,6 +190,7 @@ const ConnectedAutocompleteField = (
|
|
|
154
190
|
}
|
|
155
191
|
|
|
156
192
|
return {
|
|
193
|
+
operator: '$and',
|
|
157
194
|
field,
|
|
158
195
|
values: {
|
|
159
196
|
$lk: `%${searchedValue}%`
|
|
@@ -240,12 +277,14 @@ const ConnectedAutocompleteField = (
|
|
|
240
277
|
|
|
241
278
|
const moreOptions = page > 1 ? options : [];
|
|
242
279
|
|
|
280
|
+
const { result, limit, total } = getOptionResult(newOptions);
|
|
281
|
+
|
|
243
282
|
const formattedList = changeIdValue
|
|
244
|
-
?
|
|
283
|
+
? result.map((item) => ({
|
|
245
284
|
...item,
|
|
246
285
|
id: changeIdValue(item)
|
|
247
286
|
}))
|
|
248
|
-
:
|
|
287
|
+
: result;
|
|
249
288
|
|
|
250
289
|
if (!isEmpty(labelKey) && !isNil(labelKey)) {
|
|
251
290
|
const list = formattedList.map((item) =>
|
|
@@ -259,9 +298,6 @@ const ConnectedAutocompleteField = (
|
|
|
259
298
|
|
|
260
299
|
setOptions(moreOptions.concat(formattedList as Array<TData>));
|
|
261
300
|
|
|
262
|
-
const total = prop('total', newOptions.meta) || 1;
|
|
263
|
-
const limit = prop('limit', newOptions.meta) || 1;
|
|
264
|
-
|
|
265
301
|
const newMaxPage = Math.ceil(total / limit);
|
|
266
302
|
|
|
267
303
|
setMaxPage(newMaxPage);
|
|
@@ -322,12 +358,13 @@ const ConnectedAutocompleteField = (
|
|
|
322
358
|
<AutocompleteField
|
|
323
359
|
filterOptions={(opt): SelectEntry => opt}
|
|
324
360
|
loading={isFetching}
|
|
325
|
-
open={optionsOpen}
|
|
326
361
|
options={
|
|
327
362
|
allowUniqOption ? uniqBy(getRenderedOptionText, options) : options
|
|
328
363
|
}
|
|
329
364
|
renderOption={renderOptions}
|
|
330
|
-
onChange={(_, value) =>
|
|
365
|
+
onChange={(_, value) => {
|
|
366
|
+
setAutocompleteChangedValue(value);
|
|
367
|
+
}}
|
|
331
368
|
onClose={(): void => setOptionsOpen(false)}
|
|
332
369
|
onOpen={(): void => setOptionsOpen(true)}
|
|
333
370
|
onTextChange={changeText}
|
|
@@ -58,3 +58,22 @@ export const popoverWithoutInput = (): JSX.Element => {
|
|
|
58
58
|
/>
|
|
59
59
|
);
|
|
60
60
|
};
|
|
61
|
+
|
|
62
|
+
export const customRenderedTags = (): JSX.Element => {
|
|
63
|
+
const customRender = (tags: React.ReactNode): React.ReactNode => (
|
|
64
|
+
<div style={{ display: 'flex' }}>
|
|
65
|
+
{tags}
|
|
66
|
+
<span style={{ color: '#999' }}>Custom wrapper</span>
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<MultiAutocompleteField
|
|
72
|
+
customRenderTags={customRender}
|
|
73
|
+
label="Custom Tags Render"
|
|
74
|
+
options={options}
|
|
75
|
+
placeholder="Type here..."
|
|
76
|
+
value={[options[0], options[1]]}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
@@ -9,10 +9,6 @@ import { SelectEntry } from '../..';
|
|
|
9
9
|
import Option from '../../Option';
|
|
10
10
|
|
|
11
11
|
const useStyles = makeStyles()((theme) => ({
|
|
12
|
-
checkbox: {
|
|
13
|
-
marginRight: theme.spacing(1),
|
|
14
|
-
padding: 0
|
|
15
|
-
},
|
|
16
12
|
deleteIcon: {
|
|
17
13
|
height: theme.spacing(1.5),
|
|
18
14
|
width: theme.spacing(1.5)
|
|
@@ -33,6 +29,7 @@ export interface Props
|
|
|
33
29
|
'multiple'
|
|
34
30
|
> {
|
|
35
31
|
chipProps?: ChipProps;
|
|
32
|
+
customRenderTags?: (tags: React.ReactNode) => React.ReactNode;
|
|
36
33
|
disableSortedOptions?: boolean;
|
|
37
34
|
getOptionTooltipLabel?: (option) => string;
|
|
38
35
|
getTagLabel?: (option) => string;
|
|
@@ -48,6 +45,7 @@ const MultiAutocompleteField = ({
|
|
|
48
45
|
getTagLabel = (option): string => option[optionProperty],
|
|
49
46
|
getOptionTooltipLabel,
|
|
50
47
|
chipProps,
|
|
48
|
+
customRenderTags,
|
|
51
49
|
...props
|
|
52
50
|
}: Props): JSX.Element => {
|
|
53
51
|
const { classes } = useStyles();
|
|
@@ -65,6 +63,7 @@ const MultiAutocompleteField = ({
|
|
|
65
63
|
deleteIcon: classes.deleteIcon,
|
|
66
64
|
root: classes.tag
|
|
67
65
|
}}
|
|
66
|
+
data-testid={`tag-option-chip-${option.id}`}
|
|
68
67
|
label={getTagLabel(option)}
|
|
69
68
|
size="medium"
|
|
70
69
|
{...getTagProps({ index })}
|
|
@@ -106,7 +105,11 @@ const MultiAutocompleteField = ({
|
|
|
106
105
|
<Option checkboxSelected={selected}>{getOptionLabel(option)}</Option>
|
|
107
106
|
</li>
|
|
108
107
|
)}
|
|
109
|
-
renderTags={
|
|
108
|
+
renderTags={(renderedValue, getTagProps): React.ReactNode =>
|
|
109
|
+
customRenderTags
|
|
110
|
+
? customRenderTags(renderTags(renderedValue, getTagProps))
|
|
111
|
+
: renderTags(renderedValue, getTagProps)
|
|
112
|
+
}
|
|
110
113
|
value={value}
|
|
111
114
|
{...props}
|
|
112
115
|
/>
|
|
@@ -18,7 +18,7 @@ import { ForwardedRef, HTMLAttributes, ReactElement, forwardRef } from 'react';
|
|
|
18
18
|
import { SelectEntry } from '..';
|
|
19
19
|
import { getNormalizedId } from '../../../utils';
|
|
20
20
|
import TextField from '../../Text';
|
|
21
|
-
import { searchLabel } from '../../translatedLabels';
|
|
21
|
+
import { labelClear, labelOpen, searchLabel } from '../../translatedLabels';
|
|
22
22
|
import Option from '../Option';
|
|
23
23
|
|
|
24
24
|
export type Props = {
|
|
@@ -38,6 +38,7 @@ export type Props = {
|
|
|
38
38
|
onTextChange?;
|
|
39
39
|
placeholder?: string | undefined;
|
|
40
40
|
required?: boolean;
|
|
41
|
+
forceInputRenderValue?: boolean;
|
|
41
42
|
} & Omit<
|
|
42
43
|
AutocompleteProps<SelectEntry, Multiple, DisableClearable, FreeSolo>,
|
|
43
44
|
'renderInput'
|
|
@@ -160,7 +161,8 @@ const AutocompleteField = forwardRef(
|
|
|
160
161
|
autoSize = false,
|
|
161
162
|
autoSizeDefaultWidth = 0,
|
|
162
163
|
autoSizeCustomPadding,
|
|
163
|
-
getOptionItemLabel = (option) => option
|
|
164
|
+
getOptionItemLabel = (option) => option?.name,
|
|
165
|
+
forceInputRenderValue = false,
|
|
164
166
|
...autocompleteProps
|
|
165
167
|
}: Props,
|
|
166
168
|
ref?: ForwardedRef<HTMLDivElement>
|
|
@@ -178,59 +180,74 @@ const AutocompleteField = forwardRef(
|
|
|
178
180
|
);
|
|
179
181
|
};
|
|
180
182
|
|
|
181
|
-
const renderInput = (params): JSX.Element =>
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
183
|
+
const renderInput = (params): JSX.Element => {
|
|
184
|
+
return (
|
|
185
|
+
<TextField
|
|
186
|
+
{...params}
|
|
187
|
+
InputLabelProps={{
|
|
188
|
+
classes: {
|
|
189
|
+
marginDense: classes.inputLabel,
|
|
190
|
+
shrink: classes.inputLabelShrink
|
|
191
|
+
}
|
|
192
|
+
}}
|
|
193
|
+
InputProps={{
|
|
194
|
+
...params.InputProps,
|
|
195
|
+
endAdornment: (
|
|
196
|
+
<>
|
|
197
|
+
{endAdornment && (
|
|
198
|
+
<InputAdornment position="end">{endAdornment}</InputAdornment>
|
|
199
|
+
)}
|
|
200
|
+
{params.InputProps.endAdornment}
|
|
201
|
+
</>
|
|
202
|
+
),
|
|
203
|
+
style: {
|
|
204
|
+
background: 'transparent',
|
|
205
|
+
minWidth: 0,
|
|
206
|
+
padding: theme.spacing(
|
|
207
|
+
0.75,
|
|
208
|
+
isEmpty(placeholder) ? 0 : 5,
|
|
209
|
+
0.75,
|
|
210
|
+
0.75
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
}}
|
|
214
|
+
autoFocus={autoFocus}
|
|
215
|
+
autoSize={autoSize}
|
|
216
|
+
autoSizeCustomPadding={7 + (autoSizeCustomPadding || 0)}
|
|
217
|
+
autoSizeDefaultWidth={autoSizeDefaultWidth}
|
|
218
|
+
classes={{
|
|
219
|
+
root: classes.textfield
|
|
220
|
+
}}
|
|
221
|
+
error={error}
|
|
222
|
+
externalValueForAutoSize={autocompleteProps?.value?.name}
|
|
223
|
+
inputProps={{
|
|
224
|
+
...params.inputProps,
|
|
225
|
+
'aria-label': label,
|
|
226
|
+
'data-testid': dataTestId || label,
|
|
227
|
+
id: getNormalizedId(label || ''),
|
|
228
|
+
...(forceInputRenderValue
|
|
229
|
+
? {
|
|
230
|
+
value: getOptionItemLabel(
|
|
231
|
+
autocompleteProps?.value || undefined
|
|
232
|
+
)
|
|
233
|
+
}
|
|
234
|
+
: {}),
|
|
235
|
+
...autocompleteProps?.inputProps
|
|
236
|
+
}}
|
|
237
|
+
label={label}
|
|
238
|
+
placeholder={isNil(placeholder) ? t(searchLabel) : placeholder}
|
|
239
|
+
required={required}
|
|
240
|
+
value={
|
|
241
|
+
inputValue ||
|
|
242
|
+
(forceInputRenderValue
|
|
243
|
+
? getOptionItemLabel(autocompleteProps?.value || undefined)
|
|
244
|
+
: undefined) ||
|
|
245
|
+
undefined
|
|
188
246
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
<>
|
|
194
|
-
{endAdornment && (
|
|
195
|
-
<InputAdornment position="end">{endAdornment}</InputAdornment>
|
|
196
|
-
)}
|
|
197
|
-
{params.InputProps.endAdornment}
|
|
198
|
-
</>
|
|
199
|
-
),
|
|
200
|
-
style: {
|
|
201
|
-
background: 'transparent',
|
|
202
|
-
minWidth: 0,
|
|
203
|
-
padding: theme.spacing(
|
|
204
|
-
0.75,
|
|
205
|
-
isEmpty(placeholder) ? 0 : 5,
|
|
206
|
-
0.75,
|
|
207
|
-
0.75
|
|
208
|
-
)
|
|
209
|
-
}
|
|
210
|
-
}}
|
|
211
|
-
autoFocus={autoFocus}
|
|
212
|
-
autoSize={autoSize}
|
|
213
|
-
autoSizeCustomPadding={7 + (autoSizeCustomPadding || 0)}
|
|
214
|
-
autoSizeDefaultWidth={autoSizeDefaultWidth}
|
|
215
|
-
classes={{
|
|
216
|
-
root: classes.textfield
|
|
217
|
-
}}
|
|
218
|
-
error={error}
|
|
219
|
-
externalValueForAutoSize={autocompleteProps?.value?.name}
|
|
220
|
-
inputProps={{
|
|
221
|
-
...params.inputProps,
|
|
222
|
-
'aria-label': label,
|
|
223
|
-
'data-testid': dataTestId || label,
|
|
224
|
-
id: getNormalizedId(label || ''),
|
|
225
|
-
...autocompleteProps?.inputProps
|
|
226
|
-
}}
|
|
227
|
-
label={label}
|
|
228
|
-
placeholder={isNil(placeholder) ? t(searchLabel) : placeholder}
|
|
229
|
-
required={required}
|
|
230
|
-
value={inputValue || undefined}
|
|
231
|
-
onChange={onTextChange}
|
|
232
|
-
/>
|
|
233
|
-
);
|
|
247
|
+
onChange={onTextChange}
|
|
248
|
+
/>
|
|
249
|
+
);
|
|
250
|
+
};
|
|
234
251
|
|
|
235
252
|
return (
|
|
236
253
|
<Autocomplete
|
|
@@ -269,6 +286,14 @@ const AutocompleteField = forwardRef(
|
|
|
269
286
|
);
|
|
270
287
|
}}
|
|
271
288
|
size="small"
|
|
289
|
+
slotProps={{
|
|
290
|
+
clearIndicator: {
|
|
291
|
+
title: t(labelClear)
|
|
292
|
+
},
|
|
293
|
+
popupIndicator: {
|
|
294
|
+
title: t(labelOpen)
|
|
295
|
+
}
|
|
296
|
+
}}
|
|
272
297
|
{...autocompleteProps}
|
|
273
298
|
/>
|
|
274
299
|
);
|
|
@@ -77,7 +77,7 @@ const OptionalLabelInputAdornment = ({
|
|
|
77
77
|
type SizeVariant = 'large' | 'medium' | 'small' | 'compact';
|
|
78
78
|
|
|
79
79
|
export type TextProps = {
|
|
80
|
-
EndAdornment?: React.FC
|
|
80
|
+
EndAdornment?: React.FC;
|
|
81
81
|
StartAdornment?: React.FC;
|
|
82
82
|
ariaLabel?: string;
|
|
83
83
|
autoSize?: boolean;
|
|
@@ -95,6 +95,7 @@ export type TextProps = {
|
|
|
95
95
|
size?: SizeVariant;
|
|
96
96
|
transparent?: boolean;
|
|
97
97
|
value?: string;
|
|
98
|
+
forceUncontrolled?: boolean;
|
|
98
99
|
} & Omit<TextFieldProps, 'variant' | 'size' | 'error'>;
|
|
99
100
|
|
|
100
101
|
const TextField = forwardRef(
|
|
@@ -119,6 +120,7 @@ const TextField = forwardRef(
|
|
|
119
120
|
required = false,
|
|
120
121
|
containerClassName,
|
|
121
122
|
type,
|
|
123
|
+
forceUncontrolled,
|
|
122
124
|
...rest
|
|
123
125
|
}: TextProps,
|
|
124
126
|
ref: React.ForwardedRef<HTMLDivElement>
|
|
@@ -137,7 +139,7 @@ const TextField = forwardRef(
|
|
|
137
139
|
const tooltipTitle = displayErrorInTooltip && !isNil(error) ? error : '';
|
|
138
140
|
|
|
139
141
|
const getValueProps = useCallback((): object => {
|
|
140
|
-
if (debounced) {
|
|
142
|
+
if (debounced || forceUncontrolled) {
|
|
141
143
|
return {};
|
|
142
144
|
}
|
|
143
145
|
|
|
@@ -146,7 +148,7 @@ const TextField = forwardRef(
|
|
|
146
148
|
}
|
|
147
149
|
|
|
148
150
|
return { value: innerValue };
|
|
149
|
-
}, [innerValue, debounced, defaultValue]);
|
|
151
|
+
}, [innerValue, debounced, defaultValue, forceUncontrolled]);
|
|
150
152
|
|
|
151
153
|
return (
|
|
152
154
|
<Box
|
|
@@ -214,7 +216,7 @@ const TextField = forwardRef(
|
|
|
214
216
|
</Tooltip>
|
|
215
217
|
{autoSize && (
|
|
216
218
|
<Typography className={classes.hiddenText} ref={inputRef}>
|
|
217
|
-
{rest
|
|
219
|
+
{rest?.value || externalValueForAutoSize || innerValue}
|
|
218
220
|
</Typography>
|
|
219
221
|
)}
|
|
220
222
|
</Box>
|
|
@@ -6,13 +6,13 @@ const loadingIndicatorHeight = 3;
|
|
|
6
6
|
|
|
7
7
|
interface StylesProps {
|
|
8
8
|
dataStyle: TableStyle;
|
|
9
|
-
|
|
9
|
+
gridTemplateColumn: string;
|
|
10
10
|
isResponsive: string;
|
|
11
11
|
rows: Array<unknown>;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const useListingStyles = makeStyles<StylesProps>()(
|
|
15
|
-
(theme, { dataStyle,
|
|
15
|
+
(theme, { dataStyle, gridTemplateColumn, rows, isResponsive }) => ({
|
|
16
16
|
actionBar: {
|
|
17
17
|
alignItems: 'center',
|
|
18
18
|
display: 'flex'
|
|
@@ -51,7 +51,7 @@ const useListingStyles = makeStyles<StylesProps>()(
|
|
|
51
51
|
},
|
|
52
52
|
alignItems: 'center',
|
|
53
53
|
display: 'grid',
|
|
54
|
-
gridTemplateColumns:
|
|
54
|
+
gridTemplateColumns: gridTemplateColumn,
|
|
55
55
|
gridTemplateRows: `${theme.spacing(dataStyle.header.height / 8)} repeat(${
|
|
56
56
|
rows?.length || 1
|
|
57
57
|
}, ${isResponsive ? 'auto' : `${dataStyle.body.height}px`})`,
|
package/src/Listing/index.tsx
CHANGED
|
@@ -61,8 +61,8 @@ import {
|
|
|
61
61
|
SortOrder
|
|
62
62
|
} from './models';
|
|
63
63
|
import { subItemsPivotsAtom } from './tableAtoms';
|
|
64
|
-
import { labelNoResultFound } from './translatedLabels';
|
|
65
|
-
import useStyleTable from './useStyleTable';
|
|
64
|
+
import { labelNoResultFound as defaultLabelNoResultFound } from './translatedLabels';
|
|
65
|
+
import useStyleTable, { useColumnStyle } from './useStyleTable';
|
|
66
66
|
|
|
67
67
|
const subItemPrefixKey = 'listing';
|
|
68
68
|
|
|
@@ -139,7 +139,6 @@ export interface Props<TRow> {
|
|
|
139
139
|
totalRows?: number;
|
|
140
140
|
viewerModeConfiguration?: ViewerModeConfiguration;
|
|
141
141
|
widthToMoveTablePagination?: number;
|
|
142
|
-
isActionBarVisible: boolean;
|
|
143
142
|
}
|
|
144
143
|
|
|
145
144
|
const defaultColumnConfiguration = {
|
|
@@ -198,18 +197,19 @@ const Listing = <
|
|
|
198
197
|
getRowProperty: () => '',
|
|
199
198
|
labelCollapse: 'Collapse',
|
|
200
199
|
labelExpand: 'Expand'
|
|
201
|
-
}
|
|
202
|
-
isActionBarVisible = true
|
|
200
|
+
}
|
|
203
201
|
}: Props<TRow>): JSX.Element => {
|
|
204
202
|
const currentVisibleColumns = getVisibleColumns({
|
|
205
203
|
columnConfiguration,
|
|
206
204
|
columns
|
|
207
205
|
});
|
|
208
|
-
const { dataStyle
|
|
209
|
-
checkable,
|
|
210
|
-
currentVisibleColumns,
|
|
206
|
+
const { dataStyle } = useStyleTable({
|
|
211
207
|
listingVariant
|
|
212
208
|
});
|
|
209
|
+
const gridTemplateColumn = useColumnStyle({
|
|
210
|
+
checkable,
|
|
211
|
+
currentVisibleColumns
|
|
212
|
+
});
|
|
213
213
|
|
|
214
214
|
const { t } = useTranslation();
|
|
215
215
|
|
|
@@ -289,7 +289,7 @@ const Listing = <
|
|
|
289
289
|
|
|
290
290
|
const { classes } = useListingStyles({
|
|
291
291
|
dataStyle,
|
|
292
|
-
|
|
292
|
+
gridTemplateColumn,
|
|
293
293
|
isResponsive,
|
|
294
294
|
rows: rowsToDisplay
|
|
295
295
|
});
|
|
@@ -526,33 +526,30 @@ const Listing = <
|
|
|
526
526
|
className={classes.container}
|
|
527
527
|
ref={containerRef as RefObject<HTMLDivElement>}
|
|
528
528
|
>
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
/>
|
|
554
|
-
</div>
|
|
555
|
-
}
|
|
529
|
+
<div
|
|
530
|
+
className={classes.actionBar}
|
|
531
|
+
ref={actionBarRef as RefObject<HTMLDivElement>}
|
|
532
|
+
>
|
|
533
|
+
<ListingActionBar
|
|
534
|
+
actions={actions}
|
|
535
|
+
actionsBarMemoProps={actionsBarMemoProps}
|
|
536
|
+
columnConfiguration={columnConfiguration}
|
|
537
|
+
columns={columns}
|
|
538
|
+
currentPage={currentPage}
|
|
539
|
+
customPaginationClassName={customPaginationClassName}
|
|
540
|
+
limit={limit}
|
|
541
|
+
listingVariant={listingVariant}
|
|
542
|
+
moveTablePagination={moveTablePagination}
|
|
543
|
+
paginated={paginated}
|
|
544
|
+
totalRows={totalRows}
|
|
545
|
+
viewerModeConfiguration={viewerModeConfiguration}
|
|
546
|
+
widthToMoveTablePagination={widthToMoveTablePagination}
|
|
547
|
+
onLimitChange={changeLimit}
|
|
548
|
+
onPaginate={onPaginate}
|
|
549
|
+
onResetColumns={onResetColumns}
|
|
550
|
+
onSelectColumns={onSelectColumns}
|
|
551
|
+
/>
|
|
552
|
+
</div>
|
|
556
553
|
|
|
557
554
|
<ParentSize
|
|
558
555
|
parentSizeStyles={{
|
|
@@ -704,7 +701,13 @@ const Listing = <
|
|
|
704
701
|
(loading ? (
|
|
705
702
|
<SkeletonLoader rows={limit} />
|
|
706
703
|
) : (
|
|
707
|
-
<EmptyResult
|
|
704
|
+
<EmptyResult
|
|
705
|
+
label={
|
|
706
|
+
defaultLabelNoResultFound
|
|
707
|
+
? t(defaultLabelNoResultFound)
|
|
708
|
+
: t(defaultLabelNoResultFound)
|
|
709
|
+
}
|
|
710
|
+
/>
|
|
708
711
|
))}
|
|
709
712
|
</TableBody>
|
|
710
713
|
</Table>
|
package/src/Listing/models.ts
CHANGED