@m4l/layouts 0.1.26 → 0.1.30

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 (133) hide show
  1. package/{dist/components/MFIsolationApp/index.b21e5671.js → components/MFIsolationApp/index.b89e6800.js} +38 -37
  2. package/{dist/components/index.deb4e7ac.js → components/index.37205bf4.js} +1 -1
  3. package/index.js +42 -0
  4. package/m4l_layouts/types.d.ts +0 -0
  5. package/package.json +10 -53
  6. package/.eslintignore +0 -2
  7. package/.eslintrc.cjs +0 -118
  8. package/.gitignore +0 -23
  9. package/.gitlab-ci.yml +0 -16
  10. package/.prettierignore +0 -3
  11. package/.prettierrc.json +0 -26
  12. package/.vscode/settings.json +0 -50
  13. package/dist/index.js +0 -41
  14. package/dist/package.json +0 -36
  15. package/src/@types/index.ts +0 -8
  16. package/src/components/BaseModule/index.tsx +0 -59
  17. package/src/components/BaseModule/types.ts +0 -12
  18. package/src/components/MFHostApp/index.tsx +0 -95
  19. package/src/components/MFHostApp/types.ts +0 -16
  20. package/src/components/MFIsolationApp/index.tsx +0 -164
  21. package/src/components/MFIsolationApp/subcomponents/MFAuthApp/index.tsx +0 -98
  22. package/src/components/MFIsolationApp/subcomponents/MFAuthApp/types.ts +0 -7
  23. package/src/components/MFIsolationApp/types.ts +0 -12
  24. package/src/components/index.ts +0 -5
  25. package/src/contexts/AuthContext/index.tsx +0 -189
  26. package/src/contexts/AuthContext/types.ts +0 -65
  27. package/src/contexts/index.ts +0 -1
  28. package/src/hooks/index.ts +0 -5
  29. package/src/hooks/useAuth/index.ts +0 -12
  30. package/src/hooks/useMasterDetail/index.ts +0 -6
  31. package/src/hooks/useModule/index.ts +0 -13
  32. package/src/index.ts +0 -7
  33. package/src/layouts/MasterDetailLayout/components/ButtonDetail/index.tsx +0 -38
  34. package/src/layouts/MasterDetailLayout/contexts/MasterDetailContext/index.tsx +0 -34
  35. package/src/layouts/MasterDetailLayout/contexts/MasterDetailContext/types.ts +0 -19
  36. package/src/layouts/MasterDetailLayout/dicctionary.ts +0 -20
  37. package/src/layouts/MasterDetailLayout/index.tsx +0 -165
  38. package/src/layouts/MasterDetailLayout/types.ts +0 -11
  39. package/src/layouts/ModuleLayout/contexts/ModuleContext/index.tsx +0 -56
  40. package/src/layouts/ModuleLayout/contexts/ModuleContext/types.ts +0 -23
  41. package/src/layouts/ModuleLayout/dicctionary.ts +0 -11
  42. package/src/layouts/ModuleLayout/index.tsx +0 -59
  43. package/src/layouts/ModuleLayout/subcomponents/InnerModule/index.tsx +0 -35
  44. package/src/layouts/ModuleLayout/subcomponents/InnerModule/styles.tsx +0 -31
  45. package/src/layouts/ModuleLayout/subcomponents/InnerModule/types.ts +0 -11
  46. package/src/layouts/ModuleLayout/types.ts +0 -31
  47. package/src/layouts/NoAuthModuleLayout/dicctionary.ts +0 -9
  48. package/src/layouts/NoAuthModuleLayout/index.tsx +0 -85
  49. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/index.tsx +0 -43
  50. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/styles.tsx +0 -6
  51. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/index.tsx +0 -14
  52. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/styles.tsx +0 -7
  53. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/AppBar/index.tsx +0 -25
  54. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/AppBar/styles.tsx +0 -11
  55. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/index.tsx +0 -17
  56. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/styles.tsx +0 -19
  57. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/subcomponents/NameDescription/index.tsx +0 -25
  58. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/subcomponents/NameDescription/styles.tsx +0 -8
  59. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/types.ts +0 -5
  60. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/types.ts +0 -5
  61. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/LogoLeyend/index.tsx +0 -28
  62. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/LogoLeyend/styles.tsx +0 -16
  63. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/types.ts +0 -5
  64. package/src/layouts/NoAuthModuleLayout/types.ts +0 -22
  65. package/src/layouts/index.ts +0 -8
  66. package/src/test/setup.ts +0 -1
  67. package/src/test/utils.tsx +0 -20
  68. package/src/vite-env.d.ts +0 -3
  69. package/tsconfig.json +0 -29
  70. package/tsconfig.node.json +0 -8
  71. package/vite.config.ts +0 -172
  72. /package/{dist/components → components}/BaseModule/index.6309486a.js +0 -0
  73. /package/{dist/components → components}/BaseModule/index.d.ts +0 -0
  74. /package/{dist/components → components}/BaseModule/types.d.ts +0 -0
  75. /package/{dist/components → components}/MFHostApp/index.1700d13a.js +0 -0
  76. /package/{dist/components → components}/MFHostApp/index.d.ts +0 -0
  77. /package/{dist/components → components}/MFHostApp/types.d.ts +0 -0
  78. /package/{dist/components → components}/MFIsolationApp/index.d.ts +0 -0
  79. /package/{dist/components → components}/MFIsolationApp/subcomponents/MFAuthApp/index.d.ts +0 -0
  80. /package/{dist/components → components}/MFIsolationApp/subcomponents/MFAuthApp/types.d.ts +0 -0
  81. /package/{dist/components → components}/MFIsolationApp/types.d.ts +0 -0
  82. /package/{dist/components → components}/index.d.ts +0 -0
  83. /package/{dist/contexts → contexts}/AuthContext/index.6f966215.js +0 -0
  84. /package/{dist/contexts → contexts}/AuthContext/index.d.ts +0 -0
  85. /package/{dist/contexts → contexts}/AuthContext/types.d.ts +0 -0
  86. /package/{dist/contexts → contexts}/index.b46a2699.js +0 -0
  87. /package/{dist/contexts → contexts}/index.d.ts +0 -0
  88. /package/{dist/hooks → hooks}/index.2022a179.js +0 -0
  89. /package/{dist/hooks → hooks}/index.d.ts +0 -0
  90. /package/{dist/hooks → hooks}/useAuth/index.cb6a3420.js +0 -0
  91. /package/{dist/hooks → hooks}/useAuth/index.d.ts +0 -0
  92. /package/{dist/hooks → hooks}/useMasterDetail/index.1b024fd5.js +0 -0
  93. /package/{dist/hooks → hooks}/useMasterDetail/index.d.ts +0 -0
  94. /package/{dist/hooks → hooks}/useModule/index.6ff7d08a.js +0 -0
  95. /package/{dist/hooks → hooks}/useModule/index.d.ts +0 -0
  96. /package/{dist/index.d.ts → index.d.ts} +0 -0
  97. /package/{dist/layouts → layouts}/MasterDetailLayout/contexts/MasterDetailContext/index.d.ts +0 -0
  98. /package/{dist/layouts → layouts}/MasterDetailLayout/contexts/MasterDetailContext/types.d.ts +0 -0
  99. /package/{dist/layouts → layouts}/MasterDetailLayout/dicctionary.d.ts +0 -0
  100. /package/{dist/layouts → layouts}/MasterDetailLayout/index.3da0ffda.js +0 -0
  101. /package/{dist/layouts → layouts}/MasterDetailLayout/index.d.ts +0 -0
  102. /package/{dist/layouts → layouts}/MasterDetailLayout/types.d.ts +0 -0
  103. /package/{dist/layouts → layouts}/ModuleLayout/contexts/ModuleContext/index.d.ts +0 -0
  104. /package/{dist/layouts → layouts}/ModuleLayout/contexts/ModuleContext/types.d.ts +0 -0
  105. /package/{dist/layouts → layouts}/ModuleLayout/dicctionary.d.ts +0 -0
  106. /package/{dist/layouts → layouts}/ModuleLayout/index.a76397df.js +0 -0
  107. /package/{dist/layouts → layouts}/ModuleLayout/index.d.ts +0 -0
  108. /package/{dist/layouts → layouts}/ModuleLayout/subcomponents/InnerModule/index.d.ts +0 -0
  109. /package/{dist/layouts → layouts}/ModuleLayout/subcomponents/InnerModule/styles.d.ts +0 -0
  110. /package/{dist/layouts → layouts}/ModuleLayout/subcomponents/InnerModule/types.d.ts +0 -0
  111. /package/{dist/layouts → layouts}/ModuleLayout/types.d.ts +0 -0
  112. /package/{dist/layouts → layouts}/NoAuthModuleLayout/dicctionary.d.ts +0 -0
  113. /package/{dist/layouts → layouts}/NoAuthModuleLayout/index.5d1098ef.js +0 -0
  114. /package/{dist/layouts → layouts}/NoAuthModuleLayout/index.d.ts +0 -0
  115. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/index.d.ts +0 -0
  116. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/styles.d.ts +0 -0
  117. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/index.d.ts +0 -0
  118. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/styles.d.ts +0 -0
  119. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/AppBar/index.d.ts +0 -0
  120. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/AppBar/styles.d.ts +0 -0
  121. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/index.d.ts +0 -0
  122. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/styles.d.ts +0 -0
  123. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/subcomponents/NameDescription/index.d.ts +0 -0
  124. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/subcomponents/NameDescription/styles.d.ts +0 -0
  125. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/types.d.ts +0 -0
  126. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/types.d.ts +0 -0
  127. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/LogoLeyend/index.d.ts +0 -0
  128. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/LogoLeyend/styles.d.ts +0 -0
  129. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/types.d.ts +0 -0
  130. /package/{dist/layouts → layouts}/NoAuthModuleLayout/types.d.ts +0 -0
  131. /package/{dist/layouts → layouts}/index.014e41ba.js +0 -0
  132. /package/{dist/layouts → layouts}/index.d.ts +0 -0
  133. /package/{dist/vite-env.d.ts → vite-env.d.ts} +0 -0
