@m4l/components 9.3.16 → 9.3.17-JT25092025.beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/components/Stepper/Stepper.styles.js +17 -14
  2. package/components/Stepper/helpers/getInitialFieldValues/index.d.ts +12 -0
  3. package/components/Stepper/helpers/getInitialFieldValues/index.js +14 -0
  4. package/components/Stepper/helpers/index.d.ts +2 -0
  5. package/components/Stepper/helpers/parseWatchedValues/index.d.ts +17 -0
  6. package/components/Stepper/helpers/parseWatchedValues/index.js +12 -0
  7. package/components/Stepper/hooks/useDynamicValidation/index.d.ts +11 -0
  8. package/components/Stepper/hooks/useDynamicValidation/index.js +69 -0
  9. package/components/Stepper/hooks/useStepperActions/index.js +19 -3
  10. package/components/Stepper/store/StepperStore/index.js +20 -1
  11. package/components/Stepper/subcomponents/StepArea/index.js +41 -25
  12. package/components/Stepper/subcomponents/StepArea/subcomponents/Inidicator/index.js +18 -10
  13. package/components/Stepper/subcomponents/StepperButtons/StepperCancelButton/index.d.ts +2 -1
  14. package/components/Stepper/subcomponents/StepperButtons/StepperCancelButton/index.js +39 -6
  15. package/components/Stepper/subcomponents/StepperButtons/StepperNextButton/index.d.ts +2 -1
  16. package/components/Stepper/subcomponents/StepperButtons/StepperNextButton/index.js +5 -3
  17. package/components/Stepper/subcomponents/StepperButtons/StepperPrevButton/index.d.ts +2 -1
  18. package/components/Stepper/subcomponents/StepperButtons/StepperPrevButton/index.js +5 -3
  19. package/components/Stepper/subcomponents/StepperButtons/StepperSubmitButton/index.d.ts +2 -1
  20. package/components/Stepper/subcomponents/StepperButtons/StepperSubmitButton/index.js +5 -3
  21. package/components/Stepper/subcomponents/StepperContent/subcomponents/Step/index.js +30 -11
  22. package/components/Stepper/subcomponents/StepperFooter/subcomponents/StepperFooterRightActions/index.js +20 -10
  23. package/components/Stepper/types.d.ts +7 -0
  24. package/components/areas/icons.js +1 -1
  25. package/components/hook-form/RHFAutocomplete/RHFAutocomplete.js +3 -35
  26. package/components/hook-form/RHFAutocomplete/types.d.ts +1 -6
  27. package/components/hook-form/RHFormContext/index.d.ts +1 -1
  28. package/components/hook-form/RHFormContext/index.js +29 -4
  29. package/components/index.d.ts +1 -0
  30. package/components/mui_extended/Autocomplete/Autocomplete.js +12 -6
  31. package/components/mui_extended/Autocomplete/Autocomplete.styles.js +48 -5
  32. package/components/mui_extended/Autocomplete/hooks/useEndAdornments.d.ts +1 -0
  33. package/components/mui_extended/Autocomplete/hooks/useEndAdornments.js +4 -3
  34. package/components/mui_extended/Autocomplete/hooks/useStartAdornments.js +4 -4
  35. package/components/mui_extended/Autocomplete/hooks/useValuesAndHandlers.js +39 -4
  36. package/components/mui_extended/Autocomplete/slots/AutocompleteEnum.d.ts +3 -1
  37. package/components/mui_extended/Autocomplete/slots/AutocompleteEnum.js +2 -0
  38. package/components/mui_extended/Autocomplete/slots/AutocompleteSlots.d.ts +6 -0
  39. package/components/mui_extended/Autocomplete/slots/AutocompleteSlots.js +11 -1
  40. package/components/mui_extended/Autocomplete/types.d.ts +1 -1
  41. package/components/mui_extended/Button/ButtonStyles.js +3 -6
  42. package/components/mui_extended/Popper/Popper.js +9 -2
  43. package/components/mui_extended/Popper/types.d.ts +1 -0
  44. package/components/mui_extended/Select/Select.js +17 -10
  45. package/components/mui_extended/Select/Select.styles.js +17 -10
  46. package/components/mui_extended/Select/types.d.ts +1 -1
  47. package/components/mui_extended/TextField/TextField.d.ts +2 -1
  48. package/components/mui_extended/TextField/TextField.js +25 -4
  49. package/components/mui_extended/TextField/TextField.styles.js +132 -125
  50. package/components/mui_extended/TextField/slots/TextFieldSlots.d.ts +3 -9
  51. package/components/mui_extended/TextField/slots/TextFieldSlots.js +2 -1
  52. package/components/mui_extended/Typography/Typography.js +1 -1
  53. package/package.json +1 -1
  54. package/test/mocks/dictionary-mock.d.ts +433 -0
