@soyfri/shared-library 1.5.0 → 2.0.0-beta.1
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/build.js +75 -38
- package/dist/components/ActionMenu/ActionMenu.cjs +107 -0
- package/dist/components/ActionMenu/ActionMenu.cjs.map +1 -0
- package/dist/components/ActionMenu/ActionMenu.d.ts +60 -0
- package/dist/components/ActionMenu/ActionMenu.js +107 -0
- package/dist/components/ActionMenu/ActionMenu.js.map +1 -0
- package/dist/components/ActionMenu/index.d.ts +2 -0
- package/dist/components/ActionMenu.d.ts +6 -0
- package/dist/components/AppBar/AppBar.cjs +346 -0
- package/dist/components/AppBar/AppBar.cjs.map +1 -0
- package/dist/components/AppBar/AppBar.d.ts +55 -0
- package/dist/components/AppBar/AppBar.js +346 -0
- package/dist/components/AppBar/AppBar.js.map +1 -0
- package/dist/components/AppBar/AppBar.sx.d.ts +12 -0
- package/dist/components/AppBar/AppBarBrand.d.ts +31 -0
- package/dist/components/AppBar/AppBarContext.d.ts +18 -0
- package/dist/components/AppBar/AppBarMenuToggle.d.ts +39 -0
- package/dist/components/AppBar/AppBarUserMenu.d.ts +65 -0
- package/dist/components/AppBar/index.d.ts +12 -0
- package/dist/components/AppBar.d.ts +6 -0
- package/dist/components/Autocomplete/Autocomplete.cjs +259 -54
- package/dist/components/Autocomplete/Autocomplete.cjs.map +1 -1
- package/dist/components/Autocomplete/Autocomplete.d.ts +64 -9
- package/dist/components/Autocomplete/Autocomplete.definitions.d.ts +6 -0
- package/dist/components/Autocomplete/Autocomplete.helpers.d.ts +18 -0
- package/dist/components/Autocomplete/Autocomplete.js +261 -56
- package/dist/components/Autocomplete/Autocomplete.js.map +1 -1
- package/dist/components/Autocomplete/Autocomplete.sx.d.ts +7 -0
- package/dist/components/Autocomplete/Autocomplete.types.d.ts +1 -0
- package/dist/components/Autocomplete/_parts/AutocompleteChips.d.ts +19 -0
- package/dist/components/Autocomplete/_parts/AutocompleteLoader.d.ts +9 -0
- package/dist/components/Autocomplete/_parts/AutocompleteOption.d.ts +19 -0
- package/dist/components/Autocomplete/index.d.ts +2 -1
- package/dist/components/Autocomplete.d.ts +4 -0
- package/dist/components/Avatar/Avatar.cjs +116 -79
- package/dist/components/Avatar/Avatar.cjs.map +1 -1
- package/dist/components/Avatar/Avatar.d.ts +16 -2
- package/dist/components/Avatar/Avatar.definitions.d.ts +11 -0
- package/dist/components/Avatar/Avatar.js +117 -80
- package/dist/components/Avatar/Avatar.js.map +1 -1
- package/dist/components/Card/Card.cjs +168 -9
- package/dist/components/Card/Card.cjs.map +1 -1
- package/dist/components/Card/Card.d.ts +78 -8
- package/dist/components/Card/Card.js +170 -11
- package/dist/components/Card/Card.js.map +1 -1
- package/dist/components/Card/Card.sx.d.ts +17 -0
- package/dist/components/Card/index.d.ts +4 -1
- package/dist/components/Card.d.ts +4 -0
- package/dist/components/DatePicker/DatePicker.cjs +201 -3
- package/dist/components/DatePicker/DatePicker.cjs.map +1 -1
- package/dist/components/DatePicker/DatePicker.d.ts +47 -9
- package/dist/components/DatePicker/DatePicker.definitions.d.ts +1 -0
- package/dist/components/DatePicker/DatePicker.helpers.d.ts +7 -0
- package/dist/components/DatePicker/DatePicker.js +200 -2
- package/dist/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/components/DatePicker/DatePicker.sx.d.ts +9 -0
- package/dist/components/DatePicker/DatePicker.types.d.ts +1 -0
- package/dist/components/DatePicker/index.d.ts +2 -1
- package/dist/components/DatePicker.d.ts +4 -0
- package/dist/components/DateTimePicker/DateTimePicker.cjs +152 -138
- package/dist/components/DateTimePicker/DateTimePicker.cjs.map +1 -1
- package/dist/components/DateTimePicker/DateTimePicker.d.ts +46 -9
- package/dist/components/DateTimePicker/DateTimePicker.definitions.d.ts +1 -0
- package/dist/components/DateTimePicker/DateTimePicker.helpers.d.ts +11 -0
- package/dist/components/DateTimePicker/DateTimePicker.js +152 -138
- package/dist/components/DateTimePicker/DateTimePicker.js.map +1 -1
- package/dist/components/DateTimePicker/DateTimePicker.sx.d.ts +7 -0
- package/dist/components/DateTimePicker/DateTimePicker.types.d.ts +1 -0
- package/dist/components/DateTimePicker/index.d.ts +2 -1
- package/dist/components/DateTimePicker.d.ts +4 -0
- package/dist/components/Drawer/Drawer.cjs +271 -0
- package/dist/components/Drawer/Drawer.cjs.map +1 -0
- package/dist/components/Drawer/Drawer.d.ts +51 -0
- package/dist/components/Drawer/Drawer.js +271 -0
- package/dist/components/Drawer/Drawer.js.map +1 -0
- package/dist/components/Drawer/Drawer.sx.d.ts +23 -0
- package/dist/components/Drawer/DrawerContext.d.ts +18 -0
- package/dist/components/Drawer/DrawerItem.d.ts +35 -0
- package/dist/components/Drawer/index.d.ts +6 -0
- package/dist/components/Drawer.d.ts +6 -0
- package/dist/components/Icon/Icon.cjs +44 -3
- package/dist/components/Icon/Icon.cjs.map +1 -1
- package/dist/components/Icon/Icon.d.ts +34 -1
- package/dist/components/Icon/Icon.js +44 -3
- package/dist/components/Icon/Icon.js.map +1 -1
- package/dist/components/Input/Input.cjs +173 -3
- package/dist/components/Input/Input.cjs.map +1 -1
- package/dist/components/Input/Input.d.ts +20 -15
- package/dist/components/Input/Input.definitions.d.ts +5 -2
- package/dist/components/Input/Input.helpers.d.ts +14 -0
- package/dist/components/Input/Input.js +172 -2
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/Input/Input.sx.d.ts +8 -0
- package/dist/components/Input/Input.types.d.ts +1 -0
- package/dist/components/Input/index.d.ts +2 -1
- package/dist/components/Input.d.ts +4 -0
- package/dist/components/InputGroup/InputGroup.cjs +104 -91
- package/dist/components/InputGroup/InputGroup.cjs.map +1 -1
- package/dist/components/InputGroup/InputGroup.d.ts +37 -1
- package/dist/components/InputGroup/InputGroup.definitions.d.ts +6 -0
- package/dist/components/InputGroup/InputGroup.js +106 -93
- package/dist/components/InputGroup/InputGroup.js.map +1 -1
- package/dist/components/Modal/Modal.cjs +226 -116
- package/dist/components/Modal/Modal.cjs.map +1 -1
- package/dist/components/Modal/Modal.d.ts +38 -2
- package/dist/components/Modal/Modal.js +227 -117
- package/dist/components/Modal/Modal.js.map +1 -1
- package/dist/components/Modal/ModalFooter.d.ts +9 -1
- package/dist/components/Modal/index.d.ts +5 -0
- package/dist/components/PageLoader/PageLoader.cjs +61 -0
- package/dist/components/PageLoader/PageLoader.cjs.map +1 -0
- package/dist/components/PageLoader/PageLoader.d.ts +38 -0
- package/dist/components/PageLoader/PageLoader.js +61 -0
- package/dist/components/PageLoader/PageLoader.js.map +1 -0
- package/dist/components/PageLoader/index.d.ts +2 -0
- package/dist/components/PageLoader.d.ts +6 -0
- package/dist/components/ScrollTopButton/ScrollTopButton.cjs +79 -0
- package/dist/components/ScrollTopButton/ScrollTopButton.cjs.map +1 -0
- package/dist/components/ScrollTopButton/ScrollTopButton.d.ts +48 -0
- package/dist/components/ScrollTopButton/ScrollTopButton.js +79 -0
- package/dist/components/ScrollTopButton/ScrollTopButton.js.map +1 -0
- package/dist/components/ScrollTopButton/index.d.ts +4 -0
- package/dist/components/ScrollTopButton/scrollToTop.d.ts +29 -0
- package/dist/components/ScrollTopButton.d.ts +6 -0
- package/dist/components/Select/Select.cjs +446 -4
- package/dist/components/Select/Select.cjs.map +1 -1
- package/dist/components/Select/Select.d.ts +33 -13
- package/dist/components/Select/Select.definitions.d.ts +3 -0
- package/dist/components/Select/Select.helpers.d.ts +28 -0
- package/dist/components/Select/Select.js +445 -3
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Select/Select.sx.d.ts +7 -0
- package/dist/components/Select/Select.types.d.ts +1 -0
- package/dist/components/Select/_parts/SelectMenuItem.d.ts +20 -0
- package/dist/components/Select/_parts/SelectSearchHeader.d.ts +15 -0
- package/dist/components/Select/_parts/SelectValue.d.ts +22 -0
- package/dist/components/Select/index.d.ts +2 -1
- package/dist/components/Select.d.ts +4 -0
- package/dist/components/Stat/Stat.cjs +1 -1
- package/dist/components/Stat/Stat.js +1 -1
- package/dist/components/Stepper/Stepper.cjs +4 -1
- package/dist/components/Stepper/Stepper.cjs.map +1 -1
- package/dist/components/Stepper/Stepper.d.ts +5 -0
- package/dist/components/Stepper/Stepper.js +4 -1
- package/dist/components/Stepper/Stepper.js.map +1 -1
- package/dist/components/_shared/formField.sx.d.ts +33 -0
- package/dist/components/_shared/resolvePreset.d.ts +18 -0
- package/dist/formField.sx-CQ1mbk9M.cjs +76 -0
- package/dist/formField.sx-CQ1mbk9M.cjs.map +1 -0
- package/dist/formField.sx-DfVbMe0V.js +77 -0
- package/dist/formField.sx-DfVbMe0V.js.map +1 -0
- package/dist/hooks/Wizard/Wizard.cjs +7 -0
- package/dist/hooks/Wizard/Wizard.cjs.map +1 -0
- package/dist/hooks/Wizard/Wizard.js +7 -0
- package/dist/hooks/Wizard/Wizard.js.map +1 -0
- package/dist/hooks/Wizard/WizardContext.d.ts +67 -0
- package/dist/hooks/Wizard/index.d.ts +3 -0
- package/dist/hooks/Wizard/useWizard.d.ts +9 -0
- package/dist/hooks/Wizard.d.ts +2 -0
- package/dist/index.cjs +99 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +31 -2
- package/dist/index.js.map +1 -1
- package/dist/mui.d.ts +5 -0
- package/dist/resolvePreset-B-IB0ehH.js +15 -0
- package/dist/resolvePreset-B-IB0ehH.js.map +1 -0
- package/dist/resolvePreset-CT3kU-K2.cjs +14 -0
- package/dist/resolvePreset-CT3kU-K2.cjs.map +1 -0
- package/dist/styles.css +3 -112
- package/dist/theme/componentStyles.d.ts +32 -0
- package/dist/theme/tokens.d.ts +28 -0
- package/dist/useWizard-CWdIxZzX.cjs +94 -0
- package/dist/useWizard-CWdIxZzX.cjs.map +1 -0
- package/dist/useWizard-CWq--C3o.js +95 -0
- package/dist/useWizard-CWq--C3o.js.map +1 -0
- package/package.json +1 -1
- package/src/components/ActionMenu/ActionMenu.stories.tsx +230 -0
- package/src/components/ActionMenu/ActionMenu.tsx +174 -0
- package/src/components/ActionMenu/index.ts +2 -0
- package/src/components/AppBar/AppBar.stories.tsx +272 -0
- package/src/components/AppBar/AppBar.sx.ts +32 -0
- package/src/components/AppBar/AppBar.tsx +123 -0
- package/src/components/AppBar/AppBarBrand.tsx +120 -0
- package/src/components/AppBar/AppBarContext.ts +25 -0
- package/src/components/AppBar/AppBarMenuToggle.tsx +90 -0
- package/src/components/AppBar/AppBarUserMenu.tsx +217 -0
- package/src/components/AppBar/index.ts +25 -0
- package/src/components/Autocomplete/Autocomplete.definitions.ts +223 -0
- package/src/components/Autocomplete/Autocomplete.helpers.ts +60 -0
- package/src/components/Autocomplete/Autocomplete.stories.tsx +363 -2
- package/src/components/Autocomplete/Autocomplete.sx.ts +30 -0
- package/src/components/Autocomplete/Autocomplete.tsx +312 -90
- package/src/components/Autocomplete/Autocomplete.types.ts +13 -0
- package/src/components/Autocomplete/_parts/AutocompleteChips.tsx +55 -0
- package/src/components/Autocomplete/_parts/AutocompleteLoader.tsx +17 -0
- package/src/components/Autocomplete/_parts/AutocompleteOption.tsx +31 -0
- package/src/components/Autocomplete/index.ts +12 -1
- package/src/components/Avatar/Avatar.definitions.ts +162 -0
- package/src/components/Avatar/Avatar.stories.tsx +205 -1
- package/src/components/Avatar/Avatar.tsx +166 -103
- package/src/components/Card/Card.stories.tsx +205 -16
- package/src/components/Card/Card.sx.ts +104 -0
- package/src/components/Card/Card.tsx +191 -35
- package/src/components/Card/index.ts +9 -1
- package/src/components/DatePicker/DatePicker.definitions.ts +24 -1
- package/src/components/DatePicker/DatePicker.helpers.ts +24 -0
- package/src/components/DatePicker/DatePicker.stories.tsx +29 -2
- package/src/components/DatePicker/DatePicker.sx.ts +33 -0
- package/src/components/DatePicker/DatePicker.tsx +163 -139
- package/src/components/DatePicker/DatePicker.types.ts +10 -0
- package/src/components/DatePicker/index.ts +9 -1
- package/src/components/DateTimePicker/DateTimePicker.definitions.ts +24 -0
- package/src/components/DateTimePicker/DateTimePicker.helpers.ts +38 -0
- package/src/components/DateTimePicker/DateTimePicker.stories.tsx +29 -1
- package/src/components/DateTimePicker/DateTimePicker.sx.ts +30 -0
- package/src/components/DateTimePicker/DateTimePicker.tsx +200 -166
- package/src/components/DateTimePicker/DateTimePicker.types.ts +10 -0
- package/src/components/DateTimePicker/index.ts +9 -1
- package/src/components/Drawer/Drawer.stories.tsx +270 -0
- package/src/components/Drawer/Drawer.sx.ts +106 -0
- package/src/components/Drawer/Drawer.tsx +214 -0
- package/src/components/Drawer/DrawerContext.ts +26 -0
- package/src/components/Drawer/DrawerItem.tsx +110 -0
- package/src/components/Drawer/index.ts +10 -0
- package/src/components/Flyout/Flyout.stories.tsx +26 -18
- package/src/components/Icon/Icon.stories.tsx +68 -1
- package/src/components/Icon/Icon.tsx +87 -6
- package/src/components/Input/Input.definitions.ts +74 -2
- package/src/components/Input/Input.helpers.ts +49 -0
- package/src/components/Input/Input.stories.tsx +116 -4
- package/src/components/Input/Input.sx.ts +42 -0
- package/src/components/Input/Input.tsx +117 -162
- package/src/components/Input/Input.types.ts +10 -0
- package/src/components/Input/index.ts +9 -1
- package/src/components/InputGroup/InputGroup.definitions.ts +158 -0
- package/src/components/InputGroup/InputGroup.stories.tsx +159 -28
- package/src/components/InputGroup/InputGroup.tsx +159 -116
- package/src/components/Modal/Modal.stories.tsx +434 -6
- package/src/components/Modal/Modal.tsx +303 -121
- package/src/components/Modal/ModalFooter.tsx +22 -12
- package/src/components/Modal/index.ts +6 -1
- package/src/components/PageLoader/PageLoader.stories.tsx +217 -0
- package/src/components/PageLoader/PageLoader.tsx +96 -0
- package/src/components/PageLoader/index.ts +2 -0
- package/src/components/ScrollTopButton/ScrollTopButton.stories.tsx +158 -0
- package/src/components/ScrollTopButton/ScrollTopButton.tsx +135 -0
- package/src/components/ScrollTopButton/index.ts +8 -0
- package/src/components/ScrollTopButton/scrollToTop.ts +37 -0
- package/src/components/Select/Select.definitions.ts +114 -0
- package/src/components/Select/Select.helpers.ts +71 -0
- package/src/components/Select/Select.stories.tsx +126 -8
- package/src/components/Select/Select.sx.ts +14 -0
- package/src/components/Select/Select.tsx +246 -285
- package/src/components/Select/Select.types.ts +15 -0
- package/src/components/Select/_parts/SelectMenuItem.tsx +40 -0
- package/src/components/Select/_parts/SelectSearchHeader.tsx +51 -0
- package/src/components/Select/_parts/SelectValue.tsx +96 -0
- package/src/components/Select/index.ts +14 -1
- package/src/components/Stepper/Stepper.tsx +17 -1
- package/src/components/Tooltip/Tooltip.stories.tsx +15 -3
- package/src/components/_shared/formField.sx.ts +118 -0
- package/src/components/_shared/resolvePreset.ts +35 -0
- package/src/hooks/Wizard/Wizard.stories.tsx +301 -0
- package/src/hooks/Wizard/WizardContext.tsx +166 -0
- package/src/hooks/Wizard/index.ts +6 -0
- package/src/hooks/Wizard/useWizard.ts +13 -0
- package/src/index.ts +17 -1
- package/src/mui.ts +44 -0
- package/src/theme/componentStyles.ts +47 -0
- package/src/theme/tokens.ts +43 -0
- package/dist/DatePicker-BSNboVhN.js +0 -201
- package/dist/DatePicker-BSNboVhN.js.map +0 -1
- package/dist/DatePicker-BoqxWAhj.cjs +0 -200
- package/dist/DatePicker-BoqxWAhj.cjs.map +0 -1
- package/dist/Input-DFHs7cJ_.js +0 -171
- package/dist/Input-DFHs7cJ_.js.map +0 -1
- package/dist/Input-c8MwNNPg.cjs +0 -170
- package/dist/Input-c8MwNNPg.cjs.map +0 -1
- package/dist/Select-BO2N56sm.cjs +0 -411
- package/dist/Select-BO2N56sm.cjs.map +0 -1
- package/dist/Select-BcLkyHSE.js +0 -412
- package/dist/Select-BcLkyHSE.js.map +0 -1
- package/dist/index.css +0 -3
|
@@ -1,7 +1,40 @@
|
|
|
1
1
|
import { default as React, ReactNode } from 'react';
|
|
2
2
|
export type IconSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
3
3
|
export interface IconProps {
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Contenido icono. Modo legacy: acepta un elemento MUI o SVG ya armado.
|
|
6
|
+
* Si se usa junto con `path` o `url`, `children` tiene prioridad.
|
|
7
|
+
*/
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* Ruta SVG inline (el contenido del atributo `d` de un `<path>`). Útil para
|
|
11
|
+
* los iconos custom de Metronic que vienen como strings de path.
|
|
12
|
+
*
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <Icon path="M12 2L2 22h20L12 2z" />
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* Si el string contiene el tag `<svg>` completo (no solo el `d`), también
|
|
18
|
+
* se soporta y se inyecta tal cual via `dangerouslySetInnerHTML`.
|
|
19
|
+
*/
|
|
20
|
+
path?: string;
|
|
21
|
+
/**
|
|
22
|
+
* URL a un archivo `.svg` (asset local o remoto). Se renderiza vía `<img>`.
|
|
23
|
+
*
|
|
24
|
+
* ```tsx
|
|
25
|
+
* <Icon url="/assets/icons/custom-warning.svg" />
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
url?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Alt text cuando se usa `url`. Default: `"icon"`.
|
|
31
|
+
*/
|
|
32
|
+
alt?: string;
|
|
33
|
+
/**
|
|
34
|
+
* ViewBox cuando se usa `path`. Default: `"0 0 24 24"`. Ignorado si `path`
|
|
35
|
+
* ya viene como `<svg>` completo.
|
|
36
|
+
*/
|
|
37
|
+
viewBox?: string;
|
|
5
38
|
color?: string;
|
|
6
39
|
outlined?: boolean;
|
|
7
40
|
spin?: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../../styles.css';/* empty css */
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useMemo } from "react";
|
|
4
4
|
import { styled, Badge } from "@mui/material";
|
|
@@ -11,8 +11,12 @@ const sizeMap = {
|
|
|
11
11
|
};
|
|
12
12
|
const StyledIcon = styled("span")(({ color, fontSize, spin, outlined }) => ({
|
|
13
13
|
display: "inline-flex",
|
|
14
|
+
alignItems: "center",
|
|
15
|
+
justifyContent: "center",
|
|
14
16
|
color,
|
|
15
17
|
fontSize,
|
|
18
|
+
width: fontSize,
|
|
19
|
+
height: fontSize,
|
|
16
20
|
animation: spin ? "spin 1s linear infinite" : void 0,
|
|
17
21
|
border: outlined ? "1px solid currentColor" : void 0,
|
|
18
22
|
borderRadius: "50%",
|
|
@@ -20,17 +24,31 @@ const StyledIcon = styled("span")(({ color, fontSize, spin, outlined }) => ({
|
|
|
20
24
|
"@keyframes spin": {
|
|
21
25
|
"0%": { transform: "rotate(0deg)" },
|
|
22
26
|
"100%": { transform: "rotate(360deg)" }
|
|
27
|
+
},
|
|
28
|
+
"& svg": {
|
|
29
|
+
width: "100%",
|
|
30
|
+
height: "100%",
|
|
31
|
+
fill: "currentColor",
|
|
32
|
+
display: "block"
|
|
33
|
+
},
|
|
34
|
+
"& img": {
|
|
35
|
+
width: "100%",
|
|
36
|
+
height: "100%",
|
|
37
|
+
display: "block"
|
|
23
38
|
}
|
|
24
39
|
}));
|
|
25
40
|
const Icon = ({
|
|
26
41
|
children,
|
|
42
|
+
path,
|
|
43
|
+
url,
|
|
44
|
+
alt = "icon",
|
|
45
|
+
viewBox = "0 0 24 24",
|
|
27
46
|
color = "var(--primary-color)",
|
|
28
47
|
outlined = false,
|
|
29
48
|
spin = false,
|
|
30
49
|
badge,
|
|
31
50
|
badgeColor = "primary",
|
|
32
51
|
badgePosition = { vertical: "bottom", horizontal: "right" },
|
|
33
|
-
badgeSize = "medium",
|
|
34
52
|
size = "sm",
|
|
35
53
|
black,
|
|
36
54
|
white,
|
|
@@ -42,6 +60,29 @@ const Icon = ({
|
|
|
42
60
|
return color;
|
|
43
61
|
}, [color, white, black]);
|
|
44
62
|
const iconSize = sizeMap[size];
|
|
63
|
+
const content = useMemo(() => {
|
|
64
|
+
if (children) return children;
|
|
65
|
+
if (path) {
|
|
66
|
+
const trimmed = path.trim();
|
|
67
|
+
if (trimmed.startsWith("<svg")) {
|
|
68
|
+
return /* @__PURE__ */ jsx("span", { dangerouslySetInnerHTML: { __html: trimmed } });
|
|
69
|
+
}
|
|
70
|
+
return /* @__PURE__ */ jsx(
|
|
71
|
+
"svg",
|
|
72
|
+
{
|
|
73
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
74
|
+
viewBox,
|
|
75
|
+
fill: "currentColor",
|
|
76
|
+
"aria-hidden": "true",
|
|
77
|
+
children: /* @__PURE__ */ jsx("path", { d: trimmed })
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
if (url) {
|
|
82
|
+
return /* @__PURE__ */ jsx("img", { src: url, alt });
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}, [children, path, url, alt, viewBox]);
|
|
45
86
|
return /* @__PURE__ */ jsx(
|
|
46
87
|
Badge,
|
|
47
88
|
{
|
|
@@ -58,7 +99,7 @@ const Icon = ({
|
|
|
58
99
|
spin,
|
|
59
100
|
outlined,
|
|
60
101
|
className: `hsi-icon ${className || ""}`,
|
|
61
|
-
children
|
|
102
|
+
children: content
|
|
62
103
|
}
|
|
63
104
|
)
|
|
64
105
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.js","sources":["../../../src/components/Icon/Icon.tsx"],"sourcesContent":["import React, { ReactNode, useMemo } from 'react';\nimport { Badge,
|
|
1
|
+
{"version":3,"file":"Icon.js","sources":["../../../src/components/Icon/Icon.tsx"],"sourcesContent":["import React, { type ReactNode, useMemo } from 'react';\nimport { Badge, styled } from '@mui/material';\n\nexport type IconSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n\nexport interface IconProps {\n /**\n * Contenido icono. Modo legacy: acepta un elemento MUI o SVG ya armado.\n * Si se usa junto con `path` o `url`, `children` tiene prioridad.\n */\n children?: ReactNode;\n /**\n * Ruta SVG inline (el contenido del atributo `d` de un `<path>`). Útil para\n * los iconos custom de Metronic que vienen como strings de path.\n *\n * ```tsx\n * <Icon path=\"M12 2L2 22h20L12 2z\" />\n * ```\n *\n * Si el string contiene el tag `<svg>` completo (no solo el `d`), también\n * se soporta y se inyecta tal cual via `dangerouslySetInnerHTML`.\n */\n path?: string;\n /**\n * URL a un archivo `.svg` (asset local o remoto). Se renderiza vía `<img>`.\n *\n * ```tsx\n * <Icon url=\"/assets/icons/custom-warning.svg\" />\n * ```\n */\n url?: string;\n /**\n * Alt text cuando se usa `url`. Default: `\"icon\"`.\n */\n alt?: string;\n /**\n * ViewBox cuando se usa `path`. Default: `\"0 0 24 24\"`. Ignorado si `path`\n * ya viene como `<svg>` completo.\n */\n viewBox?: string;\n color?: string;\n outlined?: boolean;\n spin?: boolean;\n badge?: string | number;\n badgeColor?: 'primary' | 'secondary' | 'error';\n badgePosition?: {\n vertical: 'top' | 'bottom';\n horizontal: 'right' | 'left';\n };\n badgeSize?: 'small' | 'medium' | 'large';\n size?: IconSize;\n black?: boolean;\n white?: boolean;\n className?: string;\n}\n\nconst sizeMap: Record<IconSize, number> = {\n xs: 18,\n sm: 24,\n md: 36,\n lg: 48,\n xl: 64,\n};\n\nconst StyledIcon = styled('span')<{\n color?: string;\n fontSize?: number;\n spin?: boolean;\n outlined?: boolean;\n}>(({ color, fontSize, spin, outlined }) => ({\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n color: color,\n fontSize: fontSize,\n width: fontSize,\n height: fontSize,\n animation: spin ? 'spin 1s linear infinite' : undefined,\n border: outlined ? '1px solid currentColor' : undefined,\n borderRadius: '50%',\n padding: outlined ? 4 : 0,\n '@keyframes spin': {\n '0%': { transform: 'rotate(0deg)' },\n '100%': { transform: 'rotate(360deg)' },\n },\n '& svg': {\n width: '100%',\n height: '100%',\n fill: 'currentColor',\n display: 'block',\n },\n '& img': {\n width: '100%',\n height: '100%',\n display: 'block',\n },\n}));\n\nexport const Icon: React.FC<IconProps> = ({\n children,\n path,\n url,\n alt = 'icon',\n viewBox = '0 0 24 24',\n color = 'var(--primary-color)',\n outlined = false,\n spin = false,\n badge,\n badgeColor = 'primary',\n badgePosition = { vertical: 'bottom', horizontal: 'right' },\n size = 'sm',\n black,\n white,\n className,\n}) => {\n const finalColor = useMemo(() => {\n if (white) return 'white';\n if (black) return 'black';\n return color;\n }, [color, white, black]);\n\n const iconSize = sizeMap[size];\n\n // Resolver el contenido según la prop activa.\n const content = useMemo(() => {\n if (children) return children;\n\n if (path) {\n const trimmed = path.trim();\n // Si es un SVG completo (empieza con <svg), lo inyectamos tal cual.\n if (trimmed.startsWith('<svg')) {\n return <span dangerouslySetInnerHTML={{ __html: trimmed }} />;\n }\n // Si no, asumimos que es el atributo `d` de un <path>.\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox={viewBox}\n fill=\"currentColor\"\n aria-hidden=\"true\"\n >\n <path d={trimmed} />\n </svg>\n );\n }\n\n if (url) {\n return <img src={url} alt={alt} />;\n }\n\n return null;\n }, [children, path, url, alt, viewBox]);\n\n return (\n <Badge\n badgeContent={badge}\n color={badgeColor}\n anchorOrigin={badgePosition}\n invisible={badge === undefined}\n sx={{ '.MuiBadge-badge': { transform: 'scale(1)' } }}\n >\n <StyledIcon\n color={finalColor}\n fontSize={iconSize}\n spin={spin}\n outlined={outlined}\n className={`hsi-icon ${className || ''}`}\n >\n {content}\n </StyledIcon>\n </Badge>\n );\n};\n\nexport default Icon;\n"],"names":[],"mappings":";;;;AAwDA,MAAM,UAAoC;AAAA,EACxC,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAEA,MAAM,aAAa,OAAO,MAAM,EAK7B,CAAC,EAAE,OAAO,UAAU,MAAM,gBAAgB;AAAA,EAC3C,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,WAAW,OAAO,4BAA4B;AAAA,EAC9C,QAAQ,WAAW,2BAA2B;AAAA,EAC9C,cAAc;AAAA,EACd,SAAS,WAAW,IAAI;AAAA,EACxB,mBAAmB;AAAA,IACjB,MAAM,EAAE,WAAW,eAAA;AAAA,IACnB,QAAQ,EAAE,WAAW,iBAAA;AAAA,EAAiB;AAAA,EAExC,SAAS;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,EAAA;AAAA,EAEX,SAAS;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,EAAA;AAEb,EAAE;AAEK,MAAM,OAA4B,CAAC;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAM;AAAA,EACN,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,OAAO;AAAA,EACP;AAAA,EACA,aAAa;AAAA,EACb,gBAAgB,EAAE,UAAU,UAAU,YAAY,QAAA;AAAA,EAClD,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,aAAa,QAAQ,MAAM;AAC/B,QAAI,MAAO,QAAO;AAClB,QAAI,MAAO,QAAO;AAClB,WAAO;AAAA,EACT,GAAG,CAAC,OAAO,OAAO,KAAK,CAAC;AAExB,QAAM,WAAW,QAAQ,IAAI;AAG7B,QAAM,UAAU,QAAQ,MAAM;AAC5B,QAAI,SAAU,QAAO;AAErB,QAAI,MAAM;AACR,YAAM,UAAU,KAAK,KAAA;AAErB,UAAI,QAAQ,WAAW,MAAM,GAAG;AAC9B,mCAAQ,QAAA,EAAK,yBAAyB,EAAE,QAAQ,WAAW;AAAA,MAC7D;AAEA,aACE;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,OAAM;AAAA,UACN;AAAA,UACA,MAAK;AAAA,UACL,eAAY;AAAA,UAEZ,UAAA,oBAAC,QAAA,EAAK,GAAG,QAAA,CAAS;AAAA,QAAA;AAAA,MAAA;AAAA,IAGxB;AAEA,QAAI,KAAK;AACP,aAAO,oBAAC,OAAA,EAAI,KAAK,KAAK,IAAA,CAAU;AAAA,IAClC;AAEA,WAAO;AAAA,EACT,GAAG,CAAC,UAAU,MAAM,KAAK,KAAK,OAAO,CAAC;AAEtC,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,cAAc;AAAA,MACd,OAAO;AAAA,MACP,cAAc;AAAA,MACd,WAAW,UAAU;AAAA,MACrB,IAAI,EAAE,mBAAmB,EAAE,WAAW,aAAW;AAAA,MAEjD,UAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,OAAO;AAAA,UACP,UAAU;AAAA,UACV;AAAA,UACA;AAAA,UACA,WAAW,YAAY,aAAa,EAAE;AAAA,UAErC,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACH;AAAA,EAAA;AAGN;"}
|
|
@@ -1,5 +1,175 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
34
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
35
|
+
const material = require("@mui/material");
|
|
36
|
+
const styles = require("@mui/material/styles");
|
|
37
|
+
const reactHookForm = require("react-hook-form");
|
|
38
|
+
const formField_sx = require("../../formField.sx-CQ1mbk9M.cjs");
|
|
39
|
+
const resolvePreset = require("../../resolvePreset-CT3kU-K2.cjs");
|
|
40
|
+
const parseValue = (raw, type) => {
|
|
41
|
+
if (type !== "number") return raw;
|
|
42
|
+
if (raw === "" || raw === "-") return raw;
|
|
43
|
+
const n = parseFloat(raw);
|
|
44
|
+
return isNaN(n) ? raw : n;
|
|
45
|
+
};
|
|
46
|
+
const buildSlotProps = (type, min, max, customSlotProps, customInputProps, _labelPosition, readOnly) => {
|
|
47
|
+
const numberAttrs = type === "number" ? __spreadValues({ min: min != null ? min : Number.NEGATIVE_INFINITY }, max !== void 0 && { max }) : {};
|
|
48
|
+
return __spreadProps(__spreadValues({}, customSlotProps), {
|
|
49
|
+
htmlInput: __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, customInputProps), customSlotProps == null ? void 0 : customSlotProps.htmlInput), numberAttrs), readOnly && { readOnly: true }),
|
|
50
|
+
// Dejamos que MUI maneje el shrink nativamente (animación inside → up).
|
|
51
|
+
// El consumidor puede forzar shrink con slotProps.inputLabel.shrink=true si lo necesita.
|
|
52
|
+
inputLabel: __spreadValues({}, customSlotProps == null ? void 0 : customSlotProps.inputLabel)
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
const buildInputSx = (borderRadius, labelPosition) => {
|
|
56
|
+
const radius = typeof borderRadius === "number" ? `${borderRadius}px` : borderRadius;
|
|
57
|
+
return formField_sx.buildFormFieldSx({
|
|
58
|
+
borderRadius,
|
|
59
|
+
labelPosition,
|
|
60
|
+
extraOutsideSx: {
|
|
61
|
+
"& .MuiInputBase-input": {
|
|
62
|
+
paddingTop: formField_sx.FIELD_INPUT_PADDING_Y,
|
|
63
|
+
paddingBottom: formField_sx.FIELD_INPUT_PADDING_Y
|
|
64
|
+
},
|
|
65
|
+
// Filled: quitar el padding-top reservado para el label flotante dentro.
|
|
66
|
+
"& .MuiFilledInput-root": {
|
|
67
|
+
paddingTop: 0,
|
|
68
|
+
borderRadius: `${radius} ${radius} 0 0`
|
|
69
|
+
},
|
|
70
|
+
"& .MuiFilledInput-input": {
|
|
71
|
+
paddingTop: formField_sx.FIELD_INPUT_PADDING_Y
|
|
72
|
+
},
|
|
73
|
+
// Standard: quitar el margin-top reservado para el label flotante.
|
|
74
|
+
"& .MuiInput-root": {
|
|
75
|
+
marginTop: 0
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
const Input = (props) => {
|
|
81
|
+
const _a = props, {
|
|
82
|
+
type = "text",
|
|
83
|
+
variant = "outlined",
|
|
84
|
+
size = "small",
|
|
85
|
+
borderRadius = 10,
|
|
86
|
+
labelPosition = "outside",
|
|
87
|
+
preset,
|
|
88
|
+
min,
|
|
89
|
+
max,
|
|
90
|
+
readOnly,
|
|
91
|
+
inputProps,
|
|
92
|
+
slotProps,
|
|
93
|
+
sx
|
|
94
|
+
} = _a, rest = __objRest(_a, [
|
|
95
|
+
"type",
|
|
96
|
+
"variant",
|
|
97
|
+
"size",
|
|
98
|
+
"borderRadius",
|
|
99
|
+
"labelPosition",
|
|
100
|
+
"preset",
|
|
101
|
+
"min",
|
|
102
|
+
"max",
|
|
103
|
+
"readOnly",
|
|
104
|
+
"inputProps",
|
|
105
|
+
"slotProps",
|
|
106
|
+
"sx"
|
|
107
|
+
]);
|
|
108
|
+
const theme = styles.useTheme();
|
|
109
|
+
const presetSx = resolvePreset.resolvePreset("Input", preset, theme);
|
|
110
|
+
const finalSlotProps = buildSlotProps(
|
|
111
|
+
type,
|
|
112
|
+
min,
|
|
113
|
+
max,
|
|
114
|
+
slotProps,
|
|
115
|
+
inputProps,
|
|
116
|
+
labelPosition,
|
|
117
|
+
readOnly
|
|
118
|
+
);
|
|
119
|
+
const mergedSx = [
|
|
120
|
+
buildInputSx(borderRadius, labelPosition),
|
|
121
|
+
...presetSx ? [presetSx] : [],
|
|
122
|
+
...Array.isArray(sx) ? sx : [sx]
|
|
123
|
+
];
|
|
124
|
+
if ("control" in props && props.control) {
|
|
125
|
+
const { name, control, validation } = props;
|
|
126
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
127
|
+
reactHookForm.Controller,
|
|
128
|
+
{
|
|
129
|
+
name,
|
|
130
|
+
control,
|
|
131
|
+
rules: validation,
|
|
132
|
+
render: ({ field, fieldState: { error } }) => {
|
|
133
|
+
var _a2, _b;
|
|
134
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
135
|
+
material.TextField,
|
|
136
|
+
__spreadProps(__spreadValues({
|
|
137
|
+
fullWidth: true
|
|
138
|
+
}, rest), {
|
|
139
|
+
name: field.name,
|
|
140
|
+
value: (_a2 = field.value) != null ? _a2 : "",
|
|
141
|
+
onChange: (e) => field.onChange(parseValue(e.target.value, type)),
|
|
142
|
+
onBlur: field.onBlur,
|
|
143
|
+
inputRef: field.ref,
|
|
144
|
+
type,
|
|
145
|
+
variant,
|
|
146
|
+
size,
|
|
147
|
+
slotProps: finalSlotProps,
|
|
148
|
+
sx: mergedSx,
|
|
149
|
+
error: !!error || rest.error,
|
|
150
|
+
helperText: (_b = error == null ? void 0 : error.message) != null ? _b : rest.helperText
|
|
151
|
+
})
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
const { value, onChange } = props;
|
|
158
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
159
|
+
material.TextField,
|
|
160
|
+
__spreadProps(__spreadValues({
|
|
161
|
+
fullWidth: true
|
|
162
|
+
}, rest), {
|
|
163
|
+
value: value != null ? value : "",
|
|
164
|
+
onChange: (e) => onChange(parseValue(e.target.value, type)),
|
|
165
|
+
type,
|
|
166
|
+
variant,
|
|
167
|
+
size,
|
|
168
|
+
slotProps: finalSlotProps,
|
|
169
|
+
sx: mergedSx
|
|
170
|
+
})
|
|
171
|
+
);
|
|
172
|
+
};
|
|
173
|
+
exports.Input = Input;
|
|
174
|
+
exports.default = Input;
|
|
5
175
|
//# sourceMappingURL=Input.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Input.cjs","sources":["../../../src/components/Input/Input.helpers.ts","../../../src/components/Input/Input.sx.ts","../../../src/components/Input/Input.tsx"],"sourcesContent":["import type { InputHTMLAttributes } from 'react';\nimport type { TextFieldProps } from '@mui/material';\nimport type { InputType, LabelPosition } from './Input';\n\n/**\n * Convierte el valor raw del evento al tipo apropiado.\n * Para type=\"number\" intenta parsear a número; si falla, devuelve el raw\n * (permite estados intermedios como \"\" o \"-\" mientras el usuario tipea).\n */\nexport const parseValue = (raw: string, type: InputType): string | number => {\n if (type !== 'number') return raw;\n if (raw === '' || raw === '-') return raw;\n const n = parseFloat(raw);\n return isNaN(n) ? raw : n;\n};\n\n/**\n * Construye los slotProps del TextField consolidando htmlInput + inputLabel.\n * Maneja los atributos min/max cuando type=\"number\" y readOnly.\n */\nexport const buildSlotProps = (\n type: InputType,\n min: number | undefined,\n max: number | undefined,\n customSlotProps: TextFieldProps['slotProps'],\n customInputProps: InputHTMLAttributes<HTMLInputElement> | undefined,\n _labelPosition: LabelPosition,\n readOnly?: boolean,\n): TextFieldProps['slotProps'] => {\n const numberAttrs =\n type === 'number'\n ? { min: min ?? Number.NEGATIVE_INFINITY, ...(max !== undefined && { max }) }\n : {};\n\n return {\n ...customSlotProps,\n htmlInput: {\n ...customInputProps,\n ...(customSlotProps as any)?.htmlInput,\n ...numberAttrs,\n ...(readOnly && { readOnly: true }),\n },\n // Dejamos que MUI maneje el shrink nativamente (animación inside → up).\n // El consumidor puede forzar shrink con slotProps.inputLabel.shrink=true si lo necesita.\n inputLabel: {\n ...(customSlotProps as any)?.inputLabel,\n },\n };\n};\n","import type { TextFieldProps } from '@mui/material';\n\nimport { buildFormFieldSx } from '../_shared/formField.sx';\nimport { FIELD_INPUT_PADDING_Y } from '../../theme/tokens';\nimport type { LabelPosition } from './Input';\n\n/**\n * Builder de sx para el Input. Usa el builder compartido\n * `buildFormFieldSx` y añade overrides específicos de TextField\n * (padding del input base, filled, standard).\n */\nexport const buildInputSx = (\n borderRadius: number | string,\n labelPosition: LabelPosition,\n): TextFieldProps['sx'] => {\n const radius = typeof borderRadius === 'number' ? `${borderRadius}px` : borderRadius;\n\n return buildFormFieldSx({\n borderRadius,\n labelPosition,\n extraOutsideSx: {\n '& .MuiInputBase-input': {\n paddingTop: FIELD_INPUT_PADDING_Y,\n paddingBottom: FIELD_INPUT_PADDING_Y,\n },\n\n // Filled: quitar el padding-top reservado para el label flotante dentro.\n '& .MuiFilledInput-root': {\n paddingTop: 0,\n borderRadius: `${radius} ${radius} 0 0`,\n },\n '& .MuiFilledInput-input': {\n paddingTop: FIELD_INPUT_PADDING_Y,\n },\n\n // Standard: quitar el margin-top reservado para el label flotante.\n '& .MuiInput-root': {\n marginTop: 0,\n },\n },\n });\n};\n","import { TextField, type TextFieldProps } from '@mui/material';\nimport { useTheme } from '@mui/material/styles';\nimport { Controller, type Control, type RegisterOptions } from 'react-hook-form';\n\nimport { parseValue, buildSlotProps } from './Input.helpers';\nimport { buildInputSx } from './Input.sx';\nimport { resolvePreset } from '../_shared/resolvePreset';\n\n// ── Tipos de dominio ─────────────────────────────────────────────────────\nexport type InputType =\n | 'text' | 'number' | 'email' | 'password' | 'tel'\n | 'url' | 'search' | 'date' | 'datetime-local'\n | 'month' | 'week' | 'time' | 'color';\n\nexport type LabelPosition = 'outside' | 'floating';\n\n// ── Props base (todo lo común entre RHF y controlado) ────────────────────\nexport interface BaseInputProps\n extends Omit<TextFieldProps, 'value' | 'onChange' | 'type'> {\n type?: InputType;\n min?: number;\n max?: number;\n /** Border radius del input. Default: 10 */\n borderRadius?: number | string;\n /** \"outside\" = label arriba del campo (default). \"floating\" = label clásico MUI dentro del borde */\n labelPosition?: LabelPosition;\n readOnly?: boolean;\n /**\n * Nombre del preset de estilo registrado en `theme.styles.Input`.\n * - `\"default\"` (o ausente) = estilo built-in del paquete.\n * - Cualquier otro string = mergea el preset encima del estilo built-in.\n */\n preset?: string;\n}\n\n// ── Variantes discriminadas (RHF vs controlado) ──────────────────────────\nexport interface RHFInputProps extends BaseInputProps {\n name: string;\n control: Control<any>;\n validation?: RegisterOptions;\n value?: never;\n onChange?: never;\n}\n\nexport interface ControlledInputProps extends BaseInputProps {\n name?: string;\n control?: never;\n validation?: never;\n value: string | number;\n onChange: (value: string | number) => void;\n}\n\n// ── API pública final ────────────────────────────────────────────────────\nexport type InputProps = RHFInputProps | ControlledInputProps;\n\nexport const Input: React.FC<InputProps> = (props) => {\n const {\n type = 'text',\n variant = 'outlined',\n size = 'small',\n borderRadius = 10,\n labelPosition = 'outside',\n preset,\n min,\n max,\n readOnly,\n inputProps,\n slotProps,\n sx,\n ...rest\n } = props as ControlledInputProps & {\n control?: Control<any>;\n validation?: RegisterOptions;\n readOnly?: boolean;\n preset?: string;\n };\n\n const theme = useTheme();\n const presetSx = resolvePreset('Input', preset, theme);\n\n const finalSlotProps = buildSlotProps(\n type,\n min,\n max,\n slotProps,\n inputProps,\n labelPosition,\n readOnly,\n );\n const mergedSx = [\n buildInputSx(borderRadius, labelPosition),\n ...(presetSx ? [presetSx] : []),\n ...(Array.isArray(sx) ? sx : [sx]),\n ];\n\n if ('control' in props && props.control) {\n const { name, control, validation } = props as RHFInputProps;\n return (\n <Controller\n name={name}\n control={control}\n rules={validation}\n render={({ field, fieldState: { error } }) => (\n <TextField\n fullWidth\n {...rest}\n name={field.name}\n value={field.value ?? ''}\n onChange={(e) => field.onChange(parseValue(e.target.value, type))}\n onBlur={field.onBlur}\n inputRef={field.ref}\n type={type}\n variant={variant}\n size={size}\n slotProps={finalSlotProps}\n sx={mergedSx}\n error={!!error || rest.error}\n helperText={error?.message ?? rest.helperText}\n />\n )}\n />\n );\n }\n\n const { value, onChange } = props as ControlledInputProps;\n return (\n <TextField\n fullWidth\n {...rest}\n value={value ?? ''}\n onChange={(e) => onChange(parseValue(e.target.value, type))}\n type={type}\n variant={variant}\n size={size}\n slotProps={finalSlotProps}\n sx={mergedSx}\n />\n );\n};\n\nexport default Input;\n"],"names":["buildFormFieldSx","FIELD_INPUT_PADDING_Y","useTheme","resolvePreset","jsx","Controller","TextField","_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASO,MAAM,aAAa,CAAC,KAAa,SAAqC;AAC3E,MAAI,SAAS,SAAU,QAAO;AAC9B,MAAI,QAAQ,MAAM,QAAQ,IAAK,QAAO;AACtC,QAAM,IAAI,WAAW,GAAG;AACxB,SAAO,MAAM,CAAC,IAAI,MAAM;AAC1B;AAMO,MAAM,iBAAiB,CAC5B,MACA,KACA,KACA,iBACA,kBACA,gBACA,aACgC;AAChC,QAAM,cACJ,SAAS,WACL,iBAAE,KAAK,oBAAO,OAAO,qBAAuB,QAAQ,UAAa,EAAE,IAAA,KACnE,CAAA;AAEN,SAAO,iCACF,kBADE;AAAA,IAEL,WAAW,gEACN,mBACC,mDAAyB,YAC1B,cACC,YAAY,EAAE,UAAU,KAAA;AAAA;AAAA;AAAA,IAI9B,YAAY,mBACN,mDAAyB;AAAA,EAC/B;AAEJ;ACrCO,MAAM,eAAe,CAC1B,cACA,kBACyB;AACzB,QAAM,SAAS,OAAO,iBAAiB,WAAW,GAAG,YAAY,OAAO;AAExE,SAAOA,8BAAiB;AAAA,IACtB;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,MACd,yBAAyB;AAAA,QACvB,YAAYC,aAAAA;AAAAA,QACZ,eAAeA,aAAAA;AAAAA,MAAA;AAAA;AAAA,MAIjB,0BAA0B;AAAA,QACxB,YAAY;AAAA,QACZ,cAAc,GAAG,MAAM,IAAI,MAAM;AAAA,MAAA;AAAA,MAEnC,2BAA2B;AAAA,QACzB,YAAYA,aAAAA;AAAAA,MAAA;AAAA;AAAA,MAId,oBAAoB;AAAA,QAClB,WAAW;AAAA,MAAA;AAAA,IACb;AAAA,EACF,CACD;AACH;ACcO,MAAM,QAA8B,CAAC,UAAU;AACpD,QAcI,YAbF;AAAA,WAAO;AAAA,IACP,UAAU;AAAA,IACV,OAAO;AAAA,IACP,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MAEE,IADC,iBACD,IADC;AAAA,IAZH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AASF,QAAM,QAAQC,OAAAA,SAAA;AACd,QAAM,WAAWC,cAAAA,cAAc,SAAS,QAAQ,KAAK;AAErD,QAAM,iBAAiB;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEF,QAAM,WAAW;AAAA,IACf,aAAa,cAAc,aAAa;AAAA,IACxC,GAAI,WAAW,CAAC,QAAQ,IAAI,CAAA;AAAA,IAC5B,GAAI,MAAM,QAAQ,EAAE,IAAI,KAAK,CAAC,EAAE;AAAA,EAAA;AAGlC,MAAI,aAAa,SAAS,MAAM,SAAS;AACvC,UAAM,EAAE,MAAM,SAAS,WAAA,IAAe;AACtC,WACEC,2BAAAA;AAAAA,MAACC,cAAAA;AAAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA,OAAO;AAAA,QACP,QAAQ,CAAC,EAAE,OAAO,YAAY,EAAE,MAAA;;AAC9BD,4CAAAA;AAAAA,YAACE,SAAAA;AAAAA,YAAA;AAAA,cACC,WAAS;AAAA,eACL,OAFL;AAAA,cAGC,MAAM,MAAM;AAAA,cACZ,QAAOC,MAAA,MAAM,UAAN,OAAAA,MAAe;AAAA,cACtB,UAAU,CAAC,MAAM,MAAM,SAAS,WAAW,EAAE,OAAO,OAAO,IAAI,CAAC;AAAA,cAChE,QAAQ,MAAM;AAAA,cACd,UAAU,MAAM;AAAA,cAChB;AAAA,cACA;AAAA,cACA;AAAA,cACA,WAAW;AAAA,cACX,IAAI;AAAA,cACJ,OAAO,CAAC,CAAC,SAAS,KAAK;AAAA,cACvB,aAAY,oCAAO,YAAP,YAAkB,KAAK;AAAA,YAAA;AAAA,UAAA;AAAA;AAAA,MACrC;AAAA,IAAA;AAAA,EAIR;AAEA,QAAM,EAAE,OAAO,SAAA,IAAa;AAC5B,SACEH,2BAAAA;AAAAA,IAACE,SAAAA;AAAAA,IAAA;AAAA,MACC,WAAS;AAAA,OACL,OAFL;AAAA,MAGC,OAAO,wBAAS;AAAA,MAChB,UAAU,CAAC,MAAM,SAAS,WAAW,EAAE,OAAO,OAAO,IAAI,CAAC;AAAA,MAC1D;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,MACX,IAAI;AAAA,IAAA;AAAA,EAAA;AAGV;;;"}
|
|
@@ -1,32 +1,37 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
1
|
import { TextFieldProps } from '@mui/material';
|
|
3
2
|
import { Control, RegisterOptions } from 'react-hook-form';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
export type InputType = 'text' | 'number' | 'email' | 'password' | 'tel' | 'url' | 'search' | 'date' | 'datetime-local' | 'month' | 'week' | 'time' | 'color';
|
|
4
|
+
export type LabelPosition = 'outside' | 'floating';
|
|
5
|
+
export interface BaseInputProps extends Omit<TextFieldProps, 'value' | 'onChange' | 'type'> {
|
|
6
|
+
type?: InputType;
|
|
7
7
|
min?: number;
|
|
8
8
|
max?: number;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
/** Border radius del input. Default: 10 */
|
|
10
|
+
borderRadius?: number | string;
|
|
11
|
+
/** "outside" = label arriba del campo (default). "floating" = label clásico MUI dentro del borde */
|
|
12
|
+
labelPosition?: LabelPosition;
|
|
12
13
|
readOnly?: boolean;
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Nombre del preset de estilo registrado en `theme.styles.Input`.
|
|
16
|
+
* - `"default"` (o ausente) = estilo built-in del paquete.
|
|
17
|
+
* - Cualquier otro string = mergea el preset encima del estilo built-in.
|
|
18
|
+
*/
|
|
19
|
+
preset?: string;
|
|
15
20
|
}
|
|
16
|
-
interface RHFInputProps extends BaseInputProps {
|
|
21
|
+
export interface RHFInputProps extends BaseInputProps {
|
|
17
22
|
name: string;
|
|
18
23
|
control: Control<any>;
|
|
19
24
|
validation?: RegisterOptions;
|
|
20
|
-
value?:
|
|
21
|
-
onChange?:
|
|
25
|
+
value?: never;
|
|
26
|
+
onChange?: never;
|
|
22
27
|
}
|
|
23
|
-
interface
|
|
28
|
+
export interface ControlledInputProps extends BaseInputProps {
|
|
24
29
|
name?: string;
|
|
25
30
|
control?: never;
|
|
26
31
|
validation?: never;
|
|
27
32
|
value: string | number;
|
|
28
33
|
onChange: (value: string | number) => void;
|
|
29
34
|
}
|
|
30
|
-
export type InputProps = RHFInputProps |
|
|
31
|
-
export declare const Input: React.
|
|
35
|
+
export type InputProps = RHFInputProps | ControlledInputProps;
|
|
36
|
+
export declare const Input: React.FC<InputProps>;
|
|
32
37
|
export default Input;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
export declare const BasicTextInputDefinition = "\nimport React, { useState } from 'react';\nimport { Input } from './Input'; // Ajusta la ruta si es necesario\nimport { Box, Typography } from '@mui/material';\n\nexport const BasicTextInputExample = () => {\n const [value, setValue] = useState('Texto de ejemplo');\n return (\n <Box sx={{ width: 300 }}>\n <Input\n label=\"Nombre\"\n value={value}\n onChange={setValue}\n />\n <Typography sx={{ mt: 2 }}>Valor actual: {value}</Typography>\n </Box>\n );\n};\n";
|
|
2
2
|
export declare const NumberInputDefinition = "\nimport React, { useState } from 'react';\nimport { Input } from './Input'; // Ajusta la ruta si es necesario\nimport { Box, Typography } from '@mui/material';\n\nexport const NumberInputExample = () => {\n const [value, setValue] = useState(123);\n return (\n <Box sx={{ width: 300 }}>\n <Input\n label=\"Cantidad\"\n type=\"number\"\n value={value}\n onChange={setValue}\n />\n <Typography sx={{ mt: 2 }}>Valor actual: {value}</Typography>\n </Box>\n );\n};\n";
|
|
3
|
-
export declare const EmailInputDefinition = "\nimport React, { useState }
|
|
3
|
+
export declare const EmailInputDefinition = "\nimport React, { useState } from 'react';\nimport { Input } from './Input'; // Ajusta la ruta si es necesario\nimport { Box, Typography } from '@mui/material';\n\nexport const EmailInputExample = () => {\n const [value, setValue] = useState('ejemplo@dominio.com');\n return (\n <Box sx={{ width: 300 }}>\n <Input\n label=\"Correo Electr\u00F3nico\"\n type=\"email\"\n value={value}\n onChange={setValue}\n />\n <Typography sx={{ mt: 2 }}>Valor actual: {value}</Typography>\n </Box>\n );\n};\n";
|
|
4
4
|
export declare const PasswordInputDefinition = "\nimport React, { useState } from 'react';\nimport { Input } from './Input'; // Ajusta la ruta si es necesario\nimport { Box, Typography } from '@mui/material';\n\nexport const PasswordInputExample = () => {\n const [value, setValue] = useState('micontrase\u00F1a');\n return (\n <Box sx={{ width: 300 }}>\n <Input\n label=\"Contrase\u00F1a\"\n type=\"password\"\n value={value}\n onChange={setValue}\n />\n <Typography sx={{ mt: 2 }}>Valor actual: {value}</Typography>\n </Box>\n );\n};\n";
|
|
5
5
|
export declare const InputWithPlaceholderDefinition = "\nimport React, { useState } from 'react';\nimport { Input } from './Input'; // Ajusta la ruta si es necesario\nimport { Box, Typography } from '@mui/material';\n\nexport const InputWithPlaceholderExample = () => {\n const [value, setValue] = useState('');\n return (\n <Box sx={{ width: 300 }}>\n <Input\n label=\"B\u00FAsqueda\"\n placeholder=\"Escribe tu t\u00E9rmino de b\u00FAsqueda...\"\n value={value}\n onChange={setValue}\n />\n <Typography sx={{ mt: 2 }}>Valor actual: {value || 'Vac\u00EDo'}</Typography>\n </Box>\n );\n};\n";
|
|
6
6
|
export declare const InputWithErrorDefinition = "\nimport React, { useState } from 'react';\nimport { Input } from './Input'; // Ajusta la ruta si es necesario\nimport { Box, Typography } from '@mui/material';\n\nexport const InputWithErrorExample = () => {\n const [value, setValue] = useState('invalido');\n const hasError = value.length < 5 && value.length > 0;\n return (\n <Box sx={{ width: 300 }}>\n <Input\n label=\"Nombre de usuario\"\n value={value}\n onChange={setValue}\n error={hasError}\n helperText={hasError ? 'M\u00EDnimo 5 caracteres' : ''}\n />\n <Typography sx={{ mt: 2 }}>Valor actual: {value}</Typography>\n </Box>\n );\n};\n";
|
|
7
7
|
export declare const DisabledInputDefinition = "\nimport React, { useState } from 'react';\nimport { Input } from './Input'; // Ajusta la ruta si es necesario\nimport { Box, Typography } from '@mui/material';\n\nexport const DisabledInputExample = () => {\n const [value, setValue] = useState('Campo deshabilitado');\n return (\n <Box sx={{ width: 300 }}>\n <Input\n label=\"Estado\"\n value={value}\n onChange={setValue}\n disabled\n />\n <Typography sx={{ mt: 2 }}>Valor actual: {value}</Typography>\n </Box>\n );\n};\n";
|
|
8
|
-
export declare const ReadOnlyInputDefinition = "\nimport React, { useState }
|
|
8
|
+
export declare const ReadOnlyInputDefinition = "\nimport React, { useState } from 'react';\nimport { Input } from './Input'; // Ajusta la ruta si es necesario\nimport { Box, Typography } from '@mui/material';\n\nexport const ReadOnlyInputExample = () => {\n const [value, setValue] = useState('Valor de solo lectura');\n return (\n <Box sx={{ width: 300 }}>\n <Input\n label=\"Informaci\u00F3n\"\n value={value}\n onChange={setValue}\n readOnly\n />\n <Typography sx={{ mt: 2 }}>Valor actual: {value}</Typography>\n </Box>\n );\n};\n";
|
|
9
9
|
export declare const InputVariantsDefinition = "\nimport React, { useState } from 'react';\nimport { Input } from './Input'; // Ajusta la ruta si es necesario\nimport { Box, Typography } from '@mui/material';\n\nexport const InputVariantsExample = () => {\n const [valueOutlined, setValueOutlined] = useState('Outlined');\n const [valueFilled, setValueFilled] = useState('Filled');\n const [valueStandard, setValueStandard] = useState('Standard');\n return (\n <Box sx={{ display: 'flex', flexDirection: 'column', gap: 3, width: 300 }}>\n <Input\n label=\"Esquema Outlined\"\n value={valueOutlined}\n onChange={setValueOutlined}\n variant=\"outlined\"\n />\n <Input\n label=\"Esquema Filled\"\n value={valueFilled}\n onChange={setValueFilled}\n variant=\"filled\"\n />\n <Input\n label=\"Esquema Standard\"\n value={valueStandard}\n onChange={setValueStandard}\n variant=\"standard\"\n />\n </Box>\n );\n};\n";
|
|
10
10
|
export declare const InputSizesDefinition = "\nimport React, { useState } from 'react';\nimport { Input } from './Input'; // Ajusta la ruta si es necesario\nimport { Box, Typography } from '@mui/material';\n\nexport const InputSizesExample = () => {\n const [valueMedium, setValueMedium] = useState('Tama\u00F1o Mediano');\n const [valueSmall, setValueSmall] = useState('Tama\u00F1o Peque\u00F1o');\n return (\n <Box sx={{ display: 'flex', flexDirection: 'column', gap: 3, width: 300 }}>\n <Input\n label=\"Input Mediano\"\n value={valueMedium}\n onChange={setValueMedium}\n size=\"medium\"\n />\n <Input\n label=\"Input Peque\u00F1o\"\n value={valueSmall}\n onChange={setValueSmall}\n size=\"small\"\n />\n </Box>\n );\n};\n";
|
|
11
11
|
export declare const FullWidthInputDefinition = "\nimport React, { useState } from 'react';\nimport { Input } from './Input'; // Ajusta la ruta si es necesario\nimport { Box, Typography } from '@mui/material';\n\nexport const FullWidthInputExample = () => {\n const [value, setValue] = useState('Ocupa todo el ancho');\n return (\n <Box sx={{ width: '100%' }}>\n <Input\n label=\"Input de Ancho Completo\"\n value={value}\n onChange={setValue}\n fullWidth\n />\n <Typography sx={{ mt: 2 }}>Valor actual: {value}</Typography>\n </Box>\n );\n};\n";
|
|
12
|
+
export declare const LabelPositionFloatingDefinition = "\nimport React, { useState } from 'react';\nimport { Input } from './Input'; // Ajusta la ruta si es necesario\nimport { Box } from '@mui/material';\n\nexport const LabelPositionExample = () => {\n const [outside, setOutside] = useState('Outside (default)');\n const [floating, setFloating] = useState('Floating');\n return (\n <Box sx={{ display: 'flex', flexDirection: 'column', gap: 3, width: 300 }}>\n <Input\n label=\"Label outside\"\n value={outside}\n onChange={setOutside}\n labelPosition=\"outside\"\n />\n <Input\n label=\"Label floating (MUI cl\u00E1sico)\"\n value={floating}\n onChange={setFloating}\n labelPosition=\"floating\"\n />\n </Box>\n );\n};\n";
|
|
13
|
+
export declare const CustomBorderRadiusDefinition = "\nimport React, { useState } from 'react';\nimport { Input } from './Input'; // Ajusta la ruta si es necesario\nimport { Box } from '@mui/material';\n\nexport const CustomBorderRadiusExample = () => {\n const [v, setV] = useState('Texto');\n return (\n <Box sx={{ display: 'flex', flexDirection: 'column', gap: 3, width: 300 }}>\n <Input label=\"Sin radius\" value={v} onChange={setV} borderRadius={0} />\n <Input label=\"Radius 4px\" value={v} onChange={setV} borderRadius={4} />\n <Input label=\"Default (10px)\" value={v} onChange={setV} />\n <Input label=\"Pill (24px)\" value={v} onChange={setV} borderRadius={24} />\n </Box>\n );\n};\n";
|
|
14
|
+
export declare const CustomStylingDefinition = "\nimport React, { useState } from 'react';\nimport { Input } from './Input'; // Ajusta la ruta si es necesario\nimport { Box } from '@mui/material';\n\nexport const CustomStylingExample = () => {\n const [v, setV] = useState('Custom completo');\n return (\n <Box sx={{ width: 300 }}>\n <Input\n label=\"Combinado: bg + borderColor + label color\"\n value={v}\n onChange={setV}\n sx={{\n '& .MuiInputLabel-root': { color: 'primary.main' },\n '& .MuiOutlinedInput-root': { bgcolor: '#fff7e6' },\n '& .MuiOutlinedInput-notchedOutline': {\n borderColor: 'warning.main',\n borderWidth: 2,\n },\n }}\n />\n </Box>\n );\n};\n";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from 'react';
|
|
2
|
+
import { TextFieldProps } from '@mui/material';
|
|
3
|
+
import { InputType, LabelPosition } from './Input';
|
|
4
|
+
/**
|
|
5
|
+
* Convierte el valor raw del evento al tipo apropiado.
|
|
6
|
+
* Para type="number" intenta parsear a número; si falla, devuelve el raw
|
|
7
|
+
* (permite estados intermedios como "" o "-" mientras el usuario tipea).
|
|
8
|
+
*/
|
|
9
|
+
export declare const parseValue: (raw: string, type: InputType) => string | number;
|
|
10
|
+
/**
|
|
11
|
+
* Construye los slotProps del TextField consolidando htmlInput + inputLabel.
|
|
12
|
+
* Maneja los atributos min/max cuando type="number" y readOnly.
|
|
13
|
+
*/
|
|
14
|
+
export declare const buildSlotProps: (type: InputType, min: number | undefined, max: number | undefined, customSlotProps: TextFieldProps["slotProps"], customInputProps: InputHTMLAttributes<HTMLInputElement> | undefined, _labelPosition: LabelPosition, readOnly?: boolean) => TextFieldProps["slotProps"];
|
|
@@ -1,5 +1,175 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import { jsx } from "react/jsx-runtime";
|
|
33
|
+
import { TextField } from "@mui/material";
|
|
34
|
+
import { useTheme } from "@mui/material/styles";
|
|
35
|
+
import { Controller } from "react-hook-form";
|
|
36
|
+
import { b as buildFormFieldSx, F as FIELD_INPUT_PADDING_Y } from "../../formField.sx-DfVbMe0V.js";
|
|
37
|
+
import { r as resolvePreset } from "../../resolvePreset-B-IB0ehH.js";
|
|
38
|
+
const parseValue = (raw, type) => {
|
|
39
|
+
if (type !== "number") return raw;
|
|
40
|
+
if (raw === "" || raw === "-") return raw;
|
|
41
|
+
const n = parseFloat(raw);
|
|
42
|
+
return isNaN(n) ? raw : n;
|
|
43
|
+
};
|
|
44
|
+
const buildSlotProps = (type, min, max, customSlotProps, customInputProps, _labelPosition, readOnly) => {
|
|
45
|
+
const numberAttrs = type === "number" ? __spreadValues({ min: min != null ? min : Number.NEGATIVE_INFINITY }, max !== void 0 && { max }) : {};
|
|
46
|
+
return __spreadProps(__spreadValues({}, customSlotProps), {
|
|
47
|
+
htmlInput: __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, customInputProps), customSlotProps == null ? void 0 : customSlotProps.htmlInput), numberAttrs), readOnly && { readOnly: true }),
|
|
48
|
+
// Dejamos que MUI maneje el shrink nativamente (animación inside → up).
|
|
49
|
+
// El consumidor puede forzar shrink con slotProps.inputLabel.shrink=true si lo necesita.
|
|
50
|
+
inputLabel: __spreadValues({}, customSlotProps == null ? void 0 : customSlotProps.inputLabel)
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
const buildInputSx = (borderRadius, labelPosition) => {
|
|
54
|
+
const radius = typeof borderRadius === "number" ? `${borderRadius}px` : borderRadius;
|
|
55
|
+
return buildFormFieldSx({
|
|
56
|
+
borderRadius,
|
|
57
|
+
labelPosition,
|
|
58
|
+
extraOutsideSx: {
|
|
59
|
+
"& .MuiInputBase-input": {
|
|
60
|
+
paddingTop: FIELD_INPUT_PADDING_Y,
|
|
61
|
+
paddingBottom: FIELD_INPUT_PADDING_Y
|
|
62
|
+
},
|
|
63
|
+
// Filled: quitar el padding-top reservado para el label flotante dentro.
|
|
64
|
+
"& .MuiFilledInput-root": {
|
|
65
|
+
paddingTop: 0,
|
|
66
|
+
borderRadius: `${radius} ${radius} 0 0`
|
|
67
|
+
},
|
|
68
|
+
"& .MuiFilledInput-input": {
|
|
69
|
+
paddingTop: FIELD_INPUT_PADDING_Y
|
|
70
|
+
},
|
|
71
|
+
// Standard: quitar el margin-top reservado para el label flotante.
|
|
72
|
+
"& .MuiInput-root": {
|
|
73
|
+
marginTop: 0
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
const Input = (props) => {
|
|
79
|
+
const _a = props, {
|
|
80
|
+
type = "text",
|
|
81
|
+
variant = "outlined",
|
|
82
|
+
size = "small",
|
|
83
|
+
borderRadius = 10,
|
|
84
|
+
labelPosition = "outside",
|
|
85
|
+
preset,
|
|
86
|
+
min,
|
|
87
|
+
max,
|
|
88
|
+
readOnly,
|
|
89
|
+
inputProps,
|
|
90
|
+
slotProps,
|
|
91
|
+
sx
|
|
92
|
+
} = _a, rest = __objRest(_a, [
|
|
93
|
+
"type",
|
|
94
|
+
"variant",
|
|
95
|
+
"size",
|
|
96
|
+
"borderRadius",
|
|
97
|
+
"labelPosition",
|
|
98
|
+
"preset",
|
|
99
|
+
"min",
|
|
100
|
+
"max",
|
|
101
|
+
"readOnly",
|
|
102
|
+
"inputProps",
|
|
103
|
+
"slotProps",
|
|
104
|
+
"sx"
|
|
105
|
+
]);
|
|
106
|
+
const theme = useTheme();
|
|
107
|
+
const presetSx = resolvePreset("Input", preset, theme);
|
|
108
|
+
const finalSlotProps = buildSlotProps(
|
|
109
|
+
type,
|
|
110
|
+
min,
|
|
111
|
+
max,
|
|
112
|
+
slotProps,
|
|
113
|
+
inputProps,
|
|
114
|
+
labelPosition,
|
|
115
|
+
readOnly
|
|
116
|
+
);
|
|
117
|
+
const mergedSx = [
|
|
118
|
+
buildInputSx(borderRadius, labelPosition),
|
|
119
|
+
...presetSx ? [presetSx] : [],
|
|
120
|
+
...Array.isArray(sx) ? sx : [sx]
|
|
121
|
+
];
|
|
122
|
+
if ("control" in props && props.control) {
|
|
123
|
+
const { name, control, validation } = props;
|
|
124
|
+
return /* @__PURE__ */ jsx(
|
|
125
|
+
Controller,
|
|
126
|
+
{
|
|
127
|
+
name,
|
|
128
|
+
control,
|
|
129
|
+
rules: validation,
|
|
130
|
+
render: ({ field, fieldState: { error } }) => {
|
|
131
|
+
var _a2, _b;
|
|
132
|
+
return /* @__PURE__ */ jsx(
|
|
133
|
+
TextField,
|
|
134
|
+
__spreadProps(__spreadValues({
|
|
135
|
+
fullWidth: true
|
|
136
|
+
}, rest), {
|
|
137
|
+
name: field.name,
|
|
138
|
+
value: (_a2 = field.value) != null ? _a2 : "",
|
|
139
|
+
onChange: (e) => field.onChange(parseValue(e.target.value, type)),
|
|
140
|
+
onBlur: field.onBlur,
|
|
141
|
+
inputRef: field.ref,
|
|
142
|
+
type,
|
|
143
|
+
variant,
|
|
144
|
+
size,
|
|
145
|
+
slotProps: finalSlotProps,
|
|
146
|
+
sx: mergedSx,
|
|
147
|
+
error: !!error || rest.error,
|
|
148
|
+
helperText: (_b = error == null ? void 0 : error.message) != null ? _b : rest.helperText
|
|
149
|
+
})
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
const { value, onChange } = props;
|
|
156
|
+
return /* @__PURE__ */ jsx(
|
|
157
|
+
TextField,
|
|
158
|
+
__spreadProps(__spreadValues({
|
|
159
|
+
fullWidth: true
|
|
160
|
+
}, rest), {
|
|
161
|
+
value: value != null ? value : "",
|
|
162
|
+
onChange: (e) => onChange(parseValue(e.target.value, type)),
|
|
163
|
+
type,
|
|
164
|
+
variant,
|
|
165
|
+
size,
|
|
166
|
+
slotProps: finalSlotProps,
|
|
167
|
+
sx: mergedSx
|
|
168
|
+
})
|
|
169
|
+
);
|
|
170
|
+
};
|
|
2
171
|
export {
|
|
3
|
-
|
|
172
|
+
Input,
|
|
173
|
+
Input as default
|
|
4
174
|
};
|
|
5
175
|
//# sourceMappingURL=Input.js.map
|