@m4l/layouts 6.0.0 → 7.0.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/@types/index.d.ts +7 -0
- package/components/MFHostApp/index.d.ts +9 -3
- package/components/MFHostApp/index.js +60 -0
- package/components/MFHostApp/types.d.ts +3 -4
- package/components/MFNoAuthApp/index.d.ts +8 -2
- package/components/MFNoAuthApp/index.js +39 -0
- package/components/MFWindowsTitle/MFWindowsTitle.d.ts +9 -3
- package/components/MFWindowsTitle/MFWindowsTitle.js +10 -0
- package/contexts/AuthContext/index.d.ts +10 -4
- package/contexts/AuthContext/{index-DARkRRM4.js → index.js} +26 -45
- package/contexts/AuthContext/types.d.ts +6 -6
- package/contexts/AuthContext/types.js +9 -0
- package/{m4l_layouts/types.d.ts → hooks/index.js} +1 -1
- package/hooks/useAuth/index.d.ts +8 -1
- package/hooks/useAuth/{index-8hAi3guc.js → index.js} +4 -2
- package/hooks/useMasterDetail/index.d.ts +1 -1
- package/hooks/useMasterDetail/{index-D4QUQYYc.js → index.js} +1 -1
- package/hooks/useModule/index.d.ts +8 -1
- package/hooks/useModule/index.js +12 -0
- package/index.js +17 -14
- package/layouts/MasterDetailLayout/MasterDetailLayout.d.ts +9 -3
- package/layouts/MasterDetailLayout/MasterDetailLayout.js +110 -0
- package/layouts/MasterDetailLayout/classes/constants.js +4 -0
- package/layouts/MasterDetailLayout/classes/index.d.ts +8 -1
- package/layouts/MasterDetailLayout/classes/index.js +23 -0
- package/layouts/MasterDetailLayout/classes/types.d.ts +3 -3
- package/layouts/MasterDetailLayout/components/ButtonDetail/index.d.ts +9 -0
- package/layouts/MasterDetailLayout/contexts/MasterDetailContext/index.d.ts +9 -3
- package/layouts/MasterDetailLayout/contexts/MasterDetailContext/index.js +28 -0
- package/layouts/MasterDetailLayout/contexts/MasterDetailContext/types.d.ts +1 -1
- package/layouts/MasterDetailLayout/dicctionary.d.ts +1 -1
- package/layouts/MasterDetailLayout/dicctionary.js +17 -0
- package/layouts/MasterDetailLayout/index.d.ts +2 -0
- package/layouts/MasterDetailLayout/styles.d.ts +1 -2
- package/layouts/MasterDetailLayout/styles.js +7 -0
- package/layouts/ModuleLayout/ModuleLayout.d.ts +2 -3
- package/layouts/ModuleLayout/ModuleLayout.js +21 -0
- package/layouts/ModuleLayout/classes/constants.js +4 -0
- package/layouts/ModuleLayout/classes/index.d.ts +7 -0
- package/layouts/ModuleLayout/classes/index.js +25 -0
- package/layouts/ModuleLayout/classes/types.d.ts +3 -3
- package/layouts/ModuleLayout/contexts/ModuleContext/index.d.ts +9 -3
- package/layouts/ModuleLayout/contexts/ModuleContext/index.js +38 -0
- package/layouts/ModuleLayout/contexts/ModuleContext/types.d.ts +1 -1
- package/layouts/ModuleLayout/dicctionary.d.ts +1 -1
- package/layouts/ModuleLayout/dicctionary.js +11 -0
- package/layouts/ModuleLayout/index.d.ts +2 -0
- package/layouts/ModuleLayout/subcomponents/InnerModule/index.d.ts +1 -2
- package/layouts/ModuleLayout/subcomponents/InnerModule/index.js +20 -0
- package/layouts/ModuleLayout/subcomponents/InnerModule/styles.d.ts +1 -2
- package/layouts/ModuleLayout/subcomponents/InnerModule/styles.js +7 -0
- package/layouts/ModuleLayout/subcomponents/InnerModule/types.d.ts +1 -1
- package/layouts/ModuleLayout/types.d.ts +4 -4
- package/layouts/NoAuthModuleLayout/dicctionary.d.ts +1 -1
- package/layouts/NoAuthModuleLayout/dicctionary.js +10 -0
- package/layouts/NoAuthModuleLayout/index.d.ts +8 -2
- package/layouts/NoAuthModuleLayout/index.js +55 -0
- package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/index.d.ts +8 -2
- package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/index.js +16 -0
- package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/styles.d.ts +1 -2
- package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/styles.js +15 -0
- package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/DesktopContent/index.d.ts +8 -2
- package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/DesktopContent/index.js +49 -0
- package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/DesktopContent/styles.d.ts +9 -10
- package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/DesktopContent/styles.js +115 -0
- package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/MobileContent/index.d.ts +8 -2
- package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/MobileContent/index.js +45 -0
- package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/MobileContent/styles.d.ts +8 -9
- package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/MobileContent/styles.js +96 -0
- package/layouts/NoAuthModuleLayout/types.d.ts +1 -1
- package/layouts/index.js +1 -0
- package/package.json +33 -14
- package/test/setup.d.ts +0 -0
- package/test/utils.d.ts +12 -0
- package/vite-env.d.ts +3 -3
- package/components/MFHostApp/index-Bz3RUvvY.js +0 -90
- package/components/index-uQ5qk7MJ.js +0 -60
- package/hooks/useModule/index-FY5nsBmE.js +0 -10
- package/layouts/MasterDetailLayout/index-DeC4RoBs.js +0 -160
- package/layouts/ModuleLayout/index-DAtDuh6s.js +0 -129
- package/layouts/NoAuthModuleLayout/index-txgn4T5B.js +0 -419
- /package/{contexts/index-l0sNRNKZ.js → components/MFWindowsTitle/index.js} +0 -0
- /package/{hooks/index-l0sNRNKZ.js → components/index.js} +0 -0
- /package/{layouts/index-l0sNRNKZ.js → contexts/index.js} +0 -0
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { MFHostAppProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Componente que envuelve la aplicación de un microfrontend
|
|
4
|
+
* @author Juan Escobar - automatic
|
|
5
|
+
* @createdAt 2024-10-09 19:56:26 - automatic
|
|
6
|
+
* @updatedAt 2024-10-09 20:00:30 - automatic
|
|
7
|
+
* @updatedUser Juan Escobar - automatic
|
|
8
|
+
*/
|
|
9
|
+
export declare function MFHostApp(props: MFHostAppProps): import("react/jsx-runtime").JSX.Element;
|
|
4
10
|
export default MFHostApp;
|
|
@@ -0,0 +1,60 @@
|
|
|
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 { M as MFWindowsTitle } from "../MFWindowsTitle/MFWindowsTitle.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
|
+
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(
|
|
28
|
+
HostThemeProvider,
|
|
29
|
+
{
|
|
30
|
+
isMicroFrontEnd: true,
|
|
31
|
+
...hostTheme,
|
|
32
|
+
children: /* @__PURE__ */ jsx(ResponsiveContainerProvider, { observedDivRef, children: /* @__PURE__ */ jsx(unstable_HistoryRouter, { history: hostTools.history, children: /* @__PURE__ */ jsx(
|
|
33
|
+
DomainCountryProvider,
|
|
34
|
+
{
|
|
35
|
+
isMicroFrontEnd: true,
|
|
36
|
+
id: dynamicMFStore?.getState().dynamicMFParameters?.id || 1,
|
|
37
|
+
currency: formatters.currencyFormatter.code,
|
|
38
|
+
currency_decimal_digits: formatters.currencyFormatter.decimalDigits,
|
|
39
|
+
decimal_symbol: formatters.numberFormatter.decimalSymbol,
|
|
40
|
+
thousands_symbol: formatters.numberFormatter.thousandsSymbol,
|
|
41
|
+
children: /* @__PURE__ */ jsx(
|
|
42
|
+
BaseModule,
|
|
43
|
+
{
|
|
44
|
+
isAuth,
|
|
45
|
+
moduleId,
|
|
46
|
+
moduleNameField,
|
|
47
|
+
componentsDictionary,
|
|
48
|
+
skeletonFlags,
|
|
49
|
+
privileges,
|
|
50
|
+
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 }) }) }) }) })
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
) }) })
|
|
55
|
+
}
|
|
56
|
+
) }) }) }) });
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
MFHostApp as M
|
|
60
|
+
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Formatters, LocaleType } from '@m4l/graphics';
|
|
1
|
+
import { AxiosOperation, EnvironmentType, HostToolsType } from '@m4l/core';
|
|
2
|
+
import { Formatters, LocaleType, HostThemeType } from '@m4l/graphics';
|
|
3
3
|
import { DynamicMFStore, WindowToolsMF, BaseModuleProps } from '@m4l/components';
|
|
4
|
-
import { HostThemeType } from '@m4l/graphics';
|
|
5
4
|
export interface ByHostProps {
|
|
6
5
|
environment: EnvironmentType;
|
|
7
6
|
hostTools: HostToolsType;
|
|
@@ -18,4 +17,4 @@ export interface ByHostProps {
|
|
|
18
17
|
*/
|
|
19
18
|
isAddEditModule?: boolean;
|
|
20
19
|
}
|
|
21
|
-
export
|
|
20
|
+
export type MFHostAppProps = ByHostProps & BaseModuleProps;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { MFNoAuthAppProps } from './types';
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Componente que envuelve la aplicación de un microfrontend sin autenticación
|
|
4
|
+
* @author Juan Escobar - automatic
|
|
5
|
+
* @createdAt 2024-10-09 19:56:26 - automatic
|
|
6
|
+
* @updatedAt 2024-10-09 20:00:30 - automatic
|
|
7
|
+
* @updatedUser Juan Escobar - automatic
|
|
8
|
+
*/
|
|
9
|
+
export declare function MFNoAuthApp(props: MFNoAuthAppProps): import("react/jsx-runtime").JSX.Element;
|
|
4
10
|
export default MFNoAuthApp;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DomainCountryProvider } from "@m4l/core";
|
|
3
|
+
import { FormatterProvider, ResponsiveContainerProvider } from "@m4l/graphics";
|
|
4
|
+
import { BaseModule } from "@m4l/components";
|
|
5
|
+
function MFNoAuthApp(props) {
|
|
6
|
+
const {
|
|
7
|
+
children,
|
|
8
|
+
formatters,
|
|
9
|
+
moduleId,
|
|
10
|
+
moduleNameField,
|
|
11
|
+
skeletonFlags,
|
|
12
|
+
privileges,
|
|
13
|
+
componentsDictionary,
|
|
14
|
+
isAuth,
|
|
15
|
+
observedDivRef
|
|
16
|
+
} = props;
|
|
17
|
+
const domianCountry = {
|
|
18
|
+
id: 1,
|
|
19
|
+
currency: "USD",
|
|
20
|
+
currency_decimal_digits: 2,
|
|
21
|
+
decimal_symbol: ".",
|
|
22
|
+
thousands_symbol: ","
|
|
23
|
+
};
|
|
24
|
+
return /* @__PURE__ */ jsx(DomainCountryProvider, { isMicroFrontEnd: true, ...domianCountry, children: /* @__PURE__ */ jsx(
|
|
25
|
+
BaseModule,
|
|
26
|
+
{
|
|
27
|
+
isAuth,
|
|
28
|
+
moduleId,
|
|
29
|
+
moduleNameField,
|
|
30
|
+
componentsDictionary,
|
|
31
|
+
skeletonFlags,
|
|
32
|
+
privileges,
|
|
33
|
+
children: /* @__PURE__ */ jsx(FormatterProvider, { isMicroFrontEnd: true, ...formatters, children: /* @__PURE__ */ jsx(ResponsiveContainerProvider, { observedDivRef, children }) })
|
|
34
|
+
}
|
|
35
|
+
) });
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
MFNoAuthApp as M
|
|
39
|
+
};
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { MFWindowsTitleProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Titulo de la ventana del microfrontend
|
|
4
|
+
* @author Juan Escobar - automatic
|
|
5
|
+
* @createdAt 2024-10-09 19:56:26 - automatic
|
|
6
|
+
* @updatedAt 2024-10-09 20:00:30 - automatic
|
|
7
|
+
* @updatedUser Juan Escobar - automatic
|
|
8
|
+
*/
|
|
9
|
+
export declare function MFWindowsTitle({ isAddEditModule, children }: MFWindowsTitleProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment } from "react";
|
|
3
|
+
import { useSetWindowsTitle } from "@m4l/components";
|
|
4
|
+
function MFWindowsTitle({ isAddEditModule = false, children }) {
|
|
5
|
+
useSetWindowsTitle({ isAddEditModule });
|
|
6
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
MFWindowsTitle as M
|
|
10
|
+
};
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { AuthProviderProps, SessionContextType } from './types';
|
|
2
|
+
declare const AuthContext: import('react').Context<SessionContextType | null>;
|
|
3
|
+
/**
|
|
4
|
+
* Proveedor de autenticación
|
|
5
|
+
* @author Juan Escobar - automatic
|
|
6
|
+
* @createdAt 2024-10-09 19:56:26 - automatic
|
|
7
|
+
* @updatedAt 2024-10-09 20:00:30 - automatic
|
|
8
|
+
* @updatedUser Juan Escobar - automatic
|
|
9
|
+
*/
|
|
10
|
+
declare function AuthProvider(props: AuthProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
5
11
|
export { AuthContext, AuthProvider };
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
1
2
|
import { createContext, useReducer, useEffect } from "react";
|
|
2
3
|
import { useHostTools, useNetwork, useEnvironment, useLocalStorageWithListener, EmitEvents, getLocalStorage, setLocalStorage } from "@m4l/core";
|
|
3
|
-
import {
|
|
4
|
-
var EnumTypes = /* @__PURE__ */ ((EnumTypes2) => {
|
|
5
|
-
EnumTypes2["Initial"] = "INITIALIZE";
|
|
6
|
-
EnumTypes2["Login"] = "LOGIN";
|
|
7
|
-
EnumTypes2["Logout"] = "LOGOUT";
|
|
8
|
-
return EnumTypes2;
|
|
9
|
-
})(EnumTypes || {});
|
|
4
|
+
import { E as EnumTypes } from "./types.js";
|
|
10
5
|
const initialState = {
|
|
11
6
|
isAuthenticated: false,
|
|
12
7
|
isInitialized: false,
|
|
@@ -47,19 +42,11 @@ function dispatchInitial(dispatch) {
|
|
|
47
42
|
});
|
|
48
43
|
}
|
|
49
44
|
function AuthProvider(props) {
|
|
50
|
-
const {
|
|
51
|
-
children
|
|
52
|
-
} = props;
|
|
45
|
+
const { children } = props;
|
|
53
46
|
const [state, dispatch] = useReducer(JWTReducer, initialState);
|
|
54
|
-
const {
|
|
55
|
-
|
|
56
|
-
} =
|
|
57
|
-
const {
|
|
58
|
-
networkOperation
|
|
59
|
-
} = useNetwork();
|
|
60
|
-
const {
|
|
61
|
-
domain_token
|
|
62
|
-
} = useEnvironment();
|
|
47
|
+
const { events_add_listener } = useHostTools();
|
|
48
|
+
const { networkOperation } = useNetwork();
|
|
49
|
+
const { domain_token } = useEnvironment();
|
|
63
50
|
const [nextValSession, setNextValSession] = useLocalStorageWithListener(
|
|
64
51
|
//Variable para saber si ha cambiado la session en otro navegador
|
|
65
52
|
"vSession",
|
|
@@ -70,9 +57,7 @@ function AuthProvider(props) {
|
|
|
70
57
|
networkOperation({
|
|
71
58
|
method: "GET",
|
|
72
59
|
endPoint: `auth/login`,
|
|
73
|
-
parms: {
|
|
74
|
-
user_data: true
|
|
75
|
-
},
|
|
60
|
+
parms: { user_data: true },
|
|
76
61
|
checkUnAuthorized: false
|
|
77
62
|
}).then((response) => {
|
|
78
63
|
dispatch({
|
|
@@ -87,9 +72,7 @@ function AuthProvider(props) {
|
|
|
87
72
|
remember: true
|
|
88
73
|
});
|
|
89
74
|
if (useSaved?.email !== response.user.email) {
|
|
90
|
-
setLocalStorage("userData", {
|
|
91
|
-
email: response.user.email
|
|
92
|
-
}, true);
|
|
75
|
+
setLocalStorage("userData", { email: response.user.email }, true);
|
|
93
76
|
}
|
|
94
77
|
}).catch(() => {
|
|
95
78
|
dispatchInitial(dispatch);
|
|
@@ -109,15 +92,9 @@ function AuthProvider(props) {
|
|
|
109
92
|
}).then((response) => {
|
|
110
93
|
const user = response.data;
|
|
111
94
|
if (remember) {
|
|
112
|
-
setLocalStorage("userData", {
|
|
113
|
-
email,
|
|
114
|
-
remember
|
|
115
|
-
});
|
|
95
|
+
setLocalStorage("userData", { email, remember });
|
|
116
96
|
} else {
|
|
117
|
-
setLocalStorage("userData", {
|
|
118
|
-
email: "",
|
|
119
|
-
remember
|
|
120
|
-
});
|
|
97
|
+
setLocalStorage("userData", { email: "", remember });
|
|
121
98
|
}
|
|
122
99
|
dispatch({
|
|
123
100
|
type: EnumTypes.Login,
|
|
@@ -135,25 +112,29 @@ function AuthProvider(props) {
|
|
|
135
112
|
method: "POST"
|
|
136
113
|
});
|
|
137
114
|
}
|
|
138
|
-
dispatch({
|
|
139
|
-
type: EnumTypes.Logout
|
|
140
|
-
});
|
|
115
|
+
dispatch({ type: EnumTypes.Logout });
|
|
141
116
|
setNextValSession((/* @__PURE__ */ new Date()).getTime() + "");
|
|
142
117
|
};
|
|
143
118
|
const onNetserviceUnautorized = () => {
|
|
144
119
|
logout(false);
|
|
145
120
|
};
|
|
146
121
|
useEffect(() => {
|
|
147
|
-
events_add_listener(
|
|
122
|
+
events_add_listener(
|
|
123
|
+
EmitEvents.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED,
|
|
124
|
+
onNetserviceUnautorized
|
|
125
|
+
);
|
|
148
126
|
}, []);
|
|
149
|
-
return /* @__PURE__ */ jsx(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
127
|
+
return /* @__PURE__ */ jsx(
|
|
128
|
+
AuthContext.Provider,
|
|
129
|
+
{
|
|
130
|
+
value: {
|
|
131
|
+
...state,
|
|
132
|
+
login,
|
|
133
|
+
logout
|
|
134
|
+
},
|
|
135
|
+
children
|
|
136
|
+
}
|
|
137
|
+
);
|
|
157
138
|
}
|
|
158
139
|
export {
|
|
159
140
|
AuthContext as A,
|
|
@@ -5,10 +5,10 @@ export declare enum EnumTypes {
|
|
|
5
5
|
Login = "LOGIN",
|
|
6
6
|
Logout = "LOGOUT"
|
|
7
7
|
}
|
|
8
|
-
export
|
|
8
|
+
export type AuthProviderProps = {
|
|
9
9
|
children: ReactNode;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type ActionMap<M extends {
|
|
12
12
|
[index: string]: any;
|
|
13
13
|
}> = {
|
|
14
14
|
[Key in keyof M]: M[Key] extends undefined ? {
|
|
@@ -18,7 +18,7 @@ export declare type ActionMap<M extends {
|
|
|
18
18
|
payload: M[Key];
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
|
-
export
|
|
21
|
+
export type SessionAuthPayload = {
|
|
22
22
|
[EnumTypes.Initial]: {
|
|
23
23
|
isAuthenticated: boolean;
|
|
24
24
|
user: AuthUser;
|
|
@@ -28,7 +28,7 @@ export declare type SessionAuthPayload = {
|
|
|
28
28
|
};
|
|
29
29
|
[EnumTypes.Logout]: undefined;
|
|
30
30
|
};
|
|
31
|
-
export
|
|
31
|
+
export type SessionActions = ActionMap<SessionAuthPayload>[keyof ActionMap<SessionAuthPayload>];
|
|
32
32
|
export interface User {
|
|
33
33
|
email: string;
|
|
34
34
|
id: number;
|
|
@@ -39,8 +39,8 @@ export interface User {
|
|
|
39
39
|
avatar_url?: Maybe<string>;
|
|
40
40
|
user_type_id?: number;
|
|
41
41
|
}
|
|
42
|
-
export
|
|
43
|
-
export
|
|
42
|
+
export type AuthUser = Maybe<User>;
|
|
43
|
+
export type AuthState = {
|
|
44
44
|
isAuthenticated: boolean;
|
|
45
45
|
isInitialized: boolean;
|
|
46
46
|
user: AuthUser;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
package/hooks/useAuth/index.d.ts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Hook para obtener el contexto de autenticación
|
|
3
|
+
* @author Juan Escobar - automatic
|
|
4
|
+
* @createdAt 2024-10-09 19:56:26 - automatic
|
|
5
|
+
* @updatedAt 2024-10-09 20:00:30 - automatic
|
|
6
|
+
* @updatedUser Juan Escobar - automatic
|
|
7
|
+
*/
|
|
8
|
+
export declare const useAuth: () => import('../../contexts/AuthContext/types').SessionContextType;
|
|
2
9
|
export default useAuth;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { useContext } from "react";
|
|
2
|
-
import { A as AuthContext } from "../../contexts/AuthContext/index
|
|
2
|
+
import { A as AuthContext } from "../../contexts/AuthContext/index.js";
|
|
3
3
|
const useAuth = () => {
|
|
4
4
|
const context = useContext(AuthContext);
|
|
5
|
-
if (!context)
|
|
5
|
+
if (!context) {
|
|
6
|
+
throw new Error("Auth context must be use inside AuthProvider");
|
|
7
|
+
}
|
|
6
8
|
return context;
|
|
7
9
|
};
|
|
8
10
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useMasterDetail: () => import(
|
|
1
|
+
export declare const useMasterDetail: () => import('../../layouts/MasterDetailLayout/contexts/MasterDetailContext/types').MasterDetailContextProps;
|
|
@@ -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/contexts/MasterDetailContext/index.js";
|
|
3
3
|
const useMasterDetail = () => useContext(MasterDetailContext);
|
|
4
4
|
export {
|
|
5
5
|
useMasterDetail as u
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Hook para obtener el contexto de un módulo
|
|
3
|
+
* @author Juan Escobar - automatic
|
|
4
|
+
* @createdAt 2024-10-09 19:56:26 - automatic
|
|
5
|
+
* @updatedAt 2024-10-09 20:00:30 - automatic
|
|
6
|
+
* @updatedUser Juan Escobar - automatic
|
|
7
|
+
*/
|
|
8
|
+
export declare const useModule: () => import('../../layouts/ModuleLayout/contexts/ModuleContext/types').ModuleLayoutContextProps;
|
|
2
9
|
export default useModule;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { M as ModuleContext } from "../../layouts/ModuleLayout/contexts/ModuleContext/index.js";
|
|
3
|
+
const useModule = () => {
|
|
4
|
+
const context = useContext(ModuleContext);
|
|
5
|
+
if (!context) {
|
|
6
|
+
throw new Error("useModule context must be use inside ModuleContext");
|
|
7
|
+
}
|
|
8
|
+
return context;
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
useModule as u
|
|
12
|
+
};
|
package/index.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { M } from "./components/MFHostApp/index
|
|
3
|
-
import { A, a
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { N
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { M } from "./components/MFNoAuthApp/index.js";
|
|
2
|
+
import { M as M2 } from "./components/MFHostApp/index.js";
|
|
3
|
+
import { A, a } from "./contexts/AuthContext/index.js";
|
|
4
|
+
import { M as M3 } from "./layouts/ModuleLayout/ModuleLayout.js";
|
|
5
|
+
import { M as M4 } from "./layouts/MasterDetailLayout/MasterDetailLayout.js";
|
|
6
|
+
import { N } from "./layouts/NoAuthModuleLayout/index.js";
|
|
7
|
+
import { d, g } from "./layouts/ModuleLayout/dicctionary.js";
|
|
8
|
+
import { d as d2, g as g2 } from "./layouts/MasterDetailLayout/dicctionary.js";
|
|
9
|
+
import { d as d3, g as g3 } from "./layouts/NoAuthModuleLayout/dicctionary.js";
|
|
10
|
+
import { u } from "./hooks/useMasterDetail/index.js";
|
|
11
|
+
import { u as u2 } from "./hooks/useAuth/index.js";
|
|
12
|
+
import { u as u3 } from "./hooks/useModule/index.js";
|
|
10
13
|
export {
|
|
11
14
|
A as AuthContext,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
a as AuthProvider,
|
|
16
|
+
M2 as MFHostApp,
|
|
17
|
+
M as MFNoAuthApp,
|
|
18
|
+
M4 as MasterDetailLayout,
|
|
19
|
+
M3 as ModuleLayout,
|
|
17
20
|
N as NoAuthModuleLayout,
|
|
18
21
|
d2 as defaultMasterDetailDictionary,
|
|
19
22
|
d as defaultModuleLayoutDictionary,
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { MasterDetailLayoutProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Layout de maestro detalle
|
|
4
|
+
* @author Juan Escobar - automatic
|
|
5
|
+
* @createdAt 2024-10-09 19:56:26 - automatic
|
|
6
|
+
* @updatedAt 2024-10-09 20:00:30 - automatic
|
|
7
|
+
* @updatedUser Juan Escobar - automatic
|
|
8
|
+
*/
|
|
9
|
+
export declare function MasterDetailLayout(props: MasterDetailLayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useMemo, useCallback } from "react";
|
|
3
|
+
import { useEnvironment, useModuleDictionary } from "@m4l/core";
|
|
4
|
+
import { WindowBase, SplitLayout } from "@m4l/components";
|
|
5
|
+
import { M as ModuleLayout } from "../ModuleLayout/ModuleLayout.js";
|
|
6
|
+
import { a as MasterDetailProvider } from "./contexts/MasterDetailContext/index.js";
|
|
7
|
+
import { useResponsiveDesktop } from "@m4l/graphics";
|
|
8
|
+
import { g as getMasterDetailLayoutUtilityClasses } from "./classes/index.js";
|
|
9
|
+
import { M as MasterDetailLayoutRoot } from "./styles.js";
|
|
10
|
+
function getTotalModuleActions(splitActions, moduleActions = []) {
|
|
11
|
+
let totalActions = [...splitActions];
|
|
12
|
+
totalActions = moduleActions.concat(totalActions);
|
|
13
|
+
return totalActions;
|
|
14
|
+
}
|
|
15
|
+
function MasterDetailLayout(props) {
|
|
16
|
+
const {
|
|
17
|
+
moduleId,
|
|
18
|
+
masterComponent,
|
|
19
|
+
detailComponent,
|
|
20
|
+
moduleActions,
|
|
21
|
+
version
|
|
22
|
+
// defaultDictionary,
|
|
23
|
+
} = props;
|
|
24
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
25
|
+
const [splitPosition, setSplitPosition] = useState("vertical");
|
|
26
|
+
const isDesktop = useResponsiveDesktop();
|
|
27
|
+
const moduleLayoutRef = useRef(null);
|
|
28
|
+
const { getLabel } = useModuleDictionary();
|
|
29
|
+
const splitActions = useMemo(
|
|
30
|
+
() => [
|
|
31
|
+
{
|
|
32
|
+
urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/split_vertical.svg`,
|
|
33
|
+
onClick: () => onChangePostionInternal("vertical"),
|
|
34
|
+
visibility: "main",
|
|
35
|
+
label: getLabel("master_detail_layout.split_vertical"),
|
|
36
|
+
tag: "vertical",
|
|
37
|
+
className: "splitactions",
|
|
38
|
+
disabled: splitPosition === "vertical",
|
|
39
|
+
key: "vertical"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/split_horizontal.svg`,
|
|
43
|
+
onClick: () => onChangePostionInternal("horizontal"),
|
|
44
|
+
visibility: "main",
|
|
45
|
+
label: getLabel("master_detail_layout.split_horizontal"),
|
|
46
|
+
tag: "horizontal",
|
|
47
|
+
className: "splitactions",
|
|
48
|
+
disabled: splitPosition === "horizontal",
|
|
49
|
+
key: "horizontal"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/no_split.svg`,
|
|
53
|
+
onClick: () => onChangePostionInternal("none"),
|
|
54
|
+
visibility: "main",
|
|
55
|
+
label: getLabel("master_detail_layout.no_split"),
|
|
56
|
+
tag: "none",
|
|
57
|
+
className: "splitactions",
|
|
58
|
+
disabled: splitPosition === "none",
|
|
59
|
+
key: "none"
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
63
|
+
[getLabel, splitPosition]
|
|
64
|
+
);
|
|
65
|
+
const onChangePostionInternal = useCallback((newPostion) => {
|
|
66
|
+
setSplitPosition(newPostion);
|
|
67
|
+
}, []);
|
|
68
|
+
const onClickViewDetail = useCallback(() => {
|
|
69
|
+
moduleLayoutRef.current?.openModal({
|
|
70
|
+
initialWidth: 500,
|
|
71
|
+
initialHeigth: 680,
|
|
72
|
+
window: /* @__PURE__ */ jsx(
|
|
73
|
+
WindowBase,
|
|
74
|
+
{
|
|
75
|
+
title: getLabel("master_detail_layout.view_detail"),
|
|
76
|
+
children: typeof detailComponent === "function" ? detailComponent({}) : detailComponent
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
// actions: undefined,
|
|
80
|
+
});
|
|
81
|
+
}, [detailComponent, getLabel]);
|
|
82
|
+
const finalModuleActions = useMemo(() => {
|
|
83
|
+
const actions = getTotalModuleActions(
|
|
84
|
+
splitActions,
|
|
85
|
+
moduleActions
|
|
86
|
+
);
|
|
87
|
+
return actions;
|
|
88
|
+
}, [splitActions, moduleActions]);
|
|
89
|
+
const classes = getMasterDetailLayoutUtilityClasses();
|
|
90
|
+
return /* @__PURE__ */ jsx(MasterDetailProvider, { onClickViewDetail, children: /* @__PURE__ */ jsx(MasterDetailLayoutRoot, { className: classes.root, children: /* @__PURE__ */ jsx(
|
|
91
|
+
ModuleLayout,
|
|
92
|
+
{
|
|
93
|
+
ref: moduleLayoutRef,
|
|
94
|
+
moduleId,
|
|
95
|
+
moduleActions: finalModuleActions,
|
|
96
|
+
version,
|
|
97
|
+
children: /* @__PURE__ */ jsx(
|
|
98
|
+
SplitLayout,
|
|
99
|
+
{
|
|
100
|
+
splitPosition: isDesktop ? splitPosition : "none",
|
|
101
|
+
firstPart: masterComponent,
|
|
102
|
+
secondPart: detailComponent
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
) }) });
|
|
107
|
+
}
|
|
108
|
+
export {
|
|
109
|
+
MasterDetailLayout as M
|
|
110
|
+
};
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { MasterDetailLayoutClassesType } from './types';
|
|
2
2
|
export declare const masterDetailLayoutClasses: MasterDetailLayoutClassesType;
|
|
3
3
|
export declare function getMasterDetailLayoutUtilityClass(slot: string): string;
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Hook para obtener las clases del componente MasterDetailLayout
|
|
6
|
+
* @author Juan Escobar - automatic
|
|
7
|
+
* @createdAt 2024-10-09 19:56:26 - automatic
|
|
8
|
+
* @updatedAt 2024-10-09 20:00:30 - automatic
|
|
9
|
+
* @updatedUser Juan Escobar - automatic
|
|
10
|
+
*/
|
|
11
|
+
export declare const getMasterDetailLayoutUtilityClasses: () => {
|
|
5
12
|
root: string;
|
|
6
13
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { generateUtilityClasses, generateUtilityClass } from "@mui/material";
|
|
2
|
+
import { unstable_composeClasses } from "@mui/base";
|
|
3
|
+
import { c as componentName } from "./constants.js";
|
|
4
|
+
generateUtilityClasses(componentName, [
|
|
5
|
+
/* elements */
|
|
6
|
+
"root"
|
|
7
|
+
/* states or variants of elements */
|
|
8
|
+
]);
|
|
9
|
+
function getMasterDetailLayoutUtilityClass(slot) {
|
|
10
|
+
return generateUtilityClass(componentName, slot);
|
|
11
|
+
}
|
|
12
|
+
const getMasterDetailLayoutUtilityClasses = () => {
|
|
13
|
+
const slots = {
|
|
14
|
+
root: ["root"]
|
|
15
|
+
};
|
|
16
|
+
const composedClasses = unstable_composeClasses(slots, getMasterDetailLayoutUtilityClass, {});
|
|
17
|
+
return {
|
|
18
|
+
...composedClasses
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
getMasterDetailLayoutUtilityClasses as g
|
|
23
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getMasterDetailLayoutUtilityClasses } from '.';
|
|
2
2
|
export interface MasterDetailLayoutClassesType {
|
|
3
3
|
root: string;
|
|
4
4
|
}
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export type MasterDetailLayoutClassesKey = keyof MasterDetailLayoutClassesType;
|
|
6
|
+
export type Classes = ReturnType<typeof getMasterDetailLayoutUtilityClasses>;
|