@zauru-sdk/components 1.0.54 → 1.0.60

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 (94) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/LICENCE.md +11 -11
  3. package/package.json +7 -7
  4. package/src/Alerts/ErrorBoundaryAlert/ErrorBoundaryAlert.tsx +66 -66
  5. package/src/Alerts/StaticAlert.tsx +121 -121
  6. package/src/Alerts/index.ts +2 -2
  7. package/src/BlockUI/BlockUI.tsx +50 -50
  8. package/src/BlockUI/index.tsx +1 -1
  9. package/src/Buttons/Button.tsx +90 -90
  10. package/src/Buttons/index.ts +1 -1
  11. package/src/Card/Card.tsx +24 -24
  12. package/src/Card/index.ts +1 -1
  13. package/src/Chat/ChatLayout.tsx +131 -131
  14. package/src/Chat/ChatMessageHistory.tsx +142 -142
  15. package/src/Chat/index.ts +2 -2
  16. package/src/ConnectionState/ConnectionState.tsx +27 -27
  17. package/src/ConnectionState/index.tsx +1 -1
  18. package/src/Containers/BodyContainer.tsx +14 -14
  19. package/src/Containers/ButtonSectionContainer.tsx +21 -21
  20. package/src/Containers/Container.tsx +39 -39
  21. package/src/Containers/DoubleContainer.tsx +48 -48
  22. package/src/Containers/MainContainer.tsx +17 -17
  23. package/src/Containers/OutletContainer.tsx +14 -14
  24. package/src/Containers/SubContainer.tsx +37 -37
  25. package/src/Containers/index.ts +7 -7
  26. package/src/DynamicTable/BasicPrintDynamicTable.tsx +73 -73
  27. package/src/DynamicTable/DynamicPrintTable.tsx +288 -288
  28. package/src/DynamicTable/DynamicTable.tsx +405 -405
  29. package/src/DynamicTable/GenericDynamicTable.tsx +456 -456
  30. package/src/DynamicTable/index.tsx +4 -4
  31. package/src/Footer/Footer.tsx +50 -50
  32. package/src/Footer/index.tsx +1 -1
  33. package/src/Form/Checkbox/index.tsx +96 -96
  34. package/src/Form/Checklist/index.tsx +35 -35
  35. package/src/Form/DatePicker/index.tsx +132 -132
  36. package/src/Form/DynamicBaculoForm/index.tsx +361 -361
  37. package/src/Form/FieldContainer/DoubleFieldContainer.tsx +35 -35
  38. package/src/Form/FieldContainer/QuadrupleFieldContainer.tsx +36 -36
  39. package/src/Form/FieldContainer/TripleFieldContainer.tsx +35 -35
  40. package/src/Form/FieldContainer/index.ts +3 -3
  41. package/src/Form/FileUpload/index.tsx +184 -184
  42. package/src/Form/FormButtons/index.tsx +78 -78
  43. package/src/Form/FormLayout/index.tsx +37 -37
  44. package/src/Form/SelectField/index.tsx +237 -237
  45. package/src/Form/TextArea/index.tsx +125 -125
  46. package/src/Form/TextField/index.tsx +194 -194
  47. package/src/Form/TimePicker/index.tsx +127 -127
  48. package/src/Form/YesNo/index.tsx +77 -77
  49. package/src/Form/index.ts +13 -13
  50. package/src/Labels/InfoLabel/index.tsx +21 -21
  51. package/src/Labels/index.tsx +1 -1
  52. package/src/Layouts/homeLayout/index.tsx +34 -34
  53. package/src/Layouts/index.ts +1 -1
  54. package/src/LineSeparator/LineSeparator.tsx +3 -3
  55. package/src/LineSeparator/index.tsx +1 -1
  56. package/src/Modal/Modal.tsx +104 -104
  57. package/src/Modal/index.tsx +1 -1
  58. package/src/NavBar/NavBar.tsx +223 -223
  59. package/src/NavBar/NavBar.types.ts +64 -64
  60. package/src/NavBar/NavBar.utils.ts +58 -58
  61. package/src/NavBar/index.tsx +5 -5
  62. package/src/ProgressBar/ProgressBar.tsx +25 -25
  63. package/src/ProgressBar/ProgressCircle.tsx +75 -75
  64. package/src/ProgressBar/index.tsx +2 -2
  65. package/src/Skeletons/LoadingInputSkeleton.tsx +12 -12
  66. package/src/Skeletons/index.ts +1 -1
  67. package/src/Tab/Tab.tsx +63 -63
  68. package/src/Tab/index.ts +1 -1
  69. package/src/Table/ZauruTable.tsx +265 -265
  70. package/src/Table/index.tsx +1 -1
  71. package/src/TaskList/TaskList.tsx +88 -88
  72. package/src/TaskList/index.ts +1 -1
  73. package/src/Titles/LabelArray.tsx +17 -17
  74. package/src/Titles/TableColumnTitle.tsx +9 -9
  75. package/src/Titles/TitleH1.tsx +10 -10
  76. package/src/Titles/TitleH2.tsx +10 -10
  77. package/src/Titles/TitleH3.tsx +10 -10
  78. package/src/Titles/index.ts +5 -5
  79. package/src/Tooltip/Tooltip.tsx +42 -42
  80. package/src/Tooltip/index.ts +1 -1
  81. package/src/WithTooltip/WithTooltip.tsx +21 -21
  82. package/src/WithTooltip/index.tsx +1 -1
  83. package/src/Wizards/StepWizard.tsx +88 -88
  84. package/src/Wizards/index.ts +1 -1
  85. package/src/Zendesk/Chat.tsx +83 -83
  86. package/src/Zendesk/index.ts +2 -2
  87. package/src/Zendesk/zendesk.config.ts +40 -40
  88. package/src/index.ts +24 -24
  89. package/src/postcss.config.mjs +5 -5
  90. package/src/tailwind.config.ts +10 -10
  91. package/src/tailwind.css +3 -3
  92. package/tsconfig.cjs.json +8 -8
  93. package/tsconfig.esm.json +11 -11
  94. package/tsconfig.json +17 -17
