@evergis/react 3.1.40 → 3.1.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Dashboard/components/ChartLegend/index.d.ts +1 -0
- package/dist/components/Dashboard/components/ChartLegend/styled.d.ts +1 -0
- package/dist/components/Dashboard/containers/ChartContainer/types.d.ts +2 -0
- package/dist/components/Dashboard/styled.d.ts +1 -0
- package/dist/components/Dashboard/types.d.ts +3 -0
- package/dist/index.js +50 -19
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +50 -20
- package/dist/react.esm.js.map +1 -1
- package/package.json +3 -3
|
@@ -10,5 +10,6 @@ export declare const ChartLegendColor: import('styled-components').StyledCompone
|
|
|
10
10
|
color: string;
|
|
11
11
|
}, never>;
|
|
12
12
|
export declare const ChartLegendName: import('styled-components').StyledComponent<"div", any, {
|
|
13
|
+
$fontSize?: string | number;
|
|
13
14
|
$fontColor?: string;
|
|
14
15
|
}, never>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const ElementValueWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
2
|
+
export declare const InnerContainerWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
2
3
|
export declare const ContainerWrapper: any;
|
|
3
4
|
export declare const DashboardChip: import('styled-components').StyledComponent<any, any, any, any>;
|
|
4
5
|
export declare const DashboardPlaceholderWrap: import('styled-components').StyledComponent<"div", any, import('@evergis/uilib-gl').FlexProps, never>;
|
|
@@ -19,6 +19,7 @@ export interface ConfigRelatedDataSource {
|
|
|
19
19
|
dataSourceName: string;
|
|
20
20
|
attributeName: string;
|
|
21
21
|
attributeTitle: string;
|
|
22
|
+
attributeUnits?: string;
|
|
22
23
|
attributeColor?: string;
|
|
23
24
|
alias?: string;
|
|
24
25
|
chartAxis?: string;
|
|
@@ -46,8 +47,10 @@ export interface ConfigOptions {
|
|
|
46
47
|
label?: string;
|
|
47
48
|
withPadding?: boolean;
|
|
48
49
|
withDivider?: boolean;
|
|
50
|
+
dotSnapping?: boolean;
|
|
49
51
|
tagView?: boolean;
|
|
50
52
|
simple?: boolean;
|
|
53
|
+
downloadById?: string;
|
|
51
54
|
separator?: string;
|
|
52
55
|
lineBreak?: string;
|
|
53
56
|
image?: string;
|
package/dist/index.js
CHANGED
|
@@ -4500,7 +4500,7 @@ const ChartLegendColor = styled.div `
|
|
|
4500
4500
|
`;
|
|
4501
4501
|
const ChartLegendName = styled.div `
|
|
4502
4502
|
flex: 1;
|
|
4503
|
-
font-size: 0.625rem;
|
|
4503
|
+
font-size: ${({ $fontSize }) => $fontSize || "0.625rem"};
|
|
4504
4504
|
color: ${({ theme: { palette }, $fontColor }) => $fontColor || palette.textPrimary};
|
|
4505
4505
|
`;
|
|
4506
4506
|
|
|
@@ -5103,6 +5103,9 @@ const LayerListContainer = styled(uilibGl.Flex) `
|
|
|
5103
5103
|
const ElementValueWrapper = styled.div `
|
|
5104
5104
|
transition: background-color ${uilibGl.transition.toggle};
|
|
5105
5105
|
`;
|
|
5106
|
+
const InnerContainerWrapper$1 = styled.div `
|
|
5107
|
+
width: 100%;
|
|
5108
|
+
`;
|
|
5106
5109
|
const ContainerWrapper = styled(uilibGl.Flex) `
|
|
5107
5110
|
position: relative;
|
|
5108
5111
|
min-height: 1rem;
|
|
@@ -6197,6 +6200,17 @@ const ContainerIconTitle = styled(uilibGl.Flex) `
|
|
|
6197
6200
|
${uilibGl.LegendToggler} {
|
|
6198
6201
|
margin-left: 0.25rem;
|
|
6199
6202
|
}
|
|
6203
|
+
|
|
6204
|
+
span[kind="download"] {
|
|
6205
|
+
opacity: 0;
|
|
6206
|
+
transition: opacity ${uilibGl.transition.hover};
|
|
6207
|
+
}
|
|
6208
|
+
|
|
6209
|
+
:hover {
|
|
6210
|
+
span[kind="download"] {
|
|
6211
|
+
opacity: 1;
|
|
6212
|
+
}
|
|
6213
|
+
}
|
|
6200
6214
|
`;
|
|
6201
6215
|
const ContainerTitle = styled(uilibGl.Flex) `
|
|
6202
6216
|
align-items: center;
|
|
@@ -6232,8 +6246,9 @@ const TitleContainer = React.memo(({ containerId, templateName, layerNames, font
|
|
|
6232
6246
|
const [layersVisibility, toggleVisibility] = useToggle(true);
|
|
6233
6247
|
const { palette } = styled.useTheme();
|
|
6234
6248
|
const { style, options } = elementConfig || {};
|
|
6235
|
-
const { simple } = options || {};
|
|
6249
|
+
const { simple, downloadById } = options || {};
|
|
6236
6250
|
const isLayers = templateName === exports.ContainerTemplate.Layers;
|
|
6251
|
+
const { onExport } = useExportPdf(downloadById);
|
|
6237
6252
|
const onClick = React.useCallback(() => {
|
|
6238
6253
|
if (!expandable)
|
|
6239
6254
|
return;
|
|
@@ -6248,7 +6263,7 @@ const TitleContainer = React.memo(({ containerId, templateName, layerNames, font
|
|
|
6248
6263
|
const renderVisibility = React.useMemo(() => isLayers && (jsxRuntime.jsx(uilibGl.FlexSpan, { mr: "-1rem", children: jsxRuntime.jsx(uilibGl.IconToggle, { kind: layersVisibility ? "password_show" : "password_hide", className: "feature-visible", isSelected: layersVisibility, onClick: onToggleVisibility }) })), [isLayers, layersVisibility, onToggleVisibility]);
|
|
6249
6264
|
const renderToggler = React.useMemo(() => !!containerId &&
|
|
6250
6265
|
expandable && (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(uilibGl.LegendToggler, { color: palette.icon, toggled: expandedContainers?.[containerId] !== undefined ? expandedContainers[containerId] : expanded, onClick: onClick }) })), [containerId, expandable, expanded, expandedContainers, onClick, palette.icon]);
|
|
6251
|
-
return (jsxRuntime.jsx(Container, { isTitle: isVisible, style: style, children: jsxRuntime.jsxs(ContainerTitle, { simple: simple, children: [jsxRuntime.jsxs(ContainerIconTitle, { fontColor: fontColor, children: [renderElement({ id: "titleIcon", wrap: false }), renderElement({ id: "title" }), isLayers && renderToggler] }), !isLayers && renderToggler, renderVisibility] }) }));
|
|
6266
|
+
return (jsxRuntime.jsx(Container, { isTitle: isVisible, style: style, children: jsxRuntime.jsxs(ContainerTitle, { simple: simple, children: [jsxRuntime.jsxs(ContainerIconTitle, { fontColor: fontColor, children: [renderElement({ id: "titleIcon", wrap: false }), renderElement({ id: "title" }), !!downloadById && (jsxRuntime.jsx(uilibGl.IconButton, { kind: "download", onClick: onExport })), isLayers && renderToggler] }), !isLayers && renderToggler, renderVisibility] }) }));
|
|
6252
6267
|
});
|
|
6253
6268
|
|
|
6254
6269
|
const ContainerDivider = styled(uilibGl.Divider) `
|
|
@@ -7437,7 +7452,7 @@ const ElementImage = React.memo(({ type, elementConfig }) => {
|
|
|
7437
7452
|
const ElementLegend = React.memo(({ type, element, elementConfig, expandedContainers }) => {
|
|
7438
7453
|
const { attributes, dataSources } = useWidgetContext(type);
|
|
7439
7454
|
const { options } = elementConfig || {};
|
|
7440
|
-
const { twoColumns, chartId, relatedDataSources } = options || {};
|
|
7455
|
+
const { twoColumns, chartId, relatedDataSources, fontSize } = options || {};
|
|
7441
7456
|
const chartElement = React.useMemo(() => findAnd.returnFound(element?.children, { id: chartId }), [chartId, element?.children]);
|
|
7442
7457
|
const { data, loading } = useChartData({
|
|
7443
7458
|
element: chartElement,
|
|
@@ -7464,7 +7479,7 @@ const ElementLegend = React.memo(({ type, element, elementConfig, expandedContai
|
|
|
7464
7479
|
return { ...item, name: attribute?.alias || item.name };
|
|
7465
7480
|
});
|
|
7466
7481
|
}, [attributes, axes, data, options.chartType, relatedDataSources, dataSources]);
|
|
7467
|
-
return !chartElement?.options?.expanded || expandedContainers?.[chartElement.id] ? (jsxRuntime.jsx(ChartLegend, { data: legendData, loading: loading, chartElement: chartElement, twoColumns: twoColumns, type: type })) : null;
|
|
7482
|
+
return !chartElement?.options?.expanded || expandedContainers?.[chartElement.id] ? (jsxRuntime.jsx(ChartLegend, { data: legendData, loading: loading, chartElement: chartElement, twoColumns: twoColumns, fontSize: fontSize, type: type })) : null;
|
|
7468
7483
|
});
|
|
7469
7484
|
|
|
7470
7485
|
const ExternalLink = styled(uilibGl.IconButton).attrs(() => ({
|
|
@@ -8835,7 +8850,7 @@ const useChartData = ({ element, type }) => {
|
|
|
8835
8850
|
return [];
|
|
8836
8851
|
return filteredAttributes
|
|
8837
8852
|
.map(relatedAxis => {
|
|
8838
|
-
const { dataSourceName, axisColor, attributeName } = relatedAxis;
|
|
8853
|
+
const { dataSourceName, axisColor, attributeName, attributeUnits } = relatedAxis;
|
|
8839
8854
|
const dataSource = configDataSources.find(({ name }) => name === dataSourceName);
|
|
8840
8855
|
const layerInfo = layerInfos?.find(item => item?.name === dataSource?.layerName);
|
|
8841
8856
|
const featureDataSource = getDataSource(dataSourceName, dataSources);
|
|
@@ -8853,8 +8868,10 @@ const useChartData = ({ element, type }) => {
|
|
|
8853
8868
|
})
|
|
8854
8869
|
: null,
|
|
8855
8870
|
color: axisColor,
|
|
8871
|
+
attributeName,
|
|
8872
|
+
attributeUnits,
|
|
8873
|
+
dataSourceName,
|
|
8856
8874
|
layerInfo,
|
|
8857
|
-
attributeName
|
|
8858
8875
|
};
|
|
8859
8876
|
})
|
|
8860
8877
|
.filter(({ items }) => items === null || (items?.length && !items.every(({ value }) => value === null)));
|
|
@@ -8864,6 +8881,8 @@ const useChartData = ({ element, type }) => {
|
|
|
8864
8881
|
items: getDataFromAttributes(t, element, attributes),
|
|
8865
8882
|
layerInfo: null,
|
|
8866
8883
|
attributeName: null,
|
|
8884
|
+
attributeUnits: null,
|
|
8885
|
+
dataSourceName: null,
|
|
8867
8886
|
color: null
|
|
8868
8887
|
}
|
|
8869
8888
|
];
|
|
@@ -9395,7 +9414,7 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
|
|
|
9395
9414
|
const { t } = useGlobalContext();
|
|
9396
9415
|
const { expandedContainers, layerInfos, attributes, dataSources } = useWidgetContext(type);
|
|
9397
9416
|
const { id, options, children } = element || {};
|
|
9398
|
-
const { column, markers: configMarkers, showLabels, showMarkers, showTotal, totalWord: configTotalWord, totalAttribute, expandable, expanded, chartType, relatedDataSources, defaultColor } = options || {};
|
|
9417
|
+
const { column, markers: configMarkers, showLabels, showMarkers, showTotal, totalWord: configTotalWord, totalAttribute, expandable, expanded, chartType, relatedDataSources, defaultColor, dotSnapping, } = options || {};
|
|
9399
9418
|
const isLineChart = chartType === "line";
|
|
9400
9419
|
const isPieChart = chartType === "pie";
|
|
9401
9420
|
const isStackBar = chartType === "stack";
|
|
@@ -9450,14 +9469,23 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
|
|
|
9450
9469
|
const renderLineChartTooltip = React.useCallback((items, { indexX }) => {
|
|
9451
9470
|
return (jsxRuntime.jsxs(Tooltip, { children: [jsxRuntime.jsx(ChartTooltipLabel, { children: labels[indexX] }), items
|
|
9452
9471
|
.filter(({ value }) => !isEmptyValue(value))
|
|
9453
|
-
?.map(({ layerName, attributeName, value, stroke }, index) => {
|
|
9454
|
-
const layerInfo =
|
|
9455
|
-
|
|
9456
|
-
|
|
9457
|
-
|
|
9458
|
-
|
|
9472
|
+
?.map(({ layerName, attributeName, attributeUnits, dataSourceName, value, stroke }, index) => {
|
|
9473
|
+
const layerInfo = !attributeUnits
|
|
9474
|
+
? layerInfos?.find(({ name }) => name === layerName)
|
|
9475
|
+
: null;
|
|
9476
|
+
const attribute = !attributeUnits
|
|
9477
|
+
? layerInfo?.layerDefinition.attributes[attributeName]
|
|
9478
|
+
: null;
|
|
9479
|
+
const dataSource = dataSourceName ? getDataSource(dataSourceName, dataSources) : null;
|
|
9480
|
+
const dataSourceUnits = !dataSource || !attributeUnits
|
|
9481
|
+
? null
|
|
9482
|
+
: dataSource.features?.[0]?.attributes?.[attributeUnits];
|
|
9483
|
+
const legendValue = attribute
|
|
9484
|
+
? formatAttributeValue({ t, type: attribute.type, value, stringFormat: attribute.stringFormat })
|
|
9485
|
+
: [value, dataSourceUnits].filter(Boolean).join(" ");
|
|
9486
|
+
return (jsxRuntime.jsxs(ChartTooltipRow, { children: [jsxRuntime.jsx(ChartLegendColor$1, { "$color": stroke }), jsxRuntime.jsx(ChartLegendValue, { children: legendValue })] }, index));
|
|
9459
9487
|
})] }));
|
|
9460
|
-
}, [labels, layerInfos]);
|
|
9488
|
+
}, [labels, layerInfos, dataSources, dotSnapping]);
|
|
9461
9489
|
const markers = React.useMemo(() => getChartMarkers(data[0]?.items, configMarkers, dataSources), [data, dataSources, configMarkers]);
|
|
9462
9490
|
const margin = React.useMemo(() => {
|
|
9463
9491
|
const markersMargin = showMarkers ? 10 : 0;
|
|
@@ -9491,6 +9519,8 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
|
|
|
9491
9519
|
const lineChartData = data.map(item => ({
|
|
9492
9520
|
layerName: item.layerInfo?.name,
|
|
9493
9521
|
attributeName: item.attributeName,
|
|
9522
|
+
attributeUnits: item.attributeUnits,
|
|
9523
|
+
dataSourceName: item.dataSourceName,
|
|
9494
9524
|
stroke: item.color || primaryColor,
|
|
9495
9525
|
values: item.items
|
|
9496
9526
|
?.filter(({ value }) => !isEmptyValue(value))
|
|
@@ -9505,7 +9535,7 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
|
|
|
9505
9535
|
if (isHidedY) {
|
|
9506
9536
|
yAxis.remove();
|
|
9507
9537
|
}
|
|
9508
|
-
}, customYAxis: yAxis => yAxis.ticks(4), renderTooltip: renderLineChartTooltip, customize: customize, dynamicTooltipEnable: true, stackedTooltip: true, tooltipClassName: "dashboardLineChartTooltip", drawGridX: !isHidedY, margin: margin })] }));
|
|
9538
|
+
}, customYAxis: yAxis => yAxis.ticks(4), renderTooltip: renderLineChartTooltip, customize: customize, dotSnapping: dotSnapping, dynamicTooltipEnable: true, stackedTooltip: true, tooltipClassName: "dashboardLineChartTooltip", drawGridX: !isHidedY, margin: margin })] }));
|
|
9509
9539
|
}
|
|
9510
9540
|
if (isStackBar) {
|
|
9511
9541
|
return (jsxRuntime.jsx(AnyChartWrapper, { height: height, children: jsxRuntime.jsx(StackBar, { data: data, filterName: filterName, type: type, alias: elementConfig?.children?.find(child => child.id === "alias"), options: options, renderTooltip: renderPieChartTooltip, renderElement: renderElement }) }));
|
|
@@ -9567,7 +9597,7 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
|
|
|
9567
9597
|
return (jsxRuntime.jsx(ChartWrapper, { width: width, height: isStackBar ? "auto" : isPieChart ? width : height, column: column, loading: loading, children: renderChart }));
|
|
9568
9598
|
});
|
|
9569
9599
|
|
|
9570
|
-
const ChartLegend = ({ data, chartElement, type, twoColumns, loading }) => {
|
|
9600
|
+
const ChartLegend = ({ data, chartElement, fontSize, type, twoColumns, loading }) => {
|
|
9571
9601
|
const { t } = useGlobalContext();
|
|
9572
9602
|
const { sliceItems, showMore, onShowMore } = useShownOtherItems(chartElement?.options);
|
|
9573
9603
|
const axes = React.useMemo(() => getChartAxes(chartElement), [chartElement]);
|
|
@@ -9576,7 +9606,7 @@ const ChartLegend = ({ data, chartElement, type, twoColumns, loading }) => {
|
|
|
9576
9606
|
const showMoreBtn = !!shownItems && data.length > shownItems;
|
|
9577
9607
|
if (!loading && !data?.length && !!hideEmpty)
|
|
9578
9608
|
return null;
|
|
9579
|
-
return (jsxRuntime.jsxs(uilibGl.Flex, { flexDirection: "column", opacity: loading ? FILTERED_VALUE_OPACITY / 100 : 1, children: [jsxRuntime.jsx(ChartLegendContainer, { twoColumns: twoColumns, children: sliceItems(data)?.map(({ name, color }, index) => (jsxRuntime.jsxs(ChartLegendItem, { hasAnyFilter: hasAnyFilter, isFiltered: isFiltered(name), onClick: axes?.[0]?.filterName ? () => onFilter(name) : undefined, children: [jsxRuntime.jsx(ChartLegendColor, { color: color }), jsxRuntime.jsx(ChartLegendName, { "$fontColor": fontColor, children: name })] }, index))) }), showMoreBtn && (jsxRuntime.jsx(uilibGl.LegendToggler, { onClick: onShowMore, toggled: showMore, children: t("other", { ns: "dashboard", defaultValue: "Другое" }) }))] }));
|
|
9609
|
+
return (jsxRuntime.jsxs(uilibGl.Flex, { flexDirection: "column", opacity: loading ? FILTERED_VALUE_OPACITY / 100 : 1, children: [jsxRuntime.jsx(ChartLegendContainer, { twoColumns: twoColumns, children: sliceItems(data)?.map(({ name, color }, index) => (jsxRuntime.jsxs(ChartLegendItem, { hasAnyFilter: hasAnyFilter, isFiltered: isFiltered(name), onClick: axes?.[0]?.filterName ? () => onFilter(name) : undefined, children: [jsxRuntime.jsx(ChartLegendColor, { color: color }), jsxRuntime.jsx(ChartLegendName, { "$fontSize": fontSize, "$fontColor": fontColor, children: name })] }, index))) }), showMoreBtn && (jsxRuntime.jsx(uilibGl.LegendToggler, { onClick: onShowMore, toggled: showMore, children: t("other", { ns: "dashboard", defaultValue: "Другое" }) }))] }));
|
|
9580
9610
|
};
|
|
9581
9611
|
|
|
9582
9612
|
const ContainerChildren = React.memo(({ items, isColumn, isMain, renderElement }) => {
|
|
@@ -9588,7 +9618,7 @@ const ContainerChildren = React.memo(({ items, isColumn, isMain, renderElement }
|
|
|
9588
9618
|
index,
|
|
9589
9619
|
wrap: isColumn || isMain,
|
|
9590
9620
|
});
|
|
9591
|
-
return isMain ? (jsxRuntime.jsx(ContainerWrapper, {
|
|
9621
|
+
return isMain ? (jsxRuntime.jsx(ContainerWrapper, { id: item.id, "data-templatename": item.templateName, children: jsxRuntime.jsx(DashboardWrapper, { children: render }) }, index)) : (jsxRuntime.jsx(InnerContainerWrapper$1, { id: item.id, children: render }, index));
|
|
9592
9622
|
}) }));
|
|
9593
9623
|
});
|
|
9594
9624
|
|
|
@@ -10170,6 +10200,7 @@ exports.HeaderTitleContainer = HeaderTitleContainer;
|
|
|
10170
10200
|
exports.HiddenTitleItems = HiddenTitleItems;
|
|
10171
10201
|
exports.IconContainer = IconContainer;
|
|
10172
10202
|
exports.ImageContainer = ImageContainer;
|
|
10203
|
+
exports.InnerContainerWrapper = InnerContainerWrapper$1;
|
|
10173
10204
|
exports.LEFT_PANEL_HEADER_HEIGHT = LEFT_PANEL_HEADER_HEIGHT;
|
|
10174
10205
|
exports.Layer = Layer;
|
|
10175
10206
|
exports.LayerDescription = LayerDescription;
|