@@ -1,65 +0,0 @@
1
- import { DomainCountry, Maybe } from '@m4l/core';
2
- import { ReactNode } from 'react';
3
-
4
- // eslint-disable-next-line no-shadow
5
- export enum EnumTypes {
6
- Initial = 'INITIALIZE',
7
- Login = 'LOGIN',
8
- Logout = 'LOGOUT',
9
- }
10
-
11
- export type AuthProviderProps = {
12
- children: ReactNode;
13
- };
14
-
15
- export type ActionMap<M extends { [index: string]: any }> = {
16
- [Key in keyof M]: M[Key] extends undefined
17
- ? {
18
- type: Key;
19
- }
20
- : {
21
- type: Key;
22
- payload: M[Key];
23
- };
24
- };
25
-
26
- export type SessionAuthPayload = {
27
- [EnumTypes.Initial]: {
28
- isAuthenticated: boolean;
29
- user: AuthUser;
30
- };
31
- [EnumTypes.Login]: {
32
- user: AuthUser;
33
- };
34
- [EnumTypes.Logout]: undefined;
35
- };
36
-
37
- export type SessionActions = ActionMap<SessionAuthPayload>[keyof ActionMap<SessionAuthPayload>];
38
-
39
- // export type AuthStoreState = {
40
- // user: User;
41
- // remember?: boolean;
42
- // };
43
-
44
- export interface User {
45
- email: string;
46
- id: number;
47
- first_name: string;
48
- last_name: string;
49
- account_id: number;
50
- domain_country: DomainCountry;
51
- avatar_url?: Maybe<string>;
52
- }
53
-
54
- export type AuthUser = Maybe<User>;
55
-
56
- export type AuthState = {
57
- isAuthenticated: boolean;
58
- isInitialized: boolean;
59
- user: AuthUser;
60
- };
61
-
62
- export interface SessionContextType extends AuthState {
63
- login: (email: string, password: string, remember: boolean) => object | undefined;
64
- logout: (isAuthenticated: boolean) => Promise<void>;
65
- }
@@ -1 +0,0 @@
1
- export * from './AuthContext';
@@ -1,5 +0,0 @@
1
- export * from './useMasterDetail';
2
-
3
- export * from './useAuth';
4
-
5
- export * from './useModule';
@@ -1,12 +0,0 @@
1
- import { useContext } from 'react';
2
- import { AuthContext } from '../../contexts/AuthContext';
3
-
4
- export const useAuth = () => {
5
- const context = useContext(AuthContext);
6
-
7
- if (!context) throw new Error('Auth context must be use inside AuthProvider');
8
-
9
- return context;
10
- };
11
-
12
- export default useAuth;
@@ -1,6 +0,0 @@
1
- import { useContext } from 'react';
2
- import { MasterDetailContext } from '../../layouts/MasterDetailLayout/contexts/MasterDetailContext';
3
-
4
- // ----------------------------------------------------------------------
5
-
6
- export const useMasterDetail = () => useContext(MasterDetailContext);
@@ -1,13 +0,0 @@
1
- import { useContext } from 'react';
2
- import { ModuleContext } from '../../layouts/ModuleLayout/contexts/ModuleContext';
3
-
4
- // ----------------------------------------------------------------------
5
- export const useModule = () => {
6
- const context = useContext(ModuleContext);
7
-
8
- if (!context) throw new Error('useModule context must be use inside ModuleContext');
9
-
10
- return context;
11
- };
12
-
13
- export default useModule;
package/src/index.ts DELETED
@@ -1,7 +0,0 @@
1
- export * from './components';
2
-
3
- export * from './contexts';
4
-
5
- export * from './layouts';
6
-
7
- export * from './hooks';
@@ -1,38 +0,0 @@
1
- // react
2
-
3
- // mui
4
- import { Button } from '@mui/material';
5
- import { ComponentActionProps } from '@m4l/components';
6
- import { useMasterDetail } from '../../../../hooks/useMasterDetail';
7
-
8
- // external libraries
9
-
10
- // componentes estilados
11
-
12
- // sub components
13
-
14
- // dictionary
15
-
16
- // context
17
-
18
- // hooks
19
-
20
- // types
21
-
22
- // constants
23
-
24
- export function ButtonDetail(props: ComponentActionProps) {
25
- const { masterSelection } = useMasterDetail();
26
- const { onClick, description } = props;
27
-
28
- return (
29
- <Button
30
- key="miDetail"
31
- onClick={onClick}
32
- variant="outlined"
33
- disabled={masterSelection === undefined ? true : false}
34
- >
35
- {description}
36
- </Button>
37
- );
38
- }
@@ -1,34 +0,0 @@
1
- // react
2
- import { createContext, useState } from 'react';
3
- import { voidFunction } from '@m4l/core';
4
-
5
- // types
6
- import { MasterDetailContextProps, MasterDetailProviderProps, MasterSelecion } from './types';
7
-
8
- const initialState: MasterDetailContextProps = {
9
- masterSelection: undefined,
10
- onChangeMasterSelection: voidFunction,
11
- };
12
-
13
- const MasterDetailContext = createContext<MasterDetailContextProps>(initialState);
14
-
15
- // ----------------------------------------------------------------------
16
-
17
- function MasterDetailProvider(props: MasterDetailProviderProps) {
18
- const { children } = props;
19
-
20
- const [masterSelection, setMasterSelection] = useState<MasterSelecion>(undefined);
21
-
22
- return (
23
- <MasterDetailContext.Provider
24
- value={{
25
- masterSelection,
26
- onChangeMasterSelection: setMasterSelection,
27
- }}
28
- >
29
- {children}
30
- </MasterDetailContext.Provider>
31
- );
32
- }
33
-
34
- export { MasterDetailProvider, MasterDetailContext };
@@ -1,19 +0,0 @@
1
- import { ReactNode } from 'react';
2
-
3
- export type MasterSelecion = any | any[] | undefined;
4
-
5
- export interface MasterDetailContextStateProps {
6
- masterSelection?: MasterSelecion;
7
- // splitPosition?: SplitPosition;
8
- }
9
-
10
- export interface MasterDetailProviderProps {
11
- // masterSelection: MasterSelecion;
12
- // setMasterSelection: (newMasterSelecion: MasterSelecion) => void;
13
- children: ReactNode;
14
- }
15
-
16
- export interface MasterDetailContextProps extends MasterDetailContextStateProps {
17
- onChangeMasterSelection: (newMasterSelection: MasterSelecion) => void;
18
- // onChangeSplitPosition: (newMasterSelection: MasterSelecion) => void;
19
- }
@@ -1,20 +0,0 @@
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
- };
@@ -1,165 +0,0 @@
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
- }
@@ -1,11 +0,0 @@
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
- }
@@ -1,56 +0,0 @@
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 };
@@ -1,23 +0,0 @@
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
- }
@@ -1,11 +0,0 @@
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
- };
@@ -1,59 +0,0 @@
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
@@ -1,35 +0,0 @@
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';
@@ -1,31 +0,0 @@
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
- }));
@@ -1,11 +0,0 @@
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
- }
@@ -1,31 +0,0 @@
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
- }