componenteshospitais 2.0.4 → 2.0.6

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 | HTMLTextAreaElement>) => void;
8
+ onChange?: (e: ChangeEvent<HTMLInputElement>) => 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 | HTMLTextAreaElement>) => void;
17
- onBlur?: (e: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
16
+ onKeyPress?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
17
+ onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
18
18
  corFundo?: string;
19
19
  corLabel?: string;
20
20
  }
@@ -0,0 +1,19 @@
1
+ import React, { ChangeEvent } from 'react';
2
+ interface TextAreaFieldProps {
3
+ label?: string;
4
+ id: string;
5
+ placeholder: string;
6
+ value: string;
7
+ onChange?: (e: ChangeEvent<HTMLTextAreaElement>) => void;
8
+ largura?: string;
9
+ readonly?: boolean;
10
+ disabled?: boolean;
11
+ required?: boolean;
12
+ maxLength?: number;
13
+ onKeyPress?: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;
14
+ onBlur?: (e: React.FocusEvent<HTMLTextAreaElement>) => void;
15
+ corFundo?: string;
16
+ corLabel?: string;
17
+ }
18
+ declare const TextAreaField: React.FC<TextAreaFieldProps>;
19
+ export default TextAreaField;
@@ -10,3 +10,4 @@ export { default as SelectField } from "./components/SelectField";
10
10
  export { default as Busca } from "./components/Busca";
11
11
  export { default as CheckboxGroup } from "./components/CheckboxGroup";
12
12
  export { default as TableStandard } from "./components/TableStandard";
13
+ export { default as TextArea } from "./components/TextArea";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "componenteshospitais",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -9,7 +9,7 @@ interface InputFieldProps {
9
9
  id: string;
10
10
  placeholder: string;
11
11
  value: string;
12
- onChange?: (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
12
+ onChange?: (e: ChangeEvent<HTMLInputElement>) => void; // Tornando onChange opcional
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 | HTMLTextAreaElement>) => void;
21
- onBlur?: (e: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
20
+ onKeyPress?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
21
+ onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void; // Adicionando onBlur como opcional
22
22
  corFundo?: string;
23
23
  corLabel?: string;
24
24
  }
@@ -50,11 +50,11 @@ const InputField: React.FC<InputFieldProps> = ({
50
50
 
51
51
  const appliedMaxLength = maxLength !== undefined ? maxLength : 524288;
52
52
 
53
- const handleChange = (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
53
+ const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
54
54
  if (type === 'number' && e.target.value.length > appliedMaxLength) {
55
55
  e.target.value = e.target.value.slice(0, appliedMaxLength);
56
56
  }
57
- if (onChange) {
57
+ if (onChange) { // Verificando se onChange foi passado antes de chamá-lo
58
58
  onChange(e);
59
59
  }
60
60
  };
@@ -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 && type !== 'textarea' ? ( // Evitar o uso de máscara com textarea
73
+ {maskType ? (
74
74
  <InputMask
75
75
  mask={mask}
76
76
  value={value}
@@ -94,21 +94,6 @@ 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
- />
112
97
  ) : (
113
98
  <input
114
99
  type={type === 'password' && isPasswordVisible ? 'text' : type}
@@ -0,0 +1,68 @@
1
+ import React, { ChangeEvent } from 'react';
2
+ import styles from '../styles/input.module.css';
3
+
4
+ interface TextAreaFieldProps {
5
+ label?: string;
6
+ id: string;
7
+ placeholder: string;
8
+ value: string;
9
+ onChange?: (e: ChangeEvent<HTMLTextAreaElement>) => void;
10
+ largura?: string;
11
+ readonly?: boolean;
12
+ disabled?: boolean;
13
+ required?: boolean;
14
+ maxLength?: number;
15
+ onKeyPress?: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;
16
+ onBlur?: (e: React.FocusEvent<HTMLTextAreaElement>) => void;
17
+ corFundo?: string;
18
+ corLabel?: string;
19
+ }
20
+
21
+ const TextAreaField: React.FC<TextAreaFieldProps> = ({
22
+ id,
23
+ placeholder,
24
+ onChange,
25
+ value,
26
+ label,
27
+ largura,
28
+ readonly,
29
+ disabled,
30
+ required,
31
+ maxLength,
32
+ onKeyPress,
33
+ onBlur,
34
+ corFundo,
35
+ corLabel
36
+ }) => {
37
+ const appliedMaxLength = maxLength !== undefined ? maxLength : 524288;
38
+
39
+ return (
40
+ <>
41
+ {label && <label htmlFor={id} style={{color: corLabel ? corLabel : ''}}>{label}</label>}
42
+ <div className={styles.inputWrapper}>
43
+ <textarea
44
+ id={id}
45
+ name={id}
46
+ value={value}
47
+ placeholder={placeholder}
48
+ onChange={onChange}
49
+ className={styles.inputPadrao}
50
+ style={{
51
+ width: largura ? `${largura}` : '',
52
+ backgroundColor: disabled ? '#e5e5e5' : (corFundo ? corFundo : ''),
53
+ resize: 'none',
54
+ height: '6rem'
55
+ }}
56
+ readOnly={readonly}
57
+ disabled={disabled}
58
+ required={required}
59
+ maxLength={appliedMaxLength}
60
+ onKeyPress={onKeyPress}
61
+ onBlur={onBlur}
62
+ />
63
+ </div>
64
+ </>
65
+ );
66
+ };
67
+
68
+ export default TextAreaField;
package/src/index.tsx CHANGED
@@ -11,4 +11,5 @@ export { default as MenuPage } from "./components/MenuPage";
11
11
  export { default as SelectField } from "./components/SelectField";
12
12
  export { default as Busca } from "./components/Busca";
13
13
  export { default as CheckboxGroup } from "./components/CheckboxGroup";
14
- export { default as TableStandard } from "./components/TableStandard";
14
+ export { default as TableStandard } from "./components/TableStandard";
15
+ export { default as TextArea } from "./components/TextArea";