@centreon/ui 24.10.12 → 24.10.14
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/ui",
|
|
3
|
-
"version": "24.10.
|
|
3
|
+
"version": "24.10.14",
|
|
4
4
|
"description": "Centreon UI Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"update:deps": "pnpx npm-check-updates -i --format group",
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
"cypress:run": "cypress run --component --browser=chrome",
|
|
19
19
|
"tokens:transform": "TS_NODE_PROJECT=tsconfig.node.json ts-node style-dictionary.transform.ts"
|
|
20
20
|
},
|
|
21
|
-
"type": "module",
|
|
22
21
|
"sideEffects": false,
|
|
23
22
|
"repository": {
|
|
24
23
|
"type": "git",
|
|
@@ -54,6 +53,8 @@
|
|
|
54
53
|
"@cypress/webpack-dev-server": "^3.10.1",
|
|
55
54
|
"@faker-js/faker": "^8.4.1",
|
|
56
55
|
"@mdx-js/react": "^3.0.1",
|
|
56
|
+
"@modern-js/prod-server": "^2.58.1",
|
|
57
|
+
"@modern-js/storybook": "^2.58.1",
|
|
57
58
|
"@simonsmith/cypress-image-snapshot": "^9.1.0",
|
|
58
59
|
"@storybook/addon-a11y": "^8.2.9",
|
|
59
60
|
"@storybook/addon-docs": "^8.2.9",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* - Please do NOT serve this file on production.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
const PACKAGE_VERSION = '2.
|
|
11
|
+
const PACKAGE_VERSION = '2.2.14'
|
|
12
12
|
const INTEGRITY_CHECKSUM = '26357c79639bfa20d64c0efca2a87423'
|
|
13
13
|
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
|
|
14
14
|
const activeClientIds = new Set()
|
|
@@ -18,6 +18,7 @@ const useStyles = makeStyles()((theme) => ({
|
|
|
18
18
|
}));
|
|
19
19
|
|
|
20
20
|
type Props = {
|
|
21
|
+
dataTestid?: string;
|
|
21
22
|
ariaLabel?: string;
|
|
22
23
|
className?: string;
|
|
23
24
|
onClick: (event) => void;
|
|
@@ -44,6 +45,7 @@ export const IconButton = ({
|
|
|
44
45
|
className,
|
|
45
46
|
tooltipPlacement,
|
|
46
47
|
tooltipClassName,
|
|
48
|
+
dataTestid,
|
|
47
49
|
...props
|
|
48
50
|
}: Props): JSX.Element => {
|
|
49
51
|
const { classes, cx } = useStyles();
|
|
@@ -59,7 +61,7 @@ export const IconButton = ({
|
|
|
59
61
|
aria-label={ariaLabel}
|
|
60
62
|
className={cx(classes.button, className)}
|
|
61
63
|
color="primary"
|
|
62
|
-
data-testid={ariaLabel}
|
|
64
|
+
data-testid={dataTestid || ariaLabel}
|
|
63
65
|
id={getNormalizedId(ariaLabel || '')}
|
|
64
66
|
{...props}
|
|
65
67
|
/>
|
|
@@ -40,7 +40,7 @@ export const useDashboardLayoutStyles = makeStyles<boolean>()(
|
|
|
40
40
|
width: theme.spacing(1)
|
|
41
41
|
},
|
|
42
42
|
'& .react-resizable-handle.react-resizable-handle-s': {
|
|
43
|
-
bottom:
|
|
43
|
+
bottom: 0,
|
|
44
44
|
cursor: 'ns-resize',
|
|
45
45
|
height: theme.spacing(1),
|
|
46
46
|
left: 0,
|
|
@@ -49,7 +49,7 @@ export const useDashboardLayoutStyles = makeStyles<boolean>()(
|
|
|
49
49
|
width: `calc(100% - ${theme.spacing(3)})`
|
|
50
50
|
},
|
|
51
51
|
'& .react-resizable-handle.react-resizable-handle-se': {
|
|
52
|
-
bottom:
|
|
52
|
+
bottom: 0,
|
|
53
53
|
cursor: 'nwse-resize',
|
|
54
54
|
height: theme.spacing(2),
|
|
55
55
|
right: 0,
|
|
@@ -62,8 +62,7 @@ export const useDashboardLayoutStyles = makeStyles<boolean>()(
|
|
|
62
62
|
'& .react-resizable-handle:hover': {
|
|
63
63
|
opacity: 1
|
|
64
64
|
},
|
|
65
|
-
position: 'relative'
|
|
66
|
-
height: '100%',
|
|
65
|
+
position: 'relative'
|
|
67
66
|
}
|
|
68
67
|
})
|
|
69
68
|
);
|
|
@@ -95,7 +95,7 @@ export const normal = DashboardTemplate.bind({});
|
|
|
95
95
|
|
|
96
96
|
export const withManyPanels = DashboardTemplate.bind({});
|
|
97
97
|
withManyPanels.args = {
|
|
98
|
-
layout: generateLayout(
|
|
98
|
+
layout: generateLayout(1000)
|
|
99
99
|
};
|
|
100
100
|
|
|
101
101
|
export const withItemHeader = DashboardTemplate.bind({});
|
package/src/Dashboard/Grid.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactElement, useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
import { scaleLinear } from '@visx/scale';
|
|
4
4
|
import { Grid as VisxGrid } from '@visx/visx';
|
|
@@ -13,15 +13,9 @@ interface Props {
|
|
|
13
13
|
columns: number;
|
|
14
14
|
height: number;
|
|
15
15
|
width: number;
|
|
16
|
-
containerRef: MutableRefObject<HTMLDivElement | null>;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
const Grid = ({
|
|
20
|
-
width,
|
|
21
|
-
height,
|
|
22
|
-
columns,
|
|
23
|
-
containerRef
|
|
24
|
-
}: Props): ReactElement => {
|
|
18
|
+
const Grid = ({ width, height, columns }: Props): ReactElement => {
|
|
25
19
|
const theme = useTheme();
|
|
26
20
|
|
|
27
21
|
const xScale = useMemo(
|
|
@@ -50,19 +44,19 @@ const Grid = ({
|
|
|
50
44
|
.fill(0)
|
|
51
45
|
.map((_, index) => index * tick);
|
|
52
46
|
|
|
53
|
-
const yTickValues = Array(numberOfRows)
|
|
54
|
-
.fill(0)
|
|
55
|
-
.map((_, index) => index);
|
|
56
|
-
|
|
57
47
|
return useMemoComponent({
|
|
58
48
|
Component: (
|
|
59
49
|
<svg style={{ height, position: 'absolute', width }}>
|
|
60
|
-
<VisxGrid.
|
|
61
|
-
|
|
62
|
-
|
|
50
|
+
<VisxGrid.GridColumns
|
|
51
|
+
height={height}
|
|
52
|
+
scale={xScale}
|
|
53
|
+
stroke={theme.palette.divider}
|
|
54
|
+
tickValues={xTickValues}
|
|
55
|
+
width={width}
|
|
56
|
+
/>
|
|
57
|
+
<VisxGrid.GridRows
|
|
63
58
|
height={height}
|
|
64
|
-
|
|
65
|
-
xScale={xScale}
|
|
59
|
+
scale={yScale}
|
|
66
60
|
stroke={theme.palette.divider}
|
|
67
61
|
top={-10}
|
|
68
62
|
width={width}
|
package/src/Dashboard/Layout.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useEffect,
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { useSetAtom } from 'jotai';
|
|
4
4
|
import GridLayout, { Layout, WidthProvider } from 'react-grid-layout';
|
|
@@ -6,10 +6,10 @@ import 'react-grid-layout/css/styles.css';
|
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
ParentSize,
|
|
9
|
+
Responsive as ResponsiveHeight,
|
|
9
10
|
useMemoComponent
|
|
10
11
|
} from '..';
|
|
11
12
|
|
|
12
|
-
import { Box } from '@mui/material';
|
|
13
13
|
import { useDashboardLayoutStyles } from './Dashboard.styles';
|
|
14
14
|
import Grid from './Grid';
|
|
15
15
|
import { isResizingItemAtom } from './atoms';
|
|
@@ -26,18 +26,6 @@ interface DashboardLayoutProps<T> {
|
|
|
26
26
|
layout: Array<T>;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
const bottom = (layout: Array<Layout>): number => {
|
|
30
|
-
let max = 0;
|
|
31
|
-
let bottomY = 0;
|
|
32
|
-
|
|
33
|
-
layout.forEach((panel) => {
|
|
34
|
-
bottomY = panel.y + panel.h;
|
|
35
|
-
if (bottomY > max) max = bottomY;
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
return max;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
29
|
const DashboardLayout = <T extends Layout>({
|
|
42
30
|
children,
|
|
43
31
|
changeLayout,
|
|
@@ -46,8 +34,6 @@ const DashboardLayout = <T extends Layout>({
|
|
|
46
34
|
isStatic = false,
|
|
47
35
|
additionalMemoProps = []
|
|
48
36
|
}: DashboardLayoutProps<T>): JSX.Element => {
|
|
49
|
-
const dashboardContainerRef = useRef<HTMLDivElement | null>(null);
|
|
50
|
-
|
|
51
37
|
const { classes } = useDashboardLayoutStyles(isStatic);
|
|
52
38
|
|
|
53
39
|
const [columns, setColumns] = useState(getColumnsFromScreenSize());
|
|
@@ -66,16 +52,6 @@ const DashboardLayout = <T extends Layout>({
|
|
|
66
52
|
setIsResizingItem(null);
|
|
67
53
|
}, []);
|
|
68
54
|
|
|
69
|
-
const containerHeight = useMemo((): number | undefined => {
|
|
70
|
-
const nbRow = bottom(getLayout(layout));
|
|
71
|
-
const containerPaddingY = 4
|
|
72
|
-
return (
|
|
73
|
-
nbRow * rowHeight +
|
|
74
|
-
(nbRow - 1) * 20 +
|
|
75
|
-
containerPaddingY * 2
|
|
76
|
-
);
|
|
77
|
-
}, [layout, rowHeight])
|
|
78
|
-
|
|
79
55
|
useEffect(() => {
|
|
80
56
|
window.addEventListener('resize', resize);
|
|
81
57
|
|
|
@@ -86,36 +62,31 @@ const DashboardLayout = <T extends Layout>({
|
|
|
86
62
|
|
|
87
63
|
return useMemoComponent({
|
|
88
64
|
Component: (
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
</ReactGridLayout>
|
|
115
|
-
</Box>
|
|
116
|
-
)}
|
|
117
|
-
</ParentSize>
|
|
118
|
-
</Box>
|
|
65
|
+
<ResponsiveHeight margin={40}>
|
|
66
|
+
<ParentSize>
|
|
67
|
+
{({ width, height }): JSX.Element => (
|
|
68
|
+
<div className={classes.container}>
|
|
69
|
+
{displayGrid && (
|
|
70
|
+
<Grid columns={columns} height={height} width={width} />
|
|
71
|
+
)}
|
|
72
|
+
<ReactGridLayout
|
|
73
|
+
cols={columns}
|
|
74
|
+
containerPadding={[4, 0]}
|
|
75
|
+
layout={getLayout(layout)}
|
|
76
|
+
margin={[20, 20]}
|
|
77
|
+
resizeHandles={['s', 'e', 'se']}
|
|
78
|
+
rowHeight={rowHeight}
|
|
79
|
+
width={width}
|
|
80
|
+
onLayoutChange={changeLayout}
|
|
81
|
+
onResizeStart={startResize}
|
|
82
|
+
onResizeStop={stopResize}
|
|
83
|
+
>
|
|
84
|
+
{children}
|
|
85
|
+
</ReactGridLayout>
|
|
86
|
+
</div>
|
|
87
|
+
)}
|
|
88
|
+
</ParentSize>
|
|
89
|
+
</ResponsiveHeight>
|
|
119
90
|
),
|
|
120
91
|
memoProps: [columns, layout, displayGrid, isStatic, ...additionalMemoProps]
|
|
121
92
|
});
|
|
@@ -5,13 +5,13 @@ import { Modal } from '../../components/Modal';
|
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
labelDiscard,
|
|
8
|
-
|
|
9
|
-
labelDoYouWantToResolveErrors,
|
|
8
|
+
labelDoYouWantToQuit,
|
|
10
9
|
labelDoYouWantToSaveChanges,
|
|
11
10
|
labelIfYouClickOnDiscard,
|
|
12
|
-
|
|
11
|
+
labelLeave,
|
|
13
12
|
labelSave,
|
|
14
|
-
|
|
13
|
+
labelStay,
|
|
14
|
+
labelYourFormHasUnsavedChanges
|
|
15
15
|
} from './translatedLabels';
|
|
16
16
|
|
|
17
17
|
interface Props {
|
|
@@ -32,15 +32,17 @@ const UnsavedChangesDialog = ({
|
|
|
32
32
|
dialogOpened
|
|
33
33
|
}: Props): JSX.Element | null => {
|
|
34
34
|
const { t } = useTranslation();
|
|
35
|
+
|
|
35
36
|
const labelTitle = isValidForm
|
|
36
37
|
? labelDoYouWantToSaveChanges
|
|
37
|
-
:
|
|
38
|
+
: labelDoYouWantToQuit;
|
|
38
39
|
|
|
39
|
-
const
|
|
40
|
+
const lebelConfirm = isValidForm ? labelSave : labelLeave;
|
|
41
|
+
const labelCancel = isValidForm ? labelDiscard : labelStay;
|
|
40
42
|
|
|
41
|
-
const labelMessage =
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
const labelMessage = isValidForm
|
|
44
|
+
? labelIfYouClickOnDiscard
|
|
45
|
+
: labelYourFormHasUnsavedChanges;
|
|
44
46
|
|
|
45
47
|
if (not(dialogOpened)) {
|
|
46
48
|
return null;
|
|
@@ -58,11 +60,11 @@ const UnsavedChangesDialog = ({
|
|
|
58
60
|
<Modal.Actions
|
|
59
61
|
disabled={isSubmitting}
|
|
60
62
|
labels={{
|
|
61
|
-
cancel: t(
|
|
62
|
-
confirm: t(
|
|
63
|
+
cancel: t(labelCancel),
|
|
64
|
+
confirm: t(lebelConfirm)
|
|
63
65
|
}}
|
|
64
|
-
onCancel={discardChanges}
|
|
65
|
-
onConfirm={isValidForm ? saveChanges :
|
|
66
|
+
onCancel={isValidForm ? discardChanges : closeDialog}
|
|
67
|
+
onConfirm={isValidForm ? saveChanges : discardChanges}
|
|
66
68
|
/>
|
|
67
69
|
</Modal>
|
|
68
70
|
);
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
export const labelDiscard = 'Discard';
|
|
2
|
-
export const
|
|
2
|
+
export const labelSave = 'Save';
|
|
3
|
+
|
|
4
|
+
export const labelLeave = 'Leave';
|
|
5
|
+
export const labelStay = 'Stay';
|
|
6
|
+
|
|
3
7
|
export const labelIfYouClickOnDiscard =
|
|
4
8
|
'If you click on Discard, your changes will not be saved.';
|
|
5
|
-
export const
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
export const labelDoYouWantToQuit = 'Do you want to leave this page?';
|
|
10
|
+
|
|
11
|
+
export const labelYourFormHasUnsavedChanges =
|
|
12
|
+
'Your changes will not be saved if you leave this page.';
|
|
8
13
|
export const labelDoYouWantToSaveChanges = 'Do you want to save the changes?';
|
|
9
|
-
export const labelDoYouWantToResolveErrors =
|
|
10
|
-
'Do you want to resolve the errors?';
|
|
11
|
-
export const labelSave = 'Save';
|
|
12
14
|
|
|
13
15
|
export default {
|
|
14
16
|
labelDiscard,
|
|
15
|
-
labelDoYouWantToQuitWithoutResolving,
|
|
16
|
-
labelDoYouWantToResolveErrors,
|
|
17
|
-
labelDoYouWantToSaveChanges,
|
|
18
|
-
labelIfYouClickOnDiscard,
|
|
19
|
-
labelResolve,
|
|
20
17
|
labelSave,
|
|
21
|
-
|
|
18
|
+
labelLeave,
|
|
19
|
+
labelStay,
|
|
20
|
+
labelIfYouClickOnDiscard,
|
|
21
|
+
labelDoYouWantToQuit,
|
|
22
|
+
labelYourFormHasUnsavedChanges,
|
|
23
|
+
labelDoYouWantToSaveChanges
|
|
22
24
|
};
|
package/src/Form/Form.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCallback, useMemo, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { FormikValues, useFormikContext } from 'formik';
|
|
4
|
-
import { equals, isNil, map, not,
|
|
4
|
+
import { path, equals, isNil, map, not, prop, type } from 'ramda';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
|
|
7
7
|
import { FormHelperText, Stack } from '@mui/material';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCallback, useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
import { FormikValues, useFormikContext } from 'formik';
|
|
4
|
-
import { equals, isEmpty,
|
|
4
|
+
import { path, equals, isEmpty, propEq, reject, split } from 'ramda';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
|
|
7
7
|
import {
|
|
@@ -134,15 +134,18 @@ const ConnectedAutocomplete = ({
|
|
|
134
134
|
error={error}
|
|
135
135
|
field={filterKey}
|
|
136
136
|
getEndpoint={getEndpoint}
|
|
137
|
+
decoder={connectedAutocomplete?.decoder}
|
|
137
138
|
getRenderedOptionText={connectedAutocomplete?.getRenderedOptionText}
|
|
138
139
|
initialPage={1}
|
|
139
140
|
isOptionEqualToValue={isOptionEqualToValue}
|
|
140
141
|
label={t(label)}
|
|
141
142
|
name={fieldName}
|
|
142
143
|
required={isRequired}
|
|
143
|
-
value={value ??
|
|
144
|
+
value={value ?? []}
|
|
144
145
|
onBlur={blur}
|
|
145
146
|
onChange={changeAutocomplete}
|
|
147
|
+
limitTags={connectedAutocomplete?.limitTags}
|
|
148
|
+
searchConditions={connectedAutocomplete?.additionalConditionParameters}
|
|
146
149
|
/>
|
|
147
150
|
),
|
|
148
151
|
memoProps: [
|
package/src/Form/Inputs/Grid.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import { InputPropsWithoutGroup } from './models';
|
|
|
4
4
|
|
|
5
5
|
import { Box, Typography } from '@mui/material';
|
|
6
6
|
import { FormikValues, useFormikContext } from 'formik';
|
|
7
|
+
import { isNotEmpty, isNotNil } from 'ramda';
|
|
7
8
|
import { getInput } from '.';
|
|
8
9
|
|
|
9
10
|
interface StylesProps {
|
|
@@ -47,12 +48,17 @@ const Grid = ({
|
|
|
47
48
|
{grid?.columns.map((field) => {
|
|
48
49
|
const Input = getInput(field.type);
|
|
49
50
|
|
|
51
|
+
const key =
|
|
52
|
+
isNotNil(field.label) || isNotEmpty(field.label)
|
|
53
|
+
? field.label
|
|
54
|
+
: field.additionalLabel;
|
|
55
|
+
|
|
50
56
|
if (field.hideInput?.(values) ?? false) {
|
|
51
57
|
return null;
|
|
52
58
|
}
|
|
53
59
|
|
|
54
60
|
return (
|
|
55
|
-
<Box sx={{ width: '100%' }} key={
|
|
61
|
+
<Box sx={{ width: '100%' }} key={key}>
|
|
56
62
|
{field.additionalLabel && (
|
|
57
63
|
<Typography
|
|
58
64
|
sx={{ marginBottom: 0.5, color: 'primary.main' }}
|
package/src/Form/Inputs/Text.tsx
CHANGED
|
@@ -20,6 +20,8 @@ import {
|
|
|
20
20
|
groupBy,
|
|
21
21
|
isEmpty,
|
|
22
22
|
isNil,
|
|
23
|
+
isNotEmpty,
|
|
24
|
+
isNotNil,
|
|
23
25
|
keys,
|
|
24
26
|
last,
|
|
25
27
|
not,
|
|
@@ -114,9 +116,8 @@ const useStyles = makeStyles<StylesProps>()((theme, { groupDirection }) => ({
|
|
|
114
116
|
inputs: {
|
|
115
117
|
display: 'flex',
|
|
116
118
|
flexDirection: 'column',
|
|
117
|
-
|
|
118
|
-
rowGap: theme.spacing(2)
|
|
119
|
-
marginBottom: theme.spacing(1)
|
|
119
|
+
margin: theme.spacing(2, 0),
|
|
120
|
+
rowGap: theme.spacing(2)
|
|
120
121
|
}
|
|
121
122
|
}));
|
|
122
123
|
|
|
@@ -203,6 +204,7 @@ const Inputs = ({
|
|
|
203
204
|
? find(propEq(groupName, 'name'), groups)
|
|
204
205
|
: ({} as Group);
|
|
205
206
|
|
|
207
|
+
const hasGroupDivider = !groups[index]?.isDividerHidden;
|
|
206
208
|
const isFirstElement = areGroupsOpen || equals(index, 0);
|
|
207
209
|
|
|
208
210
|
return (
|
|
@@ -217,22 +219,19 @@ const Inputs = ({
|
|
|
217
219
|
>
|
|
218
220
|
<div className={classes.inputs}>
|
|
219
221
|
{groupedInputs.map((inputProps) => {
|
|
222
|
+
const key =
|
|
223
|
+
isNotNil(inputProps.label) || isNotEmpty(inputProps.label)
|
|
224
|
+
? inputProps.label
|
|
225
|
+
: inputProps.additionalLabel;
|
|
226
|
+
|
|
220
227
|
if (isLoading) {
|
|
221
|
-
return
|
|
222
|
-
<LoadingSkeleton
|
|
223
|
-
input={inputProps}
|
|
224
|
-
key={inputProps.label}
|
|
225
|
-
/>
|
|
226
|
-
);
|
|
228
|
+
return <LoadingSkeleton input={inputProps} key={key} />;
|
|
227
229
|
}
|
|
228
230
|
|
|
229
231
|
const Input = getInput(inputProps.type);
|
|
230
232
|
|
|
231
233
|
return (
|
|
232
|
-
<div
|
|
233
|
-
className={classes.inputWrapper}
|
|
234
|
-
key={inputProps.label}
|
|
235
|
-
>
|
|
234
|
+
<div className={classes.inputWrapper} key={key}>
|
|
236
235
|
{inputProps.additionalLabel && (
|
|
237
236
|
<Typography
|
|
238
237
|
className={cx(
|
|
@@ -253,17 +252,19 @@ const Inputs = ({
|
|
|
253
252
|
</div>
|
|
254
253
|
</CollapsibleGroup>
|
|
255
254
|
</div>
|
|
256
|
-
{
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
255
|
+
{hasGroupDivider &&
|
|
256
|
+
hasGroupTitle &&
|
|
257
|
+
not(equals(lastGroup, groupName as string)) && (
|
|
258
|
+
<Divider
|
|
259
|
+
flexItem
|
|
260
|
+
className={classes.divider}
|
|
261
|
+
orientation={
|
|
262
|
+
equals(groupDirection, GroupDirection.Horizontal)
|
|
263
|
+
? 'vertical'
|
|
264
|
+
: 'horizontal'
|
|
265
|
+
}
|
|
266
|
+
/>
|
|
267
|
+
)}
|
|
267
268
|
</Fragment>
|
|
268
269
|
);
|
|
269
270
|
})}
|
|
@@ -30,7 +30,7 @@ const initialize = ({
|
|
|
30
30
|
tooltip,
|
|
31
31
|
axis,
|
|
32
32
|
orientation,
|
|
33
|
-
barStyle
|
|
33
|
+
barStyle
|
|
34
34
|
}: Pick<
|
|
35
35
|
BarChartProps,
|
|
36
36
|
'data' | 'legend' | 'axis' | 'barStyle' | 'orientation' | 'tooltip' | 'start'
|
|
@@ -61,14 +61,14 @@ const checkWidth = (orientation): void => {
|
|
|
61
61
|
cy.get('g[class*="visx-rows"] > line')
|
|
62
62
|
.eq(0)
|
|
63
63
|
.should('have.attr', 'x2')
|
|
64
|
-
.and('equal', '
|
|
64
|
+
.and('equal', '1145');
|
|
65
65
|
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
cy.get('g[class*="visx-rows"] > line')
|
|
69
69
|
.eq(0)
|
|
70
70
|
.should('have.attr', 'x2')
|
|
71
|
-
.and('equal', '
|
|
71
|
+
.and('equal', '1180');
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
describe('Bar chart', () => {
|