flysoft-react-ui 0.5.2 → 0.5.3
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/dist/App.d.ts.map +1 -1
- package/dist/App.js +5 -6
- package/dist/components/form-controls/AutocompleteInput.d.ts.map +1 -1
- package/dist/components/form-controls/AutocompleteInput.js +2 -1
- package/dist/components/form-controls/Button.d.ts +3 -0
- package/dist/components/form-controls/Button.d.ts.map +1 -1
- package/dist/components/form-controls/Button.js +160 -19
- package/dist/components/form-controls/Checkbox.d.ts.map +1 -1
- package/dist/components/form-controls/Checkbox.js +3 -1
- package/dist/components/form-controls/DateInput.d.ts +5 -1
- package/dist/components/form-controls/DateInput.d.ts.map +1 -1
- package/dist/components/form-controls/DateInput.js +94 -27
- package/dist/components/form-controls/Input.d.ts.map +1 -1
- package/dist/components/form-controls/Input.js +2 -1
- package/dist/components/form-controls/LinkButton.d.ts +15 -0
- package/dist/components/form-controls/LinkButton.d.ts.map +1 -0
- package/dist/components/form-controls/LinkButton.js +248 -0
- package/dist/components/form-controls/SearchSelectInput-OLD.d.ts.map +1 -1
- package/dist/components/form-controls/SearchSelectInput-OLD.js +3 -2
- package/dist/components/form-controls/SearchSelectInput.d.ts.map +1 -1
- package/dist/components/form-controls/SearchSelectInput.js +2 -1
- package/dist/components/form-controls/index.d.ts +2 -0
- package/dist/components/form-controls/index.d.ts.map +1 -1
- package/dist/components/form-controls/index.js +1 -0
- package/dist/components/layout/Accordion.d.ts +13 -0
- package/dist/components/layout/Accordion.d.ts.map +1 -0
- package/dist/components/layout/Accordion.js +67 -0
- package/dist/components/layout/AppLayout.js +1 -1
- package/dist/components/layout/Card.d.ts +8 -3
- package/dist/components/layout/Card.d.ts.map +1 -1
- package/dist/components/layout/Card.js +18 -19
- package/dist/components/layout/index.d.ts +2 -0
- package/dist/components/layout/index.d.ts.map +1 -1
- package/dist/components/layout/index.js +1 -0
- package/dist/components/utils/Badge.d.ts.map +1 -1
- package/dist/components/utils/Badge.js +3 -2
- package/dist/components/utils/Dialog.d.ts.map +1 -1
- package/dist/components/utils/Dialog.js +2 -1
- package/dist/components/utils/Filter.d.ts.map +1 -1
- package/dist/components/utils/Filter.js +2 -1
- package/dist/components/utils/Loader.js +1 -1
- package/dist/components/utils/RoadMap.d.ts.map +1 -1
- package/dist/components/utils/RoadMap.js +2 -1
- package/dist/components/utils/Snackbar.d.ts.map +1 -1
- package/dist/components/utils/Snackbar.js +2 -1
- package/dist/components/utils/iconUtils.d.ts +16 -0
- package/dist/components/utils/iconUtils.d.ts.map +1 -0
- package/dist/components/utils/iconUtils.js +40 -0
- package/dist/contexts/ListCrudContext.d.ts +28 -7
- package/dist/contexts/ListCrudContext.d.ts.map +1 -1
- package/dist/contexts/ListCrudContext.js +100 -56
- package/dist/docs/AccordionDocs.d.ts +4 -0
- package/dist/docs/AccordionDocs.d.ts.map +1 -0
- package/dist/docs/AccordionDocs.js +21 -0
- package/dist/docs/AuthDocs.tsx/AuthDocsContent.js +3 -5
- package/dist/docs/AutocompleteInputDocs.js +1 -1
- package/dist/docs/ButtonDocs.d.ts.map +1 -1
- package/dist/docs/ButtonDocs.js +1 -1
- package/dist/docs/CardDocs.d.ts.map +1 -1
- package/dist/docs/CardDocs.js +17 -8
- package/dist/docs/DataTableDocs.js +3 -3
- package/dist/docs/DialogDocs.js +1 -1
- package/dist/docs/DocAdmin.js +1 -1
- package/dist/docs/DocsMenu.d.ts.map +1 -1
- package/dist/docs/DocsMenu.js +3 -3
- package/dist/docs/DocsRouter.d.ts.map +1 -1
- package/dist/docs/DocsRouter.js +3 -1
- package/dist/docs/DropdownMenuDocs.js +1 -1
- package/dist/docs/LinkButtonDocs.d.ts +4 -0
- package/dist/docs/LinkButtonDocs.d.ts.map +1 -0
- package/dist/docs/LinkButtonDocs.js +7 -0
- package/dist/docs/ListCrudDocs.tsx/ListCrudDocs.d.ts +0 -9
- package/dist/docs/ListCrudDocs.tsx/ListCrudDocs.d.ts.map +1 -1
- package/dist/docs/ListCrudDocs.tsx/ListCrudDocs.js +16 -12
- package/dist/docs/ListCrudDocs.tsx/ListCrudDocsContentEmpresas.d.ts +2 -0
- package/dist/docs/ListCrudDocs.tsx/ListCrudDocsContentEmpresas.d.ts.map +1 -0
- package/dist/docs/ListCrudDocs.tsx/ListCrudDocsContentEmpresas.js +7 -0
- package/dist/docs/ListCrudDocs.tsx/ListCrudDocsContentPersonas.d.ts.map +1 -1
- package/dist/docs/ListCrudDocs.tsx/ListCrudDocsContentPersonas.js +32 -26
- package/dist/docs/ListCrudDocs.tsx/ListCrudDocsEditDialog.d.ts +9 -0
- package/dist/docs/ListCrudDocs.tsx/ListCrudDocsEditDialog.d.ts.map +1 -0
- package/dist/docs/ListCrudDocs.tsx/ListCrudDocsEditDialog.js +30 -0
- package/dist/docs/SearchSelectInputDocs.js +1 -1
- package/dist/docs/docMockServices/empresaService.d.ts.map +1 -1
- package/dist/docs/docMockServices/empresaService.js +2 -1
- package/dist/docs/docMockServices/personaService.d.ts +1 -1
- package/dist/docs/docMockServices/personaService.d.ts.map +1 -1
- package/dist/docs/docMockServices/personaService.js +3 -2
- package/dist/index.css +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/templates/forms/ContactForm.js +2 -2
- package/dist/templates/forms/LoginForm.js +1 -1
- package/dist/templates/forms/RegistrationForm.js +1 -1
- package/dist/templates/layouts/SidebarLayout.d.ts.map +1 -1
- package/dist/templates/layouts/SidebarLayout.js +3 -2
- package/dist/templates/patterns/FormPattern.d.ts.map +1 -1
- package/dist/templates/patterns/FormPattern.js +4 -3
- package/package.json +1 -1
package/dist/App.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":"AAGA,OAAO,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":"AAGA,OAAO,aAAa,CAAC;AAuDrB,iBAAS,GAAG,4CAsBX;AAED,eAAe,GAAG,CAAC"}
|
package/dist/App.js
CHANGED
|
@@ -8,20 +8,19 @@ import DocsRouter from "./docs/DocsRouter";
|
|
|
8
8
|
import { AuthDocs } from "./docs/AuthDocs.tsx/AuthDocs";
|
|
9
9
|
import packageJson from "../package.json";
|
|
10
10
|
function HomeContent() {
|
|
11
|
-
return (_jsxs(_Fragment, { children: [_jsx(Card, { title: "Empleados", className: "bg-gray-50", children: _jsx(Card, { className: "w-1/2", title: "FALCONE WALTER ALDO", subtitle: "3558-03 - Titular", footer: _jsx(Button, { children: "Ver" }), headerActions: ()
|
|
12
|
-
_jsx(Badge, { variant: "secondary", children: "OSOCNA" }),
|
|
13
|
-
_jsx(Badge, { variant: "secondary", children: "B\u00C1SICO" }),
|
|
14
|
-
], children: _jsxs(Collection, { direction: "row", gap: "1rem", wrap: true, children: [_jsx(DataField, { label: "Cuil", value: "20179902711" }), _jsx(DataField, { label: "Doc", value: "17990271" }), _jsx(DataField, { label: "F Nac", value: "23/06/1966" }), _jsx(DataField, { label: "F Alta", value: "01/03/2012" })] }) }) }), _jsx("div", { children: _jsx(AuthDocs, {}) })] }));
|
|
11
|
+
return (_jsxs(_Fragment, { children: [_jsx(Card, { title: "Empleados", className: "bg-gray-50", children: _jsx(Card, { className: "w-1/2", title: "FALCONE WALTER ALDO", subtitle: "3558-03 - Titular", footer: _jsx(Button, { children: "Ver" }), headerActions: _jsxs(_Fragment, { children: [_jsx(Badge, { variant: "secondary", children: "OSOCNA" }), _jsx(Badge, { variant: "secondary", children: "B\u00C1SICO" })] }), children: _jsxs(Collection, { direction: "row", gap: "1rem", wrap: true, children: [_jsx(DataField, { label: "Cuil", value: "20179902711" }), _jsx(DataField, { label: "Doc", value: "17990271" }), _jsx(DataField, { label: "F Nac", value: "23/06/1966" }), _jsx(DataField, { label: "F Alta", value: "01/03/2012" })] }) }) }), _jsx("div", { children: _jsx(AuthDocs, {}) })] }));
|
|
15
12
|
}
|
|
16
13
|
function LeftDrawerHeader() {
|
|
17
|
-
return (_jsx("div", { className: "h-[64px] flex flex-col justify-center px-4", children: _jsx("h2", { children: _jsx(Link, { to: "/", children: "Flysoft React UI" }) }) }));
|
|
14
|
+
return (_jsx("div", { className: "h-[64px] flex flex-col justify-center px-4 bg-gray-300", children: _jsx("h2", { children: _jsx(Link, { to: "/", children: "Flysoft React UI" }) }) }));
|
|
18
15
|
}
|
|
19
16
|
function LeftDrawerFooter() {
|
|
20
|
-
return (_jsx("div", { className: "px-4", children: _jsxs("span", { children: ["v ", packageJson.version] }) }));
|
|
17
|
+
return (_jsx("div", { className: "px-4 bg-gray-300", children: _jsxs("span", { children: ["v ", packageJson.version] }) }));
|
|
21
18
|
}
|
|
22
19
|
function App() {
|
|
23
20
|
return (_jsx(AppLayoutProvider, { initialTheme: "light", forceInitialTheme: false, initialNavbar: {
|
|
21
|
+
navBarLeftNode: _jsx(_Fragment, {}),
|
|
24
22
|
fullWidthNavbar: false,
|
|
23
|
+
className: "bg-gray-300 pl-0 lg:pl-8",
|
|
25
24
|
}, initialLeftDrawer: {
|
|
26
25
|
headerNode: _jsx(LeftDrawerHeader, {}),
|
|
27
26
|
contentNode: _jsx(DocsMenu, {}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutocompleteInput.d.ts","sourceRoot":"","sources":["../../../src/components/form-controls/AutocompleteInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"AutocompleteInput.d.ts","sourceRoot":"","sources":["../../../src/components/form-controls/AutocompleteInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAI1C,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB,CAAC,CAAC,GAAG,kBAAkB,EAAE,CAAC,GAAG,MAAM,CACxE,SAAQ,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,GAAG,KAAK,CAAC;IACtD,OAAO,EAAE,CAAC,EAAE,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EACL,KAAK,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,GAC1C,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC;IAC9B;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC/C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IACrC;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;IAChC;;OAEG;IACH,oBAAoB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAChE;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC;IAC5C;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAkqBD,eAAO,MAAM,iBAAiB,EAA6B,CACzD,CAAC,GAAG,kBAAkB,EACtB,CAAC,GAAG,MAAM,EAEV,KAAK,EAAE,sBAAsB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;IACpC,GAAG,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC;CAC5C,KACE,KAAK,CAAC,YAAY,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { createPortal } from "react-dom";
|
|
4
4
|
import { Input } from "./Input";
|
|
5
|
+
import { normalizeIconClass } from "../utils/iconUtils";
|
|
5
6
|
const AutocompleteInputInner = React.forwardRef(({ options, value, onChange, onSelectOption, noResultsText = "Sin resultados", className = "", getOptionLabel, getOptionValue, getOptionDescription, renderOption, readOnly = false, ...inputProps }, ref) => {
|
|
6
7
|
const [internalValue, setInternalValue] = React.useState(value || "");
|
|
7
8
|
const [displayValue, setDisplayValue] = React.useState("");
|
|
@@ -481,7 +482,7 @@ const AutocompleteInputInner = React.forwardRef(({ options, value, onChange, onS
|
|
|
481
482
|
: "text-[var(--color-text-primary)] hover:bg-[var(--color-bg-secondary)]"}`, onMouseDown: (event) => {
|
|
482
483
|
event.preventDefault();
|
|
483
484
|
handleSelect(option);
|
|
484
|
-
}, onMouseEnter: () => setHighlightedIndex(index), children: renderOption ? (renderOption(option)) : (_jsxs(_Fragment, { children: [anyOption.icon && (_jsx("i", { className:
|
|
485
|
+
}, onMouseEnter: () => setHighlightedIndex(index), children: renderOption ? (renderOption(option)) : (_jsxs(_Fragment, { children: [anyOption.icon && (_jsx("i", { className: `${normalizeIconClass(anyOption.icon)} mt-0.5 text-[var(--color-text-muted)] flex-shrink-0` })), _jsxs("div", { className: "flex flex-col min-w-0", children: [_jsx("span", { className: "font-[var(--font-default)] whitespace-nowrap", children: label }), description !== undefined &&
|
|
485
486
|
description !== null && (_jsx("span", { className: "text-xs text-[var(--color-text-secondary)] break-words", children: description }))] })] })) }, String(valueGetter(option) ?? label ?? index)));
|
|
486
487
|
}) })) : (_jsx("div", { className: "px-3 py-2 text-sm text-[var(--color-text-secondary)]", children: noResultsText })) }), bodyElement));
|
|
487
488
|
})()] }));
|
|
@@ -2,6 +2,9 @@ import React from "react";
|
|
|
2
2
|
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
3
|
variant?: "primary" | "outline" | "ghost";
|
|
4
4
|
size?: "sm" | "md" | "lg";
|
|
5
|
+
color?: "primary" | "secondary" | "success" | "warning" | "danger" | "info";
|
|
6
|
+
bg?: string;
|
|
7
|
+
textColor?: string;
|
|
5
8
|
icon?: string;
|
|
6
9
|
iconPosition?: "left" | "right";
|
|
7
10
|
loading?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/form-controls/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/form-controls/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAkC1B,MAAM,WAAW,WACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC;IACrD,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IAC1C,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,KAAK,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC5E,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AASD,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAwPxC,CAAC"}
|
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React from "react";
|
|
3
|
-
|
|
3
|
+
import { normalizeIconClass } from "../utils/iconUtils";
|
|
4
|
+
// Función helper para convertir nombres de colores comunes a valores CSS válidos
|
|
5
|
+
const getColorValue = (color) => {
|
|
6
|
+
if (!color)
|
|
7
|
+
return undefined;
|
|
8
|
+
// Si ya es un valor CSS válido (hex, rgb, rgba, hsl, etc.), retornarlo
|
|
9
|
+
if (color.startsWith("#") ||
|
|
10
|
+
color.startsWith("rgb") ||
|
|
11
|
+
color.startsWith("hsl")) {
|
|
12
|
+
return color;
|
|
13
|
+
}
|
|
14
|
+
// Mapeo de nombres de colores comunes
|
|
15
|
+
const colorMap = {
|
|
16
|
+
white: "#ffffff",
|
|
17
|
+
black: "#000000",
|
|
18
|
+
"gray-800": "#1f2937",
|
|
19
|
+
"gray-700": "#374151",
|
|
20
|
+
"gray-600": "#4b5563",
|
|
21
|
+
"gray-500": "#6b7280",
|
|
22
|
+
"gray-400": "#9ca3af",
|
|
23
|
+
"gray-300": "#d1d5db",
|
|
24
|
+
"gray-200": "#e5e7eb",
|
|
25
|
+
"gray-100": "#f3f4f6",
|
|
26
|
+
"gray-50": "#f9fafb",
|
|
27
|
+
};
|
|
28
|
+
return colorMap[color.toLowerCase()] || color;
|
|
29
|
+
};
|
|
30
|
+
export const Button = ({ variant = "primary", size = "md", color = "primary", bg, textColor, icon, iconPosition = "left", loading = false, children, className = "", disabled, onClick, ...props }) => {
|
|
4
31
|
const buttonRef = React.useRef(null);
|
|
5
32
|
const [ripples, setRipples] = React.useState([]);
|
|
6
33
|
const baseClasses = `
|
|
@@ -9,33 +36,125 @@ export const Button = ({ variant = "primary", size = "md", icon, iconPosition =
|
|
|
9
36
|
disabled:opacity-50 disabled:cursor-not-allowed
|
|
10
37
|
font-[var(--font-default)]
|
|
11
38
|
`;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
39
|
+
// Mapeo de clases para variant primary con color primary (usa Tailwind)
|
|
40
|
+
const getVariantClasses = (variantType, colorType) => {
|
|
41
|
+
// Solo usar clases Tailwind para primary con color primary
|
|
42
|
+
if (colorType === "primary") {
|
|
43
|
+
if (variantType === "primary") {
|
|
44
|
+
return `
|
|
45
|
+
bg-[var(--color-primary)] text-[var(--color-primary-contrast)]
|
|
46
|
+
hover:bg-[var(--color-primary-dark)] focus:ring-[var(--color-primary)]
|
|
47
|
+
`;
|
|
48
|
+
}
|
|
49
|
+
else if (variantType === "outline") {
|
|
50
|
+
return `
|
|
51
|
+
border border-[var(--color-primary)] text-[var(--color-primary)]
|
|
52
|
+
hover:bg-[var(--color-bg-secondary)] focus:ring-[var(--color-primary)]
|
|
53
|
+
`;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return `
|
|
57
|
+
text-[var(--color-primary)] hover:bg-[var(--color-bg-secondary)]
|
|
58
|
+
focus:ring-[var(--color-primary)]
|
|
59
|
+
`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Para otros colores, retornar clases base sin color (se aplicarán con estilos inline)
|
|
63
|
+
if (variantType === "primary") {
|
|
64
|
+
return `focus:ring-2 focus:ring-offset-2`;
|
|
65
|
+
}
|
|
66
|
+
else if (variantType === "outline") {
|
|
67
|
+
return `border hover:bg-[var(--color-bg-secondary)] focus:ring-2 focus:ring-offset-2`;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return `hover:bg-[var(--color-bg-secondary)] focus:ring-2 focus:ring-offset-2`;
|
|
71
|
+
}
|
|
25
72
|
};
|
|
73
|
+
// Si se proporciona bg personalizado, no usar las clases de variante
|
|
74
|
+
const variantClasses = bg ? "" : getVariantClasses(variant, color);
|
|
75
|
+
// Determinar si necesitamos usar estilos inline para colores del sistema
|
|
76
|
+
const needsInlineStyles = !bg && color !== "primary";
|
|
26
77
|
const sizeClasses = {
|
|
27
78
|
sm: `${children ? "px-3 py-1.5" : "p-1.5"} text-sm`,
|
|
28
79
|
md: `${children ? "px-4 py-2" : "p-2"} text-base`,
|
|
29
80
|
lg: `${children ? "px-6 py-3" : "p-3"} text-lg`,
|
|
30
81
|
};
|
|
31
|
-
|
|
82
|
+
// Clases adicionales para variant outline cuando hay bg personalizado
|
|
83
|
+
const outlineClasses = bg && variant === "outline" ? "border" : "";
|
|
84
|
+
const classes = `${baseClasses} ${variantClasses} ${sizeClasses[size]} ${outlineClasses} ${className}`;
|
|
85
|
+
// Función para obtener el valor de una variable CSS
|
|
86
|
+
const getCSSVariable = (varName) => {
|
|
87
|
+
if (typeof window !== "undefined") {
|
|
88
|
+
const value = getComputedStyle(document.documentElement)
|
|
89
|
+
.getPropertyValue(varName)
|
|
90
|
+
.trim();
|
|
91
|
+
// Si no se encuentra la variable, intentar con el prefijo flysoft
|
|
92
|
+
if (!value && varName.startsWith("--color-")) {
|
|
93
|
+
const flysoftVarName = varName.replace("--color-", "--flysoft-");
|
|
94
|
+
return (getComputedStyle(document.documentElement)
|
|
95
|
+
.getPropertyValue(flysoftVarName)
|
|
96
|
+
.trim() || value);
|
|
97
|
+
}
|
|
98
|
+
return value;
|
|
99
|
+
}
|
|
100
|
+
return "";
|
|
101
|
+
};
|
|
102
|
+
// Estilos inline para colores personalizados o colores del sistema (no primary)
|
|
103
|
+
const inlineStyles = bg
|
|
104
|
+
? {
|
|
105
|
+
backgroundColor: variant === "primary" ? getColorValue(bg) || bg : undefined,
|
|
106
|
+
color: getColorValue(textColor) ||
|
|
107
|
+
textColor ||
|
|
108
|
+
(variant === "primary" ? "#ffffff" : getColorValue(bg) || bg),
|
|
109
|
+
borderColor: variant === "outline" ? getColorValue(bg) || bg : undefined,
|
|
110
|
+
...(variant === "ghost" && {
|
|
111
|
+
color: getColorValue(textColor) || textColor || getColorValue(bg) || bg,
|
|
112
|
+
}),
|
|
113
|
+
}
|
|
114
|
+
: needsInlineStyles
|
|
115
|
+
? {
|
|
116
|
+
...(variant === "primary" && {
|
|
117
|
+
backgroundColor: getCSSVariable(`--color-${color}`),
|
|
118
|
+
color: getCSSVariable(`--color-${color}-contrast`) || "#ffffff",
|
|
119
|
+
}),
|
|
120
|
+
...(variant === "outline" && {
|
|
121
|
+
borderColor: getCSSVariable(`--color-${color}`),
|
|
122
|
+
color: getCSSVariable(`--color-${color}`),
|
|
123
|
+
}),
|
|
124
|
+
...(variant === "ghost" && {
|
|
125
|
+
color: getCSSVariable(`--color-${color}`),
|
|
126
|
+
}),
|
|
127
|
+
}
|
|
128
|
+
: {};
|
|
129
|
+
// Función para oscurecer un color (para hover en variant primary con bg personalizado)
|
|
130
|
+
const darkenColor = (color, percent) => {
|
|
131
|
+
const hex = color.replace("#", "");
|
|
132
|
+
const num = parseInt(hex, 16);
|
|
133
|
+
const r = Math.max(0, Math.floor((num >> 16) * (1 - percent / 100)));
|
|
134
|
+
const g = Math.max(0, Math.floor(((num >> 8) & 0x00ff) * (1 - percent / 100)));
|
|
135
|
+
const b = Math.max(0, Math.floor((num & 0x0000ff) * (1 - percent / 100)));
|
|
136
|
+
return `#${((r << 16) | (g << 8) | b).toString(16).padStart(6, "0")}`;
|
|
137
|
+
};
|
|
138
|
+
// Agregar hover style cuando hay bg personalizado y variant es primary
|
|
139
|
+
const hoverStyle = bg && variant === "primary" && !disabled && !loading
|
|
140
|
+
? {
|
|
141
|
+
"--hover-bg": darkenColor(getColorValue(bg) || bg, 15),
|
|
142
|
+
}
|
|
143
|
+
: {};
|
|
32
144
|
const renderIcon = () => {
|
|
33
145
|
if (!icon)
|
|
34
146
|
return null;
|
|
35
147
|
const iconClasses = size === "sm" ? "w-4 h-4" : size === "md" ? "w-5 h-5" : "w-6 h-6";
|
|
36
|
-
return (_jsx("i", { className:
|
|
148
|
+
return (_jsx("i", { className: `${normalizeIconClass(icon)} ${iconClasses} ${children ? (iconPosition === "right" ? "ml-2" : "mr-2") : ""} mt-0.5` }));
|
|
37
149
|
};
|
|
38
|
-
|
|
150
|
+
// Determinar el color del ripple basado en el variant y si hay bg personalizado
|
|
151
|
+
const rippleColor = bg
|
|
152
|
+
? variant === "primary"
|
|
153
|
+
? "rgba(255, 255, 255, 0.45)"
|
|
154
|
+
: "rgba(0, 0, 0, 0.15)"
|
|
155
|
+
: variant === "primary"
|
|
156
|
+
? "rgba(255, 255, 255, 0.45)"
|
|
157
|
+
: "rgba(0, 0, 0, 0.15)";
|
|
39
158
|
const handleClick = (event) => {
|
|
40
159
|
if (!disabled && !loading && buttonRef.current) {
|
|
41
160
|
const rect = buttonRef.current.getBoundingClientRect();
|
|
@@ -51,11 +170,33 @@ export const Button = ({ variant = "primary", size = "md", icon, iconPosition =
|
|
|
51
170
|
}
|
|
52
171
|
onClick?.(event);
|
|
53
172
|
};
|
|
54
|
-
|
|
173
|
+
// Combinar estilos inline
|
|
174
|
+
const combinedStyles = { ...inlineStyles, ...hoverStyle };
|
|
175
|
+
return (_jsxs("button", { ref: buttonRef, className: classes, style: combinedStyles, disabled: disabled || loading, onClick: handleClick, onMouseEnter: (e) => {
|
|
176
|
+
if (variant === "primary" && !disabled && !loading) {
|
|
177
|
+
if (bg) {
|
|
178
|
+
const hoverBg = darkenColor(getColorValue(bg) || bg, 15);
|
|
179
|
+
e.currentTarget.style.backgroundColor = hoverBg;
|
|
180
|
+
}
|
|
181
|
+
else if (needsInlineStyles) {
|
|
182
|
+
const hoverBg = getCSSVariable(`--color-${color}-dark`);
|
|
183
|
+
e.currentTarget.style.backgroundColor = hoverBg;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}, onMouseLeave: (e) => {
|
|
187
|
+
if (variant === "primary") {
|
|
188
|
+
if (bg) {
|
|
189
|
+
e.currentTarget.style.backgroundColor = getColorValue(bg) || bg;
|
|
190
|
+
}
|
|
191
|
+
else if (needsInlineStyles) {
|
|
192
|
+
e.currentTarget.style.backgroundColor = getCSSVariable(`--color-${color}`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}, ...props, children: [_jsx("span", { className: "absolute inset-0 pointer-events-none", children: ripples.map((ripple) => (_jsx("span", { className: "absolute rounded-full opacity-40 flysoft-button-ripple", style: {
|
|
55
196
|
top: ripple.y,
|
|
56
197
|
left: ripple.x,
|
|
57
198
|
width: ripple.size,
|
|
58
199
|
height: ripple.size,
|
|
59
200
|
backgroundColor: rippleColor,
|
|
60
|
-
} }, ripple.id))) }), _jsxs("span", { className: "relative inline-flex items-center justify-center", children: [loading && _jsx("i", { className: "fa
|
|
201
|
+
} }, ripple.id))) }), _jsxs("span", { className: "relative inline-flex items-center justify-center", children: [loading && (_jsx("i", { className: `${normalizeIconClass("fa-spinner fa-spin")} mr-2` })), icon && iconPosition === "left" && !loading && renderIcon(), children, icon && iconPosition === "right" && !loading && renderIcon()] })] }));
|
|
61
202
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/form-controls/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,aACf,SAAQ,IAAI,
|
|
1
|
+
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/form-controls/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,aACf,SAAQ,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,QAAQ,wFA0IpB,CAAC"}
|
|
@@ -31,7 +31,9 @@ export const Checkbox = React.forwardRef(({ label, labelPosition = "right", erro
|
|
|
31
31
|
${labelSizeClasses[size]}
|
|
32
32
|
font-[var(--font-default)] cursor-pointer select-none
|
|
33
33
|
${props.disabled ? "opacity-50 cursor-not-allowed" : ""}
|
|
34
|
-
${error
|
|
34
|
+
${error
|
|
35
|
+
? "text-[var(--color-danger)]"
|
|
36
|
+
: "text-[var(--color-text-primary)]"}
|
|
35
37
|
`;
|
|
36
38
|
const containerClasses = `
|
|
37
39
|
flex items-center gap-2
|
|
@@ -6,7 +6,8 @@ export type DateInputFormat = "dd/mm/yyyy" | "mm/dd/yyyy";
|
|
|
6
6
|
export interface DateInputProps extends Omit<InputProps, "type" | "value" | "onChange" | "ref"> {
|
|
7
7
|
/**
|
|
8
8
|
* Valor de la fecha.
|
|
9
|
-
* En modo register:
|
|
9
|
+
* En modo register con FormProvider: Dayjs | null (se guarda como Dayjs en el formulario)
|
|
10
|
+
* En modo register sin FormProvider: string ISO (se guarda como ISO string, se puede parsear a Dayjs)
|
|
10
11
|
* En modo Controller: Dayjs | null
|
|
11
12
|
*/
|
|
12
13
|
value?: Dayjs | null | string;
|
|
@@ -14,6 +15,9 @@ export interface DateInputProps extends Omit<InputProps, "type" | "value" | "onC
|
|
|
14
15
|
* Callback cuando cambia la fecha.
|
|
15
16
|
* En modo register: ChangeEventHandler (de register)
|
|
16
17
|
* En modo Controller: (date: Dayjs | null) => void
|
|
18
|
+
*
|
|
19
|
+
* NOTA: Para usar Dayjs directamente con register, el formulario debe estar envuelto en FormProvider.
|
|
20
|
+
* Sin FormProvider, el valor se guarda como ISO string y se puede parsear de vuelta a Dayjs usando normalizeToDayjs.
|
|
17
21
|
*/
|
|
18
22
|
onChange?: ((date: Dayjs | null) => void) | React.ChangeEventHandler<HTMLInputElement>;
|
|
19
23
|
format?: DateInputFormat;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateInput.d.ts","sourceRoot":"","sources":["../../../src/components/form-controls/DateInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAc,EAAE,KAAK,KAAK,EAAE,MAAM,OAAO,CAAC;AAI1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,YAAY,CAAC;AAE1D,MAAM,WAAW,cACf,SAAQ,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,KAAK,CAAC;IAC/D
|
|
1
|
+
{"version":3,"file":"DateInput.d.ts","sourceRoot":"","sources":["../../../src/components/form-controls/DateInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAc,EAAE,KAAK,KAAK,EAAE,MAAM,OAAO,CAAC;AAI1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,YAAY,CAAC;AAE1D,MAAM,WAAW,cACf,SAAQ,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,KAAK,CAAC;IAC/D;;;;;OAKG;IACH,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,MAAM,CAAC;IAC9B;;;;;;;OAOG;IACH,QAAQ,CAAC,EACL,CAAC,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,CAAC,GAC9B,KAAK,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;IAC/C,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,eAAe,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,OAAO,GAAG,UAAU,CAAC,CAAC;IAC9D;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AA2HD,eAAO,MAAM,SAAS,yFAgmBrB,CAAC"}
|
|
@@ -111,10 +111,10 @@ export const DateInput = React.forwardRef(({ value, onChange, format = "dd/mm/yy
|
|
|
111
111
|
? restInputProps.name
|
|
112
112
|
: undefined;
|
|
113
113
|
// Obtener setValue del contexto del formulario
|
|
114
|
-
// Para usar objetos Dayjs con register, el formulario debe estar dentro de FormProvider
|
|
115
114
|
// useFormContext debe llamarse incondicionalmente (requisito de React Hooks)
|
|
116
|
-
// Si no hay FormProvider
|
|
117
|
-
// Para usar sin FormProvider,
|
|
115
|
+
// Si no hay FormProvider, esto lanzará un error
|
|
116
|
+
// Para usar sin FormProvider, el componente guardará el valor Dayjs serializado (ISO string)
|
|
117
|
+
// en el input, y se puede parsear de vuelta a Dayjs cuando se lee el valor del formulario
|
|
118
118
|
const formContext = useFormContext();
|
|
119
119
|
const setValue = formContext?.setValue;
|
|
120
120
|
const [internalDate, setInternalDate] = React.useState(null);
|
|
@@ -124,7 +124,9 @@ export const DateInput = React.forwardRef(({ value, onChange, format = "dd/mm/yy
|
|
|
124
124
|
const containerRef = React.useRef(null);
|
|
125
125
|
const pickerRef = React.useRef(null);
|
|
126
126
|
const inputRef = React.useRef(null);
|
|
127
|
+
const hiddenInputRef = React.useRef(null);
|
|
127
128
|
const isTypingRef = React.useRef(false);
|
|
129
|
+
const lastDayjsValueRef = React.useRef(null);
|
|
128
130
|
// Función helper para sincronizar displayValue con el valor del formulario en modo register
|
|
129
131
|
const syncDisplayValue = React.useCallback(() => {
|
|
130
132
|
if (isRegisterMode && inputRef.current) {
|
|
@@ -271,10 +273,14 @@ export const DateInput = React.forwardRef(({ value, onChange, format = "dd/mm/yy
|
|
|
271
273
|
setValue(fieldName, date, {
|
|
272
274
|
shouldValidate: true,
|
|
273
275
|
shouldDirty: true,
|
|
276
|
+
shouldTouch: true,
|
|
274
277
|
});
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
+
// Actualizar el displayValue y el estado interno
|
|
279
|
+
setDisplayValue(dateString);
|
|
280
|
+
setInternalDate(date);
|
|
281
|
+
// Actualizar el input nativo con el valor visual (string) para mantener la sincronización
|
|
282
|
+
// Esto es solo para mostrar el valor correcto en el input
|
|
283
|
+
// El valor real (Dayjs) ya está guardado en el formulario vía setValue
|
|
278
284
|
if (inputRef.current) {
|
|
279
285
|
const nativeInput = inputRef.current;
|
|
280
286
|
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value")?.set;
|
|
@@ -284,7 +290,26 @@ export const DateInput = React.forwardRef(({ value, onChange, format = "dd/mm/yy
|
|
|
284
290
|
else {
|
|
285
291
|
nativeInput.value = dateString;
|
|
286
292
|
}
|
|
287
|
-
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
// Sin FormProvider: guardar el valor Dayjs serializado (ISO string) en el input
|
|
297
|
+
// react-hook-form leerá este valor y se puede parsear de vuelta a Dayjs cuando se lee
|
|
298
|
+
lastDayjsValueRef.current = date;
|
|
299
|
+
// Guardar el valor Dayjs serializado (como ISO string)
|
|
300
|
+
const dayjsIsoString = date ? date.toISOString() : "";
|
|
301
|
+
// Actualizar el input visible con el valor Dayjs serializado
|
|
302
|
+
// Esto es lo que react-hook-form leerá y guardará
|
|
303
|
+
if (inputRef.current) {
|
|
304
|
+
const nativeInput = inputRef.current;
|
|
305
|
+
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value")?.set;
|
|
306
|
+
if (nativeInputValueSetter) {
|
|
307
|
+
nativeInputValueSetter.call(nativeInput, dayjsIsoString);
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
nativeInput.value = dayjsIsoString;
|
|
311
|
+
}
|
|
312
|
+
// Llamar al onChange de register con el valor Dayjs serializado
|
|
288
313
|
if (onChange) {
|
|
289
314
|
const changeEvent = {
|
|
290
315
|
target: nativeInput,
|
|
@@ -304,10 +329,11 @@ export const DateInput = React.forwardRef(({ value, onChange, format = "dd/mm/yy
|
|
|
304
329
|
});
|
|
305
330
|
nativeInput.dispatchEvent(changeEventNative);
|
|
306
331
|
}
|
|
332
|
+
// Actualizar el displayValue con el string formateado para mostrar al usuario
|
|
333
|
+
// Aunque el input tiene el ISO string, mostramos el formato legible
|
|
334
|
+
setDisplayValue(dateString);
|
|
335
|
+
setInternalDate(date);
|
|
307
336
|
}
|
|
308
|
-
// Actualizar el displayValue
|
|
309
|
-
setDisplayValue(dateString);
|
|
310
|
-
setInternalDate(date);
|
|
311
337
|
}
|
|
312
338
|
else {
|
|
313
339
|
// Modo Controller - comportamiento original
|
|
@@ -341,29 +367,67 @@ export const DateInput = React.forwardRef(({ value, onChange, format = "dd/mm/yy
|
|
|
341
367
|
// En modo register, validar y actualizar el input nativo
|
|
342
368
|
if (!newValue) {
|
|
343
369
|
// Limpiar el valor
|
|
344
|
-
if (
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
370
|
+
if (setValue && fieldName) {
|
|
371
|
+
// Si tenemos setValue, usar setValue para limpiar el valor como null
|
|
372
|
+
setValue(fieldName, null, {
|
|
373
|
+
shouldValidate: true,
|
|
374
|
+
shouldDirty: true,
|
|
375
|
+
shouldTouch: true,
|
|
376
|
+
});
|
|
377
|
+
setDisplayValue("");
|
|
378
|
+
setInternalDate(null);
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
// Fallback: actualizar el input nativo
|
|
382
|
+
if (inputRef.current) {
|
|
383
|
+
const nativeInput = inputRef.current;
|
|
384
|
+
const setter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value")?.set;
|
|
385
|
+
setter?.call(nativeInput, "");
|
|
386
|
+
if (onChange) {
|
|
387
|
+
const changeEvent = {
|
|
388
|
+
target: nativeInput,
|
|
389
|
+
currentTarget: nativeInput,
|
|
390
|
+
};
|
|
391
|
+
onChange(changeEvent);
|
|
392
|
+
}
|
|
393
|
+
const inputEvent = new Event("input", { bubbles: true });
|
|
394
|
+
nativeInput.dispatchEvent(inputEvent);
|
|
395
|
+
const changeEventNative = new Event("change", { bubbles: true });
|
|
396
|
+
nativeInput.dispatchEvent(changeEventNative);
|
|
354
397
|
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
const changeEventNative = new Event("change", { bubbles: true });
|
|
358
|
-
nativeInput.dispatchEvent(changeEventNative);
|
|
398
|
+
setDisplayValue("");
|
|
399
|
+
setInternalDate(null);
|
|
359
400
|
}
|
|
360
|
-
setDisplayValue("");
|
|
361
|
-
setInternalDate(null);
|
|
362
401
|
}
|
|
363
402
|
else {
|
|
364
403
|
const parsed = parseDateFromString(newValue, format);
|
|
365
404
|
if (parsed) {
|
|
405
|
+
// handleDateChange ya usa setValue si está disponible
|
|
366
406
|
handleDateChange(parsed);
|
|
407
|
+
// Si usamos setValue, asegurarse de que el valor Dayjs se mantenga
|
|
408
|
+
// después del blur, ya que registerOnBlur puede causar que react-hook-form
|
|
409
|
+
// lea el valor del input como string
|
|
410
|
+
if (setValue && fieldName && registerOnBlur) {
|
|
411
|
+
// Guardar el valor Dayjs antes de llamar a registerOnBlur
|
|
412
|
+
const dayjsValue = parsed;
|
|
413
|
+
// Llamar al onBlur de register
|
|
414
|
+
registerOnBlur(event);
|
|
415
|
+
// Usar setTimeout para asegurarse de que esto se ejecuta después de registerOnBlur
|
|
416
|
+
// y restaurar el valor Dayjs si react-hook-form lo sobrescribió con un string
|
|
417
|
+
setTimeout(() => {
|
|
418
|
+
const currentValue = formContext?.watch(fieldName);
|
|
419
|
+
// Si el valor actual es un string en lugar de Dayjs, restaurarlo
|
|
420
|
+
if (currentValue && typeof currentValue === "string") {
|
|
421
|
+
setValue(fieldName, dayjsValue, {
|
|
422
|
+
shouldValidate: true,
|
|
423
|
+
shouldDirty: true,
|
|
424
|
+
shouldTouch: true,
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
}, 0);
|
|
428
|
+
// No llamar a registerOnBlur más abajo ya que ya lo llamamos aquí
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
367
431
|
}
|
|
368
432
|
else {
|
|
369
433
|
// Si no es válida, restaurar el valor anterior
|
|
@@ -372,6 +436,7 @@ export const DateInput = React.forwardRef(({ value, onChange, format = "dd/mm/yy
|
|
|
372
436
|
}
|
|
373
437
|
}
|
|
374
438
|
// Llamar al onBlur de register si existe
|
|
439
|
+
// Solo se llama aquí si no usamos setValue o si no había un valor válido
|
|
375
440
|
if (registerOnBlur) {
|
|
376
441
|
registerOnBlur(event);
|
|
377
442
|
}
|
|
@@ -489,7 +554,9 @@ export const DateInput = React.forwardRef(({ value, onChange, format = "dd/mm/yy
|
|
|
489
554
|
setPickerPosition(null);
|
|
490
555
|
}
|
|
491
556
|
}, [isOpen, readOnly, isMounted]);
|
|
492
|
-
return (_jsxs("div", { ref: containerRef, className: "relative w-full", children: [
|
|
557
|
+
return (_jsxs("div", { ref: containerRef, className: "relative w-full", children: [isRegisterMode && !setValue && fieldName && (_jsx("input", { ref: hiddenInputRef, type: "hidden", name: fieldName, value: lastDayjsValueRef.current
|
|
558
|
+
? lastDayjsValueRef.current.toISOString()
|
|
559
|
+
: "" })), _jsx(Input, { ...restInputProps, ref: combinedRef, type: "text", value: inputValue, onChange: handleInputChange, onBlur: handleInputBlur, icon: displayIcon, iconPosition: displayIconPosition, onIconClick: displayOnIconClick, placeholder: restInputProps.placeholder ??
|
|
493
560
|
(format === "mm/dd/yyyy" ? "mm/dd/yyyy" : "dd/mm/yyyy"), className: className, readOnly: readOnly }), (() => {
|
|
494
561
|
// Verificar de forma segura que document.body existe y es válido
|
|
495
562
|
const bodyElement = typeof document !== "undefined" &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/components/form-controls/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/components/form-controls/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,WAAW,UACf,SAAQ,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACjE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IAC7D;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,KAAK,qFA4FjB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React from "react";
|
|
3
|
+
import { normalizeIconClass } from "../utils/iconUtils";
|
|
3
4
|
export const Input = React.forwardRef(({ label, error, icon, iconPosition = "left", size = "md", className = "", id, onIconClick, readOnly = false, ...props }, ref) => {
|
|
4
5
|
const inputId = id || `input-${Math.random().toString(36).substr(2, 9)}`;
|
|
5
6
|
const baseClasses = `
|
|
@@ -25,7 +26,7 @@ export const Input = React.forwardRef(({ label, error, icon, iconPosition = "lef
|
|
|
25
26
|
const renderIcon = () => {
|
|
26
27
|
if (!icon)
|
|
27
28
|
return null;
|
|
28
|
-
const iconElement = (_jsx("i", { className:
|
|
29
|
+
const iconElement = (_jsx("i", { className: `${normalizeIconClass(icon)} ${iconClasses} text-[var(--color-text-muted)] absolute top-1/2 transform -translate-y-1/2 ${iconPosition === "left" ? "left-3" : "right-3"} ${onIconClick && !readOnly ? "cursor-pointer hover:text-[var(--color-primary)] transition-colors" : ""}`, onClick: readOnly ? undefined : onIconClick }));
|
|
29
30
|
return iconElement;
|
|
30
31
|
};
|
|
31
32
|
return (_jsxs("div", { className: "w-full", children: [label && (_jsx("label", { htmlFor: inputId, className: "block text-sm text-[var(--color-primary)] mb-1 font-[var(--font-default)]", children: label })), _jsxs("div", { className: "relative", children: [icon && iconPosition === "left" && renderIcon(), _jsx("input", { ref: ref, id: inputId, className: `${inputClasses} ${icon && iconPosition === "left" ? "pl-10" : ""} ${icon && iconPosition === "right" ? "pr-10" : ""}`, autoComplete: "off", readOnly: readOnly, ...props }), icon && iconPosition === "right" && renderIcon()] }), error && (_jsx("p", { className: "mt-1 text-sm text-[var(--color-danger)] font-[var(--font-default)]", children: error }))] }));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface LinkButtonProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href"> {
|
|
3
|
+
to: string;
|
|
4
|
+
target?: string;
|
|
5
|
+
variant?: "primary" | "outline" | "ghost";
|
|
6
|
+
size?: "sm" | "md" | "lg";
|
|
7
|
+
color?: "primary" | "secondary" | "success" | "warning" | "danger" | "info";
|
|
8
|
+
bg?: string;
|
|
9
|
+
textColor?: string;
|
|
10
|
+
icon?: string;
|
|
11
|
+
iconPosition?: "left" | "right";
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export declare const LinkButton: React.FC<LinkButtonProps>;
|
|
15
|
+
//# sourceMappingURL=LinkButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinkButton.d.ts","sourceRoot":"","sources":["../../../src/components/form-controls/LinkButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAmC1B,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACnE,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IAC1C,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,KAAK,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC5E,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AASD,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAgThD,CAAC"}
|