@centreon/ui 23.10.1-sync-release-34346.0 → 23.10.1-sync-release-70021.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.
Files changed (100) hide show
  1. package/package.json +3 -3
  2. package/src/Button/Icon/index.stories.tsx +1 -1
  3. package/src/Button/Icon/index.tsx +1 -1
  4. package/src/Graph/LineChart/Legend/index.tsx +7 -8
  5. package/src/Graph/LineChart/LineChart.tsx +4 -1
  6. package/src/Graph/LineChart/index.tsx +4 -1
  7. package/src/InputField/Number/Number.cypress.spec.tsx +85 -0
  8. package/src/InputField/Number/Number.stories.tsx +66 -0
  9. package/src/InputField/Number/Number.tsx +74 -0
  10. package/src/InputField/Search/index.tsx +2 -2
  11. package/src/InputField/Select/IconPopover/index.tsx +1 -1
  12. package/src/InputField/Text/index.tsx +38 -38
  13. package/src/Listing/ActionBar/index.tsx +1 -2
  14. package/src/Listing/Listing.cypress.spec.tsx +2 -2
  15. package/src/Listing/index.stories.tsx +2 -2
  16. package/src/Listing/index.tsx +137 -123
  17. package/src/Panel/index.tsx +1 -1
  18. package/src/ThemeProvider/index.tsx +3 -0
  19. package/src/TopCounterElements/TopCounterLayout.tsx +3 -0
  20. package/src/TopCounterElements/useCloseOnLegacyPage.ts +39 -0
  21. package/src/api/index.ts +3 -3
  22. package/src/api/useGraphQuery/index.ts +26 -5
  23. package/src/api/useGraphQuery/models.ts +5 -0
  24. package/src/components/CollapsibleItem/CollapsibleItem.cypress.spec.tsx +76 -0
  25. package/src/components/CollapsibleItem/CollapsibleItem.stories.tsx +26 -0
  26. package/src/components/CollapsibleItem/CollapsibleItem.tsx +43 -14
  27. package/src/components/CollapsibleItem/useCollapsibleItemStyles.ts +24 -1
  28. package/src/components/Form/{AccessRightsV2 → AccessRights}/AccessRights.cypress.spec.tsx +23 -0
  29. package/src/components/Form/{AccessRightsV2 → AccessRights}/ShareInput/ContactSwitch.tsx +9 -1
  30. package/src/components/Form/{AccessRightsV2 → AccessRights}/ShareInput/ShareInput.styles.ts +8 -0
  31. package/src/components/Form/{AccessRightsV2 → AccessRights}/ShareInput/useShareInput.tsx +4 -0
  32. package/src/components/Form/{AccessRightsV2 → AccessRights}/models.ts +1 -0
  33. package/src/components/Form/{AccessRightsV2 → AccessRights}/storiesData.ts +1 -0
  34. package/src/components/Form/index.ts +2 -2
  35. package/src/components/ItemComposition/Item.tsx +1 -1
  36. package/src/components/ItemComposition/ItemComposition.cypress.spec.tsx +113 -0
  37. package/src/components/ItemComposition/ItemComposition.stories.tsx +14 -0
  38. package/src/components/ItemComposition/ItemComposition.styles.ts +34 -1
  39. package/src/components/ItemComposition/ItemComposition.tsx +41 -17
  40. package/src/components/Modal/Modal.styles.ts +3 -2
  41. package/src/components/Modal/ModalActions.tsx +4 -2
  42. package/src/index.ts +1 -0
  43. package/src/utils/index.ts +2 -0
  44. package/src/utils/useFullscreen/Fullscreen.cypress.spec.tsx +132 -0
  45. package/src/utils/useFullscreen/atoms.ts +3 -0
  46. package/src/utils/useFullscreen/index.ts +2 -0
  47. package/src/utils/useFullscreen/translatedLabels.ts +1 -0
  48. package/src/utils/useFullscreen/useFullscreen.ts +73 -0
  49. package/src/utils/useFullscreen/useFullscreenListener.ts +59 -0
  50. package/src/components/Form/AccessRights/AccessRights.resource.ts +0 -45
  51. package/src/components/Form/AccessRights/AccessRightsForm.stories.tsx +0 -59
  52. package/src/components/Form/AccessRights/AccessRightsForm.styles.ts +0 -21
  53. package/src/components/Form/AccessRights/AccessRightsForm.tsx +0 -67
  54. package/src/components/Form/AccessRights/AccessRightsFormActions.tsx +0 -80
  55. package/src/components/Form/AccessRights/Input/AddAction.tsx +0 -31
  56. package/src/components/Form/AccessRights/Input/ContactAccessRightInput.stories.tsx +0 -54
  57. package/src/components/Form/AccessRights/Input/ContactAccessRightInput.tsx +0 -72
  58. package/src/components/Form/AccessRights/Input/ContactAccessRightsInput.styles.ts +0 -22
  59. package/src/components/Form/AccessRights/Input/ContactInputField.tsx +0 -105
  60. package/src/components/Form/AccessRights/Input/RoleInputField.tsx +0 -29
  61. package/src/components/Form/AccessRights/List/ContactAccessRightsList.stories.tsx +0 -97
  62. package/src/components/Form/AccessRights/List/ContactAccessRightsList.styles.ts +0 -71
  63. package/src/components/Form/AccessRights/List/ContactAccessRightsList.tsx +0 -51
  64. package/src/components/Form/AccessRights/List/ContactAccessRightsListItem.stories.tsx +0 -116
  65. package/src/components/Form/AccessRights/List/ContactAccessRightsListItem.tsx +0 -118
  66. package/src/components/Form/AccessRights/List/ContactAccessRightsListItemSkeleton.tsx +0 -26
  67. package/src/components/Form/AccessRights/List/ContactAccessRightsListSkeleton.tsx +0 -28
  68. package/src/components/Form/AccessRights/Stats/AccessRightsStats.styles.ts +0 -18
  69. package/src/components/Form/AccessRights/Stats/AccessRightsStats.tsx +0 -41
  70. package/src/components/Form/AccessRights/__fixtures__/contactAccessRight.mock.ts +0 -52
  71. package/src/components/Form/AccessRights/common/GroupLabel.styles.ts +0 -18
  72. package/src/components/Form/AccessRights/common/GroupLabel.tsx +0 -15
  73. package/src/components/Form/AccessRights/common/Input.styles.ts +0 -48
  74. package/src/components/Form/AccessRights/common/RoleInputSelect.styles.ts +0 -11
  75. package/src/components/Form/AccessRights/common/RoleInputSelect.tsx +0 -57
  76. package/src/components/Form/AccessRights/index.ts +0 -3
  77. package/src/components/Form/AccessRights/useAccessRightsForm.test.tsx +0 -531
  78. package/src/components/Form/AccessRights/useAccessRightsForm.tsx +0 -282
  79. package/src/components/Form/AccessRights/useAccessRightsForm.utils.ts +0 -41
  80. /package/src/components/Form/{AccessRightsV2 → AccessRights}/AccessRights.stories.tsx +0 -0
  81. /package/src/components/Form/{AccessRightsV2 → AccessRights}/AccessRights.styles.ts +0 -0
  82. /package/src/components/Form/{AccessRightsV2 → AccessRights}/AccessRights.tsx +0 -0
  83. /package/src/components/Form/{AccessRightsV2 → AccessRights}/Actions/Actions.styles.ts +0 -0
  84. /package/src/components/Form/{AccessRightsV2 → AccessRights}/Actions/Actions.tsx +0 -0
  85. /package/src/components/Form/{AccessRightsV2 → AccessRights}/Actions/useActions.ts +0 -0
  86. /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/Item.tsx +0 -0
  87. /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/List.styles.tsx +0 -0
  88. /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/List.tsx +0 -0
  89. /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/ListItemSkeleton.tsx +0 -0
  90. /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/ListSkeleton.tsx +0 -0
  91. /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/RemoveAccessRight.tsx +0 -0
  92. /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/StateChip.tsx +0 -0
  93. /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/useItem.ts +0 -0
  94. /package/src/components/Form/{AccessRightsV2 → AccessRights}/Provider.tsx +0 -0
  95. /package/src/components/Form/{AccessRightsV2 → AccessRights}/ShareInput/ShareInput.tsx +0 -0
  96. /package/src/components/Form/{AccessRightsV2 → AccessRights}/Stats/Stats.tsx +0 -0
  97. /package/src/components/Form/{AccessRightsV2 → AccessRights}/atoms.ts +0 -0
  98. /package/src/components/Form/{AccessRightsV2 → AccessRights}/common/RoleSelectField.styles.tsx +0 -0
  99. /package/src/components/Form/{AccessRightsV2 → AccessRights}/common/RoleSelectField.tsx +0 -0
  100. /package/src/components/Form/{AccessRightsV2 → AccessRights}/useAccessRightsInitValues.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centreon/ui",