@@ -1,125 +1,125 @@
1
- import { useAppSelector } from "@zauru-sdk/redux";
2
- import React, { useEffect, useState } from "react";
3
-
4
- type Props = {
5
- id?: string;
6
- name: string;
7
- formName?: string;
8
- title?: string;
9
- defaultValue?: string | number;
10
- hidden?: boolean;
11
- hint?: string;
12
- helpText?: string;
13
- onChange?: (value: string) => void;
14
- onKeyDown?: (event: React.KeyboardEvent) => void;
15
- disabled?: boolean;
16
- readOnly?: boolean;
17
- error?: string | undefined;
18
- rows?: number;
19
- cols?: number;
20
- stopChangeEvents?: boolean;
21
- className?: string;
22
- };
23
-
24
- export const TextAreaWithoutValidation = (props: Props) => {
25
- const {
26
- id,
27
- name,
28
- title,
29
- defaultValue = "",
30
- hidden,
31
- hint,
32
- onChange,
33
- onKeyDown,
34
- disabled = false,
35
- error = false,
36
- readOnly = false,
37
- rows,
38
- cols,
39
- stopChangeEvents,
40
- className = "",
41
- } = props;
42
-
43
- const [value, setValue] = useState(defaultValue);
44
-
45
- const color = error ? "red" : "gray";
46
- const isReadOnly = disabled || readOnly;
47
- const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
48
- const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
49
- const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-500`;
50
-
51
- useEffect(() => {
52
- setValue(defaultValue);
53
- }, [defaultValue]);
54
-
55
- if (hidden) {
56
- return (
57
- <textarea
58
- id={id ?? name}
59
- name={name}
60
- value={defaultValue}
61
- readOnly={true}
62
- hidden={true}
63
- />
64
- );
65
- }
66
-
67
- const handleInputChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
68
- if (stopChangeEvents) {
69
- event.stopPropagation();
70
- event.preventDefault();
71
- }
72
- setValue(event.target.value);
73
- onChange && onChange(event.target.value);
74
- };
75
-
76
- return (
77
- <div className={`col-span-6 sm:col-span-3 ${className}`}>
78
- {title && (
79
- <label
80
- htmlFor={error ? `${name}-error` : `${name}-success`}
81
- className={`block text-sm font-medium text-${color}-700 dark:text-${color}-500`}
82
- >
83
- {title}
84
- </label>
85
- )}
86
- <textarea
87
- name={name}
88
- readOnly={readOnly}
89
- disabled={disabled}
90
- id={id ?? name}
91
- autoComplete="given-name"
92
- value={value}
93
- rows={rows}
94
- cols={cols}
95
- onChange={handleInputChange}
96
- onKeyDown={(event: React.KeyboardEvent) => {
97
- onKeyDown && onKeyDown(event);
98
- }}
99
- className={`mt-1 block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm`}
100
- />
101
- {error && (
102
- <p className={`mt-2 text-sm text-${color}-600 dark:text-${color}-500`}>
103
- <span className="font-medium">Oops!</span> {error}
104
- </p>
105
- )}
106
- {!error && hint && (
107
- <p
108
- className={`mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`}
109
- >
110
- {hint}
111
- </p>
112
- )}
113
- </div>
114
- );
115
- };
116
-
117
- //<reference> https://tailwindui.com/components/application-ui/forms/form-layouts
118
- export const TextArea = (props: Props) => {
119
- const { formValidations } = useAppSelector((state) => state.formValidation);
120
- const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
121
-
122
- props = { ...props, error };
123
-
124
- return <TextAreaWithoutValidation {...props} />;
125
- };
1
+ import { useAppSelector } from "@zauru-sdk/redux";
2
+ import React, { useEffect, useState } from "react";
3
+
4
+ type Props = {
5
+ id?: string;
6
+ name: string;
7
+ formName?: string;
8
+ title?: string;
9
+ defaultValue?: string | number;
10
+ hidden?: boolean;
11
+ hint?: string;
12
+ helpText?: string;
13
+ onChange?: (value: string) => void;
14
+ onKeyDown?: (event: React.KeyboardEvent) => void;
15
+ disabled?: boolean;
16
+ readOnly?: boolean;
17
+ error?: string | undefined;
18
+ rows?: number;
19
+ cols?: number;
20
+ stopChangeEvents?: boolean;
21
+ className?: string;
22
+ };
23
+
24
+ export const TextAreaWithoutValidation = (props: Props) => {
25
+ const {
26
+ id,
27
+ name,
28
+ title,
29
+ defaultValue = "",
30
+ hidden,
31
+ hint,
32
+ onChange,
33
+ onKeyDown,
34
+ disabled = false,
35
+ error = false,
36
+ readOnly = false,
37
+ rows,
38
+ cols,
39
+ stopChangeEvents,
40
+ className = "",
41
+ } = props;
42
+
43
+ const [value, setValue] = useState(defaultValue);
44
+
45
+ const color = error ? "red" : "gray";
46
+ const isReadOnly = disabled || readOnly;
47
+ const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
48
+ const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
49
+ const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-500`;
50
+
51
+ useEffect(() => {
52
+ setValue(defaultValue);
53
+ }, [defaultValue]);
54
+
55
+ if (hidden) {
56
+ return (
57
+ <textarea
58
+ id={id ?? name}
59
+ name={name}
60
+ value={defaultValue}
61
+ readOnly={true}
62
+ hidden={true}
63
+ />
64
+ );
65
+ }
66
+
67
+ const handleInputChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
68
+ if (stopChangeEvents) {
69
+ event.stopPropagation();
70
+ event.preventDefault();
71
+ }
72
+ setValue(event.target.value);
73
+ onChange && onChange(event.target.value);
74
+ };
75
+
76
+ return (
77
+ <div className={`col-span-6 sm:col-span-3 ${className}`}>
78
+ {title && (
79
+ <label
80
+ htmlFor={error ? `${name}-error` : `${name}-success`}
81
+ className={`block text-sm font-medium text-${color}-700 dark:text-${color}-500`}
82
+ >
83
+ {title}
84
+ </label>
85
+ )}
86
+ <textarea
87
+ name={name}
88
+ readOnly={readOnly}
89
+ disabled={disabled}
90
+ id={id ?? name}
91
+ autoComplete="given-name"
92
+ value={value}
93
+ rows={rows}
94
+ cols={cols}
95
+ onChange={handleInputChange}
96
+ onKeyDown={(event: React.KeyboardEvent) => {
97
+ onKeyDown && onKeyDown(event);
98
+ }}
99
+ className={`mt-1 block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm`}
100
+ />
101
+ {error && (
102
+ <p className={`mt-2 text-sm text-${color}-600 dark:text-${color}-500`}>
103
+ <span className="font-medium">Oops!</span> {error}
104
+ </p>
105
+ )}
106
+ {!error && hint && (
107
+ <p
108
+ className={`mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`}
109
+ >
110
+ {hint}
111
+ </p>
112
+ )}
113
+ </div>
114
+ );
115
+ };
116
+
117
+ //<reference> https://tailwindui.com/components/application-ui/forms/form-layouts
118
+ export const TextArea = (props: Props) => {
119
+ const { formValidations } = useAppSelector((state) => state.formValidation);
120
+ const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
121
+
122
+ props = { ...props, error };
123
+
124
+ return <TextAreaWithoutValidation {...props} />;
125
+ };
@@ -1,194 +1,194 @@
1
- import { IdeaIconSVG } from "@zauru-sdk/icons";
2
- import { useAppSelector } from "@zauru-sdk/redux";
3
- import React, { useEffect, useState } from "react";
4
-
5
- type Props = {
6
- id?: string;
7
- name?: string;
8
- formName?: string;
9
- title?: string;
10
- defaultValue?: string | number;
11
- hidden?: boolean;
12
- type?: React.HTMLInputTypeAttribute;
13
- helpText?: string;
14
- hint?: string;
15
- onChange?: (
16
- value: string,
17
- event: React.ChangeEvent<HTMLInputElement>
18
- ) => void;
19
- onKeyDown?: (event: React.KeyboardEvent) => void;
20
- disabled?: boolean;
21
- readOnly?: boolean;
22
- error?: string;
23
- min?: string | number;
24
- integer?: boolean;
25
- stopChangeEvents?: boolean;
26
- style?: React.CSSProperties;
27
- className?: string;
28
- };
29
-
30
- export const TextFieldWithoutValidation = (props: Props) => {
31
- const {
32
- id,
33
- name,
34
- defaultValue = "",
35
- hidden,
36
- type = "text",
37
- onChange,
38
- onKeyDown,
39
- disabled = false,
40
- readOnly = false,
41
- min,
42
- integer = false,
43
- stopChangeEvents,
44
- style,
45
- error,
46
- title,
47
- helpText,
48
- className,
49
- hint,
50
- } = props;
51
-
52
- const [showTooltip, setShowTooltip] = useState<boolean>(false);
53
- const [value, setValue] = useState(defaultValue);
54
-
55
- const color = error ? "red" : "gray";
56
-
57
- const isReadOnly = disabled || readOnly;
58
- const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
59
- const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
60
- const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-500`;
61
-
62
- useEffect(() => {
63
- setValue(defaultValue);
64
- }, [defaultValue]);
65
-
66
- if (hidden) {
67
- return (
68
- <input
69
- type={type}
70
- id={id ?? name}
71
- name={name}
72
- value={defaultValue}
73
- readOnly={true}
74
- hidden={true}
75
- />
76
- );
77
- }
78
-
79
- const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
80
- if (stopChangeEvents) {
81
- event.stopPropagation();
82
- event.preventDefault();
83
- }
84
- if (integer && type === "number") {
85
- const value = event.target.value;
86
- const isInteger = /^[0-9]*$/.test(value);
87
- if (isInteger || value === "") {
88
- setValue(value);
89
- onChange && onChange(value, event);
90
- }
91
- } else {
92
- setValue(event.target.value);
93
- onChange && onChange(event.target.value, event);
94
- }
95
- };
96
-
97
- const handleKeyDown = (event: React.KeyboardEvent) => {
98
- if (integer && type === "number") {
99
- // Permitir solo números y teclas de control
100
- const allowedKeys = [
101
- "Backspace",
102
- "ArrowLeft",
103
- "ArrowRight",
104
- "Delete",
105
- "Enter",
106
- "Tab",
107
- ];
108
- if (!allowedKeys.includes(event.key) && !/^[0-9]$/.test(event.key)) {
109
- event.preventDefault();
110
- }
111
- }
112
- };
113
-
114
- const inputComponent = (
115
- <input
116
- type={type}
117
- name={name}
118
- readOnly={readOnly}
119
- disabled={disabled}
120
- id={id ?? name}
121
- autoComplete="given-name"
122
- value={value}
123
- onWheel={(e: React.WheelEvent<HTMLInputElement>) => {
124
- e.currentTarget.blur();
125
- }}
126
- step={type === "number" ? 0.01 : undefined} //para aceptar decimales
127
- onChange={handleInputChange}
128
- onKeyDown={(event: React.KeyboardEvent) => {
129
- handleKeyDown(event);
130
- onKeyDown && onKeyDown(event);
131
- }}
132
- min={min}
133
- style={style}
134
- className={`block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm`}
135
- />
136
- );
137
-
138
- if (!error && !title) {
139
- return <div className={`${className}`}>{inputComponent}</div>;
140
- }
141
-
142
- return (
143
- <div className={`col-span-6 sm:col-span-3 ${className}`}>
144
- {title && (
145
- <label
146
- htmlFor={error ? `${name}-error` : `${name}-success`}
147
- className={`block mb-1 text-sm font-medium text-${color}-700 dark:text-${color}-500`}
148
- >
149
- {title}
150
- </label>
151
- )}
152
- <div className="flex relative items-center">
153
- {inputComponent}
154
- {helpText && (
155
- <div className="flex items-center relative ml-3">
156
- <div
157
- className="relative cursor-pointer"
158
- onMouseEnter={() => setShowTooltip(true)}
159
- onMouseLeave={() => setShowTooltip(false)}
160
- >
161
- <IdeaIconSVG />
162
- {showTooltip && (
163
- <div className="absolute -left-48 top-0 mt-8 p-2 bg-white border rounded shadow text-black z-50">
164
- {helpText}
165
- </div>
166
- )}
167
- </div>
168
- </div>
169
- )}
170
- </div>
171
- {error && (
172
- <p className={`mt-2 text-sm text-${color}-600 dark:text-${color}-500`}>
173
- <span className="font-medium">Oops!</span> {error}
174
- </p>
175
- )}
176
- {!error && hint && (
177
- <p
178
- className={`mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`}
179
- >
180
- {hint}
181
- </p>
182
- )}
183
- </div>
184
- );
185
- };
186
-
187
- export const TextField = (props: Props) => {
188
- const { formValidations } = useAppSelector((state) => state.formValidation);
189
- const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
190
-
191
- props = { ...props, error };
192
-
193
- return <TextFieldWithoutValidation {...props} />;
194
- };
1
+ import { IdeaIconSVG } from "@zauru-sdk/icons";
2
+ import { useAppSelector } from "@zauru-sdk/redux";
3
+ import React, { useEffect, useState } from "react";
4
+
5
+ type Props = {
6
+ id?: string;
7
+ name?: string;
8
+ formName?: string;
9
+ title?: string;
10
+ defaultValue?: string | number;
11
+ hidden?: boolean;
12
+ type?: React.HTMLInputTypeAttribute;
13
+ helpText?: string;
14
+ hint?: string;
15
+ onChange?: (
16
+ value: string,
17
+ event: React.ChangeEvent<HTMLInputElement>
18
+ ) => void;
19
+ onKeyDown?: (event: React.KeyboardEvent) => void;
20
+ disabled?: boolean;
21
+ readOnly?: boolean;
22
+ error?: string;
23
+ min?: string | number;
24
+ integer?: boolean;
25
+ stopChangeEvents?: boolean;
26
+ style?: React.CSSProperties;
27
+ className?: string;
28
+ };
29
+
30
+ export const TextFieldWithoutValidation = (props: Props) => {
31
+ const {
32
+ id,
33
+ name,
34
+ defaultValue = "",
35
+ hidden,
36
+ type = "text",
37
+ onChange,
38
+ onKeyDown,
39
+ disabled = false,
40
+ readOnly = false,
41
+ min,
42
+ integer = false,
43
+ stopChangeEvents,
44
+ style,
45
+ error,
46
+ title,
47
+ helpText,
48
+ className,
49
+ hint,
50
+ } = props;
51
+
52
+ const [showTooltip, setShowTooltip] = useState<boolean>(false);
53
+ const [value, setValue] = useState(defaultValue);
54
+
55
+ const color = error ? "red" : "gray";
56
+
57
+ const isReadOnly = disabled || readOnly;
58
+ const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
59
+ const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
60
+ const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-500`;
61
+
62
+ useEffect(() => {
63
+ setValue(defaultValue);
64
+ }, [defaultValue]);
65
+
66
+ if (hidden) {
67
+ return (
68
+ <input
69
+ type={type}
70
+ id={id ?? name}
71
+ name={name}
72
+ value={defaultValue}
73
+ readOnly={true}
74
+ hidden={true}
75
+ />
76
+ );
77
+ }
78
+
79
+ const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
80
+ if (stopChangeEvents) {
81
+ event.stopPropagation();
82
+ event.preventDefault();
83
+ }
84
+ if (integer && type === "number") {
85
+ const value = event.target.value;
86
+ const isInteger = /^[0-9]*$/.test(value);
87
+ if (isInteger || value === "") {
88
+ setValue(value);
89
+ onChange && onChange(value, event);
90
+ }
91
+ } else {
92
+ setValue(event.target.value);
93
+ onChange && onChange(event.target.value, event);
94
+ }
95
+ };
96
+
97
+ const handleKeyDown = (event: React.KeyboardEvent) => {
98
+ if (integer && type === "number") {
99
+ // Permitir solo números y teclas de control
100
+ const allowedKeys = [
101
+ "Backspace",
102
+ "ArrowLeft",
103
+ "ArrowRight",
104
+ "Delete",
105
+ "Enter",
106
+ "Tab",
107
+ ];
108
+ if (!allowedKeys.includes(event.key) && !/^[0-9]$/.test(event.key)) {
109
+ event.preventDefault();
110
+ }
111
+ }
112
+ };
113
+
114
+ const inputComponent = (
115
+ <input
116
+ type={type}
117
+ name={name}
118
+ readOnly={readOnly}
119
+ disabled={disabled}
120
+ id={id ?? name}
121
+ autoComplete="given-name"
122
+ value={value}
123
+ onWheel={(e: React.WheelEvent<HTMLInputElement>) => {
124
+ e.currentTarget.blur();
125
+ }}
126
+ step={type === "number" ? 0.01 : undefined} //para aceptar decimales
127
+ onChange={handleInputChange}
128
+ onKeyDown={(event: React.KeyboardEvent) => {
129
+ handleKeyDown(event);
130
+ onKeyDown && onKeyDown(event);
131
+ }}
132
+ min={min}
133
+ style={style}
134
+ className={`block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm`}
135
+ />
136
+ );
137
+
138
+ if (!error && !title) {
139
+ return <div className={`${className}`}>{inputComponent}</div>;
140
+ }
141
+
142
+ return (
143
+ <div className={`col-span-6 sm:col-span-3 ${className}`}>
144
+ {title && (
145
+ <label
146
+ htmlFor={error ? `${name}-error` : `${name}-success`}
147
+ className={`block mb-1 text-sm font-medium text-${color}-700 dark:text-${color}-500`}
148
+ >
149
+ {title}
150
+ </label>
151
+ )}
152
+ <div className="flex relative items-center">
153
+ {inputComponent}
154
+ {helpText && (
155
+ <div className="flex items-center relative ml-3">
156
+ <div
157
+ className="relative cursor-pointer"
158
+ onMouseEnter={() => setShowTooltip(true)}
159
+ onMouseLeave={() => setShowTooltip(false)}
160
+ >
161
+ <IdeaIconSVG />
162
+ {showTooltip && (
163
+ <div className="absolute -left-48 top-0 mt-8 p-2 bg-white border rounded shadow text-black z-50">
164
+ {helpText}
165
+ </div>
166
+ )}
167
+ </div>
168
+ </div>
169
+ )}
170
+ </div>
171
+ {error && (
172
+ <p className={`mt-2 text-sm text-${color}-600 dark:text-${color}-500`}>
173
+ <span className="font-medium">Oops!</span> {error}
174
+ </p>
175
+ )}
176
+ {!error && hint && (
177
+ <p
178
+ className={`mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`}
179
+ >
180
+ {hint}
181
+ </p>
182
+ )}
183
+ </div>
184
+ );
185
+ };
186
+
187
+ export const TextField = (props: Props) => {
188
+ const { formValidations } = useAppSelector((state) => state.formValidation);
189
+ const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
190
+
191
+ props = { ...props, error };
192
+
193
+ return <TextFieldWithoutValidation {...props} />;
194
+ };