@soyfri/shared-library 1.4.6 → 1.4.7
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/{Input-DFHs7cJ_.js → Input-C__f2Up9.js} +5 -39
- package/Input-C__f2Up9.js.map +1 -0
- package/{Input-c8MwNNPg.cjs → Input-CwSfAvKP.cjs} +5 -39
- package/Input-CwSfAvKP.cjs.map +1 -0
- package/README.md +243 -0
- package/components/Input/Input.cjs +1 -1
- package/components/Input/Input.js +1 -1
- package/components/Input/InputVariants.styles.d.ts +30 -0
- package/components/InputGroup/InputGroup.cjs +1 -1
- package/components/InputGroup/InputGroup.js +1 -1
- package/package.json +7 -5
- package/palette.d.ts +1 -0
- package/Input-DFHs7cJ_.js.map +0 -1
- package/Input-c8MwNNPg.cjs.map +0 -1
|
@@ -34,44 +34,10 @@ import { forwardRef } from "react";
|
|
|
34
34
|
import { TextField } from "@mui/material";
|
|
35
35
|
import { styled } from "@mui/system";
|
|
36
36
|
import { Controller } from "react-hook-form";
|
|
37
|
-
const StyledTextField = styled(TextField)(({ theme }) =>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
borderRadius: "10px",
|
|
42
|
-
display: "flex",
|
|
43
|
-
alignItems: "center",
|
|
44
|
-
fontSize: "14px"
|
|
45
|
-
},
|
|
46
|
-
"& .MuiInputBase-input": {
|
|
47
|
-
padding: "0 !important",
|
|
48
|
-
height: "18px",
|
|
49
|
-
display: "flex",
|
|
50
|
-
alignItems: "center",
|
|
51
|
-
marginTop: "-4px"
|
|
52
|
-
},
|
|
53
|
-
"& .MuiInputLabel-root": {
|
|
54
|
-
top: "50%",
|
|
55
|
-
transform: "translate(14px, -50%)",
|
|
56
|
-
"&.MuiInputLabel-shrink": {
|
|
57
|
-
transform: "translate(1px, -200%) scale(0.75)",
|
|
58
|
-
fontSize: "16px !important",
|
|
59
|
-
"> legend": {
|
|
60
|
-
display: "none"
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
"& .MuiInputLabel-root.Mui-error": {
|
|
65
|
-
top: "25%"
|
|
66
|
-
},
|
|
67
|
-
"& .MuiInputBase-root > fieldset > legend": {
|
|
68
|
-
display: "none"
|
|
69
|
-
},
|
|
70
|
-
"& .MuiOutlinedInput-notchedOutline": {
|
|
71
|
-
border: "0.7px solid",
|
|
72
|
-
borderColor: "#e0e0e0"
|
|
73
|
-
}
|
|
74
|
-
}));
|
|
37
|
+
const StyledTextField = styled(TextField)(({ theme }) => {
|
|
38
|
+
var _a, _b, _c, _d, _e, _f;
|
|
39
|
+
return console.log((_c = (_b = (_a = theme.components) == null ? void 0 : _a.MuiTextField) == null ? void 0 : _b.styleOverrides) == null ? void 0 : _c.root), __spreadValues({}, (_f = (_e = (_d = theme.components) == null ? void 0 : _d.MuiTextField) == null ? void 0 : _e.styleOverrides) == null ? void 0 : _f.root);
|
|
40
|
+
});
|
|
75
41
|
const Input = forwardRef((_a, ref) => {
|
|
76
42
|
var _b = _a, {
|
|
77
43
|
type = "text",
|
|
@@ -168,4 +134,4 @@ const Input = forwardRef((_a, ref) => {
|
|
|
168
134
|
export {
|
|
169
135
|
Input as I
|
|
170
136
|
};
|
|
171
|
-
//# sourceMappingURL=Input-
|
|
137
|
+
//# sourceMappingURL=Input-C__f2Up9.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Input-C__f2Up9.js","sources":["../src/components/Input/Input.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport { TextField, TextFieldProps } from '@mui/material';\nimport { styled } from '@mui/system';\nimport { Controller, Control, RegisterOptions } from 'react-hook-form';\n\n\n\n\ninterface BaseInputProps extends Omit<TextFieldProps, 'value' | 'onChange' | 'variant' | 'type' | 'inputProps' | 'slotProps' | 'error' | 'helperText'> {\n type?: 'text' | 'number' | 'email' | 'password' | 'tel' | 'url' | 'search' | 'date' | 'datetime-local' | 'month' | 'week' | 'time' | 'color';\n variant?: 'outlined' | 'filled' | 'standard';\n min?: number;\n max?: number;\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n slotProps?: TextFieldProps['slotProps'];\n disabled?: boolean;\n readOnly?: boolean;\n error?: boolean;\n helperText?: string;\n}\n\ninterface RHFInputProps extends BaseInputProps {\n name: string;\n control: Control<any>;\n validation?: RegisterOptions;\n value?: string | number;\n onChange?: (value: string | number) => void;\n}\n\ninterface StandardInputPropsWithOptionalName extends BaseInputProps {\n name?: string;\n control?: never;\n validation?: never;\n value: string | number;\n onChange: (value: string | number) => void;\n}\n\nexport type InputProps = RHFInputProps | StandardInputPropsWithOptionalName;\n\n\nconst StyledTextField = styled(TextField)(({ theme }) => (\n console.log(theme.components?.MuiTextField?.styleOverrides?.root),\n {\n // '& .MuiInputBase-root': {\n // maxHeight: '34px',\n // padding: '8px 10px',\n // borderRadius: '10px',\n // display: 'flex',\n // alignItems: 'center',\n // fontSize: '14px',\n // },\n // '& .MuiInputBase-input': {\n // padding: '0 !important',\n // height: '18px',\n // display: 'flex',\n // alignItems: 'center',\n // marginTop: '-4px'\n // },\n // '& .MuiInputLabel-root': {\n // top: '50%',\n // transform: 'translate(14px, -50%)',\n // '&.MuiInputLabel-shrink': {\n // transform: 'translate(1px, -200%) scale(0.75)',\n // fontSize: '16px !important',\n // '> legend': {\n // display: 'none',\n // }\n // }\n // },\n // '& .MuiInputLabel-root.Mui-error': {\n // top: '25%'\n\n // },\n // '& .MuiInputBase-root > fieldset > legend': {\n // display: 'none',\n // },\n // '& .MuiOutlinedInput-notchedOutline': {\n // border: '0.7px solid',\n // borderColor: '#e0e0e0',\n // },\n ...theme.components?.MuiTextField?.styleOverrides?.root,\n }));\n\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(({\n type = 'text',\n variant = 'outlined',\n min,\n max,\n inputProps: customInputProps,\n slotProps: customSlotProps,\n\n value,\n onChange,\n ...rest\n}, ref) => {\n const isRHFMode = 'control' in rest && rest.control !== undefined;\n\n\n const htmlInputProps: React.InputHTMLAttributes<HTMLInputElement> = {\n ...customInputProps,\n };\n\n if (type === 'number') {\n htmlInputProps.min = min !== undefined ? min : Number.NEGATIVE_INFINITY;\n if (max !== undefined) {\n htmlInputProps.max = max;\n }\n }\n\n\n const finalSlotProps: TextFieldProps['slotProps'] = {\n ...customSlotProps,\n htmlInput: {\n ...customSlotProps?.htmlInput,\n ...htmlInputProps,\n },\n };\n\n\n const handleChangeInternal = (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>, rhfOnChange?: (...event: any[]) => void) => {\n const rawValue = event.target.value;\n let newValue: string | number;\n\n if (type === 'number') {\n newValue = rawValue === '' || rawValue === '-' ? rawValue : parseFloat(rawValue);\n\n if (isNaN(newValue as number) && rawValue !== '' && rawValue !== '-') newValue = rawValue;\n } else {\n newValue = rawValue;\n }\n\n if (isRHFMode) {\n rhfOnChange?.(newValue);\n } else {\n\n (onChange as (value: string | number) => void)?.(newValue);\n }\n };\n\n\n if (isRHFMode) {\n const rhfProps = rest as RHFInputProps;\n return (\n <Controller\n name={rhfProps.name}\n control={rhfProps.control}\n rules={rhfProps.validation}\n render={({ field, fieldState: { error } }) => {\n return (\n <StyledTextField\n fullWidth={true}\n value={field.value ?? ''}\n onChange={(e) => handleChangeInternal(e, field.onChange)}\n onBlur={field.onBlur}\n type={type}\n variant={variant}\n slotProps={finalSlotProps}\n inputRef={field.ref}\n error={!!error}\n helperText={error?.message}\n {...rest}\n />\n );\n }}\n />\n );\n } else {\n\n const standardProps = rest as StandardInputPropsWithOptionalName;\n return (\n <StyledTextField\n fullWidth={true}\n name={standardProps.name}\n value={value ?? ''}\n onChange={(e) => handleChangeInternal(e)}\n type={type}\n variant={variant}\n slotProps={finalSlotProps}\n inputRef={ref}\n error={standardProps.error}\n helperText={standardProps.helperText}\n {...rest}\n />\n );\n }\n});\n\nexport default Input;"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAM,kBAAkB,OAA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,QACC,MAAM,SAAS;AAAA,QACf,SAAS,SAAS;AAAA,QAClB,OAAO,SAAS;AAAA,QAChB,QAAQ,CAAC,EAAE,OAAO,YAAY,EAAE,MAAA,QAAc;;AAC5C,iBACE;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW;AAAA,cACX,QAAOA,MAAA,MAAM,UAAN,OAAAA,MAAe;AAAA,cACtB,UAAU,CAAC,MAAM,qBAAqB,GAAG,MAAM,QAAQ;AAAA,cACvD,QAAQ,MAAM;AAAA,cACd;AAAA,cACA;AAAA,cACA,WAAW;AAAA,cACX,UAAU,MAAM;AAAA,cAChB,OAAO,CAAC,CAAC;AAAA,cACT,YAAY,+BAAO;AAAA,eACf;AAAA,UAAA;AAAA,QAGV;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN,OAAO;AAEL,UAAM,gBAAgB;AACtB,WACE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAW;AAAA,QACX,MAAM,cAAc;AAAA,QACpB,OAAO,wBAAS;AAAA,QAChB,UAAU,CAAC,MAAM,qBAAqB,CAAC;AAAA,QACvC;AAAA,QACA;AAAA,QACA,WAAW;AAAA,QACX,UAAU;AAAA,QACV,OAAO,cAAc;AAAA,QACrB,YAAY,cAAc;AAAA,SACtB;AAAA,IAAA;AAAA,EAGV;AACF,CAAC;"}
|
|
@@ -35,44 +35,10 @@ const React = require("react");
|
|
|
35
35
|
const material = require("@mui/material");
|
|
36
36
|
const system = require("@mui/system");
|
|
37
37
|
const reactHookForm = require("react-hook-form");
|
|
38
|
-
const StyledTextField = system.styled(material.TextField)(({ theme }) =>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
borderRadius: "10px",
|
|
43
|
-
display: "flex",
|
|
44
|
-
alignItems: "center",
|
|
45
|
-
fontSize: "14px"
|
|
46
|
-
},
|
|
47
|
-
"& .MuiInputBase-input": {
|
|
48
|
-
padding: "0 !important",
|
|
49
|
-
height: "18px",
|
|
50
|
-
display: "flex",
|
|
51
|
-
alignItems: "center",
|
|
52
|
-
marginTop: "-4px"
|
|
53
|
-
},
|
|
54
|
-
"& .MuiInputLabel-root": {
|
|
55
|
-
top: "50%",
|
|
56
|
-
transform: "translate(14px, -50%)",
|
|
57
|
-
"&.MuiInputLabel-shrink": {
|
|
58
|
-
transform: "translate(1px, -200%) scale(0.75)",
|
|
59
|
-
fontSize: "16px !important",
|
|
60
|
-
"> legend": {
|
|
61
|
-
display: "none"
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
"& .MuiInputLabel-root.Mui-error": {
|
|
66
|
-
top: "25%"
|
|
67
|
-
},
|
|
68
|
-
"& .MuiInputBase-root > fieldset > legend": {
|
|
69
|
-
display: "none"
|
|
70
|
-
},
|
|
71
|
-
"& .MuiOutlinedInput-notchedOutline": {
|
|
72
|
-
border: "0.7px solid",
|
|
73
|
-
borderColor: "#e0e0e0"
|
|
74
|
-
}
|
|
75
|
-
}));
|
|
38
|
+
const StyledTextField = system.styled(material.TextField)(({ theme }) => {
|
|
39
|
+
var _a, _b, _c, _d, _e, _f;
|
|
40
|
+
return console.log((_c = (_b = (_a = theme.components) == null ? void 0 : _a.MuiTextField) == null ? void 0 : _b.styleOverrides) == null ? void 0 : _c.root), __spreadValues({}, (_f = (_e = (_d = theme.components) == null ? void 0 : _d.MuiTextField) == null ? void 0 : _e.styleOverrides) == null ? void 0 : _f.root);
|
|
41
|
+
});
|
|
76
42
|
const Input = React.forwardRef((_a, ref) => {
|
|
77
43
|
var _b = _a, {
|
|
78
44
|
type = "text",
|
|
@@ -167,4 +133,4 @@ const Input = React.forwardRef((_a, ref) => {
|
|
|
167
133
|
}
|
|
168
134
|
});
|
|
169
135
|
exports.Input = Input;
|
|
170
|
-
//# sourceMappingURL=Input-
|
|
136
|
+
//# sourceMappingURL=Input-CwSfAvKP.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Input-CwSfAvKP.cjs","sources":["../src/components/Input/Input.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport { TextField, TextFieldProps } from '@mui/material';\nimport { styled } from '@mui/system';\nimport { Controller, Control, RegisterOptions } from 'react-hook-form';\n\n\n\n\ninterface BaseInputProps extends Omit<TextFieldProps, 'value' | 'onChange' | 'variant' | 'type' | 'inputProps' | 'slotProps' | 'error' | 'helperText'> {\n type?: 'text' | 'number' | 'email' | 'password' | 'tel' | 'url' | 'search' | 'date' | 'datetime-local' | 'month' | 'week' | 'time' | 'color';\n variant?: 'outlined' | 'filled' | 'standard';\n min?: number;\n max?: number;\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n slotProps?: TextFieldProps['slotProps'];\n disabled?: boolean;\n readOnly?: boolean;\n error?: boolean;\n helperText?: string;\n}\n\ninterface RHFInputProps extends BaseInputProps {\n name: string;\n control: Control<any>;\n validation?: RegisterOptions;\n value?: string | number;\n onChange?: (value: string | number) => void;\n}\n\ninterface StandardInputPropsWithOptionalName extends BaseInputProps {\n name?: string;\n control?: never;\n validation?: never;\n value: string | number;\n onChange: (value: string | number) => void;\n}\n\nexport type InputProps = RHFInputProps | StandardInputPropsWithOptionalName;\n\n\nconst StyledTextField = styled(TextField)(({ theme }) => (\n console.log(theme.components?.MuiTextField?.styleOverrides?.root),\n {\n // '& .MuiInputBase-root': {\n // maxHeight: '34px',\n // padding: '8px 10px',\n // borderRadius: '10px',\n // display: 'flex',\n // alignItems: 'center',\n // fontSize: '14px',\n // },\n // '& .MuiInputBase-input': {\n // padding: '0 !important',\n // height: '18px',\n // display: 'flex',\n // alignItems: 'center',\n // marginTop: '-4px'\n // },\n // '& .MuiInputLabel-root': {\n // top: '50%',\n // transform: 'translate(14px, -50%)',\n // '&.MuiInputLabel-shrink': {\n // transform: 'translate(1px, -200%) scale(0.75)',\n // fontSize: '16px !important',\n // '> legend': {\n // display: 'none',\n // }\n // }\n // },\n // '& .MuiInputLabel-root.Mui-error': {\n // top: '25%'\n\n // },\n // '& .MuiInputBase-root > fieldset > legend': {\n // display: 'none',\n // },\n // '& .MuiOutlinedInput-notchedOutline': {\n // border: '0.7px solid',\n // borderColor: '#e0e0e0',\n // },\n ...theme.components?.MuiTextField?.styleOverrides?.root,\n }));\n\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(({\n type = 'text',\n variant = 'outlined',\n min,\n max,\n inputProps: customInputProps,\n slotProps: customSlotProps,\n\n value,\n onChange,\n ...rest\n}, ref) => {\n const isRHFMode = 'control' in rest && rest.control !== undefined;\n\n\n const htmlInputProps: React.InputHTMLAttributes<HTMLInputElement> = {\n ...customInputProps,\n };\n\n if (type === 'number') {\n htmlInputProps.min = min !== undefined ? min : Number.NEGATIVE_INFINITY;\n if (max !== undefined) {\n htmlInputProps.max = max;\n }\n }\n\n\n const finalSlotProps: TextFieldProps['slotProps'] = {\n ...customSlotProps,\n htmlInput: {\n ...customSlotProps?.htmlInput,\n ...htmlInputProps,\n },\n };\n\n\n const handleChangeInternal = (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>, rhfOnChange?: (...event: any[]) => void) => {\n const rawValue = event.target.value;\n let newValue: string | number;\n\n if (type === 'number') {\n newValue = rawValue === '' || rawValue === '-' ? rawValue : parseFloat(rawValue);\n\n if (isNaN(newValue as number) && rawValue !== '' && rawValue !== '-') newValue = rawValue;\n } else {\n newValue = rawValue;\n }\n\n if (isRHFMode) {\n rhfOnChange?.(newValue);\n } else {\n\n (onChange as (value: string | number) => void)?.(newValue);\n }\n };\n\n\n if (isRHFMode) {\n const rhfProps = rest as RHFInputProps;\n return (\n <Controller\n name={rhfProps.name}\n control={rhfProps.control}\n rules={rhfProps.validation}\n render={({ field, fieldState: { error } }) => {\n return (\n <StyledTextField\n fullWidth={true}\n value={field.value ?? ''}\n onChange={(e) => handleChangeInternal(e, field.onChange)}\n onBlur={field.onBlur}\n type={type}\n variant={variant}\n slotProps={finalSlotProps}\n inputRef={field.ref}\n error={!!error}\n helperText={error?.message}\n {...rest}\n />\n );\n }}\n />\n );\n } else {\n\n const standardProps = rest as StandardInputPropsWithOptionalName;\n return (\n <StyledTextField\n fullWidth={true}\n name={standardProps.name}\n value={value ?? ''}\n onChange={(e) => handleChangeInternal(e)}\n type={type}\n variant={variant}\n slotProps={finalSlotProps}\n inputRef={ref}\n error={standardProps.error}\n helperText={standardProps.helperText}\n {...rest}\n />\n );\n }\n});\n\nexport default Input;"],"names":["styled","TextField","forwardRef","jsx","Controller","_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAM,kBAAkBA,OAAAA,OAAOC,SAAAA,SAAS,EAAE,CAAC,EAAE,MAAA,MAAM;;AACjD,iBAAQ,KAAI,uBAAM,eAAN,mBAAkB,iBAAlB,mBAAgC,mBAAhC,mBAAgD,IAAI,GAChE,oBAsCK,uBAAM,eAAN,mBAAkB,iBAAlB,mBAAgC,mBAAhC,mBAAgD;AAAA,CACnD;AAGG,MAAM,QAAQC,MAAAA,WAAyC,CAAC,IAW5D,QAAQ;AAXoD,eAC7D;AAAA,WAAO;AAAA,IACP,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ,WAAW;AAAA,IAEX;AAAA,IACA;AAAA,MAT6D,IAU1D,iBAV0D,IAU1D;AAAA,IATH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IAEA;AAAA,IACA;AAAA;AAGA,QAAM,YAAY,aAAa,QAAQ,KAAK,YAAY;AAGxD,QAAM,iBAA8D,mBAC/D;AAGL,MAAI,SAAS,UAAU;AACrB,mBAAe,MAAM,QAAQ,SAAY,MAAM,OAAO;AACtD,QAAI,QAAQ,QAAW;AACrB,qBAAe,MAAM;AAAA,IACvB;AAAA,EACF;AAGA,QAAM,iBAA8C,iCAC/C,kBAD+C;AAAA,IAElD,WAAW,kCACN,mDAAiB,YACjB;AAAA,EACL;AAIF,QAAM,uBAAuB,CAAC,OAAkE,gBAA4C;AAC1I,UAAM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F,CAAC;;"}
|
package/README.md
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
# @soyfri/shared-library
|
|
2
|
+
|
|
3
|
+
Una librería de componentes React reutilizables construida con Material-UI, TypeScript y Tailwind CSS, diseñada para proporcionar componentes UI consistentes y bien documentados.
|
|
4
|
+
|
|
5
|
+
## 📋 Tabla de Contenidos
|
|
6
|
+
|
|
7
|
+
- [Características](#características)
|
|
8
|
+
- [Instalación](#instalación)
|
|
9
|
+
- [Uso](#uso)
|
|
10
|
+
- [Componentes Disponibles](#componentes-disponibles)
|
|
11
|
+
- [Desarrollo](#desarrollo)
|
|
12
|
+
- [Scripts Disponibles](#scripts-disponibles)
|
|
13
|
+
- [Storybook](#storybook)
|
|
14
|
+
- [Testing](#testing)
|
|
15
|
+
- [Tecnologías](#tecnologías)
|
|
16
|
+
- [Estructura del Proyecto](#estructura-del-proyecto)
|
|
17
|
+
|
|
18
|
+
## ✨ Características
|
|
19
|
+
|
|
20
|
+
- 🎨 **Componentes tipados**: Todos los componentes están construidos con TypeScript para mayor seguridad de tipos
|
|
21
|
+
- 📚 **Documentación con Storybook**: Cada componente incluye historias interactivas y documentación
|
|
22
|
+
- 🎯 **Material-UI**: Basado en Material-UI para un diseño consistente y accesible
|
|
23
|
+
- 🌈 **Tailwind CSS**: Integración con Tailwind para estilos utilitarios
|
|
24
|
+
- 🧪 **Testing**: Configurado con Vitest y Playwright para testing de componentes
|
|
25
|
+
- 📦 **Build optimizado**: Configuración con Rollup para generar builds ESM y CommonJS
|
|
26
|
+
|
|
27
|
+
## 📦 Instalación
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install @soyfri/shared-library
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 🚀 Uso
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { Button, Table, Select } from '@soyfri/shared-library';
|
|
37
|
+
import '@soyfri/shared-library/dist/styles.css';
|
|
38
|
+
|
|
39
|
+
function App() {
|
|
40
|
+
return (
|
|
41
|
+
<div>
|
|
42
|
+
<Button variant="contained" color="primary">
|
|
43
|
+
Mi Botón
|
|
44
|
+
</Button>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## 🧩 Componentes Disponibles
|
|
51
|
+
|
|
52
|
+
### Button
|
|
53
|
+
Componente de botón personalizable basado en Material-UI con soporte para iconos, diferentes tamaños y estados.
|
|
54
|
+
|
|
55
|
+
**Características:**
|
|
56
|
+
- Variantes: `text`, `outlined`, `contained`
|
|
57
|
+
- Tamaños: `small`, `medium`, `large`
|
|
58
|
+
- Soporte para iconos de inicio y fin
|
|
59
|
+
- Estados de carga
|
|
60
|
+
- Completamente tipado
|
|
61
|
+
|
|
62
|
+
### Table
|
|
63
|
+
Componente de tabla flexible con paginación interna y externa, ordenamiento y renderizado personalizado de columnas.
|
|
64
|
+
|
|
65
|
+
**Características:**
|
|
66
|
+
- Paginación interna automática
|
|
67
|
+
- Paginación externa controlada
|
|
68
|
+
- Columnas personalizables con renderizado custom
|
|
69
|
+
- Soporte para componentes complejos en celdas
|
|
70
|
+
- Completamente tipado con generics
|
|
71
|
+
|
|
72
|
+
### Select
|
|
73
|
+
Componente select avanzado con soporte para selección múltiple, filtros, agrupación y renderizado personalizado.
|
|
74
|
+
|
|
75
|
+
**Características:**
|
|
76
|
+
- Selección simple y múltiple
|
|
77
|
+
- Filtrado de opciones
|
|
78
|
+
- Agrupación de opciones
|
|
79
|
+
- Renderizado personalizado con avatars
|
|
80
|
+
- Placeholder configurable
|
|
81
|
+
|
|
82
|
+
### Avatar
|
|
83
|
+
Componente para mostrar avatares de usuarios con soporte para imágenes y texto.
|
|
84
|
+
|
|
85
|
+
### Icon
|
|
86
|
+
Wrapper para iconos de Material-UI con propiedades consistentes.
|
|
87
|
+
|
|
88
|
+
### Stat
|
|
89
|
+
Componente para mostrar estadísticas con diferentes plantillas de visualización.
|
|
90
|
+
|
|
91
|
+
**Características:**
|
|
92
|
+
- Plantilla simple
|
|
93
|
+
- Plantilla con chip
|
|
94
|
+
- Plantilla con lista de chips
|
|
95
|
+
- Colores personalizables
|
|
96
|
+
|
|
97
|
+
### Column
|
|
98
|
+
Componente auxiliar para definir columnas en el componente Table.
|
|
99
|
+
|
|
100
|
+
## 🛠️ Desarrollo
|
|
101
|
+
|
|
102
|
+
### Prerrequisitos
|
|
103
|
+
|
|
104
|
+
- Node.js (versión 18 o superior)
|
|
105
|
+
- npm o yarn
|
|
106
|
+
|
|
107
|
+
### Configuración del entorno de desarrollo
|
|
108
|
+
|
|
109
|
+
1. Clona el repositorio:
|
|
110
|
+
```bash
|
|
111
|
+
git clone <repository-url>
|
|
112
|
+
cd shared-library
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
2. Instala las dependencias:
|
|
116
|
+
```bash
|
|
117
|
+
npm install
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
3. Inicia el entorno de desarrollo:
|
|
121
|
+
```bash
|
|
122
|
+
npm run dev
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## 📜 Scripts Disponibles
|
|
126
|
+
|
|
127
|
+
- `npm run build` - Construye la librería para producción
|
|
128
|
+
- `npm run dev` - Inicia el modo de desarrollo con watch
|
|
129
|
+
- `npm run build:css` - Construye los estilos CSS
|
|
130
|
+
- `npm run watch:css` - Observa cambios en los estilos CSS
|
|
131
|
+
- `npm run clean` - Limpia la carpeta dist
|
|
132
|
+
- `npm run prepare` - Limpia y construye la librería
|
|
133
|
+
- `npm run storybook` - Inicia Storybook en modo desarrollo
|
|
134
|
+
- `npm run build-storybook` - Construye Storybook para producción
|
|
135
|
+
- `npm run dist` - Ejecuta el script de distribución personalizado
|
|
136
|
+
|
|
137
|
+
## 📚 Storybook
|
|
138
|
+
|
|
139
|
+
La librería incluye Storybook para documentación interactiva y desarrollo de componentes.
|
|
140
|
+
|
|
141
|
+
### Iniciar Storybook
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
npm run storybook
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Esto abrirá Storybook en `http://localhost:6006` donde podrás:
|
|
148
|
+
|
|
149
|
+
- Ver todos los componentes disponibles
|
|
150
|
+
- Interactuar con las propiedades de cada componente
|
|
151
|
+
- Ver ejemplos de uso
|
|
152
|
+
- Acceder a la documentación detallada
|
|
153
|
+
|
|
154
|
+
### Construir Storybook
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
npm run build-storybook
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## 🧪 Testing
|
|
161
|
+
|
|
162
|
+
La librería está configurada con Vitest y Playwright para testing de componentes.
|
|
163
|
+
|
|
164
|
+
### Configuración de Testing
|
|
165
|
+
|
|
166
|
+
- **Vitest**: Para unit tests y testing de componentes
|
|
167
|
+
- **Playwright**: Para testing de browser
|
|
168
|
+
- **Storybook Test Addon**: Para testing de historias de Storybook
|
|
169
|
+
|
|
170
|
+
## 🔧 Tecnologías
|
|
171
|
+
|
|
172
|
+
### Dependencias Principales
|
|
173
|
+
|
|
174
|
+
- **React 19.1.0**: Librería de UI
|
|
175
|
+
- **Material-UI 7.1.0**: Sistema de diseño y componentes
|
|
176
|
+
- **TypeScript 5.8.3**: Tipado estático
|
|
177
|
+
- **Tailwind CSS 4.1.7**: Framework de CSS utilitario
|
|
178
|
+
|
|
179
|
+
### Herramientas de Desarrollo
|
|
180
|
+
|
|
181
|
+
- **Storybook 9.0.8**: Documentación y desarrollo de componentes
|
|
182
|
+
- **Rollup**: Bundler para la construcción de la librería
|
|
183
|
+
- **Vitest**: Framework de testing
|
|
184
|
+
- **Playwright**: Testing de browser
|
|
185
|
+
- **Prettier**: Formateo de código
|
|
186
|
+
|
|
187
|
+
## 📁 Estructura del Proyecto
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
shared-library/
|
|
191
|
+
├── .storybook/ # Configuración de Storybook
|
|
192
|
+
├── src/
|
|
193
|
+
│ ├── components/ # Componentes de la librería
|
|
194
|
+
│ │ ├── Avatar/
|
|
195
|
+
│ │ ├── Button/
|
|
196
|
+
│ │ ├── Column/
|
|
197
|
+
│ │ ├── Icon/
|
|
198
|
+
│ │ ├── Select/
|
|
199
|
+
│ │ ├── Stat/
|
|
200
|
+
│ │ └── Table/
|
|
201
|
+
│ ├── index.ts # Punto de entrada principal
|
|
202
|
+
│ └── styles.css # Estilos globales
|
|
203
|
+
├── dist/ # Archivos construidos
|
|
204
|
+
├── package.json
|
|
205
|
+
├── tsconfig.json
|
|
206
|
+
├── tailwind.config.js
|
|
207
|
+
├── rollup.config.cjs
|
|
208
|
+
└── vitest.config.ts
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Estructura de Componentes
|
|
212
|
+
|
|
213
|
+
Cada componente sigue una estructura consistente:
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
ComponentName/
|
|
217
|
+
├── ComponentName.tsx # Implementación del componente
|
|
218
|
+
├── ComponentName.stories.tsx # Historias de Storybook
|
|
219
|
+
├── ComponentName.definition.ts # Definiciones de código (opcional)
|
|
220
|
+
├── index.ts # Exportaciones
|
|
221
|
+
└── types.ts # Tipos específicos (opcional)
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## 🤝 Contribución
|
|
225
|
+
|
|
226
|
+
Para contribuir al proyecto:
|
|
227
|
+
|
|
228
|
+
1. Fork el repositorio
|
|
229
|
+
2. Crea una rama para tu feature (`git checkout -b feature/nueva-funcionalidad`)
|
|
230
|
+
3. Commit tus cambios (`git commit -am 'Agrega nueva funcionalidad'`)
|
|
231
|
+
4. Push a la rama (`git push origin feature/nueva-funcionalidad`)
|
|
232
|
+
5. Crea un Pull Request
|
|
233
|
+
|
|
234
|
+
## 📄 Licencia
|
|
235
|
+
|
|
236
|
+
ISC License
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
**Versión actual:** 1.0.1
|
|
241
|
+
|
|
242
|
+
Para más información y ejemplos detallados, consulta la documentación en Storybook ejecutando `npm run storybook`.
|
|
243
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const CustomInputSelfService: {
|
|
2
|
+
'& .MuiFilledInput-root': {
|
|
3
|
+
overflow: string;
|
|
4
|
+
borderRadius: string;
|
|
5
|
+
backgroundColor: string;
|
|
6
|
+
border: string;
|
|
7
|
+
borderColor: string;
|
|
8
|
+
color: string;
|
|
9
|
+
fontWeight: import("csstype").Property.FontWeight | undefined;
|
|
10
|
+
transition: string;
|
|
11
|
+
'&:hover': {
|
|
12
|
+
backgroundColor: string;
|
|
13
|
+
};
|
|
14
|
+
'&.Mui-focused': {
|
|
15
|
+
backgroundColor: string;
|
|
16
|
+
boxShadow: string;
|
|
17
|
+
borderColor: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
width: string;
|
|
21
|
+
height: string;
|
|
22
|
+
"& .MuiFormLabel-root": {
|
|
23
|
+
color: string;
|
|
24
|
+
fontWeight: import("csstype").Property.FontWeight | undefined;
|
|
25
|
+
fontSize: string;
|
|
26
|
+
};
|
|
27
|
+
".MuiSelect-icon ": {
|
|
28
|
+
fill: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
@@ -23,7 +23,7 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
23
23
|
const React = require("react");
|
|
24
24
|
const material = require("@mui/material");
|
|
25
25
|
const DatePicker = require("@mui/x-date-pickers/DatePicker");
|
|
26
|
-
const Input = require("../../Input-
|
|
26
|
+
const Input = require("../../Input-CwSfAvKP.cjs");
|
|
27
27
|
const Select = require("../../Select-BO2N56sm.cjs");
|
|
28
28
|
const DatePicker$1 = require("../../DatePicker-BoqxWAhj.cjs");
|
|
29
29
|
const InputGroup = ({ children }) => {
|
|
@@ -21,7 +21,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
21
21
|
import { Children, isValidElement, cloneElement } from "react";
|
|
22
22
|
import { Box, TextField, Select } from "@mui/material";
|
|
23
23
|
import { DatePicker } from "@mui/x-date-pickers/DatePicker";
|
|
24
|
-
import { I as Input } from "../../Input-
|
|
24
|
+
import { I as Input } from "../../Input-C__f2Up9.js";
|
|
25
25
|
import { S as Select$1 } from "../../Select-BcLkyHSE.js";
|
|
26
26
|
import { D as DatePicker$1 } from "../../DatePicker-BSNboVhN.js";
|
|
27
27
|
const InputGroup = ({ children }) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soyfri/shared-library",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"author": "",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"description": "",
|
|
12
|
-
"
|
|
12
|
+
"peerDependencies": {
|
|
13
13
|
"@emotion/react": "^11.14.0",
|
|
14
14
|
"@emotion/styled": "^11.14.0",
|
|
15
15
|
"@mui/icons-material": "^7.1.0",
|
|
@@ -17,15 +17,17 @@
|
|
|
17
17
|
"@mui/material": "^7.1.2",
|
|
18
18
|
"@mui/x-date-pickers": "^8.5.3",
|
|
19
19
|
"@mui/x-date-pickers-pro": "^8.5.3",
|
|
20
|
+
"react": "^19.1.0",
|
|
21
|
+
"react-dom": "^19.1.0",
|
|
22
|
+
"react-hook-form": "^7.62.0"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
20
25
|
"@storybook/test": "^8.6.14",
|
|
21
26
|
"@tailwindcss/cli": "^4.1.7",
|
|
22
27
|
"@vitejs/plugin-react": "^5.0.3",
|
|
23
28
|
"autoprefixer": "^10.4.21",
|
|
24
29
|
"dayjs": "^1.11.13",
|
|
25
30
|
"postcss": "^8.5.3",
|
|
26
|
-
"react": "^19.1.0",
|
|
27
|
-
"react-dom": "^19.1.0",
|
|
28
|
-
"react-hook-form": "^7.62.0",
|
|
29
31
|
"tailwindcss": "^4.1.7"
|
|
30
32
|
},
|
|
31
33
|
"overrides": {
|
package/palette.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const theme: import('@mui/material/styles').Theme;
|
package/Input-DFHs7cJ_.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Input-DFHs7cJ_.js","sources":["../src/components/Input/Input.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport { TextField, TextFieldProps } from '@mui/material';\nimport { styled } from '@mui/system';\nimport { Controller, Control, RegisterOptions } from 'react-hook-form';\n\n\n\n\ninterface BaseInputProps extends Omit<TextFieldProps, 'value' | 'onChange' | 'variant' | 'type' | 'inputProps' | 'slotProps' | 'error' | 'helperText'> {\n type?: 'text' | 'number' | 'email' | 'password' | 'tel' | 'url' | 'search' | 'date' | 'datetime-local' | 'month' | 'week' | 'time' | 'color';\n variant?: 'outlined' | 'filled' | 'standard';\n min?: number;\n max?: number;\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>; \n slotProps?: TextFieldProps['slotProps']; \n disabled?: boolean;\n readOnly?: boolean;\n error?: boolean;\n helperText?: string;\n}\n\ninterface RHFInputProps extends BaseInputProps {\n name: string;\n control: Control<any>;\n validation?: RegisterOptions;\n value?: string | number;\n onChange?: (value: string | number) => void;\n}\n\ninterface StandardInputPropsWithOptionalName extends BaseInputProps {\n name?: string; \n control?: never;\n validation?: never;\n value: string | number;\n onChange: (value: string | number) => void;\n}\n\nexport type InputProps = RHFInputProps | StandardInputPropsWithOptionalName;\n\n\nconst StyledTextField = styled(TextField)(({ theme }) => ({\n '& .MuiInputBase-root': {\n maxHeight: '34px',\n padding: '8px 10px',\n borderRadius: '10px',\n display: 'flex',\n alignItems: 'center',\n fontSize: '14px',\n },\n '& .MuiInputBase-input': {\n padding: '0 !important',\n height: '18px',\n display: 'flex',\n alignItems: 'center',\n marginTop: '-4px'\n },\n '& .MuiInputLabel-root': {\n top: '50%',\n transform: 'translate(14px, -50%)',\n '&.MuiInputLabel-shrink': {\n transform: 'translate(1px, -200%) scale(0.75)',\n fontSize: '16px !important',\n '> legend': {\n display: 'none',\n }\n }\n },\n '& .MuiInputLabel-root.Mui-error': {\n top: '25%'\n \n },\n '& .MuiInputBase-root > fieldset > legend':{\n display: 'none',\n },\n '& .MuiOutlinedInput-notchedOutline': {\n border: '0.7px solid',\n borderColor: '#e0e0e0',\n },\n}));\n\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(({\n type = 'text',\n variant = 'outlined',\n min,\n max,\n inputProps: customInputProps, \n slotProps: customSlotProps, \n \n value, \n onChange,\n ...rest \n}, ref) => {\n const isRHFMode = 'control' in rest && rest.control !== undefined;\n\n \n const htmlInputProps: React.InputHTMLAttributes<HTMLInputElement> = {\n ...customInputProps, \n };\n\n if (type === 'number') {\n htmlInputProps.min = min !== undefined ? min : Number.NEGATIVE_INFINITY;\n if (max !== undefined) {\n htmlInputProps.max = max;\n }\n }\n\n \n const finalSlotProps: TextFieldProps['slotProps'] = {\n ...customSlotProps,\n htmlInput: {\n ...customSlotProps?.htmlInput,\n ...htmlInputProps,\n },\n };\n\n \n const handleChangeInternal = (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>, rhfOnChange?: (...event: any[]) => void) => {\n const rawValue = event.target.value;\n let newValue: string | number;\n\n if (type === 'number') {\n newValue = rawValue === '' || rawValue === '-' ? rawValue : parseFloat(rawValue);\n \n if (isNaN(newValue as number) && rawValue !== '' && rawValue !== '-') newValue = rawValue;\n } else {\n newValue = rawValue;\n }\n\n if (isRHFMode) {\n rhfOnChange?.(newValue); \n } else {\n \n (onChange as (value: string | number) => void)?.(newValue); \n }\n };\n\n \n if (isRHFMode) {\n const rhfProps = rest as RHFInputProps;\n return (\n <Controller\n name={rhfProps.name}\n control={rhfProps.control}\n rules={rhfProps.validation}\n render={({ field, fieldState: { error } }) => {\n return (\n <StyledTextField\n fullWidth={true}\n value={field.value ?? ''}\n onChange={(e) => handleChangeInternal(e, field.onChange)} \n onBlur={field.onBlur}\n type={type}\n variant={variant}\n slotProps={finalSlotProps} \n inputRef={field.ref}\n error={!!error}\n helperText={error?.message}\n {...rest}\n />\n );\n }}\n />\n );\n } else {\n \n const standardProps = rest as StandardInputPropsWithOptionalName;\n return (\n <StyledTextField\n fullWidth={true}\n name={standardProps.name} \n value={value ?? ''} \n onChange={(e) => handleChangeInternal(e)} \n type={type}\n variant={variant}\n slotProps={finalSlotProps} \n inputRef={ref} \n error={standardProps.error}\n helperText={standardProps.helperText}\n {...rest} \n />\n );\n }\n});\n\nexport default Input;"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAM,kBAAkB,OAAO,SAAS,EAAE,CAAC,EAAE,aAAa;AAAA,EACxD,wBAAwB;AAAA,IACtB,WAAW;AAAA,IACX,SAAS;AAAA,IACT,cAAc;AAAA,IACd,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,UAAU;AAAA,EAAA;AAAA,EAEZ,yBAAyB;AAAA,IACvB,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,WAAW;AAAA,EAAA;AAAA,EAEb,yBAAyB;AAAA,IACvB,KAAK;AAAA,IACL,WAAW;AAAA,IACX,0BAA0B;AAAA,MACxB,WAAW;AAAA,MACX,UAAU;AAAA,MACV,YAAY;AAAA,QACV,SAAS;AAAA,MAAA;AAAA,IACX;AAAA,EACF;AAAA,EAEF,mCAAmC;AAAA,IACjC,KAAK;AAAA,EAAA;AAAA,EAGP,4CAA2C;AAAA,IACzC,SAAS;AAAA,EAAA;AAAA,EAEX,sCAAsC;AAAA,IACpC,QAAQ;AAAA,IACR,aAAa;AAAA,EAAA;AAEjB,EAAE;AAGK,MAAM,QAAQ,WAAyC,CAAC,IAW5D,QAAQ;AAXoD,eAC7D;AAAA,WAAO;AAAA,IACP,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,YAAY;A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A;AAAA,cACA,WAAW;AAAA,cACX,UAAU,MAAM;AAAA,cAChB,OAAO,CAAC,CAAC;AAAA,cACT,YAAY,+BAAO;AAAA,eACf;AAAA,UAAA;AAAA,QAGV;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN,OAAO;AAEL,UAAM,gBAAgB;AACtB,WACE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAW;AAAA,QACX,MAAM,cAAc;AAAA,QACpB,OAAO,wBAAS;AAAA,QAChB,UAAU,CAAC,MAAM,qBAAqB,CAAC;AAAA,QACvC;AAAA,QACA;AAAA,QACA,WAAW;AAAA,QACX,UAAU;AAAA,QACV,OAAO,cAAc;AAAA,QACrB,YAAY,cAAc;AAAA,SACtB;AAAA,IAAA;AAAA,EAGV;AACF,CAAC;"}
|
package/Input-c8MwNNPg.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Input-c8MwNNPg.cjs","sources":["../src/components/Input/Input.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport { TextField, TextFieldProps } from '@mui/material';\nimport { styled } from '@mui/system';\nimport { Controller, Control, RegisterOptions } from 'react-hook-form';\n\n\n\n\ninterface BaseInputProps extends Omit<TextFieldProps, 'value' | 'onChange' | 'variant' | 'type' | 'inputProps' | 'slotProps' | 'error' | 'helperText'> {\n type?: 'text' | 'number' | 'email' | 'password' | 'tel' | 'url' | 'search' | 'date' | 'datetime-local' | 'month' | 'week' | 'time' | 'color';\n variant?: 'outlined' | 'filled' | 'standard';\n min?: number;\n max?: number;\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>; \n slotProps?: TextFieldProps['slotProps']; \n disabled?: boolean;\n readOnly?: boolean;\n error?: boolean;\n helperText?: string;\n}\n\ninterface RHFInputProps extends BaseInputProps {\n name: string;\n control: Control<any>;\n validation?: RegisterOptions;\n value?: string | number;\n onChange?: (value: string | number) => void;\n}\n\ninterface StandardInputPropsWithOptionalName extends BaseInputProps {\n name?: string; \n control?: never;\n validation?: never;\n value: string | number;\n onChange: (value: string | number) => void;\n}\n\nexport type InputProps = RHFInputProps | StandardInputPropsWithOptionalName;\n\n\nconst StyledTextField = styled(TextField)(({ theme }) => ({\n '& .MuiInputBase-root': {\n maxHeight: '34px',\n padding: '8px 10px',\n borderRadius: '10px',\n display: 'flex',\n alignItems: 'center',\n fontSize: '14px',\n },\n '& .MuiInputBase-input': {\n padding: '0 !important',\n height: '18px',\n display: 'flex',\n alignItems: 'center',\n marginTop: '-4px'\n },\n '& .MuiInputLabel-root': {\n top: '50%',\n transform: 'translate(14px, -50%)',\n '&.MuiInputLabel-shrink': {\n transform: 'translate(1px, -200%) scale(0.75)',\n fontSize: '16px !important',\n '> legend': {\n display: 'none',\n }\n }\n },\n '& .MuiInputLabel-root.Mui-error': {\n top: '25%'\n \n },\n '& .MuiInputBase-root > fieldset > legend':{\n display: 'none',\n },\n '& .MuiOutlinedInput-notchedOutline': {\n border: '0.7px solid',\n borderColor: '#e0e0e0',\n },\n}));\n\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(({\n type = 'text',\n variant = 'outlined',\n min,\n max,\n inputProps: customInputProps, \n slotProps: customSlotProps, \n \n value, \n onChange,\n ...rest \n}, ref) => {\n const isRHFMode = 'control' in rest && rest.control !== undefined;\n\n \n const htmlInputProps: React.InputHTMLAttributes<HTMLInputElement> = {\n ...customInputProps, \n };\n\n if (type === 'number') {\n htmlInputProps.min = min !== undefined ? min : Number.NEGATIVE_INFINITY;\n if (max !== undefined) {\n htmlInputProps.max = max;\n }\n }\n\n \n const finalSlotProps: TextFieldProps['slotProps'] = {\n ...customSlotProps,\n htmlInput: {\n ...customSlotProps?.htmlInput,\n ...htmlInputProps,\n },\n };\n\n \n const handleChangeInternal = (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>, rhfOnChange?: (...event: any[]) => void) => {\n const rawValue = event.target.value;\n let newValue: string | number;\n\n if (type === 'number') {\n newValue = rawValue === '' || rawValue === '-' ? rawValue : parseFloat(rawValue);\n \n if (isNaN(newValue as number) && rawValue !== '' && rawValue !== '-') newValue = rawValue;\n } else {\n newValue = rawValue;\n }\n\n if (isRHFMode) {\n rhfOnChange?.(newValue); \n } else {\n \n (onChange as (value: string | number) => void)?.(newValue); \n }\n };\n\n \n if (isRHFMode) {\n const rhfProps = rest as RHFInputProps;\n return (\n <Controller\n name={rhfProps.name}\n control={rhfProps.control}\n rules={rhfProps.validation}\n render={({ field, fieldState: { error } }) => {\n return (\n <StyledTextField\n fullWidth={true}\n value={field.value ?? ''}\n onChange={(e) => handleChangeInternal(e, field.onChange)} \n onBlur={field.onBlur}\n type={type}\n variant={variant}\n slotProps={finalSlotProps} \n inputRef={field.ref}\n error={!!error}\n helperText={error?.message}\n {...rest}\n />\n );\n }}\n />\n );\n } else {\n \n const standardProps = rest as StandardInputPropsWithOptionalName;\n return (\n <StyledTextField\n fullWidth={true}\n name={standardProps.name} \n value={value ?? ''} \n onChange={(e) => handleChangeInternal(e)} \n type={type}\n variant={variant}\n slotProps={finalSlotProps} \n inputRef={ref} \n error={standardProps.error}\n helperText={standardProps.helperText}\n {...rest} \n />\n );\n }\n});\n\nexport default Input;"],"names":["styled","TextField","forwardRef","jsx","Controller","_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAM,kBAAkBA,OAAAA,OAAOC,SAAAA,SAAS,EAAE,CAAC,EAAE,aAAa;AAAA,EACxD,wBAAwB;AAAA,IACtB,WAAW;AAAA,IACX,SAAS;AAAA,IACT,cAAc;AAAA,IACd,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,UAAU;AAAA,EAAA;AAAA,EAEZ,yBAAyB;AAAA,IACvB,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,WAAW;AAAA,EAAA;AAAA,EAEb,yBAAyB;AAAA,IACvB,KAAK;AAAA,IACL,WAAW;AAAA,IACX,0BAA0B;AAAA,MACxB,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