@headless-adminapp/fluent 1.4.0 → 1.4.3
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/Insights/charts/ComposedChart.js +20 -2
- package/Insights/charts/CustomTooltipContent.d.ts +3 -1
- package/Insights/charts/CustomTooltipContent.js +4 -2
- package/Insights/charts/renderers.d.ts +1 -1
- package/Insights/charts/renderers.js +5 -5
- package/PageEntityForm/PageCustomEntityForm.js +9 -7
- package/package.json +2 -2
|
@@ -12,11 +12,29 @@ function ComposedChart({ dataset, chartInfo, }) {
|
|
|
12
12
|
const id = (0, react_1.useId)();
|
|
13
13
|
const xAxis = chartInfo.xAxis;
|
|
14
14
|
const yAxis = chartInfo.yAxis;
|
|
15
|
+
const rightYAxis = chartInfo.rightYAxis;
|
|
15
16
|
const xAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(xAxis.tick);
|
|
16
17
|
const yAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(yAxis.tick);
|
|
17
|
-
|
|
18
|
+
const rightYAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(rightYAxis?.tick ?? yAxis.tick);
|
|
19
|
+
const yAxisIdMapping = (0, react_1.useMemo)(() => {
|
|
20
|
+
const mapping = {};
|
|
21
|
+
chartInfo.bars?.forEach((bar) => {
|
|
22
|
+
mapping[bar.dataKey] = bar.yAxisId ?? 'left';
|
|
23
|
+
});
|
|
24
|
+
chartInfo.areas?.forEach((area) => {
|
|
25
|
+
mapping[area.dataKey] = area.yAxisId ?? 'left';
|
|
26
|
+
});
|
|
27
|
+
chartInfo.lines?.forEach((line) => {
|
|
28
|
+
mapping[line.dataKey] = line.yAxisId ?? 'left';
|
|
29
|
+
});
|
|
30
|
+
return mapping;
|
|
31
|
+
}, [chartInfo]);
|
|
32
|
+
const yAxisIdResolver = (0, react_1.useCallback)((dataKey) => {
|
|
33
|
+
return yAxisIdMapping[dataKey] ?? 'left';
|
|
34
|
+
}, [yAxisIdMapping]);
|
|
35
|
+
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), !!rightYAxis && (0, renderers_1.renderYAxis)(rightYAxis, 'right'), (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: {
|
|
18
36
|
stroke: react_components_1.tokens.colorNeutralBackground6,
|
|
19
37
|
opacity: 0.5,
|
|
20
|
-
}, content: ({ active, payload, label }) => ((0, jsx_runtime_1.jsx)(CustomTooltipContent_1.CustomTooltipContent, { xAxisFormatter: xAxisFullFormatter, yAxisFormatter: yAxisFullFormatter, active: active, payload: payload, label: label })) })] }) }));
|
|
38
|
+
}, content: ({ active, payload, label }) => ((0, jsx_runtime_1.jsx)(CustomTooltipContent_1.CustomTooltipContent, { xAxisFormatter: xAxisFullFormatter, yAxisFormatter: yAxisFullFormatter, yAxisIdResolver: yAxisIdResolver, rightYAxisFormatter: rightYAxisFullFormatter, active: active, payload: payload, label: label })) })] }) }));
|
|
21
39
|
}
|
|
22
40
|
exports.default = ComposedChart;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export declare const CustomTooltipContent: ({ active, payload, label, xAxisFormatter, yAxisFormatter, }: {
|
|
1
|
+
export declare const CustomTooltipContent: ({ active, payload, label, xAxisFormatter, yAxisFormatter, rightYAxisFormatter, yAxisIdResolver, }: {
|
|
2
2
|
active?: boolean;
|
|
3
3
|
payload?: any[];
|
|
4
4
|
label: string;
|
|
5
5
|
xAxisFormatter: (value: unknown) => string;
|
|
6
6
|
yAxisFormatter: (value: unknown) => string;
|
|
7
|
+
rightYAxisFormatter?: (value: unknown) => string;
|
|
8
|
+
yAxisIdResolver?: (dataKey: string) => "left" | "right";
|
|
7
9
|
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CustomTooltipContent = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
-
const CustomTooltipContent = ({ active, payload, label, xAxisFormatter, yAxisFormatter, }) => {
|
|
6
|
+
const CustomTooltipContent = ({ active, payload, label, xAxisFormatter, yAxisFormatter, rightYAxisFormatter, yAxisIdResolver, }) => {
|
|
7
7
|
if (!active || !payload?.length) {
|
|
8
8
|
return null;
|
|
9
9
|
}
|
|
@@ -20,6 +20,8 @@ const CustomTooltipContent = ({ active, payload, label, xAxisFormatter, yAxisFor
|
|
|
20
20
|
height: 8,
|
|
21
21
|
background: item.color,
|
|
22
22
|
borderRadius: 4,
|
|
23
|
-
} }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4, marginLeft: 8 }, children: item.name }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1, minWidth: 50 } }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children:
|
|
23
|
+
} }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4, marginLeft: 8 }, children: item.name }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1, minWidth: 50 } }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: yAxisIdResolver?.(item.dataKey) === 'right'
|
|
24
|
+
? (rightYAxisFormatter ?? yAxisFormatter)(item.value)
|
|
25
|
+
: yAxisFormatter(item.value) })] }, item.name + String(index)))) })] }));
|
|
24
26
|
};
|
|
25
27
|
exports.CustomTooltipContent = CustomTooltipContent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AreaInfo, BarInfo, LineInfo, XAxis, YAxis } from '@headless-adminapp/core/experience/insights';
|
|
2
2
|
import { XAxisProps } from 'recharts';
|
|
3
3
|
export declare function renderXAxis(axis: XAxis, forceCategory?: boolean, padding?: XAxisProps['padding']): import("react/jsx-runtime").JSX.Element;
|
|
4
|
-
export declare function renderYAxis(axis: YAxis): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare function renderYAxis(axis: YAxis, axisId?: 'left' | 'right'): import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
export declare function renderGrid(): import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export declare function renderLine(line: LineInfo): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export declare function renderLines(lines: LineInfo[]): import("react/jsx-runtime").JSX.Element[];
|
|
@@ -25,9 +25,9 @@ function renderXAxis(axis, forceCategory = false, padding = 'gap') {
|
|
|
25
25
|
opacity: 0.5,
|
|
26
26
|
}, scale: !forceCategory && axis.tick.type === 'time' ? 'time' : 'auto', type: forceCategory || axis.tick.type === 'category' ? 'category' : 'number', domain: axis.domain, height: 16 }));
|
|
27
27
|
}
|
|
28
|
-
function renderYAxis(axis) {
|
|
28
|
+
function renderYAxis(axis, axisId = 'left') {
|
|
29
29
|
const yAxisFormatter = (0, formatters_1.createAxisFormatter)(axis.tick);
|
|
30
|
-
return ((0, jsx_runtime_1.jsx)(recharts_1.YAxis, { yAxisId:
|
|
30
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.YAxis, { yAxisId: axisId, dataKey: axis.dataKey, orientation: axisId === 'right' ? 'right' : 'left', tickFormatter: yAxisFormatter, name: axis.name, tickLine: false, fontSize: react_components_1.tokens.fontSizeBase100, axisLine: false, tickMargin: 0, minTickGap: 0, accentHeight: 0, width: 40, scale: "auto", type: "number", domain: axis.domain, tick: {
|
|
31
31
|
fill: react_components_1.tokens.colorNeutralForeground1,
|
|
32
32
|
opacity: 0.5,
|
|
33
33
|
} }));
|
|
@@ -37,7 +37,7 @@ function renderGrid() {
|
|
|
37
37
|
}
|
|
38
38
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
39
|
function renderLine(line) {
|
|
40
|
-
return ((0, jsx_runtime_1.jsx)(recharts_1.Line, { yAxisId: 'left', type: line.curveType, dataKey: line.dataKey, name: line.dataLabel, stroke: line.color, strokeWidth: 2, dot: false, activeDot: {
|
|
40
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.Line, { yAxisId: line.yAxisId ?? 'left', type: line.curveType, dataKey: line.dataKey, name: line.dataLabel, stroke: line.color, strokeWidth: 2, dot: false, activeDot: {
|
|
41
41
|
stroke: line.color,
|
|
42
42
|
} }, line.dataKey));
|
|
43
43
|
}
|
|
@@ -47,7 +47,7 @@ function renderLines(lines) {
|
|
|
47
47
|
}
|
|
48
48
|
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
49
49
|
function renderArea(area, chartId) {
|
|
50
|
-
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsxs)("linearGradient", { id: chartId + ':' + area.dataKey, x1: "0", y1: "0", x2: "0", y2: "1", children: [(0, jsx_runtime_1.jsx)("stop", { offset: "5%", stopColor: area.color, stopOpacity: 0.8 }), (0, jsx_runtime_1.jsx)("stop", { offset: "95%", stopColor: area.color, stopOpacity: 0 })] }) }), (0, jsx_runtime_1.jsx)(recharts_1.Area, { yAxisId: 'left', type: area.curveType, dataKey: area.dataKey, name: area.dataLabel, stroke: area.color,
|
|
50
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsxs)("linearGradient", { id: chartId + ':' + area.dataKey, x1: "0", y1: "0", x2: "0", y2: "1", children: [(0, jsx_runtime_1.jsx)("stop", { offset: "5%", stopColor: area.color, stopOpacity: 0.8 }), (0, jsx_runtime_1.jsx)("stop", { offset: "95%", stopColor: area.color, stopOpacity: 0 })] }) }), (0, jsx_runtime_1.jsx)(recharts_1.Area, { yAxisId: area.yAxisId ?? 'left', type: area.curveType, dataKey: area.dataKey, name: area.dataLabel, stroke: area.color,
|
|
51
51
|
// fill={area.color}
|
|
52
52
|
fill: `url(#${chartId}:${area.dataKey})`, strokeWidth: 2, dot: false, activeDot: {
|
|
53
53
|
stroke: area.color,
|
|
@@ -59,7 +59,7 @@ function renderAreas(areas, chartId) {
|
|
|
59
59
|
}
|
|
60
60
|
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
61
61
|
function renderBar(bar, dataset) {
|
|
62
|
-
return ((0, jsx_runtime_1.jsx)(recharts_1.Bar, { yAxisId: 'left', type: bar.curveType, dataKey: bar.dataKey, name: bar.dataLabel, stroke: bar.color, fill: bar.color, strokeWidth: 1, stackId: bar.stackId, radius: bar.radius, barSize: bar.barSize }, bar.dataKey));
|
|
62
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.Bar, { yAxisId: bar.yAxisId ?? 'left', type: bar.curveType, dataKey: bar.dataKey, name: bar.dataLabel, stroke: bar.color, fill: bar.color, strokeWidth: 1, stackId: bar.stackId, radius: bar.radius, barSize: bar.barSize }, bar.dataKey));
|
|
63
63
|
}
|
|
64
64
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
65
|
function renderBars(bars, dataset) {
|
|
@@ -3,15 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PageCustomEntityForm = PageCustomEntityForm;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const historystate_1 = require("@headless-adminapp/app/historystate");
|
|
6
7
|
const PageEntityFormProvider_1 = require("@headless-adminapp/app/providers/PageEntityFormProvider");
|
|
8
|
+
const recordset_1 = require("@headless-adminapp/app/recordset");
|
|
7
9
|
const PageEntityFormDesktopContainer_1 = require("./PageEntityFormDesktopContainer");
|
|
8
10
|
const RecordSetNavigatorContainer_1 = require("./RecordSetNavigatorContainer");
|
|
9
11
|
function PageCustomEntityForm({ recordId, commands, form, schema, retriveRecordFn, saveRecordFn, }) {
|
|
10
|
-
return ((0, jsx_runtime_1.jsx)(PageEntityFormProvider_1.PageEntityFormProvider, { schema: schema, form: form, recordId: recordId, commands: commands, retriveRecordFn: retriveRecordFn, saveRecordFn: saveRecordFn, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)(historystate_1.HistoryStateKeyProvider, { historyKey: 'page-entity-form.' + schema.logicalName, children: (0, jsx_runtime_1.jsx)(recordset_1.RecordSetProvider, { children: (0, jsx_runtime_1.jsx)(PageEntityFormProvider_1.PageEntityFormProvider, { schema: schema, form: form, recordId: recordId, commands: commands, retriveRecordFn: retriveRecordFn, saveRecordFn: saveRecordFn, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
13
|
+
display: 'flex',
|
|
14
|
+
flex: 1,
|
|
15
|
+
flexDirection: 'row',
|
|
16
|
+
backgroundColor: react_components_1.tokens.colorNeutralBackground2,
|
|
17
|
+
overflow: 'hidden',
|
|
18
|
+
}, children: [(0, jsx_runtime_1.jsx)(RecordSetNavigatorContainer_1.RecordSetNavigatorContainer, {}), (0, jsx_runtime_1.jsx)(PageEntityFormDesktopContainer_1.PageEntityFormDesktopContainer, {})] }) }) }) }));
|
|
17
19
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@headless-adminapp/fluent",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"uuid": "11.0.3",
|
|
53
53
|
"yup": "^1.4.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "5c5739c442d4690430997c7f375fed5966cde046"
|
|
56
56
|
}
|