@m4l/components 9.1.94 → 9.1.95
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/areas/components/AreasViewer/subcomponents/Area/subcomponents/AreaGridLayout/index.js +1 -1
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/subcomponents/Header/index.js +7 -3
- package/components/areas/contexts/AreasContext/helpers/generateModuleCount.d.ts +9 -0
- package/components/areas/contexts/AreasContext/helpers/generateModuleCount.js +16 -0
- package/components/areas/contexts/AreasContext/{helper.d.ts → helpers/helper.d.ts} +3 -3
- package/components/areas/contexts/AreasContext/{helper.js → helpers/helper.js} +5 -5
- package/components/areas/contexts/AreasContext/index.js +3 -2
- package/components/areas/contexts/AreasContext/store.js +13 -11
- package/components/areas/contexts/AreasContext/tests/Store.test.d.ts +1 -0
- package/components/areas/types.d.ts +5 -0
- package/package.json +2 -2
- /package/components/areas/contexts/AreasContext/{index.test.d.ts → tests/AreasProvider.test.d.ts} +0 -0
|
@@ -4,7 +4,7 @@ import { W as Window } from "../Window/index.js";
|
|
|
4
4
|
import { u as useAreasStore } from "../../../../../../hooks/useAreas/index.js";
|
|
5
5
|
import { a as areasViewerClasses } from "../../../../classes/index.js";
|
|
6
6
|
import clsx from "clsx";
|
|
7
|
-
import { R as RESPONSIVE_COLAPSED_HEIGHTS, a as RESPONSIVE_ROW_HEIGHTS, M as MARGIN_GRIDLAYOUT, P as PADDING_GRIDLAYOUT } from "../../../../../../contexts/AreasContext/helper.js";
|
|
7
|
+
import { R as RESPONSIVE_COLAPSED_HEIGHTS, a as RESPONSIVE_ROW_HEIGHTS, M as MARGIN_GRIDLAYOUT, P as PADDING_GRIDLAYOUT } from "../../../../../../contexts/AreasContext/helpers/helper.js";
|
|
8
8
|
import { w as withSizeProvider } from "../../../../../../../GridLayout/subcomponents/withSizeProvider/index.js";
|
|
9
9
|
import { R as Responsive } from "../../../../../../../GridLayout/subcomponents/Responsive/index.js";
|
|
10
10
|
const ResponsiveGridLayout = withSizeProvider(Responsive);
|
|
@@ -18,7 +18,7 @@ import { I as IconButton } from "../../../../../../../../../mui_extended/IconBut
|
|
|
18
18
|
import { I as Icon } from "../../../../../../../../../Icon/Icon.js";
|
|
19
19
|
function Header(props) {
|
|
20
20
|
const { areaId, windowId, emergeType } = props;
|
|
21
|
-
const [url_icon, title, moduleActions, onClose, version, windowOptions, fnQueryClose] = useAreasStore((state) => {
|
|
21
|
+
const [url_icon, title, moduleActions, onClose, version, windowOptions, fnQueryClose, moduleCount] = useAreasStore((state) => {
|
|
22
22
|
const window = state.hashWindows[windowId];
|
|
23
23
|
return [
|
|
24
24
|
window.iconUrl,
|
|
@@ -27,7 +27,8 @@ function Header(props) {
|
|
|
27
27
|
window.onClose,
|
|
28
28
|
window.version,
|
|
29
29
|
window.windowOptions,
|
|
30
|
-
window.fnQueryClose
|
|
30
|
+
window.fnQueryClose,
|
|
31
|
+
window.moduleCount
|
|
31
32
|
];
|
|
32
33
|
}, shallow);
|
|
33
34
|
const { saveModuleCookies, resetModuleCookies } = useAreasStore(
|
|
@@ -88,7 +89,10 @@ function Header(props) {
|
|
|
88
89
|
/* @__PURE__ */ jsx(LinearProgressIndeterminate, {}),
|
|
89
90
|
/* @__PURE__ */ jsxs("div", { className: areasViewerClasses.windowHeaderContent, children: [
|
|
90
91
|
/* @__PURE__ */ jsx(Icon, { src: url_icon, size: "medium" }),
|
|
91
|
-
/* @__PURE__ */
|
|
92
|
+
/* @__PURE__ */ jsxs(Typography, { className: areasViewerClasses.windowHeaderTitle, variant: "h5", children: [
|
|
93
|
+
title,
|
|
94
|
+
moduleCount ? `:${moduleCount}` : null
|
|
95
|
+
] }),
|
|
92
96
|
/* @__PURE__ */ jsxs("div", { className: areasViewerClasses.windowHeaderCancelHandle, children: [
|
|
93
97
|
!collapsed && /* @__PURE__ */ jsx(MainActions, { windowId }),
|
|
94
98
|
!collapsed && menuActions.length > 0 && /* @__PURE__ */ jsx(
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WindowStateProps } from '../../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Función que genera un string con el número de módulos repetidos en una misma área.
|
|
4
|
+
* Esta función recibe un hash de ventanas y evalúa cada ventana para contar cuántas veces se repite un módulo en una misma área
|
|
5
|
+
* y genera un number que representa el 'moduleCount' de la ventana.
|
|
6
|
+
* @param hashWindows
|
|
7
|
+
* @returns number con el número de módulos repetidos en una mista area
|
|
8
|
+
*/
|
|
9
|
+
export declare const generateModuleCount: (areaId: string, moduleId: string, hashWindows: Record<string, WindowStateProps>) => number;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const generateModuleCount = (areaId, moduleId, hashWindows) => {
|
|
2
|
+
let moduleCount = 1;
|
|
3
|
+
const windows = Object.values(hashWindows);
|
|
4
|
+
const windowsInArea = windows.filter((window) => window.areaId === areaId);
|
|
5
|
+
const sameWindows = windowsInArea.filter((window) => window.moduleId === moduleId);
|
|
6
|
+
sameWindows.sort((a, b) => (a?.moduleCount ?? 0) - (b?.moduleCount ?? 0));
|
|
7
|
+
sameWindows.forEach((window) => {
|
|
8
|
+
if (window?.moduleCount === moduleCount) {
|
|
9
|
+
moduleCount++;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
return moduleCount;
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
generateModuleCount as g
|
|
16
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WritableDraft } from 'immer/dist/internal';
|
|
2
|
-
import { Area, AreasStateWithActions } from '
|
|
3
|
-
import { WindowState } from '
|
|
4
|
-
import { Layouts } from '
|
|
2
|
+
import { Area, AreasStateWithActions } from '../types';
|
|
3
|
+
import { WindowState } from '../../../types';
|
|
4
|
+
import { Layouts } from '../../../../GridLayout/types';
|
|
5
5
|
export declare const PADDING_GRIDLAYOUT = 11;
|
|
6
6
|
export declare const MARGIN_GRIDLAYOUT = 11;
|
|
7
7
|
export declare const DEBOUCED_SAVE_TIME = 500;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { u as useAreasViewerUtilityClasses } from "
|
|
2
|
-
import { u as useAreasAdminUtilityClasses } from "
|
|
3
|
-
import { c as createDynamicMFStore } from "
|
|
4
|
-
import { g as getAreasDictionary, A as AREAS_DICCTIONARY } from "
|
|
5
|
-
import { c as addLayoutItemToBreakPointIfNoExists } from "
|
|
1
|
+
import { u as useAreasViewerUtilityClasses } from "../../../components/AreasViewer/classes/index.js";
|
|
2
|
+
import { u as useAreasAdminUtilityClasses } from "../../../components/AreasAdmin/classes/index.js";
|
|
3
|
+
import { c as createDynamicMFStore } from "../../DynamicMFParmsContext/store.js";
|
|
4
|
+
import { g as getAreasDictionary, A as AREAS_DICCTIONARY } from "../../../dictionary.js";
|
|
5
|
+
import { c as addLayoutItemToBreakPointIfNoExists } from "../../../../GridLayout/subcomponents/Responsive/responsiveUtils.js";
|
|
6
6
|
const PADDING_GRIDLAYOUT = 11;
|
|
7
7
|
const MARGIN_GRIDLAYOUT = 11;
|
|
8
8
|
const DEBOUCED_SAVE_TIME = 500;
|
|
@@ -3,7 +3,7 @@ import { createContext, useRef, useCallback, useEffect } from "react";
|
|
|
3
3
|
import { useStore } from "zustand";
|
|
4
4
|
import { shallow } from "zustand/shallow";
|
|
5
5
|
import { useResponsiveDesktop, useFirstRender } from "@m4l/graphics";
|
|
6
|
-
import { useHostTools, useModuleDictionary, useNetwork, useModuleSkeleton, EmitEvents } from "@m4l/core";
|
|
6
|
+
import { useHostTools, useModuleDictionary, useNetwork, useModuleSkeleton, useFlagsStore, CommonFlags, EmitEvents } from "@m4l/core";
|
|
7
7
|
import { c as createAreasStore } from "./store.js";
|
|
8
8
|
const AreasContext = createContext(null);
|
|
9
9
|
function AreasProvider(props) {
|
|
@@ -14,6 +14,7 @@ function AreasProvider(props) {
|
|
|
14
14
|
const isDesktop = useResponsiveDesktop();
|
|
15
15
|
const isSkeleton = useModuleSkeleton();
|
|
16
16
|
const isFirstRender = useFirstRender([getLabel]);
|
|
17
|
+
const { addFlag } = useFlagsStore((state) => state.flagsActions);
|
|
17
18
|
const areasStoreRef = useRef();
|
|
18
19
|
if (!areasStoreRef.current) {
|
|
19
20
|
areasStoreRef.current = createAreasStore({
|
|
@@ -28,7 +29,6 @@ function AreasProvider(props) {
|
|
|
28
29
|
isSkeleton,
|
|
29
30
|
focus: false
|
|
30
31
|
}
|
|
31
|
-
// onLoad,
|
|
32
32
|
});
|
|
33
33
|
areasStoreRef.current?.getState().areasActions.init();
|
|
34
34
|
}
|
|
@@ -50,6 +50,7 @@ function AreasProvider(props) {
|
|
|
50
50
|
useEffect(() => {
|
|
51
51
|
if (status === "loaded") {
|
|
52
52
|
onLoad && onLoad();
|
|
53
|
+
addFlag(CommonFlags.FLAG_AREAS_LOADED);
|
|
53
54
|
}
|
|
54
55
|
}, [status]);
|
|
55
56
|
useEffect(() => {
|
|
@@ -3,10 +3,11 @@ import { devtools } from "zustand/middleware";
|
|
|
3
3
|
import { immer } from "zustand/middleware/immer";
|
|
4
4
|
import { u as useAreasViewerUtilityClasses } from "../../components/AreasViewer/classes/index.js";
|
|
5
5
|
import { u as useAreasAdminUtilityClasses } from "../../components/AreasAdmin/classes/index.js";
|
|
6
|
-
import { u as updateOwnerStateClasses, C as COOKIE_AREAS_ADMIN_CONTAINER_ID, b as COOKIE_AREAS_ADMIN_ID, D as DEFAULT_AREA, c as addArea, g as getSelectedAreaIdFromCookies, d as DEFAULT_WINDOW, a as RESPONSIVE_ROW_HEIGHTS, P as PADDING_GRIDLAYOUT, M as MARGIN_GRIDLAYOUT, N as NORMALIZED_COLS, e as deleteLayoutFromBreakPoints, f as COOKIE_WINDOWS, h as COOKIE_BREAKPOINT_LAYOUTS, i as DEBOUCED_SAVE_TIME, s as setColapsedLayoutBreakPoints, j as getDataFromResponse, k as getCookiesContainer } from "./helper.js";
|
|
6
|
+
import { u as updateOwnerStateClasses, C as COOKIE_AREAS_ADMIN_CONTAINER_ID, b as COOKIE_AREAS_ADMIN_ID, D as DEFAULT_AREA, c as addArea, g as getSelectedAreaIdFromCookies, d as DEFAULT_WINDOW, a as RESPONSIVE_ROW_HEIGHTS, P as PADDING_GRIDLAYOUT, M as MARGIN_GRIDLAYOUT, N as NORMALIZED_COLS, e as deleteLayoutFromBreakPoints, f as COOKIE_WINDOWS, h as COOKIE_BREAKPOINT_LAYOUTS, i as DEBOUCED_SAVE_TIME, s as setColapsedLayoutBreakPoints, j as getDataFromResponse, k as getCookiesContainer } from "./helpers/helper.js";
|
|
7
7
|
import { c as createDynamicMFStore } from "../DynamicMFParmsContext/store.js";
|
|
8
8
|
import cloneDeep from "lodash-es/cloneDeep";
|
|
9
9
|
import debounce from "lodash-es/debounce";
|
|
10
|
+
import { g as generateModuleCount } from "./helpers/generateModuleCount.js";
|
|
10
11
|
import { g as getCookie, s as setCookie, d as deleteCookie } from "../../../../helpers/cookies/cookies.js";
|
|
11
12
|
import { d as addLayoutItemToBreakPoints, e as cloneLayouts } from "../../../GridLayout/subcomponents/Responsive/responsiveUtils.js";
|
|
12
13
|
import { k as isEqualLayouts } from "../../../GridLayout/utils.js";
|
|
@@ -102,11 +103,7 @@ const createAreasStore = (initProps) => {
|
|
|
102
103
|
});
|
|
103
104
|
},
|
|
104
105
|
/**
|
|
105
|
-
*
|
|
106
|
-
* @createdAt 2024-12-30 14:36:06 - automatic
|
|
107
|
-
* @updatedAt 2025-01-29 16:33:53 - automatic
|
|
108
|
-
* @updatedUser cesar - automatic
|
|
109
|
-
* @author cesar - automatic
|
|
106
|
+
* Acción encargada de añadir un área de trabajo en blanco
|
|
110
107
|
*/
|
|
111
108
|
addArea: () => {
|
|
112
109
|
let newId = "";
|
|
@@ -160,11 +157,12 @@ const createAreasStore = (initProps) => {
|
|
|
160
157
|
delete state.hashWindows[key];
|
|
161
158
|
}
|
|
162
159
|
}
|
|
160
|
+
const indexDeleteArea = state.areasIds.findIndex((elementAreaId) => elementAreaId === areaId);
|
|
163
161
|
state.areasIds.splice(removeIndex, 1);
|
|
164
162
|
delete state.hashAreas[areaId];
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
163
|
+
if (state.currentAreaId === areaId) {
|
|
164
|
+
selectNewAreaId = state.areasIds[indexDeleteArea <= state.areasIds.length - 1 ? indexDeleteArea : state.areasIds.length - 1];
|
|
165
|
+
}
|
|
168
166
|
}
|
|
169
167
|
if (state.loadAreasFromNetwork) {
|
|
170
168
|
state.networkOperation({
|
|
@@ -264,6 +262,7 @@ const createAreasStore = (initProps) => {
|
|
|
264
262
|
addLayout: (areaId, windowId, newWindowProps) => {
|
|
265
263
|
let previousId = windowId;
|
|
266
264
|
const freeMove = newWindowProps.emergeType === "popup";
|
|
265
|
+
const moduleCount = generateModuleCount(get().currentAreaId, newWindowProps.moduleId, get().hashWindows);
|
|
267
266
|
const newLayoutItem = {
|
|
268
267
|
...newWindowProps.layoutProps,
|
|
269
268
|
i: windowId,
|
|
@@ -300,7 +299,8 @@ const createAreasStore = (initProps) => {
|
|
|
300
299
|
get().areaActions.closeLayout(areaId, removeLayoutId);
|
|
301
300
|
},
|
|
302
301
|
...DEFAULT_WINDOW,
|
|
303
|
-
dynamicMFStore
|
|
302
|
+
dynamicMFStore,
|
|
303
|
+
moduleCount
|
|
304
304
|
};
|
|
305
305
|
area.layoutItemsIds.push(windowId);
|
|
306
306
|
if (newWindowProps.emergeType === "layout") {
|
|
@@ -442,13 +442,15 @@ const createAreasStore = (initProps) => {
|
|
|
442
442
|
windowId
|
|
443
443
|
});
|
|
444
444
|
state.windowsModals.push(windowId);
|
|
445
|
+
const moduleCount = generateModuleCount(get().currentAreaId, newWindowModalProps.moduleId, get().hashWindows);
|
|
445
446
|
state.hashWindowsModals[windowId] = {
|
|
446
447
|
...newWindowModalProps,
|
|
447
448
|
areaId,
|
|
448
449
|
windowId,
|
|
449
450
|
...DEFAULT_WINDOW,
|
|
450
451
|
onClose: get().areaActions.closeWindowModal,
|
|
451
|
-
dynamicMFStore
|
|
452
|
+
dynamicMFStore,
|
|
453
|
+
moduleCount
|
|
452
454
|
};
|
|
453
455
|
state.hashWindows[windowId] = state.hashWindowsModals[windowId];
|
|
454
456
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -111,6 +111,11 @@ export type WindowState = {
|
|
|
111
111
|
* @updatedUser cesar - automatic
|
|
112
112
|
*/
|
|
113
113
|
fnQueryClose?: () => void;
|
|
114
|
+
/**
|
|
115
|
+
* moduleCount representa el identificador de
|
|
116
|
+
* la ventana cuando se repite un módulo en una misma área
|
|
117
|
+
*/
|
|
118
|
+
moduleCount?: number;
|
|
114
119
|
};
|
|
115
120
|
/**
|
|
116
121
|
* Opciones para la ventana.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4l/components",
|
|
3
|
-
"version": "9.1.
|
|
3
|
+
"version": "9.1.95",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"lint-staged": {
|
|
6
6
|
"*.{js,ts,tsx}": "eslint --fix --max-warnings 0"
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"zustand": "4.3.6"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@m4l/core": "^2.0.
|
|
56
|
+
"@m4l/core": "^2.0.18",
|
|
57
57
|
"@m4l/graphics": "^7.0.8",
|
|
58
58
|
"@m4l/styles": "^7.1.18",
|
|
59
59
|
"@mui/lab": "5.0.0-alpha.173",
|
/package/components/areas/contexts/AreasContext/{index.test.d.ts → tests/AreasProvider.test.d.ts}
RENAMED
|
File without changes
|