@centreon/ui 24.10.12 → 24.11.1

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.
Files changed (64) hide show
  1. package/package.json +3 -2
  2. package/src/Dashboard/Dashboard.styles.ts +3 -4
  3. package/src/Dashboard/DashboardLayout.stories.tsx +1 -1
  4. package/src/Dashboard/Grid.tsx +11 -17
  5. package/src/Dashboard/Layout.tsx +27 -56
  6. package/src/FileDropZone/index.tsx +23 -21
  7. package/src/Form/CollapsibleGroup.tsx +2 -3
  8. package/src/Form/Form.cypress.spec.tsx +0 -39
  9. package/src/Form/Form.tsx +0 -1
  10. package/src/Form/Inputs/Autocomplete.tsx +4 -27
  11. package/src/Form/Inputs/ConnectedAutocomplete.tsx +10 -20
  12. package/src/Form/Inputs/Grid.tsx +2 -30
  13. package/src/Form/Inputs/Radio.tsx +4 -12
  14. package/src/Form/Inputs/Switch.tsx +2 -10
  15. package/src/Form/Inputs/Text.tsx +4 -13
  16. package/src/Form/Inputs/index.tsx +2 -5
  17. package/src/Form/Inputs/models.ts +2 -18
  18. package/src/Form/storiesData.tsx +3 -15
  19. package/src/Form/translatedLabels.ts +0 -1
  20. package/src/Graph/BarChart/BarChart.tsx +1 -4
  21. package/src/Graph/BarChart/ResponsiveBarChart.tsx +2 -3
  22. package/src/Graph/Chart/Chart.tsx +2 -3
  23. package/src/Graph/Chart/index.tsx +0 -1
  24. package/src/Graph/Chart/models.ts +0 -1
  25. package/src/InputField/Text/index.tsx +1 -1
  26. package/src/Listing/index.tsx +27 -39
  27. package/src/Listing/models.ts +0 -8
  28. package/src/MultiSelectEntries/index.tsx +2 -0
  29. package/src/PopoverMenu/index.tsx +2 -9
  30. package/src/SortableItems/index.tsx +0 -1
  31. package/src/ThemeProvider/index.tsx +1 -1
  32. package/src/ThemeProvider/palettes.ts +4 -4
  33. package/src/components/DataTable/DataTable.cypress.spec.tsx +1 -2
  34. package/src/components/DataTable/DataTable.stories.tsx +0 -17
  35. package/src/components/DataTable/EmptyState/DataTableEmptyState.styles.ts +1 -3
  36. package/src/components/DataTable/EmptyState/DataTableEmptyState.tsx +0 -6
  37. package/src/components/Layout/AreaIndicator.tsx +1 -1
  38. package/src/components/Layout/PageLayout/PageLayout.styles.ts +2 -7
  39. package/src/components/Layout/PageLayout/PageLayoutBody.tsx +0 -1
  40. package/src/components/Modal/Modal.styles.ts +1 -1
  41. package/src/Form/Inputs/File.tsx +0 -69
  42. package/src/components/CrudPage/Actions/Actions.styles.ts +0 -16
  43. package/src/components/CrudPage/Actions/Actions.tsx +0 -24
  44. package/src/components/CrudPage/Actions/AddButton.tsx +0 -23
  45. package/src/components/CrudPage/Actions/Filters.tsx +0 -25
  46. package/src/components/CrudPage/Actions/Search.tsx +0 -31
  47. package/src/components/CrudPage/Actions/useSearch.tsx +0 -24
  48. package/src/components/CrudPage/Columns/Actions.tsx +0 -88
  49. package/src/components/CrudPage/CrudPage.cypress.spec.tsx +0 -559
  50. package/src/components/CrudPage/CrudPage.stories.tsx +0 -278
  51. package/src/components/CrudPage/CrudPageRoot.tsx +0 -142
  52. package/src/components/CrudPage/DeleteModal.tsx +0 -77
  53. package/src/components/CrudPage/Form/AddModal.tsx +0 -35
  54. package/src/components/CrudPage/Form/Buttons.tsx +0 -98
  55. package/src/components/CrudPage/Form/UpdateModal.tsx +0 -60
  56. package/src/components/CrudPage/Listing.tsx +0 -63
  57. package/src/components/CrudPage/atoms.ts +0 -30
  58. package/src/components/CrudPage/hooks/useDeleteItem.ts +0 -53
  59. package/src/components/CrudPage/hooks/useGetItem.ts +0 -36
  60. package/src/components/CrudPage/hooks/useGetItems.ts +0 -67
  61. package/src/components/CrudPage/hooks/useListingQueryKey.ts +0 -31
  62. package/src/components/CrudPage/index.tsx +0 -7
  63. package/src/components/CrudPage/models.ts +0 -118
  64. 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.12",
