@asaleh37/ui-base 1.1.9 → 1.2.0
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/dist/index.d.ts +11 -0
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/App.tsx +61 -3
- package/src/components/BaseApp.tsx +7 -0
- package/src/components/common/Login.tsx +28 -2
- package/src/layout/MainContent.tsx +12 -9
- package/src/layout/NavigationTree.tsx +10 -9
- package/src/redux/features/common/AppInfoSlice.ts +10 -0
- package/src/redux/features/common/CommonStoreSlice.ts +1 -4
- package/src/theme/DarkThemeOptions.ts +0 -30
- package/src/theme/LightThemeOptions.ts +0 -34
package/package.json
CHANGED
package/src/components/App.tsx
CHANGED
|
@@ -1,16 +1,74 @@
|
|
|
1
1
|
import { useDispatch, useSelector } from "react-redux";
|
|
2
|
-
import { createTheme } from "@mui/material";
|
|
2
|
+
import { createTheme, ThemeOptions } from "@mui/material";
|
|
3
3
|
import { ThemeProvider } from "@emotion/react";
|
|
4
4
|
import React, { useEffect } from "react";
|
|
5
5
|
import { RootState } from "../redux/store";
|
|
6
|
-
import { LightThemeOptions } from "../theme/LightThemeOptions";
|
|
7
|
-
import { DarkThemeOptions } from "../theme/DarkThemeOptions";
|
|
8
6
|
import Layout from "../layout/Layout";
|
|
9
7
|
import { AppInfo, AppInfoActions } from "../redux/features/common/AppInfoSlice";
|
|
10
8
|
import { LicenseInfo } from "@mui/x-license";
|
|
11
9
|
|
|
12
10
|
const App: React.FC<AppInfo> = (props: AppInfo) => {
|
|
13
11
|
LicenseInfo.setLicenseKey(props.muiPremiumKey);
|
|
12
|
+
const LightThemeOptions: ThemeOptions = {
|
|
13
|
+
components: {
|
|
14
|
+
MuiCssBaseline: {
|
|
15
|
+
styleOverrides: `
|
|
16
|
+
/* Custom Scrollbar */
|
|
17
|
+
* {
|
|
18
|
+
scrollbar-width: thin;
|
|
19
|
+
scrollbar-color: ${props.appTheme.light.primaryColor} #ffffff;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* Webkit Browsers */
|
|
23
|
+
*::-webkit-scrollbar {
|
|
24
|
+
width: 12px;
|
|
25
|
+
height: 10px;
|
|
26
|
+
}
|
|
27
|
+
`,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
palette: {
|
|
31
|
+
mode: "light",
|
|
32
|
+
primary: {
|
|
33
|
+
main: props.appTheme.light.primaryColor,
|
|
34
|
+
},
|
|
35
|
+
secondary: {
|
|
36
|
+
main: props.appTheme.light.secondaryColor,
|
|
37
|
+
},
|
|
38
|
+
background: {
|
|
39
|
+
default: "#f5f5f5",
|
|
40
|
+
paper: "#f5f5f5",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
const DarkThemeOptions: ThemeOptions = {
|
|
45
|
+
components: {
|
|
46
|
+
MuiCssBaseline: {
|
|
47
|
+
styleOverrides: `
|
|
48
|
+
/* Custom Scrollbar */
|
|
49
|
+
* {
|
|
50
|
+
scrollbar-width: thin;
|
|
51
|
+
scrollbar-color: ${props.appTheme.dark.primaryColor} #121212;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* Webkit Browsers */
|
|
55
|
+
*::-webkit-scrollbar {
|
|
56
|
+
width: 12px;
|
|
57
|
+
height: 10px;
|
|
58
|
+
}
|
|
59
|
+
`,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
palette: {
|
|
63
|
+
mode: "dark",
|
|
64
|
+
primary: {
|
|
65
|
+
main: props.appTheme.dark.primaryColor,
|
|
66
|
+
},
|
|
67
|
+
secondary: {
|
|
68
|
+
main: props.appTheme.dark.secondaryColor,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
|
14
72
|
const dispatch = useDispatch();
|
|
15
73
|
const AppLayoutState = useSelector((state: RootState) => state.AppLayout);
|
|
16
74
|
let themeOptions = { ...LightThemeOptions };
|
|
@@ -9,12 +9,19 @@ import "react-toastify/dist/ReactToastify.css";
|
|
|
9
9
|
import App from "./App";
|
|
10
10
|
import { AppInfo } from "../redux/features/common/AppInfoSlice";
|
|
11
11
|
import { commonStoresInitialState } from "../redux/features/common/CommonStoreSlice";
|
|
12
|
+
import { ADMINISTRATION_STORES } from "../redux/features/administration/AdministrationStoresMetaData";
|
|
12
13
|
|
|
13
14
|
library.add(fab);
|
|
14
15
|
library.add(far);
|
|
15
16
|
library.add(fas);
|
|
16
17
|
|
|
17
18
|
export const BaseApp: React.FC<AppInfo> = (props) => {
|
|
19
|
+
if (props.enableAdministrationModule) {
|
|
20
|
+
for (let adminStoreKey of Object.keys(ADMINISTRATION_STORES)) {
|
|
21
|
+
commonStoresInitialState[adminStoreKey] =
|
|
22
|
+
ADMINISTRATION_STORES[adminStoreKey];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
18
25
|
if (props?.businessCommonStoresMetaData) {
|
|
19
26
|
for (let businessStoreKey of Object.keys(
|
|
20
27
|
props.businessCommonStoresMetaData
|
|
@@ -14,7 +14,6 @@ import axios from "axios";
|
|
|
14
14
|
import { toast } from "react-toastify";
|
|
15
15
|
import { RootState } from "../../redux/store";
|
|
16
16
|
import { UserSessionActions } from "../../redux/features/common/UserSessionSlice";
|
|
17
|
-
import { DarkThemeOptions } from "../../theme/DarkThemeOptions";
|
|
18
17
|
|
|
19
18
|
const Login: React.FC = () => {
|
|
20
19
|
const appInfo = useSelector((state: RootState) => state.AppInfo.value);
|
|
@@ -67,7 +66,34 @@ const Login: React.FC = () => {
|
|
|
67
66
|
const userSession = useSelector(
|
|
68
67
|
(state: RootState) => state.UserSession.value
|
|
69
68
|
);
|
|
70
|
-
const loginTheme = createTheme(
|
|
69
|
+
const loginTheme = createTheme({
|
|
70
|
+
components: {
|
|
71
|
+
MuiCssBaseline: {
|
|
72
|
+
styleOverrides: `
|
|
73
|
+
/* Custom Scrollbar */
|
|
74
|
+
* {
|
|
75
|
+
scrollbar-width: thin;
|
|
76
|
+
scrollbar-color: ${appInfo.appTheme.dark.primaryColor} #121212;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* Webkit Browsers */
|
|
80
|
+
*::-webkit-scrollbar {
|
|
81
|
+
width: 12px;
|
|
82
|
+
height: 10px;
|
|
83
|
+
}
|
|
84
|
+
`,
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
palette: {
|
|
88
|
+
mode: "dark",
|
|
89
|
+
primary: {
|
|
90
|
+
main: appInfo.appTheme.dark.primaryColor,
|
|
91
|
+
},
|
|
92
|
+
secondary: {
|
|
93
|
+
main: appInfo.appTheme.dark.secondaryColor,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
});
|
|
71
97
|
const checkUserSession = async () => {
|
|
72
98
|
if (appInfo?.apiBaseUrl) {
|
|
73
99
|
if (userSession.isAuthenticated == null) {
|
|
@@ -9,6 +9,7 @@ import { SystemRoute } from "../routes/types";
|
|
|
9
9
|
|
|
10
10
|
const MainContent: React.FC = () => {
|
|
11
11
|
const AppLayoutState = useSelector((state: RootState) => state.AppLayout);
|
|
12
|
+
const AppInfo = useSelector((state: RootState) => state.AppInfo.value);
|
|
12
13
|
const businessRoutes = useSelector(
|
|
13
14
|
(state: RootState) => state.AppInfo.value.businessRoutes
|
|
14
15
|
);
|
|
@@ -28,15 +29,17 @@ const MainContent: React.FC = () => {
|
|
|
28
29
|
}}
|
|
29
30
|
>
|
|
30
31
|
<Routes>
|
|
31
|
-
{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
{AppInfo.enableAdministrationModule
|
|
33
|
+
? SYSTEM_ROUTES.map((route: SystemRoute, index) => {
|
|
34
|
+
return (
|
|
35
|
+
<Route
|
|
36
|
+
key={"adm" + index}
|
|
37
|
+
path={route.path}
|
|
38
|
+
Component={route.component}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
})
|
|
42
|
+
: null}
|
|
40
43
|
{businessRoutes.map((route: SystemRoute, index) => {
|
|
41
44
|
return (
|
|
42
45
|
<Route
|
|
@@ -232,9 +232,7 @@ const CustomTreeItem = React.forwardRef(function CustomTreeItem(
|
|
|
232
232
|
export default function NavigationTree() {
|
|
233
233
|
const navigate = useNavigate();
|
|
234
234
|
const appLayoutState = useSelector((state: RootState) => state.AppLayout);
|
|
235
|
-
const
|
|
236
|
-
(state: RootState) => state.AppInfo.value.businessNavigationItems
|
|
237
|
-
);
|
|
235
|
+
const AppInfo = useSelector((state: RootState) => state.AppInfo.value);
|
|
238
236
|
const dispatch = useDispatch();
|
|
239
237
|
const isMobile = useIsMobile();
|
|
240
238
|
const { isUserAuthorized } = useSession();
|
|
@@ -254,18 +252,21 @@ export default function NavigationTree() {
|
|
|
254
252
|
});
|
|
255
253
|
};
|
|
256
254
|
|
|
257
|
-
const mergedNavigationItems = [
|
|
258
|
-
|
|
259
|
-
...
|
|
260
|
-
|
|
261
|
-
|
|
255
|
+
const mergedNavigationItems = [];
|
|
256
|
+
if (AppInfo.enableAdministrationModule) {
|
|
257
|
+
mergedNavigationItems.push(...NavigationItems);
|
|
258
|
+
}
|
|
259
|
+
mergedNavigationItems.push(...AppInfo.businessNavigationItems);
|
|
262
260
|
const authoriedNavigationItems = filterData(mergedNavigationItems);
|
|
263
261
|
|
|
264
262
|
return (
|
|
265
263
|
<RichTreeView
|
|
266
264
|
items={authoriedNavigationItems}
|
|
267
265
|
onItemClick={(event, itemId) => {
|
|
268
|
-
const navigationItem = findNavigationItemById(
|
|
266
|
+
const navigationItem = findNavigationItemById(
|
|
267
|
+
itemId,
|
|
268
|
+
mergedNavigationItems
|
|
269
|
+
);
|
|
269
270
|
if (
|
|
270
271
|
navigationItem?.action === "NAVIGATION" &&
|
|
271
272
|
navigationItem?.actionPayload != null &&
|
|
@@ -14,6 +14,11 @@ export type AppInfo = {
|
|
|
14
14
|
businessReduxReducers: { [key: string]: Reducer<any> };
|
|
15
15
|
businessCommonStoresMetaData: { [key: string]: StoreMetaData };
|
|
16
16
|
muiPremiumKey: string;
|
|
17
|
+
enableAdministrationModule: boolean;
|
|
18
|
+
appTheme: {
|
|
19
|
+
light: { primaryColor: string; secondaryColor: string };
|
|
20
|
+
dark: { primaryColor: string; secondaryColor: string };
|
|
21
|
+
};
|
|
17
22
|
};
|
|
18
23
|
|
|
19
24
|
export type AppInfoProp = {
|
|
@@ -28,10 +33,15 @@ const initialState: AppInfoProp = {
|
|
|
28
33
|
appVersion: null,
|
|
29
34
|
appLogo: null,
|
|
30
35
|
muiPremiumKey: null,
|
|
36
|
+
enableAdministrationModule: false,
|
|
31
37
|
businessRoutes: [],
|
|
32
38
|
businessNavigationItems: [],
|
|
33
39
|
businessReduxReducers: {},
|
|
34
40
|
businessCommonStoresMetaData: {},
|
|
41
|
+
appTheme: {
|
|
42
|
+
light: { primaryColor: "#37505C", secondaryColor: "#ff6d00" },
|
|
43
|
+
dark: { primaryColor: "#ea690e", secondaryColor: "#74776B" },
|
|
44
|
+
},
|
|
35
45
|
},
|
|
36
46
|
};
|
|
37
47
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
-
import { ADMINISTRATION_STORES } from "../administration/AdministrationStoresMetaData";
|
|
3
2
|
|
|
4
3
|
export interface CommonStoresInterface {
|
|
5
4
|
[key: string]: StoreMetaData;
|
|
@@ -17,9 +16,7 @@ export interface StoreMetaData {
|
|
|
17
16
|
authority?: string;
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
export const commonStoresInitialState: CommonStoresInterface = {
|
|
21
|
-
...ADMINISTRATION_STORES,
|
|
22
|
-
};
|
|
19
|
+
export const commonStoresInitialState: CommonStoresInterface = {};
|
|
23
20
|
|
|
24
21
|
const commonStoreSlice = createSlice({
|
|
25
22
|
name: "loadingMask",
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { ThemeOptions } from "@mui/material";
|
|
2
|
-
|
|
3
|
-
export const DarkThemeOptions: ThemeOptions = {
|
|
4
|
-
components: {
|
|
5
|
-
MuiCssBaseline: {
|
|
6
|
-
styleOverrides: `
|
|
7
|
-
/* Custom Scrollbar */
|
|
8
|
-
* {
|
|
9
|
-
scrollbar-width: thin;
|
|
10
|
-
scrollbar-color: #ea690e #121212;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/* Webkit Browsers */
|
|
14
|
-
*::-webkit-scrollbar {
|
|
15
|
-
width: 12px;
|
|
16
|
-
height: 10px;
|
|
17
|
-
}
|
|
18
|
-
`,
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
palette: {
|
|
22
|
-
mode: "dark",
|
|
23
|
-
primary: {
|
|
24
|
-
main: "#ea690e",
|
|
25
|
-
},
|
|
26
|
-
secondary: {
|
|
27
|
-
main: "#74776B",
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { ThemeOptions } from "@mui/material";
|
|
2
|
-
|
|
3
|
-
export const LightThemeOptions: ThemeOptions = {
|
|
4
|
-
components: {
|
|
5
|
-
MuiCssBaseline: {
|
|
6
|
-
styleOverrides: `
|
|
7
|
-
/* Custom Scrollbar */
|
|
8
|
-
* {
|
|
9
|
-
scrollbar-width: thin;
|
|
10
|
-
scrollbar-color: #37505C #ffffff;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/* Webkit Browsers */
|
|
14
|
-
*::-webkit-scrollbar {
|
|
15
|
-
width: 12px;
|
|
16
|
-
height: 10px;
|
|
17
|
-
}
|
|
18
|
-
`,
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
palette: {
|
|
22
|
-
mode: "light",
|
|
23
|
-
primary: {
|
|
24
|
-
main: "#37505C",
|
|
25
|
-
},
|
|
26
|
-
secondary: {
|
|
27
|
-
main: "#ff6d00",
|
|
28
|
-
},
|
|
29
|
-
background: {
|
|
30
|
-
default: "#f5f5f5",
|
|
31
|
-
paper: "#f5f5f5",
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
};
|