@@ -7,7 +7,8 @@ import { useIsMobile } from "@m4l/graphics";
7
7
  import { D as DICTIONARY } from "../../../dictionary.js";
8
8
  import { I as IconButton } from "../../../../mui_extended/IconButton/IconButton.js";
9
9
  import { B as Button } from "../../../../mui_extended/Button/Button.js";
10
- function StepperPrevButton() {
10
+ function StepperPrevButton(props) {
11
+ const { label, ...rest } = props;
11
12
  const { currentStep } = useStepper((state) => ({
12
13
  currentStep: state.currentStep
13
14
  }));
@@ -35,12 +36,13 @@ function StepperPrevButton() {
35
36
  Button,
36
37
  {
37
38
  type: "button",
38
- label: !isMobile ? getLabel(DICTIONARY.LABEL_PREV_BUTTON) : "",
39
+ label: label || getLabel(DICTIONARY.LABEL_PREV_BUTTON),
39
40
  variant: "outlined",
40
41
  color: "default",
41
42
  onClick: handlePrev,
42
43
  startIcon: `${host_static_assets}/${environment_assets}/${pathIcons.arrowLeft}`,
43
- "data-testid": "stepper-prev-button"
44
+ "data-testid": "stepper-prev-button",
45
+ ...rest
44
46
  }
45
47
  );
46
48
  }
@@ -1,4 +1,5 @@
1
+ import { StepperButtonProps } from '../../../types';
1
2
  /**
2
3
  * Botón modular para finalizar el Stepper y ejecutar onFinalSubmit
3
4
  */
4
- export declare function StepperSubmitButton(): import("react/jsx-runtime").JSX.Element;
5
+ export declare function StepperSubmitButton(props: StepperButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -2,16 +2,18 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { D as DICTIONARY } from "../../../dictionary.js";
3
3
  import { useModuleDictionary } from "@m4l/core";
4
4
  import { B as Button } from "../../../../mui_extended/Button/Button.js";
5
- function StepperSubmitButton() {
5
+ function StepperSubmitButton(props) {
6
+ const { label, ...rest } = props;
6
7
  const { getLabel } = useModuleDictionary();
7
8
  return /* @__PURE__ */ jsx(
8
9
  Button,
9
10
  {
10
11
  type: "submit",
11
- label: getLabel(DICTIONARY.LABEL_SUBMIT_BUTTON),
12
+ label: label || getLabel(DICTIONARY.LABEL_SUBMIT_BUTTON),
12
13
  variant: "contained",
13
14
  color: "primary",
14
- "data-testid": "stepper-submit-button"
15
+ "data-testid": "stepper-submit-button",
16
+ ...rest
15
17
  }
16
18
  );
17
19
  }
@@ -12,28 +12,47 @@ function Step(props) {
12
12
  steps: state.steps,
13
13
  visibilityData: state.visibilityData
14
14
  }));
15
- const currentStepConfig = useMemo(() => {
16
- return steps[currentStep];
17
- }, [steps, currentStep]);
18
15
  const stepConfig = useMemo(() => {
19
16
  return steps.find((step) => step.key === stepKey);
20
17
  }, [steps, stepKey]);
21
18
  const isStepVisible = useMemo(() => {
22
- if (!currentStepConfig) {
23
- return false;
24
- }
25
- if (stepKey !== currentStepConfig.key) {
19
+ if (!stepConfig) {
26
20
  return false;
27
21
  }
28
- if (stepConfig && !evaluateVisibilityStepCondition(
22
+ const meetsVisibilityCondition = evaluateVisibilityStepCondition(
29
23
  stepConfig,
30
24
  formValues || {},
31
25
  visibilityData
32
- )) {
26
+ );
27
+ if (!meetsVisibilityCondition) {
28
+ return false;
29
+ }
30
+ const currentStepConfig = steps[currentStep];
31
+ if (!currentStepConfig) {
32
+ return false;
33
+ }
34
+ if (evaluateVisibilityStepCondition(currentStepConfig, formValues || {}, visibilityData)) {
35
+ return stepKey === currentStepConfig.key;
36
+ }
37
+ const visibleStepsUpToCurrent = [];
38
+ for (let i = 0; i <= currentStep; i++) {
39
+ const step = steps[i];
40
+ if (evaluateVisibilityStepCondition(step, formValues || {}, visibilityData)) {
41
+ visibleStepsUpToCurrent.push(step);
42
+ }
43
+ }
44
+ if (visibleStepsUpToCurrent.length === 0) {
45
+ for (let i = currentStep + 1; i < steps.length; i++) {
46
+ const step = steps[i];
47
+ if (evaluateVisibilityStepCondition(step, formValues || {}, visibilityData)) {
48
+ return stepKey === step.key;
49
+ }
50
+ }
33
51
  return false;
34
52
  }
35
- return true;
36
- }, [currentStepConfig, stepKey, stepConfig, formValues, visibilityData]);
53
+ const activeVisibleStep = visibleStepsUpToCurrent[visibleStepsUpToCurrent.length - 1];
54
+ return stepKey === activeVisibleStep.key;
55
+ }, [currentStep, stepKey, stepConfig, steps, formValues, visibilityData]);
37
56
  return /* @__PURE__ */ jsx(StepContentStyled, { ownerState: { isStepVisible }, children });
38
57
  }
