@asaleh37/ui-base 1.1.7 → 1.1.8
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 +465 -1
- 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/BaseApp.tsx +18 -1
- package/src/components/index.ts +1 -0
- package/src/components/templates/DataEntryTemplates/useApiActions.ts +1 -1
- package/src/components/templates/TransferList.tsx +1 -1
- package/src/components/templates/index.ts +19 -0
- package/src/components/templates/visuals/TemplateDashboard.tsx +1 -1
- package/src/hooks/index.ts +6 -0
- package/src/index.ts +2 -2
- package/src/layout/Layout.tsx +2 -3
- package/src/layout/MainContent.tsx +14 -2
- package/src/layout/NavigationTree.tsx +9 -1
- package/src/redux/features/administration/AdministrationStoresMetaData.ts +1 -1
- package/src/redux/features/common/AppInfoSlice.ts +12 -1
- package/src/redux/features/{business → common}/CommonStoreSlice.ts +2 -4
- package/src/redux/store.ts +17 -9
- package/src/util/index.ts +2 -0
- package/src/redux/features/business/BusinessStoresMetaData.ts +0 -3
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Provider } from "react-redux";
|
|
2
|
-
import { store } from "../redux/store";
|
|
2
|
+
import { addReducer, store } from "../redux/store";
|
|
3
3
|
import { library } from "@fortawesome/fontawesome-svg-core";
|
|
4
4
|
import { fab } from "@fortawesome/free-brands-svg-icons";
|
|
5
5
|
import { far } from "@fortawesome/free-regular-svg-icons";
|
|
@@ -13,12 +13,29 @@ LicenseInfo.setLicenseKey(
|
|
|
13
13
|
import "react-toastify/dist/ReactToastify.css";
|
|
14
14
|
import App from "./App";
|
|
15
15
|
import { AppInfo } from "../redux/features/common/AppInfoSlice";
|
|
16
|
+
import { commonStoresInitialState } from "../redux/features/common/CommonStoreSlice";
|
|
16
17
|
|
|
17
18
|
library.add(fab);
|
|
18
19
|
library.add(far);
|
|
19
20
|
library.add(fas);
|
|
20
21
|
|
|
21
22
|
export const BaseApp: React.FC<AppInfo> = (props) => {
|
|
23
|
+
if (props?.businessCommonStoresMetaData) {
|
|
24
|
+
for (let businessStoreKey of Object.keys(
|
|
25
|
+
props.businessCommonStoresMetaData
|
|
26
|
+
)) {
|
|
27
|
+
commonStoresInitialState[businessStoreKey] =
|
|
28
|
+
props.businessCommonStoresMetaData[businessStoreKey];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (props?.businessReduxReducers) {
|
|
32
|
+
for (let businessReducerKey of Object.keys(props.businessReduxReducers)) {
|
|
33
|
+
addReducer(
|
|
34
|
+
businessReducerKey,
|
|
35
|
+
props.businessReduxReducers[businessReducerKey]
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
22
39
|
return (
|
|
23
40
|
<Provider store={store}>
|
|
24
41
|
<App {...props} />
|
package/src/components/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useDispatch, useSelector } from "react-redux";
|
|
2
2
|
import { RootState } from "../../../redux/store";
|
|
3
|
-
import { setStoreData } from "../../../redux/features/business/CommonStoreSlice";
|
|
4
3
|
import useSession from "../../../hooks/UseSession";
|
|
5
4
|
import useAxios from "../../../hooks/useAxios";
|
|
5
|
+
import { setStoreData } from "../../../redux/features/common/CommonStoreSlice";
|
|
6
6
|
|
|
7
7
|
export type ApiActionsProps = {
|
|
8
8
|
findAll?: string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { default as TransferList } from "./TransferList";
|
|
2
|
+
export { default as TemplateDashboard } from "./visuals/TemplateDashboard";
|
|
3
|
+
export { default as TemplateBarChart } from "./visuals/charts/TemplateBarChart";
|
|
4
|
+
export { default as TemplateDataCard } from "./visuals/charts/TemplateDataCard";
|
|
5
|
+
export { default as TemplateGauge } from "./visuals/charts/TemplateGauge";
|
|
6
|
+
export { default as TemplateLineChart } from "./visuals/charts/TemplateLineChart";
|
|
7
|
+
export { default as TemplateLineProgress } from "./visuals/charts/TemplateLineProgress";
|
|
8
|
+
export { default as TemplatePieChart } from "./visuals/charts/TemplatePieChart";
|
|
9
|
+
export { default as CheckBox } from "./DataEntryTemplates/TemplateDataForm/FormFields/CheckBox";
|
|
10
|
+
export { default as ComboBox } from "./DataEntryTemplates/TemplateDataForm/FormFields/ComboBox";
|
|
11
|
+
export { default as Datefield } from "./DataEntryTemplates/TemplateDataForm/FormFields/Datefield";
|
|
12
|
+
export { default as DatetimeField } from "./DataEntryTemplates/TemplateDataForm/FormFields/DatetimeField";
|
|
13
|
+
export { default as TemplateTextField } from "./DataEntryTemplates/TemplateDataForm/FormFields/TemplateTextField";
|
|
14
|
+
export { default as TemplateForm } from "./DataEntryTemplates/TemplateDataForm/TemplateForm";
|
|
15
|
+
export { default as TemplateGrid } from "./DataEntryTemplates/TemplateDataGrid/TemplateGrid";
|
|
16
|
+
|
|
17
|
+
export type * from "./DataEntryTemplates/DataEntryTypes";
|
|
18
|
+
export type { DashboardProps } from "./visuals/TemplateDashboard";
|
|
19
|
+
export type { TransferListProps } from "./TransferList";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as useAxios } from "./useAxios";
|
|
2
|
+
export { useConfirmationWindow } from "./UseConfirmationWindow";
|
|
3
|
+
export { default as useLoadingMask } from "./useLoadingMask";
|
|
4
|
+
export { useIsMobile } from "./UseMobile";
|
|
5
|
+
export { default as useSession } from "./UseSession";
|
|
6
|
+
export { useWindow } from "./UseWindow";
|
package/src/index.ts
CHANGED
package/src/layout/Layout.tsx
CHANGED
|
@@ -14,12 +14,11 @@ import useLoadingMask from "../hooks/useLoadingMask";
|
|
|
14
14
|
import { useIsMobile } from "../hooks/UseMobile";
|
|
15
15
|
import useSession from "../hooks/UseSession";
|
|
16
16
|
import useAxios from "../hooks/useAxios";
|
|
17
|
-
import { setStoreData } from "../redux/features/business/CommonStoreSlice";
|
|
18
17
|
import { DRAWER_WIDTH } from "../redux/features/common/AppLayoutSlice";
|
|
19
18
|
import { UserSessionProps } from "../redux/features/common/UserSessionSlice";
|
|
20
19
|
import LoadingMask from "../components/common/LoadingMask";
|
|
21
20
|
import Login from "../components/common/Login";
|
|
22
|
-
|
|
21
|
+
import { setStoreData } from "../redux/features/common/CommonStoreSlice";
|
|
23
22
|
|
|
24
23
|
const Main = styled("main", {
|
|
25
24
|
shouldForwardProp: (prop) => prop !== "open",
|
|
@@ -104,7 +103,7 @@ export default function Layout() {
|
|
|
104
103
|
return (
|
|
105
104
|
<BrowserRouter>
|
|
106
105
|
<ToastContainer draggable={true} position="bottom-center" />
|
|
107
|
-
<LoadingMask />
|
|
106
|
+
<LoadingMask />
|
|
108
107
|
{UserSession.value.isAuthenticated === true ? (
|
|
109
108
|
<Main open={AppLayoutState.sideBarOpened}>
|
|
110
109
|
<CssBaseline />
|
|
@@ -9,6 +9,9 @@ import { SystemRoute } from "../routes/types";
|
|
|
9
9
|
|
|
10
10
|
const MainContent: React.FC = () => {
|
|
11
11
|
const AppLayoutState = useSelector((state: RootState) => state.AppLayout);
|
|
12
|
+
const businessRoutes = useSelector(
|
|
13
|
+
(state: RootState) => state.AppInfo.value.businessRoutes
|
|
14
|
+
);
|
|
12
15
|
return (
|
|
13
16
|
<CacheProvider
|
|
14
17
|
value={AppLayoutState.appDirection === "ltr" ? cacheLtr : cacheRtl}
|
|
@@ -19,7 +22,7 @@ const MainContent: React.FC = () => {
|
|
|
19
22
|
flexDirection: "column",
|
|
20
23
|
// alignItems: "center",
|
|
21
24
|
justifyContent: "flex-start",
|
|
22
|
-
flex: 1,
|
|
25
|
+
flex: 1,
|
|
23
26
|
overflow: "hidden",
|
|
24
27
|
padding: 3,
|
|
25
28
|
}}
|
|
@@ -28,7 +31,16 @@ const MainContent: React.FC = () => {
|
|
|
28
31
|
{SYSTEM_ROUTES.map((route: SystemRoute, index) => {
|
|
29
32
|
return (
|
|
30
33
|
<Route
|
|
31
|
-
key={index}
|
|
34
|
+
key={"adm" + index}
|
|
35
|
+
path={route.path}
|
|
36
|
+
Component={route.component}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
})}
|
|
40
|
+
{businessRoutes.map((route: SystemRoute, index) => {
|
|
41
|
+
return (
|
|
42
|
+
<Route
|
|
43
|
+
key={"bs" + index}
|
|
32
44
|
path={route.path}
|
|
33
45
|
Component={route.component}
|
|
34
46
|
/>
|
|
@@ -232,6 +232,9 @@ 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 businessNavigationItems = useSelector(
|
|
236
|
+
(state: RootState) => state.AppInfo.value.businessNavigationItems
|
|
237
|
+
);
|
|
235
238
|
const dispatch = useDispatch();
|
|
236
239
|
const isMobile = useIsMobile();
|
|
237
240
|
const { isUserAuthorized } = useSession();
|
|
@@ -251,7 +254,12 @@ export default function NavigationTree() {
|
|
|
251
254
|
});
|
|
252
255
|
};
|
|
253
256
|
|
|
254
|
-
const
|
|
257
|
+
const mergedNavigationItems = [
|
|
258
|
+
...NavigationItems,
|
|
259
|
+
...businessNavigationItems,
|
|
260
|
+
];
|
|
261
|
+
|
|
262
|
+
const authoriedNavigationItems = filterData(mergedNavigationItems);
|
|
255
263
|
|
|
256
264
|
return (
|
|
257
265
|
<RichTreeView
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { createSlice } from "@reduxjs/toolkit";
|
|
1
|
+
import { createSlice, Reducer } from "@reduxjs/toolkit";
|
|
2
|
+
import { SystemRoute } from "../../../routes/types";
|
|
3
|
+
import { ExtendedTreeItemProps } from "../../../navigationItems";
|
|
4
|
+
import { StoreMetaData } from "./CommonStoreSlice";
|
|
2
5
|
|
|
3
6
|
export type AppInfo = {
|
|
4
7
|
documentTitle: string | null;
|
|
@@ -6,6 +9,10 @@ export type AppInfo = {
|
|
|
6
9
|
appName: string | null;
|
|
7
10
|
appVersion: string | null;
|
|
8
11
|
appLogo: any | null;
|
|
12
|
+
businessRoutes: Array<SystemRoute>;
|
|
13
|
+
businessNavigationItems: Array<ExtendedTreeItemProps>;
|
|
14
|
+
businessReduxReducers: { [key: string]: Reducer<any> };
|
|
15
|
+
businessCommonStoresMetaData: { [key: string]: StoreMetaData };
|
|
9
16
|
};
|
|
10
17
|
|
|
11
18
|
export type AppInfoProp = {
|
|
@@ -19,6 +26,10 @@ const initialState: AppInfoProp = {
|
|
|
19
26
|
appName: null,
|
|
20
27
|
appVersion: null,
|
|
21
28
|
appLogo: null,
|
|
29
|
+
businessRoutes: [],
|
|
30
|
+
businessNavigationItems: [],
|
|
31
|
+
businessReduxReducers: {},
|
|
32
|
+
businessCommonStoresMetaData: {},
|
|
22
33
|
},
|
|
23
34
|
};
|
|
24
35
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
-
import { BUSINESS_STORES } from "./BusinessStoresMetaData";
|
|
3
2
|
import { ADMINISTRATION_STORES } from "../administration/AdministrationStoresMetaData";
|
|
4
3
|
|
|
5
4
|
export interface CommonStoresInterface {
|
|
@@ -18,14 +17,13 @@ export interface StoreMetaData {
|
|
|
18
17
|
authority?: string;
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
const
|
|
22
|
-
...BUSINESS_STORES,
|
|
20
|
+
export const commonStoresInitialState: CommonStoresInterface = {
|
|
23
21
|
...ADMINISTRATION_STORES,
|
|
24
22
|
};
|
|
25
23
|
|
|
26
24
|
const commonStoreSlice = createSlice({
|
|
27
25
|
name: "loadingMask",
|
|
28
|
-
initialState,
|
|
26
|
+
initialState: commonStoresInitialState,
|
|
29
27
|
reducers: {
|
|
30
28
|
setStoreData(state, action: PayloadAction<setStoreDataProps>) {
|
|
31
29
|
state[action.payload.storeKey].data = action.payload.data;
|
package/src/redux/store.ts
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
|
-
import { configureStore } from "@reduxjs/toolkit";
|
|
1
|
+
import { configureStore, Reducer } from "@reduxjs/toolkit";
|
|
2
2
|
import AppLayoutReducer from "./features/common/AppLayoutSlice";
|
|
3
3
|
import UserSessionReducer from "./features/common/UserSessionSlice";
|
|
4
4
|
import LoadingMaskReducer from "./features/common/LoadingMaskSlice";
|
|
5
|
-
import CommonStoreReducer from "./features/
|
|
5
|
+
import CommonStoreReducer from "./features/common/CommonStoreSlice";
|
|
6
6
|
import AppInfoReducer from "./features/common/AppInfoSlice";
|
|
7
7
|
|
|
8
|
+
const reducers = {
|
|
9
|
+
AppLayout: AppLayoutReducer,
|
|
10
|
+
UserSession: UserSessionReducer,
|
|
11
|
+
loadingMask: LoadingMaskReducer,
|
|
12
|
+
commonStores: CommonStoreReducer,
|
|
13
|
+
AppInfo: AppInfoReducer,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export function addReducer(key: string, reducer: Reducer<any>) {
|
|
17
|
+
if (!reducers[key]) {
|
|
18
|
+
reducers[key] = reducer;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
8
22
|
export const store = configureStore({
|
|
9
|
-
reducer:
|
|
10
|
-
AppLayout: AppLayoutReducer,
|
|
11
|
-
UserSession: UserSessionReducer,
|
|
12
|
-
loadingMask: LoadingMaskReducer,
|
|
13
|
-
commonStores: CommonStoreReducer,
|
|
14
|
-
AppInfo: AppInfoReducer,
|
|
15
|
-
},
|
|
23
|
+
reducer: reducers,
|
|
16
24
|
});
|
|
17
25
|
|
|
18
26
|
// Infer the `RootState` and `AppDispatch` types from the store itself
|