3
+ "version": "24.11.1",
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",
@@ -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: 4,
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: 4,
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(100)
98
+ layout: generateLayout(1000)
99
99
  };
100
100
 
101
101
  export const withItemHeader = DashboardTemplate.bind({});
@@ -1,4 +1,4 @@
1
- import { MutableRefObject, ReactElement, useMemo } from 'react';
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.Grid
61
- columnTickValues={xTickValues}
62
- rowTickValues={yTickValues}
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
- yScale={yScale}
65
- xScale={xScale}
59
+ scale={yScale}
66
60
  stroke={theme.palette.divider}
67
61
  top={-10}
68
62
  width={width}
@@ -1,4 +1,4 @@
1
- import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
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
- <Box ref={dashboardContainerRef} sx={{ overflowY: 'auto', overflowX: 'hidden' }}>
90
- <ParentSize>
91
- {({ width, height }): JSX.Element => (
92
- <Box className={classes.container}>
93
- {displayGrid && (
94
- <Grid
95
- columns={columns}
96
- height={(containerHeight || 0) > height ? containerHeight : height}
97
- width={width}
98
- containerRef={dashboardContainerRef}
99
- />
100
- )}
101
- <ReactGridLayout
102
- cols={columns}
103
- containerPadding={[4, 0]}
104
- layout={getLayout(layout)}
105
- margin={[20, 20]}
106
- resizeHandles={['s', 'e', 'se']}
107
- rowHeight={rowHeight}
108
- width={width}
109
- onLayoutChange={changeLayout}
110
- onResizeStart={startResize}
111
- onResizeStop={stopResize}
112
- >
113
- {children}
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
  });
