@soyfri/shared-library 1.5.0 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
1
|
+
{"version":3,"file":"Input.js","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":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASO,MAAM,aAAa,CAAC,KAAa,SAAqC;AAC3E,MAAI,SAAS,SAAU,QAAO;AAC9B,MAAI,QAAQ,MAAM,QAAQ,IAAK,QAAO;AACtC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AAO,IAAI,CAAC;AAAA,MAC1D;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,MACX,IAAI;AAAA,IAAA;AAAA,EAAA;AAGV;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TextFieldProps } from '@mui/material';
|
|
2
|
+
import { LabelPosition } from './Input';
|
|
3
|
+
/**
|
|
4
|
+
* Builder de sx para el Input. Usa el builder compartido
|
|
5
|
+
* `buildFormFieldSx` y añade overrides específicos de TextField
|
|
6
|
+
* (padding del input base, filled, standard).
|
|
7
|
+
*/
|
|
8
|
+
export declare const buildInputSx: (borderRadius: number | string, labelPosition: LabelPosition) => TextFieldProps["sx"];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { InputType, LabelPosition, BaseInputProps, RHFInputProps, ControlledInputProps, InputProps, } from './Input';
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default
|
|
1
|
+
export { Input, default } from './Input';
|
|
2
|
+
export type { InputProps, BaseInputProps, RHFInputProps, ControlledInputProps, InputType, LabelPosition, } from './Input.types';
|
|
@@ -22,103 +22,116 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
22
22
|
const jsxRuntime = require("react/jsx-runtime");
|
|
23
23
|
const React = require("react");
|
|
24
24
|
const material = require("@mui/material");
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
25
|
+
const mergeSx = (base, extra) => {
|
|
26
|
+
if (!extra) return base;
|
|
27
|
+
const baseArr = Array.isArray(base) ? base : [base];
|
|
28
|
+
const extraArr = Array.isArray(extra) ? extra : [extra];
|
|
29
|
+
return [...baseArr, ...extraArr];
|
|
30
|
+
};
|
|
31
|
+
const InputGroup = ({
|
|
32
|
+
children,
|
|
33
|
+
sx,
|
|
34
|
+
slotSx,
|
|
35
|
+
borderRadius = 10,
|
|
36
|
+
disabled,
|
|
37
|
+
orientation = "horizontal",
|
|
38
|
+
className
|
|
39
|
+
}) => {
|
|
40
|
+
const radius = typeof borderRadius === "number" ? `${borderRadius}px` : borderRadius;
|
|
41
|
+
const slots = React.Children.toArray(children).filter(React.isValidElement);
|
|
42
|
+
const isHorizontal = orientation === "horizontal";
|
|
43
|
+
const baseSx = {
|
|
44
|
+
// Respeta el label "outside" de Input/Select: los hijos pierden su marginTop
|
|
45
|
+
// (ver más abajo) y el grupo reserva el mismo espacio arriba para que los
|
|
46
|
+
// labels floten por encima del borde del grupo.
|
|
47
|
+
marginTop: "14px",
|
|
48
|
+
display: "flex",
|
|
49
|
+
flexDirection: isHorizontal ? "row" : "column",
|
|
50
|
+
alignItems: "stretch",
|
|
51
|
+
width: "100%",
|
|
52
|
+
border: (theme) => `1px solid ${theme.palette.divider}`,
|
|
53
|
+
borderRadius: radius,
|
|
54
|
+
backgroundColor: "background.paper",
|
|
55
|
+
transition: "border-color 200ms cubic-bezier(0.0, 0, 0.2, 1) 0ms, box-shadow 200ms cubic-bezier(0.0, 0, 0.2, 1) 0ms",
|
|
56
|
+
"&:focus-within": {
|
|
57
|
+
borderColor: "primary.main",
|
|
58
|
+
boxShadow: (theme) => `0 0 0 1px ${theme.palette.primary.main}`
|
|
59
|
+
},
|
|
60
|
+
opacity: disabled ? 0.6 : 1,
|
|
61
|
+
pointerEvents: disabled ? "none" : "auto",
|
|
62
|
+
// Cancelar el marginTop que Input/Select reservan en labelPosition="outside".
|
|
63
|
+
// El grupo ya lo reservó en su nivel externo.
|
|
64
|
+
"& .MuiFormControl-root, & > .InputGroup__slot > .MuiTextField-root, & > .InputGroup__slot > .MuiFormControl-root": {
|
|
65
|
+
marginTop: 0
|
|
66
|
+
},
|
|
67
|
+
// Quitar el borde del notched outline interno: el borde visible es el del
|
|
68
|
+
// grupo, los separadores son los borderRight/borderBottom de cada slot.
|
|
69
|
+
"& .MuiOutlinedInput-notchedOutline": {
|
|
70
|
+
border: "none"
|
|
71
|
+
},
|
|
72
|
+
// Forzar que todos los campos pinten sus esquinas cuadradas (las esquinas
|
|
73
|
+
// redondeadas se aplican solo al primer/último slot más abajo).
|
|
74
|
+
"& .MuiInputBase-root, & .MuiChip-root": {
|
|
75
|
+
borderRadius: 0
|
|
76
|
+
},
|
|
77
|
+
// Botones integrados: sin radius propio, altura completa, sin sombra.
|
|
78
|
+
"& .MuiButton-root": {
|
|
79
|
+
borderRadius: 0,
|
|
80
|
+
height: "100%",
|
|
81
|
+
boxShadow: "none",
|
|
82
|
+
border: "none"
|
|
83
|
+
},
|
|
84
|
+
// Slots: cada hijo vive en un slot neutro que lo centra verticalmente.
|
|
85
|
+
"& > .InputGroup__slot": __spreadProps(__spreadValues({
|
|
86
|
+
flex: 1,
|
|
87
|
+
display: "flex",
|
|
88
|
+
alignItems: "center",
|
|
89
|
+
minWidth: 0
|
|
90
|
+
}, isHorizontal ? { borderRight: (theme) => `1px solid ${theme.palette.divider}` } : { borderBottom: (theme) => `1px solid ${theme.palette.divider}` }), {
|
|
91
|
+
"&:last-of-type": {
|
|
92
|
+
borderRight: "none",
|
|
93
|
+
borderBottom: "none"
|
|
94
|
+
}
|
|
95
|
+
}),
|
|
96
|
+
// Esquinas redondeadas: primer slot (izquierda o arriba).
|
|
97
|
+
"& > .InputGroup__slot:first-of-type .MuiInputBase-root, & > .InputGroup__slot:first-of-type .MuiButton-root, & > .InputGroup__slot:first-of-type .MuiChip-root": isHorizontal ? {
|
|
98
|
+
borderTopLeftRadius: radius,
|
|
99
|
+
borderBottomLeftRadius: radius
|
|
100
|
+
} : {
|
|
101
|
+
borderTopLeftRadius: radius,
|
|
102
|
+
borderTopRightRadius: radius
|
|
103
|
+
},
|
|
104
|
+
// Esquinas redondeadas: último slot (derecha o abajo).
|
|
105
|
+
"& > .InputGroup__slot:last-of-type .MuiInputBase-root, & > .InputGroup__slot:last-of-type .MuiButton-root, & > .InputGroup__slot:last-of-type .MuiChip-root": isHorizontal ? {
|
|
106
|
+
borderTopRightRadius: radius,
|
|
107
|
+
borderBottomRightRadius: radius
|
|
108
|
+
} : {
|
|
109
|
+
borderBottomLeftRadius: radius,
|
|
110
|
+
borderBottomRightRadius: radius
|
|
74
111
|
}
|
|
75
|
-
|
|
76
|
-
|
|
112
|
+
};
|
|
113
|
+
const baseSlotSx = {
|
|
114
|
+
flex: 1,
|
|
115
|
+
display: "flex",
|
|
116
|
+
alignItems: "center",
|
|
117
|
+
minWidth: 0
|
|
118
|
+
};
|
|
77
119
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
78
120
|
material.Box,
|
|
79
121
|
{
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
},
|
|
86
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
122
|
+
"data-testid": "input-group",
|
|
123
|
+
className,
|
|
124
|
+
"aria-disabled": disabled ? "true" : void 0,
|
|
125
|
+
sx: mergeSx(baseSx, sx),
|
|
126
|
+
children: slots.map((child, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
87
127
|
material.Box,
|
|
88
128
|
{
|
|
89
|
-
className: "
|
|
90
|
-
sx:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
borderRadius: "10px",
|
|
96
|
-
padding: "8px 0px",
|
|
97
|
-
marginTop: "-5px",
|
|
98
|
-
marginBottom: "20px",
|
|
99
|
-
"& .MuiInputBase-root, & .MuiButtonBase-root, & .MuiChip-root": {
|
|
100
|
-
borderRadius: 0
|
|
101
|
-
},
|
|
102
|
-
"& > div:first-of-type .MuiInputBase-root, & > div:first-of-type .MuiButtonBase-root, & > div:first-of-type .MuiChip-root": {
|
|
103
|
-
borderTopLeftRadius: "10px",
|
|
104
|
-
borderBottomLeftRadius: "10px"
|
|
105
|
-
},
|
|
106
|
-
"& > div:last-of-type .MuiInputBase-root, & > div:last-of-type .MuiButtonBase-root, & > div:last-of-type .MuiChip-root": {
|
|
107
|
-
borderTopRightRadius: "10px",
|
|
108
|
-
borderBottomRightRadius: "10px",
|
|
109
|
-
border: "none !important"
|
|
110
|
-
},
|
|
111
|
-
// Estilo para los componentes que tienen `InputGroupChild` en la clase
|
|
112
|
-
"& .InputGroupChild": {
|
|
113
|
-
width: "100%"
|
|
114
|
-
},
|
|
115
|
-
"& > div:first-of-type .MuiInputBase-root > .MuiOutlinedInput-notchedOutline": {
|
|
116
|
-
border: "none !important"
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
children: childrenWithDividers
|
|
120
|
-
}
|
|
121
|
-
)
|
|
129
|
+
className: "InputGroup__slot",
|
|
130
|
+
sx: mergeSx(baseSlotSx, slotSx),
|
|
131
|
+
children: child
|
|
132
|
+
},
|
|
133
|
+
i
|
|
134
|
+
))
|
|
122
135
|
}
|
|
123
136
|
);
|
|
124
137
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputGroup.cjs","sources":["../../../src/components/InputGroup/InputGroup.tsx"],"sourcesContent":["import React, { Children,
|
|
1
|
+
{"version":3,"file":"InputGroup.cjs","sources":["../../../src/components/InputGroup/InputGroup.tsx"],"sourcesContent":["import React, { Children, isValidElement } from 'react';\nimport { Box, type SxProps, type Theme } from '@mui/material';\n\nexport interface InputGroupProps {\n children: React.ReactNode;\n /**\n * sx aplicado al contenedor raíz del grupo. Se mergea sobre los defaults.\n */\n sx?: SxProps<Theme>;\n /**\n * sx aplicado a cada slot individual. Útil para controlar flex/gap entre\n * los hijos del grupo.\n */\n slotSx?: SxProps<Theme>;\n /**\n * Radio del borde del grupo. Default: 10.\n */\n borderRadius?: number | string;\n /**\n * Desactiva visualmente el grupo (no cascada lógica — los hijos deben\n * manejar su propio `disabled`).\n */\n disabled?: boolean;\n /**\n * Orientación del grupo. Default: 'horizontal'.\n */\n orientation?: 'horizontal' | 'vertical';\n className?: string;\n}\n\nconst mergeSx = (base: SxProps<Theme>, extra?: SxProps<Theme>): SxProps<Theme> => {\n if (!extra) return base;\n const baseArr = Array.isArray(base) ? base : [base];\n const extraArr = Array.isArray(extra) ? extra : [extra];\n return [...baseArr, ...extraArr] as SxProps<Theme>;\n};\n\n/**\n * Agrupa visualmente varios componentes de entrada (Input / Select / DatePicker /\n * Button, etc.) compartiendo un solo borde y con separadores internos.\n *\n * El grupo respeta el espacio que Input/Select reservan para su label `outside`\n * (marginTop=14px) moviendo ese reservado al contenedor externo y cancelándolo\n * en los hijos. Los labels siguen flotando por encima del borde del grupo con\n * la misma animación que fuera del grupo.\n *\n * No inspecciona el tipo de cada hijo; aplica los overrides a través de\n * descendant selectors por CSS para funcionar con cualquier wrapper / memoizado.\n */\nconst InputGroup: React.FC<InputGroupProps> = ({\n children,\n sx,\n slotSx,\n borderRadius = 10,\n disabled,\n orientation = 'horizontal',\n className,\n}) => {\n const radius = typeof borderRadius === 'number' ? `${borderRadius}px` : borderRadius;\n const slots = Children.toArray(children).filter(isValidElement);\n const isHorizontal = orientation === 'horizontal';\n\n const baseSx: SxProps<Theme> = {\n // Respeta el label \"outside\" de Input/Select: los hijos pierden su marginTop\n // (ver más abajo) y el grupo reserva el mismo espacio arriba para que los\n // labels floten por encima del borde del grupo.\n marginTop: '14px',\n\n display: 'flex',\n flexDirection: isHorizontal ? 'row' : 'column',\n alignItems: 'stretch',\n width: '100%',\n border: (theme) => `1px solid ${theme.palette.divider}`,\n borderRadius: radius,\n backgroundColor: 'background.paper',\n transition: 'border-color 200ms cubic-bezier(0.0, 0, 0.2, 1) 0ms, box-shadow 200ms cubic-bezier(0.0, 0, 0.2, 1) 0ms',\n '&:focus-within': {\n borderColor: 'primary.main',\n boxShadow: (theme) => `0 0 0 1px ${theme.palette.primary.main}`,\n },\n opacity: disabled ? 0.6 : 1,\n pointerEvents: disabled ? 'none' : 'auto',\n\n // Cancelar el marginTop que Input/Select reservan en labelPosition=\"outside\".\n // El grupo ya lo reservó en su nivel externo.\n '& .MuiFormControl-root, & > .InputGroup__slot > .MuiTextField-root, & > .InputGroup__slot > .MuiFormControl-root': {\n marginTop: 0,\n },\n\n // Quitar el borde del notched outline interno: el borde visible es el del\n // grupo, los separadores son los borderRight/borderBottom de cada slot.\n '& .MuiOutlinedInput-notchedOutline': {\n border: 'none',\n },\n\n // Forzar que todos los campos pinten sus esquinas cuadradas (las esquinas\n // redondeadas se aplican solo al primer/último slot más abajo).\n '& .MuiInputBase-root, & .MuiChip-root': {\n borderRadius: 0,\n },\n\n // Botones integrados: sin radius propio, altura completa, sin sombra.\n '& .MuiButton-root': {\n borderRadius: 0,\n height: '100%',\n boxShadow: 'none',\n border: 'none',\n },\n\n // Slots: cada hijo vive en un slot neutro que lo centra verticalmente.\n '& > .InputGroup__slot': {\n flex: 1,\n display: 'flex',\n alignItems: 'center',\n minWidth: 0,\n // Separador entre slots (horizontal: borderRight / vertical: borderBottom),\n // usando el color de divider del theme.\n ...(isHorizontal\n ? { borderRight: (theme: Theme) => `1px solid ${theme.palette.divider}` }\n : { borderBottom: (theme: Theme) => `1px solid ${theme.palette.divider}` }),\n '&:last-of-type': {\n borderRight: 'none',\n borderBottom: 'none',\n },\n },\n\n // Esquinas redondeadas: primer slot (izquierda o arriba).\n '& > .InputGroup__slot:first-of-type .MuiInputBase-root, & > .InputGroup__slot:first-of-type .MuiButton-root, & > .InputGroup__slot:first-of-type .MuiChip-root':\n isHorizontal\n ? {\n borderTopLeftRadius: radius,\n borderBottomLeftRadius: radius,\n }\n : {\n borderTopLeftRadius: radius,\n borderTopRightRadius: radius,\n },\n\n // Esquinas redondeadas: último slot (derecha o abajo).\n '& > .InputGroup__slot:last-of-type .MuiInputBase-root, & > .InputGroup__slot:last-of-type .MuiButton-root, & > .InputGroup__slot:last-of-type .MuiChip-root':\n isHorizontal\n ? {\n borderTopRightRadius: radius,\n borderBottomRightRadius: radius,\n }\n : {\n borderBottomLeftRadius: radius,\n borderBottomRightRadius: radius,\n },\n };\n\n const baseSlotSx: SxProps<Theme> = {\n flex: 1,\n display: 'flex',\n alignItems: 'center',\n minWidth: 0,\n };\n\n return (\n <Box\n data-testid=\"input-group\"\n className={className}\n aria-disabled={disabled ? 'true' : undefined}\n sx={mergeSx(baseSx, sx)}\n >\n {slots.map((child, i) => (\n <Box\n key={i}\n className=\"InputGroup__slot\"\n sx={mergeSx(baseSlotSx, slotSx)}\n >\n {child}\n </Box>\n ))}\n </Box>\n );\n};\n\nexport default InputGroup;\n"],"names":["Children","isValidElement","jsx","Box"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAM,UAAU,CAAC,MAAsB,UAA2C;AAChF,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,UAAU,MAAM,QAAQ,IAAI,IAAI,OAAO,CAAC,IAAI;AAClD,QAAM,WAAW,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK;AACtD,SAAO,CAAC,GAAG,SAAS,GAAG,QAAQ;AACjC;AAcA,MAAM,aAAwC,CAAC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA,cAAc;AAAA,EACd;AACF,MAAM;AACJ,QAAM,SAAS,OAAO,iBAAiB,WAAW,GAAG,YAAY,OAAO;AACxE,QAAM,QAAQA,MAAAA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sB;AAAA,IAAA;AAAA;AAAA,IAI9B,+JACE,eACI;AAAA,MACE,sBAAsB;AAAA,MACtB,yBAAyB;AAAA,IAAA,IAE3B;AAAA,MACE,wBAAwB;AAAA,MACxB,yBAAyB;AAAA,IAAA;AAAA,EAC3B;AAGR,QAAM,aAA6B;AAAA,IACjC,MAAM;AAAA,IACN,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,UAAU;AAAA,EAAA;AAGZ,SACEC,2BAAAA;AAAAA,IAACC,SAAAA;AAAAA,IAAA;AAAA,MACC,eAAY;AAAA,MACZ;AAAA,MACA,iBAAe,WAAW,SAAS;AAAA,MACnC,IAAI,QAAQ,QAAQ,EAAE;AAAA,MAErB,UAAA,MAAM,IAAI,CAAC,OAAO,MACjBD,2BAAAA;AAAAA,QAACC,SAAAA;AAAAA,QAAA;AAAA,UAEC,WAAU;AAAA,UACV,IAAI,QAAQ,YAAY,MAAM;AAAA,UAE7B,UAAA;AAAA,QAAA;AAAA,QAJI;AAAA,MAAA,CAMR;AAAA,IAAA;AAAA,EAAA;AAGP;;"}
|
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
|
|
2
|
+
import { SxProps, Theme } from '@mui/material';
|
|
3
|
+
export interface InputGroupProps {
|
|
3
4
|
children: React.ReactNode;
|
|
5
|
+
/**
|
|
6
|
+
* sx aplicado al contenedor raíz del grupo. Se mergea sobre los defaults.
|
|
7
|
+
*/
|
|
8
|
+
sx?: SxProps<Theme>;
|
|
9
|
+
/**
|
|
10
|
+
* sx aplicado a cada slot individual. Útil para controlar flex/gap entre
|
|
11
|
+
* los hijos del grupo.
|
|
12
|
+
*/
|
|
13
|
+
slotSx?: SxProps<Theme>;
|
|
14
|
+
/**
|
|
15
|
+
* Radio del borde del grupo. Default: 10.
|
|
16
|
+
*/
|
|
17
|
+
borderRadius?: number | string;
|
|
18
|
+
/**
|
|
19
|
+
* Desactiva visualmente el grupo (no cascada lógica — los hijos deben
|
|
20
|
+
* manejar su propio `disabled`).
|
|
21
|
+
*/
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Orientación del grupo. Default: 'horizontal'.
|
|
25
|
+
*/
|
|
26
|
+
orientation?: 'horizontal' | 'vertical';
|
|
27
|
+
className?: string;
|
|
4
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Agrupa visualmente varios componentes de entrada (Input / Select / DatePicker /
|
|
31
|
+
* Button, etc.) compartiendo un solo borde y con separadores internos.
|
|
32
|
+
*
|
|
33
|
+
* El grupo respeta el espacio que Input/Select reservan para su label `outside`
|
|
34
|
+
* (marginTop=14px) moviendo ese reservado al contenedor externo y cancelándolo
|
|
35
|
+
* en los hijos. Los labels siguen flotando por encima del borde del grupo con
|
|
36
|
+
* la misma animación que fuera del grupo.
|
|
37
|
+
*
|
|
38
|
+
* No inspecciona el tipo de cada hijo; aplica los overrides a través de
|
|
39
|
+
* descendant selectors por CSS para funcionar con cualquier wrapper / memoizado.
|
|
40
|
+
*/
|
|
5
41
|
declare const InputGroup: React.FC<InputGroupProps>;
|
|
6
42
|
export default InputGroup;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const BasicInputGroupDefinition = "\nimport { useState } from 'react';\nimport { Box, Typography } from '@mui/material';\nimport InputGroup from './InputGroup';\nimport { Input } from '../Input';\nimport { Button } from '../Button';\n\nexport const BasicInputGroupExample = () => {\n const [text, setText] = useState('');\n return (\n <Box>\n <Typography variant=\"h6\" sx={{ mb: 2 }}>\n Grupo de entrada b\u00E1sico\n </Typography>\n <InputGroup>\n <Input label=\"Buscar\" value={text} onChange={(val) => setText(val as string)} />\n <Button variant=\"outlined\">Buscar</Button>\n </InputGroup>\n </Box>\n );\n};\n";
|
|
2
|
+
export declare const CombinedInputGroupDefinition = "\nimport { useState } from 'react';\nimport { Box, Typography } from '@mui/material';\nimport InputGroup from './InputGroup';\nimport { Input } from '../Input';\nimport Select, { SelectOption } from '../Select/Select';\nimport { Button } from '../Button';\n\nconst basicOptions: SelectOption[] = [\n { value: '10', label: '10' },\n { value: '25', label: '25' },\n { value: '50', label: '50' },\n { value: '100', label: '100' },\n];\n\nexport const CombinedInputGroupExample = () => {\n const [text, setText] = useState('');\n const [selectValue, setSelectValue] = useState('25');\n\n return (\n <Box>\n <Typography variant=\"h6\" sx={{ mb: 2 }}>\n Grupo de entrada combinado\n </Typography>\n <InputGroup>\n <Select\n label=\"Registros\"\n options={basicOptions}\n value={selectValue}\n onChange={(val) => setSelectValue(val as string)}\n />\n <Input\n label=\"Filtrar por nombre\"\n value={text}\n onChange={(val) => setText(val as string)}\n />\n <Button variant=\"contained\">Aplicar</Button>\n </InputGroup>\n </Box>\n );\n};\n";
|
|
3
|
+
export declare const DatePickerInputGroupDefinition = "\nimport { useState } from 'react';\nimport { Box, Typography } from '@mui/material';\nimport dayjs, { Dayjs } from 'dayjs';\nimport InputGroup from './InputGroup';\nimport { DatePicker } from '../DatePicker';\nimport { Button } from '../Button';\n\nexport const DatePickerInputGroupExample = () => {\n const [selectedDate, setSelectedDate] = useState<Dayjs | null>(dayjs());\n\n return (\n <Box>\n <Typography variant=\"h6\" sx={{ mb: 2 }}>\n Grupo de entrada con DatePicker\n </Typography>\n <InputGroup>\n <DatePicker\n label=\"Fecha de inicio\"\n selectedDate={selectedDate}\n onDateChange={(date) => setSelectedDate(date)}\n />\n <Button variant=\"contained\">Ver calendario</Button>\n </InputGroup>\n </Box>\n );\n};\n";
|
|
4
|
+
export declare const VerticalInputGroupDefinition = "\nimport { useState } from 'react';\nimport { Box } from '@mui/material';\nimport InputGroup from './InputGroup';\nimport { Input } from '../Input';\n\nexport const VerticalInputGroupExample = () => {\n const [nombre, setNombre] = useState('');\n const [email, setEmail] = useState('');\n\n return (\n <Box sx={{ width: 320 }}>\n <InputGroup orientation=\"vertical\">\n <Input label=\"Nombre\" value={nombre} onChange={(val) => setNombre(val as string)} />\n <Input label=\"Email\" value={email} onChange={(val) => setEmail(val as string)} />\n </InputGroup>\n </Box>\n );\n};\n";
|
|
5
|
+
export declare const CustomStylingInputGroupDefinition = "\nimport { useState } from 'react';\nimport { Box } from '@mui/material';\nimport InputGroup from './InputGroup';\nimport { Input } from '../Input';\nimport { Button } from '../Button';\n\nexport const CustomStylingInputGroupExample = () => {\n const [q, setQ] = useState('');\n\n return (\n <Box sx={{ width: 500 }}>\n <InputGroup\n borderRadius={999}\n sx={{\n bgcolor: 'action.hover',\n borderColor: 'primary.main',\n }}\n >\n <Input label=\"B\u00FAsqueda avanzada\" value={q} onChange={(val) => setQ(val as string)} />\n <Button variant=\"contained\" color=\"primary\">Buscar</Button>\n </InputGroup>\n </Box>\n );\n};\n";
|
|
6
|
+
export declare const DisabledInputGroupDefinition = "\nimport { Box } from '@mui/material';\nimport InputGroup from './InputGroup';\nimport { Input } from '../Input';\nimport { Button } from '../Button';\n\nexport const DisabledInputGroupExample = () => (\n <Box sx={{ width: 400 }}>\n <InputGroup disabled>\n <Input label=\"B\u00FAsqueda\" value=\"\" onChange={() => {}} disabled />\n <Button variant=\"outlined\" disabled>Buscar</Button>\n </InputGroup>\n </Box>\n);\n";
|
|
@@ -18,105 +18,118 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
import { jsx } from "react/jsx-runtime";
|
|
21
|
-
import { Children, isValidElement
|
|
22
|
-
import { Box
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
21
|
+
import { Children, isValidElement } from "react";
|
|
22
|
+
import { Box } from "@mui/material";
|
|
23
|
+
const mergeSx = (base, extra) => {
|
|
24
|
+
if (!extra) return base;
|
|
25
|
+
const baseArr = Array.isArray(base) ? base : [base];
|
|
26
|
+
const extraArr = Array.isArray(extra) ? extra : [extra];
|
|
27
|
+
return [...baseArr, ...extraArr];
|
|
28
|
+
};
|
|
29
|
+
const InputGroup = ({
|
|
30
|
+
children,
|
|
31
|
+
sx,
|
|
32
|
+
slotSx,
|
|
33
|
+
borderRadius = 10,
|
|
34
|
+
disabled,
|
|
35
|
+
orientation = "horizontal",
|
|
36
|
+
className
|
|
37
|
+
}) => {
|
|
38
|
+
const radius = typeof borderRadius === "number" ? `${borderRadius}px` : borderRadius;
|
|
39
|
+
const slots = Children.toArray(children).filter(isValidElement);
|
|
40
|
+
const isHorizontal = orientation === "horizontal";
|
|
41
|
+
const baseSx = {
|
|
42
|
+
// Respeta el label "outside" de Input/Select: los hijos pierden su marginTop
|
|
43
|
+
// (ver más abajo) y el grupo reserva el mismo espacio arriba para que los
|
|
44
|
+
// labels floten por encima del borde del grupo.
|
|
45
|
+
marginTop: "14px",
|
|
46
|
+
display: "flex",
|
|
47
|
+
flexDirection: isHorizontal ? "row" : "column",
|
|
48
|
+
alignItems: "stretch",
|
|
49
|
+
width: "100%",
|
|
50
|
+
border: (theme) => `1px solid ${theme.palette.divider}`,
|
|
51
|
+
borderRadius: radius,
|
|
52
|
+
backgroundColor: "background.paper",
|
|
53
|
+
transition: "border-color 200ms cubic-bezier(0.0, 0, 0.2, 1) 0ms, box-shadow 200ms cubic-bezier(0.0, 0, 0.2, 1) 0ms",
|
|
54
|
+
"&:focus-within": {
|
|
55
|
+
borderColor: "primary.main",
|
|
56
|
+
boxShadow: (theme) => `0 0 0 1px ${theme.palette.primary.main}`
|
|
57
|
+
},
|
|
58
|
+
opacity: disabled ? 0.6 : 1,
|
|
59
|
+
pointerEvents: disabled ? "none" : "auto",
|
|
60
|
+
// Cancelar el marginTop que Input/Select reservan en labelPosition="outside".
|
|
61
|
+
// El grupo ya lo reservó en su nivel externo.
|
|
62
|
+
"& .MuiFormControl-root, & > .InputGroup__slot > .MuiTextField-root, & > .InputGroup__slot > .MuiFormControl-root": {
|
|
63
|
+
marginTop: 0
|
|
64
|
+
},
|
|
65
|
+
// Quitar el borde del notched outline interno: el borde visible es el del
|
|
66
|
+
// grupo, los separadores son los borderRight/borderBottom de cada slot.
|
|
67
|
+
"& .MuiOutlinedInput-notchedOutline": {
|
|
68
|
+
border: "none"
|
|
69
|
+
},
|
|
70
|
+
// Forzar que todos los campos pinten sus esquinas cuadradas (las esquinas
|
|
71
|
+
// redondeadas se aplican solo al primer/último slot más abajo).
|
|
72
|
+
"& .MuiInputBase-root, & .MuiChip-root": {
|
|
73
|
+
borderRadius: 0
|
|
74
|
+
},
|
|
75
|
+
// Botones integrados: sin radius propio, altura completa, sin sombra.
|
|
76
|
+
"& .MuiButton-root": {
|
|
77
|
+
borderRadius: 0,
|
|
78
|
+
height: "100%",
|
|
79
|
+
boxShadow: "none",
|
|
80
|
+
border: "none"
|
|
81
|
+
},
|
|
82
|
+
// Slots: cada hijo vive en un slot neutro que lo centra verticalmente.
|
|
83
|
+
"& > .InputGroup__slot": __spreadProps(__spreadValues({
|
|
84
|
+
flex: 1,
|
|
85
|
+
display: "flex",
|
|
86
|
+
alignItems: "center",
|
|
87
|
+
minWidth: 0
|
|
88
|
+
}, isHorizontal ? { borderRight: (theme) => `1px solid ${theme.palette.divider}` } : { borderBottom: (theme) => `1px solid ${theme.palette.divider}` }), {
|
|
89
|
+
"&:last-of-type": {
|
|
90
|
+
borderRight: "none",
|
|
91
|
+
borderBottom: "none"
|
|
92
|
+
}
|
|
93
|
+
}),
|
|
94
|
+
// Esquinas redondeadas: primer slot (izquierda o arriba).
|
|
95
|
+
"& > .InputGroup__slot:first-of-type .MuiInputBase-root, & > .InputGroup__slot:first-of-type .MuiButton-root, & > .InputGroup__slot:first-of-type .MuiChip-root": isHorizontal ? {
|
|
96
|
+
borderTopLeftRadius: radius,
|
|
97
|
+
borderBottomLeftRadius: radius
|
|
98
|
+
} : {
|
|
99
|
+
borderTopLeftRadius: radius,
|
|
100
|
+
borderTopRightRadius: radius
|
|
101
|
+
},
|
|
102
|
+
// Esquinas redondeadas: último slot (derecha o abajo).
|
|
103
|
+
"& > .InputGroup__slot:last-of-type .MuiInputBase-root, & > .InputGroup__slot:last-of-type .MuiButton-root, & > .InputGroup__slot:last-of-type .MuiChip-root": isHorizontal ? {
|
|
104
|
+
borderTopRightRadius: radius,
|
|
105
|
+
borderBottomRightRadius: radius
|
|
106
|
+
} : {
|
|
107
|
+
borderBottomLeftRadius: radius,
|
|
108
|
+
borderBottomRightRadius: radius
|
|
72
109
|
}
|
|
73
|
-
|
|
74
|
-
|
|
110
|
+
};
|
|
111
|
+
const baseSlotSx = {
|
|
112
|
+
flex: 1,
|
|
113
|
+
display: "flex",
|
|
114
|
+
alignItems: "center",
|
|
115
|
+
minWidth: 0
|
|
116
|
+
};
|
|
75
117
|
return /* @__PURE__ */ jsx(
|
|
76
118
|
Box,
|
|
77
119
|
{
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
},
|
|
84
|
-
children: /* @__PURE__ */ jsx(
|
|
120
|
+
"data-testid": "input-group",
|
|
121
|
+
className,
|
|
122
|
+
"aria-disabled": disabled ? "true" : void 0,
|
|
123
|
+
sx: mergeSx(baseSx, sx),
|
|
124
|
+
children: slots.map((child, i) => /* @__PURE__ */ jsx(
|
|
85
125
|
Box,
|
|
86
126
|
{
|
|
87
|
-
className: "
|
|
88
|
-
sx:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
borderRadius: "10px",
|
|
94
|
-
padding: "8px 0px",
|
|
95
|
-
marginTop: "-5px",
|
|
96
|
-
marginBottom: "20px",
|
|
97
|
-
"& .MuiInputBase-root, & .MuiButtonBase-root, & .MuiChip-root": {
|
|
98
|
-
borderRadius: 0
|
|
99
|
-
},
|
|
100
|
-
"& > div:first-of-type .MuiInputBase-root, & > div:first-of-type .MuiButtonBase-root, & > div:first-of-type .MuiChip-root": {
|
|
101
|
-
borderTopLeftRadius: "10px",
|
|
102
|
-
borderBottomLeftRadius: "10px"
|
|
103
|
-
},
|
|
104
|
-
"& > div:last-of-type .MuiInputBase-root, & > div:last-of-type .MuiButtonBase-root, & > div:last-of-type .MuiChip-root": {
|
|
105
|
-
borderTopRightRadius: "10px",
|
|
106
|
-
borderBottomRightRadius: "10px",
|
|
107
|
-
border: "none !important"
|
|
108
|
-
},
|
|
109
|
-
// Estilo para los componentes que tienen `InputGroupChild` en la clase
|
|
110
|
-
"& .InputGroupChild": {
|
|
111
|
-
width: "100%"
|
|
112
|
-
},
|
|
113
|
-
"& > div:first-of-type .MuiInputBase-root > .MuiOutlinedInput-notchedOutline": {
|
|
114
|
-
border: "none !important"
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
children: childrenWithDividers
|
|
118
|
-
}
|
|
119
|
-
)
|
|
127
|
+
className: "InputGroup__slot",
|
|
128
|
+
sx: mergeSx(baseSlotSx, slotSx),
|
|
129
|
+
children: child
|
|
130
|
+
},
|
|
131
|
+
i
|
|
132
|
+
))
|
|
120
133
|
}
|
|
121
134
|
);
|
|
122
135
|
};
|