@m4l/layouts 0.1.38 → 0.1.40

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.
Files changed (37) hide show
  1. package/components/BaseModule/index.6309486a.js +24 -24
  2. package/components/BaseModule/index.d.ts +2 -1
  3. package/components/MFHostApp/index.420c2626.js +58 -58
  4. package/components/MFHostApp/index.d.ts +2 -1
  5. package/components/MFIsolationApp/index.d.ts +2 -1
  6. package/components/MFIsolationApp/index.e36cf308.js +175 -0
  7. package/components/MFIsolationApp/subcomponents/MFAuthApp/index.d.ts +2 -1
  8. package/components/{index.604759d6.js → index.aeb3cf83.js} +1 -1
  9. package/contexts/AuthContext/index.6f966215.js +118 -88
  10. package/contexts/AuthContext/index.d.ts +1 -1
  11. package/hooks/index.a0c767ed.js +4 -0
  12. package/hooks/useAuth/index.cb6a3420.js +7 -7
  13. package/hooks/useMasterDetail/index.927c0c26.js +6 -0
  14. package/hooks/useModule/index.edcd7b28.js +11 -0
  15. package/index.js +27 -27
  16. package/layouts/MasterDetailLayout/contexts/MasterDetailContext/index.d.ts +1 -1
  17. package/layouts/MasterDetailLayout/index.bca0fce5.js +136 -0
  18. package/layouts/MasterDetailLayout/index.d.ts +2 -1
  19. package/layouts/ModuleLayout/contexts/ModuleContext/index.d.ts +1 -1
  20. package/layouts/ModuleLayout/index.850f7dcf.js +118 -0
  21. package/layouts/ModuleLayout/subcomponents/InnerModule/styles.d.ts +3 -0
  22. package/layouts/NoAuthModuleLayout/index.d.ts +2 -1
  23. package/layouts/NoAuthModuleLayout/index.eabf38c1.js +179 -146
  24. package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/index.d.ts +2 -1
  25. package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/styles.d.ts +2 -0
  26. package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/DesktopContent/index.d.ts +2 -1
  27. package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/DesktopContent/styles.d.ts +9 -0
  28. package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/MobileContent/index.d.ts +2 -1
  29. package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/MobileContent/styles.d.ts +9 -0
  30. package/layouts/{index.3e2d546f.js → index.07aacf57.js} +2 -2
  31. package/package.json +2 -1
  32. package/components/MFIsolationApp/index.ed197bc0.js +0 -152
  33. package/hooks/index.18c6b299.js +0 -4
  34. package/hooks/useMasterDetail/index.50331312.js +0 -6
  35. package/hooks/useModule/index.35cc5fe0.js +0 -11
  36. package/layouts/MasterDetailLayout/index.2c363c7a.js +0 -109
  37. package/layouts/ModuleLayout/index.90b4dc8e.js +0 -103
@@ -1,11 +1,11 @@
1
- import { useContext as o } from "react";
2
- import { a as e } from "../../contexts/AuthContext/index.6f966215.js";
3
- const n = () => {
4
- const t = o(e);
5
- if (!t)
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
6
  throw new Error("Auth context must be use inside AuthProvider");
7
- return t;
7
+ return context;
8
8
  };
9
9
  export {
10
- n as u
10
+ useAuth as u
11
11
  };
@@ -0,0 +1,6 @@
1
+ import { useContext } from "react";
2
+ import { M as MasterDetailContext } from "../../layouts/MasterDetailLayout/index.bca0fce5.js";
3
+ const useMasterDetail = () => useContext(MasterDetailContext);
4
+ export {
5
+ useMasterDetail as u
6
+ };
@@ -0,0 +1,11 @@
1
+ import { useContext } from "react";
2
+ import { M as ModuleContext } from "../../layouts/ModuleLayout/index.850f7dcf.js";
3
+ const useModule = () => {
4
+ const context = useContext(ModuleContext);
5
+ if (!context)
6
+ throw new Error("useModule context must be use inside ModuleContext");
7
+ return context;
8
+ };
9
+ export {
10
+ useModule as u
11
+ };
package/index.js CHANGED
@@ -1,13 +1,13 @@
1
- import { M as f } from "./components/MFIsolationApp/index.ed197bc0.js";
2
- import { M as D } from "./components/MFHostApp/index.420c2626.js";
3
- import { B as L } from "./components/BaseModule/index.6309486a.js";
4
- import { a as g, A as h } from "./contexts/AuthContext/index.6f966215.js";
5
- import { a as N, d as B, g as F } from "./layouts/ModuleLayout/index.90b4dc8e.js";
6
- import { a as H, d as I, g as P } from "./layouts/MasterDetailLayout/index.2c363c7a.js";
7
- import { N as j, d as k, g as q } from "./layouts/NoAuthModuleLayout/index.eabf38c1.js";
8
- import { u as z } from "./hooks/useMasterDetail/index.50331312.js";
9
- import { u as G } from "./hooks/useAuth/index.cb6a3420.js";
10
- import { u as K } from "./hooks/useModule/index.35cc5fe0.js";
1
+ import { M } from "./components/MFIsolationApp/index.e36cf308.js";
2
+ import { M as M2 } from "./components/MFHostApp/index.420c2626.js";
3
+ import { B } from "./components/BaseModule/index.6309486a.js";
4
+ import { a, A } from "./contexts/AuthContext/index.6f966215.js";
5
+ import { a as a2, d, g } from "./layouts/ModuleLayout/index.850f7dcf.js";
6
+ import { a as a3, d as d2, g as g2 } from "./layouts/MasterDetailLayout/index.bca0fce5.js";
7
+ import { N, d as d3, g as g3 } from "./layouts/NoAuthModuleLayout/index.eabf38c1.js";
8
+ import { u } from "./hooks/useMasterDetail/index.927c0c26.js";
9
+ import { u as u2 } from "./hooks/useAuth/index.cb6a3420.js";
10
+ import { u as u3 } from "./hooks/useModule/index.edcd7b28.js";
11
11
  import "react";