@@ -30,15 +30,23 @@ interface StylesProps {
30
30
  const useStyles = makeStyles<StylesProps>()(
31
31
  (theme, { hasCustomDropZoneContent, isDraggingOver }) => ({
32
32
  dropzone: {
33
- '&:hover': {
34
- backgroundColor: alpha(theme.palette.primary.main, 0.1),
35
- boxShadow: theme.shadows[3],
36
- cursor: 'pointer'
37
- },
38
- border: `${theme.spacing(0.3)} dashed ${theme.palette.primary.main}`,
33
+ '&:hover': hasCustomDropZoneContent
34
+ ? undefined
35
+ : {
36
+ backgroundColor: alpha(theme.palette.primary.main, 0.1),
37
+ border: `${theme.spacing(0.3)} dashed ${
38
+ theme.palette.primary.main
39
+ }`,
40
+ boxShadow: theme.shadows[3],
41
+ cursor: 'pointer'
42
+ },
43
+ border: `${theme.spacing(0.3)} dashed ${
44
+ hasCustomDropZoneContent && !isDraggingOver
45
+ ? 'transparent'
46
+ : theme.palette.primary.main
47
+ }`,
39
48
  boxShadow: isDraggingOver ? theme.shadows[3] : theme.shadows[0],
40
- borderRadius: `${theme.shape.borderRadius}px`,
41
- padding: theme.spacing(0.5, 1),
49
+ padding: hasCustomDropZoneContent ? undefined : theme.spacing(1),
42
50
  width: hasCustomDropZoneContent ? '100%' : theme.spacing(50)
43
51
  },
44
52
  dropzoneInfo: {
@@ -58,7 +66,7 @@ const useStyles = makeStyles<StylesProps>()(
58
66
  export type CustomDropZoneContentProps = Pick<
59
67
  UseDropzoneState,
60
68
  'openFileExplorer'
61
- > & { files: FileList | null; label?: string };
69
+ >;
62
70
 
63
71
  interface Props {
64
72
  CustomDropZoneContent?: ({
@@ -71,7 +79,6 @@ interface Props {
71
79
  maxFileSize?: number;
72
80
  multiple?: boolean;
73
81
  resetFilesStatusAndUploadData: () => void;
74
- label?: string;
75
82
  }
76
83
 
77
84
  const getExtensions = cond([
@@ -108,8 +115,7 @@ const Dropzone = ({
108
115
  accept,
109
116
  CustomDropZoneContent,
110
117
  maxFileSize,
111
- className,
112
- label
118
+ className
113
119
  }: Props): JSX.Element => {
114
120
  const hasCustomDropZoneContent = !isNil(CustomDropZoneContent);
115
121
  const {
@@ -139,29 +145,25 @@ const Dropzone = ({
139
145
  <div>
140
146
  <Box
141
147
  className={cx(classes.dropzone, className)}
142
- onClick={openFileExplorer}
148
+ onClick={!hasCustomDropZoneContent ? openFileExplorer : undefined}
143
149
  onDragLeave={dragOver(false)}
144
150
  onDragOver={dragOver(true)}
145
151
  onDrop={dropFiles}
146
152
  >
147
153
  <div className={classes.dropzoneInfo}>
148
154
  {hasCustomDropZoneContent ? (
149
- <CustomDropZoneContent
150
- openFileExplorer={openFileExplorer}
151
- files={files}
152
- label={label}
153
- />
155
+ <CustomDropZoneContent openFileExplorer={openFileExplorer} />
154
156
  ) : (
155
- <Box sx={{ display: 'flex', gap: 2, alignItems: 'center' }}>
157
+ <>
156
158
  <PostAddIcon color="primary" fontSize="large" />
157
159
  <Typography>
158
160
  {t(labelDropOr)} {t(labelSelectAFile)}
159
161
  </Typography>
160
- </Box>
162
+ </>
161
163
  )}
162
164
  <input
163
165
  accept={accept}
164
- aria-label={t(labelSelectAFile)}
166
+ aria-label={t(labelSelectAFile) || ''}
165
167
  className={classes.input}
166
168
  multiple={multiple}
167
169
  ref={fileInputRef}
@@ -43,8 +43,7 @@ const useStyles = makeStyles()((theme) => ({
43
43
  },
44
44
  tooltip: {
45
45
  maxWidth: theme.spacing(60)
46
- },
47
- title: {}
46
+ }
48
47
  }));
49
48
 
50
49
  const CollapsibleGroup = ({
@@ -98,7 +97,7 @@ const CollapsibleGroup = ({
98
97
  <div className={classes.groupTitleIcon}>
99
98
  <Typography
100
99
  className="groupText"
101
- variant="h6"
100
+ variant="h5"
102
101
  {...group?.titleAttributes}
103
102
  >
104
103
  {t(group?.name as string)}
@@ -131,42 +131,3 @@ describe('Form list', () => {
131
131
  cy.makeSnapshot();
132
132
  });
133
133
  });
134
-
135
- const initializeFile = (): void => {
136
- cy.mount({
137
- Component: (
138
- <Form
139
- initialValues={{
140
- list: []
141
- }}
142
- inputs={[
143
- {
144
- fieldName: 'file',
145
- group: '',
146
- label: 'json',
147
- type: InputType.File,
148
- file: {
149
- accept: '.json'
150
- }
151
- }
152
- ]}
153
- submit={cy.stub()}
154
- validationSchema={object()}
155
- />
156
- )
157
- });
158
- };
159
-
160
- describe('File', () => {
161
- it('uploads a file when a file is selected', () => {
162
- initializeFile();
163
-
164
- cy.contains('Drop or select a file').should('be.visible');
165
- cy.findByLabelText('select a file').selectFile('package.json', {
166
- force: true
167
- });
168
- cy.contains('package.json').should('be.visible');
169
-
170
- cy.makeSnapshot();
171
- });
172
- });
package/src/Form/Form.tsx CHANGED
@@ -68,7 +68,6 @@ const Form = <T extends object>({
68
68
 
69
69
  return (
70
70
  <Formik<T>
71
- enableReinitialize
72
71
  initialValues={initialValues}
73
72
  validate={validate}
74
73
  validationSchema={validationSchema}
@@ -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, path, prop, type } from 'ramda';
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';
@@ -53,15 +53,7 @@ const Autocomplete = ({
53
53
 
54
54
  const [inputText, setInputText] = useState('');
55
55
 
56
- const {
57
- values,
58
- setFieldValue,
59
- setFieldTouched,
60
- errors,
61
- touched,
62
- setValues,
63
- setTouched
64
- } = useFormikContext<FormikValues>();
56
+ const { values, setFieldValue, errors } = useFormikContext<FormikValues>();
65
57
 
66
58
  const isMultiple = equals(inputType, InputType.MultiAutocomplete);
67
59
 
@@ -75,20 +67,11 @@ const Autocomplete = ({
75
67
  setInputText('');
76
68
 
77
69
  if (change) {
78
- setFieldTouched(fieldName, true, false);
79
- change({
80
- setFieldValue,
81
- value: normalizedNewValues,
82
- setFieldTouched,
83
- setValues,
84
- values,
85
- setTouched
86
- });
70
+ change({ setFieldValue, value: normalizedNewValues });
87
71
 
88
72
  return;
89
73
  }
90
74
 
91
- setFieldTouched(fieldName, true, false);
92
75
  setFieldValue(fieldName, normalizedNewValues);
93
76
  };
94
77
 
@@ -100,10 +83,6 @@ const Autocomplete = ({
100
83
  );
101
84
 
102
85
  const getError = useCallback((): Array<string> | undefined => {
103
- if (!path([...fieldName.split('.')], touched)) {
104
- return undefined;
105
- }
106
-
107
86
  const error = path([...fieldName.split('.')], errors) as
108
87
  | Array<string>
109
88
  | string
@@ -132,7 +111,7 @@ const Autocomplete = ({
132
111
  const filteredError = formattedError?.filter(Boolean);
133
112
 
134
113
  return (filteredError as Array<string>) || undefined;
135
- }, [errors, fieldName, isMultiple, selectedValues, touched]);
114
+ }, [errors, fieldName, isMultiple, selectedValues]);
136
115
 
137
116
  const textChange = useCallback(
138
117
  (event): void => setInputText(event.target.value),
@@ -188,7 +167,6 @@ const Autocomplete = ({
188
167
  value={getValues() ?? null}
189
168
  onChange={changeValues}
190
169
  onTextChange={textChange}
191
- style={{ width: autocomplete?.fullWidth ?? true ? 'auto' : '180px' }}
192
170
  />
193
171
  {inputErrors && (
194
172
  <Stack>
@@ -202,7 +180,6 @@ const Autocomplete = ({
202
180
  </div>
203
181
  ),
204
182
  memoProps: [
205
- values,
206
183
  getValues(),
207
184
  inputErrors,
208
185
  additionalLabel,
@@ -1,7 +1,7 @@
1
1
  import { useCallback, useMemo } from 'react';
2
2
 
3
3
  import { FormikValues, useFormikContext } from 'formik';
4
- import { equals, isEmpty, path, propEq, reject, split } from 'ramda';
4
+ import { path, equals, isEmpty, propEq, reject, split } from 'ramda';
5
5
  import { useTranslation } from 'react-i18next';
6
6
 
7
7
  import {
@@ -30,15 +30,8 @@ const ConnectedAutocomplete = ({
30
30
  }: InputPropsWithoutGroup): JSX.Element => {
31
31
  const { t } = useTranslation();
32
32
 
33
- const {
34
- values,
35
- touched,
36
- errors,
37
- setFieldValue,
38
- setFieldTouched,
39
- setValues,
40
- setTouched
41
- } = useFormikContext<FormikValues>();
33
+ const { values, touched, errors, setFieldValue, setFieldTouched } =
34
+ useFormikContext<FormikValues>();
42
35
 
43
36
  const filterKey = connectedAutocomplete?.filterKey || defaultFilterKey;
44
37
 
@@ -65,20 +58,18 @@ const ConnectedAutocomplete = ({
65
58
  const changeAutocomplete = useCallback(
66
59
  (_, value): void => {
67
60
  if (change) {
68
- change({
69
- setFieldValue,
70
- value,
71
- setFieldTouched,
72
- setValues,
73
- values,
74
- setTouched
75
- });
61
+ change({ setFieldValue, value });
76
62
 
77
63
  return;
78
64
  }
79
65
 
80
- setFieldTouched(fieldName, true, false);
81
66
  setFieldValue(fieldName, value);
67
+
68
+ if (path(fieldNamePath, touched)) {
69
+ return;
70
+ }
71
+
72
+ setFieldTouched(fieldName, true);
82
73
  },
83
74
  [fieldName, touched, additionalMemoProps]
84
75
  );
@@ -114,7 +105,6 @@ const ConnectedAutocomplete = ({
114
105
  const deleteItem = (_, option): void => {
115
106
  const newValue = reject(propEq(option.id, 'id'), value);
116
107
 
117
- setFieldTouched(fieldName, true, false);
118
108
  setFieldValue(fieldName, newValue);
119
109
  };
120
110
 
@@ -2,8 +2,6 @@ import { makeStyles } from 'tss-react/mui';
2
2
 
3
3
  import { InputPropsWithoutGroup } from './models';
4
4
 
5
- import { Box, Typography } from '@mui/material';
6
- import { FormikValues, useFormikContext } from 'formik';
7
5
  import { getInput } from '.';
8
6
 
9
7
  interface StylesProps {
@@ -24,22 +22,13 @@ const useStyles = makeStyles<StylesProps>()(
24
22
  })
25
23
  );
26
24
 
27
- const Grid = ({
28
- grid,
29
- hideInput
30
- }: InputPropsWithoutGroup): JSX.Element | null => {
25
+ const Grid = ({ grid }: InputPropsWithoutGroup): JSX.Element => {
31
26
  const { classes, cx } = useStyles({
32
27
  alignItems: grid?.alignItems,
33
28
  columns: grid?.columns.length,
34
29
  gridTemplateColumns: grid?.gridTemplateColumns
35
30
  });
36
31
 
37
- const { values } = useFormikContext<FormikValues>();
38
-
39
- if (hideInput?.(values) ?? false) {
40
- return null;
41
- }
42
-
43
32
  const className = grid?.className || '';
44
33
 
45
34
  return (
@@ -47,24 +36,7 @@ const Grid = ({
47
36
  {grid?.columns.map((field) => {
48
37
  const Input = getInput(field.type);
49
38
 
50
- if (field.hideInput?.(values) ?? false) {
51
- return null;
52
- }
53
-
54
- return (
55
- <Box sx={{ width: '100%' }} key={field.fieldName}>
56
- {field.additionalLabel && (
57
- <Typography
58
- sx={{ marginBottom: 0.5, color: 'primary.main' }}
59
- className={cx(field?.additionalLabelClassName)}
60
- variant="h6"
61
- >
62
- {field.additionalLabel}
63
- </Typography>
64
- )}
65
- <Input {...field} />
66
- </Box>
67
- );
39
+ return <Input key={field.fieldName} {...field} />;
68
40
  })}
69
41
  </div>
70
42
  );
@@ -1,5 +1,5 @@
1
1
  import { FormikValues, useFormikContext } from 'formik';
2
- import { equals, includes, path, split, type } from 'ramda';
2
+ import { path, equals, includes, split, type } from 'ramda';
3
3
  import { useTranslation } from 'react-i18next';
4
4
 
5
5
  import {
@@ -26,20 +26,12 @@ const Radio = ({
26
26
  }: InputPropsWithoutGroup): JSX.Element => {
27
27
  const { t } = useTranslation();
28
28
 
29
- const { values, setFieldValue, setFieldTouched, setValues, setTouched } =
30
- useFormikContext<FormikValues>();
29
+ const { values, setFieldValue } = useFormikContext<FormikValues>();
31
30
 
32
31
  const changeRadio = (_, value): void => {
33
32
  if (includes(value, ['true', 'false'])) {
34
33
  if (change) {
35
- change({
36
- setFieldValue,
37
- value: equals(value, 'true'),
38
- values,
39
- setFieldTouched,
40
- setValues,
41
- setTouched
42
- });
34
+ change({ setFieldValue, value: equals(value, 'true') });
43
35
 
44
36
  return;
45
37
  }
@@ -50,7 +42,7 @@ const Radio = ({
50
42
  }
51
43
 
52
44
  if (change) {
53
- change({ setFieldValue, value, values, setFieldTouched, setValues });
45
+ change({ setFieldValue, value });
54
46
 
55
47
  return;
56
48
  }
@@ -22,19 +22,11 @@ const Switch = ({
22
22
  }: InputPropsWithoutGroup): JSX.Element => {
23
23
  const { t } = useTranslation();
24
24
 
25
- const { values, setFieldValue, setFieldTouched, setValues, setTouched } =
26
- useFormikContext<FormikValues>();
25
+ const { values, setFieldValue } = useFormikContext<FormikValues>();
27
26
 
28
27
  const changeSwitchValue = (event: ChangeEvent<HTMLInputElement>): void => {
29
28
  if (change) {
30
- change({
31
- setFieldValue,
32
- value: event.target.checked,
33
- values,
34
- setFieldTouched,
35
- setValues,
36
- setTouched
37
- });
29
+ change({ setFieldValue, value: event.target.checked });
38
30
 
39
31
  return;
40
32
  }