@m4l/layouts 9.3.20 → 9.3.21-BE20260210-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/hooks/index.d.ts +1 -0
- package/hooks/useRefreshData/dictionary.d.ts +4 -0
- package/hooks/useRefreshData/dictionary.js +7 -0
- package/hooks/useRefreshData/index.d.ts +2 -0
- package/hooks/useRefreshData/index.js +1 -0
- package/hooks/useRefreshData/types.d.ts +22 -0
- package/hooks/useRefreshData/useRefreshData.d.ts +12 -0
- package/hooks/useRefreshData/useRefreshData.js +48 -0
- package/hooks/useRefreshData/useRefreshData.test.d.ts +1 -0
- package/index.js +3 -1
- package/layouts/NoAuthModuleLayout/slots/NoAuthModuleLayoutSlots.d.ts +1 -1
- package/package.json +2 -2
package/hooks/index.d.ts
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const USE_REFRESH_DATA_DICTIONARY = {
|
|
2
|
+
TOAST_NEW_ROW_BUT_NOT_VISIBLE_TITLE: "refresh.toast_new_row_but_not_visible_title",
|
|
3
|
+
TOAST_NEW_ROW_BUT_NOT_VISIBLE_DESCRIPTION: "refresh.toast_new_row_but_not_visible_description"
|
|
4
|
+
};
|
|
5
|
+
export {
|
|
6
|
+
USE_REFRESH_DATA_DICTIONARY as U
|
|
7
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RowKey } from '@m4l/components';
|
|
2
|
+
/**
|
|
3
|
+
* Interface to use the useRefreshData hook
|
|
4
|
+
* @param TRow - Type of the rows
|
|
5
|
+
*/
|
|
6
|
+
export interface UseRefreshData<TRow> {
|
|
7
|
+
/**
|
|
8
|
+
* Function to refresh the data
|
|
9
|
+
*/
|
|
10
|
+
refreshPaginate: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* Rows to refresh
|
|
13
|
+
*/
|
|
14
|
+
rows: TRow[];
|
|
15
|
+
/**
|
|
16
|
+
* Function to get the row key
|
|
17
|
+
*/
|
|
18
|
+
rowKeyGetter: (row: TRow) => number | string;
|
|
19
|
+
}
|
|
20
|
+
export interface ValidateShowRowCreate {
|
|
21
|
+
idRow: RowKey | undefined;
|
|
22
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RowKey } from '@m4l/components';
|
|
2
|
+
import { UseRefreshData } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Hook that manages the refresh of the data and the selected rows.
|
|
5
|
+
* Note: This hook could be use in every module that needs to refresh the data and the selected rows.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useRefreshData: <TRow>(props: UseRefreshData<TRow>) => {
|
|
8
|
+
refresh: (rowParam?: TRow | RowKey) => void;
|
|
9
|
+
onSelectedRowsChange: (newRowsSelectSet: ReadonlySet<RowKey>) => void;
|
|
10
|
+
selectedRows: ReadonlySet<RowKey>;
|
|
11
|
+
focusOnRowKey: RowKey | undefined;
|
|
12
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback } from "react";
|
|
2
|
+
import { getDataGridRowsFromSet } from "@m4l/components";
|
|
3
|
+
import { useHostTools, useModuleDictionary } from "@m4l/core";
|
|
4
|
+
import { u as useMasterDetail } from "../useMasterDetail/index.js";
|
|
5
|
+
import { U as USE_REFRESH_DATA_DICTIONARY } from "./dictionary.js";
|
|
6
|
+
const useRefreshData = (props) => {
|
|
7
|
+
const { rows, refreshPaginate, rowKeyGetter } = props;
|
|
8
|
+
const { toast } = useHostTools();
|
|
9
|
+
const { getLabel } = useModuleDictionary();
|
|
10
|
+
const { onChangeMasterSelection } = useMasterDetail();
|
|
11
|
+
const [validateShowRowCreate, setValidateShowRowCreate] = useState({ idRow: void 0 });
|
|
12
|
+
const [selectedRows, setSelectedRows] = useState(/* @__PURE__ */ new Set());
|
|
13
|
+
const [focusOnRowKey, setFocusOnRowKey] = useState(void 0);
|
|
14
|
+
const onSelectedRowsChange = (newRowsSelectSet) => {
|
|
15
|
+
setSelectedRows(newRowsSelectSet);
|
|
16
|
+
onChangeMasterSelection(getDataGridRowsFromSet(newRowsSelectSet, rows, rowKeyGetter));
|
|
17
|
+
};
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (selectedRows.size > 0) {
|
|
20
|
+
onChangeMasterSelection(getDataGridRowsFromSet(selectedRows, rows, rowKeyGetter));
|
|
21
|
+
}
|
|
22
|
+
}, [rows]);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (validateShowRowCreate.idRow !== void 0) {
|
|
25
|
+
const existRowSelected = rows.some((row) => selectedRows.has(rowKeyGetter(row)));
|
|
26
|
+
if (!existRowSelected && validateShowRowCreate.idRow) {
|
|
27
|
+
setSelectedRows?.(/* @__PURE__ */ new Set());
|
|
28
|
+
toast({
|
|
29
|
+
title: getLabel(USE_REFRESH_DATA_DICTIONARY.TOAST_NEW_ROW_BUT_NOT_VISIBLE_TITLE),
|
|
30
|
+
description: getLabel(USE_REFRESH_DATA_DICTIONARY.TOAST_NEW_ROW_BUT_NOT_VISIBLE_DESCRIPTION, validateShowRowCreate.idRow)
|
|
31
|
+
}, { type: "info" });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}, [rows]);
|
|
35
|
+
const refresh = useCallback((rowParam) => {
|
|
36
|
+
if (rowParam !== void 0) {
|
|
37
|
+
const idRow = typeof rowParam === "string" || typeof rowParam === "number" ? rowParam : rowKeyGetter(rowParam);
|
|
38
|
+
setFocusOnRowKey(idRow);
|
|
39
|
+
setValidateShowRowCreate({ idRow });
|
|
40
|
+
setSelectedRows(/* @__PURE__ */ new Set([idRow]));
|
|
41
|
+
}
|
|
42
|
+
refreshPaginate();
|
|
43
|
+
}, [refreshPaginate, setSelectedRows, rowKeyGetter]);
|
|
44
|
+
return { refresh, onSelectedRowsChange, selectedRows, focusOnRowKey };
|
|
45
|
+
};
|
|
46
|
+
export {
|
|
47
|
+
useRefreshData as u
|
|
48
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import { u as u3 } from "./hooks/useDynamicAccordions/useDynamicAccordions.js";
|
|
|
15
15
|
import { c, u as u4 } from "./hooks/useDynamicPaperForm/useDynamicPaperForm.js";
|
|
16
16
|
import { u as u5 } from "./hooks/useNetworkActionConfirm/useNetworkActionConfirm.js";
|
|
17
17
|
import { u as u6 } from "./hooks/useFormAddEdit/useFormAddEdit.js";
|
|
18
|
+
import { u as u7 } from "./hooks/useRefreshData/useRefreshData.js";
|
|
18
19
|
import { c as c2 } from "./utils/createAppMF.js";
|
|
19
20
|
export {
|
|
20
21
|
D as DynamicTabs,
|
|
@@ -36,5 +37,6 @@ export {
|
|
|
36
37
|
u6 as useFormAddEdit,
|
|
37
38
|
u as useMasterDetail,
|
|
38
39
|
u2 as useModule,
|
|
39
|
-
u5 as useNetworkActionConfirm
|
|
40
|
+
u5 as useNetworkActionConfirm,
|
|
41
|
+
u7 as useRefreshData
|
|
40
42
|
};
|
|
@@ -5,6 +5,6 @@ export declare const ContainerModuleNameStyled: import('@emotion/styled').Styled
|
|
|
5
5
|
export declare const ContentFormDesktopStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Record<string, unknown>, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
6
6
|
export declare const HeaderContainerStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Record<string, unknown>, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
7
7
|
export declare const ContainerLanguageAndSettingsStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Record<string, unknown>, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
8
|
-
export declare const ButtonHomeNavigationStyled: import('@emotion/styled').StyledComponent<Pick<Omit<import('@m4l/components/src/components/
|
|
8
|
+
export declare const ButtonHomeNavigationStyled: import('@emotion/styled').StyledComponent<Pick<Omit<import('@m4l/components/src/components/extended/mui/Button').ButtonProps, "ref"> & import('react').RefAttributes<HTMLButtonElement>, "value" | "size" | "children" | "title" | "component" | "name" | "id" | "type" | "disabled" | "action" | "color" | "content" | "translate" | "lang" | "form" | "label" | "slot" | "style" | "dir" | "variant" | "className" | "classes" | "sx" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoCapitalize" | "autoFocus" | "contentEditable" | "contextMenu" | "draggable" | "enterKeyHint" | "hidden" | "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" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "href" | "skeletonWidth" | "startIcon" | "endIcon" | keyof import('react').RefAttributes<HTMLButtonElement> | "fullWidth" | "disableElevation"> & import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Record<string, unknown>, {}, {}>;
|
|
9
9
|
export declare const ContainerCompanyLogoStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Record<string, unknown>, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
10
10
|
export declare const FormContentStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Record<string, unknown>, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4l/layouts",
|
|
3
|
-
"version": "9.3.
|
|
3
|
+
"version": "9.3.21-BE20260210-1+PR405-reports-list",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": "M4L Team",
|
|
6
6
|
"lint-staged": {
|
|
7
7
|
"*.{js,ts,tsx}": "eslint --fix --max-warnings 0"
|
|
8
8
|
},
|
|
9
9
|
"peerDependencies": {
|
|
10
|
-
"@m4l/components": "
|
|
10
|
+
"@m4l/components": "9.4.28-BE20260210-1+PR405-reports-list",
|
|
11
11
|
"@m4l/core": "^2.0.0",
|
|
12
12
|
"@m4l/graphics": "^7.0.0",
|
|
13
13
|
"@m4l/styles": "^7.0.0"
|