@m4l/components 9.3.19-BE021025-beta.2 → 9.3.19-JT03102025.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.
- package/components/ImageText/ImageText.styles.js +1 -1
- package/components/Stepper/Stepper.styles.js +17 -14
- package/components/Stepper/helpers/getInitialFieldValues/index.d.ts +12 -0
- package/components/Stepper/helpers/getInitialFieldValues/index.js +14 -0
- package/components/Stepper/helpers/index.d.ts +2 -0
- package/components/Stepper/helpers/parseWatchedValues/index.d.ts +17 -0
- package/components/Stepper/helpers/parseWatchedValues/index.js +12 -0
- package/components/Stepper/hooks/useDynamicValidation/index.d.ts +11 -0
- package/components/Stepper/hooks/useDynamicValidation/index.js +69 -0
- package/components/Stepper/hooks/useStepperActions/index.js +19 -3
- package/components/Stepper/store/StepperStore/index.js +20 -1
- package/components/Stepper/subcomponents/StepArea/index.js +45 -25
- package/components/Stepper/subcomponents/StepArea/subcomponents/Inidicator/index.js +18 -10
- package/components/Stepper/subcomponents/StepperButtons/StepperCancelButton/index.d.ts +2 -1
- package/components/Stepper/subcomponents/StepperButtons/StepperCancelButton/index.js +38 -5
- package/components/Stepper/subcomponents/StepperButtons/StepperNextButton/index.d.ts +2 -1
- package/components/Stepper/subcomponents/StepperButtons/StepperNextButton/index.js +5 -3
- package/components/Stepper/subcomponents/StepperButtons/StepperPrevButton/index.d.ts +2 -1
- package/components/Stepper/subcomponents/StepperButtons/StepperPrevButton/index.js +5 -3
- package/components/Stepper/subcomponents/StepperButtons/StepperSubmitButton/index.d.ts +2 -1
- package/components/Stepper/subcomponents/StepperButtons/StepperSubmitButton/index.js +5 -3
- package/components/Stepper/subcomponents/StepperContent/subcomponents/Step/index.js +30 -11
- package/components/Stepper/subcomponents/StepperFooter/subcomponents/StepperFooterRightActions/index.js +20 -10
- package/components/Stepper/types.d.ts +7 -0
- package/components/hook-form/RHFormContext/index.d.ts +1 -1
- package/components/hook-form/RHFormContext/index.js +29 -4
- package/components/mui_extended/Autocomplete/Autocomplete.js +4 -7
- package/components/mui_extended/Autocomplete/Autocomplete.styles.js +8 -31
- package/components/mui_extended/Autocomplete/hooks/useStartAdornments.d.ts +1 -3
- package/components/mui_extended/Autocomplete/hooks/useStartAdornments.js +17 -39
- package/components/mui_extended/Autocomplete/hooks/useValuesAndHandlers.js +4 -11
- package/components/mui_extended/Autocomplete/slots/AutocompleteEnum.d.ts +1 -2
- package/components/mui_extended/Autocomplete/slots/AutocompleteEnum.js +0 -1
- package/components/mui_extended/Autocomplete/slots/AutocompleteSlots.d.ts +0 -3
- package/components/mui_extended/Autocomplete/slots/AutocompleteSlots.js +0 -5
- package/components/mui_extended/Autocomplete/types.d.ts +1 -6
- package/components/mui_extended/CheckBox/CheckBox.js +0 -1
- package/components/mui_extended/CheckBox/CheckBox.styles.js +1 -1
- package/components/mui_extended/Tooltip/Tooltip.styles.js +3 -8
- package/components/mui_extended/Typography/types.d.ts +1 -2
- package/components/mui_extended/Typography/typography.styles.js +9 -4
- package/contexts/AppearanceComponentContext/AppearanceComponentContext.js +1 -6
- package/package.json +3 -3
|
@@ -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:
|
|
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 (!
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
if (stepKey !== currentStepConfig.key) {
|
|
19
|
+
if (!stepConfig) {
|
|
26
20
|
return false;
|
|
27
21
|
}
|
|
28
|
-
|
|
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
|
-
|
|
36
|
-
|
|
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
|
|
11
|
-
|
|
12
|
-
|
|
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 ===
|
|
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
|
-
|
|
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
|
*/
|
|
@@ -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({
|
|
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(
|
|
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 {
|
|
46
|
-
|
|
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
|
{
|
|
@@ -23,8 +23,7 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
23
23
|
error = false,
|
|
24
24
|
htmlFor,
|
|
25
25
|
readOnly = false,
|
|
26
|
-
placeholder
|
|
27
|
-
startAdornment
|
|
26
|
+
placeholder
|
|
28
27
|
} = props;
|
|
29
28
|
const { getLabel } = useModuleDictionary();
|
|
30
29
|
const isSkeleton = useModuleSkeleton();
|
|
@@ -51,9 +50,8 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
51
50
|
disabled,
|
|
52
51
|
multiple: Boolean(multiple),
|
|
53
52
|
error,
|
|
54
|
-
readOnly
|
|
55
|
-
|
|
56
|
-
}), [adjustedSize, disabled, error, multiple, variant, readOnly, startAdornment]);
|
|
53
|
+
readOnly
|
|
54
|
+
}), [adjustedSize, disabled, error, multiple, variant, readOnly]);
|
|
57
55
|
const startAdornments = useStartAdornments({
|
|
58
56
|
selectedValue,
|
|
59
57
|
multiple,
|
|
@@ -61,8 +59,7 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
61
59
|
getOptionLabelLocal,
|
|
62
60
|
ownerState,
|
|
63
61
|
handleDelete,
|
|
64
|
-
disabled
|
|
65
|
-
startAdornment
|
|
62
|
+
disabled
|
|
66
63
|
});
|
|
67
64
|
const endAdornments = useEndAdornments({
|
|
68
65
|
loading,
|
|
@@ -70,22 +70,17 @@ const autocompleteSyles = {
|
|
|
70
70
|
/**
|
|
71
71
|
* Styles for the text field component.
|
|
72
72
|
*/
|
|
73
|
-
textField: ({ theme
|
|
74
|
-
const sp1 = theme?.vars?.size?.baseSpacings?.sp1 || "4px";
|
|
75
|
-
const sp5 = theme?.vars?.size?.baseSpacings?.sp5 || "16px";
|
|
76
|
-
const sp7 = theme?.vars?.size?.baseSpacings?.sp7 || "24px";
|
|
73
|
+
textField: ({ theme }) => {
|
|
77
74
|
return {
|
|
78
75
|
height: "auto !important",
|
|
79
76
|
position: "relative",
|
|
80
|
-
"
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
} : {
|
|
84
|
-
padding: `${sp1} ${sp7} ${sp1} 0px!important`
|
|
85
|
-
},
|
|
86
|
-
gap: sp1,
|
|
77
|
+
"& .MuiInputBase-root": {
|
|
78
|
+
padding: `${theme.vars.size.baseSpacings.sp1} ${theme.vars.size.baseSpacings.sp12} ${theme.vars.size.baseSpacings.sp1} 0!important`,
|
|
79
|
+
gap: theme.vars.size.baseSpacings.sp1,
|
|
87
80
|
flexWrap: "wrap",
|
|
88
|
-
|
|
81
|
+
paddingLeft: `${theme.vars.size.baseSpacings.sp1} !important`,
|
|
82
|
+
// borderColor: `${ ownerState?.error ? theme.vars.palette.border.error : theme.vars.palette.border.secondary} !important`,
|
|
83
|
+
"& > input": {
|
|
89
84
|
width: "100%",
|
|
90
85
|
textOverflow: "ellipsis",
|
|
91
86
|
whiteSpace: "nowrap",
|
|
@@ -154,25 +149,7 @@ const autocompleteSyles = {
|
|
|
154
149
|
display: "flex",
|
|
155
150
|
flexWrap: "wrap",
|
|
156
151
|
gap: theme.vars.size.baseSpacings.sp1
|
|
157
|
-
})
|
|
158
|
-
/**
|
|
159
|
-
* Styles for the wrapper start adornment component.
|
|
160
|
-
*/
|
|
161
|
-
wrapperStartAdornment: ({ theme }) => {
|
|
162
|
-
const sp1 = theme?.vars?.size?.baseSpacings?.sp1 || "4px";
|
|
163
|
-
return {
|
|
164
|
-
width: "fit-content",
|
|
165
|
-
position: "absolute",
|
|
166
|
-
top: 0,
|
|
167
|
-
bottom: 0,
|
|
168
|
-
left: 0,
|
|
169
|
-
display: "flex",
|
|
170
|
-
flexDirection: "column",
|
|
171
|
-
justifyContent: "center",
|
|
172
|
-
alignItems: "center",
|
|
173
|
-
padding: `0px ${sp1}`
|
|
174
|
-
};
|
|
175
|
-
}
|
|
152
|
+
})
|
|
176
153
|
};
|
|
177
154
|
export {
|
|
178
155
|
autocompleteSyles as a
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AutocompleteOwnerState, AutocompleteProps } from '../types';
|
|
1
|
+
import { AutocompleteOwnerState } from '../types';
|
|
3
2
|
export type UseAdornmentsProps<T> = {
|
|
4
3
|
selectedValue: T | T[] | null;
|
|
5
4
|
multiple?: boolean;
|
|
@@ -15,7 +14,6 @@ export type UseAdornmentsProps<T> = {
|
|
|
15
14
|
handleRefresh: () => void;
|
|
16
15
|
disabled?: boolean;
|
|
17
16
|
onOpenLocal: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
18
|
-
startAdornment: AutocompleteProps<unknown, true>['startAdornment'];
|
|
19
17
|
};
|
|
20
18
|
/**
|
|
21
19
|
* Hook para el componente Autocomplete local
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import
|
|
3
|
-
import { b as ContainerMultipleValuesStyled, c as ContainerWrapperStyled, d as ChipStyled, W as WrapperStartAdornmentStyled } 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";
|
|
4
3
|
function useStartAdornments(props) {
|
|
5
4
|
const {
|
|
6
5
|
selectedValue,
|
|
@@ -9,44 +8,23 @@ function useStartAdornments(props) {
|
|
|
9
8
|
getOptionLabelLocal,
|
|
10
9
|
ownerState,
|
|
11
10
|
handleDelete,
|
|
12
|
-
disabled
|
|
13
|
-
startAdornment
|
|
11
|
+
disabled
|
|
14
12
|
} = props;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}) : null;
|
|
18
|
-
const internalAdornments = useMemo(() => {
|
|
19
|
-
if (!(Array.isArray(selectedValue) && multiple)) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
return /* @__PURE__ */ jsx(ContainerMultipleValuesStyled, { children: /* @__PURE__ */ jsx(ContainerWrapperStyled, { children: selectedValue.map((option, index) => /* @__PURE__ */ jsx(
|
|
23
|
-
ChipStyled,
|
|
24
|
-
{
|
|
25
|
-
size: adjustedSize,
|
|
26
|
-
label: getOptionLabelLocal(option),
|
|
27
|
-
opacity: true,
|
|
28
|
-
onDeleted: () => handleDelete(option),
|
|
29
|
-
disabledDeleteButton: disabled,
|
|
30
|
-
ownerState: { ...ownerState }
|
|
31
|
-
},
|
|
32
|
-
`${option}-${index}`
|
|
33
|
-
)) }) });
|
|
34
|
-
}, [
|
|
35
|
-
selectedValue,
|
|
36
|
-
multiple,
|
|
37
|
-
adjustedSize,
|
|
38
|
-
getOptionLabelLocal,
|
|
39
|
-
handleDelete,
|
|
40
|
-
disabled,
|
|
41
|
-
ownerState
|
|
42
|
-
]);
|
|
43
|
-
if (startAdornmentClone && internalAdornments) {
|
|
44
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
45
|
-
/* @__PURE__ */ jsx(WrapperStartAdornmentStyled, { children: startAdornmentClone }),
|
|
46
|
-
internalAdornments
|
|
47
|
-
] });
|
|
13
|
+
if (!(Array.isArray(selectedValue) && multiple)) {
|
|
14
|
+
return null;
|
|
48
15
|
}
|
|
49
|
-
return
|
|
16
|
+
return /* @__PURE__ */ jsx(ContainerMultipleValuesStyled, { children: /* @__PURE__ */ jsx(ContainerWrapperStyled, { children: selectedValue.map((option, index) => /* @__PURE__ */ jsx(
|
|
17
|
+
ChipStyled,
|
|
18
|
+
{
|
|
19
|
+
size: adjustedSize,
|
|
20
|
+
label: getOptionLabelLocal(option),
|
|
21
|
+
opacity: true,
|
|
22
|
+
onDeleted: () => handleDelete(option),
|
|
23
|
+
disabledDeleteButton: disabled,
|
|
24
|
+
ownerState: { ...ownerState }
|
|
25
|
+
},
|
|
26
|
+
`${option}-${index}`
|
|
27
|
+
)) }) });
|
|
50
28
|
}
|
|
51
29
|
export {
|
|
52
30
|
useStartAdornments as u
|
|
@@ -27,12 +27,9 @@ function useValuesAndHandlers(props) {
|
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
const newValue = value || (multiple ? [] : null);
|
|
30
|
-
if (deepEqual(selectedValue, newValue)) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
30
|
refValue.current = newValue;
|
|
34
31
|
setSelectedValue(newValue);
|
|
35
|
-
}, [multiple, value
|
|
32
|
+
}, [multiple, value]);
|
|
36
33
|
const isOptionEqualToValueLocal = useCallback(
|
|
37
34
|
(option, val) => {
|
|
38
35
|
if (val === null || val === void 0) {
|
|
@@ -125,15 +122,11 @@ function useValuesAndHandlers(props) {
|
|
|
125
122
|
useEffect(() => {
|
|
126
123
|
if (readOnly && value !== null && value !== void 0 && !multiple) {
|
|
127
124
|
const displayValue = getOptionLabelLocal(value);
|
|
128
|
-
|
|
129
|
-
setInputValue(displayValue);
|
|
130
|
-
}
|
|
125
|
+
setInputValue(displayValue);
|
|
131
126
|
} else if (readOnly && multiple) {
|
|
132
|
-
|
|
133
|
-
setInputValue("");
|
|
134
|
-
}
|
|
127
|
+
setInputValue("");
|
|
135
128
|
}
|
|
136
|
-
}, [readOnly, value, getOptionLabelLocal, multiple
|
|
129
|
+
}, [readOnly, value, getOptionLabelLocal, multiple]);
|
|
137
130
|
useEffect(() => {
|
|
138
131
|
if (open === false && value === null && inputValue !== "") {
|
|
139
132
|
setInputValue("");
|
|
@@ -13,6 +13,5 @@ export declare enum AutocompleteSlots {
|
|
|
13
13
|
image = "image",
|
|
14
14
|
renderInputText = "renderInputText",
|
|
15
15
|
containerMultipleValues = "containerMultipleValues",
|
|
16
|
-
containerWrapper = "containerWrapper"
|
|
17
|
-
wrapperStartAdornment = "wrapperStartAdornment"
|
|
16
|
+
containerWrapper = "containerWrapper"
|
|
18
17
|
}
|
|
@@ -14,7 +14,6 @@ var AutocompleteSlots = /* @__PURE__ */ ((AutocompleteSlots2) => {
|
|
|
14
14
|
AutocompleteSlots2["renderInputText"] = "renderInputText";
|
|
15
15
|
AutocompleteSlots2["containerMultipleValues"] = "containerMultipleValues";
|
|
16
16
|
AutocompleteSlots2["containerWrapper"] = "containerWrapper";
|
|
17
|
-
AutocompleteSlots2["wrapperStartAdornment"] = "wrapperStartAdornment";
|
|
18
17
|
return AutocompleteSlots2;
|
|
19
18
|
})(AutocompleteSlots || {});
|
|
20
19
|
export {
|
|
@@ -39,9 +39,6 @@ export declare const RenderInputTextStyled: import('@emotion/styled').StyledComp
|
|
|
39
39
|
export declare const AdormentsStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
40
40
|
ownerState?: (Partial<import('../types').AutocompleteOwnerState> & Record<string, unknown>) | undefined;
|
|
41
41
|
}, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
42
|
-
export declare const WrapperStartAdornmentStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
43
|
-
ownerState?: (Partial<import('../types').AutocompleteOwnerState> & Record<string, unknown>) | undefined;
|
|
44
|
-
}, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
45
42
|
export declare const ContainerMultipleValuesStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
46
43
|
ownerState?: (Partial<import('../types').AutocompleteOwnerState> & Record<string, unknown>) | undefined;
|
|
47
44
|
}, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
@@ -64,10 +64,6 @@ const AdormentsStyled = styled("div", {
|
|
|
64
64
|
name: AUTOCOMPLETE_KEY_COMPONENT,
|
|
65
65
|
slot: AutocompleteSlots.adorments
|
|
66
66
|
})(autocompleteSyles?.adorments);
|
|
67
|
-
const WrapperStartAdornmentStyled = styled("div", {
|
|
68
|
-
name: AUTOCOMPLETE_KEY_COMPONENT,
|
|
69
|
-
slot: AutocompleteSlots.wrapperStartAdornment
|
|
70
|
-
})(autocompleteSyles?.wrapperStartAdornment);
|
|
71
67
|
const ContainerMultipleValuesStyled = styled("div", {
|
|
72
68
|
name: AUTOCOMPLETE_KEY_COMPONENT,
|
|
73
69
|
slot: AutocompleteSlots.containerMultipleValues
|
|
@@ -83,7 +79,6 @@ export {
|
|
|
83
79
|
PopperComponentStyled as P,
|
|
84
80
|
RenderInputStyled as R,
|
|
85
81
|
SkeletonAutocompleteStyled as S,
|
|
86
|
-
WrapperStartAdornmentStyled as W,
|
|
87
82
|
AdormentsStyled as a,
|
|
88
83
|
ContainerMultipleValuesStyled as b,
|
|
89
84
|
ContainerWrapperStyled as c,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AutocompleteChangeReason, AutocompleteFreeSoloValueMapping, AutocompleteInputChangeReason, AutocompleteProps as MUIAutocompleteProps, Theme } from '@mui/material';
|
|
2
2
|
import { Sizes } from '@m4l/styles';
|
|
3
|
-
import { ChangeEvent
|
|
3
|
+
import { ChangeEvent } from 'react';
|
|
4
4
|
import { TextFieldProps } from '../TextField/types';
|
|
5
5
|
import { AUTOCOMPLETE_KEY_COMPONENT } from './constants';
|
|
6
6
|
import { AutocompleteSlots } from './slots';
|
|
@@ -75,10 +75,6 @@ export interface AutocompleteProps<T, Multiple extends boolean | undefined> exte
|
|
|
75
75
|
* "htmlFor" attribute for the autocomplete field.
|
|
76
76
|
*/
|
|
77
77
|
htmlFor?: string;
|
|
78
|
-
/**
|
|
79
|
-
* Icono o adorno que se muestra al inicio del autocomplete.
|
|
80
|
-
*/
|
|
81
|
-
startAdornment?: ReactElement;
|
|
82
78
|
}
|
|
83
79
|
/**
|
|
84
80
|
* Represents the owner state of the Autocomplete component for styling purposes.
|
|
@@ -88,7 +84,6 @@ export interface AutocompleteOwnerState extends Pick<BaseAutocompleteProps, 'siz
|
|
|
88
84
|
disabled?: boolean;
|
|
89
85
|
multiple?: boolean;
|
|
90
86
|
readOnly?: boolean;
|
|
91
|
-
startAdornment?: boolean;
|
|
92
87
|
}
|
|
93
88
|
/**
|
|
94
89
|
* Defines the types of Slots available for the Autocomplete.
|
|
@@ -8,7 +8,6 @@ const tooltipStyles = {
|
|
|
8
8
|
* Estilos del texto del componente Tooltip
|
|
9
9
|
*/
|
|
10
10
|
text: ({ theme, ownerState }) => ({
|
|
11
|
-
color: theme.vars.palette.text.contrastText,
|
|
12
11
|
...getTypographyStyles(
|
|
13
12
|
theme.generalSettings.isMobile,
|
|
14
13
|
ownerState?.size || "medium",
|
|
@@ -19,18 +18,14 @@ const tooltipStyles = {
|
|
|
19
18
|
* Estilos del componente Tooltip
|
|
20
19
|
*/
|
|
21
20
|
tooltip: ({ theme }) => ({
|
|
22
|
-
background: theme.vars.palette.background.
|
|
21
|
+
background: theme.vars.palette.background.default,
|
|
23
22
|
padding: theme.vars.size.baseSpacings.sp2,
|
|
24
23
|
borderRadius: theme.vars.size.borderRadius.r1,
|
|
25
24
|
boxShadow: theme.vars.customShadows.z3,
|
|
26
25
|
".MuiTooltip-arrow": {
|
|
27
26
|
"&::before": {
|
|
28
|
-
backgroundColor: theme.vars.palette.background.
|
|
29
|
-
borderRadius: theme.vars.size.borderRadius["
|
|
30
|
-
width: theme.vars.size.baseSpacings.sp3,
|
|
31
|
-
height: theme.vars.size.baseSpacings.sp3,
|
|
32
|
-
border: "unset",
|
|
33
|
-
margin: "unset"
|
|
27
|
+
backgroundColor: theme.vars.palette.background.default,
|
|
28
|
+
borderRadius: theme.vars.size.borderRadius["r0-5"]
|
|
34
29
|
}
|
|
35
30
|
}
|
|
36
31
|
})
|
|
@@ -3,7 +3,6 @@ import { Sizes, TypographyVariants } from '@m4l/styles';
|
|
|
3
3
|
import { TypographySlots } from './slots/typographyEnum';
|
|
4
4
|
import { TYPOGRAPHY_KEY_COMPONENT } from './constants';
|
|
5
5
|
import { M4LOverridesStyleRules } from '../../../@types/augmentations';
|
|
6
|
-
import { DeepKeyOf } from '../../../utils/types';
|
|
7
6
|
/**
|
|
8
7
|
* Define los colores de tipografía disponibles para el componente.
|
|
9
8
|
*/
|
|
@@ -24,7 +23,7 @@ export interface TypographyProps extends Omit<MUITypographyProps, 'color' | 'var
|
|
|
24
23
|
/**
|
|
25
24
|
* Opción de color usada para pintar el componente.
|
|
26
25
|
*/
|
|
27
|
-
color?:
|
|
26
|
+
color?: TypographyColors;
|
|
28
27
|
/**
|
|
29
28
|
* Opciones de tamaño del componente.
|
|
30
29
|
*/
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getPropertyByString } from "@m4l/core";
|
|
2
1
|
import { g as getSizeStyles } from "../../../utils/getSizeStyles/getSizeStyles.js";
|
|
3
2
|
import { g as getTypographyStyles } from "../../../utils/getTypographyStyles.js";
|
|
4
3
|
const typographyStyles = {
|
|
@@ -20,11 +19,17 @@ const typographyStyles = {
|
|
|
20
19
|
flexDirection: "column"
|
|
21
20
|
},
|
|
22
21
|
// Override de estilos generales de MUI 🚫
|
|
22
|
+
// color text.primary 🎨
|
|
23
|
+
...ownerState?.color === "text.primary" && {
|
|
24
|
+
color: theme.vars.palette.text.primary
|
|
25
|
+
},
|
|
26
|
+
// color text.secondary 🎨
|
|
27
|
+
...ownerState?.color === "text.secondary" && {
|
|
28
|
+
color: theme.vars.palette.text.secondary
|
|
29
|
+
},
|
|
23
30
|
// color text.disabled 🎨
|
|
24
|
-
...ownerState?.disabled || ownerState?.color === "text.disabled"
|
|
31
|
+
...(ownerState?.disabled || ownerState?.color === "text.disabled") && {
|
|
25
32
|
color: theme.vars.palette.text.disabled
|
|
26
|
-
} : {
|
|
27
|
-
color: getPropertyByString(theme.vars.palette, ownerState?.color || "text.primary", "text.primary")
|
|
28
33
|
},
|
|
29
34
|
...getTypographyStyles(
|
|
30
35
|
theme.generalSettings.isMobile,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useRef
|
|
2
|
+
import { createContext, useRef } from "react";
|
|
3
3
|
import { DEFAULT_SIZE } from "@m4l/styles";
|
|
4
4
|
import { c as createAppearanceComponentStore } from "./AppearanceComponentStore.js";
|
|
5
5
|
const AppearanceComponentContext = createContext(null);
|
|
@@ -12,11 +12,6 @@ function AppearanceComponentProvider(props) {
|
|
|
12
12
|
storeId
|
|
13
13
|
}, storeDevtoolsEnabled);
|
|
14
14
|
}
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
if (appearanceComponentStoreRef.current && defaultSize) {
|
|
17
|
-
appearanceComponentStoreRef.current.getState().actions.setDefaultSize(defaultSize);
|
|
18
|
-
}
|
|
19
|
-
}, [defaultSize]);
|
|
20
15
|
return /* @__PURE__ */ jsx(AppearanceComponentContext.Provider, { value: appearanceComponentStoreRef.current, children });
|
|
21
16
|
}
|
|
22
17
|
export {
|