@m4l/components 9.4.24 → 9.4.26-BE20260206-2
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/Stepper/Stepper.styles.js +22 -9
- package/components/Stepper/helpers/findAllVisibleStepsBefore/index.d.ts +19 -0
- package/components/Stepper/helpers/findAllVisibleStepsBefore/index.js +22 -0
- package/components/Stepper/helpers/findStepIndexByKey/index.d.ts +8 -0
- package/components/Stepper/helpers/findStepIndexByKey/index.js +6 -0
- package/components/Stepper/helpers/index.d.ts +2 -0
- package/components/Stepper/hooks/useInitialStepKey/index.d.ts +5 -0
- package/components/Stepper/hooks/useInitialStepKey/index.js +44 -0
- package/components/Stepper/slots/StepperEnum.d.ts +1 -0
- package/components/Stepper/slots/StepperEnum.js +1 -0
- package/components/Stepper/slots/StepperSlot.d.ts +3 -0
- package/components/Stepper/slots/StepperSlot.js +11 -6
- package/components/Stepper/store/StepperContext/index.js +3 -1
- package/components/Stepper/store/StepperStore/index.js +70 -0
- package/components/Stepper/store/types.d.ts +12 -2
- package/components/Stepper/subcomponents/ContentArea/index.js +2 -0
- package/components/Stepper/subcomponents/StepArea/index.js +2 -2
- package/components/Stepper/subcomponents/StepArea/subcomponents/Inidicator/index.js +1 -1
- package/components/Stepper/subcomponents/StepperContent/subcomponents/Step/index.js +1 -1
- package/components/Stepper/subcomponents/StepperFooter/index.js +1 -1
- package/components/Stepper/subcomponents/StepperFooter/subcomponents/StepperFooterLeftActions/index.js +1 -1
- package/components/Stepper/subcomponents/StepperFooter/subcomponents/StepperFooterRightActions/index.js +1 -1
- package/components/Stepper/types.d.ts +22 -0
- package/components/datagrids/Datagrid.styles.js +27 -0
- package/components/datagrids/components/DataGridMain/DataGridMain.js +4 -2
- package/components/datagrids/components/TreeDataGrid/TreeDataGrid.js +3 -1
- package/components/datagrids/slots/DataGridEnum.d.ts +2 -1
- package/components/datagrids/slots/DataGridEnum.js +1 -0
- package/components/datagrids/slots/DataGridSlot.d.ts +1 -0
- package/components/datagrids/slots/DataGridSlot.js +18 -13
- package/components/datagrids/types.d.ts +33 -0
- package/components/datagrids/views/TableView/TableView.js +22 -2
- package/components/datagrids/views/TableView/helpers/index.d.ts +1 -0
- package/components/datagrids/views/TableView/helpers/rowCellsBackground/index.d.ts +2 -0
- package/components/datagrids/views/TableView/helpers/rowCellsBackground/index.js +1 -0
- package/components/datagrids/views/TableView/helpers/rowCellsBackground/rowCellsBackground.d.ts +32 -0
- package/components/datagrids/views/TableView/helpers/rowCellsBackground/rowCellsBackground.js +58 -0
- package/components/datagrids/views/TableView/helpers/rowCellsBackground/types.d.ts +7 -0
- package/components/datagrids/views/TableView/subcomponents/DraggableHeaderRenderer/DraggableHeaderRenderer.js +1 -1
- package/components/datagrids/views/TableView/subcomponents/HeaderRenderClick/HeaderRenderClick.js +1 -1
- package/components/datagrids/views/TableView/subcomponents/RenderGroupCell/RenderGroupCell.js +1 -1
- package/components/datagrids/views/TableView/subcomponents/SkeletonFormatter/SkeletonFormatter.js +1 -1
- package/components/datagrids/views/adapters/CheckboxCellAdapter/CheckboxCellAdapter.js +1 -1
- package/components/hook-form/RHFAutocomplete/RHFAutocomplete.js +3 -39
- package/package.json +1 -1
|
@@ -111,35 +111,47 @@ const stepperStyles = {
|
|
|
111
111
|
* Estilos para el nombre del paso dentro del Stepper.
|
|
112
112
|
*/
|
|
113
113
|
stepName: ({ theme, ownerState }) => ({
|
|
114
|
-
...ownerState?.orientation === "horizontal" && {
|
|
115
|
-
|
|
114
|
+
...ownerState?.orientation === "horizontal" && !theme.generalSettings.isMobile && {
|
|
115
|
+
minHeight: theme.vars.size.desktop.medium.action,
|
|
116
|
+
maxWidth: "120px",
|
|
117
|
+
width: "100%"
|
|
116
118
|
},
|
|
117
119
|
...(ownerState?.orientation === "vertical" || theme.generalSettings.isMobile) && {
|
|
118
120
|
maxWidth: "120px",
|
|
119
121
|
width: "100%",
|
|
120
|
-
lineHeight: "1.2",
|
|
121
122
|
marginTop: theme.vars.size.baseSpacings.sp1
|
|
122
123
|
},
|
|
123
124
|
alignContent: "center",
|
|
124
125
|
cursor: "pointer",
|
|
125
|
-
overflow: "hidden",
|
|
126
126
|
...theme.generalSettings.isMobile ? {
|
|
127
127
|
display: "none"
|
|
128
128
|
} : {
|
|
129
|
-
display: ownerState?.visibleTitle ? "
|
|
129
|
+
display: ownerState?.visibleTitle ? "block" : "none"
|
|
130
130
|
},
|
|
131
|
-
WebkitBoxOrient: "vertical",
|
|
132
|
-
WebkitLineClamp: 2,
|
|
133
|
-
textOverflow: "ellipsis",
|
|
134
131
|
flex: 1,
|
|
135
132
|
minWidth: 0,
|
|
136
|
-
whiteSpace: "normal",
|
|
137
133
|
order: ownerState?.orientation === "vertical" || theme.generalSettings.isMobile ? 1 : 0,
|
|
138
134
|
"&.M4LTypography-root": {
|
|
139
135
|
color: ownerState?.originalStepIndex !== void 0 && typeof ownerState.originalStepIndex === "number" ? (ownerState.currentStep ?? 0) > ownerState.originalStepIndex ? theme.vars.palette.primary.semanticText : (ownerState.currentStep ?? 0) === ownerState.originalStepIndex ? theme.vars.palette.text.primary : theme.vars.palette.text.secondary : theme.vars.palette.text.secondary,
|
|
140
136
|
textAlign: ownerState?.orientation === "vertical" || theme.generalSettings.isMobile ? "center" : "right"
|
|
141
137
|
}
|
|
142
138
|
}),
|
|
139
|
+
/**
|
|
140
|
+
* Estilos para el texto del nombre del paso con truncado (line-clamp).
|
|
141
|
+
*/
|
|
142
|
+
stepNameText: ({ theme, ownerState }) => ({
|
|
143
|
+
display: "-webkit-box",
|
|
144
|
+
"-webkit-box-orient": "vertical",
|
|
145
|
+
"-webkit-line-clamp": "2",
|
|
146
|
+
overflow: "hidden",
|
|
147
|
+
textOverflow: "ellipsis",
|
|
148
|
+
wordBreak: "break-word",
|
|
149
|
+
whiteSpace: "normal",
|
|
150
|
+
width: "100%",
|
|
151
|
+
direction: "ltr",
|
|
152
|
+
lineHeight: 1.2,
|
|
153
|
+
textAlign: ownerState?.orientation === "vertical" || theme.generalSettings.isMobile ? "center" : "left"
|
|
154
|
+
}),
|
|
143
155
|
/**
|
|
144
156
|
* Estilos para el indicador numérico de cada paso del Stepper.
|
|
145
157
|
*/
|
|
@@ -228,6 +240,7 @@ const stepperStyles = {
|
|
|
228
240
|
display: "flex",
|
|
229
241
|
alignItems: "center",
|
|
230
242
|
justifyContent: "center",
|
|
243
|
+
flexShrink: 0,
|
|
231
244
|
background: theme.vars.palette.primary.enabledOpacity,
|
|
232
245
|
borderRadius: theme.vars.size.borderRadius["r1-5"],
|
|
233
246
|
...getSizeStyles(theme, ownerState?.size || "medium", "box", (size) => ({
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FormData, Step, StepWithIndex, VisibilityData } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Obtiene todos los steps visibles que están antes de un step específico.
|
|
4
|
+
*
|
|
5
|
+
* Esta función es utilizada por la feature `initialStepKey` para determinar
|
|
6
|
+
* qué steps deben ser validados antes de poder navegar al step inicial deseado.
|
|
7
|
+
* @example
|
|
8
|
+
* // Si tenemos steps: [A, B (oculto), C, D] y queremos iniciar en D (índice 3)
|
|
9
|
+
* // Esta función retornará: [{ step: A, originalIndex: 0 }, { step: C, originalIndex: 2 }]
|
|
10
|
+
* // El step B se omite porque está oculto por su visibilityCondition
|
|
11
|
+
* @param initialStepIndex - El índice del step donde se desea iniciar.
|
|
12
|
+
* Los steps en este índice y posteriores NO se incluyen en el resultado.
|
|
13
|
+
* @param steps - Array completo de steps configurados en el Stepper.
|
|
14
|
+
* @param formData - Valores actuales del formulario para evaluar las condiciones de visibilidad.
|
|
15
|
+
* @param visibilityData - Datos adicionales para evaluar visibilidad (ej: objectId, accountId).
|
|
16
|
+
* @returns Array de steps visibles con su índice original, ordenados de menor a mayor índice.
|
|
17
|
+
* Retorna array vacío si initialStepIndex es 0 o no hay steps visibles antes.
|
|
18
|
+
*/
|
|
19
|
+
export declare const findAllVisibleStepsBefore: (initialStepIndex: number, steps: Step[], formData?: FormData, visibilityData?: VisibilityData) => StepWithIndex[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { e as evaluateVisibilityStepCondition } from "../evaluateVisibilityStepCondition/index.js";
|
|
2
|
+
const findAllVisibleStepsBefore = (initialStepIndex, steps, formData, visibilityData) => {
|
|
3
|
+
const visibleStepsBefore = [];
|
|
4
|
+
for (let currentIndex = 0; currentIndex < initialStepIndex && currentIndex < steps.length; currentIndex++) {
|
|
5
|
+
const currentStep = steps[currentIndex];
|
|
6
|
+
const isStepVisible = evaluateVisibilityStepCondition(
|
|
7
|
+
currentStep,
|
|
8
|
+
formData || {},
|
|
9
|
+
visibilityData
|
|
10
|
+
);
|
|
11
|
+
if (isStepVisible) {
|
|
12
|
+
visibleStepsBefore.push({
|
|
13
|
+
step: currentStep,
|
|
14
|
+
originalIndex: currentIndex
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return visibleStepsBefore;
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
findAllVisibleStepsBefore as f
|
|
22
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Step } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* findStepIndexByKey - Encuentra el índice de un step por su key
|
|
4
|
+
* @param stepKey - La key del step a buscar
|
|
5
|
+
* @param steps - Array de steps
|
|
6
|
+
* @returns El índice del step, o -1 si no se encuentra
|
|
7
|
+
*/
|
|
8
|
+
export declare const findStepIndexByKey: (stepKey: string, steps: Step[]) => number;
|
|
@@ -6,3 +6,5 @@ export { isElementInViewport } from './isElementInViewport';
|
|
|
6
6
|
export { isLastVisibleValidStep } from './isLastVisibleValidStep';
|
|
7
7
|
export { parseWatchedValues } from './parseWatchedValues';
|
|
8
8
|
export { getInitialFieldValues } from './getInitialFieldValues';
|
|
9
|
+
export { findStepIndexByKey } from './findStepIndexByKey';
|
|
10
|
+
export { findAllVisibleStepsBefore } from './findAllVisibleStepsBefore';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useRef, useEffect } from "react";
|
|
2
|
+
import { useFormContext, useWatch } from "react-hook-form";
|
|
3
|
+
import { shallow } from "zustand/shallow";
|
|
4
|
+
import { u as useStepper } from "../useStepper/index.js";
|
|
5
|
+
function useInitialStepKey() {
|
|
6
|
+
const { trigger, getValues } = useFormContext();
|
|
7
|
+
const hasAttemptedRef = useRef(false);
|
|
8
|
+
const statusLoad = useWatch({ name: "statusLoad" });
|
|
9
|
+
const { initialStepKey, initialStepKeyApplied, applyInitialStepKey } = useStepper(
|
|
10
|
+
(state) => ({
|
|
11
|
+
initialStepKey: state.initialStepKey,
|
|
12
|
+
initialStepKeyApplied: state.initialStepKeyApplied,
|
|
13
|
+
applyInitialStepKey: state.actions.applyInitialStepKey
|
|
14
|
+
}),
|
|
15
|
+
shallow
|
|
16
|
+
);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (statusLoad !== "ready" || !initialStepKey || initialStepKeyApplied || hasAttemptedRef.current) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
hasAttemptedRef.current = true;
|
|
22
|
+
const executeInitialStepKey = async () => {
|
|
23
|
+
const validateFieldsFn = async (fields) => {
|
|
24
|
+
if (fields.length === 0) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return trigger(fields);
|
|
28
|
+
};
|
|
29
|
+
const formData = getValues();
|
|
30
|
+
await applyInitialStepKey(validateFieldsFn, formData);
|
|
31
|
+
};
|
|
32
|
+
executeInitialStepKey();
|
|
33
|
+
}, [
|
|
34
|
+
statusLoad,
|
|
35
|
+
initialStepKey,
|
|
36
|
+
initialStepKeyApplied,
|
|
37
|
+
applyInitialStepKey,
|
|
38
|
+
trigger,
|
|
39
|
+
getValues
|
|
40
|
+
]);
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
useInitialStepKey as u
|
|
44
|
+
};
|
|
@@ -7,6 +7,7 @@ var ContentSlots = /* @__PURE__ */ ((ContentSlots2) => {
|
|
|
7
7
|
ContentSlots2["stepArea"] = "stepArea";
|
|
8
8
|
ContentSlots2["step"] = "step";
|
|
9
9
|
ContentSlots2["stepName"] = "stepName";
|
|
10
|
+
ContentSlots2["stepNameText"] = "stepNameText";
|
|
10
11
|
ContentSlots2["indicator"] = "indicator";
|
|
11
12
|
ContentSlots2["textNumber"] = "textNumber";
|
|
12
13
|
return ContentSlots2;
|
|
@@ -22,6 +22,9 @@ export declare const StepStyled: import('@emotion/styled').StyledComponent<impor
|
|
|
22
22
|
export declare const StepNameStyled: import('@emotion/styled').StyledComponent<Pick<Omit<import('../../mui_extended/Typography/types').TypographyProps, "ref"> & import('react').RefAttributes<HTMLSpanElement>, "size" | "children" | "title" | "component" | "zIndex" | "id" | "disabled" | "paragraph" | "border" | "fontWeight" | "lineHeight" | "letterSpacing" | "fontSize" | "textTransform" | "fontFamily" | "typography" | "variant" | "color" | "dataTestid" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxShadow" | "boxSizing" | "columnGap" | "content" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "marginBlockEnd" | "marginBlockStart" | "marginBottom" | "marginInlineEnd" | "marginInlineStart" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBlockEnd" | "paddingBlockStart" | "paddingBottom" | "paddingInlineEnd" | "paddingInlineStart" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "top" | "translate" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "marginBlock" | "marginInline" | "overflow" | "padding" | "paddingBlock" | "paddingInline" | "className" | "style" | "classes" | "sx" | "p" | "slot" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoCapitalize" | "autoFocus" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "enterKeyHint" | "hidden" | "lang" | "nonce" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "exportparts" | "part" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "displayPrint" | "align" | "htmlFor" | "gutterBottom" | "noWrap" | "variantMapping" | "skeletonWidth" | "skeletonRows" | "ellipsis" | keyof import('react').RefAttributes<HTMLSpanElement>> & import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Record<string, unknown> & {
|
|
23
23
|
ownerState?: (Partial<import('../types').StepperOwnerState> & Record<string, unknown>) | undefined;
|
|
24
24
|
}, {}, {}>;
|
|
25
|
+
export declare const StepNameTextStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Record<string, unknown> & {
|
|
26
|
+
ownerState?: (Partial<import('../types').StepperOwnerState> & Record<string, unknown>) | undefined;
|
|
27
|
+
}, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
25
28
|
export declare const IndicatorStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Record<string, unknown> & {
|
|
26
29
|
ownerState?: (Partial<import('../types').StepperOwnerState> & Record<string, unknown>) | undefined;
|
|
27
30
|
}, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
@@ -32,6 +32,10 @@ const StepNameStyled = styled(Typography, {
|
|
|
32
32
|
name: STEPPER_PREFIX_NAME,
|
|
33
33
|
slot: ContentSlots.stepName
|
|
34
34
|
})(stepperStyles.stepName);
|
|
35
|
+
const StepNameTextStyled = styled("div", {
|
|
36
|
+
name: STEPPER_PREFIX_NAME,
|
|
37
|
+
slot: ContentSlots.stepNameText
|
|
38
|
+
})(stepperStyles.stepNameText);
|
|
35
39
|
const IndicatorStyled = styled("div", {
|
|
36
40
|
name: STEPPER_PREFIX_NAME,
|
|
37
41
|
slot: ContentSlots.indicator
|
|
@@ -98,10 +102,11 @@ export {
|
|
|
98
102
|
StepAreaStyled as e,
|
|
99
103
|
StepStyled as f,
|
|
100
104
|
StepNameStyled as g,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
StepNameTextStyled as h,
|
|
106
|
+
IndicatorStyled as i,
|
|
107
|
+
TextNumberStyled as j,
|
|
108
|
+
StepContentStyled as k,
|
|
109
|
+
StepperFooterSectionStyled as l,
|
|
110
|
+
StepperFooterLeftActionsStyled as m,
|
|
111
|
+
StepperFooterRightActionsStyled as n
|
|
107
112
|
};
|
|
@@ -12,6 +12,7 @@ const StepperProvider = (props) => {
|
|
|
12
12
|
indicatorType = "number",
|
|
13
13
|
orientation = "horizontal",
|
|
14
14
|
visibilityData,
|
|
15
|
+
initialStepKey,
|
|
15
16
|
children
|
|
16
17
|
} = props;
|
|
17
18
|
const stepperStoreRef = useRef();
|
|
@@ -25,7 +26,8 @@ const StepperProvider = (props) => {
|
|
|
25
26
|
ownerState: {},
|
|
26
27
|
indicatorType,
|
|
27
28
|
orientation,
|
|
28
|
-
visibilityData
|
|
29
|
+
visibilityData,
|
|
30
|
+
initialStepKey
|
|
29
31
|
},
|
|
30
32
|
storeDevtoolsEnabled
|
|
31
33
|
);
|
|
@@ -2,6 +2,9 @@ import { createStore } from "zustand";
|
|
|
2
2
|
import { devtools } from "zustand/middleware";
|
|
3
3
|
import { immer } from "zustand/middleware/immer";
|
|
4
4
|
import { a as STEPPER_STORE_ID } from "../../constants.js";
|
|
5
|
+
import { f as findStepIndexByKey } from "../../helpers/findStepIndexByKey/index.js";
|
|
6
|
+
import { e as evaluateVisibilityStepCondition } from "../../helpers/evaluateVisibilityStepCondition/index.js";
|
|
7
|
+
import { f as findAllVisibleStepsBefore } from "../../helpers/findAllVisibleStepsBefore/index.js";
|
|
5
8
|
import { f as findNextVisibleValidStep } from "../../helpers/findNextVisibleValidStep/index.js";
|
|
6
9
|
import { f as findPrevVisibleValidStep } from "../../helpers/findPrevVisibleValidStep/index.js";
|
|
7
10
|
const createDevtools = (immerMiddlewere, config) => {
|
|
@@ -16,6 +19,7 @@ const createStepperStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
16
19
|
currentStep: 0,
|
|
17
20
|
stepValidationStatus: {},
|
|
18
21
|
isValidating: false,
|
|
22
|
+
initialStepKeyApplied: false,
|
|
19
23
|
...initProps
|
|
20
24
|
};
|
|
21
25
|
return createStore(
|
|
@@ -128,6 +132,7 @@ const createStepperStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
128
132
|
set((state) => {
|
|
129
133
|
state.stepValidationStatus = {};
|
|
130
134
|
state.isValidating = false;
|
|
135
|
+
state.initialStepKeyApplied = false;
|
|
131
136
|
const firstVisibleStepIndex = findNextVisibleValidStep(
|
|
132
137
|
-1,
|
|
133
138
|
// Comenzar desde -1 para encontrar el primer step visible
|
|
@@ -137,6 +142,71 @@ const createStepperStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
137
142
|
);
|
|
138
143
|
state.currentStep = firstVisibleStepIndex < state.steps.length ? firstVisibleStepIndex : 0;
|
|
139
144
|
});
|
|
145
|
+
},
|
|
146
|
+
/**
|
|
147
|
+
* applyInitialStepKey - Valida los steps anteriores y navega al step indicado por initialStepKey.
|
|
148
|
+
* Si algún step anterior tiene errores, navega al primer step con errores.
|
|
149
|
+
*/
|
|
150
|
+
applyInitialStepKey: async (validateFieldsFn, formData) => {
|
|
151
|
+
const state = get();
|
|
152
|
+
const { initialStepKey, steps, visibilityData, initialStepKeyApplied } = state;
|
|
153
|
+
if (!initialStepKey || initialStepKey.trim() === "" || initialStepKeyApplied) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const initialStepIndex = findStepIndexByKey(initialStepKey, steps);
|
|
157
|
+
if (initialStepIndex === -1) {
|
|
158
|
+
const availableKeys = steps.map((s) => s.key).join(", ");
|
|
159
|
+
throw new Error(
|
|
160
|
+
`Stepper: initialStepKey "${initialStepKey}" no corresponde a ningún step. Keys disponibles: [${availableKeys}]`
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
const initialStep = steps[initialStepIndex];
|
|
164
|
+
if (!evaluateVisibilityStepCondition(initialStep, formData, visibilityData)) {
|
|
165
|
+
console.warn(
|
|
166
|
+
`Stepper: initialStepKey "${initialStepKey}" apunta a un step oculto. Iniciando en step 0.`
|
|
167
|
+
);
|
|
168
|
+
set((draft) => {
|
|
169
|
+
draft.initialStepKeyApplied = true;
|
|
170
|
+
});
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (initialStepIndex === 0) {
|
|
174
|
+
set((draft) => {
|
|
175
|
+
draft.initialStepKeyApplied = true;
|
|
176
|
+
});
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
const previousVisibleSteps = findAllVisibleStepsBefore(
|
|
180
|
+
initialStepIndex,
|
|
181
|
+
steps,
|
|
182
|
+
formData,
|
|
183
|
+
visibilityData
|
|
184
|
+
);
|
|
185
|
+
for (const { step, originalIndex } of previousVisibleSteps) {
|
|
186
|
+
const fieldsToValidate = step.validationFields || [];
|
|
187
|
+
if (fieldsToValidate.length === 0) {
|
|
188
|
+
set((draft) => {
|
|
189
|
+
draft.stepValidationStatus[originalIndex] = true;
|
|
190
|
+
});
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
const isValid = await validateFieldsFn(fieldsToValidate);
|
|
194
|
+
if (!isValid) {
|
|
195
|
+
set((draft) => {
|
|
196
|
+
draft.currentStep = originalIndex;
|
|
197
|
+
draft.stepValidationStatus[originalIndex] = false;
|
|
198
|
+
draft.initialStepKeyApplied = true;
|
|
199
|
+
});
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
set((draft) => {
|
|
203
|
+
draft.stepValidationStatus[originalIndex] = true;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
set((draft) => {
|
|
207
|
+
draft.currentStep = initialStepIndex;
|
|
208
|
+
draft.initialStepKeyApplied = true;
|
|
209
|
+
});
|
|
140
210
|
}
|
|
141
211
|
}
|
|
142
212
|
})),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { Step, StepperOwnerState, StepperProps } from '../types';
|
|
3
|
-
export interface StepperState extends Pick<StepperProps, 'storeId' | 'visibleTitle' | 'steps' | 'indicatorType' | 'orientation' | 'size' | 'visibilityData'> {
|
|
3
|
+
export interface StepperState extends Pick<StepperProps, 'storeId' | 'visibleTitle' | 'steps' | 'indicatorType' | 'orientation' | 'size' | 'visibilityData' | 'initialStepKey'> {
|
|
4
4
|
/**
|
|
5
5
|
* "ownerState" estado a nivel de clases del componente
|
|
6
6
|
*/
|
|
@@ -18,6 +18,10 @@ export interface StepperState extends Pick<StepperProps, 'storeId' | 'visibleTit
|
|
|
18
18
|
* "isValidating" indica si el stepper está en proceso de validación
|
|
19
19
|
*/
|
|
20
20
|
isValidating: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Indica si initialStepKey ya fue aplicado. Previene re-aplicación después de navegación.
|
|
23
|
+
*/
|
|
24
|
+
initialStepKeyApplied: boolean;
|
|
21
25
|
}
|
|
22
26
|
export interface StepperStateWithActions extends StepperState {
|
|
23
27
|
actions: {
|
|
@@ -55,9 +59,15 @@ export interface StepperStateWithActions extends StepperState {
|
|
|
55
59
|
* resetStepper - Resetea el Stepper a su estado inicial
|
|
56
60
|
*/
|
|
57
61
|
resetStepper: () => void;
|
|
62
|
+
/**
|
|
63
|
+
* Aplica initialStepKey validando los steps anteriores.
|
|
64
|
+
* @param validateFieldsFn - Función que valida campos específicos usando RHF trigger()
|
|
65
|
+
* @param formData - Valores actuales del formulario
|
|
66
|
+
*/
|
|
67
|
+
applyInitialStepKey: (validateFieldsFn: (fields: string[]) => Promise<boolean>, formData: Record<string, any>) => Promise<void>;
|
|
58
68
|
};
|
|
59
69
|
}
|
|
60
70
|
export interface StepperContextProps extends StepperProps {
|
|
61
71
|
children: ReactNode;
|
|
62
72
|
}
|
|
63
|
-
export type InitialStoreProps = Pick<StepperState, 'ownerState' | 'storeId' | 'steps' | 'visibleTitle' | 'indicatorType' | 'orientation' | 'visibilityData'>;
|
|
73
|
+
export type InitialStoreProps = Pick<StepperState, 'ownerState' | 'storeId' | 'steps' | 'visibleTitle' | 'indicatorType' | 'orientation' | 'visibilityData' | 'initialStepKey'>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { u as useStepper } from "../../hooks/useStepper/index.js";
|
|
3
|
+
import { u as useInitialStepKey } from "../../hooks/useInitialStepKey/index.js";
|
|
3
4
|
import { a as ContentAreaStyled, b as ContentAreaHeaderStyled, c as ContentAreaBodyStyled } from "../../slots/StepperSlot.js";
|
|
4
5
|
import { W as WrapperIcon } from "./subcomponents/WrapperIcon/index.js";
|
|
5
6
|
import { W as WrapperTitle } from "./subcomponents/WrapperTitle/index.js";
|
|
@@ -8,6 +9,7 @@ function ContentArea(props) {
|
|
|
8
9
|
const { orientation } = useStepper((state) => ({
|
|
9
10
|
orientation: state.orientation
|
|
10
11
|
}));
|
|
12
|
+
useInitialStepKey();
|
|
11
13
|
const ownerState = {
|
|
12
14
|
orientation
|
|
13
15
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { e as StepAreaStyled, f as StepStyled, g as StepNameStyled } from "../../slots/StepperSlot.js";
|
|
2
|
+
import { e as StepAreaStyled, f as StepStyled, g as StepNameStyled, h as StepNameTextStyled } from "../../slots/StepperSlot.js";
|
|
3
3
|
import { I as Indicator } from "./subcomponents/Inidicator/index.js";
|
|
4
4
|
import { u as useStepArea } from "./hooks/useStepArea.js";
|
|
5
5
|
import { u as useVisibileSteps } from "./hooks/useVisibileSteps.js";
|
|
@@ -39,7 +39,7 @@ function StepArea() {
|
|
|
39
39
|
originalStepIndex: originalIndex,
|
|
40
40
|
isStepVisible
|
|
41
41
|
},
|
|
42
|
-
children: step.title
|
|
42
|
+
children: /* @__PURE__ */ jsx(StepNameTextStyled, { ownerState: { orientation }, children: step.title })
|
|
43
43
|
}
|
|
44
44
|
),
|
|
45
45
|
/* @__PURE__ */ jsx(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { i as IndicatorStyled, j as TextNumberStyled } from "../../../../slots/StepperSlot.js";
|
|
4
4
|
import { u as useStepper } from "../../../../hooks/useStepper/index.js";
|
|
5
5
|
import { p as pathIcons } from "../../../../icons.js";
|
|
6
6
|
import { useIsMobile } from "@m4l/graphics";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { k as StepContentStyled } from "../../../../slots/StepperSlot.js";
|
|
3
3
|
import { u as useIsStepVisible } from "./hooks/useIsStepVisible.js";
|
|
4
4
|
function Step(props) {
|
|
5
5
|
const { stepKey, children } = props;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo, Children, isValidElement } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { l as StepperFooterSectionStyled } from "../../slots/StepperSlot.js";
|
|
4
4
|
import { S as StepperFooterLeftActions } from "./subcomponents/StepperFooterLeftActions/index.js";
|
|
5
5
|
import { S as StepperFooterRightActions } from "./subcomponents/StepperFooterRightActions/index.js";
|
|
6
6
|
function StepperFooter(props) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { m as StepperFooterLeftActionsStyled } from "../../../../slots/StepperSlot.js";
|
|
3
3
|
function StepperFooterLeftActions(props) {
|
|
4
4
|
const { children } = props;
|
|
5
5
|
return /* @__PURE__ */ jsx(StepperFooterLeftActionsStyled, { children });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React, { useState, useEffect, useMemo } from "react";
|
|
3
3
|
import { u as useIsLastVisibleValidStep } from "../../../../hooks/useIsLastVisibleValidStep/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { n as StepperFooterRightActionsStyled } from "../../../../slots/StepperSlot.js";
|
|
5
5
|
import { S as StepperSubmitButton } from "../../../StepperButtons/StepperSubmitButton/index.js";
|
|
6
6
|
import { S as StepperNextButton } from "../../../StepperButtons/StepperNextButton/index.js";
|
|
7
7
|
function StepperFooterRightActions(props) {
|
|
@@ -83,6 +83,13 @@ export interface StepperProps {
|
|
|
83
83
|
* Clase personalizada para el Stepper.
|
|
84
84
|
*/
|
|
85
85
|
className?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Key del step en el que se desea iniciar el Stepper.
|
|
88
|
+
* Si se proporciona, valida los steps anteriores antes de navegar al step indicado.
|
|
89
|
+
* Si algún step anterior tiene errores, inicia en el primer step con errores.
|
|
90
|
+
* Lanza Error si la key no corresponde a ningún step.
|
|
91
|
+
*/
|
|
92
|
+
initialStepKey?: string;
|
|
86
93
|
}
|
|
87
94
|
/**
|
|
88
95
|
* Props del StepperContent
|
|
@@ -172,5 +179,20 @@ export interface StepperOwnerState extends Pick<StepperProps, 'visibleTitle'>, R
|
|
|
172
179
|
stepValidationStatus?: Record<number, boolean>;
|
|
173
180
|
isStepVisible?: boolean;
|
|
174
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Representa un step junto con su posición original en el array de steps.
|
|
184
|
+
* Se usa para mantener la referencia al índice original después de filtrar steps ocultos.
|
|
185
|
+
*/
|
|
186
|
+
export interface StepWithIndex {
|
|
187
|
+
/**
|
|
188
|
+
* El objeto Step con toda su configuración (key, title, validationFields, etc.)
|
|
189
|
+
*/
|
|
190
|
+
step: Step;
|
|
191
|
+
/**
|
|
192
|
+
* El índice del step en el array original de steps.
|
|
193
|
+
* Es necesario para actualizar correctamente el stepValidationStatus del store.
|
|
194
|
+
*/
|
|
195
|
+
originalIndex: number;
|
|
196
|
+
}
|
|
175
197
|
export type StepperSlotsType = StepperSlots | ContentSlots | ContentAreaSlots | StepperFooterSlots;
|
|
176
198
|
export type StepperStyles = M4LOverridesStyleRules<StepperSlotsType, typeof STEPPER_PREFIX_NAME, Theme>;
|
|
@@ -1165,6 +1165,33 @@ const dataGridStyles = {
|
|
|
1165
1165
|
textOverflow: "ellipsis",
|
|
1166
1166
|
wordBreak: "break-word",
|
|
1167
1167
|
whiteSpace: "normal"
|
|
1168
|
+
}),
|
|
1169
|
+
/**
|
|
1170
|
+
* Wrapper para celdas con color de fondo personalizado.
|
|
1171
|
+
*
|
|
1172
|
+
* Este estilo aplica backgroundColor y ocupa toda la celda,
|
|
1173
|
+
* manteniendo el comportamiento de truncado con ellipsis.
|
|
1174
|
+
* El color se recibe a través de ownerState.cellBackgroundColor
|
|
1175
|
+
*/
|
|
1176
|
+
cellBackgroundWrapper: ({ ownerState }) => ({
|
|
1177
|
+
// Ocupar toda la celda con margin negativo
|
|
1178
|
+
margin: "-8px",
|
|
1179
|
+
padding: "8px",
|
|
1180
|
+
width: "calc(100% + 16px)",
|
|
1181
|
+
height: "calc(100% + 16px)",
|
|
1182
|
+
boxSizing: "border-box",
|
|
1183
|
+
// Mantener el comportamiento de truncado igual que las celdas
|
|
1184
|
+
display: "-webkit-box",
|
|
1185
|
+
WebkitBoxOrient: "vertical",
|
|
1186
|
+
WebkitLineClamp: ownerState?.currentRowHeightVariant === "compact" ? 1 : ownerState?.currentRowHeightVariant === "confortable" ? 3 : 2,
|
|
1187
|
+
overflow: "hidden",
|
|
1188
|
+
textOverflow: "ellipsis",
|
|
1189
|
+
wordBreak: "break-word",
|
|
1190
|
+
whiteSpace: "normal",
|
|
1191
|
+
alignContent: "center",
|
|
1192
|
+
...ownerState?.cellBackgroundColor && {
|
|
1193
|
+
backgroundColor: ownerState.cellBackgroundColor
|
|
1194
|
+
}
|
|
1168
1195
|
})
|
|
1169
1196
|
};
|
|
1170
1197
|
export {
|
|
@@ -14,7 +14,8 @@ function DataGrid(props) {
|
|
|
14
14
|
cardsViewConfig,
|
|
15
15
|
focusOnRowKey,
|
|
16
16
|
checkedRows,
|
|
17
|
-
onCheckedRowsChange
|
|
17
|
+
onCheckedRowsChange,
|
|
18
|
+
rowCellsBackground
|
|
18
19
|
} = props;
|
|
19
20
|
return /* @__PURE__ */ jsx(BaseDataGrid, { ...props, children: /* @__PURE__ */ jsx(
|
|
20
21
|
RenderContent,
|
|
@@ -30,7 +31,8 @@ function DataGrid(props) {
|
|
|
30
31
|
cardsViewConfig,
|
|
31
32
|
focusOnRowKey,
|
|
32
33
|
checkedRows,
|
|
33
|
-
onCheckedRowsChange
|
|
34
|
+
onCheckedRowsChange,
|
|
35
|
+
rowCellsBackground
|
|
34
36
|
}
|
|
35
37
|
) });
|
|
36
38
|
}
|
|
@@ -17,7 +17,8 @@ function TreeDataGrid(props) {
|
|
|
17
17
|
onCheckedRowsChange,
|
|
18
18
|
rowGrouper,
|
|
19
19
|
expandedGroupIds: expandedGroupIdsProp,
|
|
20
|
-
onExpandedGroupIdsChange: onExpandedGroupIdsChangeProp
|
|
20
|
+
onExpandedGroupIdsChange: onExpandedGroupIdsChangeProp,
|
|
21
|
+
rowCellsBackground
|
|
21
22
|
} = props;
|
|
22
23
|
const [internalExpandedGroupIds, setInternalExpandedGroupIds] = useState(() => new Set(expandedGroupIdsProp ?? []));
|
|
23
24
|
const isControlled = expandedGroupIdsProp !== void 0 && onExpandedGroupIdsChangeProp !== void 0;
|
|
@@ -37,6 +38,7 @@ function TreeDataGrid(props) {
|
|
|
37
38
|
focusOnRowKey,
|
|
38
39
|
checkedRows,
|
|
39
40
|
onCheckedRowsChange,
|
|
41
|
+
rowCellsBackground,
|
|
40
42
|
treeProps: {
|
|
41
43
|
rowGrouper,
|
|
42
44
|
expandedGroupIds,
|
|
@@ -55,7 +55,8 @@ export declare enum TableSlots {
|
|
|
55
55
|
editLabel = "editLabel",
|
|
56
56
|
iconButtonEdit = "iconButtonEdit",
|
|
57
57
|
defaultRenderGroupCellRoot = "defaultRenderGroupCellRoot",
|
|
58
|
-
defaultRenderGroupCellText = "defaultRenderGroupCellText"
|
|
58
|
+
defaultRenderGroupCellText = "defaultRenderGroupCellText",
|
|
59
|
+
cellBackgroundWrapper = "cellBackgroundWrapper"
|
|
59
60
|
}
|
|
60
61
|
export declare enum TextEditorSlots {
|
|
61
62
|
inputTexEditor = "inputTexEditor"
|
|
@@ -59,6 +59,7 @@ var TableSlots = /* @__PURE__ */ ((TableSlots2) => {
|
|
|
59
59
|
TableSlots2["iconButtonEdit"] = "iconButtonEdit";
|
|
60
60
|
TableSlots2["defaultRenderGroupCellRoot"] = "defaultRenderGroupCellRoot";
|
|
61
61
|
TableSlots2["defaultRenderGroupCellText"] = "defaultRenderGroupCellText";
|
|
62
|
+
TableSlots2["cellBackgroundWrapper"] = "cellBackgroundWrapper";
|
|
62
63
|
return TableSlots2;
|
|
63
64
|
})(TableSlots || {});
|
|
64
65
|
var TextEditorSlots = /* @__PURE__ */ ((TextEditorSlots2) => {
|
|
@@ -99,3 +99,4 @@ export declare const ControlNavigateStyled: import('@emotion/styled').StyledComp
|
|
|
99
99
|
export declare const ColumnIconFormatterStyled: import('@emotion/styled').StyledComponent<any, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
100
100
|
export declare const DefaultRenderGroupCellRootStyled: import('@emotion/styled').StyledComponent<any, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, keyof import('react').ClassAttributes<HTMLSpanElement> | keyof import('react').HTMLAttributes<HTMLSpanElement>>, {}>;
|
|
101
101
|
export declare const DefaultRenderGroupCellTextStyled: import('@emotion/styled').StyledComponent<any, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, keyof import('react').ClassAttributes<HTMLSpanElement> | keyof import('react').HTMLAttributes<HTMLSpanElement>>, {}>;
|
|
102
|
+
export declare const CellBackgroundWrapperStyled: import('@emotion/styled').StyledComponent<any, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, keyof import('react').ClassAttributes<HTMLSpanElement> | keyof import('react').HTMLAttributes<HTMLSpanElement>>, {}>;
|
|
@@ -239,31 +239,36 @@ const DefaultRenderGroupCellTextStyled = styled("span", {
|
|
|
239
239
|
name: DATAGRID_PREFIX_NAME,
|
|
240
240
|
slot: TableSlots.defaultRenderGroupCellText
|
|
241
241
|
})(dataGridStyles.defaultRenderGroupCellText);
|
|
242
|
+
const CellBackgroundWrapperStyled = styled("span", {
|
|
243
|
+
name: DATAGRID_PREFIX_NAME,
|
|
244
|
+
slot: TableSlots.cellBackgroundWrapper
|
|
245
|
+
})(dataGridStyles.cellBackgroundWrapper);
|
|
242
246
|
export {
|
|
243
247
|
ActionsRootStyled as A,
|
|
244
248
|
TableContainerStyled as B,
|
|
245
249
|
CustomHeaderStyled as C,
|
|
246
250
|
DataGridRootStyled as D,
|
|
247
251
|
EditorCellWrapperStyled as E,
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
252
|
+
CellBackgroundWrapperStyled as F,
|
|
253
|
+
NameColumnStyled as G,
|
|
254
|
+
IconColumnStyled as H,
|
|
251
255
|
InputTextEditorStyled as I,
|
|
252
|
-
|
|
253
|
-
|
|
256
|
+
DraggableHeaderRootStyled as J,
|
|
257
|
+
ButtonHeaderActionsStyled as K,
|
|
254
258
|
LabelHeaderColumnStyled as L,
|
|
255
|
-
|
|
259
|
+
DraggableWrapperInputBaseStyled as M,
|
|
256
260
|
NameColumnIconStyled as N,
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
261
|
+
IconSearchStyled as O,
|
|
262
|
+
HeaderInputBaseStyled as P,
|
|
263
|
+
MenuListStyled as Q,
|
|
260
264
|
RowsCountRootStyled as R,
|
|
261
|
-
|
|
265
|
+
HeaderRenderClickStyled as S,
|
|
262
266
|
TextToggleCardButtonStyled as T,
|
|
263
|
-
|
|
267
|
+
DefaultRenderGroupCellRootStyled as U,
|
|
264
268
|
ValueColumnStyled as V,
|
|
265
|
-
|
|
266
|
-
|
|
269
|
+
DefaultRenderGroupCellTextStyled as W,
|
|
270
|
+
WrapperSkeletonStyled as X,
|
|
271
|
+
CheckboxCellWrapperStyled as Y,
|
|
267
272
|
ControlNavigateStyled as a,
|
|
268
273
|
RowsCountLabelStyled as b,
|
|
269
274
|
RowsCountValueStyled as c,
|
|
@@ -54,6 +54,33 @@ declare module 'react-data-grid' {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
export declare type RowKey = string | number;
|
|
57
|
+
/**
|
|
58
|
+
* Define una celda específica que tendrá un color de fondo personalizado.
|
|
59
|
+
* rowKey - Identificador único de la fila (el mismo que usa rowKeyGetter)
|
|
60
|
+
* columnKey - Identificador de la columna (el key de la columna)
|
|
61
|
+
* color - Color de fondo a aplicar (puede ser hex como '#FF0000', rgb, etc.)
|
|
62
|
+
*/
|
|
63
|
+
export interface RowCellBackground<TKey extends RowKey = RowKey> {
|
|
64
|
+
rowKey: TKey;
|
|
65
|
+
columnKey: string;
|
|
66
|
+
color: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Función que retorna el color de fondo para una celda específica.
|
|
70
|
+
* Esta variante es más óptima para muchas filas porque solo se llama
|
|
71
|
+
* para las celdas visibles durante la virtualización.
|
|
72
|
+
* @param rowKey - Identificador único de la fila
|
|
73
|
+
* @param columnKey - Identificador de la columna
|
|
74
|
+
* @returns El color de fondo (hex, rgb, etc.) o undefined/null para transparente
|
|
75
|
+
*/
|
|
76
|
+
export type RowCellsBackgroundGetter<TKey extends RowKey = RowKey> = (rowKey: TKey, columnKey: string) => string | undefined | null;
|
|
77
|
+
/**
|
|
78
|
+
* Tipo union que permite array o función para rowCellsBackground.
|
|
79
|
+
*
|
|
80
|
+
* - Array: Más simple de usar, pero procesa todas las celdas al inicio
|
|
81
|
+
* - Función: Más óptima para muchas filas, solo se llama para celdas visibles
|
|
82
|
+
*/
|
|
83
|
+
export type RowCellsBackgroundProp<TKey extends RowKey = RowKey> = RowCellBackground<TKey>[] | RowCellsBackgroundGetter<TKey>;
|
|
57
84
|
export declare interface WithActionsProps {
|
|
58
85
|
withActions?: boolean;
|
|
59
86
|
}
|
|
@@ -228,6 +255,12 @@ export interface GridProps<TRow, TSummaryRow, TKey extends RowKey = RowKey> exte
|
|
|
228
255
|
* Útil cuando se agrega un nuevo elemento y se quiere enfocar en él.
|
|
229
256
|
*/
|
|
230
257
|
focusOnRowKey?: TKey;
|
|
258
|
+
/**
|
|
259
|
+
* Colores de fondo para celdas específicas.
|
|
260
|
+
* - Array: `[{ rowKey, columnKey, color }]`
|
|
261
|
+
* - Función: `(rowKey, columnKey) => color | undefined` (más óptima para muchas filas)
|
|
262
|
+
*/
|
|
263
|
+
rowCellsBackground?: RowCellsBackgroundProp<TKey>;
|
|
231
264
|
}
|
|
232
265
|
export declare const DATAGRID_TEST_ID = "m4ldatagrid";
|
|
233
266
|
export declare const PREFIX_TEST_ATTRIBUTE = "data-testid";
|
|
@@ -7,6 +7,7 @@ import { B as TableContainerStyled, y as TableWrapperDataGridStyled } from "../.
|
|
|
7
7
|
import { u as useSortColumnsRows } from "./hooks/useSortColumnsRows/useSortColumnsRows.js";
|
|
8
8
|
import { g as getGroupBy } from "./helpers/getGroupBy/getGroupBy.js";
|
|
9
9
|
import { d as defaultRowGrouper } from "./helpers/defaultRowGrouper/defaultRowGrouper.js";
|
|
10
|
+
import { c as createRowCellsBackgroundMap, p as processColumnsWithRowCellsBackground } from "./helpers/rowCellsBackground/rowCellsBackground.js";
|
|
10
11
|
import { u as useHeaderMenuActions } from "./hooks/useHeaderMenuActions/useHeaderMenuActions.js";
|
|
11
12
|
import { f as filterHeight } from "./subcomponents/SelectColumn/SelectColumn.js";
|
|
12
13
|
import { H as HeaderRenderClick } from "./subcomponents/HeaderRenderClick/HeaderRenderClick.js";
|
|
@@ -24,6 +25,7 @@ function TableView(props) {
|
|
|
24
25
|
onSelectedRowsChange,
|
|
25
26
|
defaultColumnOptions: defaultColumnOptionsProp,
|
|
26
27
|
focusOnRowKey,
|
|
28
|
+
rowCellsBackground,
|
|
27
29
|
treeProps,
|
|
28
30
|
...restProps
|
|
29
31
|
} = props;
|
|
@@ -76,6 +78,24 @@ function TableView(props) {
|
|
|
76
78
|
return getGroupBy(columnsConfig);
|
|
77
79
|
}, [columnsConfig, treeProps]);
|
|
78
80
|
const rowGrouper = treeProps?.rowGrouper ?? defaultRowGrouper;
|
|
81
|
+
const colorGetter = useMemo(() => {
|
|
82
|
+
if (!rowCellsBackground) {
|
|
83
|
+
return void 0;
|
|
84
|
+
}
|
|
85
|
+
if (typeof rowCellsBackground === "function") {
|
|
86
|
+
return rowCellsBackground;
|
|
87
|
+
}
|
|
88
|
+
return createRowCellsBackgroundMap(rowCellsBackground);
|
|
89
|
+
}, [rowCellsBackground]);
|
|
90
|
+
const columnsWithBackground = useMemo(
|
|
91
|
+
() => processColumnsWithRowCellsBackground(
|
|
92
|
+
finalColumns,
|
|
93
|
+
colorGetter,
|
|
94
|
+
rowKeyGetter,
|
|
95
|
+
currentRowHeightVariant
|
|
96
|
+
),
|
|
97
|
+
[finalColumns, colorGetter, rowKeyGetter, currentRowHeightVariant]
|
|
98
|
+
);
|
|
79
99
|
const ref_data_grid = useRef(null);
|
|
80
100
|
const [popoverState, setPopoverState] = useState({
|
|
81
101
|
anchorEl: null,
|
|
@@ -179,7 +199,7 @@ function TableView(props) {
|
|
|
179
199
|
className: "rdg-light",
|
|
180
200
|
ref: ref_data_grid,
|
|
181
201
|
headerRowHeight: activeFilters ? currentRowHeaderHeight + filterHeight : currentRowHeaderHeight,
|
|
182
|
-
columns:
|
|
202
|
+
columns: columnsWithBackground,
|
|
183
203
|
sortColumns,
|
|
184
204
|
onSortColumnsChange: handleSortColumnsChange,
|
|
185
205
|
onColumnResize,
|
|
@@ -207,7 +227,7 @@ function TableView(props) {
|
|
|
207
227
|
className: "rdg-light",
|
|
208
228
|
ref: ref_data_grid,
|
|
209
229
|
headerRowHeight: activeFilters ? currentRowHeaderHeight + filterHeight : currentRowHeaderHeight,
|
|
210
|
-
columns:
|
|
230
|
+
columns: columnsWithBackground,
|
|
211
231
|
sortColumns,
|
|
212
232
|
onSortColumnsChange: handleSortColumnsChange,
|
|
213
233
|
onColumnResize,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { getDragHeaderRenderer } from './getDragHeaderRenderer';
|
|
2
2
|
export { getGroupBy } from './getGroupBy';
|
|
3
3
|
export { defaultRowGrouper } from './defaultRowGrouper';
|
|
4
|
+
export { createRowCellsBackgroundMap, processColumnsWithRowCellsBackground, } from './rowCellsBackground';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/components/datagrids/views/TableView/helpers/rowCellsBackground/rowCellsBackground.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Column } from 'react-data-grid';
|
|
2
|
+
import { RowKey, RowCellBackground, RowHeightVariants } from '../../../../types';
|
|
3
|
+
import { CellColorGetter } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Convierte el array de rowCellsBackground en un Map para buscar el color
|
|
6
|
+
* de una celda usando la combinación de rowKey y columnKey.
|
|
7
|
+
*
|
|
8
|
+
* El Map usa como llave la combinación "rowKey|columnKey" (separados por |)
|
|
9
|
+
* y como valor el color.
|
|
10
|
+
*
|
|
11
|
+
* Ejemplo:
|
|
12
|
+
* - Entrada: [{ rowKey: 'user_1', columnKey: 'status', color: '#FF0000' }]
|
|
13
|
+
* - Map resultante: { 'user_1|status' => '#FF0000' }
|
|
14
|
+
* @param rowCellsBackground - Array de celdas con sus colores (puede ser undefined)
|
|
15
|
+
* @returns Map con la llave "rowKey|columnKey" y el color como valor
|
|
16
|
+
*/
|
|
17
|
+
export declare const createRowCellsBackgroundMap: <TKey extends RowKey>(rowCellsBackground: RowCellBackground<TKey>[] | undefined) => Map<string, string>;
|
|
18
|
+
/**
|
|
19
|
+
* Procesa las columnas para agregar el wrapper de color donde corresponda.
|
|
20
|
+
*
|
|
21
|
+
* Para cada columna, modifica el renderCell para:
|
|
22
|
+
* 1. Obtener el rowKey de la fila actual
|
|
23
|
+
* 2. Buscar si existe un color para esa combinación rowKey + columnKey
|
|
24
|
+
* 3. Si existe color, envolver el contenido con CellBackgroundWrapperStyled
|
|
25
|
+
* 4. Si no existe color, mostrar el contenido normal sin cambios
|
|
26
|
+
* @param columns - Las columnas originales del DataGrid
|
|
27
|
+
* @param colorGetter - Map con los colores o función que retorna el color
|
|
28
|
+
* @param rowKeyGetter - Función que obtiene el key de una fila
|
|
29
|
+
* @param currentRowHeightVariant - Variante de altura de fila para el truncado
|
|
30
|
+
* @returns Las columnas modificadas con el renderCell actualizado
|
|
31
|
+
*/
|
|
32
|
+
export declare const processColumnsWithRowCellsBackground: <TRow, TSummaryRow, TKey extends RowKey>(columns: readonly Column<TRow, TSummaryRow>[], colorGetter: CellColorGetter<TKey> | undefined, rowKeyGetter: (row: TRow) => TKey, currentRowHeightVariant?: RowHeightVariants) => Column<TRow, TSummaryRow>[];
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { F as CellBackgroundWrapperStyled } from "../../../../slots/DataGridSlot.js";
|
|
3
|
+
const getCellColor = (colorGetter, rowKey, columnKey) => {
|
|
4
|
+
if (colorGetter instanceof Map) {
|
|
5
|
+
return colorGetter.get(`${rowKey}|${columnKey}`);
|
|
6
|
+
}
|
|
7
|
+
return colorGetter(rowKey, columnKey);
|
|
8
|
+
};
|
|
9
|
+
const createRowCellsBackgroundMap = (rowCellsBackground) => {
|
|
10
|
+
const map = /* @__PURE__ */ new Map();
|
|
11
|
+
if (!rowCellsBackground) {
|
|
12
|
+
return map;
|
|
13
|
+
}
|
|
14
|
+
rowCellsBackground.forEach(({ rowKey, columnKey, color }) => {
|
|
15
|
+
map.set(`${rowKey}|${columnKey}`, color);
|
|
16
|
+
});
|
|
17
|
+
return map;
|
|
18
|
+
};
|
|
19
|
+
const processColumnsWithRowCellsBackground = (columns, colorGetter, rowKeyGetter, currentRowHeightVariant) => {
|
|
20
|
+
if (!colorGetter) {
|
|
21
|
+
return columns;
|
|
22
|
+
}
|
|
23
|
+
if (colorGetter instanceof Map && colorGetter.size === 0) {
|
|
24
|
+
return columns;
|
|
25
|
+
}
|
|
26
|
+
return columns.map((column) => {
|
|
27
|
+
const originalRenderCell = column.renderCell;
|
|
28
|
+
return {
|
|
29
|
+
...column,
|
|
30
|
+
// Mantener todas las propiedades originales de la columna
|
|
31
|
+
/**
|
|
32
|
+
* Reemplazar renderCell con nuestra versión que agrega el color
|
|
33
|
+
*/
|
|
34
|
+
renderCell: (props) => {
|
|
35
|
+
const rowKey = rowKeyGetter(props.row);
|
|
36
|
+
const cellColor = getCellColor(colorGetter, rowKey, column.key);
|
|
37
|
+
const originalContent = originalRenderCell ? originalRenderCell(props) : props.row[column.key];
|
|
38
|
+
if (cellColor) {
|
|
39
|
+
return /* @__PURE__ */ jsx(
|
|
40
|
+
CellBackgroundWrapperStyled,
|
|
41
|
+
{
|
|
42
|
+
ownerState: {
|
|
43
|
+
cellBackgroundColor: cellColor,
|
|
44
|
+
currentRowHeightVariant
|
|
45
|
+
},
|
|
46
|
+
children: originalContent
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return originalContent;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
export {
|
|
56
|
+
createRowCellsBackgroundMap as c,
|
|
57
|
+
processColumnsWithRowCellsBackground as p
|
|
58
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RowKey, RowCellsBackgroundGetter } from '../../../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Tipo para el getter de color - puede ser Map (desde array) o función directa.
|
|
4
|
+
* - Map: Resultado de convertir un array de RowCellBackground
|
|
5
|
+
* - Función: La función directa que retorna el color para cada celda
|
|
6
|
+
*/
|
|
7
|
+
export type CellColorGetter<TKey extends RowKey> = Map<string, string> | RowCellsBackgroundGetter<TKey>;
|
|
@@ -3,7 +3,7 @@ import { useState, useEffect } from "react";
|
|
|
3
3
|
import { useModuleDictionary, useEnvironment } from "@m4l/core";
|
|
4
4
|
import { useDrag, useDrop } from "react-dnd";
|
|
5
5
|
import { renderHeaderCell } from "react-data-grid";
|
|
6
|
-
import { N as NameColumnIconStyled,
|
|
6
|
+
import { N as NameColumnIconStyled, G as NameColumnStyled, H as IconColumnStyled, J as DraggableHeaderRootStyled, K as ButtonHeaderActionsStyled, M as DraggableWrapperInputBaseStyled, O as IconSearchStyled, P as HeaderInputBaseStyled } from "../../../../slots/DataGridSlot.js";
|
|
7
7
|
import { p as pathIcons } from "../../../../icons.js";
|
|
8
8
|
import { I as Icon } from "../../../../../Icon/Icon.js";
|
|
9
9
|
import { u as useFocusRef } from "../../hooks/useFocusRef/useFocusRef.js";
|
package/components/datagrids/views/TableView/subcomponents/HeaderRenderClick/HeaderRenderClick.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState, useMemo, useEffect, useCallback } from "react";
|
|
3
3
|
import { useModuleDictionary } from "@m4l/core";
|
|
4
4
|
import { M as MenuItem } from "../../../../../mui_extended/MenuItem/MenuItem.js";
|
|
5
|
-
import {
|
|
5
|
+
import { Q as MenuListStyled, S as HeaderRenderClickStyled } from "../../../../slots/DataGridSlot.js";
|
|
6
6
|
import { M as MenuDivider } from "../../../../../mui_extended/MenuDivider/MenuDivider.js";
|
|
7
7
|
import { P as Popover } from "../../../../../mui_extended/Popover/Popover.js";
|
|
8
8
|
import { D as DICTIONARY } from "../../../../dictionary.js";
|
package/components/datagrids/views/TableView/subcomponents/RenderGroupCell/RenderGroupCell.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsxs, jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEnvironment } from "@m4l/core";
|
|
3
3
|
import { p as pathIcons } from "../../../../icons.js";
|
|
4
4
|
import { I as Icon } from "../../../../../Icon/Icon.js";
|
|
5
|
-
import {
|
|
5
|
+
import { U as DefaultRenderGroupCellRootStyled, W as DefaultRenderGroupCellTextStyled } from "../../../../slots/DataGridSlot.js";
|
|
6
6
|
import { u as useDataGrid } from "../../../../hooks/shared/useDataGrid/useDataGrid.js";
|
|
7
7
|
function RenderGroupCell(props) {
|
|
8
8
|
const { groupKey, isExpanded, toggleGroup, column, customRenderGroupCell, ...restProps } = props;
|
package/components/datagrids/views/TableView/subcomponents/SkeletonFormatter/SkeletonFormatter.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { S as Skeleton } from "../../../../../mui_extended/Skeleton/Skeleton.js";
|
|
3
|
-
import {
|
|
3
|
+
import { X as WrapperSkeletonStyled } from "../../../../slots/DataGridSlot.js";
|
|
4
4
|
import { u as useDataGrid } from "../../../../hooks/shared/useDataGrid/useDataGrid.js";
|
|
5
5
|
function SkeletonFormatter() {
|
|
6
6
|
const { size } = useDataGrid();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useContext } from "react";
|
|
3
3
|
import { SelectCellFormatter } from "react-data-grid";
|
|
4
|
-
import {
|
|
4
|
+
import { Y as CheckboxCellWrapperStyled } from "../../../slots/DataGridSlot.js";
|
|
5
5
|
import { a as DataGridContext } from "../../../contexts/DataGridContext/DataGridContext.js";
|
|
6
6
|
import { R as RadioFormatter } from "../../TableView/subcomponents/RadioSelectColumn/subcomponents/RadioFormatter/RadioFormatter.js";
|
|
7
7
|
import { C as CheckboxFormatter } from "../../TableView/subcomponents/CheckboxFormatter/CheckboxFormatter.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useId
|
|
2
|
+
import { useId } from "react";
|
|
3
3
|
import { useFormContext, Controller } from "react-hook-form";
|
|
4
4
|
import { r as rhfAutocompleteClasses } from "./constants.js";
|
|
5
5
|
import clsx from "clsx";
|
|
@@ -31,31 +31,6 @@ function RHFAutocomplete(props) {
|
|
|
31
31
|
// onChange: onChangeRHF,
|
|
32
32
|
} = props;
|
|
33
33
|
const htmlForId = useId();
|
|
34
|
-
const [open, setOpen] = useState(false);
|
|
35
|
-
const onCloseLocal = useCallback((event, reason) => {
|
|
36
|
-
setOpen(false);
|
|
37
|
-
if (onClose) {
|
|
38
|
-
onClose(event, reason);
|
|
39
|
-
}
|
|
40
|
-
}, [onClose]);
|
|
41
|
-
const onOpenLocal = useCallback(
|
|
42
|
-
(event) => {
|
|
43
|
-
setOpen((currentState) => !currentState);
|
|
44
|
-
if (onOpen) {
|
|
45
|
-
onOpen(event);
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
[onOpen]
|
|
49
|
-
);
|
|
50
|
-
const getOptionLabelLocal = useCallback(
|
|
51
|
-
(option) => {
|
|
52
|
-
if (option === void 0 || option === null) {
|
|
53
|
-
return "";
|
|
54
|
-
}
|
|
55
|
-
return getOptionLabel(option);
|
|
56
|
-
},
|
|
57
|
-
[getOptionLabel]
|
|
58
|
-
);
|
|
59
34
|
const {
|
|
60
35
|
control
|
|
61
36
|
} = useFormContext();
|
|
@@ -74,17 +49,6 @@ function RHFAutocomplete(props) {
|
|
|
74
49
|
name: nameRHF,
|
|
75
50
|
control,
|
|
76
51
|
render: ({ field: { onChange, value }, fieldState: { error }, formState: { isSubmitting } }) => {
|
|
77
|
-
const [inputValue, setInputValue] = useState(
|
|
78
|
-
getOptionLabelLocal(value)
|
|
79
|
-
);
|
|
80
|
-
useEffect(() => {
|
|
81
|
-
if (!open && value === null && inputValue !== "") {
|
|
82
|
-
setInputValue("");
|
|
83
|
-
}
|
|
84
|
-
if (!open && value !== null && options.length === 0) {
|
|
85
|
-
onChangeFilterParmsLocal?.(getOptionLabelLocal(value), "reset");
|
|
86
|
-
}
|
|
87
|
-
}, [value, inputValue]);
|
|
88
52
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
89
53
|
label && /* @__PURE__ */ jsx(
|
|
90
54
|
LabelStyled,
|
|
@@ -115,8 +79,8 @@ function RHFAutocomplete(props) {
|
|
|
115
79
|
refresh,
|
|
116
80
|
disabled: disabled || isSubmitting,
|
|
117
81
|
loading,
|
|
118
|
-
onOpen
|
|
119
|
-
onClose
|
|
82
|
+
onOpen,
|
|
83
|
+
onClose,
|
|
120
84
|
size,
|
|
121
85
|
value,
|
|
122
86
|
htmlFor: htmlForId,
|