3
- "version": "23.10.1-sync-release-34346.0",
3
+ "version": "23.10.1-sync-release-70021.0",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
@@ -64,7 +64,7 @@
64
64
  "@storybook/preview-api": "^7.0.9",
65
65
  "@storybook/react": "^7.0.9",
66
66
  "@storybook/react-vite": "^7.0.9",
67
- "@storybook/test-runner": "^0.10.0",
67
+ "@storybook/test-runner": "^0.16.0",
68
68
  "@storybook/testing-library": "^0.1.0",
69
69
  "@storybook/theming": "^7.0.9",
70
70
  "@testing-library/cypress": "^8.0.7",
@@ -138,7 +138,7 @@
138
138
  "@mui/material": "5.x",
139
139
  "@mui/styles": "5.x",
140
140
  "@tanstack/react-query": "4.x",
141
- "axios": "0.x",
141
+ "axios": ">= 1.6.4",
142
142
  "dayjs": "1.x",
143
143
  "formik": "2.x",
144
144
  "jotai": "2.x",
@@ -4,7 +4,7 @@ import { makeStyles } from 'tss-react/mui';
4
4
  import AccessibilityIcon from '@mui/icons-material/Accessibility';
5
5
  import { Theme } from '@mui/material';
6
6
 
7
- import IconButton from '.';
7
+ import { IconButton } from '.';
8
8
 