39
58
  export {
@@ -1,19 +1,29 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import React, { useMemo } from "react";
2
+ import React, { useState, useEffect, useMemo } from "react";
3
3
  import { u as useIsLastVisibleValidStep } from "../../../../hooks/useIsLastVisibleValidStep/index.js";
4
4
  import { m as StepperFooterRightActionsStyled } from "../../../../slots/StepperSlot.js";
5
- import { S as StepperNextButton } from "../../../StepperButtons/StepperNextButton/index.js";
6
5
  import { S as StepperSubmitButton } from "../../../StepperButtons/StepperSubmitButton/index.js";
6
+ import { S as StepperNextButton } from "../../../StepperButtons/StepperNextButton/index.js";
7
7
  function StepperFooterRightActions(props) {
8
8
  const { children } = props;
9
9
  const isLastVisibleValidStep = useIsLastVisibleValidStep();
10
- const childrenWithoutNextButton = useMemo(() => {
11
- if (!isLastVisibleValidStep) {
12
- return children;
13
- }
10
+ const [hasCustomSubmitButton, setHasCustomSubmitButton] = useState(false);
11
+ useEffect(() => {
12
+ const hasCustomButton = React.Children.toArray(children).some((child) => {
13
+ if (React.isValidElement(child)) {
14
+ return child.type === StepperSubmitButton;
15
+ }
16
+ return false;
17
+ });
18
+ setHasCustomSubmitButton(hasCustomButton);
19
+ }, [children]);
20
+ const filteredChildren = useMemo(() => {
14
21
  return React.Children.toArray(children).filter((child) => {
15
22
  if (React.isValidElement(child)) {
16
- if (child.type === StepperNextButton) {
23
+ if (!isLastVisibleValidStep && child.type === StepperSubmitButton) {
24
+ return false;
25
+ }
26
+ if (isLastVisibleValidStep && child.type === StepperNextButton) {
17
27
  return false;
18
28
  }
19
29
  }
@@ -21,10 +31,10 @@ function StepperFooterRightActions(props) {
21
31
  });
22
32
  }, [children, isLastVisibleValidStep]);
23
33
  const submitButton = useMemo(() => {
24
- return isLastVisibleValidStep ? /* @__PURE__ */ jsx(StepperSubmitButton, {}) : null;
25
- }, [isLastVisibleValidStep]);
34
+ return isLastVisibleValidStep && !hasCustomSubmitButton ? /* @__PURE__ */ jsx(StepperSubmitButton, {}) : null;
35
+ }, [isLastVisibleValidStep, hasCustomSubmitButton]);
26
36
  return /* @__PURE__ */ jsxs(StepperFooterRightActionsStyled, { children: [
27
- childrenWithoutNextButton,
37
+ filteredChildren,
28
38
  submitButton
29
39
  ] });
30
40
  }
@@ -5,6 +5,7 @@ import { ContentAreaSlots, ContentSlots, StepperFooterSlots, StepperSlots } from
5
5
  import { STEPPER_PREFIX_NAME } from './constants';
6
6
  import { M4LOverridesStyleRules } from '../../@types/augmentations';
7
7
  import { Step as StepComponent } from './subcomponents/StepperContent/subcomponents/Step';
8
+ import { ButtonProps } from '../mui_extended/Button';
8
9
  export type Orientation = 'horizontal' | 'vertical';
9
10
  export type IndicatorType = 'number' | 'dot';
10
11
  export type FormData = Record<string, string | number | boolean | null | undefined>;
@@ -145,6 +146,12 @@ export interface StepperFooterProps {
145
146
  export interface StepperFooterLeftActionsProps {
146
147
  children?: ReactNode;
147
148
  }
149
+ /**
150
+ * Props para los botones del Stepper que extienden las props de Button de mui_extended
151
+ */
152
+ export interface StepperButtonProps extends Omit<ButtonProps, 'label'> {
153
+ label?: string;
154
+ }
148
155
  /**
149
156
  * Props del StepperFooterRightActions
150
157
  */
@@ -1,6 +1,6 @@
1
1
  const ICONS = {
2
2
  MAXIMIZE: "window_expand.svg",
3
- NORMALIZE: "window_normalize.svg",
3
+ NORMALIZE: "window_minimize.svg",
4
4
  COLLAPSE: "window_collapse.svg",
5
5
  UNCOLLPASE: "window_uncollapse.svg",
6
6
  RESET_COOKIES: "reset_cookies.svg",
@@ -1,7 +1,4 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { getPropertyByString } from "@m4l/core";
3
- import { useIsMobile } from "@m4l/graphics";
4
- import { useTheme } from "@mui/material";
5
2
  import { useId, useState, useCallback, useEffect } from "react";
6
3
  import { useFormContext, Controller } from "react-hook-form";
7
4
  import { A as AutocompleteRootStyled, L as LabelStyled } from "./slots/RHFAutocompleteSlots.js";
@@ -13,28 +10,22 @@ function RHFAutocomplete(props) {
13
10
  getOptionLabel,
14
11
  isOptionEqualToValue,
15
12
  label,
16
- color,
17
13
  options,
18
14
  disabled,
19
15
  onOpen,
20
16
  onClose,
21
17
  loading,
22
- variant,
23
18
  helperMessage,
24
19
  size,
25
20
  onChangeFilterParmsLocal,
26
21
  mandatory,
27
22
  mandatoryMessage,
28
23
  multiple,
29
- imageScale = true,
30
- imageRepeat,
31
24
  refresh
32
25
  // onChange: onChangeRHF,
33
26
  } = props;
34
27
  const htmlForId = useId();
35
- const theme = useTheme();
36
28
  const [open, setOpen] = useState(false);
37
- const isDesktop = !useIsMobile();
38
29
  const onCloseLocal = useCallback((event, reason) => {
39
30
  setOpen(false);
40
31
  if (onClose) {
@@ -59,34 +50,11 @@ function RHFAutocomplete(props) {
59
50
  },
60
51
  [getOptionLabel]
61
52
  );
62
- const paletteColor = getPropertyByString(
63
- theme.vars.palette,
64
- disabled ? "default" : color || "default",
65
- theme.vars.palette.default
66
- );
67
53
  const {
68
- control,
69
- formState: { errors }
54
+ control
70
55
  } = useFormContext();
71
- const [currentVariant, setCurrentVariant] = useState(null);
72
- useEffect(() => {
73
- const hasError = errors[nameRHF];
74
- if (hasError) {
75
- setCurrentVariant("error");
76
- } else if (variant) {
77
- setCurrentVariant(variant);
78
- } else {
79
- setCurrentVariant(null);
80
- }
81
- }, [errors, nameRHF, variant, control]);
82
56
  const ownerState = {
83
- size: !isDesktop ? "medium" : size,
84
- semantics: currentVariant,
85
- disabled,
86
- multiple: Boolean(multiple),
87
- imageScale: Boolean(imageScale),
88
- imageRepeat: Boolean(imageRepeat),
89
- paletteColor
57
+ disabled
90
58
  };
91
59
  return /* @__PURE__ */ jsx(
92
60
  AutocompleteRootStyled,
@@ -147,7 +115,7 @@ function RHFAutocomplete(props) {
147
115
  htmlFor: htmlForId
148
116
  }
149
117
  ),
150
- currentVariant === "error" ? /* @__PURE__ */ jsx(HelperError, { message: error?.message }) : null
118
+ error?.message ? /* @__PURE__ */ jsx(HelperError, { message: error?.message }) : null
151
119
  ] });
152
120
  }
153
121
  }
@@ -1,4 +1,4 @@
1
- import { AutocompleteCloseReason, AutocompleteFreeSoloValueMapping, AutocompleteInputChangeReason, AutocompleteProps as MUIAutocompleteProps, Theme, PaletteColor, PopperProps } from '@mui/material';
1
+ import { AutocompleteCloseReason, AutocompleteFreeSoloValueMapping, AutocompleteInputChangeReason, AutocompleteProps as MUIAutocompleteProps, Theme, PopperProps } from '@mui/material';
2
2
  import { ComponentPalletColor, Sizes } from '@m4l/styles';
3
3
  import { TextFieldProps } from '../../mui_extended/TextField/types';
4
4
  import { RFHAUTOCOMPLETE_KEY_COMPONENT } from './constants';
@@ -52,11 +52,6 @@ export interface RHFAutocompleteProps<T = any, Multiple extends boolean | undefi
52
52
  */
53
53
  export interface RHFAutocompleteOwnerState extends Pick<RHFAutocompleteProps<any>, 'size' | 'disabled' | 'variant'> {
54
54
  disabled?: boolean;
55
- semantics: RHFAutocompleteVariants | 'error' | null;
56
- multiple: boolean;
57
- imageScale?: boolean;
58
- imageRepeat?: boolean;
59
- paletteColor: PaletteColor;
60
55
  }
61
56
  /**
62
57
  * Defines the types of Slots available for the Autocomplete.
@@ -3,7 +3,7 @@ import { CustomFormArguments, FormProviderCustomProps, FormProviderProps } from
3
3
  /**
4
4
  * TODO: Documentar
5
5
  */
6
- export declare function useCustomForm({ validationSchema, values, statusLoad, mode }: CustomFormArguments): import('react-hook-form').UseFormReturn<FieldValues, any, FieldValues>;
6
+ export declare function useCustomForm({ validationSchema, values, statusLoad, mode, }: CustomFormArguments): import('react-hook-form').UseFormReturn<FieldValues, any, FieldValues>;
7
7
  /**
8
8
  * TODO: Documentar
9
9
  */
@@ -6,7 +6,12 @@ import { yupResolver } from "@hookform/resolvers/yup";
6
6
  import { F as FormProviderRoot } from "./styles.js";
7
7
  import { R as RHFormProviderUtilityClasses } from "./classes/index.js";
8
8
  const classes = RHFormProviderUtilityClasses();
9
- function useCustomForm({ validationSchema, values, statusLoad, mode }) {
9
+ function useCustomForm({
10
+ validationSchema,
11
+ values,
12
+ statusLoad,
13
+ mode
14
+ }) {
10
15
  const formMethods = useForm({
11
16
  resolver: yupResolver(validationSchema),
12
17
  defaultValues: values,
@@ -39,11 +44,31 @@ function useCustomForm({ validationSchema, values, statusLoad, mode }) {
39
44
  }
40
45
  function FormProviderCustom(props) {
41
46
  const { children, onSubmit, className, handleSubmit } = props;
42
- return /* @__PURE__ */ jsx(FormProvider, { ...props, children: /* @__PURE__ */ jsx(FormProviderRoot, { className: clsx(classes.root, className), onSubmit: handleSubmit(onSubmit), children }) });
47
+ return /* @__PURE__ */ jsx(FormProvider, { ...props, children: /* @__PURE__ */ jsx(
48
+ FormProviderRoot,
49
+ {
50
+ className: clsx(classes.root, className),
51
+ onSubmit: handleSubmit(onSubmit),
52
+ children
53
+ }
54
+ ) });
43
55
  }
44
56
  function RHFormProvider(props) {
45
- const { children, onSubmit, values, validationSchema, statusLoad = "ready", className, mode } = props;
46
- const formMethods = useCustomForm({ validationSchema, statusLoad, values, mode });
57
+ const {
58
+ children,
59
+ onSubmit,
60
+ values,
61
+ validationSchema,
62
+ statusLoad = "ready",
63
+ className,
64
+ mode
65
+ } = props;
66
+ const formMethods = useCustomForm({
67
+ validationSchema,
68
+ statusLoad,
69
+ values,
70
+ mode
71
+ });
47
72
  return /* @__PURE__ */ jsx(
48
73
  FormProviderCustom,
49
74
  {
@@ -6,6 +6,7 @@ export * from './areas';
6
6
  export * from './BaseModule';
7
7
  export * from './Card';
8
8
  export * from './Chip';
9
+ export * from './Card';
9
10
  export * from './commercial';
10
11
  export * from './CommonActions/';
11
12
  export * from './ContainerFlow';
@@ -21,7 +21,9 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
21
21
  // Diferencia
22
22
  refresh,
23
23
  error = false,
24
- htmlFor
24
+ htmlFor,
25
+ readOnly = false,
26
+ placeholder
25
27
  } = props;
26
28
  const { getLabel } = useModuleDictionary();
27
29
  const isSkeleton = useModuleSkeleton();
@@ -47,8 +49,9 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
47
49
  variant,
48
50
  disabled,
49
51
  multiple: Boolean(multiple),
50
- error
51
- }), [adjustedSize, disabled, error, multiple, variant]);
52
+ error,
53
+ readOnly
54
+ }), [adjustedSize, disabled, error, multiple, variant, readOnly]);
52
55
  const startAdornments = useStartAdornments({
53
56
  selectedValue,
54
57
  multiple,
@@ -66,7 +69,8 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
66
69
  handleRefresh,
67
70
  disabled,
68
71
  onOpenLocal,
69
- open
72
+ open,
73
+ readOnly
70
74
  });
71
75
  if (isSkeleton) {
72
76
  return /* @__PURE__ */ jsx(
@@ -158,12 +162,14 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
158
162
  InputProps: {
159
163
  ...otherInputProps,
160
164
  startAdornment: startAdornments,
161
- endAdornment: endAdornments
165
+ endAdornment: endAdornments,
166
+ readOnly
162
167
  },
163
168
  SelectProps: { native: true },
164
169
  size: adjustedSize,
165
170
  fullWidth: true,
166
- disabled
171
+ disabled,
172
+ placeholder
167
173
  }
168
174
  );
169
175
  }
@@ -10,7 +10,20 @@ const autocompleteSyles = {
10
10
  /**
11
11
  * Styles for the icon button component.
12
12
  */
13
- iconButton: {},
13
+ iconButton: ({ ownerState }) => ({
14
+ ...ownerState?.readOnly && {
15
+ "&:hover": {
16
+ backgroundColor: "unset!important"
17
+ },
18
+ "&:active": {
19
+ backgroundColor: "unset!important"
20
+ },
21
+ "&:focus-visible": {
22
+ backgroundColor: "unset!important",
23
+ outline: "none!important"
24
+ }
25
+ }
26
+ }),
14
27
  /**
15
28
  * Styles for the input component.
16
29
  */
@@ -79,10 +92,22 @@ const autocompleteSyles = {
79
92
  /**
80
93
  * Styles for the popper component.
81
94
  */
82
- popper: ({ theme }) => ({
83
- ...theme.typography.body1,
95
+ popper: () => ({
96
+ width: "fit-content!important",
97
+ maxWidth: "calc(100vw - 20px)",
84
98
  "& .MuiPaper-root": {
85
- width: "100%"
99
+ minWidth: "100%",
100
+ maxHeight: "200px",
101
+ "& .MuiAutocomplete-listbox": {
102
+ height: "100%",
103
+ "& .M4LMenuItem-root ": {
104
+ width: "fit-content",
105
+ "& .M4LTypography-root": {
106
+ width: "fit-content",
107
+ overflow: "unset"
108
+ }
109
+ }
110
+ }
86
111
  }
87
112
  }),
88
113
  /**
@@ -106,7 +131,25 @@ const autocompleteSyles = {
106
131
  )
107
132
  };
108
133
  },
109
- renderInputText: {}
134
+ renderInputText: {},
135
+ /**
136
+ * Styles for the container multiple values component.
137
+ */
138
+ containerMultipleValues: () => ({
139
+ display: "flex",
140
+ overflow: "auto",
141
+ width: "100%",
142
+ flex: 1,
143
+ maxHeight: "80px"
144
+ }),
145
+ /**
146
+ * Styles for the container wrapper component.
147
+ */
148
+ containerWrapper: ({ theme }) => ({
149
+ display: "flex",
150
+ flexWrap: "wrap",
151
+ gap: theme.vars.size.baseSpacings.sp1
152
+ })
110
153
  };
111
154
  export {
112
155
  autocompleteSyles as a
@@ -8,6 +8,7 @@ export type UseAdornmentsProps = {
8
8
  disabled?: boolean;
9
9
  onOpenLocal: (event: React.MouseEvent<HTMLButtonElement>) => void;
10
10
  open: boolean;
11
+ readOnly?: boolean;
11
12
  };
12
13
  /**
13
14
  * Hook para el componente Autocomplete local
@@ -11,7 +11,8 @@ function useEndAdornments(props) {
11
11
  handleRefresh,
12
12
  disabled,
13
13
  onOpenLocal,
14
- open
14
+ open,
15
+ readOnly
15
16
  } = props;
16
17
  const { host_static_assets, environment_assets } = useEnvironment();
17
18
  return /* @__PURE__ */ jsxs(AdormentsStyled, { children: [
@@ -26,7 +27,7 @@ function useEndAdornments(props) {
26
27
  {
27
28
  ownerState: { ...ownerState },
28
29
  icon: `${host_static_assets}/${environment_assets}/${icons.refresh}`,
29
- onClick: handleRefresh,
30
+ onClick: !readOnly ? handleRefresh : void 0,
30
31
  disabled,
31
32
  size: adjustedSize
32
33
  }
@@ -36,7 +37,7 @@ function useEndAdornments(props) {
36
37
  {
37
38
  ownerState: { ...ownerState },
38
39
  icon: `${host_static_assets}/${environment_assets}/${icons.chevronDown}`,
39
- onClick: (event) => onOpenLocal(event),
40
+ onClick: (event) => !readOnly ? onOpenLocal(event) : void 0,
40
41
  disabled,
41
42
  size: adjustedSize,
42
43
  rotationAngle: open ? 180 : 0
@@ -1,5 +1,5 @@
1
- import { jsx, Fragment } from "react/jsx-runtime";
2
- import { b as ChipStyled } from "../slots/AutocompleteSlots.js";
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { b as ContainerMultipleValuesStyled, c as ContainerWrapperStyled, d as ChipStyled } from "../slots/AutocompleteSlots.js";
3
3
  function useStartAdornments(props) {
4
4
  const {
5
5
  selectedValue,
@@ -13,7 +13,7 @@ function useStartAdornments(props) {
13
13
  if (!(Array.isArray(selectedValue) && multiple)) {
14
14
  return null;
15
15
  }
16
- return /* @__PURE__ */ jsx(Fragment, { children: selectedValue.map((option, index) => /* @__PURE__ */ jsx(
16
+ return /* @__PURE__ */ jsx(ContainerMultipleValuesStyled, { children: /* @__PURE__ */ jsx(ContainerWrapperStyled, { children: selectedValue.map((option, index) => /* @__PURE__ */ jsx(
17
17
  ChipStyled,
18
18
  {
19
19
  size: adjustedSize,
@@ -24,7 +24,7 @@ function useStartAdornments(props) {
24
24
  ownerState: { ...ownerState }
25
25
  },
26
26
  `${option}-${index}`
27
- )) });
27
+ )) }) });
28
28
  }
29
29
  export {
30
30
  useStartAdornments as u
@@ -4,7 +4,7 @@ function useValuesAndHandlers(props) {
4
4
  const {
5
5
  getOptionLabel,
6
6
  isOptionEqualToValue,
7
- options,
7
+ options = [],
8
8
  onOpen,
9
9
  onClose,
10
10
  onChangeFilterParmsLocal,
@@ -13,7 +13,8 @@ function useValuesAndHandlers(props) {
13
13
  // Diferencia
14
14
  refresh,
15
15
  onChange,
16
- value
16
+ value,
17
+ readOnly
17
18
  } = props;
18
19
  const [open, setOpen] = useState(false);
19
20
  const scrollPositionOptionsRef = useRef(0);
@@ -39,6 +40,9 @@ function useValuesAndHandlers(props) {
39
40
  [isOptionEqualToValue]
40
41
  );
41
42
  const handleDelete = useCallback((optionToDelete) => {
43
+ if (readOnly) {
44
+ return;
45
+ }
42
46
  if (Array.isArray(selectedValue)) {
43
47
  const updatedValue = selectedValue.filter(
44
48
  (val) => !isOptionEqualToValueLocal(val, optionToDelete)
@@ -50,7 +54,7 @@ function useValuesAndHandlers(props) {
50
54
  "removeOption"
51
55
  );
52
56
  }
53
- }, [selectedValue, isOptionEqualToValueLocal, onChange]);
57
+ }, [selectedValue, isOptionEqualToValueLocal, onChange, readOnly]);
54
58
  const handleRefresh = useCallback(() => {
55
59
  refresh?.();
56
60
  setOpen(true);
@@ -64,6 +68,9 @@ function useValuesAndHandlers(props) {
64
68
  onChange?.(event, updatedValue, reason);
65
69
  };
66
70
  const handleInputChange = (_event, newValue, reason) => {
71
+ if (readOnly) {
72
+ return;
73
+ }
67
74
  setInputValue(newValue);
68
75
  if (onChangeFilterParmsLocal && reason === "input") {
69
76
  onChangeFilterParmsLocal(newValue, reason);
@@ -85,11 +92,14 @@ function useValuesAndHandlers(props) {
85
92
  }
86
93
  };
87
94
  const onOpenLocal = useCallback((event) => {
95
+ if (readOnly) {
96
+ return;
97
+ }
88
98
  setOpen((currentState) => !currentState);
89
99
  if (onOpen) {
90
100
  onOpen(event);
91
101
  }
92
- }, [onOpen]);
102
+ }, [onOpen, readOnly]);
93
103
  const getOptionLabelLocal = useCallback(
94
104
  (option) => {
95
105
  if (typeof option === "string") {
@@ -109,6 +119,14 @@ function useValuesAndHandlers(props) {
109
119
  return getOptionUrlImage(option);
110
120
  }, [getOptionUrlImage]);
111
121
  const [inputValue, setInputValue] = useState("");
122
+ useEffect(() => {
123
+ if (readOnly && value !== null && value !== void 0 && !multiple) {
124
+ const displayValue = getOptionLabelLocal(value);
125
+ setInputValue(displayValue);
126
+ } else if (readOnly && multiple) {
127
+ setInputValue("");
128
+ }
129
+ }, [readOnly, value, getOptionLabelLocal, multiple]);
112
130
  useEffect(() => {
113
131
  if (open === false && value === null && inputValue !== "") {
114
132
  setInputValue("");
@@ -118,6 +136,23 @@ function useValuesAndHandlers(props) {
118
136
  if (e.code === "Enter") {
119
137
  e.preventDefault();
120
138
  }
139
+ if (readOnly) {
140
+ const allowedKeys = [
141
+ "Tab",
142
+ "Escape",
143
+ "ArrowUp",
144
+ "ArrowDown",
145
+ "ArrowLeft",
146
+ "ArrowRight",
147
+ "Home",
148
+ "End",
149
+ "PageUp",
150
+ "PageDown"
151
+ ];
152
+ if (!allowedKeys.includes(e.key) && !e.ctrlKey && !e.metaKey) {
153
+ e.preventDefault();
154
+ }
155
+ }
121
156
  };
122
157
  const selectedOption = options.find((option) => {
123
158
  return isOptionEqualToValueLocal(option, selectedValue);
@@ -11,5 +11,7 @@ export declare enum AutocompleteSlots {
11
11
  circularProgress = "circularProgress",
12
12
  textField = "textField",
13
13
  image = "image",
14
- renderInputText = "renderInputText"
14
+ renderInputText = "renderInputText",
15
+ containerMultipleValues = "containerMultipleValues",
16
+ containerWrapper = "containerWrapper"
15
17
  }