@j2inn/fin5-ui-utils 1.0.8-react-router.3 → 1.0.8-react-router.4
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 +6 -6
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/react/components/navigation/BasicLayout.d.ts +9 -11
- package/dist/react/components/navigation/BasicLayout.js +8 -26
- package/dist/react/components/navigation/BasicLayout.js.map +1 -1
- package/dist/react/components/navigation/ReactRouterLayout.d.ts +16 -0
- package/dist/react/components/navigation/ReactRouterLayout.js +80 -0
- package/dist/react/components/navigation/ReactRouterLayout.js.map +1 -0
- package/dist/react/components/navigation/{Router.d.ts → customRouting/Router.d.ts} +1 -1
- package/dist/react/components/navigation/{Router.js → customRouting/Router.js} +2 -2
- package/dist/react/components/navigation/customRouting/Router.js.map +1 -0
- package/dist/react/components/navigation/customRouting/RouterLayout.d.ts +11 -0
- package/dist/react/components/navigation/customRouting/RouterLayout.js +62 -0
- package/dist/react/components/navigation/customRouting/RouterLayout.js.map +1 -0
- package/dist_es/index.d.ts +6 -6
- package/dist_es/index.js +6 -6
- package/dist_es/index.js.map +1 -1
- package/dist_es/react/components/navigation/BasicLayout.d.ts +9 -11
- package/dist_es/react/components/navigation/BasicLayout.js +10 -28
- package/dist_es/react/components/navigation/BasicLayout.js.map +1 -1
- package/dist_es/react/components/navigation/ReactRouterLayout.d.ts +16 -0
- package/dist_es/react/components/navigation/ReactRouterLayout.js +52 -0
- package/dist_es/react/components/navigation/ReactRouterLayout.js.map +1 -0
- package/dist_es/react/components/navigation/customRouting/Router.d.ts +12 -0
- package/dist_es/react/components/navigation/customRouting/Router.js +19 -0
- package/dist_es/react/components/navigation/customRouting/Router.js.map +1 -0
- package/dist_es/react/components/navigation/customRouting/RouterLayout.d.ts +11 -0
- package/dist_es/react/components/navigation/customRouting/RouterLayout.js +35 -0
- package/dist_es/react/components/navigation/customRouting/RouterLayout.js.map +1 -0
- package/package.json +1 -1
- package/dist/react/components/navigation/Router.js.map +0 -1
- package/dist/react/components/navigation/react-router/ReactRouterBasicLayout.d.ts +0 -24
- package/dist/react/components/navigation/react-router/ReactRouterBasicLayout.js +0 -113
- package/dist/react/components/navigation/react-router/ReactRouterBasicLayout.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,16 +3,16 @@ export * from './fin5Top/getFin5BinUrl';
|
|
|
3
3
|
export * from './fin5Top/openFin5Alarm';
|
|
4
4
|
export * from './fin5Top/openFin5Historian';
|
|
5
5
|
export * from './fin5Top/useFin5AppURLHashParameter';
|
|
6
|
-
export * from './react/components/ErrorDisplayer';
|
|
7
6
|
export * from './react/components/ErrorBoundary';
|
|
7
|
+
export * from './react/components/ErrorDisplayer';
|
|
8
8
|
export * from './react/components/Loader';
|
|
9
9
|
export * from './react/components/LoadingSpinner';
|
|
10
|
-
export * from './react/components/navigation/BasicLayout';
|
|
11
|
-
export * from './react/components/navigation/MenuPage';
|
|
12
|
-
export * from './react/components/navigation/Router';
|
|
13
|
-
export * from './react/components/navigation/react-router/ReactRouterBasicLayout';
|
|
14
|
-
export * from './react/components/graphics/GraphicsTabViewer';
|
|
15
10
|
export * from './react/components/graphics/GraphicViewer';
|
|
11
|
+
export * from './react/components/graphics/GraphicsTabViewer';
|
|
12
|
+
export * from './react/components/navigation/MenuPage';
|
|
13
|
+
export * from './react/components/navigation/ReactRouterLayout';
|
|
14
|
+
export * from './react/components/navigation/customRouting/RouterLayout';
|
|
15
|
+
export * from './react/components/navigation/customRouting/Router';
|
|
16
16
|
export * from './react/components/resolvable/configurationForm/ConfigurationForm';
|
|
17
17
|
export * from './react/components/resolvable/configurationForm/ConfigurationFormEntry';
|
|
18
18
|
export * from './react/components/resolvable/configurationForm/getSectionDefault';
|
package/dist/index.js
CHANGED
|
@@ -28,16 +28,16 @@ __exportStar(require("./fin5Top/useFin5AppURLHashParameter"), exports);
|
|
|
28
28
|
//////////////////////////////////////////////////////////////////////////
|
|
29
29
|
// React components
|
|
30
30
|
//////////////////////////////////////////////////////////////////////////
|
|
31
|
-
__exportStar(require("./react/components/ErrorDisplayer"), exports);
|
|
32
31
|
__exportStar(require("./react/components/ErrorBoundary"), exports);
|
|
32
|
+
__exportStar(require("./react/components/ErrorDisplayer"), exports);
|
|
33
33
|
__exportStar(require("./react/components/Loader"), exports);
|
|
34
34
|
__exportStar(require("./react/components/LoadingSpinner"), exports);
|
|
35
|
-
__exportStar(require("./react/components/navigation/BasicLayout"), exports);
|
|
36
|
-
__exportStar(require("./react/components/navigation/MenuPage"), exports);
|
|
37
|
-
__exportStar(require("./react/components/navigation/Router"), exports);
|
|
38
|
-
__exportStar(require("./react/components/navigation/react-router/ReactRouterBasicLayout"), exports);
|
|
39
|
-
__exportStar(require("./react/components/graphics/GraphicsTabViewer"), exports);
|
|
40
35
|
__exportStar(require("./react/components/graphics/GraphicViewer"), exports);
|
|
36
|
+
__exportStar(require("./react/components/graphics/GraphicsTabViewer"), exports);
|
|
37
|
+
__exportStar(require("./react/components/navigation/MenuPage"), exports);
|
|
38
|
+
__exportStar(require("./react/components/navigation/ReactRouterLayout"), exports);
|
|
39
|
+
__exportStar(require("./react/components/navigation/customRouting/RouterLayout"), exports);
|
|
40
|
+
__exportStar(require("./react/components/navigation/customRouting/Router"), exports);
|
|
41
41
|
__exportStar(require("./react/components/resolvable/configurationForm/ConfigurationForm"), exports);
|
|
42
42
|
__exportStar(require("./react/components/resolvable/configurationForm/ConfigurationFormEntry"), exports);
|
|
43
43
|
__exportStar(require("./react/components/resolvable/configurationForm/getSectionDefault"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,0EAA0E;AAC1E,4BAA4B;AAC5B,0EAA0E;AAE1E,oDAAiC;AACjC,0DAAuC;AACvC,0DAAuC;AACvC,8DAA2C;AAC3C,uEAAoD;AAEpD,0EAA0E;AAC1E,mBAAmB;AACnB,0EAA0E;AAE1E,oEAAiD;AACjD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,0EAA0E;AAC1E,4BAA4B;AAC5B,0EAA0E;AAE1E,oDAAiC;AACjC,0DAAuC;AACvC,0DAAuC;AACvC,8DAA2C;AAC3C,uEAAoD;AAEpD,0EAA0E;AAC1E,mBAAmB;AACnB,0EAA0E;AAE1E,mEAAgD;AAChD,oEAAiD;AACjD,4DAAyC;AACzC,oEAAiD;AACjD,4EAAyD;AACzD,gFAA6D;AAC7D,yEAAsD;AACtD,kFAA+D;AAC/D,2FAAwE;AACxE,qFAAkE;AAClE,oGAAiF;AACjF,yGAAsF;AACtF,oGAAiF;AAEjF,0EAA0E;AAC1E,6BAA6B;AAC7B,0EAA0E;AAE1E,+DAA4C;AAC5C,+DAA4C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ThemeDef } from '@j2inn/ui';
|
|
2
2
|
import { LayoutProps, MenuProps, SiderProps } from 'antd';
|
|
3
|
-
import
|
|
3
|
+
import { PropsWithChildren, ReactElement } from 'react';
|
|
4
4
|
import { MenuPage } from './MenuPage';
|
|
5
5
|
export declare const HEADER_HEIGHT = 45;
|
|
6
6
|
interface StyleVariables {
|
|
@@ -10,15 +10,12 @@ interface StyleVariables {
|
|
|
10
10
|
}
|
|
11
11
|
export declare const useStyles: (data?: (StyleVariables & {
|
|
12
12
|
theme?: ThemeDef | undefined;
|
|
13
|
-
}) | undefined) => import("jss").Classes<"
|
|
14
|
-
export interface BasicLayoutProps {
|
|
15
|
-
|
|
16
|
-
* List of pages for the menu and the routing
|
|
17
|
-
*/
|
|
18
|
-
page?: string;
|
|
19
|
-
pages?: MenuPage[];
|
|
13
|
+
}) | undefined) => import("jss").Classes<"content" | "header" | "sider" | "menuTrigger">;
|
|
14
|
+
export interface BasicLayoutProps<T extends MenuPage> extends PropsWithChildren {
|
|
15
|
+
pages?: T[];
|
|
20
16
|
defaultPage?: string;
|
|
21
|
-
|
|
17
|
+
selectedPages?: string[];
|
|
18
|
+
onSelect: (key: string) => void;
|
|
22
19
|
compactSider?: boolean;
|
|
23
20
|
layoutProps?: LayoutProps;
|
|
24
21
|
mobileHeaderProps?: LayoutProps;
|
|
@@ -33,7 +30,8 @@ export interface BasicLayoutProps {
|
|
|
33
30
|
*/
|
|
34
31
|
export declare const getMenuPages: (pages: MenuPage[]) => MenuPage<Record<string, unknown>>[];
|
|
35
32
|
/**
|
|
36
|
-
* Basic layout
|
|
33
|
+
* Basic layout with sider and mobile navigation management.
|
|
34
|
+
* Routing management can be plugged in, for examples @see ReactRouterLayout @see RouterLayout
|
|
37
35
|
*/
|
|
38
|
-
export declare
|
|
36
|
+
export declare function BasicLayout<T extends MenuPage>({ pages, defaultPage, selectedPages, onSelect, compactSider, layoutProps, mobileHeaderProps, siderProps, contentProps, menuProps, children, }: BasicLayoutProps<T>): ReactElement;
|
|
39
37
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2023, J2 Innovations. All Rights Reserved
|
|
4
4
|
*/
|
|
5
5
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
6
|
if (k2 === undefined) k2 = k;
|
|
@@ -35,9 +35,6 @@ const ui_1 = require("@j2inn/ui");
|
|
|
35
35
|
const classnames_1 = __importDefault(require("classnames"));
|
|
36
36
|
const react_1 = __importStar(require("react"));
|
|
37
37
|
const react_jss_1 = require("react-jss");
|
|
38
|
-
const ErrorDisplayer_1 = require("../ErrorDisplayer");
|
|
39
|
-
const MenuPage_1 = require("./MenuPage");
|
|
40
|
-
const Router_1 = require("./Router");
|
|
41
38
|
exports.HEADER_HEIGHT = 45;
|
|
42
39
|
exports.useStyles = (0, react_jss_1.createUseStyles)((theme) => {
|
|
43
40
|
return {
|
|
@@ -106,19 +103,10 @@ const getMenuPages = (pages) => {
|
|
|
106
103
|
};
|
|
107
104
|
exports.getMenuPages = getMenuPages;
|
|
108
105
|
/**
|
|
109
|
-
* Basic layout
|
|
106
|
+
* Basic layout with sider and mobile navigation management.
|
|
107
|
+
* Routing management can be plugged in, for examples @see ReactRouterLayout @see RouterLayout
|
|
110
108
|
*/
|
|
111
|
-
|
|
112
|
-
const [currentPage, setCurrentPage] = (0, react_1.useState)(page ?? defaultPage);
|
|
113
|
-
(0, react_1.useEffect)(() => {
|
|
114
|
-
if (page) {
|
|
115
|
-
setCurrentPage(page);
|
|
116
|
-
}
|
|
117
|
-
}, [page]);
|
|
118
|
-
// Fire onChange
|
|
119
|
-
(0, react_1.useEffect)(() => {
|
|
120
|
-
onPageChange?.(currentPage);
|
|
121
|
-
}, [currentPage]);
|
|
109
|
+
function BasicLayout({ pages = [], defaultPage, selectedPages = [], onSelect, compactSider, layoutProps, mobileHeaderProps, siderProps, contentProps, menuProps, children, }) {
|
|
122
110
|
// manage mobile navigation
|
|
123
111
|
const [isMobile, setIsMobile] = (0, react_1.useState)(false);
|
|
124
112
|
const [hiddenSider, setHiddenSider] = (0, react_1.useState)(false);
|
|
@@ -139,19 +127,13 @@ const BasicLayout = ({ pages = [], defaultPage = pages?.[0].key ?? '', onPageCha
|
|
|
139
127
|
: compactSider
|
|
140
128
|
? exports.HEADER_HEIGHT
|
|
141
129
|
: 0, trigger: null },
|
|
142
|
-
react_1.default.createElement(ui_1.Menu, { ...menuProps, items: menuPages, selectedKeys:
|
|
130
|
+
react_1.default.createElement(ui_1.Menu, { ...menuProps, defaultSelectedKeys: defaultPage ? [defaultPage] : undefined, items: menuPages, selectedKeys: selectedPages, onSelect: ({ key }) => {
|
|
143
131
|
if (!hiddenSider) {
|
|
144
132
|
setHiddenSider(true);
|
|
145
133
|
}
|
|
146
|
-
|
|
147
|
-
if (page?.component) {
|
|
148
|
-
setCurrentPage(key);
|
|
149
|
-
}
|
|
134
|
+
onSelect(key);
|
|
150
135
|
} })),
|
|
151
|
-
react_1.default.createElement(Content, { ...contentProps, className: (0, classnames_1.default)(classes.content, contentProps?.className) },
|
|
152
|
-
|
|
153
|
-
react_1.default.createElement(ui_1.Button, { type: 'primary', key: 'refresh', onClick: () => setCurrentPage(defaultPage) }, "Go Home"),
|
|
154
|
-
] }) }))));
|
|
155
|
-
};
|
|
136
|
+
react_1.default.createElement(Content, { ...contentProps, className: (0, classnames_1.default)(classes.content, contentProps?.className) }, children)));
|
|
137
|
+
}
|
|
156
138
|
exports.BasicLayout = BasicLayout;
|
|
157
139
|
//# sourceMappingURL=BasicLayout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasicLayout.js","sourceRoot":"","sources":["../../../../src/react/components/navigation/BasicLayout.tsx"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAAwE;AACxE,
|
|
1
|
+
{"version":3,"file":"BasicLayout.js","sourceRoot":"","sources":["../../../../src/react/components/navigation/BasicLayout.tsx"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAAwE;AACxE,kCAAkD;AAElD,4DAAmC;AACnC,+CAKc;AACd,yCAA2C;AAG9B,QAAA,aAAa,GAAG,EAAE,CAAA;AAQlB,QAAA,SAAS,GAAG,IAAA,2BAAe,EAAC,CAAC,KAAe,EAAE,EAAE;IAC5D,OAAO;QACN,MAAM,EAAE;YACP,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,IAAI;YACZ,OAAO,EAAE,CAAC;YACV,MAAM,EAAE,qBAAa;YACrB,UAAU,EAAE,MAAM;SAClB;QACD,KAAK,EAAE;YACN,QAAQ,EAAE,MAAM;YAChB,MAAM,EAAE,OAAO;YACf,QAAQ,EAAE,OAAO;YACjB,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C,IAAI,CAAC,CAAA;qBACpB;oBACD,QAAQ,CAAC,GAAG,CAAC,CAAA;gBACd,CAAC,GACA,CACK;QACR,8BAAC,OAAO,OACH,YAAY,EAChB,SAAS,EAAE,IAAA,oBAAU,EACpB,OAAO,CAAC,OAAO,EACf,YAAY,EAAE,SAAS,CACvB,IACA,QAAQ,CACA,CACF,CACT,CAAA;AACF,CAAC;AAzFD,kCAyFC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Location } from '@remix-run/router';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { BasicLayoutProps } from './BasicLayout';
|
|
4
|
+
import { MenuPage } from './MenuPage';
|
|
5
|
+
export interface ReactRouterLayoutProps extends BasicLayoutProps<MenuPage> {
|
|
6
|
+
isSelectedRoute?: (page: MenuPage, location: Location) => boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* This hook can be used with react-router/BasicLayout,
|
|
10
|
+
* to ensure FIN5 URL is aligned with the internal frame URL.
|
|
11
|
+
*/
|
|
12
|
+
export declare const useLocationUpdate: () => void;
|
|
13
|
+
/**
|
|
14
|
+
* Basic layout that uses React Router.
|
|
15
|
+
*/
|
|
16
|
+
export declare const ReactRouterLayout: React.FC<ReactRouterLayoutProps>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023, J2 Innovations. All Rights Reserved
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.ReactRouterLayout = exports.useLocationUpdate = void 0;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const react_router_1 = require("react-router");
|
|
32
|
+
const useFin5AppURLHashParameter_1 = require("../../../fin5Top/useFin5AppURLHashParameter");
|
|
33
|
+
const BasicLayout_1 = require("./BasicLayout");
|
|
34
|
+
const MenuPage_1 = require("./MenuPage");
|
|
35
|
+
/**
|
|
36
|
+
* This hook can be used with react-router/BasicLayout,
|
|
37
|
+
* to ensure FIN5 URL is aligned with the internal frame URL.
|
|
38
|
+
*/
|
|
39
|
+
const useLocationUpdate = () => {
|
|
40
|
+
const location = (0, react_router_1.useLocation)();
|
|
41
|
+
(0, react_1.useEffect)(() => {
|
|
42
|
+
console.debug('Location changed', location);
|
|
43
|
+
const hash = location.pathname;
|
|
44
|
+
const queryParams = location.search;
|
|
45
|
+
if (useFin5AppURLHashParameter_1.IN_IFRAME) {
|
|
46
|
+
(0, useFin5AppURLHashParameter_1.fin5SkipHashUpdate)()?.then(() => {
|
|
47
|
+
const frameParameters = (0, useFin5AppURLHashParameter_1.getFin5HashFrameParameters)();
|
|
48
|
+
frameParameters.set('url', frameParameters.get('url')?.split('#')[0] +
|
|
49
|
+
'#' +
|
|
50
|
+
hash +
|
|
51
|
+
queryParams);
|
|
52
|
+
(0, useFin5AppURLHashParameter_1.getTopLocation)().hash = `#${(0, useFin5AppURLHashParameter_1.getTopLocation)().hash.slice(1).split('?')[0]}?${frameParameters.toString()}`;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}, [location]);
|
|
56
|
+
};
|
|
57
|
+
exports.useLocationUpdate = useLocationUpdate;
|
|
58
|
+
const useSelectedRoutes = (pages, isSelectedRoute = (page, location) => location.pathname.includes(`/${page.key}`)) => {
|
|
59
|
+
const location = (0, react_router_1.useLocation)();
|
|
60
|
+
return (0, react_1.useMemo)(() => {
|
|
61
|
+
const flatPages = (0, MenuPage_1.pageTreeToPageList)(pages);
|
|
62
|
+
return flatPages
|
|
63
|
+
.filter((page) => isSelectedRoute(page, location))
|
|
64
|
+
.map((page) => page.key);
|
|
65
|
+
}, [location, pages]);
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Basic layout that uses React Router.
|
|
69
|
+
*/
|
|
70
|
+
const ReactRouterLayout = ({ isSelectedRoute, pages = [], ...otherProps }) => {
|
|
71
|
+
const navigate = (0, react_router_1.useNavigate)();
|
|
72
|
+
const selectedRoutes = useSelectedRoutes(pages, isSelectedRoute);
|
|
73
|
+
const onSelect = (0, react_1.useCallback)((key) => {
|
|
74
|
+
navigate(key);
|
|
75
|
+
}, [navigate]);
|
|
76
|
+
return (react_1.default.createElement(BasicLayout_1.BasicLayout, { ...otherProps, pages: pages, onSelect: onSelect, selectedPages: selectedRoutes },
|
|
77
|
+
react_1.default.createElement(react_router_1.Outlet, null)));
|
|
78
|
+
};
|
|
79
|
+
exports.ReactRouterLayout = ReactRouterLayout;
|
|
80
|
+
//# sourceMappingURL=ReactRouterLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReactRouterLayout.js","sourceRoot":"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AAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,EAC1C,EAAE;IACH,MAAM,QAAQ,GAAG,IAAA,0BAAW,GAAE,CAAA;IAE9B,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE;QACnB,MAAM,SAAS,GAAG,IAAA,6BAAkB,EAAC,KAAK,CAAC,CAAA;QAC3C,OAAO,SAAS;aACd,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;aACjD,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC1B,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAA;AACtB,CAAC,CAAA;AAED;;GAEG;AACI,MAAM,iBAAiB,GAAqC,CAAC,EACnE,eAAe,EACf,KAAK,GAAG,EAAE,EACV,GAAG,UAAU,EACb,EAAE,EAAE;IACJ,MAAM,QAAQ,GAAG,IAAA,0BAAW,GAAE,CAAA;IAC9B,MAAM,cAAc,GAAG,iBAAiB,CAAC,KAAK,EAAE,eAAe,CAAC,CAAA;IAChE,MAAM,QAAQ,GAAG,IAAA,mBAAW,EAC3B,CAAC,GAAW,EAAE,EAAE;QACf,QAAQ,CAAC,GAAG,CAAC,CAAA;IACd,CAAC,EACD,CAAC,QAAQ,CAAC,CACV,CAAA;IAED,OAAO,CACN,8BAAC,yBAAW,OACP,UAAU,EACd,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,cAAc;QAC7B,8BAAC,qBAAM,OAAG,CACG,CACd,CAAA;AACF,CAAC,CAAA;AAvBY,QAAA,iBAAiB,qBAuB7B"}
|
|
@@ -28,8 +28,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.Router = void 0;
|
|
30
30
|
const react_1 = __importStar(require("react"));
|
|
31
|
-
const LoadingSpinner_1 = require("
|
|
32
|
-
const MenuPage_1 = require("
|
|
31
|
+
const LoadingSpinner_1 = require("../../LoadingSpinner");
|
|
32
|
+
const MenuPage_1 = require("../MenuPage");
|
|
33
33
|
/**
|
|
34
34
|
* Renders the currently selected page from a tree of pages
|
|
35
35
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Router.js","sourceRoot":"","sources":["../../../../../src/react/components/navigation/customRouting/Router.tsx"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+CAMc;AACd,yDAAqD;AACrD,0CAAsD;AAStD;;GAEG;AACH,SAAgB,MAAM,CAAqB,EAC1C,KAAK,GAAG,EAAE,EACV,WAAW,EACX,YAAY,EACZ,iBAAiB,GACkB;IACnC,MAAM,IAAI,GAAG,IAAA,eAAO,EACnB,GAAG,EAAE,CAAC,IAAA,yBAAc,EAAC,KAAK,EAAE,WAAW,CAAC,EACxC,CAAC,KAAK,EAAE,WAAW,CAAC,CACpB,CAAA;IAED,IAAA,iBAAS,EAAC,GAAG,EAAE;QACd,YAAY,EAAE,CAAC,IAAI,CAAC,CAAA;IACrB,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAEV,OAAO,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CACxB,8BAAC,gBAAQ,IAAC,QAAQ,EAAE,8BAAC,+BAAc,OAAG,IACpC,eAAK,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,CACvC,CACX,CAAC,CAAC,CAAC,CACH,iBAAiB,IAAI;QAAM,WAAW;0BAAsB,CAC5D,CAAA;AACF,CAAC;AAtBD,wBAsBC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BasicLayoutProps } from '../BasicLayout';
|
|
3
|
+
import { MenuPage } from '../MenuPage';
|
|
4
|
+
export interface RouterLayoutProps extends BasicLayoutProps<MenuPage> {
|
|
5
|
+
page?: string;
|
|
6
|
+
onPageChange?: (page: string) => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Basic layout that uses a custom router.
|
|
10
|
+
*/
|
|
11
|
+
export declare const RouterLayout: React.FC<RouterLayoutProps>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2022, J2 Innovations. All Rights Reserved
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.RouterLayout = void 0;
|
|
30
|
+
const ui_1 = require("@j2inn/ui");
|
|
31
|
+
const react_1 = __importStar(require("react"));
|
|
32
|
+
const ErrorDisplayer_1 = require("../../ErrorDisplayer");
|
|
33
|
+
const BasicLayout_1 = require("../BasicLayout");
|
|
34
|
+
const MenuPage_1 = require("../MenuPage");
|
|
35
|
+
const Router_1 = require("./Router");
|
|
36
|
+
/**
|
|
37
|
+
* Basic layout that uses a custom router.
|
|
38
|
+
*/
|
|
39
|
+
const RouterLayout = ({ pages = [], defaultPage = pages?.[0].key ?? '', onPageChange, page, ...otherProps }) => {
|
|
40
|
+
const [currentPage, setCurrentPage] = (0, react_1.useState)(page ?? defaultPage);
|
|
41
|
+
(0, react_1.useEffect)(() => {
|
|
42
|
+
if (page) {
|
|
43
|
+
setCurrentPage(page);
|
|
44
|
+
}
|
|
45
|
+
}, [page]);
|
|
46
|
+
// Fire onChange
|
|
47
|
+
(0, react_1.useEffect)(() => {
|
|
48
|
+
onPageChange?.(currentPage);
|
|
49
|
+
}, [currentPage]);
|
|
50
|
+
const onSelect = (0, react_1.useCallback)((key) => {
|
|
51
|
+
const page = (0, MenuPage_1.findPageByName)(pages, key);
|
|
52
|
+
if (page?.component) {
|
|
53
|
+
setCurrentPage(key);
|
|
54
|
+
}
|
|
55
|
+
}, [pages]);
|
|
56
|
+
return (react_1.default.createElement(BasicLayout_1.BasicLayout, { ...otherProps, pages: pages, defaultPage: defaultPage, onSelect: onSelect },
|
|
57
|
+
react_1.default.createElement(Router_1.Router, { pages: pages, currentPage: currentPage, fallbackComponent: react_1.default.createElement(ErrorDisplayer_1.ErrorDisplayer, { error: new Error('Page Not Found'), extra: [
|
|
58
|
+
react_1.default.createElement(ui_1.Button, { type: 'primary', key: 'refresh', onClick: () => setCurrentPage(defaultPage) }, "Go Home"),
|
|
59
|
+
] }) })));
|
|
60
|
+
};
|
|
61
|
+
exports.RouterLayout = RouterLayout;
|
|
62
|
+
//# sourceMappingURL=RouterLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RouterLayout.js","sourceRoot":"","sources":["../../../../../src/react/components/navigation/customRouting/RouterLayout.tsx"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kCAAkC;AAClC,+CAA+D;AAC/D,yDAAqD;AACrD,gDAA8D;AAC9D,0CAAsD;AACtD,qCAAiC;AAOjC;;GAEG;AACI,MAAM,YAAY,GAAgC,CAAC,EACzD,KAAK,GAAG,EAAE,EACV,WAAW,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,EAClC,YAAY,EACZ,IAAI,EACJ,GAAG,UAAU,EACb,EAAE,EAAE;IACJ,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,IAAA,gBAAQ,EAAC,IAAI,IAAI,WAAW,CAAC,CAAA;IAEnE,IAAA,iBAAS,EAAC,GAAG,EAAE;QACd,IAAI,IAAI,EAAE;YACT,cAAc,CAAC,IAAI,CAAC,CAAA;SACpB;IACF,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAEV,gBAAgB;IAChB,IAAA,iBAAS,EAAC,GAAG,EAAE;QACd,YAAY,EAAE,CAAC,WAAW,CAAC,CAAA;IAC5B,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAA;IAEjB,MAAM,QAAQ,GAAG,IAAA,mBAAW,EAC3B,CAAC,GAAW,EAAE,EAAE;QACf,MAAM,IAAI,GAAG,IAAA,yBAAc,EAAC,KAAK,EAAE,GAAG,CAAC,CAAA;QACvC,IAAI,IAAI,EAAE,SAAS,EAAE;YACpB,cAAc,CAAC,GAAG,CAAC,CAAA;SACnB;IACF,CAAC,EACD,CAAC,KAAK,CAAC,CACP,CAAA;IAED,OAAO,CACN,8BAAC,yBAAW,OACP,UAAU,EACd,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ;QAClB,8BAAC,eAAM,IACN,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,iBAAiB,EAChB,8BAAC,+BAAc,IACd,KAAK,EAAE,IAAI,KAAK,CAAC,gBAAgB,CAAC,EAClC,KAAK,EAAE;oBACN,8BAAC,WAAM,IACN,IAAI,EAAC,SAAS,EACd,GAAG,EAAC,SAAS,EACb,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,WAAW,CAAC,cAElC;iBACT,GACA,GAEF,CACW,CACd,CAAA;AACF,CAAC,CAAA;AAvDY,QAAA,YAAY,gBAuDxB"}
|
package/dist_es/index.d.ts
CHANGED
|
@@ -3,16 +3,16 @@ export * from './fin5Top/getFin5BinUrl';
|
|
|
3
3
|
export * from './fin5Top/openFin5Alarm';
|
|
4
4
|
export * from './fin5Top/openFin5Historian';
|
|
5
5
|
export * from './fin5Top/useFin5AppURLHashParameter';
|
|
6
|
-
export * from './react/components/ErrorDisplayer';
|
|
7
6
|
export * from './react/components/ErrorBoundary';
|
|
7
|
+
export * from './react/components/ErrorDisplayer';
|
|
8
8
|
export * from './react/components/Loader';
|
|
9
9
|
export * from './react/components/LoadingSpinner';
|
|
10
|
-
export * from './react/components/navigation/BasicLayout';
|
|
11
|
-
export * from './react/components/navigation/MenuPage';
|
|
12
|
-
export * from './react/components/navigation/Router';
|
|
13
|
-
export * from './react/components/navigation/react-router/ReactRouterBasicLayout';
|
|
14
|
-
export * from './react/components/graphics/GraphicsTabViewer';
|
|
15
10
|
export * from './react/components/graphics/GraphicViewer';
|
|
11
|
+
export * from './react/components/graphics/GraphicsTabViewer';
|
|
12
|
+
export * from './react/components/navigation/MenuPage';
|
|
13
|
+
export * from './react/components/navigation/ReactRouterLayout';
|
|
14
|
+
export * from './react/components/navigation/customRouting/RouterLayout';
|
|
15
|
+
export * from './react/components/navigation/customRouting/Router';
|
|
16
16
|
export * from './react/components/resolvable/configurationForm/ConfigurationForm';
|
|
17
17
|
export * from './react/components/resolvable/configurationForm/ConfigurationFormEntry';
|
|
18
18
|
export * from './react/components/resolvable/configurationForm/getSectionDefault';
|
package/dist_es/index.js
CHANGED
|
@@ -12,16 +12,16 @@ export * from './fin5Top/useFin5AppURLHashParameter';
|
|
|
12
12
|
//////////////////////////////////////////////////////////////////////////
|
|
13
13
|
// React components
|
|
14
14
|
//////////////////////////////////////////////////////////////////////////
|
|
15
|
-
export * from './react/components/ErrorDisplayer';
|
|
16
15
|
export * from './react/components/ErrorBoundary';
|
|
16
|
+
export * from './react/components/ErrorDisplayer';
|
|
17
17
|
export * from './react/components/Loader';
|
|
18
18
|
export * from './react/components/LoadingSpinner';
|
|
19
|
-
export * from './react/components/navigation/BasicLayout';
|
|
20
|
-
export * from './react/components/navigation/MenuPage';
|
|
21
|
-
export * from './react/components/navigation/Router';
|
|
22
|
-
export * from './react/components/navigation/react-router/ReactRouterBasicLayout';
|
|
23
|
-
export * from './react/components/graphics/GraphicsTabViewer';
|
|
24
19
|
export * from './react/components/graphics/GraphicViewer';
|
|
20
|
+
export * from './react/components/graphics/GraphicsTabViewer';
|
|
21
|
+
export * from './react/components/navigation/MenuPage';
|
|
22
|
+
export * from './react/components/navigation/ReactRouterLayout';
|
|
23
|
+
export * from './react/components/navigation/customRouting/RouterLayout';
|
|
24
|
+
export * from './react/components/navigation/customRouting/Router';
|
|
25
25
|
export * from './react/components/resolvable/configurationForm/ConfigurationForm';
|
|
26
26
|
export * from './react/components/resolvable/configurationForm/ConfigurationFormEntry';
|
|
27
27
|
export * from './react/components/resolvable/configurationForm/getSectionDefault';
|
package/dist_es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,0EAA0E;AAC1E,4BAA4B;AAC5B,0EAA0E;AAE1E,cAAc,mBAAmB,CAAA;AACjC,cAAc,yBAAyB,CAAA;AACvC,cAAc,yBAAyB,CAAA;AACvC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,sCAAsC,CAAA;AAEpD,0EAA0E;AAC1E,mBAAmB;AACnB,0EAA0E;AAE1E,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,0EAA0E;AAC1E,4BAA4B;AAC5B,0EAA0E;AAE1E,cAAc,mBAAmB,CAAA;AACjC,cAAc,yBAAyB,CAAA;AACvC,cAAc,yBAAyB,CAAA;AACvC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,sCAAsC,CAAA;AAEpD,0EAA0E;AAC1E,mBAAmB;AACnB,0EAA0E;AAE1E,cAAc,kCAAkC,CAAA;AAChD,cAAc,mCAAmC,CAAA;AACjD,cAAc,2BAA2B,CAAA;AACzC,cAAc,mCAAmC,CAAA;AACjD,cAAc,2CAA2C,CAAA;AACzD,cAAc,+CAA+C,CAAA;AAC7D,cAAc,wCAAwC,CAAA;AACtD,cAAc,iDAAiD,CAAA;AAC/D,cAAc,0DAA0D,CAAA;AACxE,cAAc,oDAAoD,CAAA;AAClE,cAAc,mEAAmE,CAAA;AACjF,cAAc,wEAAwE,CAAA;AACtF,cAAc,mEAAmE,CAAA;AAEjF,0EAA0E;AAC1E,6BAA6B;AAC7B,0EAA0E;AAE1E,cAAc,8BAA8B,CAAA;AAC5C,cAAc,8BAA8B,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ThemeDef } from '@j2inn/ui';
|
|
2
2
|
import { LayoutProps, MenuProps, SiderProps } from 'antd';
|
|
3
|
-
import
|
|
3
|
+
import { PropsWithChildren, ReactElement } from 'react';
|
|
4
4
|
import { MenuPage } from './MenuPage';
|
|
5
5
|
export declare const HEADER_HEIGHT = 45;
|
|
6
6
|
interface StyleVariables {
|
|
@@ -10,15 +10,12 @@ interface StyleVariables {
|
|
|
10
10
|
}
|
|
11
11
|
export declare const useStyles: (data?: (StyleVariables & {
|
|
12
12
|
theme?: ThemeDef | undefined;
|
|
13
|
-
}) | undefined) => import("jss").Classes<"
|
|
14
|
-
export interface BasicLayoutProps {
|
|
15
|
-
|
|
16
|
-
* List of pages for the menu and the routing
|
|
17
|
-
*/
|
|
18
|
-
page?: string;
|
|
19
|
-
pages?: MenuPage[];
|
|
13
|
+
}) | undefined) => import("jss").Classes<"content" | "header" | "sider" | "menuTrigger">;
|
|
14
|
+
export interface BasicLayoutProps<T extends MenuPage> extends PropsWithChildren {
|
|
15
|
+
pages?: T[];
|
|
20
16
|
defaultPage?: string;
|
|
21
|
-
|
|
17
|
+
selectedPages?: string[];
|
|
18
|
+
onSelect: (key: string) => void;
|
|
22
19
|
compactSider?: boolean;
|
|
23
20
|
layoutProps?: LayoutProps;
|
|
24
21
|
mobileHeaderProps?: LayoutProps;
|
|
@@ -33,7 +30,8 @@ export interface BasicLayoutProps {
|
|
|
33
30
|
*/
|
|
34
31
|
export declare const getMenuPages: (pages: MenuPage[]) => MenuPage<Record<string, unknown>>[];
|
|
35
32
|
/**
|
|
36
|
-
* Basic layout
|
|
33
|
+
* Basic layout with sider and mobile navigation management.
|
|
34
|
+
* Routing management can be plugged in, for examples @see ReactRouterLayout @see RouterLayout
|
|
37
35
|
*/
|
|
38
|
-
export declare
|
|
36
|
+
export declare function BasicLayout<T extends MenuPage>({ pages, defaultPage, selectedPages, onSelect, compactSider, layoutProps, mobileHeaderProps, siderProps, contentProps, menuProps, children, }: BasicLayoutProps<T>): ReactElement;
|
|
39
37
|
export {};
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) 2023, J2 Innovations. All Rights Reserved
|
|
3
3
|
*/
|
|
4
4
|
import { MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons';
|
|
5
|
-
import {
|
|
5
|
+
import { Layout, Menu } from '@j2inn/ui';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
|
-
import React, {
|
|
7
|
+
import React, { useMemo, useState, } from 'react';
|
|
8
8
|
import { createUseStyles } from 'react-jss';
|
|
9
|
-
import { ErrorDisplayer } from '../ErrorDisplayer';
|
|
10
|
-
import { findPageByName } from './MenuPage';
|
|
11
|
-
import { Router } from './Router';
|
|
12
9
|
export const HEADER_HEIGHT = 45;
|
|
13
10
|
export const useStyles = createUseStyles((theme) => {
|
|
14
11
|
return {
|
|
@@ -76,19 +73,10 @@ export const getMenuPages = (pages) => {
|
|
|
76
73
|
return menuPages;
|
|
77
74
|
};
|
|
78
75
|
/**
|
|
79
|
-
* Basic layout
|
|
76
|
+
* Basic layout with sider and mobile navigation management.
|
|
77
|
+
* Routing management can be plugged in, for examples @see ReactRouterLayout @see RouterLayout
|
|
80
78
|
*/
|
|
81
|
-
export
|
|
82
|
-
const [currentPage, setCurrentPage] = useState(page ?? defaultPage);
|
|
83
|
-
useEffect(() => {
|
|
84
|
-
if (page) {
|
|
85
|
-
setCurrentPage(page);
|
|
86
|
-
}
|
|
87
|
-
}, [page]);
|
|
88
|
-
// Fire onChange
|
|
89
|
-
useEffect(() => {
|
|
90
|
-
onPageChange?.(currentPage);
|
|
91
|
-
}, [currentPage]);
|
|
79
|
+
export function BasicLayout({ pages = [], defaultPage, selectedPages = [], onSelect, compactSider, layoutProps, mobileHeaderProps, siderProps, contentProps, menuProps, children, }) {
|
|
92
80
|
// manage mobile navigation
|
|
93
81
|
const [isMobile, setIsMobile] = useState(false);
|
|
94
82
|
const [hiddenSider, setHiddenSider] = useState(false);
|
|
@@ -109,18 +97,12 @@ export const BasicLayout = ({ pages = [], defaultPage = pages?.[0].key ?? '', on
|
|
|
109
97
|
: compactSider
|
|
110
98
|
? HEADER_HEIGHT
|
|
111
99
|
: 0, trigger: null },
|
|
112
|
-
React.createElement(Menu, { ...menuProps, items: menuPages, selectedKeys:
|
|
100
|
+
React.createElement(Menu, { ...menuProps, defaultSelectedKeys: defaultPage ? [defaultPage] : undefined, items: menuPages, selectedKeys: selectedPages, onSelect: ({ key }) => {
|
|
113
101
|
if (!hiddenSider) {
|
|
114
102
|
setHiddenSider(true);
|
|
115
103
|
}
|
|
116
|
-
|
|
117
|
-
if (page?.component) {
|
|
118
|
-
setCurrentPage(key);
|
|
119
|
-
}
|
|
104
|
+
onSelect(key);
|
|
120
105
|
} })),
|
|
121
|
-
React.createElement(Content, { ...contentProps, className: classNames(classes.content, contentProps?.className) },
|
|
122
|
-
|
|
123
|
-
React.createElement(Button, { type: 'primary', key: 'refresh', onClick: () => setCurrentPage(defaultPage) }, "Go Home"),
|
|
124
|
-
] }) }))));
|
|
125
|
-
};
|
|
106
|
+
React.createElement(Content, { ...contentProps, className: classNames(classes.content, contentProps?.className) }, children)));
|
|
107
|
+
}
|
|
126
108
|
//# sourceMappingURL=BasicLayout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasicLayout.js","sourceRoot":"","sources":["../../../../src/react/components/navigation/BasicLayout.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"BasicLayout.js","sourceRoot":"","sources":["../../../../src/react/components/navigation/BasicLayout.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAY,MAAM,WAAW,CAAA;AAElD,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,EAAE,EAGb,OAAO,EACP,QAAQ,GACR,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAG3C,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAA;AAQ/B,MAAM,CAAC,MAAM,SAAS,GAAG,eAAe,CAAC,CAAC,KAAe,EAAE,EAAE;IAC5D,OAAO;QACN,MAAM,EAAE;YACP,QAAQ,EAAE,OAAO;YACjB,KAAK,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SAAS,EAChB,YAAY,EAAE,aAAa,EAC3B,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;oBACrB,IAAI,CAAC,WAAW,EAAE;wBACjB,cAAc,CAAC,IAAI,CAAC,CAAA;qBACpB;oBACD,QAAQ,CAAC,GAAG,CAAC,CAAA;gBACd,CAAC,GACA,CACK;QACR,oBAAC,OAAO,OACH,YAAY,EAChB,SAAS,EAAE,UAAU,CACpB,OAAO,CAAC,OAAO,EACf,YAAY,EAAE,SAAS,CACvB,IACA,QAAQ,CACA,CACF,CACT,CAAA;AACF,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Location } from '@remix-run/router';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { BasicLayoutProps } from './BasicLayout';
|
|
4
|
+
import { MenuPage } from './MenuPage';
|
|
5
|
+
export interface ReactRouterLayoutProps extends BasicLayoutProps<MenuPage> {
|
|
6
|
+
isSelectedRoute?: (page: MenuPage, location: Location) => boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* This hook can be used with react-router/BasicLayout,
|
|
10
|
+
* to ensure FIN5 URL is aligned with the internal frame URL.
|
|
11
|
+
*/
|
|
12
|
+
export declare const useLocationUpdate: () => void;
|
|
13
|
+
/**
|
|
14
|
+
* Basic layout that uses React Router.
|
|
15
|
+
*/
|
|
16
|
+
export declare const ReactRouterLayout: React.FC<ReactRouterLayoutProps>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023, J2 Innovations. All Rights Reserved
|
|
3
|
+
*/
|
|
4
|
+
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
5
|
+
import { Outlet, useLocation, useNavigate } from 'react-router';
|
|
6
|
+
import { IN_IFRAME, fin5SkipHashUpdate, getFin5HashFrameParameters, getTopLocation, } from '../../../fin5Top/useFin5AppURLHashParameter';
|
|
7
|
+
import { BasicLayout } from './BasicLayout';
|
|
8
|
+
import { pageTreeToPageList } from './MenuPage';
|
|
9
|
+
/**
|
|
10
|
+
* This hook can be used with react-router/BasicLayout,
|
|
11
|
+
* to ensure FIN5 URL is aligned with the internal frame URL.
|
|
12
|
+
*/
|
|
13
|
+
export const useLocationUpdate = () => {
|
|
14
|
+
const location = useLocation();
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
console.debug('Location changed', location);
|
|
17
|
+
const hash = location.pathname;
|
|
18
|
+
const queryParams = location.search;
|
|
19
|
+
if (IN_IFRAME) {
|
|
20
|
+
fin5SkipHashUpdate()?.then(() => {
|
|
21
|
+
const frameParameters = getFin5HashFrameParameters();
|
|
22
|
+
frameParameters.set('url', frameParameters.get('url')?.split('#')[0] +
|
|
23
|
+
'#' +
|
|
24
|
+
hash +
|
|
25
|
+
queryParams);
|
|
26
|
+
getTopLocation().hash = `#${getTopLocation().hash.slice(1).split('?')[0]}?${frameParameters.toString()}`;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}, [location]);
|
|
30
|
+
};
|
|
31
|
+
const useSelectedRoutes = (pages, isSelectedRoute = (page, location) => location.pathname.includes(`/${page.key}`)) => {
|
|
32
|
+
const location = useLocation();
|
|
33
|
+
return useMemo(() => {
|
|
34
|
+
const flatPages = pageTreeToPageList(pages);
|
|
35
|
+
return flatPages
|
|
36
|
+
.filter((page) => isSelectedRoute(page, location))
|
|
37
|
+
.map((page) => page.key);
|
|
38
|
+
}, [location, pages]);
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Basic layout that uses React Router.
|
|
42
|
+
*/
|
|
43
|
+
export const ReactRouterLayout = ({ isSelectedRoute, pages = [], ...otherProps }) => {
|
|
44
|
+
const navigate = useNavigate();
|
|
45
|
+
const selectedRoutes = useSelectedRoutes(pages, isSelectedRoute);
|
|
46
|
+
const onSelect = useCallback((key) => {
|
|
47
|
+
navigate(key);
|
|
48
|
+
}, [navigate]);
|
|
49
|
+
return (React.createElement(BasicLayout, { ...otherProps, pages: pages, onSelect: onSelect, selectedPages: selectedRoutes },
|
|
50
|
+
React.createElement(Outlet, null)));
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=ReactRouterLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReactRouterLayout.js","sourceRoot":"","sources":["../../../../src/react/components/navigation/ReactRouterLayout.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,EACN,SAAS,EACT,kBAAkB,EAClB,0BAA0B,EAC1B,cAAc,GACd,MAAM,6CAA6C,CAAA;AACpD,OAAO,EAAE,WAAW,EAAoB,MAAM,eAAe,CAAA;AAC7D,OAAO,EAAY,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAMzD;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE;IACrC,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAA;IAC9B,SAAS,CAAC,GAAG,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAA;QAC3C,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAA;QAC9B,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAA;QAEnC,IAAI,SAAS,EAAE;YACd,kBAAkB,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;gBAC/B,MAAM,eAAe,GAAG,0BAA0B,EAAE,CAAA;gBAEpD,eAAe,CAAC,GAAG,CAClB,KAAK,EACL,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;oBACxC,GAAG;oBACH,IAAI;oBACJ,WAAW,CACZ,CAAA;gBAED,cAAc,EAAE,CAAC,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AED,OAAO,CACN,oBAAC,WAAW,OACP,UAAU,EACd,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,cAAc;QAC7B,oBAAC,MAAM,OAAG,CACG,CACd,CAAA;AACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PropsWithChildren, ReactElement } from 'react';
|
|
2
|
+
import { MenuPage } from '../MenuPage';
|
|
3
|
+
export interface RouterProps<T extends MenuPage> {
|
|
4
|
+
pages?: T[];
|
|
5
|
+
currentPage: string;
|
|
6
|
+
onPageChange?: (selectedPage?: T) => void;
|
|
7
|
+
fallbackComponent?: ReactElement;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Renders the currently selected page from a tree of pages
|
|
11
|
+
*/
|
|
12
|
+
export declare function Router<T extends MenuPage>({ pages, currentPage, onPageChange, fallbackComponent, }: PropsWithChildren<RouterProps<T>>): JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022, J2 Innovations. All Rights Reserved
|
|
3
|
+
*/
|
|
4
|
+
import React, { Suspense, useEffect, useMemo, } from 'react';
|
|
5
|
+
import { LoadingSpinner } from '../../LoadingSpinner';
|
|
6
|
+
import { findPageByName } from '../MenuPage';
|
|
7
|
+
/**
|
|
8
|
+
* Renders the currently selected page from a tree of pages
|
|
9
|
+
*/
|
|
10
|
+
export function Router({ pages = [], currentPage, onPageChange, fallbackComponent, }) {
|
|
11
|
+
const page = useMemo(() => findPageByName(pages, currentPage), [pages, currentPage]);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
onPageChange?.(page);
|
|
14
|
+
}, [page]);
|
|
15
|
+
return page?.component ? (React.createElement(Suspense, { fallback: React.createElement(LoadingSpinner, null) }, React.createElement(page.component, page?.props))) : (fallbackComponent ?? React.createElement("div", null,
|
|
16
|
+
currentPage,
|
|
17
|
+
" page not found"));
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=Router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Router.js","sourceRoot":"","sources":["../../../../../src/react/components/navigation/customRouting/Router.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,EAGb,QAAQ,EACR,SAAS,EACT,OAAO,GACP,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAY,cAAc,EAAE,MAAM,aAAa,CAAA;AAStD;;GAEG;AACH,MAAM,UAAU,MAAM,CAAqB,EAC1C,KAAK,GAAG,EAAE,EACV,WAAW,EACX,YAAY,EACZ,iBAAiB,GACkB;IACnC,MAAM,IAAI,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,EAAE,WAAW,CAAC,EACxC,CAAC,KAAK,EAAE,WAAW,CAAC,CACpB,CAAA;IAED,SAAS,CAAC,GAAG,EAAE;QACd,YAAY,EAAE,CAAC,IAAI,CAAC,CAAA;IACrB,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAEV,OAAO,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CACxB,oBAAC,QAAQ,IAAC,QAAQ,EAAE,oBAAC,cAAc,OAAG,IACpC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,CACvC,CACX,CAAC,CAAC,CAAC,CACH,iBAAiB,IAAI;QAAM,WAAW;0BAAsB,CAC5D,CAAA;AACF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BasicLayoutProps } from '../BasicLayout';
|
|
3
|
+
import { MenuPage } from '../MenuPage';
|
|
4
|
+
export interface RouterLayoutProps extends BasicLayoutProps<MenuPage> {
|
|
5
|
+
page?: string;
|
|
6
|
+
onPageChange?: (page: string) => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Basic layout that uses a custom router.
|
|
10
|
+
*/
|
|
11
|
+
export declare const RouterLayout: React.FC<RouterLayoutProps>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022, J2 Innovations. All Rights Reserved
|
|
3
|
+
*/
|
|
4
|
+
import { Button } from '@j2inn/ui';
|
|
5
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
6
|
+
import { ErrorDisplayer } from '../../ErrorDisplayer';
|
|
7
|
+
import { BasicLayout } from '../BasicLayout';
|
|
8
|
+
import { findPageByName } from '../MenuPage';
|
|
9
|
+
import { Router } from './Router';
|
|
10
|
+
/**
|
|
11
|
+
* Basic layout that uses a custom router.
|
|
12
|
+
*/
|
|
13
|
+
export const RouterLayout = ({ pages = [], defaultPage = pages?.[0].key ?? '', onPageChange, page, ...otherProps }) => {
|
|
14
|
+
const [currentPage, setCurrentPage] = useState(page ?? defaultPage);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (page) {
|
|
17
|
+
setCurrentPage(page);
|
|
18
|
+
}
|
|
19
|
+
}, [page]);
|
|
20
|
+
// Fire onChange
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
onPageChange?.(currentPage);
|
|
23
|
+
}, [currentPage]);
|
|
24
|
+
const onSelect = useCallback((key) => {
|
|
25
|
+
const page = findPageByName(pages, key);
|
|
26
|
+
if (page?.component) {
|
|
27
|
+
setCurrentPage(key);
|
|
28
|
+
}
|
|
29
|
+
}, [pages]);
|
|
30
|
+
return (React.createElement(BasicLayout, { ...otherProps, pages: pages, defaultPage: defaultPage, onSelect: onSelect },
|
|
31
|
+
React.createElement(Router, { pages: pages, currentPage: currentPage, fallbackComponent: React.createElement(ErrorDisplayer, { error: new Error('Page Not Found'), extra: [
|
|
32
|
+
React.createElement(Button, { type: 'primary', key: 'refresh', onClick: () => setCurrentPage(defaultPage) }, "Go Home"),
|
|
33
|
+
] }) })));
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=RouterLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RouterLayout.js","sourceRoot":"","sources":["../../../../../src/react/components/navigation/customRouting/RouterLayout.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,WAAW,EAAoB,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAY,cAAc,EAAE,MAAM,aAAa,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAOjC;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAgC,CAAC,EACzD,KAAK,GAAG,EAAE,EACV,WAAW,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,EAClC,YAAY,EACZ,IAAI,EACJ,GAAG,UAAU,EACb,EAAE,EAAE;IACJ,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,IAAI,IAAI,WAAW,CAAC,CAAA;IAEnE,SAAS,CAAC,GAAG,EAAE;QACd,IAAI,IAAI,EAAE;YACT,cAAc,CAAC,IAAI,CAAC,CAAA;SACpB;IACF,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAEV,gBAAgB;IAChB,SAAS,CAAC,GAAG,EAAE;QACd,YAAY,EAAE,CAAC,WAAW,CAAC,CAAA;IAC5B,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAA;IAEjB,MAAM,QAAQ,GAAG,WAAW,CAC3B,CAAC,GAAW,EAAE,EAAE;QACf,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;QACvC,IAAI,IAAI,EAAE,SAAS,EAAE;YACpB,cAAc,CAAC,GAAG,CAAC,CAAA;SACnB;IACF,CAAC,EACD,CAAC,KAAK,CAAC,CACP,CAAA;IAED,OAAO,CACN,oBAAC,WAAW,OACP,UAAU,EACd,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ;QAClB,oBAAC,MAAM,IACN,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,iBAAiB,EAChB,oBAAC,cAAc,IACd,KAAK,EAAE,IAAI,KAAK,CAAC,gBAAgB,CAAC,EAClC,KAAK,EAAE;oBACN,oBAAC,MAAM,IACN,IAAI,EAAC,SAAS,EACd,GAAG,EAAC,SAAS,EACb,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,WAAW,CAAC,cAElC;iBACT,GACA,GAEF,CACW,CACd,CAAA;AACF,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@j2inn/fin5-ui-utils",
|
|
3
|
-
"version": "1.0.8-react-router.
|
|
3
|
+
"version": "1.0.8-react-router.4",
|
|
4
4
|
"description": "A set of useful client-side utilities useful for creating UI applications on top of FIN 5",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Router.js","sourceRoot":"","sources":["../../../../src/react/components/navigation/Router.tsx"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+CAMc;AACd,sDAAkD;AAClD,yCAAqD;AASrD;;GAEG;AACH,SAAgB,MAAM,CAAqB,EAC1C,KAAK,GAAG,EAAE,EACV,WAAW,EACX,YAAY,EACZ,iBAAiB,GACkB;IACnC,MAAM,IAAI,GAAG,IAAA,eAAO,EACnB,GAAG,EAAE,CAAC,IAAA,yBAAc,EAAC,KAAK,EAAE,WAAW,CAAC,EACxC,CAAC,KAAK,EAAE,WAAW,CAAC,CACpB,CAAA;IAED,IAAA,iBAAS,EAAC,GAAG,EAAE;QACd,YAAY,EAAE,CAAC,IAAI,CAAC,CAAA;IACrB,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAEV,OAAO,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CACxB,8BAAC,gBAAQ,IAAC,QAAQ,EAAE,8BAAC,+BAAc,OAAG,IACpC,eAAK,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,CACvC,CACX,CAAC,CAAC,CAAC,CACH,iBAAiB,IAAI;QAAM,WAAW;0BAAsB,CAC5D,CAAA;AACF,CAAC;AAtBD,wBAsBC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Location } from '@remix-run/router';
|
|
2
|
-
import { LayoutProps, MenuProps, SiderProps } from 'antd';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { MenuPage } from '../MenuPage';
|
|
5
|
-
export interface ReactRouterBasicLayoutProps {
|
|
6
|
-
pages?: MenuPage[];
|
|
7
|
-
defaultPage?: string;
|
|
8
|
-
compactSider?: boolean;
|
|
9
|
-
layoutProps?: LayoutProps;
|
|
10
|
-
mobileHeaderProps?: LayoutProps;
|
|
11
|
-
siderProps?: SiderProps;
|
|
12
|
-
contentProps?: LayoutProps;
|
|
13
|
-
menuProps?: Omit<MenuProps, 'items' | 'selectedKeys' | 'onSelect'>;
|
|
14
|
-
isSelectedRoute?: (page: MenuPage, location: Location) => boolean;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* This hook can be used with react-router/BasicLayout,
|
|
18
|
-
* to ensure FIN5 URL is aligned with the internal frame URL.
|
|
19
|
-
*/
|
|
20
|
-
export declare const useLocationUpdate: () => void;
|
|
21
|
-
/**
|
|
22
|
-
* Basic layout that uses React Router.
|
|
23
|
-
*/
|
|
24
|
-
export declare const ReactRouterBasicLayout: React.FC<ReactRouterBasicLayoutProps>;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2023, J2 Innovations. All Rights Reserved
|
|
4
|
-
*/
|
|
5
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
-
}
|
|
11
|
-
Object.defineProperty(o, k2, desc);
|
|
12
|
-
}) : (function(o, m, k, k2) {
|
|
13
|
-
if (k2 === undefined) k2 = k;
|
|
14
|
-
o[k2] = m[k];
|
|
15
|
-
}));
|
|
16
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
-
}) : function(o, v) {
|
|
19
|
-
o["default"] = v;
|
|
20
|
-
});
|
|
21
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
-
if (mod && mod.__esModule) return mod;
|
|
23
|
-
var result = {};
|
|
24
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
-
__setModuleDefault(result, mod);
|
|
26
|
-
return result;
|
|
27
|
-
};
|
|
28
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
-
};
|
|
31
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.ReactRouterBasicLayout = exports.useLocationUpdate = void 0;
|
|
33
|
-
const icons_1 = require("@ant-design/icons");
|
|
34
|
-
const ui_1 = require("@j2inn/ui");
|
|
35
|
-
const classnames_1 = __importDefault(require("classnames"));
|
|
36
|
-
const react_1 = __importStar(require("react"));
|
|
37
|
-
const react_router_1 = require("react-router");
|
|
38
|
-
const useFin5AppURLHashParameter_1 = require("../../../../fin5Top/useFin5AppURLHashParameter");
|
|
39
|
-
const BasicLayout_1 = require("../BasicLayout");
|
|
40
|
-
const MenuPage_1 = require("../MenuPage");
|
|
41
|
-
// Workaround j2inn/ui exporting problem
|
|
42
|
-
const Header = ui_1.Layout.Header;
|
|
43
|
-
const Sider = ui_1.Layout.Sider;
|
|
44
|
-
const Content = ui_1.Layout.Content;
|
|
45
|
-
/**
|
|
46
|
-
* This hook can be used with react-router/BasicLayout,
|
|
47
|
-
* to ensure FIN5 URL is aligned with the internal frame URL.
|
|
48
|
-
*/
|
|
49
|
-
const useLocationUpdate = () => {
|
|
50
|
-
const location = (0, react_router_1.useLocation)();
|
|
51
|
-
(0, react_1.useEffect)(() => {
|
|
52
|
-
console.debug('Location changed', location);
|
|
53
|
-
const hash = location.pathname;
|
|
54
|
-
const queryParams = location.search;
|
|
55
|
-
if (useFin5AppURLHashParameter_1.IN_IFRAME) {
|
|
56
|
-
(0, useFin5AppURLHashParameter_1.fin5SkipHashUpdate)()?.then(() => {
|
|
57
|
-
const frameParameters = (0, useFin5AppURLHashParameter_1.getFin5HashFrameParameters)();
|
|
58
|
-
frameParameters.set('url', frameParameters.get('url')?.split('#')[0] +
|
|
59
|
-
'#' +
|
|
60
|
-
hash +
|
|
61
|
-
queryParams);
|
|
62
|
-
(0, useFin5AppURLHashParameter_1.getTopLocation)().hash = `#${(0, useFin5AppURLHashParameter_1.getTopLocation)().hash.slice(1).split('?')[0]}?${frameParameters.toString()}`;
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}, [location]);
|
|
66
|
-
};
|
|
67
|
-
exports.useLocationUpdate = useLocationUpdate;
|
|
68
|
-
const useSelectedRoutes = (pages, isSelectedRoute = (page, location) => location.pathname.includes(`/${page.key}`)) => {
|
|
69
|
-
const location = (0, react_router_1.useLocation)();
|
|
70
|
-
return (0, react_1.useMemo)(() => {
|
|
71
|
-
const flatPages = (0, MenuPage_1.pageTreeToPageList)(pages);
|
|
72
|
-
return flatPages
|
|
73
|
-
.filter((page) => isSelectedRoute(page, location))
|
|
74
|
-
.map((page) => page.key);
|
|
75
|
-
}, [location, pages]);
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* Basic layout that uses React Router.
|
|
79
|
-
*/
|
|
80
|
-
const ReactRouterBasicLayout = ({ pages = [], defaultPage, compactSider, layoutProps, mobileHeaderProps, siderProps, contentProps, menuProps, isSelectedRoute, }) => {
|
|
81
|
-
const navigate = (0, react_router_1.useNavigate)();
|
|
82
|
-
const selectedRoutes = useSelectedRoutes(pages, isSelectedRoute);
|
|
83
|
-
// manage mobile navigation
|
|
84
|
-
const [isMobile, setIsMobile] = (0, react_1.useState)(false);
|
|
85
|
-
const [hiddenSider, setHiddenSider] = (0, react_1.useState)(false);
|
|
86
|
-
const siderWidth = siderProps?.width;
|
|
87
|
-
const classes = (0, BasicLayout_1.useStyles)({ isMobile, compactSider, siderWidth });
|
|
88
|
-
const menuPages = (0, react_1.useMemo)(() => (0, BasicLayout_1.getMenuPages)(pages), [pages]);
|
|
89
|
-
return (react_1.default.createElement(ui_1.Layout, { hasSider: true, ...layoutProps },
|
|
90
|
-
isMobile && (react_1.default.createElement(Header, { ...mobileHeaderProps, className: (0, classnames_1.default)(classes.header, mobileHeaderProps?.className) }, hiddenSider ? (react_1.default.createElement(icons_1.MenuUnfoldOutlined, { className: classes.menuTrigger, onClick: () => {
|
|
91
|
-
setHiddenSider(!hiddenSider);
|
|
92
|
-
} })) : (react_1.default.createElement(icons_1.MenuFoldOutlined, { className: classes.menuTrigger, onClick: () => {
|
|
93
|
-
setHiddenSider(!hiddenSider);
|
|
94
|
-
} })))),
|
|
95
|
-
react_1.default.createElement(Sider, { ...siderProps, className: (0, classnames_1.default)(classes.sider, siderProps?.className), breakpoint: 'md', onBreakpoint: (broken) => {
|
|
96
|
-
setIsMobile(broken);
|
|
97
|
-
setHiddenSider(true);
|
|
98
|
-
}, collapsed: (isMobile && hiddenSider) || compactSider, collapsedWidth: isMobile && hiddenSider
|
|
99
|
-
? 0
|
|
100
|
-
: compactSider
|
|
101
|
-
? BasicLayout_1.HEADER_HEIGHT
|
|
102
|
-
: 0, trigger: null },
|
|
103
|
-
react_1.default.createElement(ui_1.Menu, { ...menuProps, defaultSelectedKeys: defaultPage ? [defaultPage] : undefined, items: menuPages, selectedKeys: selectedRoutes, onSelect: ({ key }) => {
|
|
104
|
-
if (!hiddenSider) {
|
|
105
|
-
setHiddenSider(true);
|
|
106
|
-
}
|
|
107
|
-
navigate(key);
|
|
108
|
-
} })),
|
|
109
|
-
react_1.default.createElement(Content, { ...contentProps, className: (0, classnames_1.default)(classes.content, contentProps?.className) },
|
|
110
|
-
react_1.default.createElement(react_router_1.Outlet, null))));
|
|
111
|
-
};
|
|
112
|
-
exports.ReactRouterBasicLayout = ReactRouterBasicLayout;
|
|
113
|
-
//# sourceMappingURL=ReactRouterBasicLayout.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReactRouterBasicLayout.js","sourceRoot":"","sources":["../../../../../src/react/components/navigation/react-router/ReactRouterBasicLayout.tsx"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAAwE;AACxE,kCAAwC;AAGxC,4DAAmC;AACnC,+CAA2D;AAC3D,+CAA+D;AAC/D,+FAKuD;AACvD,gDAAuE;AACvE,0CAA0D;AAE1D,wCAAwC;AACxC,MAAM,MAAM,GAAG,WAAM,CAAC,MAAiC,CAAA;AACvD,MAAM,KAAK,GAAG,WAAM,CAAC,KAA+B,CAAA;AACpD,MAAM,OAAO,GAAG,WAAM,CAAC,OAAmC,CAAA;AAc1D;;;GAGG;AACI,MAAM,iBAAiB,GAAG,GAAG,EAAE;IACrC,MAAM,QAAQ,GAAG,IAAA,0B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