@m4l/layouts 3.1.1 → 3.1.3
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/MFHostApp/index-DDl942hP.js +63 -0
- package/components/{index-uQ5qk7MJ.js → index-JO7pb6aB.js} +10 -25
- package/hooks/index.d.ts +0 -1
- package/hooks/useMasterDetail/{index-D4QUQYYc.js → index-B5SssPwx.js} +1 -1
- package/hooks/useModule/{index-FY5nsBmE.js → index-DN7ElPTv.js} +1 -1
- package/index.d.ts +0 -1
- package/index.js +10 -15
- package/layouts/MasterDetailLayout/{index-DeC4RoBs.js → index-1ni-37-Z.js} +69 -64
- package/layouts/ModuleLayout/{index-DAtDuh6s.js → index-r2ZbMqju.js} +24 -56
- package/layouts/NoAuthModuleLayout/{index-CUgDdhzy.js → index-DZtmX8iq.js} +102 -169
- package/m4l_layouts/types.d.ts +0 -1
- package/package.json +1 -1
- package/vite-env.d.ts +3 -3
- package/components/MFHostApp/index-VbXPmijD.js +0 -87
- package/contexts/AuthContext/index-DARkRRM4.js +0 -161
- package/contexts/AuthContext/index.d.ts +0 -5
- package/contexts/AuthContext/types.d.ts +0 -51
- package/contexts/index-l0sNRNKZ.js +0 -1
- package/contexts/index.d.ts +0 -1
- package/hooks/useAuth/index-8hAi3guc.js +0 -10
- package/hooks/useAuth/index.d.ts +0 -2
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { unstable_HistoryRouter } from "react-router-dom";
|
|
3
|
+
import { EnvironmentProvider, HostToolsProvider, NetworkProvider, DomainCountryProvider } from "@m4l/core";
|
|
4
|
+
import { LocalesProvider, HostThemeProvider, ResponsiveContainerProvider, FormatterProvider } from "@m4l/graphics";
|
|
5
|
+
import { BaseModule, WindowToolsMFProvider, DynamicMFParmsProvider, AppearanceComponentProvider } from "@m4l/components";
|
|
6
|
+
import { useTheme } from "@mui/material";
|
|
7
|
+
import { M as MFWindowsTitle } from "../index-JO7pb6aB.js";
|
|
8
|
+
function MFHostApp(props) {
|
|
9
|
+
const {
|
|
10
|
+
children,
|
|
11
|
+
currentLocale,
|
|
12
|
+
hostTheme,
|
|
13
|
+
environment,
|
|
14
|
+
hostTools,
|
|
15
|
+
axiosOperation,
|
|
16
|
+
formatters,
|
|
17
|
+
isAuth = true,
|
|
18
|
+
moduleId,
|
|
19
|
+
moduleNameField,
|
|
20
|
+
skeletonFlags,
|
|
21
|
+
privileges,
|
|
22
|
+
componentsDictionary,
|
|
23
|
+
dynamicMFStore,
|
|
24
|
+
windowTools,
|
|
25
|
+
observedDivRef,
|
|
26
|
+
isAddEditModule = false
|
|
27
|
+
} = props;
|
|
28
|
+
const { generalSettings } = useTheme();
|
|
29
|
+
return /* @__PURE__ */ jsx(EnvironmentProvider, { ...environment, children: /* @__PURE__ */ jsx(HostToolsProvider, { ...hostTools, children: /* @__PURE__ */ jsx(NetworkProvider, { axiosOperation, children: /* @__PURE__ */ jsx(LocalesProvider, { isMicroFrontEnd: true, localeHost: currentLocale, children: /* @__PURE__ */ jsx(
|
|
30
|
+
HostThemeProvider,
|
|
31
|
+
{
|
|
32
|
+
isMicroFrontEnd: true,
|
|
33
|
+
...hostTheme,
|
|
34
|
+
isMobile: generalSettings?.isMobile,
|
|
35
|
+
children: /* @__PURE__ */ jsx(ResponsiveContainerProvider, { observedDivRef, children: /* @__PURE__ */ jsx(unstable_HistoryRouter, { history: hostTools.history, children: /* @__PURE__ */ jsx(
|
|
36
|
+
DomainCountryProvider,
|
|
37
|
+
{
|
|
38
|
+
isMicroFrontEnd: true,
|
|
39
|
+
id: dynamicMFStore?.getState().dynamicMFParameters?.id || 1,
|
|
40
|
+
currency: formatters.currencyFormatter.code,
|
|
41
|
+
currency_decimal_digits: formatters.currencyFormatter.decimalDigits,
|
|
42
|
+
decimal_symbol: formatters.numberFormatter.decimalSymbol,
|
|
43
|
+
thousands_symbol: formatters.numberFormatter.thousandsSymbol,
|
|
44
|
+
children: /* @__PURE__ */ jsx(
|
|
45
|
+
BaseModule,
|
|
46
|
+
{
|
|
47
|
+
isAuth,
|
|
48
|
+
moduleId,
|
|
49
|
+
moduleNameField,
|
|
50
|
+
componentsDictionary,
|
|
51
|
+
skeletonFlags,
|
|
52
|
+
privileges,
|
|
53
|
+
children: /* @__PURE__ */ jsx(FormatterProvider, { isMicroFrontEnd: true, ...formatters, children: /* @__PURE__ */ jsx(WindowToolsMFProvider, { ...windowTools, children: /* @__PURE__ */ jsx(DynamicMFParmsProvider, { store: dynamicMFStore, children: /* @__PURE__ */ jsx(MFWindowsTitle, { isAddEditModule, children: /* @__PURE__ */ jsx(AppearanceComponentProvider, { children }) }) }) }) })
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
) }) })
|
|
58
|
+
}
|
|
59
|
+
) }) }) }) });
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
MFHostApp as M
|
|
63
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
1
2
|
import { DomainCountryProvider } from "@m4l/core";
|
|
2
3
|
import { FormatterProvider, ResponsiveContainerProvider } from "@m4l/graphics";
|
|
3
4
|
import { BaseModule, useSetWindowsTitle } from "@m4l/components";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import { Fragment } from "react";
|
|
6
6
|
function MFNoAuthApp(props) {
|
|
7
7
|
const {
|
|
@@ -22,37 +22,22 @@ function MFNoAuthApp(props) {
|
|
|
22
22
|
decimal_symbol: ".",
|
|
23
23
|
thousands_symbol: ","
|
|
24
24
|
};
|
|
25
|
-
return /* @__PURE__ */ jsx(DomainCountryProvider, {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
children: /* @__PURE__ */ jsx(BaseModule, {
|
|
25
|
+
return /* @__PURE__ */ jsx(DomainCountryProvider, { isMicroFrontEnd: true, ...domianCountry, children: /* @__PURE__ */ jsx(
|
|
26
|
+
BaseModule,
|
|
27
|
+
{
|
|
29
28
|
isAuth,
|
|
30
29
|
moduleId,
|
|
31
30
|
moduleNameField,
|
|
32
31
|
componentsDictionary,
|
|
33
32
|
skeletonFlags,
|
|
34
33
|
privileges,
|
|
35
|
-
children: /* @__PURE__ */ jsx(FormatterProvider, {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
children: /* @__PURE__ */ jsx(ResponsiveContainerProvider, {
|
|
39
|
-
observedDivRef,
|
|
40
|
-
children
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
})
|
|
44
|
-
});
|
|
34
|
+
children: /* @__PURE__ */ jsx(FormatterProvider, { isMicroFrontEnd: true, ...formatters, children: /* @__PURE__ */ jsx(ResponsiveContainerProvider, { observedDivRef, children }) })
|
|
35
|
+
}
|
|
36
|
+
) });
|
|
45
37
|
}
|
|
46
|
-
function MFWindowsTitle({
|
|
47
|
-
isAddEditModule
|
|
48
|
-
children
|
|
49
|
-
}) {
|
|
50
|
-
useSetWindowsTitle({
|
|
51
|
-
isAddEditModule
|
|
52
|
-
});
|
|
53
|
-
return /* @__PURE__ */ jsx(Fragment, {
|
|
54
|
-
children
|
|
55
|
-
});
|
|
38
|
+
function MFWindowsTitle({ isAddEditModule = false, children }) {
|
|
39
|
+
useSetWindowsTitle({ isAddEditModule });
|
|
40
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
56
41
|
}
|
|
57
42
|
export {
|
|
58
43
|
MFWindowsTitle as M,
|
package/hooks/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useContext } from "react";
|
|
2
|
-
import { M as MasterDetailContext } from "../../layouts/MasterDetailLayout/index-
|
|
2
|
+
import { M as MasterDetailContext } from "../../layouts/MasterDetailLayout/index-1ni-37-Z.js";
|
|
3
3
|
const useMasterDetail = () => useContext(MasterDetailContext);
|
|
4
4
|
export {
|
|
5
5
|
useMasterDetail as u
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useContext } from "react";
|
|
2
|
-
import { M as ModuleContext } from "../../layouts/ModuleLayout/index-
|
|
2
|
+
import { M as ModuleContext } from "../../layouts/ModuleLayout/index-r2ZbMqju.js";
|
|
3
3
|
const useModule = () => {
|
|
4
4
|
const context = useContext(ModuleContext);
|
|
5
5
|
if (!context) throw new Error("useModule context must be use inside ModuleContext");
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import { a } from "./components/index-
|
|
2
|
-
import { M } from "./components/MFHostApp/index-
|
|
3
|
-
import {
|
|
4
|
-
import { a as a3, d, g } from "./layouts/
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { u } from "./hooks/
|
|
8
|
-
import { u as u2 } from "./hooks/useAuth/index-8hAi3guc.js";
|
|
9
|
-
import { u as u3 } from "./hooks/useModule/index-FY5nsBmE.js";
|
|
1
|
+
import { a } from "./components/index-JO7pb6aB.js";
|
|
2
|
+
import { M } from "./components/MFHostApp/index-DDl942hP.js";
|
|
3
|
+
import { a as a2, d, g } from "./layouts/ModuleLayout/index-r2ZbMqju.js";
|
|
4
|
+
import { a as a3, d as d2, g as g2 } from "./layouts/MasterDetailLayout/index-1ni-37-Z.js";
|
|
5
|
+
import { N, d as d3, g as g3 } from "./layouts/NoAuthModuleLayout/index-DZtmX8iq.js";
|
|
6
|
+
import { u } from "./hooks/useMasterDetail/index-B5SssPwx.js";
|
|
7
|
+
import { u as u2 } from "./hooks/useModule/index-DN7ElPTv.js";
|
|
10
8
|
export {
|
|
11
|
-
A as AuthContext,
|
|
12
|
-
a2 as AuthProvider,
|
|
13
9
|
M as MFHostApp,
|
|
14
10
|
a as MFNoAuthApp,
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
a3 as MasterDetailLayout,
|
|
12
|
+
a2 as ModuleLayout,
|
|
17
13
|
N as NoAuthModuleLayout,
|
|
18
14
|
d2 as defaultMasterDetailDictionary,
|
|
19
15
|
d as defaultModuleLayoutDictionary,
|
|
@@ -21,7 +17,6 @@ export {
|
|
|
21
17
|
g2 as getMasterDetailLayoutComponentsDictionary,
|
|
22
18
|
g as getModuleLayoutComponentsDictionary,
|
|
23
19
|
g3 as getNoAuthModuleLayoutComponentsDictionary,
|
|
24
|
-
u2 as useAuth,
|
|
25
20
|
u as useMasterDetail,
|
|
26
|
-
|
|
21
|
+
u2 as useModule
|
|
27
22
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
1
2
|
import { createContext, useState, useRef, useMemo, useCallback } from "react";
|
|
2
3
|
import { voidFunction, useEnvironment, useModuleDictionary } from "@m4l/core";
|
|
3
4
|
import { WindowBase, SplitLayout } from "@m4l/components";
|
|
4
|
-
import { a as ModuleLayout, g as getModuleLayoutComponentsDictionary } from "../ModuleLayout/index-
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { a as ModuleLayout, g as getModuleLayoutComponentsDictionary } from "../ModuleLayout/index-r2ZbMqju.js";
|
|
6
6
|
import { useResponsiveDesktop } from "@m4l/graphics";
|
|
7
7
|
import { generateUtilityClasses, generateUtilityClass, styled } from "@mui/material";
|
|
8
8
|
import { unstable_composeClasses } from "@mui/base";
|
|
@@ -13,19 +13,19 @@ const initialState = {
|
|
|
13
13
|
};
|
|
14
14
|
const MasterDetailContext = createContext(initialState);
|
|
15
15
|
function MasterDetailProvider(props) {
|
|
16
|
-
const {
|
|
17
|
-
children,
|
|
18
|
-
onClickViewDetail
|
|
19
|
-
} = props;
|
|
16
|
+
const { children, onClickViewDetail } = props;
|
|
20
17
|
const [masterSelection, setMasterSelection] = useState(void 0);
|
|
21
|
-
return /* @__PURE__ */ jsx(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
return /* @__PURE__ */ jsx(
|
|
19
|
+
MasterDetailContext.Provider,
|
|
20
|
+
{
|
|
21
|
+
value: {
|
|
22
|
+
masterSelection,
|
|
23
|
+
onChangeMasterSelection: setMasterSelection,
|
|
24
|
+
onClickViewDetail
|
|
25
|
+
},
|
|
26
|
+
children
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
29
|
}
|
|
30
30
|
const componentName = "M4LMasterDetailLayout";
|
|
31
31
|
generateUtilityClasses(componentName, [
|
|
@@ -62,44 +62,46 @@ function MasterDetailLayout(props) {
|
|
|
62
62
|
version
|
|
63
63
|
// defaultDictionary,
|
|
64
64
|
} = props;
|
|
65
|
-
const {
|
|
66
|
-
host_static_assets,
|
|
67
|
-
environment_assets
|
|
68
|
-
} = useEnvironment();
|
|
65
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
69
66
|
const [splitPosition, setSplitPosition] = useState("vertical");
|
|
70
67
|
const isDesktop = useResponsiveDesktop();
|
|
71
68
|
const moduleLayoutRef = useRef(null);
|
|
72
|
-
const {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
69
|
+
const { getLabel } = useModuleDictionary();
|
|
70
|
+
const splitActions = useMemo(
|
|
71
|
+
() => [
|
|
72
|
+
{
|
|
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
|
+
{
|
|
83
|
+
urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/split_horizontal.svg`,
|
|
84
|
+
onClick: () => onChangePostionInternal("horizontal"),
|
|
85
|
+
visibility: "main",
|
|
86
|
+
label: getLabel("master_detail_layout.split_horizontal"),
|
|
87
|
+
tag: "horizontal",
|
|
88
|
+
className: "splitactions",
|
|
89
|
+
disabled: splitPosition === "horizontal",
|
|
90
|
+
key: "horizontal"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/no_split.svg`,
|
|
94
|
+
onClick: () => onChangePostionInternal("none"),
|
|
95
|
+
visibility: "main",
|
|
96
|
+
label: getLabel("master_detail_layout.no_split"),
|
|
97
|
+
tag: "none",
|
|
98
|
+
className: "splitactions",
|
|
99
|
+
disabled: splitPosition === "none",
|
|
100
|
+
key: "none"
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
[getLabel, splitPosition]
|
|
104
|
+
);
|
|
103
105
|
const onChangePostionInternal = useCallback((newPostion) => {
|
|
104
106
|
setSplitPosition(newPostion);
|
|
105
107
|
}, []);
|
|
@@ -118,27 +120,30 @@ function MasterDetailLayout(props) {
|
|
|
118
120
|
});
|
|
119
121
|
}, [detailComponent, getLabel]);
|
|
120
122
|
const finalModuleActions = useMemo(() => {
|
|
121
|
-
const actions = getTotalModuleActions(
|
|
123
|
+
const actions = getTotalModuleActions(
|
|
124
|
+
splitActions,
|
|
125
|
+
moduleActions
|
|
126
|
+
);
|
|
122
127
|
return actions;
|
|
123
128
|
}, [splitActions, moduleActions]);
|
|
124
129
|
const classes = useMasterDetailLayoutUtilityClasses();
|
|
125
|
-
return /* @__PURE__ */ jsx(MasterDetailProvider, {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
130
|
+
return /* @__PURE__ */ jsx(MasterDetailProvider, { onClickViewDetail, children: /* @__PURE__ */ jsx(MasterDetailLayoutRoot, { className: classes.root, children: /* @__PURE__ */ jsx(
|
|
131
|
+
ModuleLayout,
|
|
132
|
+
{
|
|
133
|
+
ref: moduleLayoutRef,
|
|
134
|
+
moduleId,
|
|
135
|
+
moduleActions: finalModuleActions,
|
|
136
|
+
version,
|
|
137
|
+
children: /* @__PURE__ */ jsx(
|
|
138
|
+
SplitLayout,
|
|
139
|
+
{
|
|
135
140
|
splitPosition: isDesktop ? splitPosition : "none",
|
|
136
141
|
firstPart: masterComponent,
|
|
137
142
|
secondPart: detailComponent
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
});
|
|
143
|
+
}
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
) }) });
|
|
142
147
|
}
|
|
143
148
|
function getMasterDetailLayoutComponentsDictionary() {
|
|
144
149
|
return ["master_detail_layout"].concat(getModuleLayoutComponentsDictionary());
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
1
2
|
import { useModal, useWindowToolsMF, ModalProvider, getModalDialogComponentsDictionary } from "@m4l/components";
|
|
2
3
|
import { forwardRef, useRef, useImperativeHandle, createContext, useState, useMemo, useEffect } from "react";
|
|
3
4
|
import { styled } from "@mui/material/styles";
|
|
4
5
|
import { generateUtilityClasses, generateUtilityClass } from "@mui/material";
|
|
5
6
|
import { unstable_composeClasses } from "@mui/base";
|
|
6
|
-
|
|
7
|
-
const InnerModuleRoot = styled("div")(({
|
|
8
|
-
theme
|
|
9
|
-
}) => ({
|
|
7
|
+
const InnerModuleRoot = styled("div")(({ theme }) => ({
|
|
10
8
|
...theme.components?.M4LModuleLayout?.styleOverrides
|
|
11
9
|
}));
|
|
12
10
|
const componentName = "M4LModuleLayout";
|
|
@@ -30,43 +28,25 @@ const useModuleLayoutUtilityClasses = () => {
|
|
|
30
28
|
};
|
|
31
29
|
};
|
|
32
30
|
const InnerModule = forwardRef((props, ref) => {
|
|
33
|
-
const {
|
|
34
|
-
|
|
35
|
-
} = props;
|
|
36
|
-
const {
|
|
37
|
-
openModal
|
|
38
|
-
} = useModal();
|
|
31
|
+
const { children } = props;
|
|
32
|
+
const { openModal } = useModal();
|
|
39
33
|
const divRef = useRef(null);
|
|
40
34
|
useImperativeHandle(ref, () => ({
|
|
41
35
|
openModal,
|
|
42
36
|
current: divRef.current
|
|
43
37
|
}));
|
|
44
38
|
const classes = useModuleLayoutUtilityClasses();
|
|
45
|
-
return /* @__PURE__ */ jsx(InnerModuleRoot, {
|
|
46
|
-
className: classes.root,
|
|
47
|
-
ref: divRef,
|
|
48
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
49
|
-
className: classes.moduleContent,
|
|
50
|
-
children
|
|
51
|
-
})
|
|
52
|
-
});
|
|
39
|
+
return /* @__PURE__ */ jsx(InnerModuleRoot, { className: classes.root, ref: divRef, children: /* @__PURE__ */ jsx("div", { className: classes.moduleContent, children }) });
|
|
53
40
|
});
|
|
54
41
|
InnerModule.displayName = "InnerModule";
|
|
55
42
|
const ModuleContext = createContext(null);
|
|
56
43
|
function ModuleProvider(props) {
|
|
57
|
-
const {
|
|
58
|
-
children,
|
|
59
|
-
moduleActions,
|
|
60
|
-
moduleId,
|
|
61
|
-
version
|
|
62
|
-
} = props;
|
|
44
|
+
const { children, moduleActions, moduleId, version } = props;
|
|
63
45
|
const [configOptions] = useState(() => ({
|
|
64
46
|
moduleId,
|
|
65
47
|
dictionary: void 0
|
|
66
48
|
}));
|
|
67
|
-
const {
|
|
68
|
-
setActions
|
|
69
|
-
} = useWindowToolsMF();
|
|
49
|
+
const { setActions } = useWindowToolsMF();
|
|
70
50
|
const [dynamicActions, setDynamicActions] = useState([]);
|
|
71
51
|
const finalModuleActions = useMemo(() => {
|
|
72
52
|
return (moduleActions || []).concat(dynamicActions);
|
|
@@ -74,26 +54,24 @@ function ModuleProvider(props) {
|
|
|
74
54
|
useEffect(() => {
|
|
75
55
|
setActions(finalModuleActions, version);
|
|
76
56
|
}, [finalModuleActions]);
|
|
77
|
-
return /* @__PURE__ */ jsx(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
57
|
+
return /* @__PURE__ */ jsx(
|
|
58
|
+
ModuleContext.Provider,
|
|
59
|
+
{
|
|
60
|
+
value: {
|
|
61
|
+
// moduleActions: finalModuleActions,
|
|
62
|
+
// dynamicActions,
|
|
63
|
+
setDynamicActions,
|
|
64
|
+
moduleId: configOptions.moduleId
|
|
65
|
+
// moduleNameField: configOptions.moduleNameField,
|
|
66
|
+
// urlIcon: configOptions.urlIcon,
|
|
67
|
+
// breadcrumbLinks: configOptions.breadcrumbLinks,
|
|
68
|
+
},
|
|
69
|
+
children
|
|
70
|
+
}
|
|
71
|
+
);
|
|
89
72
|
}
|
|
90
73
|
const ModuleLayout = forwardRef((props, ref) => {
|
|
91
|
-
const {
|
|
92
|
-
moduleId,
|
|
93
|
-
moduleActions,
|
|
94
|
-
version,
|
|
95
|
-
children
|
|
96
|
-
} = props;
|
|
74
|
+
const { moduleId, moduleActions, version, children } = props;
|
|
97
75
|
const moduleRef = useRef(null);
|
|
98
76
|
const openModal = (modalOpenProps) => {
|
|
99
77
|
moduleRef.current?.openModal(modalOpenProps);
|
|
@@ -102,17 +80,7 @@ const ModuleLayout = forwardRef((props, ref) => {
|
|
|
102
80
|
openModal,
|
|
103
81
|
current: moduleRef.current
|
|
104
82
|
}));
|
|
105
|
-
return /* @__PURE__ */ jsx(ModuleProvider, {
|
|
106
|
-
moduleId,
|
|
107
|
-
moduleActions,
|
|
108
|
-
version,
|
|
109
|
-
children: /* @__PURE__ */ jsx(ModalProvider, {
|
|
110
|
-
children: /* @__PURE__ */ jsx(InnerModule, {
|
|
111
|
-
ref: moduleRef,
|
|
112
|
-
children
|
|
113
|
-
})
|
|
114
|
-
})
|
|
115
|
-
});
|
|
83
|
+
return /* @__PURE__ */ jsx(ModuleProvider, { moduleId, moduleActions, version, children: /* @__PURE__ */ jsx(ModalProvider, { children: /* @__PURE__ */ jsx(InnerModule, { ref: moduleRef, children }) }) });
|
|
116
84
|
});
|
|
117
85
|
ModuleLayout.displayName = "ModuleLayout";
|
|
118
86
|
function getModuleLayoutComponentsDictionary() {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
1
2
|
import { useResponsiveDesktop, useLocales, ResponsiveContainerProvider } from "@m4l/graphics";
|
|
2
3
|
import { LanguagePopover, Image, Typography, Stack, ScrollBar, HelmetPage } from "@m4l/components";
|
|
3
4
|
import { styled } from "@mui/material";
|
|
4
5
|
import { useBase, useModuleDictionary, useDomain, useEnvironment, BaseProvider, FlagsProvider, ModuleDictionaryProvider, ModuleSkeletonProvider } from "@m4l/core";
|
|
5
6
|
import { styled as styled$1, alpha } from "@mui/material/styles";
|
|
6
|
-
|
|
7
|
-
const InnerModuleRoot = styled("div")(({
|
|
8
|
-
theme
|
|
9
|
-
}) => ({
|
|
7
|
+
const InnerModuleRoot = styled("div")(({ theme }) => ({
|
|
10
8
|
display: "flex",
|
|
11
9
|
justifyContent: "center",
|
|
12
10
|
alignItems: "center",
|
|
@@ -122,77 +120,46 @@ styled$1("div")(() => ({
|
|
|
122
120
|
alignItems: "center"
|
|
123
121
|
}));
|
|
124
122
|
const DesktopContent = () => {
|
|
125
|
-
const {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
children: getLabel("company_name_subtitle")
|
|
156
|
-
})]
|
|
157
|
-
}), /* @__PURE__ */ jsxs(CompanyLeyend, {
|
|
158
|
-
children: [/* @__PURE__ */ jsx(Typography, {
|
|
159
|
-
variant: "h5",
|
|
160
|
-
skeletonWidth: "50%",
|
|
161
|
-
skeletongHeight: "36px",
|
|
162
|
-
children: getLabel("module_leyend")
|
|
163
|
-
}), /* @__PURE__ */ jsx(Typography, {
|
|
164
|
-
variant: "subtitle",
|
|
165
|
-
skeletonWidth: "80%",
|
|
166
|
-
skeletongHeight: "24px",
|
|
167
|
-
children: slogan
|
|
168
|
-
})]
|
|
169
|
-
})]
|
|
170
|
-
}), /* @__PURE__ */ jsx(WrapperFormContent$1, {
|
|
171
|
-
children: /* @__PURE__ */ jsxs(FormContent$1, {
|
|
172
|
-
children: [/* @__PURE__ */ jsxs(ContainerModuleName$1, {
|
|
173
|
-
children: [/* @__PURE__ */ jsx(Typography, {
|
|
174
|
-
variant: "h5",
|
|
175
|
-
skeletonWidth: "20%",
|
|
176
|
-
skeletongHeight: "36px",
|
|
177
|
-
children: getLabel("module_name")
|
|
178
|
-
}), /* @__PURE__ */ jsx(Typography, {
|
|
123
|
+
const { children, companyLogoSmallUrl } = useBase();
|
|
124
|
+
const { getLabel } = useModuleDictionary();
|
|
125
|
+
const { name, slogan } = useDomain();
|
|
126
|
+
return /* @__PURE__ */ jsxs(DesktopContentRoot, { children: [
|
|
127
|
+
/* @__PURE__ */ jsx(LanguagePopover, {}),
|
|
128
|
+
/* @__PURE__ */ jsxs(DesktopBanner, { children: [
|
|
129
|
+
/* @__PURE__ */ jsx(ContainerLogo$1, { children: /* @__PURE__ */ jsx(Image, { src: companyLogoSmallUrl, ratio: "1:1", width: "64px", height: "64px" }) }),
|
|
130
|
+
/* @__PURE__ */ jsxs(CompanyName$1, { children: [
|
|
131
|
+
/* @__PURE__ */ jsx(
|
|
132
|
+
Typography,
|
|
133
|
+
{
|
|
134
|
+
variant: "subtitleDens",
|
|
135
|
+
skeletonWidth: "70%",
|
|
136
|
+
skeletongHeight: "24px",
|
|
137
|
+
children: name
|
|
138
|
+
}
|
|
139
|
+
),
|
|
140
|
+
/* @__PURE__ */ jsx(Typography, { variant: "paragraph", skeletonWidth: "40%", skeletongHeight: "20px", children: getLabel("company_name_subtitle") })
|
|
141
|
+
] }),
|
|
142
|
+
/* @__PURE__ */ jsxs(CompanyLeyend, { children: [
|
|
143
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h5", skeletonWidth: "50%", skeletongHeight: "36px", children: getLabel("module_leyend") }),
|
|
144
|
+
/* @__PURE__ */ jsx(Typography, { variant: "subtitle", skeletonWidth: "80%", skeletongHeight: "24px", children: slogan })
|
|
145
|
+
] })
|
|
146
|
+
] }),
|
|
147
|
+
/* @__PURE__ */ jsx(WrapperFormContent$1, { children: /* @__PURE__ */ jsxs(FormContent$1, { children: [
|
|
148
|
+
/* @__PURE__ */ jsxs(ContainerModuleName$1, { children: [
|
|
149
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h5", skeletonWidth: "20%", skeletongHeight: "36px", children: getLabel("module_name") }),
|
|
150
|
+
/* @__PURE__ */ jsx(
|
|
151
|
+
Typography,
|
|
152
|
+
{
|
|
179
153
|
variant: "paragraph",
|
|
180
154
|
skeletonWidth: "40%",
|
|
181
155
|
skeletongHeight: "20px",
|
|
182
156
|
children: getLabel("module_description")
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
children
|
|
190
|
-
})
|
|
191
|
-
})
|
|
192
|
-
})]
|
|
193
|
-
})
|
|
194
|
-
})]
|
|
195
|
-
});
|
|
157
|
+
}
|
|
158
|
+
)
|
|
159
|
+
] }),
|
|
160
|
+
/* @__PURE__ */ jsx(Stack, { direction: "column", height: "auto", children: /* @__PURE__ */ jsx(ScrollBar, { children: /* @__PURE__ */ jsx(Fragment, { children }) }) })
|
|
161
|
+
] }) })
|
|
162
|
+
] });
|
|
196
163
|
};
|
|
197
164
|
const MobileContentRoot = styled$1("div")(({ theme }) => ({
|
|
198
165
|
display: "flex",
|
|
@@ -281,77 +248,48 @@ const ContainerModuleName = styled$1("div")(() => ({
|
|
|
281
248
|
gap: "4px"
|
|
282
249
|
}));
|
|
283
250
|
const MobileContent = () => {
|
|
284
|
-
const {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
children
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
children: [/* @__PURE__ */ jsx(Typography, {
|
|
321
|
-
variant: "h5",
|
|
322
|
-
skeletonWidth: "20%",
|
|
323
|
-
skeletongHeight: "36px",
|
|
324
|
-
children: getLabel("module_name")
|
|
325
|
-
}), /* @__PURE__ */ jsx(Typography, {
|
|
326
|
-
variant: "paragraph",
|
|
327
|
-
skeletonWidth: "40%",
|
|
328
|
-
skeletongHeight: "20px",
|
|
329
|
-
children: getLabel("module_description")
|
|
330
|
-
})]
|
|
331
|
-
}), children]
|
|
332
|
-
})
|
|
333
|
-
})
|
|
334
|
-
})]
|
|
335
|
-
});
|
|
251
|
+
const { children, companyLogoSmallUrl } = useBase();
|
|
252
|
+
const { getLabel } = useModuleDictionary();
|
|
253
|
+
const { name } = useDomain();
|
|
254
|
+
return /* @__PURE__ */ jsxs(MobileContentRoot, { children: [
|
|
255
|
+
/* @__PURE__ */ jsxs(MobileBanner, { children: [
|
|
256
|
+
/* @__PURE__ */ jsx(ContainerLogo, { children: /* @__PURE__ */ jsx(Image, { src: companyLogoSmallUrl, ratio: "1:1", width: "44px", height: "44px" }) }),
|
|
257
|
+
/* @__PURE__ */ jsxs(CompanyName, { children: [
|
|
258
|
+
/* @__PURE__ */ jsx(
|
|
259
|
+
Typography,
|
|
260
|
+
{
|
|
261
|
+
variant: "subtitleDens",
|
|
262
|
+
skeletonWidth: "70%",
|
|
263
|
+
skeletongHeight: "24px",
|
|
264
|
+
children: name
|
|
265
|
+
}
|
|
266
|
+
),
|
|
267
|
+
/* @__PURE__ */ jsx(Typography, { variant: "paragraph", skeletonWidth: "40%", skeletongHeight: "20px", children: getLabel("company_name_subtitle") })
|
|
268
|
+
] }),
|
|
269
|
+
/* @__PURE__ */ jsx(LanguagePopover, {})
|
|
270
|
+
] }),
|
|
271
|
+
/* @__PURE__ */ jsx(WrapperFormContent, { children: /* @__PURE__ */ jsx(ScrollBar, { children: /* @__PURE__ */ jsxs(FormContent, { children: [
|
|
272
|
+
/* @__PURE__ */ jsxs(ContainerModuleName, { children: [
|
|
273
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h5", skeletonWidth: "20%", skeletongHeight: "36px", children: getLabel("module_name") }),
|
|
274
|
+
/* @__PURE__ */ jsx(
|
|
275
|
+
Typography,
|
|
276
|
+
{
|
|
277
|
+
variant: "paragraph",
|
|
278
|
+
skeletonWidth: "40%",
|
|
279
|
+
skeletongHeight: "20px",
|
|
280
|
+
children: getLabel("module_description")
|
|
281
|
+
}
|
|
282
|
+
)
|
|
283
|
+
] }),
|
|
284
|
+
children
|
|
285
|
+
] }) }) })
|
|
286
|
+
] });
|
|
336
287
|
};
|
|
337
288
|
const InnerModule = () => {
|
|
338
|
-
const {
|
|
339
|
-
getModuleLabel
|
|
340
|
-
} = useModuleDictionary();
|
|
289
|
+
const { getModuleLabel } = useModuleDictionary();
|
|
341
290
|
const isDesktop = useResponsiveDesktop();
|
|
342
|
-
const {
|
|
343
|
-
|
|
344
|
-
} = useBase();
|
|
345
|
-
return /* @__PURE__ */ jsx(HelmetPage, {
|
|
346
|
-
title: getModuleLabel(),
|
|
347
|
-
subtitle,
|
|
348
|
-
children: /* @__PURE__ */ jsx(Fragment, {
|
|
349
|
-
children: /* @__PURE__ */ jsx(InnerModuleRoot, {
|
|
350
|
-
id: "modulerootnouth",
|
|
351
|
-
children: isDesktop ? /* @__PURE__ */ jsx(DesktopContent, {}) : /* @__PURE__ */ jsx(MobileContent, {})
|
|
352
|
-
})
|
|
353
|
-
})
|
|
354
|
-
});
|
|
291
|
+
const { subtitle } = useBase();
|
|
292
|
+
return /* @__PURE__ */ jsx(HelmetPage, { title: getModuleLabel(), subtitle, children: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(InnerModuleRoot, { id: "modulerootnouth", children: isDesktop ? /* @__PURE__ */ jsx(DesktopContent, {}) : /* @__PURE__ */ jsx(MobileContent, {}) }) }) });
|
|
355
293
|
};
|
|
356
294
|
const NoAuthModuleLayout = (props) => {
|
|
357
295
|
const {
|
|
@@ -367,10 +305,7 @@ const NoAuthModuleLayout = (props) => {
|
|
|
367
305
|
handleSetting,
|
|
368
306
|
observedDivRef
|
|
369
307
|
} = props;
|
|
370
|
-
const {
|
|
371
|
-
host_static_assets,
|
|
372
|
-
environment_assets
|
|
373
|
-
} = useEnvironment();
|
|
308
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
374
309
|
const localeString = useLocales().currentLocale?.localeString;
|
|
375
310
|
const finalCompanyLogoNormalUrl = companyLogoNormalUrl || `${host_static_assets}/${environment_assets}/frontend/commons/assets/icons/logotipo_m4l.svg`;
|
|
376
311
|
const finalCompanyLogoSmallUrl = companyLogoSmallUrl || `${host_static_assets}/${environment_assets}/frontend/commons/assets/icons/isotipo_m4l.svg`;
|
|
@@ -379,32 +314,30 @@ const NoAuthModuleLayout = (props) => {
|
|
|
379
314
|
if (finalSkeletonFlags.findIndex((f) => f === "dictionary_loaded") < 0) {
|
|
380
315
|
finalSkeletonFlags.push("dictionary_loaded");
|
|
381
316
|
}
|
|
382
|
-
return /* @__PURE__ */ jsx(
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
})
|
|
407
|
-
});
|
|
317
|
+
return /* @__PURE__ */ jsx(
|
|
318
|
+
BaseProvider,
|
|
319
|
+
{
|
|
320
|
+
value: {
|
|
321
|
+
subtitle,
|
|
322
|
+
companyLogoSmallUrl: finalCompanyLogoSmallUrl,
|
|
323
|
+
companyLogoNormalUrl: finalCompanyLogoNormalUrl,
|
|
324
|
+
moduleIlustrationUrl: finalIllustrationUrl,
|
|
325
|
+
children,
|
|
326
|
+
handleSetting
|
|
327
|
+
},
|
|
328
|
+
children: /* @__PURE__ */ jsx(FlagsProvider, { children: /* @__PURE__ */ jsx(
|
|
329
|
+
ModuleDictionaryProvider,
|
|
330
|
+
{
|
|
331
|
+
isAuth: false,
|
|
332
|
+
moduleId,
|
|
333
|
+
moduleNameField,
|
|
334
|
+
componentsDictionary,
|
|
335
|
+
currentLang: localeString,
|
|
336
|
+
children: /* @__PURE__ */ jsx(ModuleSkeletonProvider, { flags: finalSkeletonFlags, children: /* @__PURE__ */ jsx(ResponsiveContainerProvider, { observedDivRef, children: /* @__PURE__ */ jsx(InnerModule, {}) }) })
|
|
337
|
+
}
|
|
338
|
+
) })
|
|
339
|
+
}
|
|
340
|
+
);
|
|
408
341
|
};
|
|
409
342
|
function getNoAuthModuleLayoutComponentsDictionary() {
|
|
410
343
|
return ["no_auth_module_layout"];
|
package/m4l_layouts/types.d.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
package/package.json
CHANGED
package/vite-env.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
|
2
|
-
/// <reference types="vitest" />
|
|
3
|
-
/// <reference types="vitest/importMeta" />
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
/// <reference types="vitest" />
|
|
3
|
+
/// <reference types="vitest/importMeta" />
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { unstable_HistoryRouter } from "react-router-dom";
|
|
2
|
-
import { EnvironmentProvider, HostToolsProvider, NetworkProvider, DomainCountryProvider } from "@m4l/core";
|
|
3
|
-
import { LocalesProvider, HostThemeProvider, ResponsiveContainerProvider, FormatterProvider } from "@m4l/graphics";
|
|
4
|
-
import { BaseModule, WindowToolsMFProvider, DynamicMFParmsProvider, AppearanceComponentProvider } from "@m4l/components";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
import { M as MFWindowsTitle } from "../index-uQ5qk7MJ.js";
|
|
7
|
-
function MFHostApp(props) {
|
|
8
|
-
const {
|
|
9
|
-
children,
|
|
10
|
-
currentLocale,
|
|
11
|
-
hostTheme,
|
|
12
|
-
environment,
|
|
13
|
-
hostTools,
|
|
14
|
-
axiosOperation,
|
|
15
|
-
formatters,
|
|
16
|
-
isAuth = true,
|
|
17
|
-
moduleId,
|
|
18
|
-
moduleNameField,
|
|
19
|
-
skeletonFlags,
|
|
20
|
-
privileges,
|
|
21
|
-
componentsDictionary,
|
|
22
|
-
dynamicMFStore,
|
|
23
|
-
windowTools,
|
|
24
|
-
observedDivRef,
|
|
25
|
-
isAddEditModule = false
|
|
26
|
-
} = props;
|
|
27
|
-
const hostIsMobile = hostTheme.hostThemeOptions.generalSettings.isMobile;
|
|
28
|
-
return /* @__PURE__ */ jsx(EnvironmentProvider, {
|
|
29
|
-
...environment,
|
|
30
|
-
children: /* @__PURE__ */ jsx(HostToolsProvider, {
|
|
31
|
-
...hostTools,
|
|
32
|
-
children: /* @__PURE__ */ jsx(NetworkProvider, {
|
|
33
|
-
axiosOperation,
|
|
34
|
-
children: /* @__PURE__ */ jsx(LocalesProvider, {
|
|
35
|
-
isMicroFrontEnd: true,
|
|
36
|
-
localeHost: currentLocale,
|
|
37
|
-
children: /* @__PURE__ */ jsx(HostThemeProvider, {
|
|
38
|
-
isMicroFrontEnd: true,
|
|
39
|
-
...hostTheme,
|
|
40
|
-
isMobile: hostIsMobile,
|
|
41
|
-
children: /* @__PURE__ */ jsx(ResponsiveContainerProvider, {
|
|
42
|
-
observedDivRef,
|
|
43
|
-
children: /* @__PURE__ */ jsx(unstable_HistoryRouter, {
|
|
44
|
-
history: hostTools.history,
|
|
45
|
-
children: /* @__PURE__ */ jsx(DomainCountryProvider, {
|
|
46
|
-
isMicroFrontEnd: true,
|
|
47
|
-
id: dynamicMFStore?.getState().dynamicMFParameters?.id || 1,
|
|
48
|
-
currency: formatters.currencyFormatter.code,
|
|
49
|
-
currency_decimal_digits: formatters.currencyFormatter.decimalDigits,
|
|
50
|
-
decimal_symbol: formatters.numberFormatter.decimalSymbol,
|
|
51
|
-
thousands_symbol: formatters.numberFormatter.thousandsSymbol,
|
|
52
|
-
children: /* @__PURE__ */ jsx(BaseModule, {
|
|
53
|
-
isAuth,
|
|
54
|
-
moduleId,
|
|
55
|
-
moduleNameField,
|
|
56
|
-
componentsDictionary,
|
|
57
|
-
skeletonFlags,
|
|
58
|
-
privileges,
|
|
59
|
-
children: /* @__PURE__ */ jsx(FormatterProvider, {
|
|
60
|
-
isMicroFrontEnd: true,
|
|
61
|
-
...formatters,
|
|
62
|
-
children: /* @__PURE__ */ jsx(WindowToolsMFProvider, {
|
|
63
|
-
...windowTools,
|
|
64
|
-
children: /* @__PURE__ */ jsx(DynamicMFParmsProvider, {
|
|
65
|
-
store: dynamicMFStore,
|
|
66
|
-
children: /* @__PURE__ */ jsx(MFWindowsTitle, {
|
|
67
|
-
isAddEditModule,
|
|
68
|
-
children: /* @__PURE__ */ jsx(AppearanceComponentProvider, {
|
|
69
|
-
children
|
|
70
|
-
})
|
|
71
|
-
})
|
|
72
|
-
})
|
|
73
|
-
})
|
|
74
|
-
})
|
|
75
|
-
})
|
|
76
|
-
})
|
|
77
|
-
})
|
|
78
|
-
})
|
|
79
|
-
})
|
|
80
|
-
})
|
|
81
|
-
})
|
|
82
|
-
})
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
export {
|
|
86
|
-
MFHostApp as M
|
|
87
|
-
};
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { createContext, useReducer, useEffect } from "react";
|
|
2
|
-
import { useHostTools, useNetwork, useEnvironment, useLocalStorageWithListener, EmitEvents, getLocalStorage, setLocalStorage } from "@m4l/core";
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
var EnumTypes = /* @__PURE__ */ ((EnumTypes2) => {
|
|
5
|
-
EnumTypes2["Initial"] = "INITIALIZE";
|
|
6
|
-
EnumTypes2["Login"] = "LOGIN";
|
|
7
|
-
EnumTypes2["Logout"] = "LOGOUT";
|
|
8
|
-
return EnumTypes2;
|
|
9
|
-
})(EnumTypes || {});
|
|
10
|
-
const initialState = {
|
|
11
|
-
isAuthenticated: false,
|
|
12
|
-
isInitialized: false,
|
|
13
|
-
user: null
|
|
14
|
-
};
|
|
15
|
-
const JWTReducer = (state, action) => {
|
|
16
|
-
switch (action.type) {
|
|
17
|
-
case "INITIALIZE":
|
|
18
|
-
return {
|
|
19
|
-
isAuthenticated: action.payload.isAuthenticated,
|
|
20
|
-
isInitialized: true,
|
|
21
|
-
user: action.payload.user
|
|
22
|
-
};
|
|
23
|
-
case "LOGIN":
|
|
24
|
-
return {
|
|
25
|
-
...state,
|
|
26
|
-
isAuthenticated: true,
|
|
27
|
-
user: action.payload.user
|
|
28
|
-
};
|
|
29
|
-
case "LOGOUT":
|
|
30
|
-
return {
|
|
31
|
-
...state,
|
|
32
|
-
isAuthenticated: false,
|
|
33
|
-
user: null
|
|
34
|
-
};
|
|
35
|
-
default:
|
|
36
|
-
return state;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
const AuthContext = createContext(null);
|
|
40
|
-
function dispatchInitial(dispatch) {
|
|
41
|
-
dispatch({
|
|
42
|
-
type: EnumTypes.Initial,
|
|
43
|
-
payload: {
|
|
44
|
-
isAuthenticated: false,
|
|
45
|
-
user: null
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
function AuthProvider(props) {
|
|
50
|
-
const {
|
|
51
|
-
children
|
|
52
|
-
} = props;
|
|
53
|
-
const [state, dispatch] = useReducer(JWTReducer, initialState);
|
|
54
|
-
const {
|
|
55
|
-
events_add_listener
|
|
56
|
-
} = useHostTools();
|
|
57
|
-
const {
|
|
58
|
-
networkOperation
|
|
59
|
-
} = useNetwork();
|
|
60
|
-
const {
|
|
61
|
-
domain_token
|
|
62
|
-
} = useEnvironment();
|
|
63
|
-
const [nextValSession, setNextValSession] = useLocalStorageWithListener(
|
|
64
|
-
//Variable para saber si ha cambiado la session en otro navegador
|
|
65
|
-
"vSession",
|
|
66
|
-
(/* @__PURE__ */ new Date()).getTime() + ""
|
|
67
|
-
);
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
const initialize = async () => {
|
|
70
|
-
networkOperation({
|
|
71
|
-
method: "GET",
|
|
72
|
-
endPoint: `auth/login`,
|
|
73
|
-
parms: {
|
|
74
|
-
user_data: true
|
|
75
|
-
},
|
|
76
|
-
checkUnAuthorized: false
|
|
77
|
-
}).then((response) => {
|
|
78
|
-
dispatch({
|
|
79
|
-
type: EnumTypes.Initial,
|
|
80
|
-
payload: {
|
|
81
|
-
isAuthenticated: true,
|
|
82
|
-
user: response.user
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
const useSaved = getLocalStorage("userData", {
|
|
86
|
-
email: response.user.email,
|
|
87
|
-
remember: true
|
|
88
|
-
});
|
|
89
|
-
if (useSaved?.email !== response.user.email) {
|
|
90
|
-
setLocalStorage("userData", {
|
|
91
|
-
email: response.user.email
|
|
92
|
-
}, true);
|
|
93
|
-
}
|
|
94
|
-
}).catch(() => {
|
|
95
|
-
dispatchInitial(dispatch);
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
initialize();
|
|
99
|
-
}, [nextValSession]);
|
|
100
|
-
const login = async (email, password, remember) => {
|
|
101
|
-
await networkOperation({
|
|
102
|
-
endPoint: `auth/login`,
|
|
103
|
-
method: "POST",
|
|
104
|
-
data: {
|
|
105
|
-
email,
|
|
106
|
-
password,
|
|
107
|
-
domain_token
|
|
108
|
-
}
|
|
109
|
-
}).then((response) => {
|
|
110
|
-
const user = response.data;
|
|
111
|
-
if (remember) {
|
|
112
|
-
setLocalStorage("userData", {
|
|
113
|
-
email,
|
|
114
|
-
remember
|
|
115
|
-
});
|
|
116
|
-
} else {
|
|
117
|
-
setLocalStorage("userData", {
|
|
118
|
-
email: "",
|
|
119
|
-
remember
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
dispatch({
|
|
123
|
-
type: EnumTypes.Login,
|
|
124
|
-
payload: {
|
|
125
|
-
user
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
setNextValSession((/* @__PURE__ */ new Date()).getTime() + "");
|
|
129
|
-
});
|
|
130
|
-
};
|
|
131
|
-
const logout = async (isAuthenticated) => {
|
|
132
|
-
if (isAuthenticated) {
|
|
133
|
-
await networkOperation({
|
|
134
|
-
endPoint: `auth/logout`,
|
|
135
|
-
method: "POST"
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
dispatch({
|
|
139
|
-
type: EnumTypes.Logout
|
|
140
|
-
});
|
|
141
|
-
setNextValSession((/* @__PURE__ */ new Date()).getTime() + "");
|
|
142
|
-
};
|
|
143
|
-
const onNetserviceUnautorized = () => {
|
|
144
|
-
logout(false);
|
|
145
|
-
};
|
|
146
|
-
useEffect(() => {
|
|
147
|
-
events_add_listener(EmitEvents.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED, onNetserviceUnautorized);
|
|
148
|
-
}, []);
|
|
149
|
-
return /* @__PURE__ */ jsx(AuthContext.Provider, {
|
|
150
|
-
value: {
|
|
151
|
-
...state,
|
|
152
|
-
login,
|
|
153
|
-
logout
|
|
154
|
-
},
|
|
155
|
-
children
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
export {
|
|
159
|
-
AuthContext as A,
|
|
160
|
-
AuthProvider as a
|
|
161
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { AuthProviderProps, SessionContextType } from './types';
|
|
3
|
-
declare const AuthContext: import("react").Context<SessionContextType | null>;
|
|
4
|
-
declare function AuthProvider(props: AuthProviderProps): import("react").JSX.Element;
|
|
5
|
-
export { AuthContext, AuthProvider };
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { DomainCountry, Maybe } from '@m4l/core';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
export declare enum EnumTypes {
|
|
4
|
-
Initial = "INITIALIZE",
|
|
5
|
-
Login = "LOGIN",
|
|
6
|
-
Logout = "LOGOUT"
|
|
7
|
-
}
|
|
8
|
-
export declare type AuthProviderProps = {
|
|
9
|
-
children: ReactNode;
|
|
10
|
-
};
|
|
11
|
-
export declare type ActionMap<M extends {
|
|
12
|
-
[index: string]: any;
|
|
13
|
-
}> = {
|
|
14
|
-
[Key in keyof M]: M[Key] extends undefined ? {
|
|
15
|
-
type: Key;
|
|
16
|
-
} : {
|
|
17
|
-
type: Key;
|
|
18
|
-
payload: M[Key];
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
export declare type SessionAuthPayload = {
|
|
22
|
-
[EnumTypes.Initial]: {
|
|
23
|
-
isAuthenticated: boolean;
|
|
24
|
-
user: AuthUser;
|
|
25
|
-
};
|
|
26
|
-
[EnumTypes.Login]: {
|
|
27
|
-
user: AuthUser;
|
|
28
|
-
};
|
|
29
|
-
[EnumTypes.Logout]: undefined;
|
|
30
|
-
};
|
|
31
|
-
export declare type SessionActions = ActionMap<SessionAuthPayload>[keyof ActionMap<SessionAuthPayload>];
|
|
32
|
-
export interface User {
|
|
33
|
-
email: string;
|
|
34
|
-
id: number;
|
|
35
|
-
first_name: string;
|
|
36
|
-
last_name: string;
|
|
37
|
-
account_id: number;
|
|
38
|
-
domain_country: DomainCountry;
|
|
39
|
-
avatar_url?: Maybe<string>;
|
|
40
|
-
user_type_id?: number;
|
|
41
|
-
}
|
|
42
|
-
export declare type AuthUser = Maybe<User>;
|
|
43
|
-
export declare type AuthState = {
|
|
44
|
-
isAuthenticated: boolean;
|
|
45
|
-
isInitialized: boolean;
|
|
46
|
-
user: AuthUser;
|
|
47
|
-
};
|
|
48
|
-
export interface SessionContextType extends AuthState {
|
|
49
|
-
login: (email: string, password: string, remember: boolean) => object | undefined;
|
|
50
|
-
logout: (isAuthenticated: boolean) => Promise<void>;
|
|
51
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
package/contexts/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './AuthContext';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
import { A as AuthContext } from "../../contexts/AuthContext/index-DARkRRM4.js";
|
|
3
|
-
const useAuth = () => {
|
|
4
|
-
const context = useContext(AuthContext);
|
|
5
|
-
if (!context) throw new Error("Auth context must be use inside AuthProvider");
|
|
6
|
-
return context;
|
|
7
|
-
};
|
|
8
|
-
export {
|
|
9
|
-
useAuth as u
|
|
10
|
-
};
|
package/hooks/useAuth/index.d.ts
DELETED