@j2inn/fin5-ui-utils 3.0.7-beta.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/fantomProps/createFin5Props/index.d.ts +12 -12
- package/dist/fantomProps/createFin5Props/index.js +146 -146
- package/dist/fantomProps/createFin5Props/runCreateFin5Props.d.ts +2 -2
- package/dist/fantomProps/createFin5Props/runCreateFin5Props.js +16 -16
- package/dist/fantomProps/fantomPropsToObject.d.ts +8 -8
- package/dist/fantomProps/fantomPropsToObject.js +183 -183
- package/dist/fantomProps/generateJsonFromFantomPropsFile.d.ts +4 -4
- package/dist/fantomProps/generateJsonFromFantomPropsFile.js +41 -41
- package/dist/fantomProps/localePropsToJson.d.ts +1 -1
- package/dist/fantomProps/localePropsToJson.js +50 -50
- package/dist/fantomProps/readFantomPropsFile.d.ts +5 -5
- package/dist/fantomProps/readFantomPropsFile.js +61 -61
- package/dist/fin5Top/fin5FileUpload.d.ts +24 -24
- package/dist/fin5Top/fin5FileUpload.js +51 -51
- package/dist/fin5Top/fin5Top.d.ts +115 -115
- package/dist/fin5Top/fin5Top.js +58 -58
- package/dist/fin5Top/finEdge2Cloud.d.ts +6 -6
- package/dist/fin5Top/finEdge2Cloud.js +15 -15
- package/dist/fin5Top/getFin5BinUrl.d.ts +2 -2
- package/dist/fin5Top/getFin5BinUrl.js +9 -9
- package/dist/fin5Top/openFin5Alarm.d.ts +22 -22
- package/dist/fin5Top/openFin5Alarm.js +23 -23
- package/dist/fin5Top/openFin5Historian.d.ts +3 -3
- package/dist/fin5Top/openFin5Historian.js +19 -19
- package/dist/fin5Top/useFin5AppURLHashParameter.d.ts +18 -18
- package/dist/fin5Top/useFin5AppURLHashParameter.js +128 -128
- package/dist/index.d.ts +30 -30
- package/dist/index.js +64 -64
- package/dist/jobs/jobUtils.d.ts +14 -14
- package/dist/jobs/jobUtils.js +15 -15
- package/dist/react/app/Fin5AppContainer.d.ts +36 -36
- package/dist/react/app/Fin5AppContainer.js +102 -102
- package/dist/react/app/Fin5AppRootStore.d.ts +39 -39
- package/dist/react/app/Fin5AppRootStore.js +69 -69
- package/dist/react/components/ErrorBoundary.d.ts +57 -57
- package/dist/react/components/ErrorBoundary.js +150 -150
- package/dist/react/components/ErrorDisplayer.d.ts +19 -19
- package/dist/react/components/ErrorDisplayer.js +36 -36
- package/dist/react/components/Loader.d.ts +9 -9
- package/dist/react/components/Loader.js +17 -17
- package/dist/react/components/LoadingSpinner.d.ts +2 -2
- package/dist/react/components/LoadingSpinner.js +27 -27
- package/dist/react/components/RecordImage.d.ts +20 -20
- package/dist/react/components/RecordImage.js +51 -51
- package/dist/react/components/charts/QRCode.d.ts +25 -25
- package/dist/react/components/charts/QRCode.js +81 -81
- package/dist/react/components/charts/pie/PieChart.d.ts +93 -93
- package/dist/react/components/charts/pie/PieChart.js +202 -202
- package/dist/react/components/charts/pie/SimplePieChart.d.ts +20 -20
- package/dist/react/components/charts/pie/SimplePieChart.js +55 -55
- package/dist/react/components/graphics/GraphicViewer.d.ts +10 -10
- package/dist/react/components/graphics/GraphicViewer.js +29 -29
- package/dist/react/components/graphics/GraphicsTabViewer.d.ts +17 -17
- package/dist/react/components/graphics/GraphicsTabViewer.js +90 -90
- package/dist/react/components/navigation/BasicLayout.d.ts +41 -41
- package/dist/react/components/navigation/BasicLayout.js +155 -155
- package/dist/react/components/navigation/HeaderSiderLayout.d.ts +13 -13
- package/dist/react/components/navigation/HeaderSiderLayout.js +110 -110
- package/dist/react/components/navigation/MenuPage.d.ts +37 -37
- package/dist/react/components/navigation/MenuPage.js +36 -36
- package/dist/react/components/navigation/MenuTrigger.d.ts +9 -9
- package/dist/react/components/navigation/MenuTrigger.js +33 -33
- package/dist/react/components/navigation/ReactRouterHeaderSiderLayout.d.ts +11 -11
- package/dist/react/components/navigation/ReactRouterHeaderSiderLayout.js +25 -25
- package/dist/react/components/navigation/ReactRouterLayout.d.ts +35 -35
- package/dist/react/components/navigation/ReactRouterLayout.js +113 -117
- package/dist/react/components/navigation/ReactRouterLayout.js.map +1 -1
- package/dist/react/components/navigation/customRouting/Router.d.ts +12 -12
- package/dist/react/components/navigation/customRouting/Router.js +45 -45
- package/dist/react/components/navigation/customRouting/RouterLayout.d.ts +11 -11
- package/dist/react/components/navigation/customRouting/RouterLayout.js +61 -61
- package/dist/react/components/resolvable/configurationForm/ConfigurationForm.d.ts +27 -27
- package/dist/react/components/resolvable/configurationForm/ConfigurationForm.js +95 -95
- package/dist/react/components/resolvable/configurationForm/ConfigurationFormEntry.d.ts +16 -16
- package/dist/react/components/resolvable/configurationForm/ConfigurationFormEntry.js +88 -88
- package/dist/react/components/resolvable/configurationForm/getSectionDefault.d.ts +16 -16
- package/dist/react/components/resolvable/configurationForm/getSectionDefault.js +99 -99
- package/dist/react/hooks/useFin5BinUrl.d.ts +6 -6
- package/dist/react/hooks/useFin5BinUrl.js +15 -15
- package/dist_es/fantomProps/createFin5Props/index.d.ts +12 -12
- package/dist_es/fantomProps/createFin5Props/index.js +140 -140
- package/dist_es/fantomProps/createFin5Props/index.js.map +0 -0
- package/dist_es/fantomProps/createFin5Props/runCreateFin5Props.d.ts +2 -2
- package/dist_es/fantomProps/createFin5Props/runCreateFin5Props.js +11 -11
- package/dist_es/fantomProps/createFin5Props/runCreateFin5Props.js.map +0 -0
- package/dist_es/fantomProps/fantomPropsToObject.d.ts +8 -8
- package/dist_es/fantomProps/fantomPropsToObject.js +178 -178
- package/dist_es/fantomProps/fantomPropsToObject.js.map +0 -0
- package/dist_es/fantomProps/generateJsonFromFantomPropsFile.d.ts +4 -4
- package/dist_es/fantomProps/generateJsonFromFantomPropsFile.js +12 -12
- package/dist_es/fantomProps/generateJsonFromFantomPropsFile.js.map +0 -0
- package/dist_es/fantomProps/localePropsToJson.d.ts +1 -1
- package/dist_es/fantomProps/localePropsToJson.js +21 -21
- package/dist_es/fantomProps/localePropsToJson.js.map +0 -0
- package/dist_es/fantomProps/readFantomPropsFile.d.ts +5 -5
- package/dist_es/fantomProps/readFantomPropsFile.js +35 -35
- package/dist_es/fantomProps/readFantomPropsFile.js.map +0 -0
- package/dist_es/fin5Top/fin5FileUpload.d.ts +24 -24
- package/dist_es/fin5Top/fin5FileUpload.js +47 -47
- package/dist_es/fin5Top/fin5Top.d.ts +115 -115
- package/dist_es/fin5Top/fin5Top.js +54 -54
- package/dist_es/fin5Top/fin5Top.js.map +0 -0
- package/dist_es/fin5Top/finEdge2Cloud.d.ts +6 -6
- package/dist_es/fin5Top/finEdge2Cloud.js +11 -11
- package/dist_es/fin5Top/getFin5BinUrl.d.ts +2 -2
- package/dist_es/fin5Top/getFin5BinUrl.js +5 -5
- package/dist_es/fin5Top/getFin5BinUrl.js.map +0 -0
- package/dist_es/fin5Top/openFin5Alarm.d.ts +22 -22
- package/dist_es/fin5Top/openFin5Alarm.js +19 -19
- package/dist_es/fin5Top/openFin5Alarm.js.map +0 -0
- package/dist_es/fin5Top/openFin5Historian.d.ts +3 -3
- package/dist_es/fin5Top/openFin5Historian.js +15 -15
- package/dist_es/fin5Top/openFin5Historian.js.map +0 -0
- package/dist_es/fin5Top/useFin5AppURLHashParameter.d.ts +18 -18
- package/dist_es/fin5Top/useFin5AppURLHashParameter.js +119 -119
- package/dist_es/fin5Top/useFin5AppURLHashParameter.js.map +0 -0
- package/dist_es/index.d.ts +30 -30
- package/dist_es/index.js +48 -48
- package/dist_es/index.js.map +0 -0
- package/dist_es/jobs/jobUtils.d.ts +14 -14
- package/dist_es/jobs/jobUtils.js +9 -9
- package/dist_es/react/app/Fin5AppContainer.d.ts +36 -36
- package/dist_es/react/app/Fin5AppContainer.js +73 -73
- package/dist_es/react/app/Fin5AppContainer.jsx +0 -0
- package/dist_es/react/app/Fin5AppContainer.jsx.map +0 -0
- package/dist_es/react/app/Fin5AppRootStore.d.ts +39 -39
- package/dist_es/react/app/Fin5AppRootStore.js +65 -65
- package/dist_es/react/app/Fin5AppRootStore.js.map +0 -0
- package/dist_es/react/components/ErrorBoundary.d.ts +57 -57
- package/dist_es/react/components/ErrorBoundary.js +123 -123
- package/dist_es/react/components/ErrorBoundary.jsx +0 -0
- package/dist_es/react/components/ErrorBoundary.jsx.map +0 -0
- package/dist_es/react/components/ErrorDisplayer.d.ts +19 -19
- package/dist_es/react/components/ErrorDisplayer.js +28 -28
- package/dist_es/react/components/ErrorDisplayer.jsx +0 -0
- package/dist_es/react/components/ErrorDisplayer.jsx.map +0 -0
- package/dist_es/react/components/Loader.d.ts +9 -9
- package/dist_es/react/components/Loader.js +12 -12
- package/dist_es/react/components/Loader.jsx +1 -1
- package/dist_es/react/components/Loader.jsx.map +1 -1
- package/dist_es/react/components/LoadingSpinner.d.ts +2 -2
- package/dist_es/react/components/LoadingSpinner.js +20 -20
- package/dist_es/react/components/LoadingSpinner.jsx +4 -3
- package/dist_es/react/components/LoadingSpinner.jsx.map +1 -1
- package/dist_es/react/components/RecordImage.d.ts +20 -20
- package/dist_es/react/components/RecordImage.js +24 -24
- package/dist_es/react/components/charts/QRCode.d.ts +25 -25
- package/dist_es/react/components/charts/QRCode.js +53 -53
- package/dist_es/react/components/charts/pie/PieChart.d.ts +93 -93
- package/dist_es/react/components/charts/pie/PieChart.js +175 -175
- package/dist_es/react/components/charts/pie/SimplePieChart.d.ts +20 -20
- package/dist_es/react/components/charts/pie/SimplePieChart.js +25 -25
- package/dist_es/react/components/graphics/GraphicViewer.d.ts +10 -10
- package/dist_es/react/components/graphics/GraphicViewer.js +22 -22
- package/dist_es/react/components/graphics/GraphicsTabViewer.d.ts +17 -17
- package/dist_es/react/components/graphics/GraphicsTabViewer.js +60 -60
- package/dist_es/react/components/navigation/BasicLayout.d.ts +41 -41
- package/dist_es/react/components/navigation/BasicLayout.js +124 -124
- package/dist_es/react/components/navigation/BasicLayout.jsx +7 -35
- package/dist_es/react/components/navigation/BasicLayout.jsx.map +1 -1
- package/dist_es/react/components/navigation/HeaderSiderLayout.d.ts +13 -13
- package/dist_es/react/components/navigation/HeaderSiderLayout.js +80 -80
- package/dist_es/react/components/navigation/MenuPage.d.ts +37 -37
- package/dist_es/react/components/navigation/MenuPage.js +30 -30
- package/dist_es/react/components/navigation/MenuPage.jsx +0 -0
- package/dist_es/react/components/navigation/MenuPage.jsx.map +1 -1
- package/dist_es/react/components/navigation/MenuTrigger.d.ts +9 -9
- package/dist_es/react/components/navigation/MenuTrigger.js +28 -28
- package/dist_es/react/components/navigation/ReactRouterHeaderSiderLayout.d.ts +11 -11
- package/dist_es/react/components/navigation/ReactRouterHeaderSiderLayout.js +18 -18
- package/dist_es/react/components/navigation/ReactRouterLayout.d.ts +35 -35
- package/dist_es/react/components/navigation/ReactRouterLayout.js +81 -85
- package/dist_es/react/components/navigation/ReactRouterLayout.js.map +1 -1
- package/dist_es/react/components/navigation/Router.d.ts +0 -0
- package/dist_es/react/components/navigation/Router.jsx +1 -1
- package/dist_es/react/components/navigation/Router.jsx.map +1 -1
- package/dist_es/react/components/navigation/customRouting/Router.d.ts +12 -12
- package/dist_es/react/components/navigation/customRouting/Router.js +18 -18
- package/dist_es/react/components/navigation/customRouting/RouterLayout.d.ts +11 -11
- package/dist_es/react/components/navigation/customRouting/RouterLayout.js +34 -34
- package/dist_es/react/components/resolvable/configurationForm/ConfigurationForm.d.ts +27 -27
- package/dist_es/react/components/resolvable/configurationForm/ConfigurationForm.js +64 -64
- package/dist_es/react/components/resolvable/configurationForm/ConfigurationFormEntry.d.ts +16 -16
- package/dist_es/react/components/resolvable/configurationForm/ConfigurationFormEntry.js +58 -58
- package/dist_es/react/components/resolvable/configurationForm/getSectionDefault.d.ts +16 -16
- package/dist_es/react/components/resolvable/configurationForm/getSectionDefault.js +94 -94
- package/dist_es/react/hooks/useFin5BinUrl.d.ts +6 -6
- package/dist_es/react/hooks/useFin5BinUrl.js +11 -11
- package/package.json +13 -13
- package/dist_es/react/components/graphics/GraphicViewer.jsx +0 -23
- package/dist_es/react/components/graphics/GraphicViewer.jsx.map +0 -1
- package/dist_es/react/components/graphics/GraphicsTabViewer.jsx +0 -63
- package/dist_es/react/components/graphics/GraphicsTabViewer.jsx.map +0 -1
- package/dist_es/react/components/navigation/Router.js +0 -19
- package/dist_es/react/components/navigation/Router.js.map +0 -1
- package/dist_es/react/components/navigation/react-router/BasicLayout.d.ts +0 -23
- package/dist_es/react/components/navigation/react-router/BasicLayout.js +0 -82
- package/dist_es/react/components/navigation/react-router/BasicLayout.js.map +0 -1
- package/dist_es/react/components/navigation/react-router/ReactRouterBasicLayout.d.ts +0 -24
- package/dist_es/react/components/navigation/react-router/ReactRouterBasicLayout.js +0 -82
- package/dist_es/react/components/navigation/react-router/ReactRouterBasicLayout.js.map +0 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { PieChartColorPalette, PieChartSliceData } from './PieChart';
|
|
3
|
-
export interface SimplePieChartProps {
|
|
4
|
-
data: PieChartSliceData[];
|
|
5
|
-
donut?: boolean;
|
|
6
|
-
animated?: boolean;
|
|
7
|
-
colorPalette?: Partial<PieChartColorPalette>;
|
|
8
|
-
tooltipFormat?: string;
|
|
9
|
-
numberFormat?: Intl.NumberFormatOptions;
|
|
10
|
-
hideLabels?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Optional DOM id for the chart container, if not specified it will be automatically generated
|
|
13
|
-
*/
|
|
14
|
-
DOMtargetId?: string;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Simplified version of the pie chart for quick usage and easy configuration.
|
|
18
|
-
* Serves also as an example of how to use the underlying PieChart component.
|
|
19
|
-
*/
|
|
20
|
-
export declare const SimplePieChart: React.FC<SimplePieChartProps>;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PieChartColorPalette, PieChartSliceData } from './PieChart';
|
|
3
|
+
export interface SimplePieChartProps {
|
|
4
|
+
data: PieChartSliceData[];
|
|
5
|
+
donut?: boolean;
|
|
6
|
+
animated?: boolean;
|
|
7
|
+
colorPalette?: Partial<PieChartColorPalette>;
|
|
8
|
+
tooltipFormat?: string;
|
|
9
|
+
numberFormat?: Intl.NumberFormatOptions;
|
|
10
|
+
hideLabels?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Optional DOM id for the chart container, if not specified it will be automatically generated
|
|
13
|
+
*/
|
|
14
|
+
DOMtargetId?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Simplified version of the pie chart for quick usage and easy configuration.
|
|
18
|
+
* Serves also as an example of how to use the underlying PieChart component.
|
|
19
|
+
*/
|
|
20
|
+
export declare const SimplePieChart: React.FC<SimplePieChartProps>;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2023, J2 Innovations. All Rights Reserved
|
|
3
|
-
*/
|
|
4
|
-
import * as am5 from '@amcharts/amcharts5';
|
|
5
|
-
import am5themes_Animated from '@amcharts/amcharts5/themes/Animated';
|
|
6
|
-
import React from 'react';
|
|
7
|
-
import { PieChart } from './PieChart';
|
|
8
|
-
/**
|
|
9
|
-
* Simplified version of the pie chart for quick usage and easy configuration.
|
|
10
|
-
* Serves also as an example of how to use the underlying PieChart component.
|
|
11
|
-
*/
|
|
12
|
-
export const SimplePieChart = ({ data, donut, animated, colorPalette, tooltipFormat, numberFormat = {
|
|
13
|
-
style: 'decimal',
|
|
14
|
-
minimumFractionDigits: 0,
|
|
15
|
-
maximumFractionDigits: 1,
|
|
16
|
-
}, hideLabels, DOMtargetId, }) => {
|
|
17
|
-
return (React.createElement(PieChart, { DOMtargetId: DOMtargetId, colorPalette: colorPalette, data: data, chartThemes: animated ? [am5themes_Animated] : undefined, chartSettingsProvider: () => ({
|
|
18
|
-
innerRadius: donut ? am5.percent(55) : undefined,
|
|
19
|
-
}), numberFormat: numberFormat, legendSettingsProvider: () => ({
|
|
20
|
-
centerX: am5.percent(50),
|
|
21
|
-
x: am5.percent(50),
|
|
22
|
-
}), seriesLabelsSettings: { forceHidden: hideLabels }, seriesSettings: { alignLabels: false }, slicesSettings: {
|
|
23
|
-
tooltipText: tooltipFormat,
|
|
24
|
-
} }));
|
|
25
|
-
};
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023, J2 Innovations. All Rights Reserved
|
|
3
|
+
*/
|
|
4
|
+
import * as am5 from '@amcharts/amcharts5';
|
|
5
|
+
import am5themes_Animated from '@amcharts/amcharts5/themes/Animated';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { PieChart } from './PieChart';
|
|
8
|
+
/**
|
|
9
|
+
* Simplified version of the pie chart for quick usage and easy configuration.
|
|
10
|
+
* Serves also as an example of how to use the underlying PieChart component.
|
|
11
|
+
*/
|
|
12
|
+
export const SimplePieChart = ({ data, donut, animated, colorPalette, tooltipFormat, numberFormat = {
|
|
13
|
+
style: 'decimal',
|
|
14
|
+
minimumFractionDigits: 0,
|
|
15
|
+
maximumFractionDigits: 1,
|
|
16
|
+
}, hideLabels, DOMtargetId, }) => {
|
|
17
|
+
return (React.createElement(PieChart, { DOMtargetId: DOMtargetId, colorPalette: colorPalette, data: data, chartThemes: animated ? [am5themes_Animated] : undefined, chartSettingsProvider: () => ({
|
|
18
|
+
innerRadius: donut ? am5.percent(55) : undefined,
|
|
19
|
+
}), numberFormat: numberFormat, legendSettingsProvider: () => ({
|
|
20
|
+
centerX: am5.percent(50),
|
|
21
|
+
x: am5.percent(50),
|
|
22
|
+
}), seriesLabelsSettings: { forceHidden: hideLabels }, seriesSettings: { alignLabels: false }, slicesSettings: {
|
|
23
|
+
tooltipText: tooltipFormat,
|
|
24
|
+
} }));
|
|
25
|
+
};
|
|
26
26
|
//# sourceMappingURL=SimplePieChart.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { HRef } from 'haystack-core';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
interface GraphicViewerProps {
|
|
4
|
-
projectName?: string;
|
|
5
|
-
graphicId: HRef;
|
|
6
|
-
targetRef: HRef;
|
|
7
|
-
className?: string;
|
|
8
|
-
}
|
|
9
|
-
export declare const GraphicViewer: React.FC<GraphicViewerProps>;
|
|
10
|
-
export {};
|
|
1
|
+
import { HRef } from 'haystack-core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
interface GraphicViewerProps {
|
|
4
|
+
projectName?: string;
|
|
5
|
+
graphicId: HRef;
|
|
6
|
+
targetRef: HRef;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const GraphicViewer: React.FC<GraphicViewerProps>;
|
|
10
|
+
export {};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2022, J2 Innovations. All Rights Reserved
|
|
3
|
-
*/
|
|
4
|
-
import cn from 'classnames';
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { createUseStyles } from 'react-jss';
|
|
7
|
-
import { fin5Top } from '../../../fin5Top/fin5Top';
|
|
8
|
-
const useStyles = createUseStyles({
|
|
9
|
-
iframe: {
|
|
10
|
-
width: '100%',
|
|
11
|
-
height: '100%',
|
|
12
|
-
border: 0,
|
|
13
|
-
overflow: 'hidden',
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
export const GraphicViewer = ({ projectName = fin5Top?.finstack?.projectName ?? '', graphicId, targetRef, className, }) => {
|
|
17
|
-
const classes = useStyles();
|
|
18
|
-
const url = new URL(`${window.location.protocol}//${window.location.host}/fin5/${projectName}`);
|
|
19
|
-
url.hash = `targetRef=${targetRef.toAxon()}`;
|
|
20
|
-
url.searchParams.set('projectRef', graphicId.toAxon());
|
|
21
|
-
return (React.createElement("iframe", { id: graphicId.toAxon(), className: cn(classes.iframe, className), src: url.toString() }));
|
|
22
|
-
};
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022, J2 Innovations. All Rights Reserved
|
|
3
|
+
*/
|
|
4
|
+
import cn from 'classnames';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { createUseStyles } from 'react-jss';
|
|
7
|
+
import { fin5Top } from '../../../fin5Top/fin5Top';
|
|
8
|
+
const useStyles = createUseStyles({
|
|
9
|
+
iframe: {
|
|
10
|
+
width: '100%',
|
|
11
|
+
height: '100%',
|
|
12
|
+
border: 0,
|
|
13
|
+
overflow: 'hidden',
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
export const GraphicViewer = ({ projectName = fin5Top?.finstack?.projectName ?? '', graphicId, targetRef, className, }) => {
|
|
17
|
+
const classes = useStyles();
|
|
18
|
+
const url = new URL(`${window.location.protocol}//${window.location.host}/fin5/${projectName}`);
|
|
19
|
+
url.hash = `targetRef=${targetRef.toAxon()}`;
|
|
20
|
+
url.searchParams.set('projectRef', graphicId.toAxon());
|
|
21
|
+
return (React.createElement("iframe", { id: graphicId.toAxon(), className: cn(classes.iframe, className), src: url.toString() }));
|
|
22
|
+
};
|
|
23
23
|
//# sourceMappingURL=GraphicViewer.js.map
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { HRef } from 'haystack-core';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
interface GraphicsTabViewer {
|
|
4
|
-
projectName?: string;
|
|
5
|
-
targetRef: HRef;
|
|
6
|
-
className?: string;
|
|
7
|
-
/**
|
|
8
|
-
* Set it to true if you want to query also for related graphics (graphics applicable to objects linked by refs),
|
|
9
|
-
* false to just get the graphics on this target.
|
|
10
|
-
* @default false
|
|
11
|
-
*/
|
|
12
|
-
queryRelated?: boolean;
|
|
13
|
-
fallbackClassName?: string;
|
|
14
|
-
fallbackText?: string;
|
|
15
|
-
}
|
|
16
|
-
export declare const GraphicsTabViewer: React.FC<GraphicsTabViewer>;
|
|
17
|
-
export {};
|
|
1
|
+
import { HRef } from 'haystack-core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
interface GraphicsTabViewer {
|
|
4
|
+
projectName?: string;
|
|
5
|
+
targetRef: HRef;
|
|
6
|
+
className?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Set it to true if you want to query also for related graphics (graphics applicable to objects linked by refs),
|
|
9
|
+
* false to just get the graphics on this target.
|
|
10
|
+
* @default false
|
|
11
|
+
*/
|
|
12
|
+
queryRelated?: boolean;
|
|
13
|
+
fallbackClassName?: string;
|
|
14
|
+
fallbackText?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const GraphicsTabViewer: React.FC<GraphicsTabViewer>;
|
|
17
|
+
export {};
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2022, J2 Innovations. All Rights Reserved
|
|
3
|
-
*/
|
|
4
|
-
import { ant_prefix, Tabs } from '@j2inn/ui';
|
|
5
|
-
import cn from 'classnames';
|
|
6
|
-
import { useClient } from 'haystack-react';
|
|
7
|
-
import React, { useEffect, useMemo, useState } from 'react';
|
|
8
|
-
import { createUseStyles } from 'react-jss';
|
|
9
|
-
import { fin5Top } from '../../../fin5Top/fin5Top';
|
|
10
|
-
import { LoadingSpinner } from '../LoadingSpinner';
|
|
11
|
-
import { GraphicViewer } from './GraphicViewer';
|
|
12
|
-
const useStyles = createUseStyles({
|
|
13
|
-
tabs: {
|
|
14
|
-
height: '100%',
|
|
15
|
-
[`& .${ant_prefix}-tabs-content-holder`]: {
|
|
16
|
-
height: '100%',
|
|
17
|
-
[`& .${ant_prefix}-tabs-content`]: {
|
|
18
|
-
height: '100%',
|
|
19
|
-
[`& .${ant_prefix}-tabs-tabpane`]: {
|
|
20
|
-
height: '100%',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
fallback: {
|
|
26
|
-
height: '100%',
|
|
27
|
-
display: 'flex',
|
|
28
|
-
justifyContent: 'center',
|
|
29
|
-
alignItems: 'center',
|
|
30
|
-
fontSize: '1.1em',
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
export const GraphicsTabViewer = ({ projectName = fin5Top?.finstack?.projectName, targetRef, className, queryRelated = false, fallbackText = 'No graphics found.', fallbackClassName, }) => {
|
|
34
|
-
const client = useClient();
|
|
35
|
-
const classes = useStyles();
|
|
36
|
-
const [loading, setLoading] = useState(true);
|
|
37
|
-
const [graphicsList, setGraphicsList] = useState([]);
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
if (targetRef) {
|
|
40
|
-
client.ext
|
|
41
|
-
.eval(`readById(${targetRef.toAxon()}).finGraphicOn(${queryRelated})`)
|
|
42
|
-
.then((grid) => {
|
|
43
|
-
setGraphicsList(grid.getRows());
|
|
44
|
-
})
|
|
45
|
-
.finally(() => setLoading(false));
|
|
46
|
-
}
|
|
47
|
-
}, [targetRef]);
|
|
48
|
-
const tabs = useMemo(() => {
|
|
49
|
-
return graphicsList
|
|
50
|
-
.sort((g1, g2) => g1.toDis().localeCompare(g2.toDis()))
|
|
51
|
-
.map((graphic) => {
|
|
52
|
-
return {
|
|
53
|
-
label: graphic.toDis(),
|
|
54
|
-
key: graphic.id.toAxon(),
|
|
55
|
-
children: (React.createElement(GraphicViewer, { projectName: projectName ?? '', targetRef: targetRef, graphicId: graphic.id })),
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
}, [graphicsList]);
|
|
59
|
-
return loading ? (React.createElement(LoadingSpinner, null)) : tabs.length > 0 ? (React.createElement(Tabs, { className: cn(classes.tabs, className), items: tabs })) : (React.createElement("div", { className: cn(classes.fallback, fallbackClassName) }, fallbackText));
|
|
60
|
-
};
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022, J2 Innovations. All Rights Reserved
|
|
3
|
+
*/
|
|
4
|
+
import { ant_prefix, Tabs } from '@j2inn/ui';
|
|
5
|
+
import cn from 'classnames';
|
|
6
|
+
import { useClient } from 'haystack-react';
|
|
7
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
8
|
+
import { createUseStyles } from 'react-jss';
|
|
9
|
+
import { fin5Top } from '../../../fin5Top/fin5Top';
|
|
10
|
+
import { LoadingSpinner } from '../LoadingSpinner';
|
|
11
|
+
import { GraphicViewer } from './GraphicViewer';
|
|
12
|
+
const useStyles = createUseStyles({
|
|
13
|
+
tabs: {
|
|
14
|
+
height: '100%',
|
|
15
|
+
[`& .${ant_prefix}-tabs-content-holder`]: {
|
|
16
|
+
height: '100%',
|
|
17
|
+
[`& .${ant_prefix}-tabs-content`]: {
|
|
18
|
+
height: '100%',
|
|
19
|
+
[`& .${ant_prefix}-tabs-tabpane`]: {
|
|
20
|
+
height: '100%',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
fallback: {
|
|
26
|
+
height: '100%',
|
|
27
|
+
display: 'flex',
|
|
28
|
+
justifyContent: 'center',
|
|
29
|
+
alignItems: 'center',
|
|
30
|
+
fontSize: '1.1em',
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
export const GraphicsTabViewer = ({ projectName = fin5Top?.finstack?.projectName, targetRef, className, queryRelated = false, fallbackText = 'No graphics found.', fallbackClassName, }) => {
|
|
34
|
+
const client = useClient();
|
|
35
|
+
const classes = useStyles();
|
|
36
|
+
const [loading, setLoading] = useState(true);
|
|
37
|
+
const [graphicsList, setGraphicsList] = useState([]);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (targetRef) {
|
|
40
|
+
client.ext
|
|
41
|
+
.eval(`readById(${targetRef.toAxon()}).finGraphicOn(${queryRelated})`)
|
|
42
|
+
.then((grid) => {
|
|
43
|
+
setGraphicsList(grid.getRows());
|
|
44
|
+
})
|
|
45
|
+
.finally(() => setLoading(false));
|
|
46
|
+
}
|
|
47
|
+
}, [targetRef]);
|
|
48
|
+
const tabs = useMemo(() => {
|
|
49
|
+
return graphicsList
|
|
50
|
+
.sort((g1, g2) => g1.toDis().localeCompare(g2.toDis()))
|
|
51
|
+
.map((graphic) => {
|
|
52
|
+
return {
|
|
53
|
+
label: graphic.toDis(),
|
|
54
|
+
key: graphic.id.toAxon(),
|
|
55
|
+
children: (React.createElement(GraphicViewer, { projectName: projectName ?? '', targetRef: targetRef, graphicId: graphic.id })),
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
}, [graphicsList]);
|
|
59
|
+
return loading ? (React.createElement(LoadingSpinner, null)) : tabs.length > 0 ? (React.createElement(Tabs, { className: cn(classes.tabs, className), items: tabs })) : (React.createElement("div", { className: cn(classes.fallback, fallbackClassName) }, fallbackText));
|
|
60
|
+
};
|
|
61
61
|
//# sourceMappingURL=GraphicsTabViewer.js.map
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { LayoutProps, MenuProps, SiderProps } from 'antd';
|
|
2
|
-
import React, { PropsWithChildren, ReactElement } from 'react';
|
|
3
|
-
import { MenuPage } from './MenuPage';
|
|
4
|
-
export interface BasicLayoutStyleVariables {
|
|
5
|
-
isMobile?: boolean;
|
|
6
|
-
compactSider?: boolean;
|
|
7
|
-
siderWidth?: number | string;
|
|
8
|
-
headerHeight: number;
|
|
9
|
-
}
|
|
10
|
-
export interface BasicLayoutProps<T extends MenuPage> extends PropsWithChildren {
|
|
11
|
-
pages?: T[];
|
|
12
|
-
defaultPage?: string;
|
|
13
|
-
selectedPages?: string[];
|
|
14
|
-
onSelect?: (key: string) => void;
|
|
15
|
-
compactSider?: {
|
|
16
|
-
isCompact?: boolean;
|
|
17
|
-
showButton?: boolean;
|
|
18
|
-
buttonClassName?: string;
|
|
19
|
-
};
|
|
20
|
-
layoutProps?: LayoutProps;
|
|
21
|
-
mobileHeaderProps?: LayoutProps;
|
|
22
|
-
siderProps?: SiderProps;
|
|
23
|
-
contentProps?: LayoutProps;
|
|
24
|
-
menuProps?: Omit<MenuProps, 'items' | 'selectedKeys' | 'onSelect'>;
|
|
25
|
-
menuBefore?: React.ReactNode;
|
|
26
|
-
menuAfter?: React.ReactNode;
|
|
27
|
-
menuTriggerClassName?: string;
|
|
28
|
-
headerHeight?: number;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Copy the array and recursively remove pages having the `showInMenu` flag set to false.
|
|
32
|
-
* @param pages
|
|
33
|
-
* @returns
|
|
34
|
-
*/
|
|
35
|
-
export declare const getMenuPages: (pages: MenuPage[]) => MenuPage<Record<string, unknown>>[];
|
|
36
|
-
export declare const DEFAULT_HEADER_HEIGHT = 45;
|
|
37
|
-
/**
|
|
38
|
-
* Basic layout with sider and mobile navigation management.
|
|
39
|
-
* Routing management can be plugged in, for examples @see ReactRouterLayout @see RouterLayout
|
|
40
|
-
*/
|
|
41
|
-
export declare function BasicLayout<T extends MenuPage>({ pages, defaultPage, selectedPages, onSelect, compactSider, layoutProps, mobileHeaderProps, siderProps, contentProps, menuProps, menuBefore, menuAfter, menuTriggerClassName, headerHeight, children, }: BasicLayoutProps<T>): ReactElement;
|
|
1
|
+
import { LayoutProps, MenuProps, SiderProps } from 'antd';
|
|
2
|
+
import React, { PropsWithChildren, ReactElement } from 'react';
|
|
3
|
+
import { MenuPage } from './MenuPage';
|
|
4
|
+
export interface BasicLayoutStyleVariables {
|
|
5
|
+
isMobile?: boolean;
|
|
6
|
+
compactSider?: boolean;
|
|
7
|
+
siderWidth?: number | string;
|
|
8
|
+
headerHeight: number;
|
|
9
|
+
}
|
|
10
|
+
export interface BasicLayoutProps<T extends MenuPage> extends PropsWithChildren {
|
|
11
|
+
pages?: T[];
|
|
12
|
+
defaultPage?: string;
|
|
13
|
+
selectedPages?: string[];
|
|
14
|
+
onSelect?: (key: string) => void;
|
|
15
|
+
compactSider?: {
|
|
16
|
+
isCompact?: boolean;
|
|
17
|
+
showButton?: boolean;
|
|
18
|
+
buttonClassName?: string;
|
|
19
|
+
};
|
|
20
|
+
layoutProps?: LayoutProps;
|
|
21
|
+
mobileHeaderProps?: LayoutProps;
|
|
22
|
+
siderProps?: SiderProps;
|
|
23
|
+
contentProps?: LayoutProps;
|
|
24
|
+
menuProps?: Omit<MenuProps, 'items' | 'selectedKeys' | 'onSelect'>;
|
|
25
|
+
menuBefore?: React.ReactNode;
|
|
26
|
+
menuAfter?: React.ReactNode;
|
|
27
|
+
menuTriggerClassName?: string;
|
|
28
|
+
headerHeight?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Copy the array and recursively remove pages having the `showInMenu` flag set to false.
|
|
32
|
+
* @param pages
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
export declare const getMenuPages: (pages: MenuPage[]) => MenuPage<Record<string, unknown>>[];
|
|
36
|
+
export declare const DEFAULT_HEADER_HEIGHT = 45;
|
|
37
|
+
/**
|
|
38
|
+
* Basic layout with sider and mobile navigation management.
|
|
39
|
+
* Routing management can be plugged in, for examples @see ReactRouterLayout @see RouterLayout
|
|
40
|
+
*/
|
|
41
|
+
export declare function BasicLayout<T extends MenuPage>({ pages, defaultPage, selectedPages, onSelect, compactSider, layoutProps, mobileHeaderProps, siderProps, contentProps, menuProps, menuBefore, menuAfter, menuTriggerClassName, headerHeight, children, }: BasicLayoutProps<T>): ReactElement;
|
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2023, J2 Innovations. All Rights Reserved
|
|
3
|
-
*/
|
|
4
|
-
import { LeftOutlined } from '@ant-design/icons';
|
|
5
|
-
import { ant_prefix, Layout, Menu } from '@j2inn/ui';
|
|
6
|
-
import classNames from 'classnames';
|
|
7
|
-
import React, { useMemo, useState, } from 'react';
|
|
8
|
-
import { createUseStyles } from 'react-jss';
|
|
9
|
-
import MenuTrigger from './MenuTrigger';
|
|
10
|
-
const useStyles = createUseStyles({
|
|
11
|
-
header: ({ headerHeight }) => ({
|
|
12
|
-
position: 'fixed',
|
|
13
|
-
width: '100%',
|
|
14
|
-
zIndex: 1000,
|
|
15
|
-
padding: 0,
|
|
16
|
-
height: headerHeight,
|
|
17
|
-
lineHeight: `${headerHeight}px`,
|
|
18
|
-
}),
|
|
19
|
-
sider: {
|
|
20
|
-
overflow: 'auto',
|
|
21
|
-
height: '100vh',
|
|
22
|
-
position: 'fixed',
|
|
23
|
-
left: 0,
|
|
24
|
-
top: 0,
|
|
25
|
-
bottom: 0,
|
|
26
|
-
zIndex: 999,
|
|
27
|
-
paddingTop: ({ isMobile, headerHeight }) => isMobile ? headerHeight : 0,
|
|
28
|
-
[`& .${ant_prefix}-layout-sider-children`]: {
|
|
29
|
-
display: 'flex',
|
|
30
|
-
flexDirection: 'column',
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
compactSiderButton: {
|
|
34
|
-
position: 'sticky',
|
|
35
|
-
bottom: 0,
|
|
36
|
-
width: '100%',
|
|
37
|
-
textAlign: 'center',
|
|
38
|
-
fontSize: '1.3rem',
|
|
39
|
-
padding: '0.5rem',
|
|
40
|
-
cursor: 'pointer',
|
|
41
|
-
transition: '0.3s',
|
|
42
|
-
},
|
|
43
|
-
compactSiderButtonItem: {
|
|
44
|
-
transition: '0.3s',
|
|
45
|
-
},
|
|
46
|
-
compactSiderButtonItemCollapsed: {
|
|
47
|
-
transform: ' rotate(180deg)',
|
|
48
|
-
},
|
|
49
|
-
content: ({ isMobile, compactSider, siderWidth = 200, headerHeight, }) => ({
|
|
50
|
-
paddingLeft: isMobile ? 0 : compactSider ? 45 : siderWidth,
|
|
51
|
-
paddingTop: isMobile ? headerHeight : 0,
|
|
52
|
-
}),
|
|
53
|
-
});
|
|
54
|
-
// Workaround j2inn/ui exporting problem
|
|
55
|
-
const Header = Layout.Header;
|
|
56
|
-
const Sider = Layout.Sider;
|
|
57
|
-
const Content = Layout.Content;
|
|
58
|
-
/**
|
|
59
|
-
* Copy the array and recursively remove pages having the `showInMenu` flag set to false.
|
|
60
|
-
* @param pages
|
|
61
|
-
* @returns
|
|
62
|
-
*/
|
|
63
|
-
export const getMenuPages = (pages) => {
|
|
64
|
-
const menuPages = [];
|
|
65
|
-
pages.forEach((page) => {
|
|
66
|
-
const show = page.showInMenu == null || page.showInMenu;
|
|
67
|
-
if (show) {
|
|
68
|
-
const copiedPage = Object.assign({}, page);
|
|
69
|
-
if (copiedPage.children) {
|
|
70
|
-
const filteredChildren = getMenuPages(copiedPage.children);
|
|
71
|
-
copiedPage.children = filteredChildren.length
|
|
72
|
-
? filteredChildren
|
|
73
|
-
: undefined;
|
|
74
|
-
}
|
|
75
|
-
menuPages.push(copiedPage);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
return menuPages;
|
|
79
|
-
};
|
|
80
|
-
export const DEFAULT_HEADER_HEIGHT = 45;
|
|
81
|
-
/**
|
|
82
|
-
* Basic layout with sider and mobile navigation management.
|
|
83
|
-
* Routing management can be plugged in, for examples @see ReactRouterLayout @see RouterLayout
|
|
84
|
-
*/
|
|
85
|
-
export function BasicLayout({ pages = [], defaultPage, selectedPages = [], onSelect, compactSider, layoutProps, mobileHeaderProps, siderProps, contentProps, menuProps, menuBefore, menuAfter, menuTriggerClassName, headerHeight = DEFAULT_HEADER_HEIGHT, children, }) {
|
|
86
|
-
// manage mobile navigation
|
|
87
|
-
const [isMobile, setIsMobile] = useState(false);
|
|
88
|
-
const [isSiderCompact, setIsSiderCompact] = useState(compactSider?.isCompact ?? false);
|
|
89
|
-
const [hiddenSider, setHiddenSider] = useState(false);
|
|
90
|
-
const siderWidth = siderProps?.width;
|
|
91
|
-
const classes = useStyles({
|
|
92
|
-
isMobile,
|
|
93
|
-
compactSider: isSiderCompact,
|
|
94
|
-
siderWidth,
|
|
95
|
-
headerHeight,
|
|
96
|
-
});
|
|
97
|
-
const menuPages = useMemo(() => getMenuPages(pages), [pages]);
|
|
98
|
-
return (React.createElement(Layout, { hasSider: true, ...layoutProps },
|
|
99
|
-
isMobile && (React.createElement(Header, { ...mobileHeaderProps, className: classNames(classes.header, mobileHeaderProps?.className) },
|
|
100
|
-
React.createElement(MenuTrigger, { hiddenSider: hiddenSider, headerHeight: headerHeight, className: menuTriggerClassName, onClick: () => {
|
|
101
|
-
setHiddenSider(!hiddenSider);
|
|
102
|
-
} }))),
|
|
103
|
-
React.createElement(Sider, { ...siderProps, className: classNames(classes.sider, siderProps?.className), breakpoint: 'md', onBreakpoint: (broken) => {
|
|
104
|
-
setIsMobile(broken);
|
|
105
|
-
setHiddenSider(true);
|
|
106
|
-
}, collapsed: (isMobile && hiddenSider) || isSiderCompact, collapsedWidth: isMobile && hiddenSider
|
|
107
|
-
? 0
|
|
108
|
-
: isSiderCompact
|
|
109
|
-
? headerHeight
|
|
110
|
-
: 0, trigger: null },
|
|
111
|
-
menuBefore,
|
|
112
|
-
React.createElement(Menu, { style: { flex: 1 }, ...menuProps, defaultSelectedKeys: defaultPage ? [defaultPage] : undefined, items: menuPages, selectedKeys: selectedPages, onSelect: ({ key }) => {
|
|
113
|
-
if (!hiddenSider) {
|
|
114
|
-
setHiddenSider(true);
|
|
115
|
-
}
|
|
116
|
-
onSelect?.(key);
|
|
117
|
-
} }),
|
|
118
|
-
menuAfter,
|
|
119
|
-
compactSider?.showButton && !isMobile && (React.createElement("div", { className: classNames(classes.compactSiderButton, compactSider.buttonClassName), onClick: () => setIsSiderCompact(!isSiderCompact) },
|
|
120
|
-
React.createElement(LeftOutlined, { className: classNames(classes.compactSiderButtonItem, {
|
|
121
|
-
[classes.compactSiderButtonItemCollapsed]: isSiderCompact,
|
|
122
|
-
}) })))),
|
|
123
|
-
React.createElement(Content, { ...contentProps, className: classNames(classes.content, contentProps?.className) }, children)));
|
|
124
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023, J2 Innovations. All Rights Reserved
|
|
3
|
+
*/
|
|
4
|
+
import { LeftOutlined } from '@ant-design/icons';
|
|
5
|
+
import { ant_prefix, Layout, Menu } from '@j2inn/ui';
|
|
6
|
+
import classNames from 'classnames';
|
|
7
|
+
import React, { useMemo, useState, } from 'react';
|
|
8
|
+
import { createUseStyles } from 'react-jss';
|
|
9
|
+
import MenuTrigger from './MenuTrigger';
|
|
10
|
+
const useStyles = createUseStyles({
|
|
11
|
+
header: ({ headerHeight }) => ({
|
|
12
|
+
position: 'fixed',
|
|
13
|
+
width: '100%',
|
|
14
|
+
zIndex: 1000,
|
|
15
|
+
padding: 0,
|
|
16
|
+
height: headerHeight,
|
|
17
|
+
lineHeight: `${headerHeight}px`,
|
|
18
|
+
}),
|
|
19
|
+
sider: {
|
|
20
|
+
overflow: 'auto',
|
|
21
|
+
height: '100vh',
|
|
22
|
+
position: 'fixed',
|
|
23
|
+
left: 0,
|
|
24
|
+
top: 0,
|
|
25
|
+
bottom: 0,
|
|
26
|
+
zIndex: 999,
|
|
27
|
+
paddingTop: ({ isMobile, headerHeight }) => isMobile ? headerHeight : 0,
|
|
28
|
+
[`& .${ant_prefix}-layout-sider-children`]: {
|
|
29
|
+
display: 'flex',
|
|
30
|
+
flexDirection: 'column',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
compactSiderButton: {
|
|
34
|
+
position: 'sticky',
|
|
35
|
+
bottom: 0,
|
|
36
|
+
width: '100%',
|
|
37
|
+
textAlign: 'center',
|
|
38
|
+
fontSize: '1.3rem',
|
|
39
|
+
padding: '0.5rem',
|
|
40
|
+
cursor: 'pointer',
|
|
41
|
+
transition: '0.3s',
|
|
42
|
+
},
|
|
43
|
+
compactSiderButtonItem: {
|
|
44
|
+
transition: '0.3s',
|
|
45
|
+
},
|
|
46
|
+
compactSiderButtonItemCollapsed: {
|
|
47
|
+
transform: ' rotate(180deg)',
|
|
48
|
+
},
|
|
49
|
+
content: ({ isMobile, compactSider, siderWidth = 200, headerHeight, }) => ({
|
|
50
|
+
paddingLeft: isMobile ? 0 : compactSider ? 45 : siderWidth,
|
|
51
|
+
paddingTop: isMobile ? headerHeight : 0,
|
|
52
|
+
}),
|
|
53
|
+
});
|
|
54
|
+
// Workaround j2inn/ui exporting problem
|
|
55
|
+
const Header = Layout.Header;
|
|
56
|
+
const Sider = Layout.Sider;
|
|
57
|
+
const Content = Layout.Content;
|
|
58
|
+
/**
|
|
59
|
+
* Copy the array and recursively remove pages having the `showInMenu` flag set to false.
|
|
60
|
+
* @param pages
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
export const getMenuPages = (pages) => {
|
|
64
|
+
const menuPages = [];
|
|
65
|
+
pages.forEach((page) => {
|
|
66
|
+
const show = page.showInMenu == null || page.showInMenu;
|
|
67
|
+
if (show) {
|
|
68
|
+
const copiedPage = Object.assign({}, page);
|
|
69
|
+
if (copiedPage.children) {
|
|
70
|
+
const filteredChildren = getMenuPages(copiedPage.children);
|
|
71
|
+
copiedPage.children = filteredChildren.length
|
|
72
|
+
? filteredChildren
|
|
73
|
+
: undefined;
|
|
74
|
+
}
|
|
75
|
+
menuPages.push(copiedPage);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return menuPages;
|
|
79
|
+
};
|
|
80
|
+
export const DEFAULT_HEADER_HEIGHT = 45;
|
|
81
|
+
/**
|
|
82
|
+
* Basic layout with sider and mobile navigation management.
|
|
83
|
+
* Routing management can be plugged in, for examples @see ReactRouterLayout @see RouterLayout
|
|
84
|
+
*/
|
|
85
|
+
export function BasicLayout({ pages = [], defaultPage, selectedPages = [], onSelect, compactSider, layoutProps, mobileHeaderProps, siderProps, contentProps, menuProps, menuBefore, menuAfter, menuTriggerClassName, headerHeight = DEFAULT_HEADER_HEIGHT, children, }) {
|
|
86
|
+
// manage mobile navigation
|
|
87
|
+
const [isMobile, setIsMobile] = useState(false);
|
|
88
|
+
const [isSiderCompact, setIsSiderCompact] = useState(compactSider?.isCompact ?? false);
|
|
89
|
+
const [hiddenSider, setHiddenSider] = useState(false);
|
|
90
|
+
const siderWidth = siderProps?.width;
|
|
91
|
+
const classes = useStyles({
|
|
92
|
+
isMobile,
|
|
93
|
+
compactSider: isSiderCompact,
|
|
94
|
+
siderWidth,
|
|
95
|
+
headerHeight,
|
|
96
|
+
});
|
|
97
|
+
const menuPages = useMemo(() => getMenuPages(pages), [pages]);
|
|
98
|
+
return (React.createElement(Layout, { hasSider: true, ...layoutProps },
|
|
99
|
+
isMobile && (React.createElement(Header, { ...mobileHeaderProps, className: classNames(classes.header, mobileHeaderProps?.className) },
|
|
100
|
+
React.createElement(MenuTrigger, { hiddenSider: hiddenSider, headerHeight: headerHeight, className: menuTriggerClassName, onClick: () => {
|
|
101
|
+
setHiddenSider(!hiddenSider);
|
|
102
|
+
} }))),
|
|
103
|
+
React.createElement(Sider, { ...siderProps, className: classNames(classes.sider, siderProps?.className), breakpoint: 'md', onBreakpoint: (broken) => {
|
|
104
|
+
setIsMobile(broken);
|
|
105
|
+
setHiddenSider(true);
|
|
106
|
+
}, collapsed: (isMobile && hiddenSider) || isSiderCompact, collapsedWidth: isMobile && hiddenSider
|
|
107
|
+
? 0
|
|
108
|
+
: isSiderCompact
|
|
109
|
+
? headerHeight
|
|
110
|
+
: 0, trigger: null },
|
|
111
|
+
menuBefore,
|
|
112
|
+
React.createElement(Menu, { style: { flex: 1 }, ...menuProps, defaultSelectedKeys: defaultPage ? [defaultPage] : undefined, items: menuPages, selectedKeys: selectedPages, onSelect: ({ key }) => {
|
|
113
|
+
if (!hiddenSider) {
|
|
114
|
+
setHiddenSider(true);
|
|
115
|
+
}
|
|
116
|
+
onSelect?.(key);
|
|
117
|
+
} }),
|
|
118
|
+
menuAfter,
|
|
119
|
+
compactSider?.showButton && !isMobile && (React.createElement("div", { className: classNames(classes.compactSiderButton, compactSider.buttonClassName), onClick: () => setIsSiderCompact(!isSiderCompact) },
|
|
120
|
+
React.createElement(LeftOutlined, { className: classNames(classes.compactSiderButtonItem, {
|
|
121
|
+
[classes.compactSiderButtonItemCollapsed]: isSiderCompact,
|
|
122
|
+
}) })))),
|
|
123
|
+
React.createElement(Content, { ...contentProps, className: classNames(classes.content, contentProps?.className) }, children)));
|
|
124
|
+
}
|
|
125
125
|
//# sourceMappingURL=BasicLayout.js.map
|