@zauru-sdk/components 1.0.104 → 1.0.106
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/Buttons/Button.d.ts +1 -0
- package/dist/Footer/Footer.d.ts +2 -1
- package/dist/cjs/Buttons/Button.js +10 -6
- package/dist/cjs/Footer/Footer.js +2 -2
- package/dist/cjs/Form/SelectField/index.js +7 -2
- package/dist/cjs/Form/TextField/index.js +3 -3
- package/dist/esm/Buttons/Button.js +10 -6
- package/dist/esm/Footer/Footer.js +2 -2
- package/dist/esm/Form/SelectField/index.js +7 -2
- package/dist/esm/Form/TextField/index.js +3 -3
- package/package.json +5 -5
- package/src/Buttons/Button.tsx +21 -10
- package/src/Footer/Footer.tsx +3 -1
- package/src/Form/SelectField/index.tsx +6 -1
- package/src/Form/TextField/index.tsx +16 -15
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.0.106](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.105...v1.0.106) (2024-09-18)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @zauru-sdk/components
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [1.0.105](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.104...v1.0.105) (2024-09-18)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @zauru-sdk/components
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [1.0.104](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.103...v1.0.104) (2024-09-17)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @zauru-sdk/components
|
package/dist/Buttons/Button.d.ts
CHANGED
package/dist/Footer/Footer.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ type FooterProps = {
|
|
|
2
2
|
href: string;
|
|
3
3
|
showConnection?: boolean;
|
|
4
4
|
selectedColor: "purple" | "pink" | "indigo" | "cyan" | "slate" | "green" | "red" | "sky";
|
|
5
|
+
version?: string;
|
|
5
6
|
};
|
|
6
|
-
export declare const Footer: ({ href, selectedColor, showConnection, }: FooterProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare const Footer: ({ href, selectedColor, showConnection, version, }: FooterProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
8
|
export {};
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Button = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const WithTooltip_js_1 = require("../WithTooltip/WithTooltip.js");
|
|
5
6
|
const react_hook_form_1 = require("react-hook-form");
|
|
6
|
-
const index_js_1 = require("../index.js");
|
|
7
7
|
const Button = (props) => {
|
|
8
|
-
const { type = "submit", loading = false, loadingText = "Guardando...", title = "Guardar", name = "save", onClickSave, selectedColor = "indigo", children, className = "", disabled = false, } = props;
|
|
8
|
+
const { type = "submit", loading = false, loadingText = "Guardando...", title = "Guardar", name = "save", onClickSave, selectedColor = "indigo", children, className = "", disabled = false, enableFormErrorsValidation = true, } = props;
|
|
9
9
|
const formContext = (0, react_hook_form_1.useFormContext)();
|
|
10
10
|
const formHasErrors = formContext ? !formContext.formState.isValid : false;
|
|
11
11
|
const formErrors = formContext ? formContext.formState.errors : {};
|
|
@@ -45,14 +45,18 @@ const Button = (props) => {
|
|
|
45
45
|
};
|
|
46
46
|
const color = COLORS[selectedColor];
|
|
47
47
|
const inside = children ?? title;
|
|
48
|
-
const errorMessage = formHasErrors
|
|
48
|
+
const errorMessage = enableFormErrorsValidation && formHasErrors
|
|
49
49
|
? Object.values(formErrors)
|
|
50
50
|
.map((error) => error?.message?.toString())
|
|
51
51
|
.join(", ")
|
|
52
52
|
: "";
|
|
53
|
-
const buttonContent = ((0, jsx_runtime_1.jsx)("button", { type: type, name: "action", disabled: loading || disabled || formHasErrors, value: name, onClick: onClickSave, className: `ml-2 ${loading || disabled ||
|
|
53
|
+
const buttonContent = ((0, jsx_runtime_1.jsx)("button", { type: type, name: "action", disabled: loading || disabled || (enableFormErrorsValidation && formHasErrors), value: name, onClick: onClickSave, className: `ml-2 ${loading || disabled || (enableFormErrorsValidation && formHasErrors)
|
|
54
|
+
? " bg-opacity-25 "
|
|
55
|
+
: ""} ${loading
|
|
54
56
|
? " cursor-progress"
|
|
55
|
-
: `${disabled ||
|
|
56
|
-
|
|
57
|
+
: `${disabled || (enableFormErrorsValidation && formHasErrors)
|
|
58
|
+
? ""
|
|
59
|
+
: `hover:${color.bg700}`}`} inline-flex justify-center rounded-md border border-transparent ${color.bg600} py-2 px-4 text-sm font-medium text-white shadow-sm focus:outline-none focus:ring-2 focus:${color.ring500} focus:ring-offset-2 ${className}`, children: loading ? loadingText : inside }));
|
|
60
|
+
return enableFormErrorsValidation && formHasErrors ? ((0, jsx_runtime_1.jsx)(WithTooltip_js_1.WithTooltip, { text: errorMessage, children: buttonContent })) : (buttonContent);
|
|
57
61
|
};
|
|
58
62
|
exports.Button = Button;
|
|
@@ -13,8 +13,8 @@ const COLORS = {
|
|
|
13
13
|
red: "bg-red-500",
|
|
14
14
|
sky: "bg-sky-500",
|
|
15
15
|
};
|
|
16
|
-
const Footer = ({ href, selectedColor, showConnection = false, }) => {
|
|
16
|
+
const Footer = ({ href, selectedColor, showConnection = false, version = "2.0.5", }) => {
|
|
17
17
|
const color = COLORS[selectedColor];
|
|
18
|
-
return ((0, jsx_runtime_1.jsx)("footer", { className: `inset-x-0 bottom-0 px-2 py-[20px] ${color}`, children: (0, jsx_runtime_1.jsxs)("div", { className: "px-4 mx-auto flex flex-wrap items-center justify-center", children: [(0, jsx_runtime_1.jsxs)("p", { className: "text-white text-[1.2rem]", children: [`Creado en `, " ", (0, jsx_runtime_1.jsx)("a", { href: href, children: "Zauru" }), " ", `con ❤️ ${new Date().getFullYear()} v
|
|
18
|
+
return ((0, jsx_runtime_1.jsx)("footer", { className: `inset-x-0 bottom-0 px-2 py-[20px] ${color}`, children: (0, jsx_runtime_1.jsxs)("div", { className: "px-4 mx-auto flex flex-wrap items-center justify-center", children: [(0, jsx_runtime_1.jsxs)("p", { className: "text-white text-[1.2rem]", children: [`Creado en `, " ", (0, jsx_runtime_1.jsx)("a", { href: href, children: "Zauru" }), " ", `con ❤️ ${new Date().getFullYear()} v.${version}`] }), showConnection && ((0, jsx_runtime_1.jsx)("div", { className: "ml-5", children: (0, jsx_runtime_1.jsx)(index_js_1.ConnectionState, {}) }))] }) }));
|
|
19
19
|
};
|
|
20
20
|
exports.Footer = Footer;
|
|
@@ -90,7 +90,12 @@ const SelectField = (props) => {
|
|
|
90
90
|
filteredOptions.length > 0 &&
|
|
91
91
|
!isEnterPressed &&
|
|
92
92
|
isSearching) {
|
|
93
|
-
|
|
93
|
+
if (highlightedIndex >= 0) {
|
|
94
|
+
handleOptionClick(filteredOptions[highlightedIndex]);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
handleOptionClick(filteredOptions[0]);
|
|
98
|
+
}
|
|
94
99
|
}
|
|
95
100
|
setIsTabPressed(false);
|
|
96
101
|
setIsEnterPressed(false);
|
|
@@ -133,7 +138,7 @@ const SelectField = (props) => {
|
|
|
133
138
|
}
|
|
134
139
|
return ((0, jsx_runtime_1.jsxs)("div", { className: `col-span-6 sm:col-span-3 ${className}`, ref: selectRef, children: [title && ((0, jsx_runtime_1.jsxs)("label", { htmlFor: error ? `${name}-error` : `${name}-success`, className: `block text-sm font-medium ${color === "red"
|
|
135
140
|
? "text-red-700 dark:text-red-500"
|
|
136
|
-
: "text-gray-700 dark:text-gray-500"}`, children: [title, required && (0, jsx_runtime_1.jsx)("span", { className: "text-red-500", children: "*" })] })), (0, jsx_runtime_1.jsxs)("div", { className: "relative", children: [(0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { name: name || "", control: control, rules: { required }, defaultValue: defaultValue || (isMulti ? [] : null), render: ({ field }) => ((0, jsx_runtime_1.jsx)("input", { ...field, type: "text", id: id, value: inputValue, onFocus: () => setIsOpen(true), onBlur: handleBlur, onKeyDown: handleKeyDown, readOnly: isReadOnly, disabled: disabled, className: `block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm`, placeholder: isMulti ? "Select options..." : "Select an option...", onChange: (e) => {
|
|
141
|
+
: "text-gray-700 dark:text-gray-500"}`, children: [title, required && (0, jsx_runtime_1.jsx)("span", { className: "text-red-500", children: "*" })] })), (0, jsx_runtime_1.jsxs)("div", { className: "relative", children: [(0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { name: name || "", control: control, rules: { required }, defaultValue: defaultValue || (isMulti ? [] : null), render: ({ field }) => ((0, jsx_runtime_1.jsx)("input", { ...field, type: "text", id: id, autoComplete: "off", value: inputValue, onFocus: () => setIsOpen(true), onBlur: handleBlur, onKeyDown: handleKeyDown, readOnly: isReadOnly, disabled: disabled, className: `block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm`, placeholder: isMulti ? "Select options..." : "Select an option...", onChange: (e) => {
|
|
137
142
|
field.onChange(e);
|
|
138
143
|
handleInputChange(e);
|
|
139
144
|
} })) }), isClearable && (value || valueMulti.length > 0) && ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: handleClear, className: "absolute inset-y-0 right-0 pr-3 flex items-center", children: "\u00D7" })), isOpen && !isReadOnly && ((0, jsx_runtime_1.jsx)("ul", { ref: optionsRef, className: "absolute z-10 mt-1 w-full bg-white shadow-lg max-h-60 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm", children: filteredOptions.map((option, index) => ((0, jsx_runtime_1.jsx)("li", { className: `cursor-pointer select-none relative py-2 pl-3 pr-9 ${(isMulti
|
|
@@ -25,9 +25,6 @@ const TextField = (props) => {
|
|
|
25
25
|
(0, react_1.useEffect)(() => {
|
|
26
26
|
setValue(defaultValue);
|
|
27
27
|
}, [defaultValue]);
|
|
28
|
-
if (hidden) {
|
|
29
|
-
return ((0, jsx_runtime_1.jsx)("input", { type: type, id: id ?? name, value: defaultValue, readOnly: true, hidden: true, ...(register ?? {}), name: name }));
|
|
30
|
-
}
|
|
31
28
|
const handleInputChange = (event) => {
|
|
32
29
|
if (register) {
|
|
33
30
|
register.onChange(event);
|
|
@@ -65,6 +62,9 @@ const TextField = (props) => {
|
|
|
65
62
|
}
|
|
66
63
|
}
|
|
67
64
|
};
|
|
65
|
+
if (hidden) {
|
|
66
|
+
return ((0, jsx_runtime_1.jsx)("input", { type: "hidden", id: id ?? name, value: value, readOnly: true, hidden: true, ...(register ?? {}), name: name, onChange: handleInputChange }));
|
|
67
|
+
}
|
|
68
68
|
const inputComponent = ((0, jsx_runtime_1.jsx)("input", { type: type, readOnly: readOnly, disabled: disabled, id: id ?? name, autoComplete: "given-name", value: value, onWheel: (e) => {
|
|
69
69
|
e.currentTarget.blur();
|
|
70
70
|
}, step: type === "number" ? 0.01 : undefined, onKeyDown: (event) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { WithTooltip } from "../WithTooltip/WithTooltip.js";
|
|
2
3
|
import { useFormContext } from "react-hook-form";
|
|
3
|
-
import { WithTooltip } from "../index.js";
|
|
4
4
|
export const Button = (props) => {
|
|
5
|
-
const { type = "submit", loading = false, loadingText = "Guardando...", title = "Guardar", name = "save", onClickSave, selectedColor = "indigo", children, className = "", disabled = false, } = props;
|
|
5
|
+
const { type = "submit", loading = false, loadingText = "Guardando...", title = "Guardar", name = "save", onClickSave, selectedColor = "indigo", children, className = "", disabled = false, enableFormErrorsValidation = true, } = props;
|
|
6
6
|
const formContext = useFormContext();
|
|
7
7
|
const formHasErrors = formContext ? !formContext.formState.isValid : false;
|
|
8
8
|
const formErrors = formContext ? formContext.formState.errors : {};
|
|
@@ -42,13 +42,17 @@ export const Button = (props) => {
|
|
|
42
42
|
};
|
|
43
43
|
const color = COLORS[selectedColor];
|
|
44
44
|
const inside = children ?? title;
|
|
45
|
-
const errorMessage = formHasErrors
|
|
45
|
+
const errorMessage = enableFormErrorsValidation && formHasErrors
|
|
46
46
|
? Object.values(formErrors)
|
|
47
47
|
.map((error) => error?.message?.toString())
|
|
48
48
|
.join(", ")
|
|
49
49
|
: "";
|
|
50
|
-
const buttonContent = (_jsx("button", { type: type, name: "action", disabled: loading || disabled || formHasErrors, value: name, onClick: onClickSave, className: `ml-2 ${loading || disabled ||
|
|
50
|
+
const buttonContent = (_jsx("button", { type: type, name: "action", disabled: loading || disabled || (enableFormErrorsValidation && formHasErrors), value: name, onClick: onClickSave, className: `ml-2 ${loading || disabled || (enableFormErrorsValidation && formHasErrors)
|
|
51
|
+
? " bg-opacity-25 "
|
|
52
|
+
: ""} ${loading
|
|
51
53
|
? " cursor-progress"
|
|
52
|
-
: `${disabled ||
|
|
53
|
-
|
|
54
|
+
: `${disabled || (enableFormErrorsValidation && formHasErrors)
|
|
55
|
+
? ""
|
|
56
|
+
: `hover:${color.bg700}`}`} inline-flex justify-center rounded-md border border-transparent ${color.bg600} py-2 px-4 text-sm font-medium text-white shadow-sm focus:outline-none focus:ring-2 focus:${color.ring500} focus:ring-offset-2 ${className}`, children: loading ? loadingText : inside }));
|
|
57
|
+
return enableFormErrorsValidation && formHasErrors ? (_jsx(WithTooltip, { text: errorMessage, children: buttonContent })) : (buttonContent);
|
|
54
58
|
};
|
|
@@ -10,7 +10,7 @@ const COLORS = {
|
|
|
10
10
|
red: "bg-red-500",
|
|
11
11
|
sky: "bg-sky-500",
|
|
12
12
|
};
|
|
13
|
-
export const Footer = ({ href, selectedColor, showConnection = false, }) => {
|
|
13
|
+
export const Footer = ({ href, selectedColor, showConnection = false, version = "2.0.5", }) => {
|
|
14
14
|
const color = COLORS[selectedColor];
|
|
15
|
-
return (_jsx("footer", { className: `inset-x-0 bottom-0 px-2 py-[20px] ${color}`, children: _jsxs("div", { className: "px-4 mx-auto flex flex-wrap items-center justify-center", children: [_jsxs("p", { className: "text-white text-[1.2rem]", children: [`Creado en `, " ", _jsx("a", { href: href, children: "Zauru" }), " ", `con ❤️ ${new Date().getFullYear()} v
|
|
15
|
+
return (_jsx("footer", { className: `inset-x-0 bottom-0 px-2 py-[20px] ${color}`, children: _jsxs("div", { className: "px-4 mx-auto flex flex-wrap items-center justify-center", children: [_jsxs("p", { className: "text-white text-[1.2rem]", children: [`Creado en `, " ", _jsx("a", { href: href, children: "Zauru" }), " ", `con ❤️ ${new Date().getFullYear()} v.${version}`] }), showConnection && (_jsx("div", { className: "ml-5", children: _jsx(ConnectionState, {}) }))] }) }));
|
|
16
16
|
};
|
|
@@ -87,7 +87,12 @@ export const SelectField = (props) => {
|
|
|
87
87
|
filteredOptions.length > 0 &&
|
|
88
88
|
!isEnterPressed &&
|
|
89
89
|
isSearching) {
|
|
90
|
-
|
|
90
|
+
if (highlightedIndex >= 0) {
|
|
91
|
+
handleOptionClick(filteredOptions[highlightedIndex]);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
handleOptionClick(filteredOptions[0]);
|
|
95
|
+
}
|
|
91
96
|
}
|
|
92
97
|
setIsTabPressed(false);
|
|
93
98
|
setIsEnterPressed(false);
|
|
@@ -130,7 +135,7 @@ export const SelectField = (props) => {
|
|
|
130
135
|
}
|
|
131
136
|
return (_jsxs("div", { className: `col-span-6 sm:col-span-3 ${className}`, ref: selectRef, children: [title && (_jsxs("label", { htmlFor: error ? `${name}-error` : `${name}-success`, className: `block text-sm font-medium ${color === "red"
|
|
132
137
|
? "text-red-700 dark:text-red-500"
|
|
133
|
-
: "text-gray-700 dark:text-gray-500"}`, children: [title, required && _jsx("span", { className: "text-red-500", children: "*" })] })), _jsxs("div", { className: "relative", children: [_jsx(Controller, { name: name || "", control: control, rules: { required }, defaultValue: defaultValue || (isMulti ? [] : null), render: ({ field }) => (_jsx("input", { ...field, type: "text", id: id, value: inputValue, onFocus: () => setIsOpen(true), onBlur: handleBlur, onKeyDown: handleKeyDown, readOnly: isReadOnly, disabled: disabled, className: `block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm`, placeholder: isMulti ? "Select options..." : "Select an option...", onChange: (e) => {
|
|
138
|
+
: "text-gray-700 dark:text-gray-500"}`, children: [title, required && _jsx("span", { className: "text-red-500", children: "*" })] })), _jsxs("div", { className: "relative", children: [_jsx(Controller, { name: name || "", control: control, rules: { required }, defaultValue: defaultValue || (isMulti ? [] : null), render: ({ field }) => (_jsx("input", { ...field, type: "text", id: id, autoComplete: "off", value: inputValue, onFocus: () => setIsOpen(true), onBlur: handleBlur, onKeyDown: handleKeyDown, readOnly: isReadOnly, disabled: disabled, className: `block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm`, placeholder: isMulti ? "Select options..." : "Select an option...", onChange: (e) => {
|
|
134
139
|
field.onChange(e);
|
|
135
140
|
handleInputChange(e);
|
|
136
141
|
} })) }), isClearable && (value || valueMulti.length > 0) && (_jsx("button", { type: "button", onClick: handleClear, className: "absolute inset-y-0 right-0 pr-3 flex items-center", children: "\u00D7" })), isOpen && !isReadOnly && (_jsx("ul", { ref: optionsRef, className: "absolute z-10 mt-1 w-full bg-white shadow-lg max-h-60 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm", children: filteredOptions.map((option, index) => (_jsx("li", { className: `cursor-pointer select-none relative py-2 pl-3 pr-9 ${(isMulti
|
|
@@ -22,9 +22,6 @@ export const TextField = (props) => {
|
|
|
22
22
|
useEffect(() => {
|
|
23
23
|
setValue(defaultValue);
|
|
24
24
|
}, [defaultValue]);
|
|
25
|
-
if (hidden) {
|
|
26
|
-
return (_jsx("input", { type: type, id: id ?? name, value: defaultValue, readOnly: true, hidden: true, ...(register ?? {}), name: name }));
|
|
27
|
-
}
|
|
28
25
|
const handleInputChange = (event) => {
|
|
29
26
|
if (register) {
|
|
30
27
|
register.onChange(event);
|
|
@@ -62,6 +59,9 @@ export const TextField = (props) => {
|
|
|
62
59
|
}
|
|
63
60
|
}
|
|
64
61
|
};
|
|
62
|
+
if (hidden) {
|
|
63
|
+
return (_jsx("input", { type: "hidden", id: id ?? name, value: value, readOnly: true, hidden: true, ...(register ?? {}), name: name, onChange: handleInputChange }));
|
|
64
|
+
}
|
|
65
65
|
const inputComponent = (_jsx("input", { type: type, readOnly: readOnly, disabled: disabled, id: id ?? name, autoComplete: "given-name", value: value, onWheel: (e) => {
|
|
66
66
|
e.currentTarget.blur();
|
|
67
67
|
}, step: type === "number" ? 0.01 : undefined, onKeyDown: (event) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.106",
|
|
4
4
|
"description": "Componentes reutilizables en las WebApps de Zauru.",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"@hookform/resolvers": "^3.9.0",
|
|
35
35
|
"@reduxjs/toolkit": "^2.2.1",
|
|
36
36
|
"@remix-run/react": "^2.8.1",
|
|
37
|
-
"@zauru-sdk/common": "^1.0.
|
|
38
|
-
"@zauru-sdk/hooks": "^1.0.
|
|
37
|
+
"@zauru-sdk/common": "^1.0.105",
|
|
38
|
+
"@zauru-sdk/hooks": "^1.0.106",
|
|
39
39
|
"@zauru-sdk/icons": "^1.0.60",
|
|
40
40
|
"@zauru-sdk/types": "^1.0.98",
|
|
41
|
-
"@zauru-sdk/utils": "^1.0.
|
|
41
|
+
"@zauru-sdk/utils": "^1.0.105",
|
|
42
42
|
"framer-motion": "^11.0.8",
|
|
43
43
|
"jsonwebtoken": "^9.0.2",
|
|
44
44
|
"react": "^18.2.0",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"styled-components": "^5.3.5",
|
|
51
51
|
"zod": "^3.23.8"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "664e7ee59830cf458ea3e47b597a89867b65b66b"
|
|
54
54
|
}
|
package/src/Buttons/Button.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { WithTooltip } from "../WithTooltip/WithTooltip.js";
|
|
1
2
|
import type { ColorInterface } from "../NavBar/NavBar.types.js";
|
|
2
3
|
import { useFormContext } from "react-hook-form";
|
|
3
|
-
import { WithTooltip } from "../index.js";
|
|
4
4
|
|
|
5
5
|
type Props = {
|
|
6
6
|
type?: "reset" | "button" | "submit" | undefined;
|
|
@@ -14,6 +14,7 @@ type Props = {
|
|
|
14
14
|
children?: React.ReactNode;
|
|
15
15
|
className?: string;
|
|
16
16
|
disabled?: boolean;
|
|
17
|
+
enableFormErrorsValidation?: boolean;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
export const Button = (props: Props) => {
|
|
@@ -28,6 +29,7 @@ export const Button = (props: Props) => {
|
|
|
28
29
|
children,
|
|
29
30
|
className = "",
|
|
30
31
|
disabled = false,
|
|
32
|
+
enableFormErrorsValidation = true,
|
|
31
33
|
} = props;
|
|
32
34
|
|
|
33
35
|
const formContext = useFormContext();
|
|
@@ -73,25 +75,34 @@ export const Button = (props: Props) => {
|
|
|
73
75
|
|
|
74
76
|
const inside = children ?? title;
|
|
75
77
|
|
|
76
|
-
const errorMessage =
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
const errorMessage =
|
|
79
|
+
enableFormErrorsValidation && formHasErrors
|
|
80
|
+
? Object.values(formErrors)
|
|
81
|
+
.map((error) => error?.message?.toString())
|
|
82
|
+
.join(", ")
|
|
83
|
+
: "";
|
|
81
84
|
|
|
82
85
|
const buttonContent = (
|
|
83
86
|
<button
|
|
84
87
|
type={type}
|
|
85
88
|
name="action"
|
|
86
|
-
disabled={
|
|
89
|
+
disabled={
|
|
90
|
+
loading || disabled || (enableFormErrorsValidation && formHasErrors)
|
|
91
|
+
}
|
|
87
92
|
value={name}
|
|
88
93
|
onClick={onClickSave}
|
|
89
94
|
className={`ml-2 ${
|
|
90
|
-
loading || disabled ||
|
|
95
|
+
loading || disabled || (enableFormErrorsValidation && formHasErrors)
|
|
96
|
+
? " bg-opacity-25 "
|
|
97
|
+
: ""
|
|
91
98
|
} ${
|
|
92
99
|
loading
|
|
93
100
|
? " cursor-progress"
|
|
94
|
-
: `${
|
|
101
|
+
: `${
|
|
102
|
+
disabled || (enableFormErrorsValidation && formHasErrors)
|
|
103
|
+
? ""
|
|
104
|
+
: `hover:${color.bg700}`
|
|
105
|
+
}`
|
|
95
106
|
} inline-flex justify-center rounded-md border border-transparent ${
|
|
96
107
|
color.bg600
|
|
97
108
|
} py-2 px-4 text-sm font-medium text-white shadow-sm focus:outline-none focus:ring-2 focus:${
|
|
@@ -102,7 +113,7 @@ export const Button = (props: Props) => {
|
|
|
102
113
|
</button>
|
|
103
114
|
);
|
|
104
115
|
|
|
105
|
-
return formHasErrors ? (
|
|
116
|
+
return enableFormErrorsValidation && formHasErrors ? (
|
|
106
117
|
<WithTooltip text={errorMessage}>{buttonContent}</WithTooltip>
|
|
107
118
|
) : (
|
|
108
119
|
buttonContent
|
package/src/Footer/Footer.tsx
CHANGED
|
@@ -12,6 +12,7 @@ type FooterProps = {
|
|
|
12
12
|
| "green"
|
|
13
13
|
| "red"
|
|
14
14
|
| "sky";
|
|
15
|
+
version?: string;
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
const COLORS = {
|
|
@@ -29,6 +30,7 @@ export const Footer = ({
|
|
|
29
30
|
href,
|
|
30
31
|
selectedColor,
|
|
31
32
|
showConnection = false,
|
|
33
|
+
version = "2.0.5",
|
|
32
34
|
}: FooterProps) => {
|
|
33
35
|
const color = COLORS[selectedColor];
|
|
34
36
|
|
|
@@ -37,7 +39,7 @@ export const Footer = ({
|
|
|
37
39
|
<div className="px-4 mx-auto flex flex-wrap items-center justify-center">
|
|
38
40
|
<p className="text-white text-[1.2rem]">
|
|
39
41
|
{`Creado en `} <a href={href}>Zauru</a>{" "}
|
|
40
|
-
{`con ❤️ ${new Date().getFullYear()} v
|
|
42
|
+
{`con ❤️ ${new Date().getFullYear()} v.${version}`}
|
|
41
43
|
</p>
|
|
42
44
|
{showConnection && (
|
|
43
45
|
<div className="ml-5">
|
|
@@ -152,7 +152,11 @@ export const SelectField = (props: Props) => {
|
|
|
152
152
|
!isEnterPressed &&
|
|
153
153
|
isSearching
|
|
154
154
|
) {
|
|
155
|
-
|
|
155
|
+
if (highlightedIndex >= 0) {
|
|
156
|
+
handleOptionClick(filteredOptions[highlightedIndex]);
|
|
157
|
+
} else {
|
|
158
|
+
handleOptionClick(filteredOptions[0]);
|
|
159
|
+
}
|
|
156
160
|
}
|
|
157
161
|
setIsTabPressed(false);
|
|
158
162
|
setIsEnterPressed(false);
|
|
@@ -245,6 +249,7 @@ export const SelectField = (props: Props) => {
|
|
|
245
249
|
{...field}
|
|
246
250
|
type="text"
|
|
247
251
|
id={id}
|
|
252
|
+
autoComplete="off"
|
|
248
253
|
value={inputValue}
|
|
249
254
|
onFocus={() => setIsOpen(true)}
|
|
250
255
|
onBlur={handleBlur}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IdeaIconSVG } from "@zauru-sdk/icons";
|
|
2
|
-
import React, { useEffect, useState } from "react";
|
|
2
|
+
import React, { useEffect, useMemo, useState } from "react";
|
|
3
3
|
import { useFormContext } from "react-hook-form";
|
|
4
4
|
|
|
5
5
|
type Props = {
|
|
@@ -73,20 +73,6 @@ export const TextField = (props: Props) => {
|
|
|
73
73
|
setValue(defaultValue);
|
|
74
74
|
}, [defaultValue]);
|
|
75
75
|
|
|
76
|
-
if (hidden) {
|
|
77
|
-
return (
|
|
78
|
-
<input
|
|
79
|
-
type={type}
|
|
80
|
-
id={id ?? name}
|
|
81
|
-
value={defaultValue}
|
|
82
|
-
readOnly={true}
|
|
83
|
-
hidden={true}
|
|
84
|
-
{...(register ?? {})}
|
|
85
|
-
name={name}
|
|
86
|
-
/>
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
76
|
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
91
77
|
if (register) {
|
|
92
78
|
register.onChange(event);
|
|
@@ -125,6 +111,21 @@ export const TextField = (props: Props) => {
|
|
|
125
111
|
}
|
|
126
112
|
};
|
|
127
113
|
|
|
114
|
+
if (hidden) {
|
|
115
|
+
return (
|
|
116
|
+
<input
|
|
117
|
+
type={"hidden"}
|
|
118
|
+
id={id ?? name}
|
|
119
|
+
value={value}
|
|
120
|
+
readOnly={true}
|
|
121
|
+
hidden={true}
|
|
122
|
+
{...(register ?? {})}
|
|
123
|
+
name={name}
|
|
124
|
+
onChange={handleInputChange}
|
|
125
|
+
/>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
128
129
|
const inputComponent = (
|
|
129
130
|
<input
|
|
130
131
|
type={type}
|