@m4l/layouts 1.0.4 → 1.0.5
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/BaseModule/index.8ff0193e.js +39 -0
- package/components/BaseModule/index.d.ts +4 -0
- package/components/BaseModule/types.d.ts +10 -0
- package/components/MFHostApp/index.401a303e.js +79 -0
- package/components/MFHostApp/index.d.ts +4 -0
- package/components/MFHostApp/types.d.ts +17 -0
- package/components/MFIsolationApp/index.d.ts +4 -0
- package/components/MFIsolationApp/index.e733d368.js +181 -0
- package/components/MFIsolationApp/subcomponents/MFAuthApp/index.d.ts +4 -0
- package/components/MFIsolationApp/subcomponents/MFAuthApp/types.d.ts +6 -0
- package/components/MFIsolationApp/types.d.ts +14 -0
- package/components/MFNoAuthApp/index.d.ts +4 -0
- package/components/MFNoAuthApp/types.d.ts +10 -0
- package/components/index.7006a30d.js +47 -0
- package/components/index.d.ts +6 -0
- package/contexts/AuthContext/index.6f966215.js +160 -0
- package/contexts/AuthContext/index.d.ts +5 -0
- package/contexts/AuthContext/types.d.ts +51 -0
- package/contexts/index.d.ts +1 -0
- package/contexts/index.ee173661.js +1 -0
- package/hooks/index.77acdde7.js +1 -0
- package/{dist/hooks → hooks}/index.d.ts +1 -0
- package/hooks/useAuth/index.cb6a3420.js +11 -0
- package/hooks/useAuth/index.d.ts +2 -0
- package/{dist/hooks/useMasterDetail/index.js → hooks/useMasterDetail/index.d45f2a86.js} +4 -2
- package/{dist/hooks/useModule/index.js → hooks/useModule/index.b5f598b1.js} +4 -2
- package/index.d.ts +4 -0
- package/index.js +46 -0
- package/{dist/layouts/MasterDetailLayout/index.d.ts → layouts/MasterDetailLayout/MasterDetailLayout.d.ts} +1 -1
- package/layouts/MasterDetailLayout/classes/constants.d.ts +1 -0
- package/layouts/MasterDetailLayout/classes/index.d.ts +6 -0
- package/layouts/MasterDetailLayout/classes/types.d.ts +6 -0
- package/{dist/layouts → layouts}/MasterDetailLayout/contexts/MasterDetailContext/index.d.ts +1 -1
- package/{dist/layouts → layouts}/MasterDetailLayout/contexts/MasterDetailContext/types.d.ts +2 -3
- package/layouts/MasterDetailLayout/index.748f7ada.js +155 -0
- package/layouts/MasterDetailLayout/styles.d.ts +2 -0
- package/{dist/layouts → layouts}/MasterDetailLayout/types.d.ts +0 -1
- package/layouts/ModuleLayout/classes/constants.d.ts +1 -0
- package/layouts/ModuleLayout/classes/index.d.ts +7 -0
- package/layouts/ModuleLayout/classes/types.d.ts +7 -0
- package/{dist/layouts → layouts}/ModuleLayout/contexts/ModuleContext/index.d.ts +2 -2
- package/{dist/layouts → layouts}/ModuleLayout/contexts/ModuleContext/types.d.ts +4 -9
- package/layouts/ModuleLayout/index.e7218171.js +122 -0
- package/layouts/ModuleLayout/subcomponents/InnerModule/index.d.ts +3 -0
- package/layouts/ModuleLayout/subcomponents/InnerModule/styles.d.ts +2 -0
- package/layouts/ModuleLayout/types.d.ts +16 -0
- package/layouts/NoAuthModuleLayout/dicctionary.d.ts +3 -0
- package/layouts/NoAuthModuleLayout/index.83cd3ea3.js +425 -0
- package/layouts/NoAuthModuleLayout/index.d.ts +3 -0
- package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/index.d.ts +2 -0
- package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/styles.d.ts +2 -0
- package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/DesktopContent/index.d.ts +2 -0
- package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/DesktopContent/styles.d.ts +10 -0
- package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/MobileContent/index.d.ts +2 -0
- package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/MobileContent/styles.d.ts +9 -0
- package/layouts/NoAuthModuleLayout/types.d.ts +20 -0
- package/layouts/index.417b6868.js +1 -0
- package/layouts/index.d.ts +6 -0
- package/m4l_layouts/types.d.ts +0 -0
- package/package.json +22 -55
- package/dist/hooks/useResponsive.d.ts +0 -8
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -12
- package/dist/layouts/MasterDetailLayout/components/ButtonDetail/index.d.ts +0 -3
- package/dist/layouts/MasterDetailLayout/index.js +0 -170
- package/dist/layouts/ModuleLayout/components/Header/index.d.ts +0 -2
- package/dist/layouts/ModuleLayout/components/Header/skeleton.d.ts +0 -2
- package/dist/layouts/ModuleLayout/components/Header/styles.d.ts +0 -8
- package/dist/layouts/ModuleLayout/components/Header/types.d.ts +0 -2
- package/dist/layouts/ModuleLayout/components/ModuleContent/index.d.ts +0 -3
- package/dist/layouts/ModuleLayout/components/ModuleContent/styles.d.ts +0 -3
- package/dist/layouts/ModuleLayout/index.js +0 -380
- package/dist/layouts/ModuleLayout/types.d.ts +0 -28
- package/dist/layouts/index.d.ts +0 -2
- package/dist/vendor.js +0 -35
- /package/{dist/hooks → hooks}/useMasterDetail/index.d.ts +0 -0
- /package/{dist/hooks → hooks}/useModule/index.d.ts +0 -0
- /package/{dist/layouts → layouts}/MasterDetailLayout/dicctionary.d.ts +0 -0
- /package/{dist/layouts/ModuleLayout/index.d.ts → layouts/ModuleLayout/ModuleLayout.d.ts} +0 -0
- /package/{dist/layouts → layouts}/ModuleLayout/dicctionary.d.ts +0 -0
- /package/{dist/layouts/ModuleLayout/components/ModuleContent → layouts/ModuleLayout/subcomponents/InnerModule}/types.d.ts +0 -0
- /package/{dist/vite-env.d.ts → vite-env.d.ts} +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { a as AuthContext } from "../../contexts/AuthContext/index.6f966215.js";
|
|
3
|
+
const useAuth = () => {
|
|
4
|
+
const context = useContext(AuthContext);
|
|
5
|
+
if (!context)
|
|
6
|
+
throw new Error("Auth context must be use inside AuthProvider");
|
|
7
|
+
return context;
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
useAuth as u
|
|
11
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { useContext } from "react";
|
|
2
|
-
import { M as MasterDetailContext } from "../../layouts/MasterDetailLayout/index.js";
|
|
2
|
+
import { M as MasterDetailContext } from "../../layouts/MasterDetailLayout/index.748f7ada.js";
|
|
3
3
|
const useMasterDetail = () => useContext(MasterDetailContext);
|
|
4
|
-
export {
|
|
4
|
+
export {
|
|
5
|
+
useMasterDetail as u
|
|
6
|
+
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { useContext } from "react";
|
|
2
|
-
import { M as ModuleContext } from "../../layouts/ModuleLayout/index.js";
|
|
2
|
+
import { M as ModuleContext } from "../../layouts/ModuleLayout/index.e7218171.js";
|
|
3
3
|
const useModule = () => {
|
|
4
4
|
const context = useContext(ModuleContext);
|
|
5
5
|
if (!context)
|
|
6
6
|
throw new Error("useModule context must be use inside ModuleContext");
|
|
7
7
|
return context;
|
|
8
8
|
};
|
|
9
|
-
export {
|
|
9
|
+
export {
|
|
10
|
+
useModule as u
|
|
11
|
+
};
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { M } from "./components/MFIsolationApp/index.e733d368.js";
|
|
2
|
+
import { M as M2 } from "./components/index.7006a30d.js";
|
|
3
|
+
import { M as M3 } from "./components/MFHostApp/index.401a303e.js";
|
|
4
|
+
import { B } from "./components/BaseModule/index.8ff0193e.js";
|
|
5
|
+
import { a, A } from "./contexts/AuthContext/index.6f966215.js";
|
|
6
|
+
import { a as a2, d, g } from "./layouts/ModuleLayout/index.e7218171.js";
|
|
7
|
+
import { a as a3, d as d2, g as g2 } from "./layouts/MasterDetailLayout/index.748f7ada.js";
|
|
8
|
+
import { N, d as d3, g as g3 } from "./layouts/NoAuthModuleLayout/index.83cd3ea3.js";
|
|
9
|
+
import { u } from "./hooks/useMasterDetail/index.d45f2a86.js";
|
|
10
|
+
import { u as u2 } from "./hooks/useAuth/index.cb6a3420.js";
|
|
11
|
+
import { u as u3 } from "./hooks/useModule/index.b5f598b1.js";
|
|
12
|
+
import "react";
|
|
13
|
+
import "react-router-dom";
|
|
14
|
+
import "react-toastify";
|
|
15
|
+
import "@m4l/graphics";
|
|
16
|
+
import "@m4l/core";
|
|
17
|
+
import "history";
|
|
18
|
+
import "eventemitter3";
|
|
19
|
+
import "date-fns";
|
|
20
|
+
import "@m4l/styles";
|
|
21
|
+
import "react/jsx-runtime";
|
|
22
|
+
import "nprogress";
|
|
23
|
+
import "@m4l/components";
|
|
24
|
+
import "@mui/material/styles";
|
|
25
|
+
import "@mui/material";
|
|
26
|
+
import "@mui/base";
|
|
27
|
+
export {
|
|
28
|
+
a as AuthContext,
|
|
29
|
+
A as AuthProvider,
|
|
30
|
+
B as BaseModule,
|
|
31
|
+
M3 as MFHostApp,
|
|
32
|
+
M as MFIsolationApp,
|
|
33
|
+
M2 as MFNoAuthApp,
|
|
34
|
+
a3 as MasterDetailLayout,
|
|
35
|
+
a2 as ModuleLayout,
|
|
36
|
+
N as NoAuthModuleLayout,
|
|
37
|
+
d2 as defaultMasterDetailDictionary,
|
|
38
|
+
d as defaultModuleLayoutDictionary,
|
|
39
|
+
d3 as defaultNoAuthModuleLayoutDictionary,
|
|
40
|
+
g2 as getMasterDetailLayoutComponentsDictionary,
|
|
41
|
+
g as getModuleLayoutComponentsDictionary,
|
|
42
|
+
g3 as getNoAuthModuleLayoutComponentsDictionary,
|
|
43
|
+
u2 as useAuth,
|
|
44
|
+
u as useMasterDetail,
|
|
45
|
+
u3 as useModule
|
|
46
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { MasterDetailLayoutProps } from './types';
|
|
3
|
-
export declare function MasterDetailLayout(props: MasterDetailLayoutProps): JSX.Element;
|
|
3
|
+
export declare function MasterDetailLayout(props: MasterDetailLayoutProps): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const componentName = "M4LMasterDetailLayout";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MasterDetailLayoutClassesType } from './types';
|
|
2
|
+
export declare const masterDetailLayoutClasses: MasterDetailLayoutClassesType;
|
|
3
|
+
export declare function getMasterDetailLayoutUtilityClass(slot: string): string;
|
|
4
|
+
export declare const useMasterDetailLayoutUtilityClasses: () => {
|
|
5
|
+
root: string;
|
|
6
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { useMasterDetailLayoutUtilityClasses } from ".";
|
|
2
|
+
export interface MasterDetailLayoutClassesType {
|
|
3
|
+
root: string;
|
|
4
|
+
}
|
|
5
|
+
export declare type MasterDetailLayoutClassesKey = keyof MasterDetailLayoutClassesType;
|
|
6
|
+
export declare type Classes = ReturnType<typeof useMasterDetailLayoutUtilityClasses>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { MasterDetailContextProps, MasterDetailProviderProps } from './types';
|
|
3
3
|
declare const MasterDetailContext: import("react").Context<MasterDetailContextProps>;
|
|
4
|
-
declare function MasterDetailProvider(props: MasterDetailProviderProps): JSX.Element;
|
|
4
|
+
declare function MasterDetailProvider(props: MasterDetailProviderProps): import("react").JSX.Element;
|
|
5
5
|
export { MasterDetailProvider, MasterDetailContext };
|
|
@@ -4,10 +4,9 @@ export interface MasterDetailContextStateProps {
|
|
|
4
4
|
masterSelection?: MasterSelecion;
|
|
5
5
|
}
|
|
6
6
|
export interface MasterDetailProviderProps {
|
|
7
|
-
masterSelection: MasterSelecion;
|
|
8
|
-
setMasterSelection: (newMasterSelecion: MasterSelecion) => void;
|
|
9
7
|
children: ReactNode;
|
|
8
|
+
onClickViewDetail: () => void;
|
|
10
9
|
}
|
|
11
|
-
export interface MasterDetailContextProps extends MasterDetailContextStateProps {
|
|
10
|
+
export interface MasterDetailContextProps extends MasterDetailContextStateProps, Pick<MasterDetailProviderProps, 'onClickViewDetail'> {
|
|
12
11
|
onChangeMasterSelection: (newMasterSelection: MasterSelecion) => void;
|
|
13
12
|
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { createContext, useState, useRef, useMemo, useCallback } from "react";
|
|
2
|
+
import { voidFunction, useEnvironment, useModuleDictionary } from "@m4l/core";
|
|
3
|
+
import { WindowBase, SplitLayout } from "@m4l/components";
|
|
4
|
+
import { a as ModuleLayout, g as getModuleLayoutComponentsDictionary } from "../ModuleLayout/index.e7218171.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { useResponsiveDesktop } from "@m4l/graphics";
|
|
7
|
+
import { generateUtilityClasses, generateUtilityClass, styled } from "@mui/material";
|
|
8
|
+
import { unstable_composeClasses } from "@mui/base";
|
|
9
|
+
const initialState = {
|
|
10
|
+
masterSelection: void 0,
|
|
11
|
+
onChangeMasterSelection: voidFunction,
|
|
12
|
+
onClickViewDetail: voidFunction
|
|
13
|
+
};
|
|
14
|
+
const MasterDetailContext = createContext(initialState);
|
|
15
|
+
function MasterDetailProvider(props) {
|
|
16
|
+
const {
|
|
17
|
+
children,
|
|
18
|
+
onClickViewDetail
|
|
19
|
+
} = props;
|
|
20
|
+
const [masterSelection, setMasterSelection] = useState(void 0);
|
|
21
|
+
return /* @__PURE__ */ jsx(MasterDetailContext.Provider, {
|
|
22
|
+
value: {
|
|
23
|
+
masterSelection,
|
|
24
|
+
onChangeMasterSelection: setMasterSelection,
|
|
25
|
+
onClickViewDetail
|
|
26
|
+
},
|
|
27
|
+
children
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
const componentName = "M4LMasterDetailLayout";
|
|
31
|
+
generateUtilityClasses(componentName, [
|
|
32
|
+
"root"
|
|
33
|
+
]);
|
|
34
|
+
function getMasterDetailLayoutUtilityClass(slot) {
|
|
35
|
+
return generateUtilityClass(componentName, slot);
|
|
36
|
+
}
|
|
37
|
+
const useMasterDetailLayoutUtilityClasses = () => {
|
|
38
|
+
const slots = {
|
|
39
|
+
root: ["root"]
|
|
40
|
+
};
|
|
41
|
+
const composedClasses = unstable_composeClasses(slots, getMasterDetailLayoutUtilityClass, {});
|
|
42
|
+
return {
|
|
43
|
+
...composedClasses
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
const MasterDetailLayoutRoot = styled("div")(({ theme }) => ({
|
|
47
|
+
...theme.components?.M4LMasterDetailLayout?.styleOverrides
|
|
48
|
+
}));
|
|
49
|
+
function getTotalModuleActions(splitActions, moduleActions = []) {
|
|
50
|
+
let totalActions = [...splitActions];
|
|
51
|
+
totalActions = moduleActions.concat(totalActions);
|
|
52
|
+
return totalActions;
|
|
53
|
+
}
|
|
54
|
+
function MasterDetailLayout(props) {
|
|
55
|
+
const {
|
|
56
|
+
moduleId,
|
|
57
|
+
masterComponent,
|
|
58
|
+
detailComponent,
|
|
59
|
+
moduleActions,
|
|
60
|
+
version
|
|
61
|
+
} = props;
|
|
62
|
+
const {
|
|
63
|
+
host_static_assets,
|
|
64
|
+
environment_assets
|
|
65
|
+
} = useEnvironment();
|
|
66
|
+
const [splitPosition, setSplitPosition] = useState("vertical");
|
|
67
|
+
const isDesktop = useResponsiveDesktop();
|
|
68
|
+
const moduleLayoutRef = useRef(null);
|
|
69
|
+
const {
|
|
70
|
+
getLabel
|
|
71
|
+
} = useModuleDictionary();
|
|
72
|
+
const splitActions = useMemo(() => [{
|
|
73
|
+
urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/split_vertical.svg`,
|
|
74
|
+
onClick: () => onChangePostionInternal("vertical"),
|
|
75
|
+
visibility: "main",
|
|
76
|
+
label: getLabel("master_detail_layout.split_vertical"),
|
|
77
|
+
tag: "vertical",
|
|
78
|
+
className: "splitactions",
|
|
79
|
+
disabled: splitPosition === "vertical",
|
|
80
|
+
key: "vertical"
|
|
81
|
+
}, {
|
|
82
|
+
urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/split_horizontal.svg`,
|
|
83
|
+
onClick: () => onChangePostionInternal("horizontal"),
|
|
84
|
+
visibility: "main",
|
|
85
|
+
label: getLabel("master_detail_layout.split_horizontal"),
|
|
86
|
+
tag: "horizontal",
|
|
87
|
+
className: "splitactions",
|
|
88
|
+
disabled: splitPosition === "horizontal",
|
|
89
|
+
key: "horizontal"
|
|
90
|
+
}, {
|
|
91
|
+
urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/no_split.svg`,
|
|
92
|
+
onClick: () => onChangePostionInternal("none"),
|
|
93
|
+
visibility: "main",
|
|
94
|
+
label: getLabel("master_detail_layout.no_split"),
|
|
95
|
+
tag: "none",
|
|
96
|
+
className: "splitactions",
|
|
97
|
+
disabled: splitPosition === "none",
|
|
98
|
+
key: "none"
|
|
99
|
+
}], [getLabel, splitPosition]);
|
|
100
|
+
const onChangePostionInternal = useCallback((newPostion) => {
|
|
101
|
+
setSplitPosition(newPostion);
|
|
102
|
+
}, []);
|
|
103
|
+
const onClickViewDetail = useCallback(() => {
|
|
104
|
+
moduleLayoutRef.current?.openModal({
|
|
105
|
+
initialWidth: 500,
|
|
106
|
+
initialHeigth: 680,
|
|
107
|
+
window: /* @__PURE__ */ jsx(
|
|
108
|
+
WindowBase,
|
|
109
|
+
{
|
|
110
|
+
title: getLabel("master_detail_layout.view_detail"),
|
|
111
|
+
children: typeof detailComponent === "function" ? detailComponent({}) : detailComponent
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
});
|
|
115
|
+
}, [detailComponent, getLabel]);
|
|
116
|
+
const finalModuleActions = useMemo(() => {
|
|
117
|
+
const actions = getTotalModuleActions(splitActions, moduleActions);
|
|
118
|
+
return actions;
|
|
119
|
+
}, [splitActions, moduleActions]);
|
|
120
|
+
const classes = useMasterDetailLayoutUtilityClasses();
|
|
121
|
+
return /* @__PURE__ */ jsx(MasterDetailProvider, {
|
|
122
|
+
onClickViewDetail,
|
|
123
|
+
children: /* @__PURE__ */ jsx(MasterDetailLayoutRoot, {
|
|
124
|
+
className: classes.root,
|
|
125
|
+
children: /* @__PURE__ */ jsx(ModuleLayout, {
|
|
126
|
+
ref: moduleLayoutRef,
|
|
127
|
+
moduleId,
|
|
128
|
+
moduleActions: finalModuleActions,
|
|
129
|
+
version,
|
|
130
|
+
children: /* @__PURE__ */ jsx(SplitLayout, {
|
|
131
|
+
splitPosition: isDesktop ? splitPosition : "none",
|
|
132
|
+
firstPart: masterComponent,
|
|
133
|
+
secondPart: detailComponent
|
|
134
|
+
})
|
|
135
|
+
})
|
|
136
|
+
})
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function getMasterDetailLayoutComponentsDictionary() {
|
|
140
|
+
return ["master_detail_layout"].concat(getModuleLayoutComponentsDictionary());
|
|
141
|
+
}
|
|
142
|
+
const defaultMasterDetailDictionary = {
|
|
143
|
+
master_detail_layout: {
|
|
144
|
+
split_vertical: "Split vertically",
|
|
145
|
+
split_horizontal: "Split horizontally",
|
|
146
|
+
no_split: "No split",
|
|
147
|
+
view_detail: "View detail"
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
export {
|
|
151
|
+
MasterDetailContext as M,
|
|
152
|
+
MasterDetailLayout as a,
|
|
153
|
+
defaultMasterDetailDictionary as d,
|
|
154
|
+
getMasterDetailLayoutComponentsDictionary as g
|
|
155
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const MasterDetailLayoutRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -6,5 +6,4 @@ export interface ContainerProps {
|
|
|
6
6
|
export interface MasterDetailLayoutProps extends Omit<ModuleLayoutProps, 'children'> {
|
|
7
7
|
masterComponent: ((props?: any) => JSX.Element) | ReactNode;
|
|
8
8
|
detailComponent: ((props?: any) => JSX.Element) | ReactNode;
|
|
9
|
-
onChangeSelected?: (row: any[]) => void;
|
|
10
9
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const componentName = "M4LModuleLayout";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ModuleLayoutClassesType } from './types';
|
|
2
|
+
export declare const moduleLayoutClasses: ModuleLayoutClassesType;
|
|
3
|
+
export declare function getModuleLayoutUtilityClass(slot: string): string;
|
|
4
|
+
export declare const useModuleLayoutUtilityClasses: () => {
|
|
5
|
+
root: string;
|
|
6
|
+
moduleContent: string;
|
|
7
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useModuleLayoutUtilityClasses } from ".";
|
|
2
|
+
export interface ModuleLayoutClassesType {
|
|
3
|
+
root: string;
|
|
4
|
+
moduleContent: string;
|
|
5
|
+
}
|
|
6
|
+
export declare type ModuleLayoutClassesKey = keyof ModuleLayoutClassesType;
|
|
7
|
+
export declare type Classes = ReturnType<typeof useModuleLayoutUtilityClasses>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ModuleLayoutContextProps, ModuleLayoutProviderProps } from './types';
|
|
3
|
-
declare const ModuleContext: import("react").Context<ModuleLayoutContextProps>;
|
|
4
|
-
declare function ModuleProvider(props: ModuleLayoutProviderProps): JSX.Element;
|
|
3
|
+
declare const ModuleContext: import("react").Context<ModuleLayoutContextProps | null>;
|
|
4
|
+
declare function ModuleProvider(props: ModuleLayoutProviderProps): import("react").JSX.Element;
|
|
5
5
|
export { ModuleProvider, ModuleContext };
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ModuleAction } from '@m4l/components';
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
|
-
import type { ModuleAction } from '../../types';
|
|
4
3
|
export interface ModuleLayoutContextStateProps {
|
|
5
|
-
|
|
6
|
-
moduleId: number;
|
|
7
|
-
moduleNameField: string;
|
|
8
|
-
breadcrumbLinks: TLink[];
|
|
4
|
+
moduleId: string;
|
|
9
5
|
}
|
|
10
6
|
export interface ModuleLayoutProviderProps extends Omit<ModuleLayoutContextStateProps, 'init'> {
|
|
11
7
|
children: ReactNode;
|
|
12
|
-
|
|
8
|
+
version: string;
|
|
9
|
+
moduleActions?: ModuleAction[];
|
|
13
10
|
}
|
|
14
11
|
export interface ModuleLayoutContextProps extends ModuleLayoutContextStateProps {
|
|
15
|
-
moduleActions: ModuleAction[];
|
|
16
|
-
dynamicActions: ModuleAction[];
|
|
17
12
|
setDynamicActions: (dynamicActions: ModuleAction[]) => void;
|
|
18
13
|
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { useModal, useWindowToolsMF, ModalProvider, getModalDialogComponentsDictionary } from "@m4l/components";
|
|
2
|
+
import { forwardRef, useRef, useImperativeHandle, createContext, useState, useMemo, useEffect } from "react";
|
|
3
|
+
import { styled } from "@mui/material/styles";
|
|
4
|
+
import { generateUtilityClasses, generateUtilityClass } from "@mui/material";
|
|
5
|
+
import { unstable_composeClasses } from "@mui/base";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
const InnerModuleRoot = styled("div")(({
|
|
8
|
+
theme
|
|
9
|
+
}) => ({
|
|
10
|
+
...theme.components?.M4LModuleLayout?.styleOverrides
|
|
11
|
+
}));
|
|
12
|
+
const componentName = "M4LModuleLayout";
|
|
13
|
+
generateUtilityClasses(componentName, [
|
|
14
|
+
"root",
|
|
15
|
+
"moduleContent"
|
|
16
|
+
]);
|
|
17
|
+
function getModuleLayoutUtilityClass(slot) {
|
|
18
|
+
return generateUtilityClass(componentName, slot);
|
|
19
|
+
}
|
|
20
|
+
const useModuleLayoutUtilityClasses = () => {
|
|
21
|
+
const slots = {
|
|
22
|
+
root: ["root"],
|
|
23
|
+
moduleContent: ["moduleContent"]
|
|
24
|
+
};
|
|
25
|
+
const composedClasses = unstable_composeClasses(slots, getModuleLayoutUtilityClass, {});
|
|
26
|
+
return {
|
|
27
|
+
...composedClasses
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
const InnerModule = forwardRef((props, ref) => {
|
|
31
|
+
const {
|
|
32
|
+
children
|
|
33
|
+
} = props;
|
|
34
|
+
const {
|
|
35
|
+
openModal
|
|
36
|
+
} = useModal();
|
|
37
|
+
const divRef = useRef(null);
|
|
38
|
+
useImperativeHandle(ref, () => ({
|
|
39
|
+
openModal,
|
|
40
|
+
current: divRef.current
|
|
41
|
+
}));
|
|
42
|
+
const classes = useModuleLayoutUtilityClasses();
|
|
43
|
+
return /* @__PURE__ */ jsx(InnerModuleRoot, {
|
|
44
|
+
className: classes.root,
|
|
45
|
+
ref: divRef,
|
|
46
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
47
|
+
className: classes.moduleContent,
|
|
48
|
+
children
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
InnerModule.displayName = "InnerModule";
|
|
53
|
+
const ModuleContext = createContext(null);
|
|
54
|
+
function ModuleProvider(props) {
|
|
55
|
+
const {
|
|
56
|
+
children,
|
|
57
|
+
moduleActions,
|
|
58
|
+
moduleId,
|
|
59
|
+
version
|
|
60
|
+
} = props;
|
|
61
|
+
const [configOptions] = useState(() => ({
|
|
62
|
+
moduleId,
|
|
63
|
+
dictionary: void 0
|
|
64
|
+
}));
|
|
65
|
+
const {
|
|
66
|
+
setActions
|
|
67
|
+
} = useWindowToolsMF();
|
|
68
|
+
const [dynamicActions, setDynamicActions] = useState([]);
|
|
69
|
+
const finalModuleActions = useMemo(() => {
|
|
70
|
+
return (moduleActions || []).concat(dynamicActions);
|
|
71
|
+
}, [moduleActions, dynamicActions]);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
setActions(finalModuleActions, version);
|
|
74
|
+
}, [finalModuleActions]);
|
|
75
|
+
return /* @__PURE__ */ jsx(ModuleContext.Provider, {
|
|
76
|
+
value: {
|
|
77
|
+
setDynamicActions,
|
|
78
|
+
moduleId: configOptions.moduleId
|
|
79
|
+
},
|
|
80
|
+
children
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const ModuleLayout = forwardRef((props, ref) => {
|
|
84
|
+
const {
|
|
85
|
+
moduleId,
|
|
86
|
+
moduleActions,
|
|
87
|
+
version,
|
|
88
|
+
children
|
|
89
|
+
} = props;
|
|
90
|
+
const moduleRef = useRef(null);
|
|
91
|
+
const openModal = (modalOpenProps) => {
|
|
92
|
+
moduleRef.current?.openModal(modalOpenProps);
|
|
93
|
+
};
|
|
94
|
+
useImperativeHandle(ref, () => ({
|
|
95
|
+
openModal,
|
|
96
|
+
current: moduleRef.current
|
|
97
|
+
}));
|
|
98
|
+
return /* @__PURE__ */ jsx(ModuleProvider, {
|
|
99
|
+
moduleId,
|
|
100
|
+
moduleActions,
|
|
101
|
+
version,
|
|
102
|
+
children: /* @__PURE__ */ jsx(ModalProvider, {
|
|
103
|
+
children: /* @__PURE__ */ jsx(InnerModule, {
|
|
104
|
+
ref: moduleRef,
|
|
105
|
+
children
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
ModuleLayout.displayName = "ModuleLayout";
|
|
111
|
+
function getModuleLayoutComponentsDictionary() {
|
|
112
|
+
return ["module_layout"].concat(getModalDialogComponentsDictionary());
|
|
113
|
+
}
|
|
114
|
+
const defaultModuleLayoutDictionary = {
|
|
115
|
+
module_layout: {}
|
|
116
|
+
};
|
|
117
|
+
export {
|
|
118
|
+
ModuleContext as M,
|
|
119
|
+
ModuleLayout as a,
|
|
120
|
+
defaultModuleLayoutDictionary as d,
|
|
121
|
+
getModuleLayoutComponentsDictionary as g
|
|
122
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const InnerModuleRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ModalOpenOptions, ModuleAction } from '@m4l/components';
|
|
3
|
+
import type { ModuleRef } from './subcomponents/InnerModule/types';
|
|
4
|
+
export interface ContainerProps {
|
|
5
|
+
vertical: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare type ModuleLayoutRef = {
|
|
8
|
+
openModal: (modalOpenProps: ModalOpenOptions) => void;
|
|
9
|
+
current: ModuleRef | null;
|
|
10
|
+
};
|
|
11
|
+
export interface ModuleLayoutProps {
|
|
12
|
+
moduleId: string;
|
|
13
|
+
moduleActions?: ModuleAction[];
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
version: string;
|
|
16
|
+
}
|