@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
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Re-export barrel para compatibilidad con imports antiguos.
|
|
2
|
+
// Los tipos ahora viven dentro de Select.tsx.
|
|
3
|
+
export type {
|
|
4
|
+
SelectOption,
|
|
5
|
+
LabelPosition,
|
|
6
|
+
ChipVariant,
|
|
7
|
+
SelectSize,
|
|
8
|
+
RenderOptionItem,
|
|
9
|
+
RenderChipLabel,
|
|
10
|
+
OptionProps,
|
|
11
|
+
BaseSelectProps,
|
|
12
|
+
RHFSelectProps,
|
|
13
|
+
StandardSelectProps,
|
|
14
|
+
SelectProps,
|
|
15
|
+
} from './Select';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ListItemIcon, MenuItem } from '@mui/material';
|
|
3
|
+
import CheckIcon from '@mui/icons-material/Check';
|
|
4
|
+
|
|
5
|
+
import type { SelectOption, RenderOptionItem } from '../Select';
|
|
6
|
+
|
|
7
|
+
interface RenderSelectMenuItemArgs {
|
|
8
|
+
option: SelectOption;
|
|
9
|
+
selected: boolean;
|
|
10
|
+
customRender?: RenderOptionItem | null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Render helper (no componente) que devuelve un <MenuItem> listo para
|
|
15
|
+
* colocarse como hijo directo del <MuiSelect>. Se implementa como función
|
|
16
|
+
* y no como componente porque MUI Select inspecciona `props.value` de sus
|
|
17
|
+
* children para resolver la selección, y envolverlo en un componente extra
|
|
18
|
+
* rompe esa detección.
|
|
19
|
+
*
|
|
20
|
+
* Incluye el icono de check a la izquierda cuando `selected` es true. Si el
|
|
21
|
+
* consumer pasó un `<Option>{(opt) => ...}</Option>`, usa ese render para el
|
|
22
|
+
* contenido principal; de lo contrario muestra `option.label`.
|
|
23
|
+
*/
|
|
24
|
+
export const renderSelectMenuItem = ({
|
|
25
|
+
option,
|
|
26
|
+
selected,
|
|
27
|
+
customRender,
|
|
28
|
+
}: RenderSelectMenuItemArgs): React.ReactElement => (
|
|
29
|
+
<MenuItem
|
|
30
|
+
key={String(option.value)}
|
|
31
|
+
value={option.value}
|
|
32
|
+
disabled={option.disabled}
|
|
33
|
+
selected={selected}
|
|
34
|
+
>
|
|
35
|
+
<ListItemIcon sx={{ minWidth: 32 }}>
|
|
36
|
+
{selected && <CheckIcon color="success" fontSize="small" />}
|
|
37
|
+
</ListItemIcon>
|
|
38
|
+
{customRender ? customRender(option) : option.label}
|
|
39
|
+
</MenuItem>
|
|
40
|
+
);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ListSubheader, TextField } from '@mui/material';
|
|
3
|
+
|
|
4
|
+
interface SelectSearchHeaderProps {
|
|
5
|
+
value: string;
|
|
6
|
+
onChange: (next: string) => void;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
inputRef?: React.Ref<HTMLInputElement>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Header sticky del menu del Select que contiene el input de búsqueda.
|
|
13
|
+
* Se usa cuando `filterable` es true o cuando el Select opera en modo async.
|
|
14
|
+
* Detiene la propagación de click/keydown para que el menu no se cierre ni
|
|
15
|
+
* intercepte las teclas al tipear.
|
|
16
|
+
*/
|
|
17
|
+
export const SelectSearchHeader: React.FC<SelectSearchHeaderProps> = ({
|
|
18
|
+
value,
|
|
19
|
+
onChange,
|
|
20
|
+
placeholder = 'Buscar...',
|
|
21
|
+
inputRef,
|
|
22
|
+
}) => {
|
|
23
|
+
return (
|
|
24
|
+
<ListSubheader
|
|
25
|
+
sx={{
|
|
26
|
+
px: 2,
|
|
27
|
+
pt: 1,
|
|
28
|
+
pb: 1,
|
|
29
|
+
backgroundColor: 'background.paper',
|
|
30
|
+
zIndex: 1,
|
|
31
|
+
position: 'sticky',
|
|
32
|
+
top: 0,
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
<TextField
|
|
36
|
+
inputRef={inputRef}
|
|
37
|
+
placeholder={placeholder}
|
|
38
|
+
variant="standard"
|
|
39
|
+
size="small"
|
|
40
|
+
fullWidth
|
|
41
|
+
value={value}
|
|
42
|
+
onChange={(e) => onChange(e.target.value)}
|
|
43
|
+
slotProps={{ htmlInput: { autoFocus: true } }}
|
|
44
|
+
onClick={(e) => e.stopPropagation()}
|
|
45
|
+
onKeyDown={(e) => e.stopPropagation()}
|
|
46
|
+
/>
|
|
47
|
+
</ListSubheader>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export default SelectSearchHeader;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Avatar, Box, Chip, Typography } from '@mui/material';
|
|
3
|
+
import ClearIcon from '@mui/icons-material/Clear';
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
SelectOption,
|
|
7
|
+
RenderChipLabel,
|
|
8
|
+
ChipVariant,
|
|
9
|
+
} from '../Select';
|
|
10
|
+
|
|
11
|
+
interface SelectValueProps<TValue extends SelectOption['value']> {
|
|
12
|
+
selected: TValue | TValue[] | null | undefined;
|
|
13
|
+
options: SelectOption[];
|
|
14
|
+
multiple: boolean;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
maxChipsToShow: number;
|
|
17
|
+
chipVariant: ChipVariant;
|
|
18
|
+
renderChipLabel?: RenderChipLabel;
|
|
19
|
+
/** Solo relevante en modo multiple. Recibe el nuevo array de valores. */
|
|
20
|
+
onDeleteChip?: (nextValues: TValue[]) => void;
|
|
21
|
+
/** Array de valores actuales (para componer el nuevo array al borrar chips). */
|
|
22
|
+
currentValues?: TValue[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Render del valor seleccionado del Select.
|
|
27
|
+
* - single: texto (label) o lo que devuelva `renderChipLabel`.
|
|
28
|
+
* - multiple: chips con delete. Trunca después de `maxChipsToShow` mostrando "+N más".
|
|
29
|
+
* - empty: placeholder en color disabled.
|
|
30
|
+
*/
|
|
31
|
+
export function SelectValue<TValue extends SelectOption['value']>(
|
|
32
|
+
props: SelectValueProps<TValue>,
|
|
33
|
+
) {
|
|
34
|
+
const {
|
|
35
|
+
selected,
|
|
36
|
+
options,
|
|
37
|
+
multiple,
|
|
38
|
+
placeholder,
|
|
39
|
+
maxChipsToShow,
|
|
40
|
+
chipVariant,
|
|
41
|
+
renderChipLabel,
|
|
42
|
+
onDeleteChip,
|
|
43
|
+
currentValues,
|
|
44
|
+
} = props;
|
|
45
|
+
|
|
46
|
+
const isEmpty =
|
|
47
|
+
!selected || (Array.isArray(selected) && selected.length === 0);
|
|
48
|
+
|
|
49
|
+
if (isEmpty) {
|
|
50
|
+
return (
|
|
51
|
+
<Typography sx={{ color: 'text.disabled' }}>{placeholder || ''}</Typography>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (!multiple) {
|
|
56
|
+
const item = options.find((opt) => opt.value === selected);
|
|
57
|
+
if (renderChipLabel && item) return <>{renderChipLabel(item)}</>;
|
|
58
|
+
return <>{item?.label ?? String(selected)}</>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const selectedValuesArray = selected as TValue[];
|
|
62
|
+
const displayedChips = selectedValuesArray.slice(0, maxChipsToShow);
|
|
63
|
+
const hiddenChipsCount = selectedValuesArray.length - maxChipsToShow;
|
|
64
|
+
|
|
65
|
+
const handleDelete = (chipValue: TValue) => {
|
|
66
|
+
if (!onDeleteChip || !currentValues) return;
|
|
67
|
+
onDeleteChip(currentValues.filter((v) => v !== chipValue));
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 0.5 }}>
|
|
72
|
+
{displayedChips.map((val) => {
|
|
73
|
+
const item = options.find((o) => o.value === val);
|
|
74
|
+
if (!item) return null;
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<Chip
|
|
78
|
+
variant={chipVariant}
|
|
79
|
+
color="primary"
|
|
80
|
+
size="small"
|
|
81
|
+
key={String(val)}
|
|
82
|
+
label={renderChipLabel ? renderChipLabel(item) : item.label}
|
|
83
|
+
avatar={item.img ? <Avatar src={item.img} /> : undefined}
|
|
84
|
+
onDelete={() => handleDelete(val)}
|
|
85
|
+
deleteIcon={<ClearIcon fontSize="small" />}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
88
|
+
})}
|
|
89
|
+
{hiddenChipsCount > 0 && (
|
|
90
|
+
<Chip size="small" variant={chipVariant} label={`+${hiddenChipsCount} más`} />
|
|
91
|
+
)}
|
|
92
|
+
</Box>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export default SelectValue;
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Select, Option, default } from './Select';
|
|
2
|
+
export type {
|
|
3
|
+
SelectProps,
|
|
4
|
+
SelectOption,
|
|
5
|
+
OptionProps,
|
|
6
|
+
BaseSelectProps,
|
|
7
|
+
RHFSelectProps,
|
|
8
|
+
StandardSelectProps,
|
|
9
|
+
RenderOptionItem,
|
|
10
|
+
RenderChipLabel,
|
|
11
|
+
LabelPosition,
|
|
12
|
+
ChipVariant,
|
|
13
|
+
SelectSize,
|
|
14
|
+
} from './Select.types';
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import React, { ReactElement } from "react";
|
|
2
2
|
import { Stepper as MuiStepper, Step as MuiStep, StepLabel as MuiStepLabel, Box } from "@mui/material";
|
|
3
3
|
import { StepProps } from "./Step";
|
|
4
|
+
import { useWizard } from "../../hooks/Wizard";
|
|
4
5
|
|
|
5
6
|
interface MyStepperProps {
|
|
6
7
|
children: ReactElement<StepProps>[];
|
|
7
8
|
orientation?: "horizontal" | "vertical";
|
|
8
9
|
sx?: object;
|
|
9
10
|
alternateLabel?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Índice 0-based del paso activo. Si no se provee, el Stepper intenta
|
|
13
|
+
* leerlo del `WizardContext` (si está dentro de un `<WizardProvider>`).
|
|
14
|
+
* Si tampoco hay provider, el default es 0.
|
|
15
|
+
*/
|
|
10
16
|
currentStep?: number;
|
|
11
17
|
}
|
|
12
18
|
|
|
@@ -16,8 +22,18 @@ export const Stepper: React.FC<MyStepperProps> = ({
|
|
|
16
22
|
alternateLabel = false,
|
|
17
23
|
|
|
18
24
|
sx,
|
|
19
|
-
currentStep
|
|
25
|
+
currentStep: currentStepProp,
|
|
20
26
|
}) => {
|
|
27
|
+
// Lee el paso desde el WizardContext cuando el consumer no lo pasa como prop.
|
|
28
|
+
// Si el Stepper NO está dentro de un WizardProvider, `useWizard()` devuelve
|
|
29
|
+
// el valor default (currentStep=0, totalSteps=0), así que no rompe nada.
|
|
30
|
+
const wizard = useWizard();
|
|
31
|
+
const currentStep =
|
|
32
|
+
currentStepProp !== undefined
|
|
33
|
+
? currentStepProp
|
|
34
|
+
: wizard.totalSteps > 0
|
|
35
|
+
? wizard.currentStep
|
|
36
|
+
: 0;
|
|
21
37
|
|
|
22
38
|
return (
|
|
23
39
|
<Box sx={sx}>
|
|
@@ -1,9 +1,21 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
3
|
import Tooltip from './Tooltip'; // Asegúrate que la ruta sea correcta
|
|
4
4
|
import Button from '@mui/material/Button';
|
|
5
|
-
import TextField from '@mui/material/TextField';
|
|
6
5
|
import Stack from '@mui/material/Stack';
|
|
6
|
+
import { Input } from '../Input/Input';
|
|
7
|
+
|
|
8
|
+
// Helper controlado para envolver nuestro Input propio con estado local
|
|
9
|
+
const TooltipNameInput: React.FC = () => {
|
|
10
|
+
const [value, setValue] = useState<string | number>('');
|
|
11
|
+
return (
|
|
12
|
+
<Input
|
|
13
|
+
label="Nombre"
|
|
14
|
+
value={value}
|
|
15
|
+
onChange={(next) => setValue(next)}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
7
19
|
|
|
8
20
|
// --- Metadatos de la Historia ---
|
|
9
21
|
// Define la configuración global de tu componente en Storybook
|
|
@@ -61,7 +73,7 @@ export const AplicadoAElementoDeFormulario: Story = {
|
|
|
61
73
|
args: {
|
|
62
74
|
text: 'Introduce tu nombre completo y validado.',
|
|
63
75
|
maxWidth: 300,
|
|
64
|
-
children: <
|
|
76
|
+
children: <TooltipNameInput />,
|
|
65
77
|
},
|
|
66
78
|
};
|
|
67
79
|
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { SxProps, Theme } from '@mui/material/styles';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
LABEL_COLOR_FILLED,
|
|
5
|
+
LABEL_COLOR_FOCUSED,
|
|
6
|
+
LABEL_COLOR_REST,
|
|
7
|
+
LABEL_FONT_WEIGHT_FILLED,
|
|
8
|
+
LABEL_MARGIN_TOP,
|
|
9
|
+
LABEL_SHRINK_TRANSFORM,
|
|
10
|
+
LABEL_TRANSFORM_ORIGIN,
|
|
11
|
+
LABEL_TRANSITION,
|
|
12
|
+
} from '../../theme/tokens';
|
|
13
|
+
|
|
14
|
+
export type LabelPosition = 'outside' | 'floating';
|
|
15
|
+
|
|
16
|
+
export interface BuildFormFieldSxOptions {
|
|
17
|
+
borderRadius: number | string;
|
|
18
|
+
labelPosition: LabelPosition;
|
|
19
|
+
/**
|
|
20
|
+
* Si es `true`, los selectores incluyen también la API nueva de MUI X
|
|
21
|
+
* Pickers (v8): `MuiPickersInputBase-root`, `MuiPickersOutlinedInput-*`.
|
|
22
|
+
*/
|
|
23
|
+
includePickersApi?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Selectores/valores extra que se mergean SOLO cuando labelPosition === 'outside'.
|
|
26
|
+
* Usar para paddings específicos del componente (p.ej. MuiAutocomplete-input).
|
|
27
|
+
*/
|
|
28
|
+
extraOutsideSx?: Record<string, any>;
|
|
29
|
+
/**
|
|
30
|
+
* Selectores/valores extra que se mergean SOLO cuando labelPosition === 'floating'.
|
|
31
|
+
*/
|
|
32
|
+
extraFloatingSx?: Record<string, any>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const toRadius = (borderRadius: number | string) =>
|
|
36
|
+
typeof borderRadius === 'number' ? `${borderRadius}px` : borderRadius;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Builder del sx compartido por todos los campos de formulario
|
|
40
|
+
* (Input/Select/Autocomplete/DatePicker/DateTimePicker).
|
|
41
|
+
*
|
|
42
|
+
* Produce:
|
|
43
|
+
* - en modo "floating": sólo el border-radius del outlined input;
|
|
44
|
+
* - en modo "outside": todo el pack (margen superior, label flotante afuera,
|
|
45
|
+
* input base, notched outline oculto, helper text sin margen izquierdo).
|
|
46
|
+
*
|
|
47
|
+
* Componentes con paddings o selectores propios pueden inyectarlos vía
|
|
48
|
+
* `extraOutsideSx` / `extraFloatingSx`.
|
|
49
|
+
*/
|
|
50
|
+
export const buildFormFieldSx = ({
|
|
51
|
+
borderRadius,
|
|
52
|
+
labelPosition,
|
|
53
|
+
includePickersApi = false,
|
|
54
|
+
extraOutsideSx,
|
|
55
|
+
extraFloatingSx,
|
|
56
|
+
}: BuildFormFieldSxOptions): SxProps<Theme> => {
|
|
57
|
+
const radius = toRadius(borderRadius);
|
|
58
|
+
|
|
59
|
+
// ── Selectores (alternan según la API de pickers) ────────────────────
|
|
60
|
+
const outlinedRootSelector = includePickersApi
|
|
61
|
+
? '& .MuiOutlinedInput-root, & .MuiPickersOutlinedInput-root'
|
|
62
|
+
: '& .MuiOutlinedInput-root';
|
|
63
|
+
|
|
64
|
+
const inputBaseSelector = includePickersApi
|
|
65
|
+
? '& .MuiInputBase-root, & .MuiPickersInputBase-root'
|
|
66
|
+
: '& .MuiInputBase-root';
|
|
67
|
+
|
|
68
|
+
const notchedOutlineSelector = includePickersApi
|
|
69
|
+
? '& .MuiOutlinedInput-notchedOutline, & .MuiPickersOutlinedInput-notchedOutline'
|
|
70
|
+
: '& .MuiOutlinedInput-notchedOutline';
|
|
71
|
+
|
|
72
|
+
// ── Floating ─────────────────────────────────────────────────────────
|
|
73
|
+
if (labelPosition === 'floating') {
|
|
74
|
+
return {
|
|
75
|
+
[outlinedRootSelector]: { borderRadius: radius },
|
|
76
|
+
...(extraFloatingSx ?? {}),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// ── Outside ──────────────────────────────────────────────────────────
|
|
81
|
+
return {
|
|
82
|
+
marginTop: LABEL_MARGIN_TOP,
|
|
83
|
+
|
|
84
|
+
'& .MuiInputLabel-root': {
|
|
85
|
+
color: LABEL_COLOR_REST,
|
|
86
|
+
transition: LABEL_TRANSITION,
|
|
87
|
+
|
|
88
|
+
// Estado shrunk (focused o con valor): flota ARRIBA del input.
|
|
89
|
+
'&.MuiInputLabel-shrink': {
|
|
90
|
+
transform: LABEL_SHRINK_TRANSFORM,
|
|
91
|
+
transformOrigin: LABEL_TRANSFORM_ORIGIN,
|
|
92
|
+
color: LABEL_COLOR_FILLED,
|
|
93
|
+
fontWeight: LABEL_FONT_WEIGHT_FILLED,
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
'&.Mui-focused': { color: LABEL_COLOR_FOCUSED },
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
// Input base — centra verticalmente (clásico y, si aplica, pickers).
|
|
100
|
+
[inputBaseSelector]: {
|
|
101
|
+
borderRadius: radius,
|
|
102
|
+
display: 'flex',
|
|
103
|
+
alignItems: 'center',
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
// El label flota afuera: ocultar legend del notch.
|
|
107
|
+
[notchedOutlineSelector]: {
|
|
108
|
+
top: 0,
|
|
109
|
+
'& legend': { display: 'none' },
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
'& .MuiFormHelperText-root': {
|
|
113
|
+
marginLeft: 0,
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
...(extraOutsideSx ?? {}),
|
|
117
|
+
};
|
|
118
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { SxProps, Theme } from '@mui/material/styles';
|
|
2
|
+
|
|
3
|
+
import type { LibraryComponentName, PresetStyle } from '../../theme/componentStyles';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Nombre del preset built-in del paquete. No se registra en el theme: si un
|
|
7
|
+
* componente recibe `preset="default"` (o no recibe preset), sólo aplica el
|
|
8
|
+
* estilo base de fábrica.
|
|
9
|
+
*/
|
|
10
|
+
export const DEFAULT_PRESET_NAME = 'default';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Resuelve el sx de un preset registrado en `theme.styles[componentName]`.
|
|
14
|
+
*
|
|
15
|
+
* - Si `presetName` es `"default"` o `undefined`, devuelve `undefined`
|
|
16
|
+
* (caller sólo aplicará el estilo base del paquete).
|
|
17
|
+
* - Si la entrada en el theme es una función `(theme) => sx`, se ejecuta.
|
|
18
|
+
* - Si la entrada no existe, devuelve `undefined` silenciosamente (no se
|
|
19
|
+
* rompe el componente — la responsabilidad de registrarlo es del consumer).
|
|
20
|
+
*/
|
|
21
|
+
export function resolvePreset(
|
|
22
|
+
componentName: LibraryComponentName,
|
|
23
|
+
presetName: string | undefined,
|
|
24
|
+
theme: Theme,
|
|
25
|
+
): SxProps<Theme> | undefined {
|
|
26
|
+
if (!presetName || presetName === DEFAULT_PRESET_NAME) return undefined;
|
|
27
|
+
|
|
28
|
+
const componentPresets = theme.styles?.[componentName];
|
|
29
|
+
if (!componentPresets) return undefined;
|
|
30
|
+
|
|
31
|
+
const entry: PresetStyle | undefined = componentPresets[presetName];
|
|
32
|
+
if (!entry) return undefined;
|
|
33
|
+
|
|
34
|
+
return typeof entry === 'function' ? entry(theme) : entry;
|
|
35
|
+
}
|