12
12
  import "react-router-dom";
13
13
  import "react-toastify";
@@ -22,21 +22,21 @@ import "nprogress";
22
22
  import "@m4l/components";
23
23
  import "@mui/material/styles";
24
24
  export {
25
- g as AuthContext,
26
- h as AuthProvider,
27
- L as BaseModule,
28
- D as MFHostApp,
29
- f as MFIsolationApp,
30
- H as MasterDetailLayout,
31
- N as ModuleLayout,
32
- j as NoAuthModuleLayout,
33
- I as defaultMasterDetailDictionary,
34
- B as defaultModuleLayoutDictionary,
35
- k as defaultNoAuthModuleLayoutDictionary,
36
- P as getMasterDetailLayoutComponentsDictionary,
37
- F as getModuleLayoutComponentsDictionary,
38
- q as getNoAuthModuleLayoutComponentsDictionary,
39
- G as useAuth,
40
- z as useMasterDetail,
41
- K as useModule
25
+ a as AuthContext,
26
+ A as AuthProvider,
27
+ B as BaseModule,
28
+ M2 as MFHostApp,
29
+ M as MFIsolationApp,
30
+ a3 as MasterDetailLayout,
31
+ a2 as ModuleLayout,
32
+ N as NoAuthModuleLayout,
33
+ d2 as defaultMasterDetailDictionary,
34
+ d as defaultModuleLayoutDictionary,
35
+ d3 as defaultNoAuthModuleLayoutDictionary,
36
+ g2 as getMasterDetailLayoutComponentsDictionary,
37
+ g as getModuleLayoutComponentsDictionary,
38
+ g3 as getNoAuthModuleLayoutComponentsDictionary,
39
+ u2 as useAuth,
40
+ u as useMasterDetail,
41
+ u3 as useModule
42
42
  };
