componenteshospitais 2.0.0 → 2.0.2
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.
|
@@ -5,7 +5,7 @@ interface InputFieldProps {
|
|
|
5
5
|
id: string;
|
|
6
6
|
placeholder: string;
|
|
7
7
|
value: string;
|
|
8
|
-
onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
8
|
+
onChange?: (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
9
9
|
largura?: string;
|
|
10
10
|
readonly?: boolean;
|
|
11
11
|
disabled?: boolean;
|
|
@@ -13,8 +13,8 @@ interface InputFieldProps {
|
|
|
13
13
|
checked?: boolean;
|
|
14
14
|
maxLength?: number;
|
|
15
15
|
maskType?: 'cpf' | 'phone' | 'time' | 'date' | 'cep' | 'telefone';
|
|
16
|
-
onKeyPress?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
17
|
-
onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
|
|
16
|
+
onKeyPress?: (e: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
17
|
+
onBlur?: (e: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
18
18
|
corFundo?: string;
|
|
19
19
|
corLabel?: string;
|
|
20
20
|
}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@ interface InputFieldProps {
|
|
|
9
9
|
id: string;
|
|
10
10
|
placeholder: string;
|
|
11
11
|
value: string;
|
|
12
|
-
onChange?: (e: ChangeEvent<HTMLInputElement>) => void; //
|
|
12
|
+
onChange?: (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void; // Aceitando também TextAreaElement
|
|
13
13
|
largura?: string;
|
|
14
14
|
readonly?: boolean;
|
|
15
15
|
disabled?: boolean;
|
|
@@ -17,8 +17,8 @@ interface InputFieldProps {
|
|
|
17
17
|
checked?: boolean;
|
|
18
18
|
maxLength?: number;
|
|
19
19
|
maskType?: 'cpf' | 'phone' | 'time' | 'date' | 'cep' | 'telefone';
|
|
20
|
-
onKeyPress?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
21
|
-
onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void; // Adicionando onBlur como opcional
|
|
20
|
+
onKeyPress?: (e: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
21
|
+
onBlur?: (e: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void; // Adicionando onBlur como opcional
|
|
22
22
|
corFundo?: string;
|
|
23
23
|
corLabel?: string;
|
|
24
24
|
}
|
|
@@ -50,7 +50,7 @@ const InputField: React.FC<InputFieldProps> = ({
|
|
|
50
50
|
|
|
51
51
|
const appliedMaxLength = maxLength !== undefined ? maxLength : 524288;
|
|
52
52
|
|
|
53
|
-
const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
53
|
+
const handleChange = (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
|
|
54
54
|
if (type === 'number' && e.target.value.length > appliedMaxLength) {
|
|
55
55
|
e.target.value = e.target.value.slice(0, appliedMaxLength);
|
|
56
56
|
}
|
|
@@ -70,7 +70,7 @@ const InputField: React.FC<InputFieldProps> = ({
|
|
|
70
70
|
<>
|
|
71
71
|
{label && <label htmlFor={id} style={{color: corLabel ? corLabel: ''}}>{label}</label>}
|
|
72
72
|
<div className={styles.inputWrapper}>
|
|
73
|
-
{maskType ? (
|
|
73
|
+
{maskType && type !== 'textarea' ? ( // Evitar o uso de máscara com textarea
|
|
74
74
|
<InputMask
|
|
75
75
|
mask={mask}
|
|
76
76
|
value={value}
|
|
@@ -94,6 +94,21 @@ const InputField: React.FC<InputFieldProps> = ({
|
|
|
94
94
|
/>
|
|
95
95
|
)}
|
|
96
96
|
</InputMask>
|
|
97
|
+
) : type === 'textarea' ? ( // Condição para renderizar textarea
|
|
98
|
+
<textarea
|
|
99
|
+
id={id}
|
|
100
|
+
name={id}
|
|
101
|
+
value={value}
|
|
102
|
+
placeholder={placeholder}
|
|
103
|
+
onChange={handleChange}
|
|
104
|
+
className={styles.inputPadrao}
|
|
105
|
+
style={{ width: largura ? `${largura}` : '', backgroundColor: (disabled ? '#e5e5e5' : (corFundo ? corFundo : '')), resize: 'none', height: '6rem'}}
|
|
106
|
+
readOnly={readonly}
|
|
107
|
+
disabled={disabled}
|
|
108
|
+
required={required}
|
|
109
|
+
onKeyPress={onKeyPress}
|
|
110
|
+
onBlur={onBlur} // Aplicando onBlur
|
|
111
|
+
/>
|
|
97
112
|
) : (
|
|
98
113
|
<input
|
|
99
114
|
type={type === 'password' && isPasswordVisible ? 'text' : type}
|
|
@@ -123,4 +138,4 @@ const InputField: React.FC<InputFieldProps> = ({
|
|
|
123
138
|
);
|
|
124
139
|
};
|
|
125
140
|
|
|
126
|
-
export default InputField;
|
|
141
|
+
export default InputField;
|