@zauru-sdk/components 1.0.98 → 1.0.100
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/CHANGELOG.md +16 -0
- package/dist/Form/Checkbox/index.d.ts +1 -3
- package/dist/Form/DatePicker/index.d.ts +1 -3
- package/dist/Form/FileUpload/index.d.ts +1 -2
- package/dist/Form/ReactZodForm/index.d.ts +12 -0
- package/dist/Form/SelectField/index.d.ts +6 -9
- package/dist/Form/TextArea/index.d.ts +1 -3
- package/dist/Form/TextField/index.d.ts +1 -3
- package/dist/Form/TimePicker/index.d.ts +1 -2
- package/dist/Form/YesNo/index.d.ts +1 -0
- package/dist/Form/index.d.ts +1 -2
- package/dist/Layouts/homeLayout/index.d.ts +3 -1
- package/dist/Modal/Modal.d.ts +1 -1
- package/dist/Zendesk/zendesk.config.d.ts +1 -1
- package/dist/cjs/Alerts/StaticAlert.js +0 -6
- package/dist/cjs/Buttons/Button.js +13 -2
- package/dist/cjs/DynamicTable/DynamicPrintTable.js +2 -2
- package/dist/cjs/DynamicTable/DynamicTable.js +3 -3
- package/dist/cjs/DynamicTable/GenericDynamicTable.js +4 -5
- package/dist/cjs/Footer/Footer.js +1 -1
- package/dist/cjs/Form/Checkbox/index.js +14 -14
- package/dist/cjs/Form/Checklist/index.js +1 -1
- package/dist/cjs/Form/DatePicker/index.js +14 -13
- package/dist/cjs/Form/DynamicBaculoForm/index.js +1 -1
- package/dist/cjs/Form/FileUpload/index.js +25 -13
- package/dist/cjs/Form/ReactZodForm/index.js +31 -0
- package/dist/cjs/Form/SelectField/index.js +118 -73
- package/dist/cjs/Form/TextArea/index.js +15 -15
- package/dist/cjs/Form/TextField/index.js +20 -16
- package/dist/cjs/Form/TimePicker/index.js +17 -15
- package/dist/cjs/Form/YesNo/index.js +12 -6
- package/dist/cjs/Form/index.js +1 -2
- package/dist/cjs/Layouts/homeLayout/index.js +45 -8
- package/dist/cjs/Modal/Modal.js +1 -2
- package/dist/cjs/NavBar/NavBar.js +12 -17
- package/dist/cjs/Table/ZauruTable.js +11 -4
- package/dist/cjs/WithTooltip/WithTooltip.js +1 -1
- package/dist/cjs/Zendesk/zendesk.config.js +7 -9
- package/dist/esm/Alerts/StaticAlert.js +0 -6
- package/dist/esm/Buttons/Button.js +13 -2
- package/dist/esm/DynamicTable/DynamicPrintTable.js +4 -4
- package/dist/esm/DynamicTable/DynamicTable.js +6 -6
- package/dist/esm/DynamicTable/GenericDynamicTable.js +7 -8
- package/dist/esm/Footer/Footer.js +1 -1
- package/dist/esm/Form/Checkbox/index.js +13 -12
- package/dist/esm/Form/Checklist/index.js +2 -2
- package/dist/esm/Form/DatePicker/index.js +13 -11
- package/dist/esm/Form/DynamicBaculoForm/index.js +2 -2
- package/dist/esm/Form/FileUpload/index.js +24 -11
- package/dist/esm/Form/ReactZodForm/index.js +27 -0
- package/dist/esm/Form/SelectField/index.js +118 -49
- package/dist/esm/Form/TextArea/index.js +14 -13
- package/dist/esm/Form/TextField/index.js +19 -14
- package/dist/esm/Form/TimePicker/index.js +16 -13
- package/dist/esm/Form/YesNo/index.js +12 -6
- package/dist/esm/Form/index.js +1 -2
- package/dist/esm/Layouts/homeLayout/index.js +46 -9
- package/dist/esm/Modal/Modal.js +1 -2
- package/dist/esm/NavBar/NavBar.js +12 -17
- package/dist/esm/Table/ZauruTable.js +11 -4
- package/dist/esm/WithTooltip/WithTooltip.js +2 -2
- package/dist/esm/Zendesk/zendesk.config.js +7 -6
- package/package.json +9 -6
- package/src/Alerts/StaticAlert.tsx +0 -10
- package/src/Buttons/Button.tsx +24 -4
- package/src/DynamicTable/DynamicPrintTable.tsx +5 -6
- package/src/DynamicTable/DynamicTable.tsx +7 -7
- package/src/DynamicTable/GenericDynamicTable.tsx +7 -8
- package/src/Footer/Footer.tsx +1 -1
- package/src/Form/Checkbox/index.tsx +21 -18
- package/src/Form/Checklist/index.tsx +2 -2
- package/src/Form/DatePicker/index.tsx +22 -19
- package/src/Form/DynamicBaculoForm/index.tsx +2 -2
- package/src/Form/FileUpload/index.tsx +29 -14
- package/src/Form/ReactZodForm/index.tsx +60 -0
- package/src/Form/SelectField/index.tsx +246 -130
- package/src/Form/TextArea/index.tsx +22 -19
- package/src/Form/TextField/index.tsx +25 -18
- package/src/Form/TimePicker/index.tsx +25 -18
- package/src/Form/YesNo/index.tsx +20 -7
- package/src/Form/index.ts +1 -2
- package/src/Layouts/homeLayout/index.tsx +114 -21
- package/src/Modal/Modal.tsx +2 -5
- package/src/NavBar/NavBar.tsx +35 -46
- package/src/Table/ZauruTable.tsx +11 -4
- package/src/WithTooltip/WithTooltip.tsx +8 -7
- package/src/Zendesk/zendesk.config.ts +8 -6
- package/dist/Form/FormLayout/index.d.ts +0 -11
- package/dist/Form/RadioButtonGroup/index.d.ts +0 -20
- package/dist/cjs/Form/FormLayout/index.js +0 -11
- package/dist/cjs/Form/RadioButtonGroup/index.js +0 -26
- package/dist/esm/Form/FormLayout/index.js +0 -7
- package/dist/esm/Form/RadioButtonGroup/index.js +0 -21
- package/src/Form/FormLayout/index.tsx +0 -37
- package/src/Form/RadioButtonGroup/index.tsx +0 -108
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { IdeaIconSVG } from "@zauru-sdk/icons";
|
|
2
|
-
import { useAppSelector } from "@zauru-sdk/redux";
|
|
3
2
|
import React, { useEffect, useState } from "react";
|
|
3
|
+
import { useFormContext } from "react-hook-form";
|
|
4
4
|
|
|
5
5
|
type Props = {
|
|
6
6
|
id?: string;
|
|
7
7
|
name?: string;
|
|
8
|
-
formName?: string;
|
|
9
8
|
title?: string;
|
|
10
9
|
defaultValue?: string | number;
|
|
11
10
|
hidden?: boolean;
|
|
@@ -19,15 +18,15 @@ type Props = {
|
|
|
19
18
|
onKeyDown?: (event: React.KeyboardEvent) => void;
|
|
20
19
|
disabled?: boolean;
|
|
21
20
|
readOnly?: boolean;
|
|
22
|
-
error?: string;
|
|
23
21
|
min?: string | number;
|
|
24
22
|
integer?: boolean;
|
|
25
23
|
stopChangeEvents?: boolean;
|
|
26
24
|
style?: React.CSSProperties;
|
|
27
25
|
className?: string;
|
|
26
|
+
required?: boolean;
|
|
28
27
|
};
|
|
29
28
|
|
|
30
|
-
export const
|
|
29
|
+
export const TextField = (props: Props) => {
|
|
31
30
|
const {
|
|
32
31
|
id,
|
|
33
32
|
name,
|
|
@@ -42,15 +41,26 @@ export const TextFieldWithoutValidation = (props: Props) => {
|
|
|
42
41
|
integer = false,
|
|
43
42
|
stopChangeEvents,
|
|
44
43
|
style,
|
|
45
|
-
error,
|
|
46
44
|
title,
|
|
47
45
|
helpText,
|
|
48
46
|
className,
|
|
49
47
|
hint,
|
|
48
|
+
required,
|
|
50
49
|
} = props;
|
|
51
50
|
|
|
52
51
|
const [showTooltip, setShowTooltip] = useState<boolean>(false);
|
|
53
52
|
const [value, setValue] = useState(defaultValue);
|
|
53
|
+
const {
|
|
54
|
+
register: tempRegister,
|
|
55
|
+
formState: { errors },
|
|
56
|
+
} = useFormContext() || { formState: {} }; // Obtener el contexto solo si existe
|
|
57
|
+
const error = errors ? errors[props.name ?? "-1"] : undefined;
|
|
58
|
+
const register = tempRegister
|
|
59
|
+
? tempRegister(props.name ?? "-1", {
|
|
60
|
+
valueAsNumber: props.type === "number",
|
|
61
|
+
required,
|
|
62
|
+
})
|
|
63
|
+
: undefined; // Solo usar register si está disponible
|
|
54
64
|
|
|
55
65
|
const color = error ? "red" : "gray";
|
|
56
66
|
|
|
@@ -68,15 +78,19 @@ export const TextFieldWithoutValidation = (props: Props) => {
|
|
|
68
78
|
<input
|
|
69
79
|
type={type}
|
|
70
80
|
id={id ?? name}
|
|
71
|
-
name={name}
|
|
72
81
|
value={defaultValue}
|
|
73
82
|
readOnly={true}
|
|
74
83
|
hidden={true}
|
|
84
|
+
{...(register ?? {})}
|
|
85
|
+
name={name}
|
|
75
86
|
/>
|
|
76
87
|
);
|
|
77
88
|
}
|
|
78
89
|
|
|
79
90
|
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
91
|
+
if (register) {
|
|
92
|
+
register.onChange(event);
|
|
93
|
+
}
|
|
80
94
|
if (stopChangeEvents) {
|
|
81
95
|
event.stopPropagation();
|
|
82
96
|
event.preventDefault();
|
|
@@ -114,7 +128,6 @@ export const TextFieldWithoutValidation = (props: Props) => {
|
|
|
114
128
|
const inputComponent = (
|
|
115
129
|
<input
|
|
116
130
|
type={type}
|
|
117
|
-
name={name}
|
|
118
131
|
readOnly={readOnly}
|
|
119
132
|
disabled={disabled}
|
|
120
133
|
id={id ?? name}
|
|
@@ -124,7 +137,6 @@ export const TextFieldWithoutValidation = (props: Props) => {
|
|
|
124
137
|
e.currentTarget.blur();
|
|
125
138
|
}}
|
|
126
139
|
step={type === "number" ? 0.01 : undefined} //para aceptar decimales
|
|
127
|
-
onChange={handleInputChange}
|
|
128
140
|
onKeyDown={(event: React.KeyboardEvent) => {
|
|
129
141
|
handleKeyDown(event);
|
|
130
142
|
onKeyDown && onKeyDown(event);
|
|
@@ -132,6 +144,9 @@ export const TextFieldWithoutValidation = (props: Props) => {
|
|
|
132
144
|
min={min}
|
|
133
145
|
style={style}
|
|
134
146
|
className={`block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm`}
|
|
147
|
+
{...(register ?? {})}
|
|
148
|
+
name={name}
|
|
149
|
+
onChange={handleInputChange}
|
|
135
150
|
/>
|
|
136
151
|
);
|
|
137
152
|
|
|
@@ -147,6 +162,7 @@ export const TextFieldWithoutValidation = (props: Props) => {
|
|
|
147
162
|
className={`block mb-1 text-sm font-medium text-${color}-700 dark:text-${color}-500`}
|
|
148
163
|
>
|
|
149
164
|
{title}
|
|
165
|
+
{required && <span className="text-red-500">*</span>}
|
|
150
166
|
</label>
|
|
151
167
|
)}
|
|
152
168
|
<div className="flex relative items-center">
|
|
@@ -170,7 +186,7 @@ export const TextFieldWithoutValidation = (props: Props) => {
|
|
|
170
186
|
</div>
|
|
171
187
|
{error && (
|
|
172
188
|
<p className={`mt-2 text-sm text-${color}-600 dark:text-${color}-500`}>
|
|
173
|
-
<span className="font-medium">Oops!</span> {error}
|
|
189
|
+
<span className="font-medium">Oops!</span> {error.message?.toString()}
|
|
174
190
|
</p>
|
|
175
191
|
)}
|
|
176
192
|
{!error && hint && (
|
|
@@ -183,12 +199,3 @@ export const TextFieldWithoutValidation = (props: Props) => {
|
|
|
183
199
|
</div>
|
|
184
200
|
);
|
|
185
201
|
};
|
|
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,6 +1,6 @@
|
|
|
1
1
|
import { ClockIconSVG, CloseSvgIcon, IdeaIconSVG } from "@zauru-sdk/icons";
|
|
2
|
-
import { useAppSelector } from "@zauru-sdk/redux";
|
|
3
2
|
import React, { useEffect, useState } from "react";
|
|
3
|
+
import { useFormContext } from "react-hook-form";
|
|
4
4
|
|
|
5
5
|
type Props = {
|
|
6
6
|
id?: string;
|
|
@@ -12,11 +12,11 @@ type Props = {
|
|
|
12
12
|
defaultValue?: string;
|
|
13
13
|
onChange?: (value: string) => void;
|
|
14
14
|
tabIndex?: number;
|
|
15
|
-
error?: string;
|
|
16
15
|
disabled?: boolean;
|
|
16
|
+
required?: boolean;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
export const
|
|
19
|
+
export const FormTimePicker = (props: Props) => {
|
|
20
20
|
const {
|
|
21
21
|
id,
|
|
22
22
|
name,
|
|
@@ -26,12 +26,20 @@ export const FormTimePickerWithoutValidation = (props: Props) => {
|
|
|
26
26
|
helpText,
|
|
27
27
|
onChange,
|
|
28
28
|
tabIndex,
|
|
29
|
-
error,
|
|
30
29
|
disabled = false,
|
|
30
|
+
required = false,
|
|
31
31
|
} = props;
|
|
32
32
|
|
|
33
33
|
const [value, setValue] = useState<string>(defaultValue);
|
|
34
34
|
const [showTooltip, setShowTooltip] = useState<boolean>(false);
|
|
35
|
+
const {
|
|
36
|
+
register: tempRegister,
|
|
37
|
+
formState: { errors },
|
|
38
|
+
} = useFormContext() || { formState: {} }; // Obtener el contexto solo si existe
|
|
39
|
+
const error = errors ? errors[props.name ?? "-1"] : undefined;
|
|
40
|
+
const register = tempRegister
|
|
41
|
+
? tempRegister(props.name ?? "-1", { required })
|
|
42
|
+
: undefined; // Solo usar register si está disponible
|
|
35
43
|
|
|
36
44
|
const color = error ? "red" : "gray";
|
|
37
45
|
|
|
@@ -49,6 +57,14 @@ export const FormTimePickerWithoutValidation = (props: Props) => {
|
|
|
49
57
|
onChange && onChange("");
|
|
50
58
|
};
|
|
51
59
|
|
|
60
|
+
const handleOnChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
61
|
+
setValue(e.target.value);
|
|
62
|
+
onChange && onChange(e.target.value);
|
|
63
|
+
if (register) {
|
|
64
|
+
register.onChange(e);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
52
68
|
return (
|
|
53
69
|
<>
|
|
54
70
|
{title && (
|
|
@@ -57,6 +73,7 @@ export const FormTimePickerWithoutValidation = (props: Props) => {
|
|
|
57
73
|
className={`block text-sm font-medium ${textColor}`}
|
|
58
74
|
>
|
|
59
75
|
{title}
|
|
76
|
+
{required && <span className="text-red-500">*</span>}
|
|
60
77
|
</label>
|
|
61
78
|
)}
|
|
62
79
|
<div className="flex relative items-center">
|
|
@@ -65,16 +82,14 @@ export const FormTimePickerWithoutValidation = (props: Props) => {
|
|
|
65
82
|
</div>
|
|
66
83
|
<input
|
|
67
84
|
id={id}
|
|
68
|
-
name={name}
|
|
69
85
|
tabIndex={tabIndex}
|
|
70
86
|
type="time"
|
|
71
|
-
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
72
|
-
setValue(e.target.value);
|
|
73
|
-
onChange && onChange(e.target.value);
|
|
74
|
-
}}
|
|
75
87
|
value={value}
|
|
76
88
|
pattern="\d{2}:\d{2}"
|
|
77
89
|
className={`${bgColor} ${borderColor} ${textColor} text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2.5`}
|
|
90
|
+
{...(register ?? {})}
|
|
91
|
+
name={name}
|
|
92
|
+
onChange={handleOnChange}
|
|
78
93
|
/>
|
|
79
94
|
{value && (
|
|
80
95
|
<button
|
|
@@ -104,7 +119,7 @@ export const FormTimePickerWithoutValidation = (props: Props) => {
|
|
|
104
119
|
</div>
|
|
105
120
|
{error && (
|
|
106
121
|
<p className={`mt-2 text-sm text-${color}-600 dark:text-${color}-500`}>
|
|
107
|
-
<span className="font-medium">Oops!</span> {error}
|
|
122
|
+
<span className="font-medium">Oops!</span> {error.message?.toString()}
|
|
108
123
|
</p>
|
|
109
124
|
)}
|
|
110
125
|
{!error && hint && (
|
|
@@ -117,11 +132,3 @@ export const FormTimePickerWithoutValidation = (props: Props) => {
|
|
|
117
132
|
</>
|
|
118
133
|
);
|
|
119
134
|
};
|
|
120
|
-
|
|
121
|
-
export const FormTimePicker = (props: Props) => {
|
|
122
|
-
const { formValidations } = useAppSelector((state) => state.formValidation);
|
|
123
|
-
const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
|
|
124
|
-
props = { ...props, error };
|
|
125
|
-
|
|
126
|
-
return <FormTimePickerWithoutValidation {...props} />;
|
|
127
|
-
};
|
package/src/Form/YesNo/index.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useAppSelector } from "@zauru-sdk/redux";
|
|
2
1
|
import { useState } from "react";
|
|
2
|
+
import { useFormContext } from "react-hook-form";
|
|
3
3
|
|
|
4
4
|
type Props = {
|
|
5
5
|
id?: string;
|
|
@@ -10,6 +10,7 @@ type Props = {
|
|
|
10
10
|
helpText?: string;
|
|
11
11
|
onChange?: (value: boolean) => void;
|
|
12
12
|
disabled?: boolean;
|
|
13
|
+
required?: boolean;
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
export const YesNo = (props: Props) => {
|
|
@@ -21,17 +22,27 @@ export const YesNo = (props: Props) => {
|
|
|
21
22
|
helpText,
|
|
22
23
|
onChange,
|
|
23
24
|
disabled,
|
|
25
|
+
required,
|
|
24
26
|
} = props;
|
|
25
27
|
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
+
const {
|
|
29
|
+
register: tempRegister,
|
|
30
|
+
formState: { errors },
|
|
31
|
+
} = useFormContext() || { formState: {} }; // Obtener el contexto solo si existe
|
|
32
|
+
const error = errors ? errors[props.name ?? "-1"] : undefined;
|
|
33
|
+
const register = tempRegister
|
|
34
|
+
? tempRegister(props.name ?? "-1", { required })
|
|
35
|
+
: undefined; // Solo usar register si está disponible
|
|
28
36
|
|
|
29
37
|
const [value, setValue] = useState(defaultValue);
|
|
30
38
|
|
|
31
39
|
const color = error ? "red" : "gray";
|
|
32
40
|
|
|
33
|
-
const handleOnChange = () => {
|
|
41
|
+
const handleOnChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
34
42
|
if (disabled) return; // No hacer nada si está deshabilitado
|
|
43
|
+
if (register) {
|
|
44
|
+
register.onChange(e);
|
|
45
|
+
}
|
|
35
46
|
const newValue = !value;
|
|
36
47
|
setValue(newValue);
|
|
37
48
|
onChange && onChange(newValue);
|
|
@@ -47,22 +58,24 @@ export const YesNo = (props: Props) => {
|
|
|
47
58
|
<input
|
|
48
59
|
type="checkbox"
|
|
49
60
|
id={id ?? name}
|
|
50
|
-
name={name}
|
|
51
61
|
checked={value}
|
|
52
62
|
value={value.toString()}
|
|
53
63
|
className="sr-only peer"
|
|
54
|
-
onChange={handleOnChange}
|
|
55
64
|
disabled={disabled}
|
|
65
|
+
{...(register ?? {})}
|
|
66
|
+
name={name}
|
|
67
|
+
onChange={handleOnChange}
|
|
56
68
|
/>
|
|
57
69
|
{value.toString() === "false" && (
|
|
58
70
|
<input type="hidden" name={name} value="false" />
|
|
59
71
|
)}
|
|
60
72
|
<div className="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"></div>
|
|
61
73
|
<span className="ml-3 text-sm font-medium text-gray-900">{title}</span>
|
|
74
|
+
{required && <span className="text-red-500">*</span>}
|
|
62
75
|
</label>
|
|
63
76
|
{error && (
|
|
64
77
|
<p className={`mt-2 text-sm text-${color}-600 dark:text-${color}-500`}>
|
|
65
|
-
<span className="font-medium">Oops!</span> {error}
|
|
78
|
+
<span className="font-medium">Oops!</span> {error.message?.toString()}
|
|
66
79
|
</p>
|
|
67
80
|
)}
|
|
68
81
|
{!error && helpText && (
|
package/src/Form/index.ts
CHANGED
|
@@ -5,10 +5,9 @@ export * from "./DynamicBaculoForm/index.js";
|
|
|
5
5
|
export * from "./FieldContainer/index.js";
|
|
6
6
|
export * from "./FileUpload/index.js";
|
|
7
7
|
export * from "./FormButtons/index.js";
|
|
8
|
-
export * from "./FormLayout/index.js";
|
|
9
8
|
export * from "./SelectField/index.js";
|
|
10
9
|
export * from "./TextArea/index.js";
|
|
11
10
|
export * from "./TextField/index.js";
|
|
12
11
|
export * from "./TimePicker/index.js";
|
|
13
12
|
export * from "./YesNo/index.js";
|
|
14
|
-
export * from "./
|
|
13
|
+
export * from "./ReactZodForm/index.js";
|
|
@@ -1,34 +1,127 @@
|
|
|
1
|
+
import { Form } from "@remix-run/react";
|
|
2
|
+
|
|
1
3
|
type Props = {
|
|
2
4
|
title?: string;
|
|
3
5
|
description?: string;
|
|
6
|
+
loading?: boolean;
|
|
7
|
+
color?: "green" | "blue" | "red" | "purple" | "yellow";
|
|
4
8
|
};
|
|
5
9
|
|
|
6
|
-
export const HomeLayout = ({
|
|
10
|
+
export const HomeLayout = ({
|
|
11
|
+
title,
|
|
12
|
+
description,
|
|
13
|
+
loading,
|
|
14
|
+
color = "green",
|
|
15
|
+
}: Props) => {
|
|
16
|
+
const getColorClasses = (shade: number) => {
|
|
17
|
+
switch (color) {
|
|
18
|
+
case "blue":
|
|
19
|
+
return `bg-blue-${shade}`;
|
|
20
|
+
case "red":
|
|
21
|
+
return `bg-red-${shade}`;
|
|
22
|
+
case "purple":
|
|
23
|
+
return `bg-purple-${shade}`;
|
|
24
|
+
case "yellow":
|
|
25
|
+
return `bg-yellow-${shade}`;
|
|
26
|
+
default:
|
|
27
|
+
return `bg-green-${shade}`;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const getGradientClasses = () => {
|
|
32
|
+
switch (color) {
|
|
33
|
+
case "blue":
|
|
34
|
+
return "from-blue-100 to-blue-200";
|
|
35
|
+
case "red":
|
|
36
|
+
return "from-red-100 to-red-200";
|
|
37
|
+
case "purple":
|
|
38
|
+
return "from-purple-100 to-purple-200";
|
|
39
|
+
case "yellow":
|
|
40
|
+
return "from-yellow-100 to-yellow-200";
|
|
41
|
+
default:
|
|
42
|
+
return "from-green-100 to-green-200";
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const getButtonClasses = () => {
|
|
47
|
+
switch (color) {
|
|
48
|
+
case "blue":
|
|
49
|
+
return "bg-blue-600 hover:bg-blue-700 focus:ring-blue-500";
|
|
50
|
+
case "red":
|
|
51
|
+
return "bg-red-600 hover:bg-red-700 focus:ring-red-500";
|
|
52
|
+
case "purple":
|
|
53
|
+
return "bg-purple-600 hover:bg-purple-700 focus:ring-purple-500";
|
|
54
|
+
case "yellow":
|
|
55
|
+
return "bg-yellow-600 hover:bg-yellow-700 focus:ring-yellow-500";
|
|
56
|
+
default:
|
|
57
|
+
return "bg-green-600 hover:bg-green-700 focus:ring-green-500";
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
7
61
|
return (
|
|
8
62
|
<div
|
|
9
|
-
className=
|
|
10
|
-
style={{ backgroundImage: 'url("/wallpaper.webp")' }}
|
|
63
|
+
className={`min-h-screen bg-gradient-to-br ${getGradientClasses()} flex flex-col justify-center py-12 sm:px-6 lg:px-8 relative overflow-hidden`}
|
|
11
64
|
>
|
|
12
|
-
<div
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
65
|
+
<div
|
|
66
|
+
className={`absolute top-0 left-0 w-64 h-64 ${getColorClasses(
|
|
67
|
+
500
|
|
68
|
+
)} rounded-full -translate-x-1/2 -translate-y-1/2 opacity-50`}
|
|
69
|
+
></div>
|
|
70
|
+
<div
|
|
71
|
+
className={`absolute bottom-0 right-0 w-96 h-96 ${getColorClasses(
|
|
72
|
+
600
|
|
73
|
+
)} rounded-full translate-x-1/3 translate-y-1/3 opacity-40`}
|
|
74
|
+
></div>
|
|
75
|
+
<div
|
|
76
|
+
className={`absolute top-1/2 left-1/4 w-48 h-48 ${getColorClasses(
|
|
77
|
+
400
|
|
78
|
+
)} rounded-full opacity-30`}
|
|
79
|
+
></div>
|
|
80
|
+
|
|
81
|
+
<div
|
|
82
|
+
className={`absolute top-1/3 right-1/4 w-32 h-32 ${getColorClasses(
|
|
83
|
+
500
|
|
84
|
+
)} rounded-full opacity-25`}
|
|
85
|
+
></div>
|
|
86
|
+
<div
|
|
87
|
+
className={`absolute bottom-1/4 left-1/3 w-40 h-40 ${getColorClasses(
|
|
88
|
+
400
|
|
89
|
+
)} rounded-full opacity-20`}
|
|
90
|
+
></div>
|
|
91
|
+
<div
|
|
92
|
+
className={`absolute top-3/4 right-1/2 w-24 h-24 ${getColorClasses(
|
|
93
|
+
600
|
|
94
|
+
)} rounded-full opacity-15`}
|
|
95
|
+
></div>
|
|
96
|
+
|
|
97
|
+
<div className="sm:mx-auto sm:w-full sm:max-w-md relative z-10">
|
|
98
|
+
<img className="mx-auto h-12 w-auto" src="/logo.png" alt="Zauru Logo" />
|
|
99
|
+
<h2 className="mt-6 text-center text-3xl font-extrabold text-gray-900">
|
|
100
|
+
{title ?? "Bienvenido"}
|
|
101
|
+
</h2>
|
|
102
|
+
<p className="mt-2 text-center text-sm text-gray-600">
|
|
103
|
+
{description ?? "Inicie sesión para acceder a su cuenta"}
|
|
30
104
|
</p>
|
|
31
105
|
</div>
|
|
106
|
+
|
|
107
|
+
{loading ? (
|
|
108
|
+
<></>
|
|
109
|
+
) : (
|
|
110
|
+
<div className="mt-8 sm:mx-auto sm:w-full sm:max-w-md relative z-10">
|
|
111
|
+
<div className="bg-white bg-opacity-90 py-8 px-4 shadow-lg sm:rounded-lg sm:px-10">
|
|
112
|
+
<Form className="space-y-6" method="post" action="/login">
|
|
113
|
+
<div>
|
|
114
|
+
<button
|
|
115
|
+
type="submit"
|
|
116
|
+
className={`w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white ${getButtonClasses()} transition duration-150 ease-in-out`}
|
|
117
|
+
>
|
|
118
|
+
Inicie sesión con Zauru
|
|
119
|
+
</button>
|
|
120
|
+
</div>
|
|
121
|
+
</Form>
|
|
122
|
+
</div>
|
|
123
|
+
</div>
|
|
124
|
+
)}
|
|
32
125
|
</div>
|
|
33
126
|
);
|
|
34
127
|
};
|
package/src/Modal/Modal.tsx
CHANGED
|
@@ -5,7 +5,7 @@ export type ModalOption = "OK" | "CANCEL" | null;
|
|
|
5
5
|
|
|
6
6
|
type ModalParams = {
|
|
7
7
|
title: string;
|
|
8
|
-
description: React.ReactNode
|
|
8
|
+
description: React.ReactNode;
|
|
9
9
|
okButtonText?: string;
|
|
10
10
|
showOptions?: boolean;
|
|
11
11
|
};
|
|
@@ -64,9 +64,6 @@ export const createModal = ({
|
|
|
64
64
|
document.body.appendChild(modalOverlay);
|
|
65
65
|
document.body.appendChild(modalWrapper);
|
|
66
66
|
|
|
67
|
-
const content =
|
|
68
|
-
typeof description === "function" ? description() : description;
|
|
69
|
-
|
|
70
67
|
const ModalContent = () => (
|
|
71
68
|
<div className="relative w-auto my-6 mx-auto max-w-3xl">
|
|
72
69
|
<div className="border-0 rounded-lg shadow-lg relative flex flex-col w-full bg-white outline-none focus:outline-none">
|
|
@@ -78,7 +75,7 @@ export const createModal = ({
|
|
|
78
75
|
</span>
|
|
79
76
|
</button>
|
|
80
77
|
</div>
|
|
81
|
-
<div className="relative p-6 flex-auto">{
|
|
78
|
+
<div className="relative p-6 flex-auto">{description}</div>
|
|
82
79
|
{showOptions && (
|
|
83
80
|
<div className="flex items-center justify-end p-6 border-t border-solid border-slate-200 rounded-b">
|
|
84
81
|
<button
|
package/src/NavBar/NavBar.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
ColorInterface,
|
|
11
11
|
DropDownLinkButtonType,
|
|
12
12
|
EntityProps,
|
|
13
|
+
NavBarItemsSchema,
|
|
13
14
|
NavBarProps,
|
|
14
15
|
NavItemProps,
|
|
15
16
|
} from "./NavBar.types.js";
|
|
@@ -88,7 +89,7 @@ const NavItem = ({
|
|
|
88
89
|
<div
|
|
89
90
|
className={`${
|
|
90
91
|
specialColor ? specialColor.bg700 : color.bg700
|
|
91
|
-
} container text-white w-
|
|
92
|
+
} container text-white w-full sm:w-auto h-10 text-sm py-1 uppercase shadow hover:shadow-lg outline-none rounded-full focus:outline-none my-auto sm:my-0 sm:mr-1 mb-1 ease-linear transition-all duration-150 `}
|
|
92
93
|
>
|
|
93
94
|
<Link
|
|
94
95
|
className="px-3 flex items-center text-xs leading-snug text-white uppercase hover:opacity-75"
|
|
@@ -114,36 +115,36 @@ export const NavBar = ({
|
|
|
114
115
|
const color: ColorInterface = COLORS[selectedColor];
|
|
115
116
|
const [NavBarOpen, setNavBarOpen] = useState(false);
|
|
116
117
|
|
|
118
|
+
const renderNavItems = (items: NavBarItemsSchema[]) => (
|
|
119
|
+
<div className="flex flex-col lg:flex-row w-full">
|
|
120
|
+
{items.map((item, index) => {
|
|
121
|
+
const specialColor: ColorInterface | undefined = item.color
|
|
122
|
+
? COLORS[item.color]
|
|
123
|
+
: undefined;
|
|
124
|
+
return (
|
|
125
|
+
<NavItem
|
|
126
|
+
key={index}
|
|
127
|
+
name={item.name}
|
|
128
|
+
link={item.link}
|
|
129
|
+
icon={item.icon}
|
|
130
|
+
specialColor={specialColor}
|
|
131
|
+
color={color}
|
|
132
|
+
childrens={item.childrens?.map((x) => {
|
|
133
|
+
return { ...x } as any;
|
|
134
|
+
})}
|
|
135
|
+
/>
|
|
136
|
+
);
|
|
137
|
+
})}
|
|
138
|
+
</div>
|
|
139
|
+
);
|
|
140
|
+
|
|
117
141
|
const options = (
|
|
118
142
|
<>
|
|
119
|
-
<ul>
|
|
120
|
-
{loggedIn
|
|
121
|
-
<div className="flex flex-col sm:flex-row ">
|
|
122
|
-
{items
|
|
123
|
-
.filter((item) => item.loggedIn)
|
|
124
|
-
.map((item, index) => {
|
|
125
|
-
const specialColor: ColorInterface | undefined = item.color
|
|
126
|
-
? COLORS[item.color]
|
|
127
|
-
: undefined;
|
|
128
|
-
return (
|
|
129
|
-
<NavItem
|
|
130
|
-
key={index}
|
|
131
|
-
name={item.name}
|
|
132
|
-
link={item.link}
|
|
133
|
-
icon={item.icon}
|
|
134
|
-
specialColor={specialColor}
|
|
135
|
-
color={color}
|
|
136
|
-
childrens={item.childrens?.map((x) => {
|
|
137
|
-
return { ...x } as any;
|
|
138
|
-
})}
|
|
139
|
-
/>
|
|
140
|
-
);
|
|
141
|
-
})}
|
|
142
|
-
</div>
|
|
143
|
-
)}
|
|
143
|
+
<ul className="w-full lg:flex lg:items-center">
|
|
144
|
+
{renderNavItems(items.filter((item) => item.loggedIn === loggedIn))}
|
|
144
145
|
</ul>
|
|
145
|
-
<ul className="sm:flex sm:flex-col
|
|
146
|
-
{loggedIn
|
|
146
|
+
<ul className="sm:flex sm:flex-col lg:flex-row ml-auto">
|
|
147
|
+
{loggedIn && (
|
|
147
148
|
<OptionsDropDownButton
|
|
148
149
|
color={color}
|
|
149
150
|
options={[
|
|
@@ -156,20 +157,6 @@ export const NavBar = ({
|
|
|
156
157
|
/>,
|
|
157
158
|
]}
|
|
158
159
|
/>
|
|
159
|
-
) : (
|
|
160
|
-
items
|
|
161
|
-
.filter((item) => !item.loggedIn)
|
|
162
|
-
.map((item, index) => {
|
|
163
|
-
return (
|
|
164
|
-
<NavItem
|
|
165
|
-
key={index}
|
|
166
|
-
name={item.name}
|
|
167
|
-
link={item.link}
|
|
168
|
-
icon={item.icon}
|
|
169
|
-
color={color}
|
|
170
|
-
/>
|
|
171
|
-
);
|
|
172
|
-
})
|
|
173
160
|
)}
|
|
174
161
|
</ul>
|
|
175
162
|
</>
|
|
@@ -207,16 +194,18 @@ export const NavBar = ({
|
|
|
207
194
|
</div>
|
|
208
195
|
{/* Menú para dispositivos móviles */}
|
|
209
196
|
<div
|
|
210
|
-
className={`lg:hidden
|
|
197
|
+
className={`lg:hidden fixed top-0 left-0 z-50 w-64 h-full ${
|
|
211
198
|
color.bg700
|
|
212
199
|
} shadow-lg transform ${
|
|
213
200
|
NavBarOpen ? "translate-x-0" : "-translate-x-full"
|
|
214
|
-
} transition-transform duration-300 ease-in-out`}
|
|
201
|
+
} transition-transform duration-300 ease-in-out overflow-y-auto`}
|
|
215
202
|
>
|
|
216
|
-
{options}
|
|
203
|
+
<div className="p-4">{options}</div>
|
|
217
204
|
</div>
|
|
218
205
|
{/* Menú para escritorio */}
|
|
219
|
-
<div className="hidden lg:flex w-full lg:w-auto">
|
|
206
|
+
<div className="hidden lg:flex lg:items-center w-full lg:w-auto">
|
|
207
|
+
{options}
|
|
208
|
+
</div>
|
|
220
209
|
</div>
|
|
221
210
|
</nav>
|
|
222
211
|
);
|
package/src/Table/ZauruTable.tsx
CHANGED
|
@@ -16,10 +16,17 @@ const customStyles: TableStyles = {
|
|
|
16
16
|
style: {
|
|
17
17
|
color: "#202124",
|
|
18
18
|
fontSize: "14px",
|
|
19
|
-
justifyContent: "left",
|
|
20
|
-
whiteSpace: "normal",
|
|
21
|
-
wordBreak: "break-word",
|
|
22
|
-
maxWidth: "
|
|
19
|
+
justifyContent: "left",
|
|
20
|
+
whiteSpace: "normal",
|
|
21
|
+
wordBreak: "break-word",
|
|
22
|
+
maxWidth: "250px",
|
|
23
|
+
padding: "4px", // Add some padding
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
cells: {
|
|
27
|
+
style: {
|
|
28
|
+
whiteSpace: "normal", // Allow wrapping for cell content
|
|
29
|
+
wordBreak: "break-word",
|
|
23
30
|
},
|
|
24
31
|
},
|
|
25
32
|
rows: {
|
|
@@ -9,13 +9,14 @@ export const WithTooltip = (props: Props) => {
|
|
|
9
9
|
const { children, text } = props;
|
|
10
10
|
|
|
11
11
|
return (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
<
|
|
12
|
+
<div className="group relative inline-block">
|
|
13
|
+
{children}
|
|
14
|
+
<div className="pointer-events-none absolute left-1/2 -translate-x-1/2 bottom-full mb-2 opacity-0 transition-opacity duration-300 group-hover:opacity-100">
|
|
15
|
+
<div className="relative bg-black text-white text-sm rounded py-1 px-2 text-wrap w-40">
|
|
16
16
|
{text}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
<div className="absolute top-full left-1/2 -translate-x-1/2 border-4 border-transparent border-t-black"></div>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
20
21
|
);
|
|
21
22
|
};
|