@@ -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 };
@@ -0,0 +1,136 @@
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.850f7dcf.js";
5
+ import { jsx } from "react/jsx-runtime";
6
+ import { useResponsiveDesktop } from "@m4l/graphics";
7
+ const initialState = {
8
+ masterSelection: void 0,
9
+ onChangeMasterSelection: voidFunction
10
+ };
11
+ const MasterDetailContext = createContext(initialState);
12
+ function MasterDetailProvider(props) {
13
+ const {
14
+ children
15
+ } = props;
16
+ const [masterSelection, setMasterSelection] = useState(void 0);
17
+ return /* @__PURE__ */ jsx(MasterDetailContext.Provider, {
18
+ value: {
19
+ masterSelection,
20
+ onChangeMasterSelection: setMasterSelection
21
+ },
22
+ children
23
+ });
24
+ }
25
+ function getTotalModuleActions(splitActions, moduleActions = [], viewDetailAction, isDesktop) {
26
+ let totalActions = isDesktop !== void 0 && isDesktop ? [...splitActions] : [viewDetailAction];
27
+ totalActions = moduleActions.concat(totalActions);
28
+ return totalActions;
29
+ }
30
+ function MasterDetailLayout(props) {
31
+ const {
32
+ moduleId,
33
+ masterComponent,
34
+ detailComponent,
35
+ moduleActions,
36
+ version
37
+ } = props;
38
+ const {
39
+ host_static_assets,
40
+ environment_assets
41
+ } = useEnvironment();
42
+ const [splitPosition, setSplitPosition] = useState("vertical");
43
+ const isDesktop = useResponsiveDesktop();
44
+ const moduleLayoutRef = useRef(null);
45
+ const {
46
+ getLabel
47
+ } = useModuleDictionary();
48
+ const splitActions = useMemo(() => [{
49
+ urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/split_vertical.svg`,
50
+ onClick: () => onChangePostionInternal("vertical"),
51
+ visibility: "main",
52
+ label: getLabel("master_detail_layout.split_vertical"),
53
+ tag: "vertical",
54
+ className: "splitactions",
55
+ disabled: splitPosition === "vertical",
56
+ key: "vertical"
57
+ }, {
58
+ urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/split_horizontal.svg`,
59
+ onClick: () => onChangePostionInternal("horizontal"),
60
+ visibility: "main",
61
+ label: getLabel("master_detail_layout.split_horizontal"),
62
+ tag: "horizontal",
63
+ className: "splitactions",
64
+ disabled: splitPosition === "horizontal",
65
+ key: "horizontal"
66
+ }, {
67
+ urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/no_split.svg`,
68
+ onClick: () => onChangePostionInternal("none"),
69
+ visibility: "main",
70
+ label: getLabel("master_detail_layout.no_split"),
71
+ tag: "none",
72
+ className: "splitactions",
73
+ disabled: splitPosition === "none",
74
+ key: "none"
75
+ }], [getLabel, splitPosition]);
76
+ const onChangePostionInternal = useCallback((newPostion) => {
77
+ setSplitPosition(newPostion);
78
+ }, []);
79
+ const onClickViewDetail = useCallback(() => {
80
+ moduleLayoutRef.current?.openModal({
81
+ initialWidth: 500,
82
+ initialHeigth: 680,
83
+ window: /* @__PURE__ */ jsx(WindowBase, {
84
+ urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/view_detail.svg`,
85
+ title: getLabel("master_detail_layout.view_detail"),
86
+ children: typeof detailComponent === "function" ? detailComponent({}) : detailComponent
87
+ })
88
+ });
89
+ }, [detailComponent, getLabel]);
90
+ const viewDetailAction = useMemo(() => {
91
+ return {
92
+ urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/view_detail.svg`,
93
+ onClick: onClickViewDetail,
94
+ disabled: false,
95
+ visibility: "allways",
96
+ label: getLabel("master_detail_layout.view_detail"),
97
+ tag: "none",
98
+ className: "",
99
+ key: "detail"
100
+ };
101
+ }, [environment_assets, onClickViewDetail]);
102
+ const finalModuleActions = useMemo(() => {
103
+ const actions = getTotalModuleActions(splitActions, moduleActions, viewDetailAction, isDesktop);
104
+ return actions;
105
+ }, [splitActions, moduleActions, isDesktop, viewDetailAction]);
106
+ return /* @__PURE__ */ jsx(MasterDetailProvider, {
107
+ children: /* @__PURE__ */ jsx(ModuleLayout, {
108
+ ref: moduleLayoutRef,
109
+ moduleId,
110
+ moduleActions: finalModuleActions,
111
+ version,
112
+ children: /* @__PURE__ */ jsx(SplitLayout, {
113
+ splitPosition: isDesktop ? splitPosition : "none",
114
+ firstPart: masterComponent,
115
+ secondPart: detailComponent
116
+ })
117
+ })
118
+ });
119
+ }
120
+ function getMasterDetailLayoutComponentsDictionary() {
121
+ return ["master_detail_layout"].concat(getModuleLayoutComponentsDictionary());
122
+ }
123
+ const defaultMasterDetailDictionary = {
124
+ master_detail_layout: {
125
+ split_vertical: "Split vertically",
126
+ split_horizontal: "Split horizontally",
127
+ no_split: "No split",
128
+ view_detail: "View detail"
129
+ }
130
+ };
131
+ export {
132
+ MasterDetailContext as M,
133
+ MasterDetailLayout as a,
134
+ defaultMasterDetailDictionary as d,
135
+ getMasterDetailLayoutComponentsDictionary as g
136
+ };
@@ -1,2 +1,3 @@
1
+ /// <reference types="react" />
1
2
  import type { MasterDetailLayoutProps } from './types';
2
- export declare function MasterDetailLayout(props: MasterDetailLayoutProps): JSX.Element;
3
+ export declare function MasterDetailLayout(props: MasterDetailLayoutProps): import("react").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import { ModuleLayoutContextProps, ModuleLayoutProviderProps } from './types';
3
3
  declare const ModuleContext: import("react").Context<ModuleLayoutContextProps | null>;
4
- declare function ModuleProvider(props: ModuleLayoutProviderProps): JSX.Element;
4
+ declare function ModuleProvider(props: ModuleLayoutProviderProps): import("react").JSX.Element;
5
5
  export { ModuleProvider, ModuleContext };
@@ -0,0 +1,118 @@
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 { jsx } from "react/jsx-runtime";
5
+ const WrapperInnerModule = styled("div")(() => ({
6
+ display: "flex",
7
+ flexDirection: "column",
8
+ position: "absolute",
9
+ margin: "0px 12px 12px 12px",
10
+ left: "0px",
11
+ right: "0px",
12
+ top: "0px",
13
+ bottom: "0px",
14
+ overflow: "hidden"
15
+ }));
16
+ const ModuleContent = styled("div")(({
17
+ theme
18
+ }) => ({
19
+ display: "flex",
20
+ position: "relative",
21
+ marginTop: theme.spacing(1),
22
+ justifyContent: "center",
23
+ flexGrow: "1",
24
+ overflow: "hidden"
25
+ }));
26
+ const InnerModule = forwardRef((props, ref) => {
27
+ const {
28
+ children
29
+ } = props;
30
+ const {
31
+ openModal
32
+ } = useModal();
33
+ const divRef = useRef(null);
34
+ useImperativeHandle(ref, () => ({
35
+ openModal,
36
+ current: divRef.current
37
+ }));
38
+ return /* @__PURE__ */ jsx(WrapperInnerModule, {
39
+ id: "WrapperInnerModule",
40
+ className: "m4l_module_layout",
41
+ ref: divRef,
42
+ children: /* @__PURE__ */ jsx(ModuleContent, {
43
+ id: "ModuleContent",
44
+ children
45
+ })
46
+ });
47
+ });
48
+ InnerModule.displayName = "InnerModule";
49
+ const ModuleContext = createContext(null);
50
+ function ModuleProvider(props) {
51
+ const {
52
+ children,
53
+ moduleActions,
54
+ moduleId,
55
+ version
56
+ } = props;
57
+ const [configOptions] = useState(() => ({
58
+ moduleId,
59
+ dictionary: void 0
60
+ }));
61
+ const {
62
+ setActions
63
+ } = useWindowToolsMF();
64
+ const [dynamicActions, setDynamicActions] = useState([]);
65
+ const finalModuleActions = useMemo(() => {
66
+ return (moduleActions || []).concat(dynamicActions);
67
+ }, [moduleActions, dynamicActions]);
68
+ useEffect(() => {
69
+ setActions(finalModuleActions, version);
70
+ }, [finalModuleActions]);
71
+ return /* @__PURE__ */ jsx(ModuleContext.Provider, {
72
+ value: {
73
+ setDynamicActions,
74
+ moduleId: configOptions.moduleId
75
+ },
76
+ children
77
+ });
78
+ }
79
+ const ModuleLayout = forwardRef((props, ref) => {
80
+ const {
81
+ moduleId,
82
+ moduleActions,
83
+ version,
84
+ children
85
+ } = props;
86
+ const moduleRef = useRef(null);
87
+ const openModal = (modalOpenProps) => {
88
+ moduleRef.current?.openModal(modalOpenProps);
89
+ };
90
+ useImperativeHandle(ref, () => ({
91
+ openModal,
92
+ current: moduleRef.current
93
+ }));
94
+ return /* @__PURE__ */ jsx(ModuleProvider, {
95
+ moduleId,
96
+ moduleActions,
97
+ version,
98
+ children: /* @__PURE__ */ jsx(ModalProvider, {
99
+ children: /* @__PURE__ */ jsx(InnerModule, {
100
+ ref: moduleRef,
101
+ children
102
+ })
103
+ })
104
+ });
105
+ });
106
+ ModuleLayout.displayName = "ModuleLayout";
107
+ function getModuleLayoutComponentsDictionary() {
108
+ return ["module_layout"].concat(getModalDialogComponentsDictionary());
109
+ }
110
+ const defaultModuleLayoutDictionary = {
111
+ module_layout: {}
112
+ };
113
+ export {
114
+ ModuleContext as M,
115
+ ModuleLayout as a,
116
+ defaultModuleLayoutDictionary as d,
117
+ getModuleLayoutComponentsDictionary as g
118
+ };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare const WrapperInnerModule: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
3
+ export declare const ModuleContent: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -1,2 +1,3 @@
1
+ /// <reference types="react" />
1
2
  import { NoAuthModuleLayoutProps } from './types';
2
- export declare const NoAuthModuleLayout: (props: NoAuthModuleLayoutProps) => JSX.Element;
3
+ export declare const NoAuthModuleLayout: (props: NoAuthModuleLayoutProps) => import("react").JSX.Element;