@centreon/ui 23.10.34 → 23.10.36

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centreon/ui",
3
- "version": "23.10.34",
3
+ "version": "23.10.36",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
@@ -12,6 +12,8 @@ import {
12
12
  CircularProgress
13
13
  } from '@mui/material';
14
14
 
15
+ import { DataTestAttributes } from '../@types/data-attributes';
16
+
15
17
  interface StylesProps {
16
18
  contentWidth?: number;
17
19
  }
@@ -47,7 +49,8 @@ export type Props = {
47
49
  onConfirm: (event, value?) => void;
48
50
  open: boolean;
49
51
  submitting?: boolean;
50
- } & DialogProps;
52
+ } & DialogProps &
53
+ DataTestAttributes;
51
54
 
52
55
  const Dialog = ({
53
56
  open,
@@ -95,7 +98,7 @@ const Dialog = ({
95
98
  {onCancel && (
96
99
  <Button
97
100
  color="primary"
98
- data-testid="cancel"
101
+ data-testid="Cancel"
99
102
  disabled={cancelDisabled}
100
103
  onClick={onCancel}
101
104
  >
@@ -106,7 +109,7 @@ const Dialog = ({
106
109
  aria-label={labelConfirm || ''}
107
110
  className={dialogConfirmButtonClassName}
108
111
  color="primary"
109
- data-testid="confirm"
112
+ data-testid="Confirm"
110
113
  disabled={confirmDisabled}
111
114
  endIcon={submitting && <CircularProgress size={15} />}
112
115
  onClick={onConfirm}
@@ -12,6 +12,8 @@ import {
12
12
  type as variableType
13
13
  } from 'ramda';
14
14
 
15
+ import { InputAdornment } from '@mui/material';
16
+
15
17
  import { TextField, useMemoComponent } from '../..';
16
18
 
17
19
  import PasswordEndAdornment from './PasswordEndAdornment';
@@ -64,16 +66,24 @@ const Text = ({
64
66
  ? path(fieldNamePath, errors)
65
67
  : undefined;
66
68
 
67
- const passwordEndAdornment = useCallback(
68
- (): JSX.Element | null =>
69
- equals(type, InputType.Password) ? (
69
+ const EndAdornment = useCallback((): JSX.Element | null => {
70
+ if (equals(type, InputType.Password)) {
71
+ return (
70
72
  <PasswordEndAdornment
71
73
  changeVisibility={changeVisibility}
72
74
  isVisible={isVisible}
73
75
  />
74
- ) : null,
75
- [isVisible]
76
- );
76
+ );
77
+ }
78
+
79
+ if (text?.endAdornment) {
80
+ return (
81
+ <InputAdornment position="end">{text?.endAdornment}</InputAdornment>
82
+ );
83
+ }
84
+
85
+ return null;
86
+ }, [isVisible]);
77
87
 
78
88
  const getInputType = (): string => {
79
89
  if (text?.type) {
@@ -97,13 +107,14 @@ const Text = ({
97
107
  Component: (
98
108
  <TextField
99
109
  fullWidth
100
- EndAdornment={passwordEndAdornment}
110
+ EndAdornment={EndAdornment}
101
111
  ariaLabel={t(label) || ''}
102
112
  dataTestId={dataTestId || ''}
103
113
  disabled={disabled}
104
114
  error={error as string | undefined}
105
115
  label={t(label)}
106
116
  multiline={isMultiline}
117
+ placeholder={text?.placeholder}
107
118
  required={isRequired}
108
119
  rows={rows}
109
120
  type={getInputType()}
@@ -35,7 +35,6 @@ export const getInput = R.cond<
35
35
  R.equals(InputType.Radio) as (b: InputType) => boolean,
36
36
  R.always(RadioInput)
37
37
  ],
38
- [R.equals(InputType.Text) as (b: InputType) => boolean, R.always(TextInput)],
39
38
  [
40
39
  R.equals(InputType.SingleAutocomplete) as (b: InputType) => boolean,
41
40
  R.always(Autocomplete)
@@ -44,10 +43,6 @@ export const getInput = R.cond<
44
43
  R.equals(InputType.MultiAutocomplete) as (b: InputType) => boolean,
45
44
  R.always(Autocomplete)
46
45
  ],
47
- [
48
- R.equals(InputType.Password) as (b: InputType) => boolean,
49
- R.always(TextInput)
50
- ],
51
46
  [
52
47
  R.equals(InputType.MultiConnectedAutocomplete) as (b: InputType) => boolean,
53
48
  R.always(ConnectedAutocomplete)
@@ -71,7 +66,8 @@ export const getInput = R.cond<
71
66
  [
72
67
  R.equals(InputType.CheckboxGroup) as (b: InputType) => boolean,
73
68
  R.always(CheckboxGroup)
74
- ]
69
+ ],
70
+ [R.T, R.always(TextInput)]
75
71
  ]);
76
72
 
77
73
  interface StylesProps {
@@ -87,7 +87,9 @@ export interface InputProps {
87
87
  getChecked?: (value) => boolean;
88
88
  };
89
89
  text?: {
90
+ endAdornment?: JSX.Element;
90
91
  multilineRows?: number;
92
+ placeholder?: string;
91
93
  type?: string;
92
94
  };
93
95
  type: InputType;
@@ -179,6 +179,10 @@ export const basicFormInputs: Array<InputProps> = [
179
179
  fieldName: 'email',
180
180
  group: 'First group',
181
181
  label: 'Email',
182
+ text: {
183
+ endAdornment: <MailIcon />,
184
+ placeholder: 'Your email here'
185
+ },
182
186
  type: InputType.Text
183
187
  },
184
188
  {
@@ -166,7 +166,6 @@ const TextField = forwardRef(
166
166
  },
167
167
  className
168
168
  ),
169
- disableUnderline: true,
170
169
  endAdornment: (
171
170
  <OptionalLabelInputAdornment label={label} position="end">
172
171
  {EndAdornment ? (