9
9
  const useStyles = makeStyles()((theme: Theme) => ({
10
10
  root: {
@@ -38,7 +38,7 @@ type Props = {
38
38
  | 'top-start';
39
39
  } & IconButtonProps;
40
40
 
41
- const IconButton = ({
41
+ export const IconButton = ({
42
42
  title = '',
43
43
  ariaLabel,
44
44
  className,
@@ -7,7 +7,6 @@ import { Box, alpha, useTheme } from '@mui/material';
7
7
 
8
8
  import { useMemoComponent } from '@centreon/ui';
9
9
 
10
- import { maxLinesDisplayedLegend } from '../common';
11
10
  import { formatMetricValue } from '../../common/timeSeries';
12
11
  import { Line, TimeValue } from '../../common/timeSeries/models';
13
12
  import { labelAvg, labelMax, labelMin } from '../translatedLabels';
@@ -24,7 +23,7 @@ import LegendContent from './LegendContent';
24
23
  interface Props {
25
24
  base: number;
26
25
  displayAnchor?: boolean;
27
- limitLegendRows?: boolean;
26
+ limitLegend?: false | number;
28
27
  lines: Array<Line>;
29
28
  renderExtraComponent?: ReactNode;
30
29
  setLinesGraph: Dispatch<SetStateAction<Array<Line> | null>>;
@@ -39,14 +38,14 @@ const MainLegend = ({
39
38
  timeSeries,
40
39
  base,
41
40
  toggable = true,
42
- limitLegendRows = true,
41
+ limitLegend = false,
43
42
  renderExtraComponent,
44
43
  displayAnchor = true,
45
44
  setLinesGraph,
46
45
  xScale,
47
46
  shouldDisplayLegendInCompactMode
48
47
  }: Props): JSX.Element => {
49
- const { classes, cx } = useStyles({ limitLegendRows });
48
+ const { classes, cx } = useStyles({ limitLegendRows: Boolean(limitLegend) });
50
49
  const theme = useTheme();
51
50
 
52
51
  const { selectMetricLine, clearHighlight, highlightLine, toggleMetricLine } =
@@ -61,8 +60,8 @@ const MainLegend = ({
61
60
 
62
61
  const sortedData = sortBy(prop('metric_id'), lines);
63
62
 
64
- const displayedLines = limitLegendRows
65
- ? slice(0, maxLinesDisplayedLegend, sortedData)
63
+ const displayedLines = limitLegend
64
+ ? slice(0, limitLegend, sortedData)
66
65
  : sortedData;
67
66
 
68
67
  const getMetricValue = ({ value, unit }: GetMetricValueProps): string =>
@@ -174,7 +173,7 @@ const MainLegend = ({
174
173
  const Legend = (props: Props): JSX.Element => {
175
174
  const {
176
175
  toggable,
177
- limitLegendRows,
176
+ limitLegend,
178
177
  timeSeries,
179
178
  lines,
180
179
  base,
@@ -191,7 +190,7 @@ const Legend = (props: Props): JSX.Element => {
191
190
  lines,
192
191
  base,
193
192
  toggable,
194
- limitLegendRows,
193
+ limitLegend,
195
194
  displayAnchor,
196
195
  shouldDisplayLegendInCompactMode
197
196
  ]
@@ -43,6 +43,7 @@ interface Props extends LineChartProps {
43
43
  graphInterval: GraphInterval;
44
44
  graphRef: MutableRefObject<HTMLDivElement | null>;
45
45
  legend?: LegendModel;
46
+ limitLegend?: false | number;
46
47
  marginBottom: number;
47
48
  shapeLines?: GlobalAreaLines;
48
49
  thresholdUnit?: string;
@@ -73,7 +74,8 @@ const LineChart = ({
73
74
  curve,
74
75
  marginBottom,
75
76
  thresholds,
76
- thresholdUnit
77
+ thresholdUnit,
78
+ limitLegend
77
79
  }: Props): JSX.Element => {
78
80
  const { classes } = useStyles();
79
81
 
@@ -301,6 +303,7 @@ const LineChart = ({
301
303
  <Legend
302
304
  base={baseAxis}
303
305
  displayAnchor={displayAnchor?.displayGuidingLines ?? true}
306
+ limitLegend={limitLegend}
304
307
  lines={newLines}
305
308
  renderExtraComponent={legend?.renderExtraComponent}
306
309
  setLinesGraph={setLinesGraph}
@@ -28,6 +28,7 @@ interface Props extends Partial<LineChartProps> {
28
28
  data?: LineChartData;
29
29
  end: string;
30
30
  legend: LegendModel;
31
+ limitLegend?: false | number;
31
32
  loading: boolean;
32
33
  marginBottom?: number;
33
34
  shapeLines?: GlobalAreaLines;
@@ -55,7 +56,8 @@ const WrapperLineChart = ({
55
56
  curve = Curve.curveLinear,
56
57
  marginBottom = 0,
57
58
  thresholds,
58
- thresholdUnit
59
+ thresholdUnit,
60
+ limitLegend
59
61
  }: Props): JSX.Element | null => {
60
62
  const { adjustedData } = useLineChartData({ data, end, start });
61
63
  const lineChartRef = useRef<HTMLDivElement | null>(null);
@@ -95,6 +97,7 @@ const WrapperLineChart = ({
95
97
  header={header}
96
98
  height={height || responsiveHeight}
97
99
  legend={legend}
100
+ limitLegend={limitLegend}
98
101
  loading={loading}
99
102
  marginBottom={marginBottom}
100
103
  shapeLines={shapeLines}
@@ -0,0 +1,85 @@
1
+ import NumberField, { NumberProps } from './Number';
2
+
3
+ const initialize = (props: NumberProps): void => {
4
+ cy.mount({
5
+ Component: <NumberField {...props} />
6
+ });
7
+ };
8
+
9
+ describe('Number field', () => {
10
+ it('displays the placeholder when the field has no default or fallback values', () => {
11
+ initialize({ dataTestId: 'test', onChange: cy.stub() });
12
+
13
+ cy.get('input').should('have.value', '');
14
+ cy.get('input').should('have.attr', 'placeholder', '0');
15
+
16
+ cy.makeSnapshot();
17
+ });
18
+
19
+ it('displays the fallback value as placeholder when the field as no default value', () => {
20
+ initialize({ dataTestId: 'test', fallbackValue: 25, onChange: cy.stub() });
21
+
22
+ cy.get('input').should('have.value', '');
23
+ cy.get('input').should('have.attr', 'placeholder', '25');
24
+
25
+ cy.makeSnapshot();
26
+ });
27
+
28
+ it('displays the default value as placeholder when the field as default value', () => {
29
+ initialize({ dataTestId: 'test', defaultValue: 25, onChange: cy.stub() });
30
+
31
+ cy.get('input').should('have.value', '25');
32
+
33
+ cy.makeSnapshot();
34
+ });
35
+
36
+ it('displays the fallback value when the field is cleared out', () => {
37
+ initialize({
38
+ dataTestId: 'test',
39
+ defaultValue: 25,
40
+ fallbackValue: 10,
41
+ onChange: cy.stub()
42
+ });
43
+
44
+ cy.get('input').should('have.value', '25');
45
+ cy.get('input').clear();
46
+ cy.get('input').should('have.value', '');
47
+ cy.get('input').should('have.attr', 'placeholder', '10');
48
+
49
+ cy.makeSnapshot();
50
+ });
51
+
52
+ it('displays the field using auto size', () => {
53
+ initialize({
54
+ autoSize: true,
55
+ dataTestId: 'test',
56
+ defaultValue: 25,
57
+ onChange: cy.stub()
58
+ });
59
+
60
+ cy.get('input').should('have.value', '25');
61
+
62
+ cy.get('input').type('0');
63
+
64
+ cy.makeSnapshot();
65
+ });
66
+
67
+ it('sets the value to the minimum value configured when a value less than the minimum value is typed in the field', () => {
68
+ initialize({
69
+ dataTestId: 'test',
70
+ defaultValue: 25,
71
+ inputProps: {
72
+ min: 2
73
+ },
74
+ onChange: cy.stub()
75
+ });
76
+
77
+ cy.get('input').should('have.value', '25');
78
+
79
+ cy.get('input').clear().type('-1');
80
+
81
+ cy.get('input').should('have.value', '2');
82
+
83
+ cy.makeSnapshot();
84
+ });
85
+ });
@@ -0,0 +1,66 @@
1
+ /* eslint-disable no-console */
2
+ import { Meta, StoryObj } from '@storybook/react';
3
+
4
+ import NumberField from './Number';
5
+
6
+ const meta: Meta<typeof NumberField> = {
7
+ argTypes: {
8
+ defaultValue: {
9
+ defaultValue: 0,
10
+ description:
11
+ 'The initial value which will be used by the input for the first render',
12
+ type: 'number'
13
+ },
14
+ fallbackValue: {
15
+ defaultValue: 0,
16
+ description: 'This value will be used when the input is cleared',
17
+ type: 'number'
18
+ },
19
+ onChange: {
20
+ description:
21
+ 'The change function with the actual value as parameter. This parameter will be the value when the input is filled but it will be the fallbackValue when the input is cleared out',
22
+ type: 'function'
23
+ }
24
+ },
25
+ component: NumberField
26
+ };
27
+
28
+ export default meta;
29
+ type Story = StoryObj<typeof NumberField>;
30
+
31
+ export const Default: Story = {
32
+ args: {
33
+ onChange: console.log
34
+ }
35
+ };
36
+
37
+ export const WithDefaultValue: Story = {
38
+ args: {
39
+ defaultValue: 25,
40
+ onChange: console.log
41
+ }
42
+ };
43
+
44
+ export const WithFallbackValue: Story = {
45
+ args: {
46
+ fallbackValue: 25,
47
+ onChange: console.log
48
+ }
49
+ };
50
+
51
+ export const WithFallbackValueAndDefaultValue: Story = {
52
+ args: {
53
+ defaultValue: 10,
54
+ fallbackValue: 25,
55
+ onChange: console.log
56
+ }
57
+ };
58
+
59
+ export const WithFallbackValueAndDefaultValueAutoSize: Story = {
60
+ args: {
61
+ autoSize: true,
62
+ defaultValue: 10,
63
+ fallbackValue: 25,
64
+ onChange: console.log
65
+ }
66
+ };
@@ -0,0 +1,74 @@
1
+ import { ChangeEvent, useState } from 'react';
2
+
3
+ import { T, always, cond, isEmpty, isNil } from 'ramda';
4
+
5
+ import TextField, { TextProps } from '../Text';
6
+
7
+ export interface NumberProps
8
+ extends Omit<TextProps, 'defaultValue' | 'onChange'> {
9
+ /**
10
+ * The initial value which will be used by the input for the first render
11
+ */
12
+ defaultValue?: number;
13
+ /**
14
+ * This value will be used when the input is cleared
15
+ */
16
+ fallbackValue?: number;
17
+ /**
18
+ * The change function with the actual value as parameter. This parameter will be the value when the input is filled but it will be the fallbackValue when the input is cleared out
19
+ */
20
+ onChange: (actualValue: number) => void;
21
+ }
22
+
23
+ const NumberField = ({
24
+ fallbackValue = 0,
25
+ defaultValue,
26
+ onChange,
27
+ ...props
28
+ }: NumberProps): JSX.Element => {
29
+ const [placeholder, setPlaceholder] = useState<string | undefined>();
30
+ const [actualValue, setActualValue] = useState(
31
+ defaultValue ? `${defaultValue}` : ''
32
+ );
33
+
34
+ const { inputProps } = props;
35
+
36
+ const changeValue = (event: ChangeEvent<HTMLInputElement>): void => {
37
+ const inputValue = event.target.value;
38
+
39
+ const number = Number(inputValue);
40
+ const campledNumber = cond([
41
+ [() => isEmpty(inputValue), always(fallbackValue)],
42
+ [() => Number.isNaN(number), always(number)],
43
+ [
44
+ T,
45
+ always(
46
+ Math.max(
47
+ !isNil(inputProps?.min) ? inputProps?.min : -Infinity,
48
+ number
49
+ )
50
+ )
51
+ ]
52
+ ])();
53
+
54
+ onChange(campledNumber);
55
+ setPlaceholder(isEmpty(inputValue) ? `${fallbackValue}` : undefined);
56
+ setActualValue(isEmpty(inputValue) ? inputValue : `${campledNumber}`);
57
+ };
58
+
59
+ return (
60
+ <TextField
61
+ defaultValue={defaultValue}
62
+ type="number"
63
+ value={actualValue}
64
+ onChange={changeValue}
65
+ {...props}
66
+ inputProps={inputProps}
67
+ placeholder={
68
+ placeholder || (!defaultValue ? `${fallbackValue}` : undefined)
69
+ }
70
+ />
71
+ );
72
+ };
73
+
74
+ export default NumberField;
@@ -1,8 +1,8 @@
1
1
  import IconSearch from '@mui/icons-material/Search';
2
2
 
3
- import TextField, { Props as TextFieldProps } from '../Text';
3
+ import TextField, { TextProps } from '../Text';
4
4
 
5
- type Props = Omit<TextFieldProps, 'StartAdornment'>;
5
+ type Props = Omit<TextProps, 'StartAdornment'>;
6
6
 
7
7
  const SearchAdornment = (): JSX.Element => <IconSearch />;
8
8
 
@@ -15,7 +15,7 @@ import {
15
15
  } from '@mui/material';
16
16
  import IconReset from '@mui/icons-material/RotateLeft';
17
17
 
18
- import IconButton from '../../../Button/Icon';
18
+ import { IconButton } from '../../..';
19
19
  import Option from '../Option';
20
20
  import { SelectEntry } from '..';
21
21
 
@@ -17,38 +17,36 @@ import { getNormalizedId } from '../../utils';
17
17
 
18
18
  import useAutoSize from './useAutoSize';
19
19
 
20
- const useStyles = makeStyles<{ displayAsBlock: boolean }>()(
21
- (theme: Theme, { displayAsBlock }) => ({
22
- autoSizeCompact: {
23
- paddingRight: theme.spacing(1),
24
- paddingTop: theme.spacing(0.6)
25
- },
26
- hiddenText: {
27
- display: 'table',
28
- lineHeight: 0,
29
- transform: 'scaleY(0)'
30
- },
31
- input: {
32
- fontSize: theme.typography.body1.fontSize
33
- },
34
- inputBase: {
35
- display: displayAsBlock ? 'block' : 'inline-flex',
36
- justifyItems: 'start',
37
- paddingRight: theme.spacing(1)
38
- },
39
- noLabelInput: {
40
- padding: theme.spacing(1)
41
- },
42
- textField: {
43
- transition: theme.transitions.create(['width'], {
44
- duration: theme.transitions.duration.shortest
45
- })
46
- },
47
- transparent: {
48
- backgroundColor: 'transparent'
49
- }
50
- })
51
- );
20
+ const useStyles = makeStyles()((theme: Theme) => ({
21
+ autoSizeCompact: {
22
+ paddingRight: theme.spacing(1),
23
+ paddingTop: theme.spacing(0.6)
24
+ },
25
+ hiddenText: {
26
+ display: 'table',
27
+ lineHeight: 0,
28
+ transform: 'scaleY(0)'
29
+ },
30
+ input: {
31
+ fontSize: theme.typography.body1.fontSize
32
+ },
33
+ inputBase: {
34
+ display: 'inline-flex',
35
+ justifyItems: 'start',
36
+ paddingRight: theme.spacing(1)
37
+ },
38
+ noLabelInput: {
39
+ padding: theme.spacing(1)
40
+ },
41
+ textField: {
42
+ transition: theme.transitions.create(['width'], {
43
+ duration: theme.transitions.duration.shortest
44
+ })
45
+ },
46
+ transparent: {
47
+ backgroundColor: 'transparent'
48
+ }
49
+ }));
52
50
 
53
51
  interface OptionalLabelInputAdornmentProps {
54
52
  children: React.ReactNode;
@@ -72,7 +70,7 @@ const OptionalLabelInputAdornment = ({
72
70
 
73
71
  type SizeVariant = 'large' | 'medium' | 'small' | 'compact';
74
72
 
75
- export type Props = {
73
+ export type TextProps = {
76
74
  EndAdornment?: React.FC;
77
75
  StartAdornment?: React.FC;
78
76
  ariaLabel?: string;
@@ -114,17 +112,18 @@ const TextField = forwardRef(
114
112
  defaultValue,
115
113
  required = false,
116
114
  containerClassName,
115
+ type,
117
116
  ...rest
118
- }: Props,
117
+ }: TextProps,
119
118
  ref: React.ForwardedRef<HTMLDivElement>
120
119
  ): JSX.Element => {
121
- const { classes, cx } = useStyles({
122
- displayAsBlock: autoSize && isNil(StartAdornment) && isNil(EndAdornment)
123
- });
120
+ const { classes, cx } = useStyles();
124
121
 
125
122
  const { inputRef, width, changeInputValue, innerValue } = useAutoSize({
126
123
  autoSize,
127
- autoSizeCustomPadding,
124
+ autoSizeCustomPadding: equals(type, 'number')
125
+ ? Math.max(6, autoSizeCustomPadding || 0)
126
+ : autoSizeCustomPadding,
128
127
  autoSizeDefaultWidth,
129
128
  value: externalValueForAutoSize || rest.value
130
129
  });
@@ -196,6 +195,7 @@ const TextField = forwardRef(
196
195
  width: autoSize ? width : undefined,
197
196
  ...rest?.sx
198
197
  }}
198
+ type={type}
199
199
  />
200
200
  </Tooltip>
201
201
  {autoSize && (
@@ -9,10 +9,9 @@ import Divider from '@mui/material/Divider';
9
9
 
10
10
  import { userAtom, ListingVariant } from '@centreon/ui-context';
11
11
 
12
- import { ListingProps } from '../..';
12
+ import { ListingProps, IconButton } from '../..';
13
13
  import { labelOf, labelRowsPerPage } from '../translatedLabels';
14
14
  import { useMemoComponent } from '../../utils';
15
- import IconButton from '../../Button/Icon/index';
16
15
 
17
16
  import StyledPagination from './Pagination';
18
17
  import PaginationActions from './PaginationActions';
@@ -77,9 +77,9 @@ const mountListing = (): void => {
77
77
  subItems={{
78
78
  canCheckSubItems: false,
79
79
  enable: true,
80
+ getRowProperty: () => 'subItems',
80
81
  labelCollapse: 'Collapse',
81
- labelExpand: 'Expand',
82
- rowProperty: 'subItems'
82
+ labelExpand: 'Expand'
83
83
  }}
84
84
  totalRows={10}
85
85
  />
@@ -377,9 +377,9 @@ export const ListingWithSubItems = {
377
377
  subItems: {
378
378
  canCheckSubItems: false,
379
379
  enable: true,
380
+ getRowProperty: () => 'subItems',
380
381
  labelCollapse: 'Collapse',
381
- labelExpand: 'Expand',
382
- rowProperty: 'subItems'
382
+ labelExpand: 'Expand'
383
383
  },
384
384
  totalRows: 10
385
385
  }