@soyfri/shared-library 1.5.0-beta.4 → 1.6.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/Button-C17mExpd.cjs.map +1 -1
- package/Button-UkkP-bNw.js.map +1 -1
- package/components/ActionMenu/ActionMenu.cjs +107 -0
- package/components/ActionMenu/ActionMenu.cjs.map +1 -0
- package/components/ActionMenu/ActionMenu.d.ts +44 -0
- package/components/ActionMenu/ActionMenu.js +107 -0
- package/components/ActionMenu/ActionMenu.js.map +1 -0
- package/components/ActionMenu/index.d.ts +2 -0
- package/components/ActionMenu.d.ts +6 -0
- package/components/AppBar/AppBar.cjs +129 -0
- package/components/AppBar/AppBar.cjs.map +1 -0
- package/components/AppBar/AppBar.d.ts +55 -0
- package/components/AppBar/AppBar.js +129 -0
- package/components/AppBar/AppBar.js.map +1 -0
- package/components/AppBar/AppBar.sx.d.ts +12 -0
- package/components/AppBar/AppBarContext.d.ts +18 -0
- package/components/AppBar/AppBarMenuToggle.d.ts +39 -0
- package/components/AppBar/index.d.ts +6 -0
- package/components/AppBar.d.ts +6 -0
- package/components/Autocomplete/Autocomplete.cjs +263 -82
- package/components/Autocomplete/Autocomplete.cjs.map +1 -1
- package/components/Autocomplete/Autocomplete.d.ts +71 -13
- package/components/Autocomplete/Autocomplete.definitions.d.ts +7 -0
- package/components/Autocomplete/Autocomplete.helpers.d.ts +22 -0
- package/components/Autocomplete/Autocomplete.js +264 -83
- package/components/Autocomplete/Autocomplete.js.map +1 -1
- package/components/Autocomplete/Autocomplete.sx.d.ts +7 -0
- package/components/Autocomplete/_parts/AutocompleteChips.d.ts +20 -0
- package/components/Autocomplete/_parts/AutocompleteLoader.d.ts +9 -0
- package/components/Autocomplete/_parts/AutocompleteOption.d.ts +16 -0
- package/components/Autocomplete/index.d.ts +2 -1
- package/components/Autocomplete.d.ts +4 -0
- package/components/Avatar/Avatar.cjs +117 -81
- package/components/Avatar/Avatar.cjs.map +1 -1
- package/components/Avatar/Avatar.d.ts +16 -2
- package/components/Avatar/Avatar.definitions.d.ts +11 -0
- package/components/Avatar/Avatar.js +118 -82
- package/components/Avatar/Avatar.js.map +1 -1
- package/components/Avatar/index.d.ts +1 -0
- package/components/Button/Button.d.ts +5 -5
- package/components/Button/index.d.ts +1 -0
- package/components/Card/Card.cjs +78 -7
- package/components/Card/Card.cjs.map +1 -1
- package/components/Card/Card.d.ts +31 -8
- package/components/Card/Card.js +79 -8
- package/components/Card/Card.js.map +1 -1
- package/components/Card/Card.sx.d.ts +14 -0
- package/components/Card/index.d.ts +4 -1
- package/components/Card.d.ts +4 -0
- package/components/Checkbox/Checkbox.cjs +189 -0
- package/components/Checkbox/Checkbox.cjs.map +1 -0
- package/components/Checkbox/Checkbox.d.ts +55 -0
- package/components/Checkbox/Checkbox.js +189 -0
- package/components/Checkbox/Checkbox.js.map +1 -0
- package/components/Checkbox/Checkbox.sx.d.ts +13 -0
- package/components/Checkbox/index.d.ts +2 -0
- package/components/Checkbox.d.ts +6 -0
- package/components/Chip/Chip.cjs +2 -1
- package/components/Chip/Chip.cjs.map +1 -1
- package/components/Chip/Chip.js +2 -1
- package/components/Chip/Chip.js.map +1 -1
- package/components/Chip/index.d.ts +2 -1
- package/components/Chip.d.ts +4 -0
- package/components/DatePicker/DatePicker.cjs +178 -3
- package/components/DatePicker/DatePicker.cjs.map +1 -1
- package/components/DatePicker/DatePicker.d.ts +35 -9
- package/components/DatePicker/DatePicker.definitions.d.ts +1 -0
- package/components/DatePicker/DatePicker.helpers.d.ts +7 -0
- package/components/DatePicker/DatePicker.js +177 -2
- package/components/DatePicker/DatePicker.js.map +1 -1
- package/components/DatePicker/DatePicker.sx.d.ts +9 -0
- package/components/DatePicker/index.d.ts +2 -1
- package/components/DatePicker.d.ts +4 -0
- package/components/DateTimePicker/DateTimePicker.cjs +121 -131
- package/components/DateTimePicker/DateTimePicker.cjs.map +1 -1
- package/components/DateTimePicker/DateTimePicker.d.ts +41 -12
- package/components/DateTimePicker/DateTimePicker.definitions.d.ts +3 -0
- package/components/DateTimePicker/DateTimePicker.helpers.d.ts +13 -0
- package/components/DateTimePicker/DateTimePicker.js +121 -131
- package/components/DateTimePicker/DateTimePicker.js.map +1 -1
- package/components/DateTimePicker/DateTimePicker.sx.d.ts +7 -0
- package/components/DateTimePicker/index.d.ts +2 -1
- package/components/DateTimePicker.d.ts +4 -0
- package/components/Drawer/Drawer.cjs +272 -0
- package/components/Drawer/Drawer.cjs.map +1 -0
- package/components/Drawer/Drawer.d.ts +58 -0
- package/components/Drawer/Drawer.js +272 -0
- package/components/Drawer/Drawer.js.map +1 -0
- package/components/Drawer/Drawer.sx.d.ts +23 -0
- package/components/Drawer/DrawerContext.d.ts +18 -0
- package/components/Drawer/DrawerItem.d.ts +40 -0
- package/components/Drawer/index.d.ts +6 -0
- package/components/Drawer.d.ts +6 -0
- package/components/Gallery/Gallery.cjs +154 -79
- package/components/Gallery/Gallery.cjs.map +1 -1
- package/components/Gallery/Gallery.d.ts +25 -9
- package/components/Gallery/Gallery.js +154 -79
- package/components/Gallery/Gallery.js.map +1 -1
- package/components/Gallery/GalleryLightbox.d.ts +6 -10
- package/components/Gallery/GalleryMain.d.ts +3 -7
- package/components/Gallery/GalleryThumbnails.d.ts +7 -11
- package/components/Gallery/index.d.ts +2 -1
- package/components/Gallery.d.ts +4 -0
- package/components/Icon/Icon.cjs +49 -10
- package/components/Icon/Icon.cjs.map +1 -1
- package/components/Icon/Icon.d.ts +29 -2
- package/components/Icon/Icon.js +49 -10
- package/components/Icon/Icon.js.map +1 -1
- package/components/Icon/index.d.ts +2 -1
- package/components/Icon.d.ts +4 -0
- package/components/Input/Input.cjs +186 -3
- package/components/Input/Input.cjs.map +1 -1
- package/components/Input/Input.d.ts +29 -17
- package/components/Input/Input.definitions.d.ts +6 -2
- package/components/Input/Input.helpers.d.ts +14 -0
- package/components/Input/Input.js +185 -2
- package/components/Input/Input.js.map +1 -1
- package/components/Input/Input.sx.d.ts +8 -0
- package/components/Input/index.d.ts +2 -1
- package/components/Input.d.ts +4 -0
- package/components/InputGroup/InputGroup.cjs +107 -93
- package/components/InputGroup/InputGroup.cjs.map +1 -1
- package/components/InputGroup/InputGroup.d.ts +38 -2
- package/components/InputGroup/InputGroup.definitions.d.ts +6 -0
- package/components/InputGroup/InputGroup.js +109 -95
- package/components/InputGroup/InputGroup.js.map +1 -1
- package/components/InputGroup/index.d.ts +2 -1
- package/components/InputGroup.d.ts +4 -0
- package/components/Modal/Modal.cjs +287 -148
- package/components/Modal/Modal.cjs.map +1 -1
- package/components/Modal/Modal.d.ts +57 -6
- package/components/Modal/Modal.js +289 -150
- package/components/Modal/Modal.js.map +1 -1
- package/components/Modal/ModalBody.d.ts +6 -1
- package/components/Modal/ModalFooter.d.ts +12 -4
- package/components/Modal/ModalHeader.d.ts +6 -1
- package/components/Modal/index.d.ts +8 -1
- package/components/Modal.d.ts +4 -0
- package/components/RadioGroup/RadioGroup.cjs +204 -0
- package/components/RadioGroup/RadioGroup.cjs.map +1 -0
- package/components/RadioGroup/RadioGroup.d.ts +59 -0
- package/components/RadioGroup/RadioGroup.definitions.d.ts +6 -0
- package/components/RadioGroup/RadioGroup.js +204 -0
- package/components/RadioGroup/RadioGroup.js.map +1 -0
- package/components/RadioGroup/RadioGroup.sx.d.ts +20 -0
- package/components/RadioGroup/index.d.ts +2 -0
- package/components/RadioGroup.d.ts +6 -0
- package/components/Select/Select.cjs +311 -4
- package/components/Select/Select.cjs.map +1 -1
- package/components/Select/Select.d.ts +62 -27
- package/components/Select/Select.helpers.d.ts +15 -0
- package/components/Select/Select.js +310 -3
- package/components/Select/Select.js.map +1 -1
- package/components/Select/Select.sx.d.ts +7 -0
- package/components/Select/_parts/SelectMenuItem.d.ts +20 -0
- package/components/Select/index.d.ts +2 -1
- package/components/Select.d.ts +4 -0
- package/components/Stat/Stat.cjs +2 -2
- package/components/Stat/Stat.cjs.map +1 -1
- package/components/Stat/Stat.js +2 -2
- package/components/Stat/Stat.js.map +1 -1
- package/components/Stat/index.d.ts +2 -1
- package/components/Stat.d.ts +4 -0
- package/components/StatusMessage/StatusMessage.cjs +66 -55
- package/components/StatusMessage/StatusMessage.cjs.map +1 -1
- package/components/StatusMessage/StatusMessage.d.ts +20 -36
- package/components/StatusMessage/StatusMessage.js +68 -57
- package/components/StatusMessage/StatusMessage.js.map +1 -1
- package/components/StatusMessage/index.d.ts +2 -1
- package/components/StatusMessage.d.ts +4 -0
- package/components/Stepper/Stepper.cjs +285 -29
- package/components/Stepper/Stepper.cjs.map +1 -1
- package/components/Stepper/Stepper.d.ts +13 -7
- package/components/Stepper/Stepper.js +287 -31
- package/components/Stepper/Stepper.js.map +1 -1
- package/components/Stepper/StepperContext.d.ts +73 -0
- package/components/Stepper/_hooks/useHorizontalScroll.d.ts +19 -0
- package/components/Stepper/_parts/StepperScrollArrow.d.ts +19 -0
- package/components/Stepper/index.d.ts +6 -2
- package/components/Stepper.d.ts +4 -0
- package/components/Switch/Switch.cjs +184 -0
- package/components/Switch/Switch.cjs.map +1 -0
- package/components/Switch/Switch.d.ts +48 -0
- package/components/Switch/Switch.definitions.d.ts +7 -0
- package/components/Switch/Switch.js +184 -0
- package/components/Switch/Switch.js.map +1 -0
- package/components/Switch/Switch.sx.d.ts +22 -0
- package/components/Switch/Switch.types.d.ts +1 -0
- package/components/Switch/index.d.ts +2 -0
- package/components/Switch.d.ts +6 -0
- package/components/Tabs/Tabs.cjs +45 -29
- package/components/Tabs/Tabs.cjs.map +1 -1
- package/components/Tabs/Tabs.d.ts +21 -16
- package/components/Tabs/Tabs.js +46 -30
- package/components/Tabs/Tabs.js.map +1 -1
- package/components/Tabs/index.d.ts +4 -2
- package/components/Tabs.d.ts +4 -0
- package/components/Timeline/Timeline.cjs +3 -2
- package/components/Timeline/Timeline.cjs.map +1 -1
- package/components/Timeline/Timeline.d.ts +4 -8
- package/components/Timeline/Timeline.js +3 -2
- package/components/Timeline/Timeline.js.map +1 -1
- package/components/Timeline/index.d.ts +4 -2
- package/components/Timeline.d.ts +4 -0
- package/components/_shared/formField.sx.d.ts +33 -0
- package/components/_shared/mergeSx.d.ts +7 -0
- package/components/_shared/resolvePreset.d.ts +18 -0
- package/formField.sx-8_QRnKxv.js +68 -0
- package/formField.sx-8_QRnKxv.js.map +1 -0
- package/formField.sx-BAX7KwMR.cjs +67 -0
- package/formField.sx-BAX7KwMR.cjs.map +1 -0
- package/index.cjs +144 -1
- package/index.cjs.map +1 -1
- package/index.d.ts +4 -0
- package/index.js +49 -2
- package/index.js.map +1 -1
- package/mergeSx-BXoNZjB_.js +10 -0
- package/mergeSx-BXoNZjB_.js.map +1 -0
- package/mergeSx-Dbccoo_H.cjs +9 -0
- package/mergeSx-Dbccoo_H.cjs.map +1 -0
- package/mui.d.ts +7 -0
- package/package.json +31 -1
- package/resolvePreset-B-IB0ehH.js +15 -0
- package/resolvePreset-B-IB0ehH.js.map +1 -0
- package/resolvePreset-CT3kU-K2.cjs +14 -0
- package/resolvePreset-CT3kU-K2.cjs.map +1 -0
- package/theme/componentStyles.d.ts +32 -0
- package/theme/tokens.d.ts +28 -0
- package/tokens-BRrcP_p_.js +21 -0
- package/tokens-BRrcP_p_.js.map +1 -0
- package/tokens-jaWWNk39.cjs +20 -0
- package/tokens-jaWWNk39.cjs.map +1 -0
- package/utils/index.d.ts +2 -0
- package/utils/scrollToTop.d.ts +28 -0
- package/DatePicker-BSNboVhN.js +0 -201
- package/DatePicker-BSNboVhN.js.map +0 -1
- package/DatePicker-BoqxWAhj.cjs +0 -200
- package/DatePicker-BoqxWAhj.cjs.map +0 -1
- package/Input-DFHs7cJ_.js +0 -171
- package/Input-DFHs7cJ_.js.map +0 -1
- package/Input-c8MwNNPg.cjs +0 -170
- package/Input-c8MwNNPg.cjs.map +0 -1
- package/Select-BO2N56sm.cjs +0 -411
- package/Select-BO2N56sm.cjs.map +0 -1
- package/Select-BcLkyHSE.js +0 -412
- package/Select-BcLkyHSE.js.map +0 -1
- package/components/Select/Select.definitions.d.ts +0 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Autocomplete.cjs","sources":["../../../src/components/Autocomplete/Autocomplete.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n Autocomplete,\n TextField,\n Chip,\n Avatar,\n Box,\n Typography,\n CircularProgress,\n} from \"@mui/material\";\nimport ClearIcon from \"@mui/icons-material/Clear\";\nimport { styled } from \"@mui/system\";\n\nexport interface SelectOption {\n value: string | number;\n label: string;\n img?: string;\n disabled?: boolean;\n group?: string;\n [key: string]: any;\n}\n\ntype RenderOptionItem = (item: SelectOption) => React.ReactNode;\ntype RenderChipLabel = (item: SelectOption) => React.ReactNode;\n\ninterface AutocompleteProps<\n TValue extends SelectOption[\"value\"] = SelectOption[\"value\"],\n> {\n label?: string;\n value: TValue | TValue[];\n onChange: (val: TValue | TValue[]) => void;\n options?: SelectOption[];\n placeholder?: string;\n multiple?: boolean;\n disabled?: boolean;\n loading?: boolean;\n error?: boolean;\n helperText?: string;\n maxChipsToShow?: number;\n renderOptionItem?: RenderOptionItem;\n renderChipLabel?: RenderChipLabel;\n}\n\nconst StyledAutocomplete = styled(Autocomplete as typeof Autocomplete)(\n ({ theme }) => ({\n \"& .MuiOutlinedInput-root\": {\n maxHeight: \"36px\",\n padding: \"8px 10px\",\n borderRadius: \"10px\",\n display: \"flex\",\n alignItems: \"center\",\n fontSize: \"14px\",\n },\n\n \"& .MuiAutocomplete-inputRoot\": {\n padding: \"0 !important\",\n },\n\n \"& .MuiAutocomplete-input\": {\n padding: \"0 !important\",\n height: \"28px\",\n marginLeft: \"8px\",\n },\n\n \"& .MuiOutlinedInput-notchedOutline\": {\n marginBottom: \"-4px\",\n borderRadius: \"10px\",\n },\n\n \"& .MuiOutlinedInput-notchedOutline > legend\": {\n display: \"none\",\n },\n\n \"& .MuiAutocomplete-endAdornment\": {\n top: \"50%\",\n transform: \"translateY(-50%)\",\n },\n }),\n);\n\nexport function AutocompleteSelect<\n TValue extends SelectOption[\"value\"] = SelectOption[\"value\"],\n>(props: AutocompleteProps<TValue>) {\n const {\n label,\n options = [],\n value,\n onChange,\n placeholder,\n multiple = false,\n disabled = false,\n loading = false,\n error = false,\n helperText,\n renderOptionItem,\n renderChipLabel,\n maxChipsToShow = 3,\n } = props;\n\n const renderTags = (value: SelectOption[], getTagProps: any) => {\n const displayed = value.slice(0, maxChipsToShow);\n const hidden = value.length - maxChipsToShow;\n\n return (\n <>\n {displayed.map((option, index) => (\n <Chip\n {...getTagProps({ index })}\n key={option.value}\n label={renderChipLabel ? renderChipLabel(option) : option.label}\n avatar={option.img ? <Avatar src={option.img} /> : undefined}\n deleteIcon={<ClearIcon />}\n />\n ))}\n\n {hidden > 0 && <Chip label={`+${hidden} más`} />}\n </>\n );\n };\n\n const renderOption = (propsLi: any, option: SelectOption) => (\n <li {...propsLi} key={option.value}>\n {renderOptionItem ? renderOptionItem(option) : option.label}\n </li>\n );\n\n const renderAutocomplete = (value: any, onChange: any) => (\n <Box\n sx={{\n width: \"100%\",\n display: \"grid\",\n marginBottom: \"10px\",\n marginTop: \"10px\",\n }}\n >\n <StyledAutocomplete\n multiple={multiple}\n options={options}\n value={\n multiple\n ? (options.filter((o) =>\n (value as string[] | undefined)?.includes(o.value as string),\n ) ?? [])\n : (options.find((o) => o.value === value) ?? null)\n }\n disabled={disabled}\n loading={loading}\n getOptionLabel={(opt: any) => opt?.label ?? \"\"}\n isOptionEqualToValue={(a: any, b: any) => a.value === b.value}\n onChange={onChange}\n // renderOption={renderOption}\n // renderTags={multiple ? renderTags : undefined}\n noOptionsText=\"No hay opciones\"\n loadingText={\n <Box sx={{ display: \"flex\", alignItems: \"center\", gap: 1 }}>\n <CircularProgress size={20} />\n <Typography>Cargando...</Typography>\n </Box>\n }\n renderInput={(params) => (\n <TextField\n {...params}\n // label={label}\n placeholder={placeholder}\n error={error}\n helperText={helperText}\n />\n )}\n />\n </Box>\n );\n\n const handleChangeInternal = (event: any, newValue: any) => {\n if (multiple) {\n const values = (newValue ?? []).map((opt: any) => opt.value);\n (onChange as (val: TValue[]) => void)?.(values);\n } else {\n const value = newValue?.value ?? \"\";\n (onChange as (val: TValue) => void)?.(value);\n }\n };\n\n return renderAutocomplete(value, handleChangeInternal);\n}\n\nexport default AutocompleteSelect;\n"],"names":["styled","Autocomplete","value","onChange","jsx","Box","_a","jsxs","CircularProgress","Typography","TextField"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAM,qBAAqBA,OAAAA,OAAOC,qBAAmC;AAAA,EACnE,CAAC,EAAE,MAAA,OAAa;AAAA,IACd,4BAA4B;AAAA,MAC1B,WAAW;AAAA,MACX,SAAS;AAAA,MACT,cAAc;AAAA,MACd,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,UAAU;AAAA,IAAA;AAAA,IAGZ,gCAAgC;AAAA,MAC9B,SAAS;AAAA,IAAA;AAAA,IAGX,4BAA4B;AAAA,MAC1B,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,YAAY;AAAA,IAAA;AAAA,IAGd,sCAAsC;AAAA,MACpC,cAAc;AAAA,MACd,cAAc;AAAA,IAAA;AAAA,IAGhB,+CAA+C;AAAA,MAC7C,SAAS;AAAA,IAAA;AAAA,IAGX,mCAAmC;AAAA,MACjC,KAAK;AAAA,MACL,WAAW;AAAA,IAAA;AAAA,EACb;AAEJ;AAEO,SAAS,mBAEd,OAAkC;AAClC,QAAM;AAAA,IACJ;AAAA,IACA,UAAU,CAAA;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,WAAW;AAAA,IACX,UAAU;AAAA,IACV,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA,iBAAiB;AAAA,EAAA,IACf;AA6BJ,QAAM,qBAAqB,CAACC,QAAYC;;AACtCC,sCAAAA;AAAAA,MAACC,SAAAA;AAAAA,MAAA;AAAA,QACC,IAAI;AAAA,UACF,OAAO;AAAA,UACP,SAAS;AAAA,UACT,cAAc;AA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3,"file":"Autocomplete.cjs","sources":["../../../src/components/Autocomplete/Autocomplete.sx.ts","../../../src/components/Autocomplete/Autocomplete.helpers.ts","../../../src/components/Autocomplete/_parts/AutocompleteOption.tsx","../../../src/components/Autocomplete/_parts/AutocompleteChips.tsx","../../../src/components/Autocomplete/_parts/AutocompleteLoader.tsx","../../../src/components/Autocomplete/Autocomplete.tsx"],"sourcesContent":["import type { SxProps, Theme } from '@mui/material/styles';\n\nimport { buildFormFieldSx } from '../_shared/formField.sx';\nimport type { LabelPosition } from './Autocomplete';\n\n/**\n * Builder del sx del Autocomplete. Reutiliza `buildFormFieldSx` y añade\n * los paddings propios del Autocomplete (chips + input interno).\n */\nexport const buildAutocompleteSx = (\n borderRadius: number | string,\n labelPosition: LabelPosition,\n): SxProps<Theme> =>\n buildFormFieldSx({\n borderRadius,\n labelPosition,\n extraOutsideSx: {\n // El input interno del Autocomplete.\n '& .MuiAutocomplete-input': {\n paddingTop: '4px',\n paddingBottom: '4px',\n },\n\n // Contenedor del input (donde viven los chips en modo multiple).\n '& .MuiAutocomplete-inputRoot': {\n paddingTop: '4px',\n paddingBottom: '4px',\n },\n },\n });\n","import type { SxProps, Theme } from '@mui/material/styles';\nimport type { AutocompleteValueKey, SelectOption } from './Autocomplete';\n\n/** Resuelve un value único a su SelectOption dentro del pool. */\nexport const resolveSingleValue = <TValue,>(\n options: SelectOption<TValue>[],\n value: TValue | null | undefined,\n getKey: (v: TValue) => AutocompleteValueKey,\n): SelectOption<TValue> | null => {\n if (value === null || value === undefined) return null;\n const key = getKey(value);\n return options.find((o) => getKey(o.value) === key) ?? null;\n};\n\n/** Resuelve un array de values a sus SelectOption dentro del pool. */\nexport const resolveMultipleValue = <TValue,>(\n options: SelectOption<TValue>[],\n value: TValue[] | null | undefined,\n getKey: (v: TValue) => AutocompleteValueKey,\n): SelectOption<TValue>[] => {\n if (!Array.isArray(value)) return [];\n const keys = new Set(value.map(getKey));\n return options.filter((o) => keys.has(getKey(o.value)));\n};\n\n/** Merge de sx base + extra del consumer, respetando el contrato de MUI. */\nexport const mergeSx = (\n base: SxProps<Theme>,\n extra?: SxProps<Theme>,\n): SxProps<Theme> => {\n if (!extra) return base;\n return [base, ...(Array.isArray(extra) ? extra : [extra])] as SxProps<Theme>;\n};\n\n/**\n * Compara dos SelectOption por todas sus props (shallow). Se usa para detectar\n * cambios de metadata (p.ej. `label`, `img`) cuando `value` no cambió, para\n * que la estabilización no tape datos frescos del server. Para `value` se\n * compara vía `getKey` (no por `===`), de modo que values objeto con misma\n * identidad lógica pero referencia distinta no rompan la estabilización.\n */\nconst areOptionsShallowEqual = <TValue,>(\n a: SelectOption<TValue>,\n b: SelectOption<TValue>,\n getKey: (v: TValue) => AutocompleteValueKey,\n): boolean => {\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n if (keysA.length !== keysB.length) return false;\n return keysA.every((k) => {\n if (k === 'value') return getKey(a.value) === getKey(b.value);\n return a[k] === b[k];\n });\n};\n\n/**\n * Compara dos valores resueltos (single o multiple) estructuralmente para\n * decidir si se puede reusar la referencia previa. Se usa para estabilizar la\n * referencia que se pasa a MUI Autocomplete (MUI compara value por referencia\n * con `!==`, y una nueva referencia — aunque el contenido sea igual — dispara\n * `resetInputValue` y borra el texto mientras el usuario tipea).\n *\n * Comparamos todas las props del SelectOption, no solo `value`, para que un\n * refresh de metadata (label/img/etc.) invalide la referencia estabilizada\n * y la UI muestre los datos actualizados.\n */\nexport const areResolvedValuesEqual = <TValue,>(\n prev: SelectOption<TValue> | SelectOption<TValue>[] | null,\n next: SelectOption<TValue> | SelectOption<TValue>[] | null,\n multiple: boolean,\n getKey: (v: TValue) => AutocompleteValueKey,\n): boolean => {\n if (multiple) {\n if (!Array.isArray(prev) || !Array.isArray(next)) return false;\n if (prev.length !== next.length) return false;\n return prev.every((o, i) => {\n const n = next[i];\n return !!n && areOptionsShallowEqual(o, n, getKey);\n });\n }\n const p = prev as SelectOption<TValue> | null;\n const n = next as SelectOption<TValue> | null;\n if (p === n) return true;\n if (!p || !n) return false;\n return areOptionsShallowEqual(p, n, getKey);\n};\n\n/** Determina si un valor resuelto está vacío (para placeholder/shrink). */\nexport const isResolvedValueEmpty = (\n resolvedValue: unknown,\n multiple: boolean,\n): boolean => {\n if (multiple) {\n return !Array.isArray(resolvedValue) || resolvedValue.length === 0;\n }\n return !resolvedValue;\n};\n","import React from 'react';\nimport type {\n AutocompleteValueKey,\n RenderOptionItem,\n SelectOption,\n} from '../Autocomplete';\n\ninterface AutocompleteOptionProps<TValue = AutocompleteValueKey> {\n liProps: React.HTMLAttributes<HTMLLIElement>;\n option: SelectOption<TValue>;\n customRender?: RenderOptionItem<TValue>;\n}\n\n/**\n * Render por defecto de un `<li>` del dropdown del Autocomplete.\n * MUI lo invoca desde `renderOption={(props, option) => ...}` en el padre.\n *\n * La `key` la maneja el padre (`renderOption` en Autocomplete.tsx). Este\n * componente solo recibe los props restantes del `<li>` para spread.\n */\nexport const AutocompleteOption = <TValue,>({\n liProps,\n option,\n customRender,\n}: AutocompleteOptionProps<TValue>) => {\n return (\n <li {...liProps}>\n {customRender ? customRender(option) : option.label}\n </li>\n );\n};\n\nexport default AutocompleteOption;\n","import { Avatar, Chip } from '@mui/material';\nimport ClearIcon from '@mui/icons-material/Clear';\n\nimport type {\n AutocompleteSize,\n AutocompleteValueKey,\n RenderChipLabel,\n SelectOption,\n} from '../Autocomplete';\n\ninterface AutocompleteChipsProps<TValue = AutocompleteValueKey> {\n value: SelectOption<TValue>[];\n getTagProps: (args: { index: number }) => Record<string, any>;\n size: AutocompleteSize;\n maxChipsToShow: number;\n renderChipLabel?: RenderChipLabel<TValue>;\n /** Extrae la React key estable a partir del value (necesario para values objeto). */\n getKey: (value: TValue) => AutocompleteValueKey;\n}\n\n/**\n * Render de los chips del Autocomplete en modo multiple.\n * Trunca después de `maxChipsToShow` con un chip \"+N más\".\n * El `getTagProps({ index })` viene de MUI y contiene el handler de delete,\n * la key, etc. — se spreadea tal cual al Chip.\n */\nexport const AutocompleteChips = <TValue,>({\n value,\n getTagProps,\n size,\n maxChipsToShow,\n renderChipLabel,\n getKey,\n}: AutocompleteChipsProps<TValue>) => {\n const displayed = value.slice(0, maxChipsToShow);\n const hidden = value.length - maxChipsToShow;\n\n return (\n <>\n {displayed.map((option, index) => {\n const { key: _ignored, ...tagProps } = getTagProps({ index });\n return (\n <Chip\n key={getKey(option.value)}\n {...tagProps}\n size={size}\n label={renderChipLabel ? renderChipLabel(option) : option.label}\n avatar={option.img ? <Avatar src={option.img} /> : undefined}\n deleteIcon={<ClearIcon />}\n />\n );\n })}\n {hidden > 0 && <Chip size={size} label={`+${hidden} más`} />}\n </>\n );\n};\n\nexport default AutocompleteChips;\n","import React from 'react';\nimport { Box, CircularProgress, Typography } from '@mui/material';\n\n/**\n * Loader por defecto para el `loadingText` del Autocomplete.\n * El consumer puede sobrescribirlo pasando `loadingText` al componente padre.\n */\nexport const AutocompleteLoader: React.FC<{ text?: string }> = ({\n text = 'Cargando...',\n}) => (\n <Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>\n <CircularProgress size={16} />\n <Typography variant=\"body2\">{text}</Typography>\n </Box>\n);\n\nexport default AutocompleteLoader;\n","import React, {\n useMemo,\n useRef,\n useState,\n type ReactNode,\n type SyntheticEvent,\n} from 'react';\nimport {\n Autocomplete as MuiAutocomplete,\n TextField,\n type TextFieldProps,\n} from '@mui/material';\nimport { useTheme, type SxProps, type Theme } from '@mui/material/styles';\n\nimport { buildAutocompleteSx } from './Autocomplete.sx';\nimport {\n areResolvedValuesEqual,\n isResolvedValueEmpty,\n resolveMultipleValue,\n resolveSingleValue,\n} from './Autocomplete.helpers';\nimport { resolvePreset } from '../_shared/resolvePreset';\nimport { AutocompleteOption } from './_parts/AutocompleteOption';\nimport { AutocompleteChips } from './_parts/AutocompleteChips';\nimport { AutocompleteLoader } from './_parts/AutocompleteLoader';\n\n// ── Tipos de dominio ─────────────────────────────────────────────────────\n/** Key estable usada para comparar values, indexar caches y como React key. */\nexport type AutocompleteValueKey = string | number;\n\nexport interface SelectOption<TValue = AutocompleteValueKey> {\n value: TValue;\n label: string;\n img?: string;\n disabled?: boolean;\n group?: string;\n [key: string]: any; //campos extras que puede tener la opcion\n}\n\nexport type LabelPosition = 'outside' | 'floating';\nexport type AutocompleteSize = 'small' | 'medium';\n\n// ── Render slots ─────────────────────────────────────────────────────────\nexport type RenderOptionItem<TValue = AutocompleteValueKey> = (\n item: SelectOption<TValue>,\n) => ReactNode;\nexport type RenderChipLabel<TValue = AutocompleteValueKey> = (\n item: SelectOption<TValue>,\n) => ReactNode;\nexport type RenderSingleValue<TValue = AutocompleteValueKey> = (\n item: SelectOption<TValue>,\n) => ReactNode;\n\n// ── Props base ───────────────────────────────────────────────────────────\nexport type BaseAutocompleteProps<TValue = AutocompleteValueKey> = {\n label?: string;\n options: SelectOption<TValue>[];\n placeholder?: string;\n multiple?: boolean;\n disabled?: boolean;\n readOnly?: boolean;\n loading?: boolean;\n error?: boolean;\n helperText?: string;\n maxChipsToShow?: number;\n renderOptionItem?: RenderOptionItem<TValue>;\n renderChipLabel?: RenderChipLabel<TValue>;\n /**\n * Renderiza JSX custom como `startAdornment` del input en single mode.\n * Recibe la `SelectOption` seleccionada. Útil para mostrar avatars, iconos,\n * etc. junto al texto del label. En `multiple` no aplica (se usa `renderChipLabel`).\n */\n renderSingleValue?: RenderSingleValue<TValue>;\n /**\n * Extrae una key estable (string | number) desde el `value`. Obligatorio\n * cuando `TValue` es un objeto: se usa para comparar values (`isOptionEqualToValue`,\n * resolución desde el value del form), indexar el cache interno de opciones\n * vistas y como React key en chips/options del dropdown. Para primitivos se\n * puede omitir (default: identidad, o sea `===`).\n */\n getOptionKey?: (value: TValue) => AutocompleteValueKey;\n /** Border radius del input. Default: 10. */\n borderRadius?: number | string;\n /** \"outside\" (default) = label arriba del input; \"floating\" = comportamiento nativo MUI. */\n labelPosition?: LabelPosition;\n /** Tamaño del TextField. Default: 'small'. */\n size?: AutocompleteSize;\n /** Texto cuando no hay coincidencias. */\n noOptionsText?: ReactNode;\n /** Texto cuando está cargando. */\n loadingText?: ReactNode;\n sx?: SxProps<Theme>;\n /**\n * Nombre del preset de estilo registrado en `theme.styles.Autocomplete`.\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 /** Props para el TextField subyacente. */\n textFieldProps?: Partial<TextFieldProps>;\n\n // ── Búsqueda asíncrona / remota ──────────────────────────────────────\n /** Se dispara cada vez que el usuario escribe. Útil para llamadas a servicios\n * (debounce recomendado en el consumer). */\n onInputChange?: (\n event: SyntheticEvent,\n value: string,\n reason: 'input' | 'reset' | 'clear' | 'blur' | 'selectOption' | 'removeOption',\n ) => void;\n /** Valor controlado del texto de búsqueda. */\n inputValue?: string;\n /** Filtro custom. Para búsqueda remota pasar `(x) => x` y confiar sólo en el servicio. */\n filterOptions?: (\n options: SelectOption<TValue>[],\n state: any,\n ) => SelectOption<TValue>[];\n /** Permite valores arbitrarios (no solo de la lista). */\n freeSolo?: boolean;\n open?: boolean;\n onOpen?: (event: SyntheticEvent) => void;\n onClose?: (event: SyntheticEvent, reason: string) => void;\n};\n\n// ── API pública final ────────────────────────────────────────────────────\nexport interface AutocompleteProps<TValue = AutocompleteValueKey>\n extends BaseAutocompleteProps<TValue> {\n value: TValue | TValue[] | null;\n onChange: (val: TValue | TValue[] | null) => void;\n name?: string;\n}\n\nexport function Autocomplete<TValue = AutocompleteValueKey>(\n props: AutocompleteProps<TValue>,\n) {\n const {\n label,\n options,\n placeholder,\n multiple = false,\n disabled = false,\n readOnly = false,\n loading = false,\n error: errorProp = false,\n helperText,\n maxChipsToShow = 3,\n renderOptionItem,\n renderChipLabel,\n renderSingleValue,\n borderRadius = 10,\n labelPosition = 'outside',\n size = 'small',\n noOptionsText = 'No hay opciones',\n loadingText,\n sx,\n preset,\n textFieldProps,\n onInputChange,\n inputValue,\n filterOptions,\n freeSolo,\n open,\n onOpen,\n onClose,\n getOptionKey,\n } = props as BaseAutocompleteProps<TValue>;\n\n // Default identidad: para primitivos (string|number) funciona como `===`.\n // Para values objeto, el consumer DEBE pasar `getOptionKey` o la igualdad\n // caerá a referencia (Map/Set agruparían por identidad).\n const getKey = (getOptionKey ??\n ((v: TValue) => v as unknown as AutocompleteValueKey)) as (\n v: TValue,\n ) => AutocompleteValueKey;\n\n // Focus tracking para mostrar placeholder solo cuando el label sube.\n const [isFocused, setIsFocused] = useState(false);\n\n // Cache interno de opciones vistas (indexado por key estable). Crítico para\n // async multiple: cuando `options` cambian por un nuevo search, los items\n // ya seleccionados no desaparecen de los chips porque los recordamos acá.\n const seenOptionsRef = useRef<\n Map<AutocompleteValueKey, SelectOption<TValue>>\n >(new Map());\n for (const opt of options) {\n seenOptionsRef.current.set(getKey(opt.value), opt);\n }\n\n // Pool de opciones para resolver values (merge de options + vistas).\n const resolvePool = useMemo<SelectOption<TValue>[]>(() => {\n const merged = new Map(seenOptionsRef.current);\n for (const opt of options) merged.set(getKey(opt.value), opt);\n return Array.from(merged.values());\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [options]);\n\n // Estabiliza la referencia del resolvedValue que pasamos a MUI Autocomplete.\n // MUI compara value con `!==`: una referencia nueva con mismo contenido\n // dispara resetInputValue() y borra el texto que el usuario está escribiendo.\n const prevResolvedRef = useRef<\n SelectOption<TValue>[] | SelectOption<TValue> | null\n >(multiple ? [] : null);\n\n const stabilizeResolved = (\n newVal: SelectOption<TValue>[] | SelectOption<TValue> | null,\n ): SelectOption<TValue>[] | SelectOption<TValue> | null => {\n if (\n areResolvedValuesEqual(prevResolvedRef.current, newVal, multiple, getKey)\n ) {\n return prevResolvedRef.current;\n }\n prevResolvedRef.current = newVal;\n return newVal;\n };\n\n const theme = useTheme();\n const presetSx = resolvePreset('Autocomplete', preset, theme);\n\n const mergedSx = [\n buildAutocompleteSx(borderRadius, labelPosition),\n ...(presetSx ? [presetSx] : []),\n ...(Array.isArray(sx) ? sx : sx ? [sx] : []),\n ];\n\n const renderAutocomplete = (\n resolvedValue: any,\n handleChange: (event: any, newValue: any) => void,\n ) => {\n const isEmpty = isResolvedValueEmpty(resolvedValue, multiple);\n const showPlaceholder = isEmpty && isFocused && !!placeholder;\n const singleAdornment =\n !multiple && resolvedValue && renderSingleValue\n ? renderSingleValue(resolvedValue as SelectOption<TValue>)\n : null;\n\n return (\n <MuiAutocomplete\n multiple={multiple}\n options={options}\n value={resolvedValue}\n disabled={disabled}\n readOnly={readOnly}\n loading={loading}\n sx={mergedSx}\n freeSolo={freeSolo as any}\n open={open}\n onOpen={onOpen}\n onClose={onClose}\n inputValue={inputValue}\n onInputChange={onInputChange}\n filterOptions={filterOptions as any}\n getOptionLabel={(opt) =>\n typeof opt === 'string' ? opt : (opt?.label ?? '')\n }\n isOptionEqualToValue={(a, b) => {\n if (typeof a === 'string' || typeof b === 'string') return a === b;\n if (!a || !b) return a === b;\n return getKey(a.value) === getKey(b.value);\n }}\n getOptionDisabled={(opt) =>\n typeof opt === 'string' ? false : !!opt?.disabled\n }\n onChange={handleChange}\n onFocus={() => setIsFocused(true)}\n onBlur={() => setIsFocused(false)}\n renderOption={(liProps, option) => {\n // MUI inyecta la `key` dentro de `liProps`. React necesita la key\n // en el elemento más externo que devuelve `renderOption` (acá el\n // wrapper), no en el `<li>` interno. El resto de `liProps` viaja\n // al `<li>`. La key auto-generada por MUI cae a `getOptionLabel`,\n // que colisiona si hay opciones con label duplicado. Usamos\n // `option.value` (único por contrato de SelectOption) para\n // garantizar uniqueness aunque haya labels repetidos.\n const { key: _muiKey, ...liRest } = liProps as React.HTMLAttributes<HTMLLIElement> & {\n key?: React.Key;\n };\n return (\n <AutocompleteOption<TValue>\n key={getKey(option.value)}\n liProps={liRest}\n option={option}\n customRender={renderOptionItem}\n />\n );\n }}\n renderValue={\n multiple\n ? (value, getItemProps) => (\n <AutocompleteChips<TValue>\n value={value as SelectOption<TValue>[]}\n getTagProps={getItemProps}\n size={size}\n maxChipsToShow={maxChipsToShow}\n renderChipLabel={renderChipLabel}\n getKey={getKey}\n />\n )\n : undefined\n }\n noOptionsText={noOptionsText}\n loadingText={loadingText ?? <AutocompleteLoader />}\n renderInput={(params) => {\n const paramsInputLabel =\n (params as any).InputLabelProps as Record<string, any> | undefined;\n const consumerInputLabel =\n (textFieldProps?.slotProps as any)?.inputLabel ??\n (textFieldProps as any)?.InputLabelProps;\n // Para inyectar `singleAdornment` necesitamos pasar `slotProps.input`\n // a TextField, pero `slotProps.input` gana sobre `params.InputProps`\n // (que trae endAdornment con chevron + clear). Por eso, cuando hay\n // adornment custom, mergeamos params.InputProps + lo que el consumer\n // haya pasado por textFieldProps + nuestro startAdornment. Si no hay\n // adornment, no tocamos `slotProps.input` y se preserva el flujo legacy.\n const muiInputProps = (params as any).InputProps as\n | Record<string, any>\n | undefined;\n const consumerInputProps =\n (textFieldProps?.slotProps as any)?.input ??\n (textFieldProps as any)?.InputProps;\n const inputSlot = singleAdornment\n ? {\n ...muiInputProps,\n ...consumerInputProps,\n startAdornment: (\n <>\n {singleAdornment}\n {consumerInputProps?.startAdornment}\n {muiInputProps?.startAdornment}\n </>\n ),\n }\n : undefined;\n\n return (\n <TextField\n {...params}\n label={label}\n size={size}\n variant=\"outlined\"\n placeholder={showPlaceholder ? placeholder : undefined}\n error={!!errorProp}\n helperText={helperText}\n {...textFieldProps}\n slotProps={{\n ...textFieldProps?.slotProps,\n ...(inputSlot ? { input: inputSlot } : {}),\n inputLabel: {\n ...paramsInputLabel,\n ...consumerInputLabel,\n shrink:\n labelPosition === 'outside'\n ? !isEmpty || isFocused\n : paramsInputLabel?.shrink,\n },\n }}\n />\n );\n }}\n />\n );\n };\n\n //obtiene el primitivo (o objeto) value desde la opción seleccionada\n const extractValue = (opt: any): TValue | null => {\n if (opt === null || opt === undefined) return null;\n if (typeof opt === 'string') return opt as unknown as TValue;\n return (opt?.value ?? null) as TValue | null;\n };\n\n const handleControlledChange = (_event: any, newValue: any) => {\n const { onChange } = props;\n if (multiple) {\n const values = (newValue ?? [])\n .map((opt: SelectOption<TValue> | string) => extractValue(opt))\n .filter((v: TValue | null): v is TValue => v !== null);\n onChange(values);\n } else {\n onChange(extractValue(newValue));\n }\n };\n\n const resolvedValue = stabilizeResolved(\n multiple\n ? resolveMultipleValue(resolvePool, props.value as TValue[], getKey)\n : resolveSingleValue(resolvePool, props.value as TValue, getKey),\n );\n\n return renderAutocomplete(resolvedValue, handleControlledChange);\n}\n\n/** Alias de `Autocomplete`. Ambos nombres son equivalentes. */\nexport const AutocompleteSelect = Autocomplete;\n\nexport default Autocomplete;\n"],"names":["buildFormFieldSx","n","jsx","jsxs","Fragment","Chip","Avatar","Box","CircularProgress","Typography","useState","useRef","useMemo","useTheme","resolvePreset","resolvedValue","MuiAutocomplete","TextField"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASO,MAAM,sBAAsB,CACjC,cACA,kBAEAA,8BAAiB;AAAA,EACf;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA;AAAA,IAEd,4BAA4B;AAAA,MAC1B,YAAY;AAAA,MACZ,eAAe;AAAA,IAAA;AAAA;AAAA,IAIjB,gCAAgC;AAAA,MAC9B,YAAY;AAAA,MACZ,eAAe;AAAA,IAAA;AAAA,EACjB;AAEJ,CAAC;ACzBI,MAAM,qBAAqB,CAChC,SACA,OACA,WACgC;;AAChC,MAAI,UAAU,QAAQ,UAAU,OAAW,QAAO;AAClD,QAAM,MAAM,OAAO,KAAK;AACxB,UAAO,aAAQ,KAAK,CAAC,MAAM,OAAO,EAAE,KAAK,MAAM,GAAG,MAA3C,YAAgD;AACzD;AAGO,MAAM,uBAAuB,CAClC,SACA,OACA,WAC2B;AAC3B,MAAI,CAAC,MAAM,QAAQ,KAAK,UAAU,CAAA;AAClC,QAAM,OAAO,IAAI,IAAI,MAAM,IAAI,MAAM,CAAC;AACtC,SAAO,QAAQ,OAAO,CAAC,MAAM,KAAK,IAAI,OAAO,EAAE,KAAK,CAAC,CAAC;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,YAAM,UAAU,8BAAY,CAAA,GACzB,IAAI,CAAC,QAAuC,aAAa,GAAG,CAAC,EAC7D,OAAO,CAAC,MAAkC,MAAM,IAAI;AACvD,eAAS,MAAM;AAAA,IACjB,OAAO;AACL,eAAS,aAAa,QAAQ,CAAC;AAAA,IACjC;AAAA,EACF;AAEA,QAAM,gBAAgB;AAAA,IACpB,WACI,qBAAqB,aAAa,MAAM,OAAmB,MAAM,IACjE,mBAAmB,aAAa,MAAM,OAAiB,MAAM;AAAA,EAAA;AAGnE,SAAO,mBAAmB,eAAe,sBAAsB;AACjE;AAGO,MAAM,qBAAqB;;;;"}
|
|
@@ -1,28 +1,86 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { ReactNode, SyntheticEvent } from 'react';
|
|
2
|
+
import { TextFieldProps } from '@mui/material';
|
|
3
|
+
import { SxProps, Theme } from '@mui/material/styles';
|
|
4
|
+
/** Key estable usada para comparar values, indexar caches y como React key. */
|
|
5
|
+
export type AutocompleteValueKey = string | number;
|
|
6
|
+
export interface SelectOption<TValue = AutocompleteValueKey> {
|
|
7
|
+
value: TValue;
|
|
4
8
|
label: string;
|
|
5
9
|
img?: string;
|
|
6
10
|
disabled?: boolean;
|
|
7
11
|
group?: string;
|
|
8
12
|
[key: string]: any;
|
|
9
13
|
}
|
|
10
|
-
type
|
|
11
|
-
type
|
|
12
|
-
|
|
14
|
+
export type LabelPosition = 'outside' | 'floating';
|
|
15
|
+
export type AutocompleteSize = 'small' | 'medium';
|
|
16
|
+
export type RenderOptionItem<TValue = AutocompleteValueKey> = (item: SelectOption<TValue>) => ReactNode;
|
|
17
|
+
export type RenderChipLabel<TValue = AutocompleteValueKey> = (item: SelectOption<TValue>) => ReactNode;
|
|
18
|
+
export type RenderSingleValue<TValue = AutocompleteValueKey> = (item: SelectOption<TValue>) => ReactNode;
|
|
19
|
+
export type BaseAutocompleteProps<TValue = AutocompleteValueKey> = {
|
|
13
20
|
label?: string;
|
|
14
|
-
|
|
15
|
-
onChange: (val: TValue | TValue[]) => void;
|
|
16
|
-
options?: SelectOption[];
|
|
21
|
+
options: SelectOption<TValue>[];
|
|
17
22
|
placeholder?: string;
|
|
18
23
|
multiple?: boolean;
|
|
19
24
|
disabled?: boolean;
|
|
25
|
+
readOnly?: boolean;
|
|
20
26
|
loading?: boolean;
|
|
21
27
|
error?: boolean;
|
|
22
28
|
helperText?: string;
|
|
23
29
|
maxChipsToShow?: number;
|
|
24
|
-
renderOptionItem?: RenderOptionItem
|
|
25
|
-
renderChipLabel?: RenderChipLabel
|
|
30
|
+
renderOptionItem?: RenderOptionItem<TValue>;
|
|
31
|
+
renderChipLabel?: RenderChipLabel<TValue>;
|
|
32
|
+
/**
|
|
33
|
+
* Renderiza JSX custom como `startAdornment` del input en single mode.
|
|
34
|
+
* Recibe la `SelectOption` seleccionada. Útil para mostrar avatars, iconos,
|
|
35
|
+
* etc. junto al texto del label. En `multiple` no aplica (se usa `renderChipLabel`).
|
|
36
|
+
*/
|
|
37
|
+
renderSingleValue?: RenderSingleValue<TValue>;
|
|
38
|
+
/**
|
|
39
|
+
* Extrae una key estable (string | number) desde el `value`. Obligatorio
|
|
40
|
+
* cuando `TValue` es un objeto: se usa para comparar values (`isOptionEqualToValue`,
|
|
41
|
+
* resolución desde el value del form), indexar el cache interno de opciones
|
|
42
|
+
* vistas y como React key en chips/options del dropdown. Para primitivos se
|
|
43
|
+
* puede omitir (default: identidad, o sea `===`).
|
|
44
|
+
*/
|
|
45
|
+
getOptionKey?: (value: TValue) => AutocompleteValueKey;
|
|
46
|
+
/** Border radius del input. Default: 10. */
|
|
47
|
+
borderRadius?: number | string;
|
|
48
|
+
/** "outside" (default) = label arriba del input; "floating" = comportamiento nativo MUI. */
|
|
49
|
+
labelPosition?: LabelPosition;
|
|
50
|
+
/** Tamaño del TextField. Default: 'small'. */
|
|
51
|
+
size?: AutocompleteSize;
|
|
52
|
+
/** Texto cuando no hay coincidencias. */
|
|
53
|
+
noOptionsText?: ReactNode;
|
|
54
|
+
/** Texto cuando está cargando. */
|
|
55
|
+
loadingText?: ReactNode;
|
|
56
|
+
sx?: SxProps<Theme>;
|
|
57
|
+
/**
|
|
58
|
+
* Nombre del preset de estilo registrado en `theme.styles.Autocomplete`.
|
|
59
|
+
* - `"default"` (o ausente) = estilo built-in del paquete.
|
|
60
|
+
* - Cualquier otro string = mergea el preset encima del estilo built-in.
|
|
61
|
+
*/
|
|
62
|
+
preset?: string;
|
|
63
|
+
/** Props para el TextField subyacente. */
|
|
64
|
+
textFieldProps?: Partial<TextFieldProps>;
|
|
65
|
+
/** Se dispara cada vez que el usuario escribe. Útil para llamadas a servicios
|
|
66
|
+
* (debounce recomendado en el consumer). */
|
|
67
|
+
onInputChange?: (event: SyntheticEvent, value: string, reason: 'input' | 'reset' | 'clear' | 'blur' | 'selectOption' | 'removeOption') => void;
|
|
68
|
+
/** Valor controlado del texto de búsqueda. */
|
|
69
|
+
inputValue?: string;
|
|
70
|
+
/** Filtro custom. Para búsqueda remota pasar `(x) => x` y confiar sólo en el servicio. */
|
|
71
|
+
filterOptions?: (options: SelectOption<TValue>[], state: any) => SelectOption<TValue>[];
|
|
72
|
+
/** Permite valores arbitrarios (no solo de la lista). */
|
|
73
|
+
freeSolo?: boolean;
|
|
74
|
+
open?: boolean;
|
|
75
|
+
onOpen?: (event: SyntheticEvent) => void;
|
|
76
|
+
onClose?: (event: SyntheticEvent, reason: string) => void;
|
|
77
|
+
};
|
|
78
|
+
export interface AutocompleteProps<TValue = AutocompleteValueKey> extends BaseAutocompleteProps<TValue> {
|
|
79
|
+
value: TValue | TValue[] | null;
|
|
80
|
+
onChange: (val: TValue | TValue[] | null) => void;
|
|
81
|
+
name?: string;
|
|
26
82
|
}
|
|
27
|
-
export declare function
|
|
28
|
-
|
|
83
|
+
export declare function Autocomplete<TValue = AutocompleteValueKey>(props: AutocompleteProps<TValue>): import("react/jsx-runtime").JSX.Element;
|
|
84
|
+
/** Alias de `Autocomplete`. Ambos nombres son equivalentes. */
|
|
85
|
+
export declare const AutocompleteSelect: typeof Autocomplete;
|
|
86
|
+
export default Autocomplete;
|
|
@@ -7,3 +7,10 @@ export declare const CustomChipRenderAutocompleteDefinition = "\nimport React, {
|
|
|
7
7
|
export declare const LoadingAutocompleteDefinition = "\nimport React, { useState } from 'react';\nimport Autocomplete from './Autocomplete';\n\nexport const LoadingExample = () => {\n const [value, setValue] = useState(null);\n\n return (\n <Autocomplete\n loading\n options={[]}\n value={value}\n onChange={(val) => {\n\t\t\t\tsetValue(val as string);\n\t\t\t}}\n />\n );\n};\n";
|
|
8
8
|
export declare const EmptyOptionsAutocompleteDefinition = "\nimport React, { useState } from 'react';\nimport Autocomplete from './Autocomplete';\n\nexport const EmptyExample = () => {\n const [value, setValue] = useState(null);\n\n return (\n <Autocomplete\n options={[]}\n value={value}\n onChange={(val) => {\n\t\t\t\tsetValue(val as string);\n\t\t\t}}\n placeholder=\"No hay opciones\"\n />\n );\n};\n";
|
|
9
9
|
export declare const ManyOptionsAutocompleteDefinition = "\nimport React, { useState } from 'react';\nimport Autocomplete from './Autocomplete';\n\nconst options = Array.from({ length: 50 }, (_, i) => ({\n value: i,\n label: 'Opci\u00F3n ' + i,\n}));\n\nexport const ManyOptionsExample = () => {\n const [value, setValue] = useState(null);\n\n return (\n <Autocomplete\n options={options}\n value={value}\n onChange={(val) => {\n\t\t\t\tsetValue(val as string);\n\t\t\t}}\n />\n );\n};\n";
|
|
10
|
+
export declare const WithErrorAutocompleteDefinition = "\nimport React, { useState } from 'react';\nimport Autocomplete from './Autocomplete';\nimport { Box } from '@mui/material';\n\nconst options = [\n { value: '10', label: '10' },\n { value: '25', label: '25' },\n];\n\nexport const WithErrorExample = () => {\n const [value, setValue] = useState<string | null>(null);\n return (\n <Box sx={{ width: 300 }}>\n <Autocomplete\n label=\"Cantidad\"\n options={options}\n value={value}\n onChange={(val) => setValue(val as string | null)}\n error={!value}\n helperText={!value ? 'Debes seleccionar una cantidad' : ' '}\n />\n </Box>\n );\n};\n";
|
|
11
|
+
export declare const LabelPositionAutocompleteDefinition = "\nimport React, { useState } from 'react';\nimport Autocomplete from './Autocomplete';\nimport { Box, Stack } from '@mui/material';\n\nconst options = [\n { value: 'a', label: 'Opci\u00F3n A' },\n { value: 'b', label: 'Opci\u00F3n B' },\n];\n\nexport const LabelPositionExample = () => {\n const [a, setA] = useState<string | null>(null);\n const [b, setB] = useState<string | null>(null);\n return (\n <Stack spacing={3} sx={{ width: 320 }}>\n <Autocomplete\n label=\"Outside (default)\"\n labelPosition=\"outside\"\n options={options}\n value={a}\n onChange={(val) => setA(val as string | null)}\n />\n <Autocomplete\n label=\"Floating\"\n labelPosition=\"floating\"\n options={options}\n value={b}\n onChange={(val) => setB(val as string | null)}\n />\n </Stack>\n );\n};\n";
|
|
12
|
+
export declare const CustomBorderRadiusAutocompleteDefinition = "\nimport React, { useState } from 'react';\nimport Autocomplete from './Autocomplete';\nimport { Box, Stack } from '@mui/material';\n\nconst options = [\n { value: '10', label: '10' },\n { value: '25', label: '25' },\n];\n\nexport const CustomBorderRadiusExample = () => {\n const [a, setA] = useState<string | null>(null);\n const [b, setB] = useState<string | null>(null);\n const [c, setC] = useState<string | null>(null);\n return (\n <Stack spacing={2} sx={{ width: 300 }}>\n <Autocomplete label=\"0\" borderRadius={0} options={options} value={a} onChange={(v) => setA(v as string | null)} />\n <Autocomplete label=\"10 (default)\" borderRadius={10} options={options} value={b} onChange={(v) => setB(v as string | null)} />\n <Autocomplete label=\"24 (pill)\" borderRadius={24} options={options} value={c} onChange={(v) => setC(v as string | null)} />\n </Stack>\n );\n};\n";
|
|
13
|
+
export declare const EmptyWithPlaceholderAutocompleteDefinition = "\nimport React, { useState } from 'react';\nimport Autocomplete from './Autocomplete';\nimport { Box } from '@mui/material';\n\nconst options = [\n { value: 'mx', label: 'M\u00E9xico' },\n { value: 'co', label: 'Colombia' },\n { value: 'ar', label: 'Argentina' },\n];\n\nexport const EmptyWithPlaceholderExample = () => {\n const [value, setValue] = useState<string | null>(null);\n return (\n <Box sx={{ width: 300 }}>\n <Autocomplete\n label=\"Pa\u00EDs\"\n placeholder=\"Buscar pa\u00EDs...\"\n options={options}\n value={value}\n onChange={(val) => setValue(val as string | null)}\n />\n </Box>\n );\n};\n";
|
|
14
|
+
export declare const RHFAutocompleteDefinition = "\nimport React from 'react';\nimport { Controller, useForm } from 'react-hook-form';\nimport Autocomplete from './Autocomplete';\nimport { Box, Button, Stack } from '@mui/material';\n\nconst options = [\n { value: 'mx', label: 'M\u00E9xico' },\n { value: 'co', label: 'Colombia' },\n { value: 'ar', label: 'Argentina' },\n];\n\ntype FormValues = { country: string | null };\n\nexport const RHFExample = () => {\n const { control, handleSubmit } = useForm<FormValues>({\n defaultValues: { country: null },\n });\n\n return (\n <Box component=\"form\" onSubmit={handleSubmit((data) => console.log(data))}>\n <Stack spacing={2} sx={{ width: 320 }}>\n <Controller\n name=\"country\"\n control={control}\n rules={{ required: 'Campo requerido' }}\n render={({ field, fieldState }) => (\n <Autocomplete\n label=\"Pa\u00EDs\"\n placeholder=\"Seleccione...\"\n options={options}\n value={field.value}\n onChange={(v) => field.onChange(v as string | null)}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n />\n )}\n />\n <Button type=\"submit\" variant=\"contained\">Guardar</Button>\n </Stack>\n </Box>\n );\n};\n";
|
|
15
|
+
export declare const ObjectValueAutocompleteDefinition = "\nimport React, { useState } from 'react';\nimport Autocomplete, { SelectOption } from './Autocomplete';\nimport { Box, Typography } from '@mui/material';\n\ntype Country = { id: string; iso: string; name: string };\n\nconst options: SelectOption<Country>[] = [\n { value: { id: '1', iso: 'MX', name: 'M\u00E9xico' }, label: 'M\u00E9xico' },\n { value: { id: '2', iso: 'CO', name: 'Colombia' }, label: 'Colombia' },\n { value: { id: '3', iso: 'AR', name: 'Argentina' }, label: 'Argentina' },\n];\n\n// Obligatorio cuando TValue es objeto: extrae una key estable (string|number).\nconst getCountryKey = (c: Country) => c.id;\n\nexport const ObjectValueExample = () => {\n const [value, setValue] = useState<Country | null>(null);\n\n return (\n <Box sx={{ width: 320 }}>\n <Autocomplete<Country>\n label=\"Pa\u00EDs\"\n options={options}\n value={value}\n onChange={(v) => setValue(v as Country | null)}\n getOptionKey={getCountryKey}\n />\n <Typography>{value ? value.iso : 'Ninguno'}</Typography>\n </Box>\n );\n};\n";
|
|
16
|
+
export declare const AsyncServiceAutocompleteDefinition: string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SxProps, Theme } from '@mui/material/styles';
|
|
2
|
+
import { AutocompleteValueKey, SelectOption } from './Autocomplete';
|
|
3
|
+
/** Resuelve un value único a su SelectOption dentro del pool. */
|
|
4
|
+
export declare const resolveSingleValue: <TValue>(options: SelectOption<TValue>[], value: TValue | null | undefined, getKey: (v: TValue) => AutocompleteValueKey) => SelectOption<TValue> | null;
|
|
5
|
+
/** Resuelve un array de values a sus SelectOption dentro del pool. */
|
|
6
|
+
export declare const resolveMultipleValue: <TValue>(options: SelectOption<TValue>[], value: TValue[] | null | undefined, getKey: (v: TValue) => AutocompleteValueKey) => SelectOption<TValue>[];
|
|
7
|
+
/** Merge de sx base + extra del consumer, respetando el contrato de MUI. */
|
|
8
|
+
export declare const mergeSx: (base: SxProps<Theme>, extra?: SxProps<Theme>) => SxProps<Theme>;
|
|
9
|
+
/**
|
|
10
|
+
* Compara dos valores resueltos (single o multiple) estructuralmente para
|
|
11
|
+
* decidir si se puede reusar la referencia previa. Se usa para estabilizar la
|
|
12
|
+
* referencia que se pasa a MUI Autocomplete (MUI compara value por referencia
|
|
13
|
+
* con `!==`, y una nueva referencia — aunque el contenido sea igual — dispara
|
|
14
|
+
* `resetInputValue` y borra el texto mientras el usuario tipea).
|
|
15
|
+
*
|
|
16
|
+
* Comparamos todas las props del SelectOption, no solo `value`, para que un
|
|
17
|
+
* refresh de metadata (label/img/etc.) invalide la referencia estabilizada
|
|
18
|
+
* y la UI muestre los datos actualizados.
|
|
19
|
+
*/
|
|
20
|
+
export declare const areResolvedValuesEqual: <TValue>(prev: SelectOption<TValue> | SelectOption<TValue>[] | null, next: SelectOption<TValue> | SelectOption<TValue>[] | null, multiple: boolean, getKey: (v: TValue) => AutocompleteValueKey) => boolean;
|
|
21
|
+
/** Determina si un valor resuelto está vacío (para placeholder/shrink). */
|
|
22
|
+
export declare const isResolvedValueEmpty: (resolvedValue: unknown, multiple: boolean) => boolean;
|
|
@@ -17,116 +17,297 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
33
|
+
import { useState, useRef, useMemo } from "react";
|
|
34
|
+
import { Chip, Avatar, Box, CircularProgress, Typography, Autocomplete as Autocomplete$1, TextField } from "@mui/material";
|
|
35
|
+
import { useTheme } from "@mui/material/styles";
|
|
36
|
+
import { b as buildFormFieldSx } from "../../formField.sx-8_QRnKxv.js";
|
|
37
|
+
import { r as resolvePreset } from "../../resolvePreset-B-IB0ehH.js";
|
|
38
|
+
import ClearIcon from "@mui/icons-material/Clear";
|
|
39
|
+
const buildAutocompleteSx = (borderRadius, labelPosition) => buildFormFieldSx({
|
|
40
|
+
borderRadius,
|
|
41
|
+
labelPosition,
|
|
42
|
+
extraOutsideSx: {
|
|
43
|
+
// El input interno del Autocomplete.
|
|
38
44
|
"& .MuiAutocomplete-input": {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
marginLeft: "8px"
|
|
42
|
-
},
|
|
43
|
-
"& .MuiOutlinedInput-notchedOutline": {
|
|
44
|
-
marginBottom: "-4px",
|
|
45
|
-
borderRadius: "10px"
|
|
45
|
+
paddingTop: "4px",
|
|
46
|
+
paddingBottom: "4px"
|
|
46
47
|
},
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
top: "50%",
|
|
52
|
-
transform: "translateY(-50%)"
|
|
48
|
+
// Contenedor del input (donde viven los chips en modo multiple).
|
|
49
|
+
"& .MuiAutocomplete-inputRoot": {
|
|
50
|
+
paddingTop: "4px",
|
|
51
|
+
paddingBottom: "4px"
|
|
53
52
|
}
|
|
54
|
-
}
|
|
55
|
-
);
|
|
56
|
-
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const resolveSingleValue = (options, value, getKey) => {
|
|
56
|
+
var _a;
|
|
57
|
+
if (value === null || value === void 0) return null;
|
|
58
|
+
const key = getKey(value);
|
|
59
|
+
return (_a = options.find((o) => getKey(o.value) === key)) != null ? _a : null;
|
|
60
|
+
};
|
|
61
|
+
const resolveMultipleValue = (options, value, getKey) => {
|
|
62
|
+
if (!Array.isArray(value)) return [];
|
|
63
|
+
const keys = new Set(value.map(getKey));
|
|
64
|
+
return options.filter((o) => keys.has(getKey(o.value)));
|
|
65
|
+
};
|
|
66
|
+
const areOptionsShallowEqual = (a, b, getKey) => {
|
|
67
|
+
const keysA = Object.keys(a);
|
|
68
|
+
const keysB = Object.keys(b);
|
|
69
|
+
if (keysA.length !== keysB.length) return false;
|
|
70
|
+
return keysA.every((k) => {
|
|
71
|
+
if (k === "value") return getKey(a.value) === getKey(b.value);
|
|
72
|
+
return a[k] === b[k];
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
const areResolvedValuesEqual = (prev, next, multiple, getKey) => {
|
|
76
|
+
if (multiple) {
|
|
77
|
+
if (!Array.isArray(prev) || !Array.isArray(next)) return false;
|
|
78
|
+
if (prev.length !== next.length) return false;
|
|
79
|
+
return prev.every((o, i) => {
|
|
80
|
+
const n2 = next[i];
|
|
81
|
+
return !!n2 && areOptionsShallowEqual(o, n2, getKey);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
const p = prev;
|
|
85
|
+
const n = next;
|
|
86
|
+
if (p === n) return true;
|
|
87
|
+
if (!p || !n) return false;
|
|
88
|
+
return areOptionsShallowEqual(p, n, getKey);
|
|
89
|
+
};
|
|
90
|
+
const isResolvedValueEmpty = (resolvedValue, multiple) => {
|
|
91
|
+
if (multiple) {
|
|
92
|
+
return !Array.isArray(resolvedValue) || resolvedValue.length === 0;
|
|
93
|
+
}
|
|
94
|
+
return !resolvedValue;
|
|
95
|
+
};
|
|
96
|
+
const AutocompleteOption = ({
|
|
97
|
+
liProps,
|
|
98
|
+
option,
|
|
99
|
+
customRender
|
|
100
|
+
}) => {
|
|
101
|
+
return /* @__PURE__ */ jsx("li", __spreadProps(__spreadValues({}, liProps), { children: customRender ? customRender(option) : option.label }));
|
|
102
|
+
};
|
|
103
|
+
const AutocompleteChips = ({
|
|
104
|
+
value,
|
|
105
|
+
getTagProps,
|
|
106
|
+
size,
|
|
107
|
+
maxChipsToShow,
|
|
108
|
+
renderChipLabel,
|
|
109
|
+
getKey
|
|
110
|
+
}) => {
|
|
111
|
+
const displayed = value.slice(0, maxChipsToShow);
|
|
112
|
+
const hidden = value.length - maxChipsToShow;
|
|
113
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
114
|
+
displayed.map((option, index) => {
|
|
115
|
+
const _a = getTagProps({ index }), { key: _ignored } = _a, tagProps = __objRest(_a, ["key"]);
|
|
116
|
+
return /* @__PURE__ */ jsx(
|
|
117
|
+
Chip,
|
|
118
|
+
__spreadProps(__spreadValues({}, tagProps), {
|
|
119
|
+
size,
|
|
120
|
+
label: renderChipLabel ? renderChipLabel(option) : option.label,
|
|
121
|
+
avatar: option.img ? /* @__PURE__ */ jsx(Avatar, { src: option.img }) : void 0,
|
|
122
|
+
deleteIcon: /* @__PURE__ */ jsx(ClearIcon, {})
|
|
123
|
+
}),
|
|
124
|
+
getKey(option.value)
|
|
125
|
+
);
|
|
126
|
+
}),
|
|
127
|
+
hidden > 0 && /* @__PURE__ */ jsx(Chip, { size, label: `+${hidden} más` })
|
|
128
|
+
] });
|
|
129
|
+
};
|
|
130
|
+
const AutocompleteLoader = ({
|
|
131
|
+
text = "Cargando..."
|
|
132
|
+
}) => /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
|
|
133
|
+
/* @__PURE__ */ jsx(CircularProgress, { size: 16 }),
|
|
134
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", children: text })
|
|
135
|
+
] });
|
|
136
|
+
function Autocomplete(props) {
|
|
57
137
|
const {
|
|
58
138
|
label,
|
|
59
|
-
options
|
|
60
|
-
value,
|
|
61
|
-
onChange,
|
|
139
|
+
options,
|
|
62
140
|
placeholder,
|
|
63
141
|
multiple = false,
|
|
64
142
|
disabled = false,
|
|
143
|
+
readOnly = false,
|
|
65
144
|
loading = false,
|
|
66
|
-
error = false,
|
|
145
|
+
error: errorProp = false,
|
|
67
146
|
helperText,
|
|
147
|
+
maxChipsToShow = 3,
|
|
68
148
|
renderOptionItem,
|
|
69
149
|
renderChipLabel,
|
|
70
|
-
|
|
150
|
+
renderSingleValue,
|
|
151
|
+
borderRadius = 10,
|
|
152
|
+
labelPosition = "outside",
|
|
153
|
+
size = "small",
|
|
154
|
+
noOptionsText = "No hay opciones",
|
|
155
|
+
loadingText,
|
|
156
|
+
sx,
|
|
157
|
+
preset,
|
|
158
|
+
textFieldProps,
|
|
159
|
+
onInputChange,
|
|
160
|
+
inputValue,
|
|
161
|
+
filterOptions,
|
|
162
|
+
freeSolo,
|
|
163
|
+
open,
|
|
164
|
+
onOpen,
|
|
165
|
+
onClose,
|
|
166
|
+
getOptionKey
|
|
71
167
|
} = props;
|
|
72
|
-
const
|
|
73
|
-
|
|
168
|
+
const getKey = getOptionKey != null ? getOptionKey : ((v) => v);
|
|
169
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
170
|
+
const seenOptionsRef = useRef(/* @__PURE__ */ new Map());
|
|
171
|
+
for (const opt of options) {
|
|
172
|
+
seenOptionsRef.current.set(getKey(opt.value), opt);
|
|
173
|
+
}
|
|
174
|
+
const resolvePool = useMemo(() => {
|
|
175
|
+
const merged = new Map(seenOptionsRef.current);
|
|
176
|
+
for (const opt of options) merged.set(getKey(opt.value), opt);
|
|
177
|
+
return Array.from(merged.values());
|
|
178
|
+
}, [options]);
|
|
179
|
+
const prevResolvedRef = useRef(multiple ? [] : null);
|
|
180
|
+
const stabilizeResolved = (newVal) => {
|
|
181
|
+
if (areResolvedValuesEqual(prevResolvedRef.current, newVal, multiple, getKey)) {
|
|
182
|
+
return prevResolvedRef.current;
|
|
183
|
+
}
|
|
184
|
+
prevResolvedRef.current = newVal;
|
|
185
|
+
return newVal;
|
|
186
|
+
};
|
|
187
|
+
const theme = useTheme();
|
|
188
|
+
const presetSx = resolvePreset("Autocomplete", preset, theme);
|
|
189
|
+
const mergedSx = [
|
|
190
|
+
buildAutocompleteSx(borderRadius, labelPosition),
|
|
191
|
+
...presetSx ? [presetSx] : [],
|
|
192
|
+
...Array.isArray(sx) ? sx : sx ? [sx] : []
|
|
193
|
+
];
|
|
194
|
+
const renderAutocomplete = (resolvedValue2, handleChange) => {
|
|
195
|
+
const isEmpty = isResolvedValueEmpty(resolvedValue2, multiple);
|
|
196
|
+
const showPlaceholder = isEmpty && isFocused && !!placeholder;
|
|
197
|
+
const singleAdornment = !multiple && resolvedValue2 && renderSingleValue ? renderSingleValue(resolvedValue2) : null;
|
|
74
198
|
return /* @__PURE__ */ jsx(
|
|
75
|
-
|
|
199
|
+
Autocomplete$1,
|
|
76
200
|
{
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
201
|
+
multiple,
|
|
202
|
+
options,
|
|
203
|
+
value: resolvedValue2,
|
|
204
|
+
disabled,
|
|
205
|
+
readOnly,
|
|
206
|
+
loading,
|
|
207
|
+
sx: mergedSx,
|
|
208
|
+
freeSolo,
|
|
209
|
+
open,
|
|
210
|
+
onOpen,
|
|
211
|
+
onClose,
|
|
212
|
+
inputValue,
|
|
213
|
+
onInputChange,
|
|
214
|
+
filterOptions,
|
|
215
|
+
getOptionLabel: (opt) => {
|
|
216
|
+
var _a;
|
|
217
|
+
return typeof opt === "string" ? opt : (_a = opt == null ? void 0 : opt.label) != null ? _a : "";
|
|
82
218
|
},
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
219
|
+
isOptionEqualToValue: (a, b) => {
|
|
220
|
+
if (typeof a === "string" || typeof b === "string") return a === b;
|
|
221
|
+
if (!a || !b) return a === b;
|
|
222
|
+
return getKey(a.value) === getKey(b.value);
|
|
223
|
+
},
|
|
224
|
+
getOptionDisabled: (opt) => typeof opt === "string" ? false : !!(opt == null ? void 0 : opt.disabled),
|
|
225
|
+
onChange: handleChange,
|
|
226
|
+
onFocus: () => setIsFocused(true),
|
|
227
|
+
onBlur: () => setIsFocused(false),
|
|
228
|
+
renderOption: (liProps, option) => {
|
|
229
|
+
const _a = liProps, { key: _muiKey } = _a, liRest = __objRest(_a, ["key"]);
|
|
230
|
+
return /* @__PURE__ */ jsx(
|
|
231
|
+
AutocompleteOption,
|
|
232
|
+
{
|
|
233
|
+
liProps: liRest,
|
|
234
|
+
option,
|
|
235
|
+
customRender: renderOptionItem
|
|
96
236
|
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
helperText
|
|
110
|
-
})
|
|
111
|
-
)
|
|
237
|
+
getKey(option.value)
|
|
238
|
+
);
|
|
239
|
+
},
|
|
240
|
+
renderValue: multiple ? (value, getItemProps) => /* @__PURE__ */ jsx(
|
|
241
|
+
AutocompleteChips,
|
|
242
|
+
{
|
|
243
|
+
value,
|
|
244
|
+
getTagProps: getItemProps,
|
|
245
|
+
size,
|
|
246
|
+
maxChipsToShow,
|
|
247
|
+
renderChipLabel,
|
|
248
|
+
getKey
|
|
112
249
|
}
|
|
113
|
-
)
|
|
250
|
+
) : void 0,
|
|
251
|
+
noOptionsText,
|
|
252
|
+
loadingText: loadingText != null ? loadingText : /* @__PURE__ */ jsx(AutocompleteLoader, {}),
|
|
253
|
+
renderInput: (params) => {
|
|
254
|
+
var _a, _b, _c, _d;
|
|
255
|
+
const paramsInputLabel = params.InputLabelProps;
|
|
256
|
+
const consumerInputLabel = (_b = (_a = textFieldProps == null ? void 0 : textFieldProps.slotProps) == null ? void 0 : _a.inputLabel) != null ? _b : textFieldProps == null ? void 0 : textFieldProps.InputLabelProps;
|
|
257
|
+
const muiInputProps = params.InputProps;
|
|
258
|
+
const consumerInputProps = (_d = (_c = textFieldProps == null ? void 0 : textFieldProps.slotProps) == null ? void 0 : _c.input) != null ? _d : textFieldProps == null ? void 0 : textFieldProps.InputProps;
|
|
259
|
+
const inputSlot = singleAdornment ? __spreadProps(__spreadValues(__spreadValues({}, muiInputProps), consumerInputProps), {
|
|
260
|
+
startAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
261
|
+
singleAdornment,
|
|
262
|
+
consumerInputProps == null ? void 0 : consumerInputProps.startAdornment,
|
|
263
|
+
muiInputProps == null ? void 0 : muiInputProps.startAdornment
|
|
264
|
+
] })
|
|
265
|
+
}) : void 0;
|
|
266
|
+
return /* @__PURE__ */ jsx(
|
|
267
|
+
TextField,
|
|
268
|
+
__spreadProps(__spreadValues(__spreadProps(__spreadValues({}, params), {
|
|
269
|
+
label,
|
|
270
|
+
size,
|
|
271
|
+
variant: "outlined",
|
|
272
|
+
placeholder: showPlaceholder ? placeholder : void 0,
|
|
273
|
+
error: !!errorProp,
|
|
274
|
+
helperText
|
|
275
|
+
}), textFieldProps), {
|
|
276
|
+
slotProps: __spreadProps(__spreadValues(__spreadValues({}, textFieldProps == null ? void 0 : textFieldProps.slotProps), inputSlot ? { input: inputSlot } : {}), {
|
|
277
|
+
inputLabel: __spreadProps(__spreadValues(__spreadValues({}, paramsInputLabel), consumerInputLabel), {
|
|
278
|
+
shrink: labelPosition === "outside" ? !isEmpty || isFocused : paramsInputLabel == null ? void 0 : paramsInputLabel.shrink
|
|
279
|
+
})
|
|
280
|
+
})
|
|
281
|
+
})
|
|
282
|
+
);
|
|
283
|
+
}
|
|
114
284
|
}
|
|
115
285
|
);
|
|
116
286
|
};
|
|
117
|
-
const
|
|
287
|
+
const extractValue = (opt) => {
|
|
118
288
|
var _a;
|
|
289
|
+
if (opt === null || opt === void 0) return null;
|
|
290
|
+
if (typeof opt === "string") return opt;
|
|
291
|
+
return (_a = opt == null ? void 0 : opt.value) != null ? _a : null;
|
|
292
|
+
};
|
|
293
|
+
const handleControlledChange = (_event, newValue) => {
|
|
294
|
+
const { onChange } = props;
|
|
119
295
|
if (multiple) {
|
|
120
|
-
const values = (newValue != null ? newValue : []).map((opt) => opt.
|
|
121
|
-
onChange
|
|
296
|
+
const values = (newValue != null ? newValue : []).map((opt) => extractValue(opt)).filter((v) => v !== null);
|
|
297
|
+
onChange(values);
|
|
122
298
|
} else {
|
|
123
|
-
|
|
124
|
-
onChange == null ? void 0 : onChange(value2);
|
|
299
|
+
onChange(extractValue(newValue));
|
|
125
300
|
}
|
|
126
301
|
};
|
|
127
|
-
|
|
302
|
+
const resolvedValue = stabilizeResolved(
|
|
303
|
+
multiple ? resolveMultipleValue(resolvePool, props.value, getKey) : resolveSingleValue(resolvePool, props.value, getKey)
|
|
304
|
+
);
|
|
305
|
+
return renderAutocomplete(resolvedValue, handleControlledChange);
|
|
128
306
|
}
|
|
307
|
+
const AutocompleteSelect = Autocomplete;
|
|
129
308
|
export {
|
|
130
|
-
|
|
309
|
+
Autocomplete,
|
|
310
|
+
AutocompleteSelect,
|
|
311
|
+
Autocomplete as default
|
|
131
312
|
};
|
|
132
313
|
//# sourceMappingURL=Autocomplete.js.map
|