@m4l/layouts 0.1.22 → 0.1.25
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/.eslintignore +2 -0
- package/.eslintrc.cjs +118 -0
- package/.gitignore +23 -0
- package/.gitlab-ci.yml +16 -0
- package/.prettierignore +3 -0
- package/.prettierrc.json +26 -0
- package/.vscode/settings.json +50 -0
- package/dist/components/BaseModule/index.6309486a.js +33 -0
- package/dist/components/BaseModule/index.d.ts +4 -0
- package/dist/components/BaseModule/types.d.ts +9 -0
- package/dist/components/MFHostApp/index.1700d13a.js +69 -0
- package/{components → dist/components}/MFHostApp/types.d.ts +3 -7
- package/dist/components/MFIsolationApp/index.b21e5671.js +151 -0
- package/dist/components/MFIsolationApp/types.d.ts +11 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.deb4e7ac.js +6 -0
- package/{contexts → dist/contexts}/AuthContext/types.d.ts +1 -1
- package/dist/contexts/index.b46a2699.js +1 -0
- package/dist/hooks/index.2022a179.js +4 -0
- package/{hooks/useMasterDetail/index.8e9e900b.js → dist/hooks/useMasterDetail/index.1b024fd5.js} +1 -1
- package/{hooks/useModule/index.096d7d13.js → dist/hooks/useModule/index.6ff7d08a.js} +1 -1
- package/dist/index.js +41 -0
- package/dist/layouts/MasterDetailLayout/index.3da0ffda.js +104 -0
- package/{layouts → dist/layouts}/ModuleLayout/contexts/ModuleContext/types.d.ts +2 -7
- package/dist/layouts/ModuleLayout/index.a76397df.js +101 -0
- package/dist/layouts/ModuleLayout/types.d.ts +15 -0
- package/dist/layouts/index.014e41ba.js +8 -0
- package/{layouts → dist/layouts}/index.d.ts +0 -1
- package/dist/package.json +36 -0
- package/package.json +57 -12
- package/src/@types/index.ts +8 -0
- package/src/components/BaseModule/index.tsx +59 -0
- package/src/components/BaseModule/types.ts +12 -0
- package/src/components/MFHostApp/index.tsx +95 -0
- package/src/components/MFHostApp/types.ts +16 -0
- package/src/components/MFIsolationApp/index.tsx +164 -0
- package/src/components/MFIsolationApp/subcomponents/MFAuthApp/index.tsx +98 -0
- package/src/components/MFIsolationApp/subcomponents/MFAuthApp/types.ts +7 -0
- package/src/components/MFIsolationApp/types.ts +12 -0
- package/src/components/index.ts +5 -0
- package/src/contexts/AuthContext/index.tsx +189 -0
- package/src/contexts/AuthContext/types.ts +65 -0
- package/src/contexts/index.ts +1 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/useAuth/index.ts +12 -0
- package/src/hooks/useMasterDetail/index.ts +6 -0
- package/src/hooks/useModule/index.ts +13 -0
- package/src/index.ts +7 -0
- package/src/layouts/MasterDetailLayout/components/ButtonDetail/index.tsx +38 -0
- package/src/layouts/MasterDetailLayout/contexts/MasterDetailContext/index.tsx +34 -0
- package/src/layouts/MasterDetailLayout/contexts/MasterDetailContext/types.ts +19 -0
- package/src/layouts/MasterDetailLayout/dicctionary.ts +20 -0
- package/src/layouts/MasterDetailLayout/index.tsx +165 -0
- package/src/layouts/MasterDetailLayout/types.ts +11 -0
- package/src/layouts/ModuleLayout/contexts/ModuleContext/index.tsx +56 -0
- package/src/layouts/ModuleLayout/contexts/ModuleContext/types.ts +23 -0
- package/src/layouts/ModuleLayout/dicctionary.ts +11 -0
- package/src/layouts/ModuleLayout/index.tsx +59 -0
- package/src/layouts/ModuleLayout/subcomponents/InnerModule/index.tsx +35 -0
- package/src/layouts/ModuleLayout/subcomponents/InnerModule/styles.tsx +31 -0
- package/src/layouts/ModuleLayout/subcomponents/InnerModule/types.ts +11 -0
- package/src/layouts/ModuleLayout/types.ts +31 -0
- package/src/layouts/NoAuthModuleLayout/dicctionary.ts +9 -0
- package/src/layouts/NoAuthModuleLayout/index.tsx +85 -0
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/index.tsx +43 -0
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/styles.tsx +6 -0
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/index.tsx +14 -0
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/styles.tsx +7 -0
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/AppBar/index.tsx +25 -0
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/AppBar/styles.tsx +11 -0
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/index.tsx +17 -0
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/styles.tsx +19 -0
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/subcomponents/NameDescription/index.tsx +25 -0
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/subcomponents/NameDescription/styles.tsx +8 -0
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/types.ts +5 -0
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/types.ts +5 -0
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/LogoLeyend/index.tsx +28 -0
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/LogoLeyend/styles.tsx +16 -0
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/types.ts +5 -0
- package/src/layouts/NoAuthModuleLayout/types.ts +22 -0
- package/src/layouts/index.ts +8 -0
- package/src/test/setup.ts +1 -0
- package/src/test/utils.tsx +20 -0
- package/src/vite-env.d.ts +3 -0
- package/tsconfig.json +29 -0
- package/tsconfig.node.json +8 -0
- package/vite.config.ts +172 -0
- package/components/MFHostApp/index.b3c15ec3.js +0 -52
- package/components/MFIsolationApp/index.28f538a3.js +0 -106
- package/components/MFIsolationApp/types.d.ts +0 -10
- package/components/index.d.ts +0 -3
- package/index.js +0 -38
- package/layouts/MasterDetailLayout/components/ButtonDetail/index.d.ts +0 -3
- package/layouts/MasterDetailLayout/index.71de0dc7.js +0 -141
- package/layouts/ModuleLayout/index.842072c5.js +0 -348
- package/layouts/ModuleLayout/subcomponents/InnerModule/subcomponents/Header/index.d.ts +0 -2
- package/layouts/ModuleLayout/subcomponents/InnerModule/subcomponents/Header/skeleton.d.ts +0 -2
- package/layouts/ModuleLayout/subcomponents/InnerModule/subcomponents/Header/styles.d.ts +0 -8
- package/layouts/ModuleLayout/subcomponents/InnerModule/subcomponents/Header/types.d.ts +0 -2
- package/layouts/ModuleLayout/types.d.ts +0 -29
- package/node_modules.26043cf4.js +0 -1601
- package/vendor.95e38403.js +0 -20
- /package/{components → dist/components}/MFHostApp/index.d.ts +0 -0
- /package/{components → dist/components}/MFIsolationApp/index.d.ts +0 -0
- /package/{components → dist/components}/MFIsolationApp/subcomponents/MFAuthApp/index.d.ts +0 -0
- /package/{components → dist/components}/MFIsolationApp/subcomponents/MFAuthApp/types.d.ts +0 -0
- /package/{contexts → dist/contexts}/AuthContext/index.6f966215.js +0 -0
- /package/{contexts → dist/contexts}/AuthContext/index.d.ts +0 -0
- /package/{contexts → dist/contexts}/index.d.ts +0 -0
- /package/{hooks → dist/hooks}/index.d.ts +0 -0
- /package/{hooks → dist/hooks}/useAuth/index.cb6a3420.js +0 -0
- /package/{hooks → dist/hooks}/useAuth/index.d.ts +0 -0
- /package/{hooks → dist/hooks}/useMasterDetail/index.d.ts +0 -0
- /package/{hooks → dist/hooks}/useModule/index.d.ts +0 -0
- /package/{index.d.ts → dist/index.d.ts} +0 -0
- /package/{layouts → dist/layouts}/MasterDetailLayout/contexts/MasterDetailContext/index.d.ts +0 -0
- /package/{layouts → dist/layouts}/MasterDetailLayout/contexts/MasterDetailContext/types.d.ts +0 -0
- /package/{layouts → dist/layouts}/MasterDetailLayout/dicctionary.d.ts +0 -0
- /package/{layouts → dist/layouts}/MasterDetailLayout/index.d.ts +0 -0
- /package/{layouts → dist/layouts}/MasterDetailLayout/types.d.ts +0 -0
- /package/{layouts → dist/layouts}/ModuleLayout/contexts/ModuleContext/index.d.ts +0 -0
- /package/{layouts → dist/layouts}/ModuleLayout/dicctionary.d.ts +0 -0
- /package/{layouts → dist/layouts}/ModuleLayout/index.d.ts +0 -0
- /package/{layouts → dist/layouts}/ModuleLayout/subcomponents/InnerModule/index.d.ts +0 -0
- /package/{layouts → dist/layouts}/ModuleLayout/subcomponents/InnerModule/styles.d.ts +0 -0
- /package/{layouts → dist/layouts}/ModuleLayout/subcomponents/InnerModule/types.d.ts +0 -0
- /package/{layouts → dist/layouts}/NoAuthModuleLayout/dicctionary.d.ts +0 -0
- /package/{layouts → dist/layouts}/NoAuthModuleLayout/index.5d1098ef.js +0 -0
- /package/{layouts → dist/layouts}/NoAuthModuleLayout/index.d.ts +0 -0
- /package/{layouts → dist/layouts}/NoAuthModuleLayout/subcomponents/InnerModule/index.d.ts +0 -0
- /package/{layouts → dist/layouts}/NoAuthModuleLayout/subcomponents/InnerModule/styles.d.ts +0 -0
- /package/{layouts → dist/layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/index.d.ts +0 -0
- /package/{layouts → dist/layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/styles.d.ts +0 -0
- /package/{layouts → dist/layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/AppBar/index.d.ts +0 -0
- /package/{layouts → dist/layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/AppBar/styles.d.ts +0 -0
- /package/{layouts → dist/layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/index.d.ts +0 -0
- /package/{layouts → dist/layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/styles.d.ts +0 -0
- /package/{layouts → dist/layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/subcomponents/NameDescription/index.d.ts +0 -0
- /package/{layouts → dist/layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/subcomponents/NameDescription/styles.d.ts +0 -0
- /package/{layouts → dist/layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/types.d.ts +0 -0
- /package/{layouts → dist/layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/types.d.ts +0 -0
- /package/{layouts → dist/layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/LogoLeyend/index.d.ts +0 -0
- /package/{layouts → dist/layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/LogoLeyend/styles.d.ts +0 -0
- /package/{layouts → dist/layouts}/NoAuthModuleLayout/subcomponents/InnerModule/types.d.ts +0 -0
- /package/{layouts → dist/layouts}/NoAuthModuleLayout/types.d.ts +0 -0
- /package/{vite-env.d.ts → dist/vite-env.d.ts} +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Dictionary } from '@m4l/core';
|
|
2
|
+
import {
|
|
3
|
+
// defaultModuleLayoutDictionary,
|
|
4
|
+
getModuleLayoutComponentsDictionary,
|
|
5
|
+
} from '../ModuleLayout/dicctionary';
|
|
6
|
+
|
|
7
|
+
export function getMasterDetailLayoutComponentsDictionary() {
|
|
8
|
+
return ['master_detail_layout'].concat(getModuleLayoutComponentsDictionary());
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const defaultMasterDetailDictionary: Dictionary = {
|
|
12
|
+
master_detail_layout: {
|
|
13
|
+
split_vertical: 'Split vertically',
|
|
14
|
+
split_horizontal: 'Split horizontally',
|
|
15
|
+
no_split: 'No split',
|
|
16
|
+
view_detail: 'View detail',
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
//...defaultModuleLayoutDictionary,
|
|
20
|
+
};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// react
|
|
2
|
+
import { useCallback, useMemo, useRef, useState } from 'react';
|
|
3
|
+
//m4l
|
|
4
|
+
import { useEnvironment } from '@m4l/core';
|
|
5
|
+
// external libraries
|
|
6
|
+
|
|
7
|
+
// componentes estilados
|
|
8
|
+
|
|
9
|
+
// sub components
|
|
10
|
+
import { ModuleAction, SplitLayout } from '@m4l/components';
|
|
11
|
+
import { ModuleLayout } from '../ModuleLayout';
|
|
12
|
+
|
|
13
|
+
// dictionary
|
|
14
|
+
// import { getMasterDetailLayoutComponentsDictionary } from './dicctionary';
|
|
15
|
+
// context
|
|
16
|
+
import { MasterDetailProvider } from './contexts/MasterDetailContext';
|
|
17
|
+
// hooks
|
|
18
|
+
import { useResponsiveDesktop } from '@m4l/graphics';
|
|
19
|
+
|
|
20
|
+
// types
|
|
21
|
+
import type { MasterDetailLayoutProps } from './types';
|
|
22
|
+
import type { SplitPosition } from '@m4l/components';
|
|
23
|
+
import type { ModuleLayoutRef } from '../ModuleLayout/types';
|
|
24
|
+
// constants
|
|
25
|
+
|
|
26
|
+
function getTotalModuleActions(
|
|
27
|
+
splitActions: ModuleAction[],
|
|
28
|
+
moduleActions: ModuleAction[],
|
|
29
|
+
viewDetailAction: ModuleAction,
|
|
30
|
+
isDesktop: boolean | undefined,
|
|
31
|
+
): ModuleAction[] {
|
|
32
|
+
let totalActions: ModuleAction[] =
|
|
33
|
+
isDesktop !== undefined && isDesktop ? [...splitActions] : [viewDetailAction];
|
|
34
|
+
// !== undefined
|
|
35
|
+
// ? [viewDetailAction]
|
|
36
|
+
// : [];
|
|
37
|
+
totalActions = moduleActions.concat(totalActions);
|
|
38
|
+
|
|
39
|
+
return totalActions;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function MasterDetailLayout(props: MasterDetailLayoutProps) {
|
|
43
|
+
const {
|
|
44
|
+
moduleId,
|
|
45
|
+
|
|
46
|
+
masterComponent,
|
|
47
|
+
detailComponent,
|
|
48
|
+
moduleActions,
|
|
49
|
+
|
|
50
|
+
// defaultDictionary,
|
|
51
|
+
} = props;
|
|
52
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
53
|
+
|
|
54
|
+
const [splitPosition, setSplitPosition] = useState<SplitPosition>('vertical');
|
|
55
|
+
const isDesktop = useResponsiveDesktop();
|
|
56
|
+
const moduleLayoutRef = useRef<ModuleLayoutRef>(null);
|
|
57
|
+
|
|
58
|
+
const onChangePostionInternal = (newPostion: SplitPosition) => {
|
|
59
|
+
const newSplitActions = [...initialSplitActions];
|
|
60
|
+
|
|
61
|
+
for (let i = 0; i < newSplitActions.length; i++) {
|
|
62
|
+
newSplitActions[i].disabled = false;
|
|
63
|
+
if (newSplitActions[i].tag === newPostion) {
|
|
64
|
+
newSplitActions[i].disabled = true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
setSplitActions(newSplitActions);
|
|
68
|
+
setSplitPosition(newPostion);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const initialSplitActions: ModuleAction[] = [
|
|
72
|
+
{
|
|
73
|
+
urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/split_vertical.svg`,
|
|
74
|
+
onClick: () => onChangePostionInternal('vertical'),
|
|
75
|
+
disabled: true,
|
|
76
|
+
visibility: 'main',
|
|
77
|
+
dictionaryField: 'master_detail_layout.split_vertical',
|
|
78
|
+
tag: 'vertical',
|
|
79
|
+
className: 'splitactions',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/split_horizontal.svg`,
|
|
83
|
+
onClick: () => onChangePostionInternal('horizontal'),
|
|
84
|
+
disabled: false,
|
|
85
|
+
visibility: 'main',
|
|
86
|
+
dictionaryField: 'master_detail_layout.split_horizontal',
|
|
87
|
+
tag: 'horizontal',
|
|
88
|
+
className: 'splitactions',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/no_split.svg`,
|
|
92
|
+
onClick: () => onChangePostionInternal('none'),
|
|
93
|
+
disabled: false,
|
|
94
|
+
visibility: 'main',
|
|
95
|
+
dictionaryField: 'master_detail_layout.no_split',
|
|
96
|
+
tag: 'none',
|
|
97
|
+
className: 'splitactions',
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
const onClickViewDetail = useCallback(() => {
|
|
101
|
+
// moduleLayoutRef.current?.openModal({
|
|
102
|
+
// title: 'master_detail_layout.view_detail',
|
|
103
|
+
// initialWidth: 500,
|
|
104
|
+
// initialHeigth: 680,
|
|
105
|
+
// window: detailComponent,
|
|
106
|
+
// actions: undefined,
|
|
107
|
+
// });
|
|
108
|
+
}, [detailComponent]);
|
|
109
|
+
|
|
110
|
+
const viewDetailAction: ModuleAction = useMemo(() => {
|
|
111
|
+
return {
|
|
112
|
+
urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/view_detail.svg`,
|
|
113
|
+
onClick: onClickViewDetail,
|
|
114
|
+
disabled: false,
|
|
115
|
+
visibility: 'allways',
|
|
116
|
+
dictionaryField: 'master_detail_layout.view_detail',
|
|
117
|
+
tag: 'none',
|
|
118
|
+
className: '',
|
|
119
|
+
// component: ButtonDetail,
|
|
120
|
+
};
|
|
121
|
+
}, [environment_assets, onClickViewDetail]);
|
|
122
|
+
|
|
123
|
+
const [splitActions, setSplitActions] = useState<ModuleAction[]>(initialSplitActions);
|
|
124
|
+
|
|
125
|
+
const finalModuleActions = useMemo(() => {
|
|
126
|
+
const actions = getTotalModuleActions(
|
|
127
|
+
splitActions,
|
|
128
|
+
moduleActions,
|
|
129
|
+
viewDetailAction,
|
|
130
|
+
isDesktop,
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
return actions;
|
|
134
|
+
|
|
135
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
136
|
+
}, [splitActions, moduleActions, isDesktop, viewDetailAction]);
|
|
137
|
+
|
|
138
|
+
// const finalComponentsDictionary = useMemo(
|
|
139
|
+
// () => componentsDictionary.concat(getMasterDetailLayoutComponentsDictionary()),
|
|
140
|
+
// [componentsDictionary],
|
|
141
|
+
// );
|
|
142
|
+
|
|
143
|
+
// const finalDefaultDictionary = useMemo(
|
|
144
|
+
// () => ({ ...defaultDictionary, ...defaultMasterDetailDictionary }),
|
|
145
|
+
// [defaultDictionary],
|
|
146
|
+
// );
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
<MasterDetailProvider>
|
|
150
|
+
<ModuleLayout
|
|
151
|
+
ref={moduleLayoutRef}
|
|
152
|
+
moduleId={moduleId}
|
|
153
|
+
moduleActions={finalModuleActions}
|
|
154
|
+
//defaultDictionary={finalDefaultDictionary}
|
|
155
|
+
// componentsDictionary={finalComponentsDictionary}
|
|
156
|
+
>
|
|
157
|
+
<SplitLayout
|
|
158
|
+
splitPosition={isDesktop ? splitPosition : 'none'}
|
|
159
|
+
firstPart={masterComponent}
|
|
160
|
+
secondPart={detailComponent}
|
|
161
|
+
/>
|
|
162
|
+
</ModuleLayout>
|
|
163
|
+
</MasterDetailProvider>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ModuleLayoutProps } from '../ModuleLayout/types';
|
|
3
|
+
|
|
4
|
+
export interface ContainerProps {
|
|
5
|
+
vertical: boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface MasterDetailLayoutProps extends Omit<ModuleLayoutProps, 'children'> {
|
|
9
|
+
masterComponent: ((props?: any) => JSX.Element) | ReactNode;
|
|
10
|
+
detailComponent: ((props?: any) => JSX.Element) | ReactNode;
|
|
11
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// react
|
|
2
|
+
import { ModuleAction, useDynamicMFParameters } from '@m4l/components';
|
|
3
|
+
import { createContext, useState, useMemo, useEffect } from 'react';
|
|
4
|
+
|
|
5
|
+
// sub componentes
|
|
6
|
+
|
|
7
|
+
// types
|
|
8
|
+
import {
|
|
9
|
+
ModuleLayoutContextProps,
|
|
10
|
+
ModuleLayoutContextStateProps,
|
|
11
|
+
ModuleLayoutProviderProps,
|
|
12
|
+
} from './types';
|
|
13
|
+
|
|
14
|
+
// network
|
|
15
|
+
|
|
16
|
+
const ModuleContext = createContext<ModuleLayoutContextProps | null>(null);
|
|
17
|
+
|
|
18
|
+
function ModuleProvider(props: ModuleLayoutProviderProps) {
|
|
19
|
+
const { children, moduleActions, moduleId } = props;
|
|
20
|
+
|
|
21
|
+
const [configOptions] = useState<ModuleLayoutContextStateProps>(() => ({
|
|
22
|
+
moduleId,
|
|
23
|
+
dictionary: undefined,
|
|
24
|
+
}));
|
|
25
|
+
const { setModuleActions } = useDynamicMFParameters();
|
|
26
|
+
|
|
27
|
+
const [dynamicActions, setDynamicActions] = useState<Array<ModuleAction>>([]);
|
|
28
|
+
|
|
29
|
+
const finalModuleActions = useMemo(
|
|
30
|
+
() => moduleActions.concat(dynamicActions),
|
|
31
|
+
[moduleActions, dynamicActions],
|
|
32
|
+
);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
console.log('useEffect ModuleProvider', finalModuleActions);
|
|
35
|
+
setModuleActions(finalModuleActions);
|
|
36
|
+
}, [finalModuleActions]);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<ModuleContext.Provider
|
|
40
|
+
value={{
|
|
41
|
+
moduleActions: finalModuleActions,
|
|
42
|
+
// dynamicActions,
|
|
43
|
+
setDynamicActions,
|
|
44
|
+
moduleId: configOptions.moduleId,
|
|
45
|
+
// moduleNameField: configOptions.moduleNameField,
|
|
46
|
+
// urlIcon: configOptions.urlIcon,
|
|
47
|
+
|
|
48
|
+
// breadcrumbLinks: configOptions.breadcrumbLinks,
|
|
49
|
+
}}
|
|
50
|
+
>
|
|
51
|
+
{children}
|
|
52
|
+
</ModuleContext.Provider>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { ModuleProvider, ModuleContext };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ModuleAction } from '@m4l/components';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
export interface ModuleLayoutContextStateProps {
|
|
5
|
+
// init: boolean,
|
|
6
|
+
// urlIcon: string;
|
|
7
|
+
moduleId: string;
|
|
8
|
+
// moduleNameField: string;
|
|
9
|
+
// breadcrumbLinks: TLink[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ModuleLayoutProviderProps extends Omit<ModuleLayoutContextStateProps, 'init'> {
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
|
|
15
|
+
moduleActions: ModuleAction[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface ModuleLayoutContextProps extends ModuleLayoutContextStateProps {
|
|
19
|
+
// , "dictionary" | "moduleId" | "moduleNameField" | "breadcrumbLinks"
|
|
20
|
+
moduleActions: ModuleAction[];
|
|
21
|
+
// dynamicActions: ModuleAction[];
|
|
22
|
+
setDynamicActions: (dynamicActions: ModuleAction[]) => void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Dictionary } from '@m4l/core';
|
|
2
|
+
|
|
3
|
+
import { getModalDialogComponentsDictionary } from '@m4l/components';
|
|
4
|
+
|
|
5
|
+
export function getModuleLayoutComponentsDictionary() {
|
|
6
|
+
return ['module_layout'].concat(getModalDialogComponentsDictionary());
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const defaultModuleLayoutDictionary: Dictionary = {
|
|
10
|
+
module_layout: {},
|
|
11
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// m4l
|
|
2
|
+
import { ModalProvider } from '@m4l/components';
|
|
3
|
+
|
|
4
|
+
// react
|
|
5
|
+
import { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
6
|
+
// external libraries
|
|
7
|
+
|
|
8
|
+
// componentes estilados
|
|
9
|
+
|
|
10
|
+
// sub components
|
|
11
|
+
import { InnerModule } from './subcomponents/InnerModule';
|
|
12
|
+
|
|
13
|
+
// types
|
|
14
|
+
import type { ModuleLayoutProps, ModuleLayoutRef } from './types';
|
|
15
|
+
import type { ModuleRef } from './subcomponents/InnerModule/types';
|
|
16
|
+
import type { ModalOpenOptions } from '@m4l/components';
|
|
17
|
+
// constants
|
|
18
|
+
|
|
19
|
+
// context
|
|
20
|
+
import { ModuleProvider } from './contexts/ModuleContext';
|
|
21
|
+
|
|
22
|
+
// hooks
|
|
23
|
+
//export const ModuleLayout = forwardRef<ModuleLayoutRef, ModuleLayoutProps>((props, ref) => {
|
|
24
|
+
|
|
25
|
+
export const ModuleLayout = forwardRef<ModuleLayoutRef, ModuleLayoutProps>((props, ref) => {
|
|
26
|
+
const { moduleId, moduleActions, children } = props;
|
|
27
|
+
const moduleRef = useRef<ModuleRef>(null);
|
|
28
|
+
|
|
29
|
+
const openModal = (modalOpenProps: ModalOpenOptions) => {
|
|
30
|
+
moduleRef.current?.openModal(modalOpenProps);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
useImperativeHandle(ref, () => ({
|
|
34
|
+
openModal,
|
|
35
|
+
current: moduleRef.current,
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
// <FlagsProvider>
|
|
40
|
+
// <ModuleDictionaryProvider
|
|
41
|
+
// moduleId={moduleId}
|
|
42
|
+
// componentsDictionary={componentsDictionary}
|
|
43
|
+
// currentLang={currentLang}
|
|
44
|
+
// >
|
|
45
|
+
// <ModuleSkeletonProvider flags={skeletonFlags}>
|
|
46
|
+
// <ModulePrivilegesProvider queryPrivileges={privileges}>
|
|
47
|
+
<ModuleProvider moduleId={moduleId} moduleActions={moduleActions}>
|
|
48
|
+
<ModalProvider>
|
|
49
|
+
<InnerModule ref={moduleRef}>{children}</InnerModule>
|
|
50
|
+
</ModalProvider>
|
|
51
|
+
</ModuleProvider>
|
|
52
|
+
// </ModulePrivilegesProvider>
|
|
53
|
+
// </ModuleSkeletonProvider>
|
|
54
|
+
// </ModuleDictionaryProvider>
|
|
55
|
+
// </FlagsProvider>
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
ModuleLayout.displayName = 'ModuleLayout'; //para efectos de debuggin de React
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// react
|
|
2
|
+
import { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
// external libraries
|
|
4
|
+
|
|
5
|
+
// componentes estilados
|
|
6
|
+
import { WrapperInnerModule, ModuleContent } from './styles';
|
|
7
|
+
|
|
8
|
+
// sub components
|
|
9
|
+
// import { Header } from './subcomponents/Header';
|
|
10
|
+
|
|
11
|
+
// types
|
|
12
|
+
import { ModuleProps, ModuleRef } from './types';
|
|
13
|
+
// constants
|
|
14
|
+
|
|
15
|
+
// hooks
|
|
16
|
+
import { useModal } from '@m4l/components';
|
|
17
|
+
|
|
18
|
+
export const InnerModule = forwardRef<ModuleRef, ModuleProps>((props, ref) => {
|
|
19
|
+
const { children } = props;
|
|
20
|
+
const { openModal } = useModal();
|
|
21
|
+
const divRef = useRef<HTMLDivElement>(null);
|
|
22
|
+
|
|
23
|
+
useImperativeHandle(ref, () => ({
|
|
24
|
+
openModal,
|
|
25
|
+
current: divRef.current,
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<WrapperInnerModule id="WrapperInnerModule" className="m4l_module_layout" ref={divRef}>
|
|
30
|
+
<ModuleContent id="ModuleContent">{children}</ModuleContent>
|
|
31
|
+
</WrapperInnerModule>
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
InnerModule.displayName = 'InnerModule';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { styled } from '@mui/material/styles';
|
|
2
|
+
|
|
3
|
+
export const WrapperInnerModule = styled('div')(() => ({
|
|
4
|
+
display: 'flex',
|
|
5
|
+
flexDirection: 'column',
|
|
6
|
+
position: 'absolute',
|
|
7
|
+
margin: '0px 12px 12px 12px',
|
|
8
|
+
|
|
9
|
+
left: '0px',
|
|
10
|
+
right: '0px',
|
|
11
|
+
top: '0px',
|
|
12
|
+
bottom: '0px',
|
|
13
|
+
|
|
14
|
+
overflow: 'hidden',
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
export const ModuleContent = styled('div')(({ theme }) => ({
|
|
18
|
+
display: 'flex',
|
|
19
|
+
// flexDirection: "column",
|
|
20
|
+
position: 'relative',
|
|
21
|
+
marginTop: theme.spacing(1),
|
|
22
|
+
justifyContent: 'center',
|
|
23
|
+
|
|
24
|
+
// left: "0px",
|
|
25
|
+
// right: "0px",
|
|
26
|
+
// top: "72px",
|
|
27
|
+
// bottom: "0px",
|
|
28
|
+
flexGrow: '1',
|
|
29
|
+
// padding: "16px",
|
|
30
|
+
overflow: 'hidden',
|
|
31
|
+
}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ModalOpenOptions } from '@m4l/components';
|
|
3
|
+
|
|
4
|
+
export type ModuleRef = {
|
|
5
|
+
openModal: (modalOpenProps: ModalOpenOptions) => void;
|
|
6
|
+
current: HTMLDivElement | null;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export interface ModuleProps {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ModalOpenOptions, ModuleAction } from '@m4l/components';
|
|
3
|
+
|
|
4
|
+
import type { ModuleRef } from './subcomponents/InnerModule/types';
|
|
5
|
+
|
|
6
|
+
export interface ContainerProps {
|
|
7
|
+
vertical: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type ModuleLayoutRef = {
|
|
11
|
+
openModal: (modalOpenProps: ModalOpenOptions) => void;
|
|
12
|
+
current: ModuleRef | null;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// export type Skeleton = 'form' | 'masterdetail_1';
|
|
16
|
+
|
|
17
|
+
export interface ModuleLayoutProps {
|
|
18
|
+
// skeleton: Skeleton;
|
|
19
|
+
moduleId: string;
|
|
20
|
+
// urlIcon: string;
|
|
21
|
+
// currentLang: string;
|
|
22
|
+
// skeletonFlags: string[];
|
|
23
|
+
// moduleNameField?: string;
|
|
24
|
+
// privileges: string[];
|
|
25
|
+
// breadcrumbLinks: TLink[];
|
|
26
|
+
moduleActions: ModuleAction[];
|
|
27
|
+
//defaultDictionary: ModuleDictionary;
|
|
28
|
+
// componentsDictionary: string[];
|
|
29
|
+
// master: (props: any) => JSX.Element;
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
//react
|
|
2
|
+
|
|
3
|
+
//external libraries
|
|
4
|
+
|
|
5
|
+
//componentes estilados
|
|
6
|
+
|
|
7
|
+
//sub components
|
|
8
|
+
import { InnerModule } from './subcomponents/InnerModule';
|
|
9
|
+
|
|
10
|
+
//types
|
|
11
|
+
import { NoAuthBaseProviderProps, NoAuthModuleLayoutProps } from './types';
|
|
12
|
+
|
|
13
|
+
//constants
|
|
14
|
+
|
|
15
|
+
//context
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
BaseProvider,
|
|
19
|
+
FlagsProvider,
|
|
20
|
+
ModuleDictionaryProvider,
|
|
21
|
+
ModuleSkeletonProvider,
|
|
22
|
+
useEnvironment,
|
|
23
|
+
} from '@m4l/core';
|
|
24
|
+
import { useLocales } from '@m4l/graphics';
|
|
25
|
+
|
|
26
|
+
//hooks
|
|
27
|
+
|
|
28
|
+
export const NoAuthModuleLayout = (props: NoAuthModuleLayoutProps) => {
|
|
29
|
+
const {
|
|
30
|
+
moduleId,
|
|
31
|
+
moduleNameField,
|
|
32
|
+
children,
|
|
33
|
+
componentsDictionary,
|
|
34
|
+
skeletonFlags,
|
|
35
|
+
subtitle,
|
|
36
|
+
companyLogoSmallUrl,
|
|
37
|
+
companyLogoNormalUrl,
|
|
38
|
+
moduleIlustrationUrl,
|
|
39
|
+
} = props;
|
|
40
|
+
|
|
41
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
42
|
+
|
|
43
|
+
const localeString = useLocales().currentLocale?.localeString;
|
|
44
|
+
|
|
45
|
+
const finalCompanyLogoNormalUrl =
|
|
46
|
+
companyLogoNormalUrl ||
|
|
47
|
+
`${host_static_assets}/${environment_assets}/frontend/commons/assets/icons/logotipo_m4l.svg`;
|
|
48
|
+
const finalCompanyLogoSmallUrl =
|
|
49
|
+
companyLogoSmallUrl ||
|
|
50
|
+
`${host_static_assets}/${environment_assets}/frontend/commons/assets/icons/isotipo_m4l.svg`;
|
|
51
|
+
const finalIllustrationUrl =
|
|
52
|
+
moduleIlustrationUrl ||
|
|
53
|
+
`${host_static_assets}/${environment_assets}/frontend/domain/host/commons/assets/img/illustration_noauth.png`;
|
|
54
|
+
|
|
55
|
+
const finalSkeletonFlags = skeletonFlags;
|
|
56
|
+
|
|
57
|
+
if (finalSkeletonFlags.findIndex(f => f === 'dictionary_loaded') < 0) {
|
|
58
|
+
finalSkeletonFlags.push('dictionary_loaded');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<BaseProvider<NoAuthBaseProviderProps>
|
|
63
|
+
value={{
|
|
64
|
+
subtitle,
|
|
65
|
+
companyLogoSmallUrl: finalCompanyLogoSmallUrl,
|
|
66
|
+
companyLogoNormalUrl: finalCompanyLogoNormalUrl,
|
|
67
|
+
moduleIlustrationUrl: finalIllustrationUrl,
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
<FlagsProvider>
|
|
71
|
+
<ModuleDictionaryProvider
|
|
72
|
+
isAuth={false}
|
|
73
|
+
moduleId={moduleId}
|
|
74
|
+
moduleNameField={moduleNameField}
|
|
75
|
+
componentsDictionary={componentsDictionary}
|
|
76
|
+
currentLang={localeString}
|
|
77
|
+
>
|
|
78
|
+
<ModuleSkeletonProvider flags={finalSkeletonFlags}>
|
|
79
|
+
<InnerModule>{children}</InnerModule>
|
|
80
|
+
</ModuleSkeletonProvider>
|
|
81
|
+
</ModuleDictionaryProvider>
|
|
82
|
+
</FlagsProvider>
|
|
83
|
+
</BaseProvider>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//react
|
|
2
|
+
// m4l
|
|
3
|
+
import { useResponsive } from '@m4l/graphics';
|
|
4
|
+
import { HelmetPage } from '@m4l/components';
|
|
5
|
+
|
|
6
|
+
//mui
|
|
7
|
+
//external libraries
|
|
8
|
+
|
|
9
|
+
//my components
|
|
10
|
+
import { LogoLeyend } from './subcomponents/LogoLeyend';
|
|
11
|
+
import { AppBarForm } from './subcomponents/AppBarForm';
|
|
12
|
+
//componentes estilados
|
|
13
|
+
|
|
14
|
+
import { WrapperMain } from './styles';
|
|
15
|
+
|
|
16
|
+
//sub components
|
|
17
|
+
|
|
18
|
+
//types
|
|
19
|
+
|
|
20
|
+
//constants
|
|
21
|
+
|
|
22
|
+
//hooks
|
|
23
|
+
|
|
24
|
+
import { useBase, useModuleDictionary } from '@m4l/core';
|
|
25
|
+
|
|
26
|
+
import { ModuleProps } from './types';
|
|
27
|
+
import { NoAuthBaseProviderProps } from '../../types';
|
|
28
|
+
|
|
29
|
+
export const InnerModule = (props: ModuleProps) => {
|
|
30
|
+
const { children } = props;
|
|
31
|
+
const { getModuleLabel } = useModuleDictionary();
|
|
32
|
+
const mdUp = useResponsive('up', 'md');
|
|
33
|
+
const { subtitle } = useBase<NoAuthBaseProviderProps>();
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<HelmetPage title={getModuleLabel()} subtitle={subtitle}>
|
|
37
|
+
<WrapperMain>
|
|
38
|
+
{mdUp ? <LogoLeyend /> : null}
|
|
39
|
+
<AppBarForm>{children}</AppBarForm>
|
|
40
|
+
</WrapperMain>
|
|
41
|
+
</HelmetPage>
|
|
42
|
+
);
|
|
43
|
+
};
|
package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/index.tsx
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { WrapperAppBarForm } from './styles';
|
|
2
|
+
import { AppBar } from './subcomponents/AppBar';
|
|
3
|
+
import { Form } from './subcomponents/Form';
|
|
4
|
+
import { WrapperAppBarFormProps } from './types';
|
|
5
|
+
|
|
6
|
+
export const AppBarForm = (props: WrapperAppBarFormProps) => {
|
|
7
|
+
const { children } = props;
|
|
8
|
+
return (
|
|
9
|
+
<WrapperAppBarForm>
|
|
10
|
+
<AppBar />
|
|
11
|
+
<Form>{children}</Form>
|
|
12
|
+
</WrapperAppBarForm>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Image, LanguagePopover } from '@m4l/components';
|
|
2
|
+
import { useBase } from '@m4l/core';
|
|
3
|
+
import { useResponsive } from '@m4l/graphics';
|
|
4
|
+
import { NoAuthBaseProviderProps } from '../../../../../../types';
|
|
5
|
+
|
|
6
|
+
import { WrapperAppBar } from './styles';
|
|
7
|
+
export const AppBar = () => {
|
|
8
|
+
const { companyLogoSmallUrl } = useBase<NoAuthBaseProviderProps>();
|
|
9
|
+
const downMd = useResponsive('down', 'md');
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<WrapperAppBar>
|
|
13
|
+
{downMd ? (
|
|
14
|
+
<Image
|
|
15
|
+
key={'Isotipo'}
|
|
16
|
+
src={companyLogoSmallUrl}
|
|
17
|
+
width={'40px'}
|
|
18
|
+
height={'40px'}
|
|
19
|
+
skeletonVariant="circle"
|
|
20
|
+
/>
|
|
21
|
+
) : null}
|
|
22
|
+
<LanguagePopover />
|
|
23
|
+
</WrapperAppBar>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { styled } from '@mui/material/styles';
|
|
2
|
+
|
|
3
|
+
export const WrapperAppBar = styled('header')(({ theme }) => ({
|
|
4
|
+
width: '100%',
|
|
5
|
+
display: 'flex',
|
|
6
|
+
justifyContent: 'space-between',
|
|
7
|
+
padding: theme.spacing(1, 3),
|
|
8
|
+
[theme.breakpoints.up('md')]: {
|
|
9
|
+
justifyContent: 'flex-end',
|
|
10
|
+
},
|
|
11
|
+
}));
|