@headless-adminapp/fluent 1.0.2 → 1.1.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/App/AppHeaderContianer.js +5 -1
- package/App/AppUI.js +7 -2
- package/App/Navigation/NavCategoryItemComponent.d.ts +8 -0
- package/App/Navigation/NavCategoryItemComponent.js +20 -0
- package/App/Navigation/NavItemComponent.d.ts +8 -0
- package/App/Navigation/NavItemComponent.js +19 -0
- package/App/Navigation/NavSubItemComponent.d.ts +8 -0
- package/App/Navigation/NavSubItemComponent.js +17 -0
- package/App/Navigation/NavigationContainer.d.ts +9 -0
- package/App/Navigation/NavigationContainer.js +85 -0
- package/App/Navigation/index.d.ts +1 -0
- package/App/Navigation/index.js +5 -0
- package/App/Navigation/types.d.ts +39 -0
- package/App/Navigation/types.js +2 -0
- package/App/Navigation/utils.d.ts +18 -0
- package/App/Navigation/utils.js +82 -0
- package/App/QuickActionItem.d.ts +3 -0
- package/App/QuickActionItem.js +12 -3
- package/CommandBar/Button.d.ts +1 -0
- package/CommandBar/Button.js +22 -2
- package/CommandBar/IconButton.d.ts +1 -0
- package/CommandBar/MenuButton.d.ts +1 -0
- package/CommandBar/MenuItem.d.ts +1 -0
- package/DataGrid/GridColumnHeader/TableHeaderFilterCell.js +3 -1
- package/DataGrid/GridHeaderContainer.d.ts +1 -0
- package/DataGrid/GridHeaderContainer.js +6 -1
- package/DataGrid/GridHeaderDesktopV2.d.ts +6 -0
- package/DataGrid/GridHeaderDesktopV2.js +54 -0
- package/DataGrid/GridListContainer.js +9 -5
- package/DataGrid/GridTableContainer.d.ts +2 -0
- package/DataGrid/GridTableContainer.js +37 -13
- package/DataGrid/TableCell/TableCellAction.js +2 -1
- package/DataGrid/TableCell/TableCellBase.js +1 -0
- package/DataGrid/TableCell/TableCellLink.js +1 -0
- package/DataGrid/constants.d.ts +2 -0
- package/DataGrid/constants.js +5 -0
- package/DataGrid/useTableColumns.js +23 -6
- package/Insights/CommandBarContainer.js +1 -1
- package/Insights/FilterBarContainer.js +8 -8
- package/Insights/Grid.d.ts +7 -1
- package/Insights/Grid.js +24 -8
- package/Insights/Header.d.ts +6 -0
- package/Insights/Header.js +50 -0
- package/Insights/InsightsContainer.js +19 -14
- package/Insights/WidgetChartContainer.d.ts +13 -3
- package/Insights/WidgetChartContainer.js +62 -38
- package/Insights/WidgetDataGridContainer.d.ts +11 -4
- package/Insights/WidgetDataGridContainer.js +7 -27
- package/Insights/WidgetSection.d.ts +2 -0
- package/Insights/WidgetSection.js +16 -0
- package/Insights/WidgetTableContainer.d.ts +9 -2
- package/Insights/WidgetTableContainer.js +7 -18
- package/Insights/WidgetTileContainer.d.ts +0 -2
- package/Insights/WidgetTileContainer.js +8 -11
- package/Insights/WidgetTitleBar.d.ts +1 -1
- package/Insights/WidgetTitleBar.js +1 -1
- package/Insights/Widgets.d.ts +2 -2
- package/Insights/Widgets.js +15 -48
- package/Insights/charts/AreaChart.d.ts +1 -0
- package/Insights/charts/AreaChart.js +4 -1
- package/Insights/charts/BarChart.d.ts +1 -0
- package/Insights/charts/BarChart.js +3 -2
- package/Insights/charts/ComposedChart.d.ts +1 -0
- package/Insights/charts/ComposedChart.js +4 -1
- package/Insights/charts/FunnelChart.d.ts +6 -0
- package/Insights/charts/FunnelChart.js +50 -0
- package/Insights/charts/FunnelCustomTooltipContent.d.ts +5 -0
- package/Insights/charts/FunnelCustomTooltipContent.js +27 -0
- package/Insights/charts/GaugeChart.d.ts +1 -0
- package/Insights/charts/GaugeChart.js +1 -0
- package/Insights/charts/LineChart.d.ts +1 -0
- package/Insights/charts/LineChart.js +2 -2
- package/Insights/charts/OhlcChart.d.ts +1 -0
- package/Insights/charts/OhlcChart.js +1 -1
- package/Insights/charts/PieChart.d.ts +1 -0
- package/Insights/charts/PieChart.js +2 -1
- package/Insights/charts/RadarChart.d.ts +1 -0
- package/Insights/charts/RadarChart.js +1 -0
- package/Insights/charts/ScatterChart.d.ts +1 -0
- package/Insights/charts/ScatterChart.js +2 -1
- package/Insights/charts/renderers.d.ts +6 -5
- package/Insights/charts/renderers.js +16 -13
- package/Insights/constants.d.ts +4 -0
- package/Insights/constants.js +7 -0
- package/Insights/hooks/useQueriesData.d.ts +2 -2
- package/Insights/hooks/useQueriesData.js +0 -1
- package/OverflowCommandBar/render.js +3 -3
- package/PageBoard/BoardColumnUI.js +36 -7
- package/PageBoard/Header.js +5 -3
- package/PageBoard/PageBoard.js +7 -1
- package/PageCalendar/CalendarSection.js +37 -8
- package/PageCalendar/EventDialog/AttributeController.d.ts +2 -1
- package/PageCalendar/EventDialog/AttributeController.js +2 -2
- package/PageCalendar/EventDialog/EventFormBody.js +17 -2
- package/PageCalendar/EventDialog/EventFormContent.d.ts +4 -1
- package/PageCalendar/EventDialog/EventFormContent.js +7 -7
- package/PageCalendar/Header.js +1 -1
- package/PageCalendar/PageCalendar.js +6 -1
- package/PageCalendar/TitleSelector.js +8 -4
- package/PageEntityForm/PageCustomEntityForm.d.ts +1 -2
- package/PageEntityForm/PageCustomEntityForm.js +3 -4
- package/PageEntityForm/PageEntityFormDesktopContainer.js +4 -0
- package/PageEntityForm/RecordAvatar.js +1 -2
- package/PageEntityForm/RecordCard.js +17 -28
- package/PageEntityForm/RelatedViewSelector.js +1 -0
- package/PageEntityForm/SectionContainer.js +7 -1
- package/PageEntityView/PageEntityView.d.ts +1 -0
- package/PageEntityView/PageEntityView.js +12 -2
- package/PageEntityView/PageEntityViewDesktopContainer.d.ts +1 -0
- package/PageEntityView/PageEntityViewDesktopContainer.js +7 -3
- package/PageEntityView/PageEntityViewDesktopFrame.js +1 -1
- package/PageEntityView/PageEntityViewDesktopFrameV2.d.ts +8 -0
- package/PageEntityView/PageEntityViewDesktopFrameV2.js +48 -0
- package/PageEntityView/PageEntityViewMobileContainer.js +2 -3
- package/PageEntityView/PageEntityViewMobileFrame.d.ts +8 -0
- package/PageEntityView/PageEntityViewMobileFrame.js +38 -0
- package/PageInsight/PageInsight.d.ts +7 -0
- package/PageInsight/PageInsight.js +31 -0
- package/PageInsight/index.d.ts +1 -0
- package/PageInsight/index.js +5 -0
- package/PageInsights/PageInsights.d.ts +5 -7
- package/PageInsights/PageInsights.js +24 -18
- package/PageInsights/index.d.ts +1 -1
- package/PageInsights/index.js +1 -2
- package/components/ComponentBroken.d.ts +7 -0
- package/components/ComponentBroken.js +16 -0
- package/components/ComponentErrorBoundary.d.ts +15 -0
- package/components/ComponentErrorBoundary.js +26 -0
- package/form/controls/DateTimeControl.js +17 -3
- package/form/controls/DurationControl.js +0 -2
- package/form/controls/LookupControl.js +6 -3
- package/package.json +3 -3
|
@@ -1,56 +1,80 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
26
|
+
exports.WidgetChart = void 0;
|
|
4
27
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const
|
|
28
|
+
const react_1 = require("react");
|
|
6
29
|
const BodyLoading_1 = require("../components/BodyLoading");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const ComposedChart_1 = require("./charts/ComposedChart");
|
|
10
|
-
const GaugeChart_1 = require("./charts/GaugeChart");
|
|
11
|
-
const LineChart_1 = require("./charts/LineChart");
|
|
12
|
-
const OhlcChart_1 = require("./charts/OhlcChart");
|
|
13
|
-
const PieChart_1 = require("./charts/PieChart");
|
|
14
|
-
const RadarChart_1 = require("./charts/RadarChart");
|
|
15
|
-
const ScatterChart_1 = require("./charts/ScatterChart");
|
|
16
|
-
const useWidgetDetail_1 = require("./hooks/useWidgetDetail");
|
|
30
|
+
const ComponentErrorBoundary_1 = require("../components/ComponentErrorBoundary");
|
|
31
|
+
const WidgetSection_1 = require("./WidgetSection");
|
|
17
32
|
const WidgetTitleBar_1 = require("./WidgetTitleBar");
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
)
|
|
33
|
+
const AreaChart = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./charts/AreaChart'))));
|
|
34
|
+
const BarChart = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./charts/BarChart'))));
|
|
35
|
+
const ComposedChart = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./charts/ComposedChart'))));
|
|
36
|
+
const FunnelChart = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./charts/FunnelChart'))));
|
|
37
|
+
const GaugeChart = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./charts/GaugeChart'))));
|
|
38
|
+
const LineChart = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./charts/LineChart'))));
|
|
39
|
+
const OhlcChart = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./charts/OhlcChart'))));
|
|
40
|
+
const PieChart = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./charts/PieChart'))));
|
|
41
|
+
const RadarChart = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./charts/RadarChart'))));
|
|
42
|
+
const ScatterChart = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./charts/ScatterChart'))));
|
|
43
|
+
function getChartComponent(chart) {
|
|
44
|
+
const type = chart.type;
|
|
21
45
|
switch (type) {
|
|
22
46
|
case 'line':
|
|
23
|
-
return
|
|
47
|
+
return LineChart;
|
|
24
48
|
case 'area':
|
|
25
|
-
return
|
|
49
|
+
return AreaChart;
|
|
26
50
|
case 'bar':
|
|
27
|
-
return
|
|
51
|
+
return BarChart;
|
|
28
52
|
case 'composed':
|
|
29
|
-
return
|
|
53
|
+
return ComposedChart;
|
|
30
54
|
case 'scatter':
|
|
31
|
-
return
|
|
55
|
+
return ScatterChart;
|
|
32
56
|
case 'pie':
|
|
33
|
-
return
|
|
57
|
+
return PieChart;
|
|
34
58
|
case 'radar':
|
|
35
|
-
return
|
|
59
|
+
return RadarChart;
|
|
36
60
|
case 'gauge':
|
|
37
|
-
return
|
|
61
|
+
return GaugeChart;
|
|
38
62
|
case 'ohlc':
|
|
39
|
-
return
|
|
63
|
+
return OhlcChart;
|
|
64
|
+
case 'funnel':
|
|
65
|
+
return FunnelChart;
|
|
66
|
+
default:
|
|
67
|
+
throw new Error(`Unsupported chart type: ${type}`);
|
|
40
68
|
}
|
|
41
69
|
}
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
53
|
-
flexDirection: 'column',
|
|
54
|
-
}, children: [(0, jsx_runtime_1.jsx)(WidgetTitleBar_1.WidgetTitleBar, { title: widget.title, commands: transformedCommands }), (0, jsx_runtime_1.jsxs)("div", { style: { flex: 1, position: 'relative' }, children: [!isPending && ((0, jsx_runtime_1.jsx)("div", { style: { position: 'absolute', inset: 0 }, children: (0, jsx_runtime_1.jsx)(ChartComponent, { dataset: dataset, chartInfo: info.chart }) })), (0, jsx_runtime_1.jsx)(BodyLoading_1.BodyLoading, { loading: isFetching })] })] }));
|
|
70
|
+
const WidgetChart = (props) => {
|
|
71
|
+
return ((0, jsx_runtime_1.jsxs)(WidgetSection_1.WidgetSection, { children: [(0, jsx_runtime_1.jsx)(WidgetTitleBar_1.WidgetTitleBar, { title: props.title, commands: props.commands }), (0, jsx_runtime_1.jsx)(WidgetChartBody, { dataset: props.dataset, chartInfo: props.chartInfo, isFetching: props.isFetching, isPending: props.isPending })] }));
|
|
72
|
+
};
|
|
73
|
+
exports.WidgetChart = WidgetChart;
|
|
74
|
+
const WidgetChartBody = ({ isFetching, isPending, chartInfo, dataset, }) => {
|
|
75
|
+
const ChartComponent = getChartComponent(chartInfo);
|
|
76
|
+
if (!ChartComponent) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flex: 1, position: 'relative' }, children: [!isPending && ((0, jsx_runtime_1.jsx)(ComponentErrorBoundary_1.ComponentErrorBoundary, { children: (0, jsx_runtime_1.jsx)("div", { style: { position: 'absolute', inset: 0 }, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: (0, jsx_runtime_1.jsx)(BodyLoading_1.BodyLoading, { loading: isFetching }), children: (0, jsx_runtime_1.jsx)(ChartComponent, { dataset: dataset, chartInfo: chartInfo }) }) }) })), (0, jsx_runtime_1.jsx)(BodyLoading_1.BodyLoading, { loading: isFetching })] }));
|
|
55
80
|
};
|
|
56
|
-
exports.WidgetChartContainer = WidgetChartContainer;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { Filter } from '@headless-adminapp/core/transport';
|
|
2
|
+
interface WidgetDataGridContainerProps {
|
|
3
|
+
title: string;
|
|
4
|
+
logicalName: string;
|
|
5
|
+
maxRecords?: number;
|
|
6
|
+
filter?: Filter;
|
|
7
|
+
commands?: any[][];
|
|
8
|
+
}
|
|
9
|
+
/*** @deprecated Need refactoring */
|
|
10
|
+
export declare function WidgetDataGridContainer({ logicalName, maxRecords, filter, commands, title, }: Readonly<WidgetDataGridContainerProps>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -8,13 +8,10 @@ const hooks_1 = require("@headless-adminapp/app/command/hooks");
|
|
|
8
8
|
const DataGridProvider_1 = require("@headless-adminapp/app/datagrid/DataGridProvider");
|
|
9
9
|
const hooks_2 = require("@headless-adminapp/app/datagrid/hooks");
|
|
10
10
|
const hooks_3 = require("@headless-adminapp/app/metadata/hooks");
|
|
11
|
-
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
12
|
-
const widget_1 = require("@headless-adminapp/app/widget");
|
|
13
|
-
const react_1 = require("react");
|
|
14
11
|
const DataGrid_1 = require("../DataGrid");
|
|
15
12
|
const WidgetTitleBar_1 = require("./WidgetTitleBar");
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
/*** @deprecated Need refactoring */
|
|
14
|
+
function WidgetDataGridContainer({ logicalName, maxRecords, filter, commands, title, }) {
|
|
18
15
|
const schema = (0, hooks_3.useSchema)(logicalName);
|
|
19
16
|
const { view } = (0, hooks_3.useExperienceView)(logicalName);
|
|
20
17
|
if (!view) {
|
|
@@ -31,41 +28,24 @@ function WidgetDataGridContainer({ content, }) {
|
|
|
31
28
|
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
32
29
|
// padding: tokens.spacingHorizontalM,
|
|
33
30
|
flexDirection: 'column',
|
|
34
|
-
}, children: (0, jsx_runtime_1.jsx)(DataGridProvider_1.DataGridProvider, { schema: schema, view: view, views: [], onChangeView: () => { }, commands: [], allowViewSelection: false, maxRecords:
|
|
31
|
+
}, children: (0, jsx_runtime_1.jsx)(DataGridProvider_1.DataGridProvider, { schema: schema, view: view, views: [], onChangeView: () => { }, commands: [], allowViewSelection: false, maxRecords: maxRecords, extraFilter: filter, children: (0, jsx_runtime_1.jsx)(FormSubgridContainer, { title: title, commands: commands }) }) }));
|
|
35
32
|
}
|
|
36
|
-
const FormSubgridContainer = ({
|
|
33
|
+
const FormSubgridContainer = ({ title, commands, }) => {
|
|
37
34
|
const baseCommandHandleContext = (0, hooks_1.useBaseCommandHandlerContext)();
|
|
38
35
|
const primaryControl = (0, hooks_2.useGridControlContext)();
|
|
39
|
-
const
|
|
40
|
-
const updateStateValue = (0, react_1.useCallback)(
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
-
(value) => {
|
|
43
|
-
widgetSetValue((state) => ({
|
|
44
|
-
...state,
|
|
45
|
-
data: { ...state.data, ...value },
|
|
46
|
-
}));
|
|
47
|
-
}, [widgetSetValue]);
|
|
48
|
-
const transformedCommands = (0, command_1.useCommands)([content.commands], {
|
|
36
|
+
const transformedCommands = (0, command_1.useCommands)(commands, {
|
|
49
37
|
...baseCommandHandleContext,
|
|
50
|
-
primaryControl
|
|
51
|
-
...primaryControl,
|
|
52
|
-
updateStateValue,
|
|
53
|
-
},
|
|
38
|
+
primaryControl,
|
|
54
39
|
});
|
|
55
40
|
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
56
41
|
display: 'flex',
|
|
57
42
|
flex: 1,
|
|
58
43
|
flexDirection: 'column',
|
|
59
|
-
// gap: 8,
|
|
60
|
-
// backgroundColor: tokens.colorNeutralBackground2,
|
|
61
|
-
// padding: 2,
|
|
62
44
|
overflow: 'hidden',
|
|
63
|
-
}, children: [(0, jsx_runtime_1.jsx)(WidgetTitleBar_1.WidgetTitleBar, { title:
|
|
64
|
-
// gap: 12,
|
|
45
|
+
}, children: [(0, jsx_runtime_1.jsx)(WidgetTitleBar_1.WidgetTitleBar, { title: title, commands: transformedCommands }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
65
46
|
flex: 1,
|
|
66
47
|
display: 'flex',
|
|
67
48
|
flexDirection: 'column',
|
|
68
|
-
// overflow: 'hidden',
|
|
69
49
|
}, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
70
50
|
flex: 1,
|
|
71
51
|
display: 'flex',
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WidgetSection = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const WidgetSection = ({ children }) => {
|
|
7
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
8
|
+
display: 'flex',
|
|
9
|
+
flex: 1,
|
|
10
|
+
background: react_components_1.tokens.colorNeutralBackground1,
|
|
11
|
+
boxShadow: 'none',
|
|
12
|
+
borderRadius: react_components_1.tokens.borderRadiusXLarge,
|
|
13
|
+
flexDirection: 'column',
|
|
14
|
+
}, children: children }));
|
|
15
|
+
};
|
|
16
|
+
exports.WidgetSection = WidgetSection;
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CommandItemState } from '@headless-adminapp/app/command';
|
|
2
|
+
import { Attribute } from '@headless-adminapp/core';
|
|
2
3
|
import { FC } from 'react';
|
|
3
4
|
interface WidgetTableContainerProps {
|
|
4
|
-
|
|
5
|
+
title: string;
|
|
6
|
+
columns: string[];
|
|
7
|
+
attributes: Record<string, Attribute>;
|
|
8
|
+
isPending?: boolean;
|
|
9
|
+
isFetching?: boolean;
|
|
10
|
+
commands?: CommandItemState[][];
|
|
11
|
+
data: any[];
|
|
5
12
|
}
|
|
6
13
|
export declare const WidgetTableContainer: FC<WidgetTableContainerProps>;
|
|
7
14
|
export {};
|
|
@@ -5,21 +5,10 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
6
|
const utils_1 = require("@headless-adminapp/app/utils");
|
|
7
7
|
const BodyLoading_1 = require("../components/BodyLoading");
|
|
8
|
-
const
|
|
8
|
+
const WidgetSection_1 = require("./WidgetSection");
|
|
9
9
|
const WidgetTitleBar_1 = require("./WidgetTitleBar");
|
|
10
|
-
const WidgetTableContainer = ({
|
|
11
|
-
|
|
12
|
-
const info = content.table;
|
|
13
|
-
const data = dataset[0];
|
|
14
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
15
|
-
display: 'flex',
|
|
16
|
-
flex: 1,
|
|
17
|
-
background: react_components_1.tokens.colorNeutralBackground1,
|
|
18
|
-
boxShadow: react_components_1.tokens.shadow2,
|
|
19
|
-
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
20
|
-
flexDirection: 'column',
|
|
21
|
-
overflow: 'hidden',
|
|
22
|
-
}, children: [(0, jsx_runtime_1.jsx)(WidgetTitleBar_1.WidgetTitleBar, { title: widget.title, commands: transformedCommands }), (0, jsx_runtime_1.jsxs)("div", { style: { flex: 1, position: 'relative', overflow: 'auto' }, children: [!isPending && ((0, jsx_runtime_1.jsxs)(react_components_1.Table, { style: {
|
|
10
|
+
const WidgetTableContainer = ({ title, columns, attributes, isPending, isFetching, commands, data, }) => {
|
|
11
|
+
return ((0, jsx_runtime_1.jsxs)(WidgetSection_1.WidgetSection, { children: [(0, jsx_runtime_1.jsx)(WidgetTitleBar_1.WidgetTitleBar, { title: title, commands: commands }), (0, jsx_runtime_1.jsxs)("div", { style: { flex: 1, position: 'relative', overflow: 'auto' }, children: [!isPending && ((0, jsx_runtime_1.jsxs)(react_components_1.Table, { style: {
|
|
23
12
|
borderCollapse: 'collapse',
|
|
24
13
|
width: '100%',
|
|
25
14
|
}, children: [(0, jsx_runtime_1.jsx)(react_components_1.TableHeader, { style: {
|
|
@@ -31,8 +20,8 @@ const WidgetTableContainer = ({ content, }) => {
|
|
|
31
20
|
position: 'sticky',
|
|
32
21
|
top: 0,
|
|
33
22
|
minWidth: 'calc(100% - 16px)',
|
|
34
|
-
}, children:
|
|
35
|
-
const attribute =
|
|
23
|
+
}, children: columns.map((column, index) => {
|
|
24
|
+
const attribute = attributes[column];
|
|
36
25
|
return ((0, jsx_runtime_1.jsx)(react_components_1.TableHeaderCell, { style: {
|
|
37
26
|
minWidth: 32,
|
|
38
27
|
flexShrink: 0,
|
|
@@ -41,8 +30,8 @@ const WidgetTableContainer = ({ content, }) => {
|
|
|
41
30
|
background: react_components_1.tokens.colorNeutralBackground3,
|
|
42
31
|
borderBottom: `${react_components_1.tokens.strokeWidthThin} solid ${react_components_1.tokens.colorNeutralStroke3}`,
|
|
43
32
|
}, children: attribute.label }, column + String(index)));
|
|
44
|
-
}) }) }), (0, jsx_runtime_1.jsx)(react_components_1.TableBody, { children: data.map((row, index) => ((0, jsx_runtime_1.jsx)(react_components_1.TableRow, { children:
|
|
45
|
-
const attribute =
|
|
33
|
+
}) }) }), (0, jsx_runtime_1.jsx)(react_components_1.TableBody, { children: data.map((row, index) => ((0, jsx_runtime_1.jsx)(react_components_1.TableRow, { children: columns.map((column) => {
|
|
34
|
+
const attribute = attributes[column];
|
|
46
35
|
const value = row[column];
|
|
47
36
|
const formattedValue = (0, utils_1.getAttributeFormattedValue)(attribute, value) ?? '';
|
|
48
37
|
switch (attribute?.type) {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { TileWidgetExperience } from '@headless-adminapp/core/experience/insights';
|
|
2
1
|
import { FC } from 'react';
|
|
3
2
|
interface WidgetTileContainerProps {
|
|
4
|
-
content: TileWidgetExperience;
|
|
5
3
|
}
|
|
6
4
|
export declare const WidgetTileContainer: FC<WidgetTileContainerProps>;
|
|
7
5
|
export {};
|
|
@@ -3,22 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.WidgetTileContainer = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const WidgetTileContainer = ({ content, }) => {
|
|
9
|
-
const { transformedCommands, widget } = (0, useWidgetDetail_1.useWidgetDetail)(content);
|
|
10
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
6
|
+
const WidgetTileContainer = ({}) => {
|
|
7
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
11
8
|
display: 'flex',
|
|
12
9
|
flex: 1,
|
|
13
10
|
background: react_components_1.tokens.colorNeutralBackground1,
|
|
14
11
|
boxShadow: react_components_1.tokens.shadow2,
|
|
15
12
|
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
16
13
|
flexDirection: 'column',
|
|
17
|
-
}, children:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flex: 1 }, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
15
|
+
flex: 1,
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
display: 'flex',
|
|
18
|
+
paddingInline: 16,
|
|
19
|
+
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Title2, { children: "Not supported yet" }) }) }) }));
|
|
23
20
|
};
|
|
24
21
|
exports.WidgetTileContainer = WidgetTileContainer;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CommandItemState } from '@headless-adminapp/app/command';
|
|
2
2
|
interface WidgetTitleBarProps {
|
|
3
3
|
title: string;
|
|
4
|
-
commands
|
|
4
|
+
commands?: CommandItemState[][];
|
|
5
5
|
}
|
|
6
6
|
export declare function WidgetTitleBar({ title, commands }: WidgetTitleBarProps): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -17,5 +17,5 @@ function WidgetTitleBar({ title, commands }) {
|
|
|
17
17
|
paddingBlock: 8,
|
|
18
18
|
height: 40,
|
|
19
19
|
alignItems: 'center',
|
|
20
|
-
}, children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center', width: '100%' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Body1Strong, { children: title }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1 } }), commands
|
|
20
|
+
}, children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center', width: '100%' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Body1Strong, { children: title }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1 } }), !!commands && commands[0]?.length > 0 && ((0, jsx_runtime_1.jsx)("div", { style: { marginRight: -20 }, children: (0, jsx_runtime_1.jsx)(CommandBar_1.default.Wrapper, { children: commands[0].map((command, index) => (0, OverflowCommandBar_1.renderCommandItem)(index, command, language)) }) }))] }) }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(react_components_1.Divider, { style: { opacity: 0.2 } }) })] }));
|
|
21
21
|
}
|
package/Insights/Widgets.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InsightConfig } from '@headless-adminapp/core/experience/insights';
|
|
2
2
|
export declare function Widgets({ widgets, }: Readonly<{
|
|
3
|
-
widgets:
|
|
3
|
+
widgets: InsightConfig['widgets'];
|
|
4
4
|
}>): import("react/jsx-runtime").JSX.Element;
|
package/Insights/Widgets.js
CHANGED
|
@@ -3,55 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Widgets = Widgets;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const hooks_1 = require("@headless-adminapp/app/hooks");
|
|
6
|
-
const insights_1 = require("@headless-adminapp/app/insights");
|
|
7
|
-
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
8
|
-
const widget_1 = require("@headless-adminapp/app/widget");
|
|
9
|
-
const react_1 = require("react");
|
|
10
6
|
const Grid_1 = require("./Grid");
|
|
11
|
-
const WidgetChartContainer_1 = require("./WidgetChartContainer");
|
|
12
|
-
const WidgetDataGridContainer_1 = require("./WidgetDataGridContainer");
|
|
13
|
-
const WidgetTableContainer_1 = require("./WidgetTableContainer");
|
|
14
|
-
const WidgetTileContainer_1 = require("./WidgetTileContainer");
|
|
15
|
-
const WidgetProvider = ({ children, widget, }) => {
|
|
16
|
-
const contextValue = (0, mutable_1.useCreateContextStore)({
|
|
17
|
-
widget,
|
|
18
|
-
data: widget.defaultData,
|
|
19
|
-
});
|
|
20
|
-
(0, react_1.useEffect)(() => {
|
|
21
|
-
contextValue.setValue({
|
|
22
|
-
widget,
|
|
23
|
-
data: widget.defaultData,
|
|
24
|
-
});
|
|
25
|
-
}, [contextValue, widget]);
|
|
26
|
-
return ((0, jsx_runtime_1.jsx)(widget_1.WidgetContext.Provider, { value: contextValue, children: children }));
|
|
27
|
-
};
|
|
28
7
|
function Widgets({ widgets, }) {
|
|
29
|
-
|
|
30
|
-
return ((0, jsx_runtime_1.jsx)(Grid_1.WidgetGrid, { children: widgets.map((widget, index) => {
|
|
31
|
-
return ((0, jsx_runtime_1.jsx)(Grid_1.WidgetGridItem, { row: widget.rows, column: isMobile ? 12 : widget.columns, children: (0, jsx_runtime_1.jsx)(WidgetProvider, { widget: widget, children: (0, jsx_runtime_1.jsx)(WidgetItem, {}) }) }, widget.title + String(index)));
|
|
32
|
-
}) }));
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(Grid_1.WidgetGrid, { children: (0, jsx_runtime_1.jsx)(WidgetRenderer, { items: widgets }) }));
|
|
33
9
|
}
|
|
34
|
-
function
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return (0, jsx_runtime_1.jsx)(WidgetDataGridContainer_1.WidgetDataGridContainer, { content: content });
|
|
49
|
-
}
|
|
50
|
-
if (content.type === 'table') {
|
|
51
|
-
return (0, jsx_runtime_1.jsx)(WidgetTableContainer_1.WidgetTableContainer, { content: content });
|
|
52
|
-
}
|
|
53
|
-
if (content.type === 'custom') {
|
|
54
|
-
return (0, jsx_runtime_1.jsx)(content.Component, {});
|
|
55
|
-
}
|
|
56
|
-
return null;
|
|
10
|
+
function WidgetRenderer({ items }) {
|
|
11
|
+
const isMobile = (0, hooks_1.useIsMobile)();
|
|
12
|
+
return items.map((widget, index) => {
|
|
13
|
+
if (widget.type === 'space') {
|
|
14
|
+
if (isMobile) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return (0, jsx_runtime_1.jsx)(Grid_1.WidgetGridItem, { column: widget.columns }, String(index));
|
|
18
|
+
}
|
|
19
|
+
if (widget.type === 'group') {
|
|
20
|
+
return ((0, jsx_runtime_1.jsx)(Grid_1.WidgetGridGroup, { column: isMobile ? 12 : widget.columns, row: widget.rows, children: (0, jsx_runtime_1.jsx)(WidgetRenderer, { items: widget.items }) }, String(index)));
|
|
21
|
+
}
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(Grid_1.WidgetGridItem, { row: widget.rows, column: isMobile ? 12 : widget.columns, children: (0, jsx_runtime_1.jsx)(widget.Component, { ...widget.props }) }, String(index)));
|
|
23
|
+
});
|
|
57
24
|
}
|
|
@@ -3,18 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AreaChart = AreaChart;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const react_1 = require("react");
|
|
6
7
|
const recharts_1 = require("recharts");
|
|
7
8
|
const CustomTooltipContent_1 = require("./CustomTooltipContent");
|
|
8
9
|
const formatters_1 = require("./formatters");
|
|
9
10
|
const renderers_1 = require("./renderers");
|
|
10
11
|
function AreaChart({ dataset, chartInfo, }) {
|
|
12
|
+
const id = (0, react_1.useId)();
|
|
11
13
|
const xAxis = chartInfo.xAxis;
|
|
12
14
|
const yAxis = chartInfo.yAxis;
|
|
13
15
|
const areas = chartInfo.areas;
|
|
14
16
|
const xAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(xAxis.tick);
|
|
15
17
|
const yAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(yAxis.tick);
|
|
16
|
-
return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.AreaChart, { data: dataset[0], children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderXAxis)(xAxis), (0, renderers_1.renderYAxis)(yAxis), (0, renderers_1.renderAreas)(areas,
|
|
18
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.AreaChart, { data: dataset[0], children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderXAxis)(xAxis), (0, renderers_1.renderYAxis)(yAxis), (0, renderers_1.renderAreas)(areas, id), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
|
|
17
19
|
stroke: react_components_1.tokens.colorNeutralBackground6,
|
|
18
20
|
opacity: 0.5,
|
|
19
21
|
}, content: ({ active, payload, label }) => ((0, jsx_runtime_1.jsx)(CustomTooltipContent_1.CustomTooltipContent, { xAxisFormatter: xAxisFullFormatter, yAxisFormatter: yAxisFullFormatter, active: active, payload: payload, label: label })) })] }) }));
|
|
20
22
|
}
|
|
23
|
+
exports.default = AreaChart;
|
|
@@ -14,7 +14,8 @@ function BarChart({ dataset, chartInfo, }) {
|
|
|
14
14
|
const xAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(xAxis.tick);
|
|
15
15
|
const yAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(yAxis.tick);
|
|
16
16
|
return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.BarChart, { data: dataset[0], stackOffset: chartInfo.stackOffset, children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)(yAxis), (0, renderers_1.renderXAxis)(xAxis), (0, renderers_1.renderBars)(bars, dataset), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
|
|
17
|
-
|
|
18
|
-
opacity: 0.
|
|
17
|
+
fill: react_components_1.tokens.colorNeutralBackground6,
|
|
18
|
+
opacity: 0.2,
|
|
19
19
|
}, content: ({ active, payload, label }) => ((0, jsx_runtime_1.jsx)(CustomTooltipContent_1.CustomTooltipContent, { xAxisFormatter: xAxisFullFormatter, yAxisFormatter: yAxisFullFormatter, active: active, payload: payload, label: label })) })] }) }));
|
|
20
20
|
}
|
|
21
|
+
exports.default = BarChart;
|
|
@@ -3,17 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ComposedChart = ComposedChart;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const react_1 = require("react");
|
|
6
7
|
const recharts_1 = require("recharts");
|
|
7
8
|
const CustomTooltipContent_1 = require("./CustomTooltipContent");
|
|
8
9
|
const formatters_1 = require("./formatters");
|
|
9
10
|
const renderers_1 = require("./renderers");
|
|
10
11
|
function ComposedChart({ dataset, chartInfo, }) {
|
|
12
|
+
const id = (0, react_1.useId)();
|
|
11
13
|
const xAxis = chartInfo.xAxis;
|
|
12
14
|
const yAxis = chartInfo.yAxis;
|
|
13
15
|
const xAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(xAxis.tick);
|
|
14
16
|
const yAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(yAxis.tick);
|
|
15
|
-
return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.ComposedChart, { data: dataset[0], children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)(yAxis), (0, renderers_1.renderXAxis)(xAxis, !!chartInfo.bars?.length), (0, renderers_1.renderLines)(chartInfo.lines ?? []
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.ComposedChart, { data: dataset[0], children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)(yAxis), (0, renderers_1.renderXAxis)(xAxis, !!chartInfo.bars?.length), (0, renderers_1.renderLines)(chartInfo.lines ?? []), (0, renderers_1.renderAreas)(chartInfo.areas ?? [], id), (0, renderers_1.renderBars)(chartInfo.bars ?? [], dataset), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
|
|
16
18
|
stroke: react_components_1.tokens.colorNeutralBackground6,
|
|
17
19
|
opacity: 0.5,
|
|
18
20
|
}, content: ({ active, payload, label }) => ((0, jsx_runtime_1.jsx)(CustomTooltipContent_1.CustomTooltipContent, { xAxisFormatter: xAxisFullFormatter, yAxisFormatter: yAxisFullFormatter, active: active, payload: payload, label: label })) })] }) }));
|
|
19
21
|
}
|
|
22
|
+
exports.default = ComposedChart;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FunnelChartInfo } from '@headless-adminapp/core/experience/insights';
|
|
2
|
+
export declare function FunnelChart({ dataset, chartInfo, }: Readonly<{
|
|
3
|
+
dataset: any[];
|
|
4
|
+
chartInfo: FunnelChartInfo;
|
|
5
|
+
}>): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export default FunnelChart;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FunnelChart = FunnelChart;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const recharts_1 = require("recharts");
|
|
8
|
+
const constants_1 = require("./constants");
|
|
9
|
+
const formatters_1 = require("./formatters");
|
|
10
|
+
const FunnelCustomTooltipContent_1 = require("./FunnelCustomTooltipContent");
|
|
11
|
+
function FunnelChart({ dataset, chartInfo, }) {
|
|
12
|
+
const item = chartInfo;
|
|
13
|
+
const nameFormatter = (0, formatters_1.createLongAxisFormatter)({
|
|
14
|
+
type: 'category',
|
|
15
|
+
options: item.nameTick?.options,
|
|
16
|
+
});
|
|
17
|
+
const nameFormatterRef = (0, react_1.useRef)(nameFormatter);
|
|
18
|
+
nameFormatterRef.current = nameFormatter;
|
|
19
|
+
const data = dataset[0];
|
|
20
|
+
const valueFormatter = (0, formatters_1.createLongAxisFormatter)(item.dataTick);
|
|
21
|
+
const transformedData = (0, react_1.useMemo)(() => {
|
|
22
|
+
if (!data?.length) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
let total = data[0][item.dataKey] ?? 0;
|
|
26
|
+
return data.map((dataItem, index) => {
|
|
27
|
+
const perc = total ? dataItem[item.dataKey] / total : 0;
|
|
28
|
+
const label = nameFormatterRef.current(dataItem[item.nameKey]);
|
|
29
|
+
const labelWithPerc = `${label} (${(perc * 100).toFixed(0)}%)`;
|
|
30
|
+
return {
|
|
31
|
+
value: dataItem[item.dataKey],
|
|
32
|
+
label: label,
|
|
33
|
+
labelWithPerc,
|
|
34
|
+
name: dataItem[item.nameKey],
|
|
35
|
+
fill: item.colorKey && dataItem[item.colorKey]
|
|
36
|
+
? dataItem[item.colorKey]
|
|
37
|
+
: (item.colors ?? constants_1.defaultColors)[index % (item.colors ?? constants_1.defaultColors).length],
|
|
38
|
+
perc,
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
}, [data, item]);
|
|
42
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.FunnelChart, { children: [(0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { content: ({ active, payload }) => {
|
|
43
|
+
return ((0, jsx_runtime_1.jsx)(FunnelCustomTooltipContent_1.FunnelCustomTooltipContent, { valueFormatter: valueFormatter, active: active, payload: payload }));
|
|
44
|
+
} }), (0, jsx_runtime_1.jsx)(recharts_1.Funnel, { dataKey: "value", data: transformedData, isAnimationActive: false, lastShapeType: "rectangle", stroke: "none", children: (0, jsx_runtime_1.jsx)(recharts_1.LabelList, { position: "inside", fill: "#000", stroke: "none", dataKey: "labelWithPerc", style: {
|
|
45
|
+
fontSize: react_components_1.tokens.fontSizeBase100,
|
|
46
|
+
fontFamily: react_components_1.tokens.fontFamilyBase,
|
|
47
|
+
fill: react_components_1.tokens.colorNeutralForeground1,
|
|
48
|
+
}, content: ({ content: _, ...props }) => (0, jsx_runtime_1.jsx)(recharts_1.Label, { ...props }) }) })] }) }));
|
|
49
|
+
}
|
|
50
|
+
exports.default = FunnelChart;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FunnelCustomTooltipContent = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const formatters_1 = require("./formatters");
|
|
7
|
+
const FunnelCustomTooltipContent = ({ active, payload, valueFormatter, }) => {
|
|
8
|
+
if (!active || !payload?.length) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const [firstPayload] = payload;
|
|
12
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
13
|
+
display: 'flex',
|
|
14
|
+
flexDirection: 'column',
|
|
15
|
+
boxShadow: react_components_1.tokens.shadow16,
|
|
16
|
+
backgroundColor: react_components_1.tokens.colorNeutralBackground1,
|
|
17
|
+
padding: 8,
|
|
18
|
+
borderRadius: 4,
|
|
19
|
+
gap: 4,
|
|
20
|
+
}, children: [(0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: firstPayload.label }), (0, jsx_runtime_1.jsx)(react_components_1.Divider, { style: { opacity: 0.2 } }), (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'column', gap: 4 }, children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
21
|
+
width: 8,
|
|
22
|
+
height: 8,
|
|
23
|
+
background: firstPayload.payload.fill,
|
|
24
|
+
borderRadius: 4,
|
|
25
|
+
} }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4, marginLeft: 8 }, children: valueFormatter(firstPayload.value) }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1, minWidth: 50 } }), (0, jsx_runtime_1.jsxs)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: [(0, formatters_1.formatNumber)(firstPayload.payload.perc * 100, { maxDigit: 2 }), "%"] })] }) })] }));
|
|
26
|
+
};
|
|
27
|
+
exports.FunnelCustomTooltipContent = FunnelCustomTooltipContent;
|