@evergis/react 3.1.81 → 3.1.82
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/Dashboard/index.d.ts +1 -2
- package/dist/components/Dashboard/hooks/useWidgetConfig.d.ts +1 -2
- package/dist/components/Dashboard/hooks/useWidgetContext.d.ts +1 -0
- package/dist/components/Dashboard/types.d.ts +1 -0
- package/dist/contexts/DashboardContext/types.d.ts +1 -0
- package/dist/contexts/FeatureCardContext/types.d.ts +1 -1
- package/dist/index.js +34 -38
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +34 -38
- package/dist/react.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/react.esm.js
CHANGED
|
@@ -4001,8 +4001,8 @@ const ServerNotificationsProvider = ({ url, initialized, children }) => {
|
|
|
4001
4001
|
};
|
|
4002
4002
|
|
|
4003
4003
|
const useWidgetContext = (type = WidgetType.Dashboard) => {
|
|
4004
|
-
const { projectInfo, updateProject, layerInfos, geometryFilter, dashboardLayers, setDashboardLayer, components: dashboardComponents, config: dashboardConfig, containerIds, pageIndex: projectPageIndex, selectedTabId: projectSelectedTabId, setSelectedTabId: setProjectSelectedTabId, dataSources: projectDataSources, loading: projectLoading, filters: projectFilters, changeFilters: projectChangeFilters, expandContainer: projectExpandContainer, expandedContainers: projectExpandedContainers, nextPage: projectNextPage, prevPage: projectPrevPage, changePage: projectChangePage, } = useContext(DashboardContext) || {};
|
|
4005
|
-
const { layerInfo, attributes, feature, closeFeatureCard, config: featureConfig, pageIndex: featurePageIndex, selectedTabId: featureSelectedTabId, setSelectedTabId: setFeatureSelectedTabId, dataSources: featureDataSources, loading: featureLoading, filters: featureFilters, changeFilters: featureChangeFilters, expandContainer: featureExpandContainer, expandedContainers: featureExpandedContainers, nextPage: featureNextPage, prevPage: featurePrevPage, changePage: featureChangePage, } = useContext(FeatureCardContext) || {};
|
|
4004
|
+
const { projectInfo, updateProject, layerInfos, geometryFilter, dashboardLayers, setDashboardLayer, components: dashboardComponents, config: dashboardConfig, containerIds, pageIndex: projectPageIndex, selectedTabId: projectSelectedTabId, setSelectedTabId: setProjectSelectedTabId, dataSources: projectDataSources, loading: projectLoading, editMode: projectEditMode, filters: projectFilters, changeFilters: projectChangeFilters, expandContainer: projectExpandContainer, expandedContainers: projectExpandedContainers, nextPage: projectNextPage, prevPage: projectPrevPage, changePage: projectChangePage, } = useContext(DashboardContext) || {};
|
|
4005
|
+
const { layerInfo, attributes, feature, closeFeatureCard, config: featureConfig, pageIndex: featurePageIndex, selectedTabId: featureSelectedTabId, setSelectedTabId: setFeatureSelectedTabId, dataSources: featureDataSources, loading: featureLoading, editMode: featureEditMode, filters: featureFilters, changeFilters: featureChangeFilters, expandContainer: featureExpandContainer, expandedContainers: featureExpandedContainers, nextPage: featureNextPage, prevPage: featurePrevPage, changePage: featureChangePage, } = useContext(FeatureCardContext) || {};
|
|
4006
4006
|
return {
|
|
4007
4007
|
projectInfo,
|
|
4008
4008
|
layerInfos,
|
|
@@ -4017,6 +4017,7 @@ const useWidgetContext = (type = WidgetType.Dashboard) => {
|
|
|
4017
4017
|
containerIds,
|
|
4018
4018
|
components: dashboardComponents,
|
|
4019
4019
|
config: type === WidgetType.Dashboard ? dashboardConfig : featureConfig,
|
|
4020
|
+
isEditing: type === WidgetType.Dashboard ? projectEditMode : featureEditMode,
|
|
4020
4021
|
isLoading: type === WidgetType.Dashboard ? projectLoading : featureLoading,
|
|
4021
4022
|
pageIndex: type === WidgetType.Dashboard ? projectPageIndex || 1 : featurePageIndex || 1,
|
|
4022
4023
|
filters: type === WidgetType.Dashboard ? projectFilters : featureFilters,
|
|
@@ -7769,33 +7770,30 @@ const ElementChips = memo(({ type, elementConfig }) => {
|
|
|
7769
7770
|
const ElementControl = ({ elementConfig }) => {
|
|
7770
7771
|
const { t } = useGlobalContext();
|
|
7771
7772
|
const { dataSources, filters, changeFilters } = useWidgetContext(WidgetType.FeatureCard);
|
|
7773
|
+
const [value, setValue] = useState();
|
|
7772
7774
|
const { options, attributeName } = elementConfig || {};
|
|
7773
7775
|
const { filterName, relatedDataSource, label, placeholder = t("selectValue", { ns: "dashboard", defaultValue: "Выберите значение" }) } = options || {};
|
|
7774
|
-
// Получаем данные из datasource
|
|
7775
7776
|
const dataSource = useMemo(() => getDataSource(relatedDataSource, dataSources), [relatedDataSource, dataSources]);
|
|
7776
|
-
// Формируем опции для dropdown из features datasource
|
|
7777
7777
|
const items = useMemo(() => {
|
|
7778
7778
|
if (!dataSource?.features?.length || !attributeName) {
|
|
7779
7779
|
return [];
|
|
7780
7780
|
}
|
|
7781
|
-
return dataSource.features.map((
|
|
7782
|
-
|
|
7783
|
-
|
|
7784
|
-
label: feature.attributes?.[attributeName] || "",
|
|
7781
|
+
return dataSource.features.map(({ attributes }) => ({
|
|
7782
|
+
value: attributes?.[attributeName] || "",
|
|
7783
|
+
text: attributes?.[attributeName] || "",
|
|
7785
7784
|
}));
|
|
7786
|
-
}, [dataSource, attributeName]);
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
|
|
7790
|
-
|
|
7791
|
-
changeFilters({
|
|
7785
|
+
}, [dataSource?.features, attributeName]);
|
|
7786
|
+
const handleChange = useCallback(([option]) => {
|
|
7787
|
+
setValue(option?.value);
|
|
7788
|
+
if (filterName) {
|
|
7789
|
+
changeFilters?.({
|
|
7792
7790
|
[filterName]: {
|
|
7793
|
-
value: option?.value
|
|
7791
|
+
value: option?.value,
|
|
7794
7792
|
},
|
|
7795
7793
|
});
|
|
7796
7794
|
}
|
|
7797
7795
|
}, [changeFilters, filterName]);
|
|
7798
|
-
return (jsx(Dropdown, { label: label, options: items, value:
|
|
7796
|
+
return (jsx(Dropdown, { zIndex: 1000, width: "100%", label: label, options: items, value: filters?.[filterName]?.value ?? value, placeholder: placeholder, onChange: handleChange }));
|
|
7799
7797
|
};
|
|
7800
7798
|
|
|
7801
7799
|
const StyledIconFontSizeMixin = css `
|
|
@@ -9618,11 +9616,16 @@ const tooltipValueFromRelatedFeatures = (t, value, relatedAttributes, layerInfo)
|
|
|
9618
9616
|
};
|
|
9619
9617
|
|
|
9620
9618
|
const useWidgetConfig = (type = WidgetType.Dashboard) => {
|
|
9621
|
-
const { config: configProp, containerIds, projectInfo, layerInfo } = useWidgetContext(type);
|
|
9619
|
+
const { config: configProp, containerIds, projectInfo, layerInfo, isEditing } = useWidgetContext(type);
|
|
9622
9620
|
const config = useMemo(() => {
|
|
9623
9621
|
if (configProp) {
|
|
9624
9622
|
return configProp;
|
|
9625
9623
|
}
|
|
9624
|
+
if (isEditing) {
|
|
9625
|
+
return type === WidgetType.Dashboard
|
|
9626
|
+
? (projectInfo?.content?.editConfiguration || {})
|
|
9627
|
+
: (layerInfo?.configuration?.editConfiguration || {});
|
|
9628
|
+
}
|
|
9626
9629
|
const currentConfig = type === WidgetType.Dashboard
|
|
9627
9630
|
? (projectInfo?.content?.dashboardConfiguration || {})
|
|
9628
9631
|
: (layerInfo?.configuration?.cardConfiguration || {});
|
|
@@ -9638,14 +9641,10 @@ const useWidgetConfig = (type = WidgetType.Dashboard) => {
|
|
|
9638
9641
|
return newConfig;
|
|
9639
9642
|
}
|
|
9640
9643
|
return currentConfig;
|
|
9641
|
-
}, [configProp, containerIds, layerInfo?.configuration?.cardConfiguration, projectInfo?.content?.dashboardConfiguration, type]);
|
|
9642
|
-
const editConfig = useMemo(() => type === WidgetType.Dashboard
|
|
9643
|
-
? (projectInfo?.content?.editConfiguration || {})
|
|
9644
|
-
: (layerInfo?.configuration?.editConfiguration || {}), []);
|
|
9644
|
+
}, [configProp, containerIds, layerInfo?.configuration?.cardConfiguration, projectInfo?.content?.dashboardConfiguration, type, isEditing]);
|
|
9645
9645
|
const pages = useMemo(() => (getPagesFromConfig(config) || []), [config]);
|
|
9646
9646
|
return {
|
|
9647
9647
|
config,
|
|
9648
|
-
editConfig,
|
|
9649
9648
|
pages,
|
|
9650
9649
|
};
|
|
9651
9650
|
};
|
|
@@ -10382,20 +10381,17 @@ const Chart = memo(({ config, element, elementConfig, type, renderElement }) =>
|
|
|
10382
10381
|
return (jsxs(Tooltip, { children: [jsx(ChartTooltipLabel, { children: labels[indexX] }), items
|
|
10383
10382
|
.filter(({ value }) => !isEmptyValue(value))
|
|
10384
10383
|
?.map(({ layerName, attributeName, attributeUnits, dataSourceName, value, stroke }, index) => {
|
|
10385
|
-
const layerInfo =
|
|
10386
|
-
|
|
10387
|
-
|
|
10388
|
-
const
|
|
10389
|
-
?
|
|
10390
|
-
:
|
|
10391
|
-
const
|
|
10392
|
-
|
|
10393
|
-
|
|
10394
|
-
|
|
10395
|
-
|
|
10396
|
-
? formatAttributeValue({ t, type: attribute.type, value, stringFormat: attribute.stringFormat })
|
|
10397
|
-
: [value, dataSourceUnits].filter(Boolean).join(" ");
|
|
10398
|
-
return (jsxs(ChartTooltipRow, { children: [jsx(ChartLegendColor$1, { "$color": stroke }), jsx(ChartLegendValue, { children: legendValue })] }, index));
|
|
10384
|
+
const layerInfo = layerInfos?.find(({ name }) => name === layerName);
|
|
10385
|
+
const attribute = layerInfo?.layerDefinition.attributes[attributeName];
|
|
10386
|
+
const dataSource = getDataSource(dataSourceName, dataSources);
|
|
10387
|
+
const units = attributeUnits
|
|
10388
|
+
? dataSource?.features?.[0]?.attributes?.[attributeUnits]
|
|
10389
|
+
: attribute?.stringFormat?.unitsLabel;
|
|
10390
|
+
const formatValue = attribute
|
|
10391
|
+
? formatAttributeValue({ t, type: attribute.type, value, stringFormat: attribute.stringFormat, noUnits: true })
|
|
10392
|
+
: value;
|
|
10393
|
+
const resultValue = [formatValue, units].filter(Boolean).join(" ");
|
|
10394
|
+
return (jsxs(ChartTooltipRow, { children: [jsx(ChartLegendColor$1, { "$color": stroke }), jsx(ChartLegendValue, { children: resultValue })] }, index));
|
|
10399
10395
|
})] }));
|
|
10400
10396
|
}, [labels, layerInfos, dataSources, dotSnapping]);
|
|
10401
10397
|
const markers = useMemo(() => getChartMarkers(data[0]?.items, configMarkers, dataSources), [data, dataSources, configMarkers]);
|
|
@@ -10541,7 +10537,7 @@ const DashboardLoading = memo(() => {
|
|
|
10541
10537
|
return (jsx(Container, { noBorders: true, children: jsx(ContainerWrapper, { "$noMargin": true, children: jsx(DashboardWrapper, { children: jsx(DashboardPlaceholderWrap, { children: jsxs(DashboardPlaceholder, { isLoading: true, children: [jsx(Icon, { kind: "dashboard_loading" }), jsx(Flex, { width: "8rem", children: jsx(LinearProgress, {}) })] }) }) }) }) }));
|
|
10542
10538
|
});
|
|
10543
10539
|
|
|
10544
|
-
const Dashboard = memo(({ type = WidgetType.Dashboard,
|
|
10540
|
+
const Dashboard = memo(({ type = WidgetType.Dashboard, noBorders }) => {
|
|
10545
10541
|
const { dataSources, isLoading } = useWidgetContext(type);
|
|
10546
10542
|
const { currentPage } = useWidgetPage(type);
|
|
10547
10543
|
const isDiffPage = useDiffPage(type);
|
|
@@ -10549,7 +10545,7 @@ const Dashboard = memo(({ type = WidgetType.Dashboard, config, noBorders }) => {
|
|
|
10549
10545
|
if (dataSourceLoading || isDiffPage) {
|
|
10550
10546
|
return (jsx(DashboardLoading, {}));
|
|
10551
10547
|
}
|
|
10552
|
-
return (jsx(PagesContainer, { type: type,
|
|
10548
|
+
return (jsx(PagesContainer, { type: type, noBorders: noBorders }));
|
|
10553
10549
|
});
|
|
10554
10550
|
|
|
10555
10551
|
const CardCheckbox = styled(Checkbox) `
|