@j2inn/fin5-ui-utils 1.0.8-react.router.7 → 1.0.9
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/fin5Top/useFin5AppURLHashParameter.d.ts +0 -3
- package/dist/fin5Top/useFin5AppURLHashParameter.js +9 -11
- package/dist/fin5Top/useFin5AppURLHashParameter.js.map +1 -1
- package/dist/index.d.ts +4 -6
- package/dist/index.js +4 -6
- package/dist/index.js.map +1 -1
- package/dist/react/components/navigation/BasicLayout.d.ts +10 -8
- package/dist/react/components/navigation/BasicLayout.js +26 -8
- package/dist/react/components/navigation/BasicLayout.js.map +1 -1
- package/dist/react/components/navigation/{customRouting/Router.d.ts → Router.d.ts} +1 -1
- package/dist/react/components/navigation/{customRouting/Router.js → Router.js} +2 -2
- package/dist/react/components/navigation/Router.js.map +1 -0
- package/dist_es/fin5Top/fin5FileUpload.d.ts +24 -0
- package/dist_es/fin5Top/fin5FileUpload.js +48 -0
- package/dist_es/fin5Top/fin5FileUpload.js.map +1 -0
- package/dist_es/fin5Top/finEdge2Cloud.d.ts +6 -0
- package/dist_es/fin5Top/finEdge2Cloud.js +12 -0
- package/dist_es/fin5Top/finEdge2Cloud.js.map +1 -0
- package/dist_es/fin5Top/useFin5AppURLHashParameter.d.ts +0 -3
- package/dist_es/fin5Top/useFin5AppURLHashParameter.js +6 -5
- package/dist_es/fin5Top/useFin5AppURLHashParameter.js.map +1 -1
- package/dist_es/index.d.ts +4 -6
- package/dist_es/index.js +4 -6
- package/dist_es/index.js.map +1 -1
- package/dist_es/jobs/jobUtils.d.ts +14 -0
- package/dist_es/jobs/jobUtils.js +10 -0
- package/dist_es/jobs/jobUtils.js.map +1 -0
- package/dist_es/react/components/RecordImage.d.ts +20 -0
- package/dist_es/react/components/RecordImage.js +25 -0
- package/dist_es/react/components/RecordImage.js.map +1 -0
- package/dist_es/react/components/charts/QRCode.d.ts +25 -0
- package/dist_es/react/components/charts/QRCode.js +54 -0
- package/dist_es/react/components/charts/QRCode.js.map +1 -0
- package/dist_es/react/components/charts/pie/PieChart.d.ts +93 -0
- package/dist_es/react/components/charts/pie/PieChart.js +176 -0
- package/dist_es/react/components/charts/pie/PieChart.js.map +1 -0
- package/dist_es/react/components/charts/pie/SimplePieChart.d.ts +20 -0
- package/dist_es/react/components/charts/pie/SimplePieChart.js +26 -0
- package/dist_es/react/components/charts/pie/SimplePieChart.js.map +1 -0
- package/dist_es/react/components/navigation/BasicLayout.d.ts +10 -8
- package/dist_es/react/components/navigation/BasicLayout.js +28 -10
- package/dist_es/react/components/navigation/BasicLayout.js.map +1 -1
- package/dist_es/react/components/navigation/HeaderSiderLayout.d.ts +13 -0
- package/dist_es/react/components/navigation/HeaderSiderLayout.js +81 -0
- package/dist_es/react/components/navigation/HeaderSiderLayout.js.map +1 -0
- package/dist_es/react/components/navigation/MenuTrigger.d.ts +9 -0
- package/dist_es/react/components/navigation/MenuTrigger.js +29 -0
- package/dist_es/react/components/navigation/MenuTrigger.js.map +1 -0
- package/dist_es/react/components/navigation/ReactRouterHeaderSiderLayout.d.ts +11 -0
- package/dist_es/react/components/navigation/ReactRouterHeaderSiderLayout.js +19 -0
- package/dist_es/react/components/navigation/ReactRouterHeaderSiderLayout.js.map +1 -0
- package/dist_es/react/components/navigation/ReactRouterLayout.d.ts +25 -2
- package/dist_es/react/components/navigation/ReactRouterLayout.js +54 -15
- package/dist_es/react/components/navigation/ReactRouterLayout.js.map +1 -1
- package/dist_es/react/hooks/useFin5BinUrl.d.ts +6 -0
- package/dist_es/react/hooks/useFin5BinUrl.js +12 -0
- package/dist_es/react/hooks/useFin5BinUrl.js.map +1 -0
- package/package.json +2 -4
- package/dist/react/components/navigation/ReactRouterLayout.d.ts +0 -23
- package/dist/react/components/navigation/ReactRouterLayout.js +0 -90
- package/dist/react/components/navigation/ReactRouterLayout.js.map +0 -1
- package/dist/react/components/navigation/customRouting/Router.js.map +0 -1
- package/dist/react/components/navigation/customRouting/RouterLayout.d.ts +0 -11
- package/dist/react/components/navigation/customRouting/RouterLayout.js +0 -62
- package/dist/react/components/navigation/customRouting/RouterLayout.js.map +0 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024, J2 Innovations. All Rights Reserved
|
|
3
|
+
*/
|
|
4
|
+
import { MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons';
|
|
5
|
+
import classNames from 'classnames';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { createUseStyles } from 'react-jss';
|
|
8
|
+
const useStyles = createUseStyles((theme) => ({
|
|
9
|
+
menuTrigger: ({ headerHeight }) => ({
|
|
10
|
+
width: headerHeight,
|
|
11
|
+
height: '100%',
|
|
12
|
+
textAlign: 'center',
|
|
13
|
+
fontSize: 18,
|
|
14
|
+
cursor: 'pointer',
|
|
15
|
+
transition: 'color 0.3s ease-in-out',
|
|
16
|
+
backgroundColor: 'transparent',
|
|
17
|
+
color: theme.linkColor,
|
|
18
|
+
padding: '0 0.5rem',
|
|
19
|
+
'&:hover': {
|
|
20
|
+
color: theme.linkActiveColor,
|
|
21
|
+
},
|
|
22
|
+
}),
|
|
23
|
+
}));
|
|
24
|
+
const MenuTrigger = ({ hiddenSider, headerHeight = 45, onClick, className, }) => {
|
|
25
|
+
const classes = useStyles({ headerHeight });
|
|
26
|
+
return hiddenSider ? (React.createElement(MenuUnfoldOutlined, { className: classNames(classes.menuTrigger, className), onClick: onClick })) : (React.createElement(MenuFoldOutlined, { className: classNames(classes.menuTrigger, className), onClick: onClick }));
|
|
27
|
+
};
|
|
28
|
+
export default MenuTrigger;
|
|
29
|
+
//# sourceMappingURL=MenuTrigger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MenuTrigger.js","sourceRoot":"","sources":["../../../../src/react/components/navigation/MenuTrigger.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,M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Props } from './HeaderSiderLayout';
|
|
4
|
+
import { ReactRouterMenuPage } from './ReactRouterLayout';
|
|
5
|
+
export interface ReactRouterHeaderSiderLayoutProps extends HeaderSiderLayoutProps<ReactRouterMenuPage> {
|
|
6
|
+
isSelectedRoute?: (page: ReactRouterMenuPage, location: Location) => boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Header/Sider layout that uses React Router.
|
|
10
|
+
*/
|
|
11
|
+
export declare const ReactRouterHeaderSiderLayout: React.FC<ReactRouterHeaderSiderLayoutProps>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024, J2 Innovations. All Rights Reserved
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { Outlet, useNavigate } from 'react-router';
|
|
6
|
+
import { HeaderSiderLayout } from './HeaderSiderLayout';
|
|
7
|
+
import { useDefaultOnSelect, useGetPageKeyRouteMap, useSelectedRoutes, } from './ReactRouterLayout';
|
|
8
|
+
/**
|
|
9
|
+
* Header/Sider layout that uses React Router.
|
|
10
|
+
*/
|
|
11
|
+
export const ReactRouterHeaderSiderLayout = ({ isSelectedRoute, pages = [], onSelect, ...otherProps }) => {
|
|
12
|
+
const navigate = useNavigate();
|
|
13
|
+
const selectedRoutes = useSelectedRoutes(pages, isSelectedRoute);
|
|
14
|
+
const pageKeyRouteMap = useGetPageKeyRouteMap(pages);
|
|
15
|
+
const defaultOnSelect = useDefaultOnSelect(navigate, pageKeyRouteMap, pages);
|
|
16
|
+
return (React.createElement(HeaderSiderLayout, { ...otherProps, pages: pages, onSelect: onSelect ?? defaultOnSelect, selectedPages: selectedRoutes },
|
|
17
|
+
React.createElement(Outlet, null)));
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=ReactRouterHeaderSiderLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReactRouterHeaderSiderLayout.js","sourceRoot":"","sources":["../../../../src/react/components/navigation/ReactRouterHeaderSiderLayout.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAA0B,MAAM,qBAAqB,CAAA;AAC/E,OAAO,EAEN,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,GACjB,MAAM,qBAAqB,CAAA;AAO5B;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAErC,CAAC,EAAE,eAAe,EAAE,KAAK,GAAG,EAAE,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,EAAE,EAAE;IAChE,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAA;IAC9B,MAAM,cAAc,GAAG,iBAAiB,CAAC,KAAK,EAAE,eAAe,CAAC,CAAA;IAChE,MAAM,eAAe,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAA;IACpD,MAAM,eAAe,GAAG,kBAAkB,CAAC,QAAQ,EAAE,eAAe,EAAE,KAAK,CAAC,CAAA;IAE5E,OAAO,CACN,oBAAC,iBAAiB,OACb,UAAU,EACd,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,IAAI,eAAe,EACrC,aAAa,EAAE,cAAc;QAC7B,oBAAC,MAAM,OAAG,CACS,CACpB,CAAA;AACF,CAAC,CAAA"}
|
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
import type { Location } from '@remix-run/router';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { NavigateFunction } from 'react-router';
|
|
3
4
|
import { BasicLayoutProps } from './BasicLayout';
|
|
4
5
|
import { MenuPage } from './MenuPage';
|
|
5
|
-
export
|
|
6
|
-
|
|
6
|
+
export declare type ReactRouterMenuPage = MenuPage & {
|
|
7
|
+
route: string;
|
|
8
|
+
};
|
|
9
|
+
export interface ReactRouterLayoutProps extends BasicLayoutProps<ReactRouterMenuPage> {
|
|
10
|
+
isSelectedRoute?: (page: ReactRouterMenuPage, location: Location) => boolean;
|
|
7
11
|
}
|
|
8
12
|
/**
|
|
9
13
|
* This hook can be used with react-router/BasicLayout,
|
|
10
14
|
* to ensure FIN5 URL is aligned with the internal frame URL.
|
|
15
|
+
* This does not skip the hash update and should be used only with
|
|
16
|
+
* FIN >= 5.1.7.92, otherwise FIN will reload the entire page.
|
|
11
17
|
*/
|
|
12
18
|
export declare const useLocationUpdate: () => void;
|
|
19
|
+
/**
|
|
20
|
+
* This hook can be used with react-router/BasicLayout,
|
|
21
|
+
* to ensure FIN5 URL is aligned with the internal frame URL.
|
|
22
|
+
* This skips the hash update and should be used only with
|
|
23
|
+
* FIN < 5.1.7.92.
|
|
24
|
+
* @deprecated use only with FIN < 5.1.7.92
|
|
25
|
+
* @see {@link useLocationUpdate} for FIN >= 5.1.7.92
|
|
26
|
+
*/
|
|
27
|
+
export declare const useLocationUpdateSkippingHash: () => void;
|
|
28
|
+
export declare const useSelectedRoutes: (pages: ReactRouterMenuPage[], isSelectedRoute?: (page: ReactRouterMenuPage, location: Location) => boolean) => string[];
|
|
13
29
|
/**
|
|
14
30
|
* If we are inside a frame (FIN5), the route is left as is.
|
|
15
31
|
* If we are outside FIN5 frame, the route needs to be prefixed with a segment containing the project name.
|
|
@@ -17,6 +33,13 @@ export declare const useLocationUpdate: () => void;
|
|
|
17
33
|
* @returns the correct route for the environment
|
|
18
34
|
*/
|
|
19
35
|
export declare const getRoute: (route: string) => string;
|
|
36
|
+
/**
|
|
37
|
+
* Create a map that holds the page key and its related route.
|
|
38
|
+
* @param pages
|
|
39
|
+
* @returns the map page key - route
|
|
40
|
+
*/
|
|
41
|
+
export declare const useGetPageKeyRouteMap: (pages: ReactRouterMenuPage[]) => Map<string, string>;
|
|
42
|
+
export declare const useDefaultOnSelect: (navigate: NavigateFunction, pageKeyRouteMap: Map<string, string>, pages: ReactRouterMenuPage[]) => (key: string) => void;
|
|
20
43
|
/**
|
|
21
44
|
* Basic layout that uses React Router.
|
|
22
45
|
*/
|
|
@@ -2,32 +2,50 @@
|
|
|
2
2
|
* Copyright (c) 2023, J2 Innovations. All Rights Reserved
|
|
3
3
|
*/
|
|
4
4
|
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
5
|
-
import { Outlet, useLocation, useNavigate } from 'react-router';
|
|
5
|
+
import { Outlet, useLocation, useNavigate, } from 'react-router';
|
|
6
6
|
import { IN_IFRAME, fin5SkipHashUpdate, getFin5HashFrameParameters, getTopLocation, } from '../../../fin5Top/useFin5AppURLHashParameter';
|
|
7
7
|
import { BasicLayout } from './BasicLayout';
|
|
8
8
|
import { pageTreeToPageList } from './MenuPage';
|
|
9
9
|
/**
|
|
10
10
|
* This hook can be used with react-router/BasicLayout,
|
|
11
11
|
* to ensure FIN5 URL is aligned with the internal frame URL.
|
|
12
|
+
* This does not skip the hash update and should be used only with
|
|
13
|
+
* FIN >= 5.1.7.92, otherwise FIN will reload the entire page.
|
|
12
14
|
*/
|
|
13
15
|
export const useLocationUpdate = () => {
|
|
14
16
|
const location = useLocation();
|
|
15
17
|
useEffect(() => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
if (IN_IFRAME) {
|
|
19
|
+
setHash(location);
|
|
20
|
+
}
|
|
21
|
+
}, [location]);
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* This hook can be used with react-router/BasicLayout,
|
|
25
|
+
* to ensure FIN5 URL is aligned with the internal frame URL.
|
|
26
|
+
* This skips the hash update and should be used only with
|
|
27
|
+
* FIN < 5.1.7.92.
|
|
28
|
+
* @deprecated use only with FIN < 5.1.7.92
|
|
29
|
+
* @see {@link useLocationUpdate} for FIN >= 5.1.7.92
|
|
30
|
+
*/
|
|
31
|
+
export const useLocationUpdateSkippingHash = () => {
|
|
32
|
+
const location = useLocation();
|
|
33
|
+
useEffect(() => {
|
|
18
34
|
if (IN_IFRAME) {
|
|
19
35
|
fin5SkipHashUpdate()?.then(() => {
|
|
20
|
-
|
|
21
|
-
frameParameters.set('url', frameParameters.get('url')?.split('#')[0] +
|
|
22
|
-
'#' +
|
|
23
|
-
hash +
|
|
24
|
-
queryParams);
|
|
25
|
-
getTopLocation().hash = `#${getTopLocation().hash.slice(1).split('?')[0]}?${frameParameters.toString()}`;
|
|
36
|
+
setHash(location);
|
|
26
37
|
});
|
|
27
38
|
}
|
|
28
39
|
}, [location]);
|
|
29
40
|
};
|
|
30
|
-
const
|
|
41
|
+
const setHash = (location) => {
|
|
42
|
+
const hash = location.pathname;
|
|
43
|
+
const queryParams = location.search;
|
|
44
|
+
const frameParameters = getFin5HashFrameParameters();
|
|
45
|
+
frameParameters.set('url', frameParameters.get('url')?.split('#')[0] + '#' + hash + queryParams);
|
|
46
|
+
getTopLocation().hash = `#${getTopLocation().hash.slice(1).split('?')[0]}?${frameParameters.toString()}`;
|
|
47
|
+
};
|
|
48
|
+
export const useSelectedRoutes = (pages, isSelectedRoute = (page, location) => location.pathname.includes(page.route)) => {
|
|
31
49
|
const location = useLocation();
|
|
32
50
|
const flatPages = useMemo(() => pageTreeToPageList(pages), [pages]);
|
|
33
51
|
return useMemo(() => {
|
|
@@ -46,16 +64,37 @@ export const getRoute = (route) => {
|
|
|
46
64
|
const prefixedRoute = route.startsWith('/') ? route : `/${route}`;
|
|
47
65
|
return !IN_IFRAME ? `/proj/:projectName${prefixedRoute}` : prefixedRoute;
|
|
48
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* Create a map that holds the page key and its related route.
|
|
69
|
+
* @param pages
|
|
70
|
+
* @returns the map page key - route
|
|
71
|
+
*/
|
|
72
|
+
export const useGetPageKeyRouteMap = (pages) => useMemo(() => {
|
|
73
|
+
const flatPages = pageTreeToPageList(pages);
|
|
74
|
+
const result = new Map();
|
|
75
|
+
flatPages.forEach((page) => {
|
|
76
|
+
result.set(page.key, page.route);
|
|
77
|
+
});
|
|
78
|
+
return result;
|
|
79
|
+
}, [pages]);
|
|
80
|
+
export const useDefaultOnSelect = (navigate, pageKeyRouteMap, pages) => useCallback((key) => {
|
|
81
|
+
const route = pageKeyRouteMap.get(key);
|
|
82
|
+
if (route) {
|
|
83
|
+
navigate(route);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
console.warn('Could not find route for page key', key, 'pages', pages);
|
|
87
|
+
}
|
|
88
|
+
}, [navigate, pageKeyRouteMap]);
|
|
49
89
|
/**
|
|
50
90
|
* Basic layout that uses React Router.
|
|
51
91
|
*/
|
|
52
|
-
export const ReactRouterLayout = ({ isSelectedRoute, pages = [], ...otherProps }) => {
|
|
92
|
+
export const ReactRouterLayout = ({ isSelectedRoute, pages = [], onSelect, ...otherProps }) => {
|
|
53
93
|
const navigate = useNavigate();
|
|
54
94
|
const selectedRoutes = useSelectedRoutes(pages, isSelectedRoute);
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
return (React.createElement(BasicLayout, { ...otherProps, pages: pages, onSelect: onSelect, selectedPages: selectedRoutes },
|
|
95
|
+
const pageKeyRouteMap = useGetPageKeyRouteMap(pages);
|
|
96
|
+
const defaultOnSelect = useDefaultOnSelect(navigate, pageKeyRouteMap, pages);
|
|
97
|
+
return (React.createElement(BasicLayout, { ...otherProps, pages: pages, onSelect: onSelect ?? defaultOnSelect, selectedPages: selectedRoutes },
|
|
59
98
|
React.createElement(Outlet, null)));
|
|
60
99
|
};
|
|
61
100
|
//# sourceMappingURL=ReactRouterLayout.js.map
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"ReactRouterLayout.js","sourceRoot":"","sources":["../../../../src/react/components/navigation/ReactRouterLayout.tsx"],"names":[],"mappings":"AAAA;;G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MAAM,eAAe,GAAG,kBAAkB,CAAC,QAAQ,EAAE,eAAe,EAAE,KAAK,CAAC,CAAA;IAE5E,OAAO,CACN,oBAAC,WAAW,OACP,UAAU,EACd,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,IAAI,eAAe,EACrC,aAAa,EAAE,cAAc;QAC7B,oBAAC,MAAM,OAAG,CACG,CACd,CAAA;AACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { HRef } from 'haystack-core';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the url of a Fin 5 bin based on the file record id, or undefined if the url couldn't be retrieved.
|
|
4
|
+
* Uses haystack-nclient to retrieve the projectName from context.
|
|
5
|
+
*/
|
|
6
|
+
export declare const useFin5BinUrl: (fileId?: HRef) => string | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useClient } from 'haystack-react';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { getFin5BinUrl } from '../../fin5Top/getFin5BinUrl';
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves the url of a Fin 5 bin based on the file record id, or undefined if the url couldn't be retrieved.
|
|
6
|
+
* Uses haystack-nclient to retrieve the projectName from context.
|
|
7
|
+
*/
|
|
8
|
+
export const useFin5BinUrl = (fileId) => {
|
|
9
|
+
const projectName = useClient().project;
|
|
10
|
+
return useMemo(() => (fileId ? getFin5BinUrl(fileId, projectName) : undefined), [fileId, projectName]);
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=useFin5BinUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFin5BinUrl.js","sourceRoot":"","sources":["../../../src/react/hooks/useFin5BinUrl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAE3D;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAa,EAAsB,EAAE;IAClE,MAAM,WAAW,GAAG,SAAS,EAAE,CAAC,OAAO,CAAA;IAEvC,OAAO,OAAO,CACb,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAC/D,CAAC,MAAM,EAAE,WAAW,CAAC,CACrB,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.
|
|
3
|
+
"version": "1.0.9",
|
|
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",
|
|
@@ -41,9 +41,7 @@
|
|
|
41
41
|
"haystack-units": "^1.0.20",
|
|
42
42
|
"react": "^18.2.0",
|
|
43
43
|
"react-dom": "^18.2.0",
|
|
44
|
-
"react-jss": "^10.9.2"
|
|
45
|
-
"react-router": "^6.10.0",
|
|
46
|
-
"react-router-dom": "^6.10.0"
|
|
44
|
+
"react-jss": "^10.9.2"
|
|
47
45
|
},
|
|
48
46
|
"devDependencies": {
|
|
49
47
|
"@babel/cli": "^7.18.10",
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
* If we are inside a frame (FIN5), the route is left as is.
|
|
15
|
-
* If we are outside FIN5 frame, the route needs to be prefixed with a segment containing the project name.
|
|
16
|
-
* @param route
|
|
17
|
-
* @returns the correct route for the environment
|
|
18
|
-
*/
|
|
19
|
-
export declare const getRoute: (route: string) => string;
|
|
20
|
-
/**
|
|
21
|
-
* Basic layout that uses React Router.
|
|
22
|
-
*/
|
|
23
|
-
export declare const ReactRouterLayout: React.FC<ReactRouterLayoutProps>;
|
|
@@ -1,90 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.ReactRouterLayout = exports.getRoute = 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
|
-
const hash = location.pathname;
|
|
43
|
-
const queryParams = location.search;
|
|
44
|
-
if (useFin5AppURLHashParameter_1.IN_IFRAME) {
|
|
45
|
-
(0, useFin5AppURLHashParameter_1.fin5SkipHashUpdate)()?.then(() => {
|
|
46
|
-
const frameParameters = (0, useFin5AppURLHashParameter_1.getFin5HashFrameParameters)();
|
|
47
|
-
frameParameters.set('url', frameParameters.get('url')?.split('#')[0] +
|
|
48
|
-
'#' +
|
|
49
|
-
hash +
|
|
50
|
-
queryParams);
|
|
51
|
-
(0, useFin5AppURLHashParameter_1.getTopLocation)().hash = `#${(0, useFin5AppURLHashParameter_1.getTopLocation)().hash.slice(1).split('?')[0]}?${frameParameters.toString()}`;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}, [location]);
|
|
55
|
-
};
|
|
56
|
-
exports.useLocationUpdate = useLocationUpdate;
|
|
57
|
-
const useSelectedRoutes = (pages, isSelectedRoute = (page, location) => location.pathname.includes(`/${page.key}`)) => {
|
|
58
|
-
const location = (0, react_router_1.useLocation)();
|
|
59
|
-
const flatPages = (0, react_1.useMemo)(() => (0, MenuPage_1.pageTreeToPageList)(pages), [pages]);
|
|
60
|
-
return (0, react_1.useMemo)(() => {
|
|
61
|
-
return flatPages
|
|
62
|
-
.filter((page) => isSelectedRoute(page, location))
|
|
63
|
-
.map((page) => page.key);
|
|
64
|
-
}, [location, flatPages, isSelectedRoute]);
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* If we are inside a frame (FIN5), the route is left as is.
|
|
68
|
-
* If we are outside FIN5 frame, the route needs to be prefixed with a segment containing the project name.
|
|
69
|
-
* @param route
|
|
70
|
-
* @returns the correct route for the environment
|
|
71
|
-
*/
|
|
72
|
-
const getRoute = (route) => {
|
|
73
|
-
const prefixedRoute = route.startsWith('/') ? route : `/${route}`;
|
|
74
|
-
return !useFin5AppURLHashParameter_1.IN_IFRAME ? `/proj/:projectName${prefixedRoute}` : prefixedRoute;
|
|
75
|
-
};
|
|
76
|
-
exports.getRoute = getRoute;
|
|
77
|
-
/**
|
|
78
|
-
* Basic layout that uses React Router.
|
|
79
|
-
*/
|
|
80
|
-
const ReactRouterLayout = ({ isSelectedRoute, pages = [], ...otherProps }) => {
|
|
81
|
-
const navigate = (0, react_router_1.useNavigate)();
|
|
82
|
-
const selectedRoutes = useSelectedRoutes(pages, isSelectedRoute);
|
|
83
|
-
const onSelect = (0, react_1.useCallback)((key) => {
|
|
84
|
-
navigate(key);
|
|
85
|
-
}, [navigate]);
|
|
86
|
-
return (react_1.default.createElement(BasicLayout_1.BasicLayout, { ...otherProps, pages: pages, onSelect: onSelect, selectedPages: selectedRoutes },
|
|
87
|
-
react_1.default.createElement(react_router_1.Outlet, null)));
|
|
88
|
-
};
|
|
89
|
-
exports.ReactRouterLayout = ReactRouterLayout;
|
|
90
|
-
//# sourceMappingURL=ReactRouterLayout.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReactRouterLayout.js","sourceRo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ED,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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,11 +0,0 @@
|
|
|
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>;
|
|
@@ -1,62 +0,0 @@
|
|
|
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, selectedPages: [currentPage] },
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,EAClB,aAAa,EAAE,CAAC,WAAW,CAAC;QAC5B,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