@evergis/react 3.1.130 → 3.1.132
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/hooks/index.d.ts +2 -0
- package/dist/components/Dashboard/hooks/useFetchImageWithAuth.d.ts +1 -0
- package/dist/components/Dashboard/hooks/useFetchWithAuth.d.ts +1 -0
- package/dist/index.js +45 -27
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +46 -30
- package/dist/react.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/react.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
2
2
|
import { IconButton, Flex, transition, Chip, Icon, Description, FlexSpan, IconToggle, Popup, Menu, DraggableTree, shadows, Divider, LegendToggler, Tooltip as Tooltip$1, DropdownField, MultiSelectContainer, IconButtonButton, FlatButton, DraggableTreeContainer, Dialog, DialogTitle, ThemeProvider, darkTheme, DialogContent, CircularProgress, Switch, AutoComplete, Input, Slider, Dropdown, Checkbox, DatePicker, getLocale, LinearProgress, H2, defaultTheme, Preview, Blank, Popover, UploaderItemArea, UploaderTitleWrapper, Uploader, NumberRangeSlider, useAsyncAutocomplete, RangeNumberInput, dateFormat } from '@evergis/uilib-gl';
|
|
3
|
-
import { useState, useMemo, useCallback,
|
|
3
|
+
import { useState, useMemo, useCallback, useRef, useEffect, createContext, memo, useContext, Fragment } from 'react';
|
|
4
4
|
import styled, { createGlobalStyle, css, useTheme } from 'styled-components';
|
|
5
5
|
import { lineChartClassNames, BarChart as BarChart$1, barChartClassNames, LineChart, PieChart } from '@evergis/charts';
|
|
6
|
-
import { AttributeType,
|
|
6
|
+
import { AttributeType, STORAGE_TOKEN_KEY, generateId, GeometryType, RemoteTaskStatus } from '@evergis/api';
|
|
7
7
|
import Gradient from 'javascript-color-gradient';
|
|
8
8
|
import { Color as Color$1 } from '@evergis/color';
|
|
9
9
|
import { isValid, format, parseJSON, parseISO, toDate } from 'date-fns';
|
|
@@ -3921,6 +3921,40 @@ const useAutoCompleteControl = (items) => {
|
|
|
3921
3921
|
};
|
|
3922
3922
|
};
|
|
3923
3923
|
|
|
3924
|
+
const useFetchWithAuth = (url, transform, cleanup) => {
|
|
3925
|
+
const [data, setData] = useState(null);
|
|
3926
|
+
const loadingRef = useRef(false);
|
|
3927
|
+
const transformRef = useRef(transform);
|
|
3928
|
+
const cleanupRef = useRef(cleanup);
|
|
3929
|
+
transformRef.current = transform;
|
|
3930
|
+
cleanupRef.current = cleanup;
|
|
3931
|
+
const fetchData = useCallback(() => {
|
|
3932
|
+
if (!url || loadingRef.current)
|
|
3933
|
+
return;
|
|
3934
|
+
loadingRef.current = true;
|
|
3935
|
+
const token = window.localStorage.getItem(STORAGE_TOKEN_KEY);
|
|
3936
|
+
fetch(url, {
|
|
3937
|
+
headers: token ? { Authorization: `Bearer ${token}` } : {},
|
|
3938
|
+
})
|
|
3939
|
+
.then(res => (res.ok ? transformRef.current(res) : null))
|
|
3940
|
+
.then(setData)
|
|
3941
|
+
.finally(() => {
|
|
3942
|
+
loadingRef.current = false;
|
|
3943
|
+
});
|
|
3944
|
+
}, [url]);
|
|
3945
|
+
useEffect(() => {
|
|
3946
|
+
fetchData();
|
|
3947
|
+
}, [fetchData]);
|
|
3948
|
+
useEffect(() => () => {
|
|
3949
|
+
if (data !== null)
|
|
3950
|
+
cleanupRef.current?.(data);
|
|
3951
|
+
}, [data]);
|
|
3952
|
+
return data;
|
|
3953
|
+
};
|
|
3954
|
+
|
|
3955
|
+
const toObjectUrl = (res) => res.blob().then(blob => URL.createObjectURL(blob));
|
|
3956
|
+
const useFetchImageWithAuth = (url) => useFetchWithAuth(url, toObjectUrl, URL.revokeObjectURL);
|
|
3957
|
+
|
|
3924
3958
|
const DashboardContext = createContext({});
|
|
3925
3959
|
const DashboardProvider = memo(({ children, ...props }) => {
|
|
3926
3960
|
return jsx(DashboardContext.Provider, { value: props, children: children });
|
|
@@ -7769,10 +7803,10 @@ const PageTitleContainer = styled(Flex) `
|
|
|
7769
7803
|
`;
|
|
7770
7804
|
|
|
7771
7805
|
const DashboardDefaultHeader = memo(() => {
|
|
7772
|
-
const { title } = useDashboardHeader();
|
|
7806
|
+
const { title, pageId, image, icon, tooltip, themeName } = useDashboardHeader();
|
|
7773
7807
|
const { toggleLayersVisibility, components: { ProjectPanelMenu, ProjectPagesMenu }, } = useWidgetContext();
|
|
7774
|
-
const
|
|
7775
|
-
return (jsxs(DefaultHeaderContainer, { image:
|
|
7808
|
+
const backgroundImage = useFetchImageWithAuth(image ? getResourceUrl(image) : null);
|
|
7809
|
+
return (jsxs(DefaultHeaderContainer, { image: backgroundImage ?? undefined, isDark: themeName === ThemeName.Dark, children: [!pageId && jsx(LinearProgress, {}), jsxs(Flex, { column: true, gap: "1rem", children: [jsx(FlexSpan, { children: jsxs(TopContainer, { children: [jsx(LogoContainer, { children: icon }), jsx(TopContainerButtons, { children: jsx(ProjectPanelMenu, {}) })] }) }), jsx(FlexSpan, { children: jsx(Flex, { column: true, gap: "0.25rem", children: jsx(FlexSpan, { children: jsxs(Flex, { alignItems: "center", children: [jsxs(PageTitleContainer, { children: [jsx(Tooltip$1, { arrow: true, content: tooltip, children: ref => (jsx(PageTitle, { ref: ref, onClick: toggleLayersVisibility, children: title })) }), jsx(ProjectPagesMenu, {})] }), jsx(FlexSpan, { children: jsx(Pagination, {}) })] }) }) }) })] })] }));
|
|
7776
7810
|
});
|
|
7777
7811
|
|
|
7778
7812
|
const HeaderFrontView = styled(Flex) `
|
|
@@ -8529,7 +8563,10 @@ const ElementImage = memo(({ type, elementConfig }) => {
|
|
|
8529
8563
|
return null;
|
|
8530
8564
|
return getResourceUrl(imageUrl);
|
|
8531
8565
|
}, [attributeName, attributes, value]);
|
|
8532
|
-
|
|
8566
|
+
const blobUrl = useFetchImageWithAuth(firstImage);
|
|
8567
|
+
if (!blobUrl)
|
|
8568
|
+
return null;
|
|
8569
|
+
return (jsx("img", { src: blobUrl, alt: firstImage ?? "", width: width, style: style }));
|
|
8533
8570
|
});
|
|
8534
8571
|
|
|
8535
8572
|
const ElementLegend = memo(({ type, element, elementConfig }) => {
|
|
@@ -11678,30 +11715,9 @@ const StyledSvg = styled(Flex) `
|
|
|
11678
11715
|
`;
|
|
11679
11716
|
|
|
11680
11717
|
const SvgImage = memo(({ url, width, height, fontColor }) => {
|
|
11681
|
-
const
|
|
11682
|
-
const loadingRef = useRef(false);
|
|
11683
|
-
const fetchSvg = useCallback(() => {
|
|
11684
|
-
if (!url || loadingRef.current)
|
|
11685
|
-
return;
|
|
11686
|
-
loadingRef.current = true;
|
|
11687
|
-
const token = window.localStorage.getItem(STORAGE_TOKEN_KEY);
|
|
11688
|
-
fetch(url, {
|
|
11689
|
-
headers: token ? { Authorization: `Bearer ${token}` } : {},
|
|
11690
|
-
})
|
|
11691
|
-
.then(res => (res.ok ? res.text() : null))
|
|
11692
|
-
.then(setSvg)
|
|
11693
|
-
.finally(() => {
|
|
11694
|
-
loadingRef.current = false;
|
|
11695
|
-
});
|
|
11696
|
-
}, [url]);
|
|
11697
|
-
useEffect(() => {
|
|
11698
|
-
fetchSvg();
|
|
11699
|
-
}, [fetchSvg]);
|
|
11700
|
-
useEffect(() => () => {
|
|
11701
|
-
setSvg(null);
|
|
11702
|
-
}, []);
|
|
11718
|
+
const svg = useFetchWithAuth(url, res => res.text());
|
|
11703
11719
|
const regexp = /<\/svg>\s*$/im;
|
|
11704
|
-
if (!regexp.test(svg))
|
|
11720
|
+
if (!svg || !regexp.test(svg))
|
|
11705
11721
|
return null;
|
|
11706
11722
|
return (jsx(StyledSvg, { "$width": width, "$height": height, "$fontColor": fontColor, dangerouslySetInnerHTML: { __html: svg } }));
|
|
11707
11723
|
});
|
|
@@ -11980,5 +11996,5 @@ const Map$1 = ({ zIndex, lowerSiblings, upperSiblings, onError, children, ...res
|
|
|
11980
11996
|
}, children: children }), upperSiblings] }));
|
|
11981
11997
|
};
|
|
11982
11998
|
|
|
11983
|
-
export { AddFeatureButton, AddFeatureContainer, AlertIconContainer, AttributeGalleryContainer, AttributeLabel, BASE_CONTAINER_STYLE, BaseMapTheme, CONFIG_PAGES_ID, CONFIG_PAGE_ID, CameraContainer, Chart, ChartContainer, ChartLegend, ChartLoading, Container, ContainerChildren, ContainerLoading, ContainerTemplate, ContainerWrapper, ContainersGroupContainer, DEFAULT_ATTRIBUTE_NAME, DEFAULT_BARCHART_RADIUS, DEFAULT_BASE_MAP, DEFAULT_CHART_ANGLE, DEFAULT_CHART_HEIGHT, DEFAULT_CHART_WIDTH, DEFAULT_CIRCLE_PAINT, DEFAULT_DASHBOARD_CONFIG, DEFAULT_DATA_SOURCE_LIMIT, DEFAULT_DROPDOWN_WIDTH, DEFAULT_FILL_EXTRUSION_PAINT, DEFAULT_FILL_PAINT, DEFAULT_FILTER_PADDING, DEFAULT_ID_ATTRIBUTE_NAME, DEFAULT_LAT, DEFAULT_LINE_PAINT, DEFAULT_LNG, DEFAULT_PAGES_CONFIG, DEFAULT_PIECHART_RADIUS, DEFAULT_ZOOM, Dashboard, DashboardCheckbox, DashboardChip, DashboardContent, DashboardContext, DashboardDefaultHeader, DashboardHeader, DashboardLoading, DashboardPlaceholder, DashboardPlaceholderWrap, DashboardProvider, DashboardWrapper, DataSourceContainer, DataSourceError, DataSourceErrorContainer, DataSourceInnerContainer, DataSourceProgressContainer, DateFormat, DefaultAttributesContainer, DefaultHeaderContainer, DefaultHeaderWrapper, DividerContainer, EditGeometryType, ElementButton, ElementCamera, ElementChart, ElementChips, ElementControl, ElementIcon, ElementImage, ElementLegend, ElementLink, ElementMarkdown, ElementSlideshow, ElementSvg, ElementTooltip, ElementValueWrapper, ExpandableTitle, FEATURE_CARD_DEFAULT_COLORS, FEATURE_CARD_OTHER_COLOR, FILTERED_VALUE_OPACITY, FILTER_PREFIX, FeatureCardButtons, FeatureCardContext, FeatureCardDefaultHeader, FeatureCardGradientHeader, FeatureCardHeader, FeatureCardIconHeader, FeatureCardProvider, FeatureCardSlideshowHeader, FeatureCardTitle, FeatureControls, FeatureTitleContainer, FiltersContainer, GEOMETRY_ATTRIBUTE, GlobalContext, GlobalProvider, Header, HeaderContainer, HeaderFrontView, HeaderTemplate, HeaderTitleContainer, HiddenTitleItems, IconContainer, ImageContainer, LEFT_PANEL_HEADER_HEIGHT, Layer, LayerDescription, LayerGroup, LayerGroupList, LayerIcon, LayerIconContainer, LayerListContainer, LayerTree, LayersContainer, LayersListWrapper, LinearProgressContainer, LogTerminal, LogoContainer, MAX_CHART_WIDTH, Map$1 as Map, MapContext, MapProvider, NO_CONTENT_VALUE, NUMERIC_ATTRIBUTE_TYPES, NoLiveSnapshotContainer, OneColumnContainer, PageNavigator, PageTitle, PageTitleContainer, PagesContainer, Pagination, PresentationHeader, PresentationHeaderButtons, PresentationHeaderTools, PresentationPanelContainer, PresentationPanelWrapper, PresentationWrapper, ProgressContainer, RoundedBackgroundContainer, SERVER_NOTIFICATION_EVENT, ScalingFactor, ServerNotificationsContext, ServerNotificationsProvider, SlideshowContainer, SmallPreviewContainer$1 as SmallPreviewContainer, SmallPreviewControl, SmallPreviewCounter, SmallPreviewImages, SmallPreviewLeft, SmallPreviewRight, StackBar, SvgImage, TIME_ZONE_FORMAT, TabsContainer, TextTrim, ThemeName, TitleContainer, TmsType, TopContainer, TopContainerButtons, TwoColumnContainer, UploadContainer, WidgetType, addDataSource, addDataSources, adjustColor, applyFiltersToCondition, applyQueryFilters, applyVarsToCondition, checkEqualOrIncludes, checkIsLoading, convertSpToTurfFeature, createConfigLayer, createConfigPage, createNewPageId, createTreeNode, dateOptions, debounce, decimalOpacityToHex, eqlParametersToPayload, findAttributeInExpression, formatArea, formatAttributeValue, formatChartRelatedValue, formatConditionValue, formatDataSourceCondition, formatDate$1 as formatDate, formatElementValue, formatLength, formatNumber, formatPolygonMeasure, getActualExtrusionHeight, getAttributeByName, getAttributeValue, getAttributesConfiguration, getChartAxes, getChartFilterName, getChartMarkers, getConfigFilter, getContainerComponent, getDashboardHeader, getDataFromAttributes, getDataFromRelatedFeatures, getDataSource, getDataSourceFilterValue, getDate, getDefaultConfig, getElementValue, getFeatureAttributes, getFeatureCardHeader, getFilterComponent, getFilterSelectedItems, getFilterValue, getFormattedAttributes, getGradientColors, getLayerDefinition, getLayerInfo, getLayerInfoFromDataSources, getPagesFromConfig, getPagesFromProjectInfo, getProxyService, getRelatedAttribute, getRenderElement, getResourceUrl, getRootElementId, getSelectedFilterValue, getSlideshowImages, getSvgUrl, getTemplateNameFromAttribute, getTotalFromAttributes, getTotalFromRelatedFeatures, hexToRgba, isCompositeLayerConfiguration, isEmptyElementValue, isEmptyValue, isHiddenEmptyValue, isLayerService, isNotValidSelectedTab, isNumeric, isObject, isProxyService, isVisibleContainer, numberOptions, parseClientStyle, parseIconNames, parseIconNamesFromClientStyle, pieChartTooltipFromAttributes, pieChartTooltipFromRelatedFeatures, pointOptions, removeDataSource, rgbToHex, roundTotalSum, sliceShownOtherItems, timeOptions, tooltipNameFromAttributes, tooltipValueFromAttributes, tooltipValueFromRelatedFeatures, transparentizeColor, treeNodesToProjectItems, useAppHeight, useAutoCompleteControl, useChartChange, useChartData, useDashboardHeader, useDataSources, useDebouncedCallback, useDiffPage, useExpandableContainers, useExportPdf, useGetConfigLayer, useGlobalContext, useHeaderRender, useHideIfEmptyDataSource, useIconsFromLayers, useLayerParams, useMapContext, useMapDraw, useMapImages, useProjectDashboardInit, usePythonTask, useRedrawLayer, useRelatedDataSourceAttributes, useRenderElement, useServerNotificationsContext, useShownOtherItems, useToggle, useUpdateDataSource, useWidgetConfig, useWidgetContext, useWidgetFilters, useWidgetPage, useWindowResize, useZoomToFeatures, useZoomToPoint };
|
|
11999
|
+
export { AddFeatureButton, AddFeatureContainer, AlertIconContainer, AttributeGalleryContainer, AttributeLabel, BASE_CONTAINER_STYLE, BaseMapTheme, CONFIG_PAGES_ID, CONFIG_PAGE_ID, CameraContainer, Chart, ChartContainer, ChartLegend, ChartLoading, Container, ContainerChildren, ContainerLoading, ContainerTemplate, ContainerWrapper, ContainersGroupContainer, DEFAULT_ATTRIBUTE_NAME, DEFAULT_BARCHART_RADIUS, DEFAULT_BASE_MAP, DEFAULT_CHART_ANGLE, DEFAULT_CHART_HEIGHT, DEFAULT_CHART_WIDTH, DEFAULT_CIRCLE_PAINT, DEFAULT_DASHBOARD_CONFIG, DEFAULT_DATA_SOURCE_LIMIT, DEFAULT_DROPDOWN_WIDTH, DEFAULT_FILL_EXTRUSION_PAINT, DEFAULT_FILL_PAINT, DEFAULT_FILTER_PADDING, DEFAULT_ID_ATTRIBUTE_NAME, DEFAULT_LAT, DEFAULT_LINE_PAINT, DEFAULT_LNG, DEFAULT_PAGES_CONFIG, DEFAULT_PIECHART_RADIUS, DEFAULT_ZOOM, Dashboard, DashboardCheckbox, DashboardChip, DashboardContent, DashboardContext, DashboardDefaultHeader, DashboardHeader, DashboardLoading, DashboardPlaceholder, DashboardPlaceholderWrap, DashboardProvider, DashboardWrapper, DataSourceContainer, DataSourceError, DataSourceErrorContainer, DataSourceInnerContainer, DataSourceProgressContainer, DateFormat, DefaultAttributesContainer, DefaultHeaderContainer, DefaultHeaderWrapper, DividerContainer, EditGeometryType, ElementButton, ElementCamera, ElementChart, ElementChips, ElementControl, ElementIcon, ElementImage, ElementLegend, ElementLink, ElementMarkdown, ElementSlideshow, ElementSvg, ElementTooltip, ElementValueWrapper, ExpandableTitle, FEATURE_CARD_DEFAULT_COLORS, FEATURE_CARD_OTHER_COLOR, FILTERED_VALUE_OPACITY, FILTER_PREFIX, FeatureCardButtons, FeatureCardContext, FeatureCardDefaultHeader, FeatureCardGradientHeader, FeatureCardHeader, FeatureCardIconHeader, FeatureCardProvider, FeatureCardSlideshowHeader, FeatureCardTitle, FeatureControls, FeatureTitleContainer, FiltersContainer, GEOMETRY_ATTRIBUTE, GlobalContext, GlobalProvider, Header, HeaderContainer, HeaderFrontView, HeaderTemplate, HeaderTitleContainer, HiddenTitleItems, IconContainer, ImageContainer, LEFT_PANEL_HEADER_HEIGHT, Layer, LayerDescription, LayerGroup, LayerGroupList, LayerIcon, LayerIconContainer, LayerListContainer, LayerTree, LayersContainer, LayersListWrapper, LinearProgressContainer, LogTerminal, LogoContainer, MAX_CHART_WIDTH, Map$1 as Map, MapContext, MapProvider, NO_CONTENT_VALUE, NUMERIC_ATTRIBUTE_TYPES, NoLiveSnapshotContainer, OneColumnContainer, PageNavigator, PageTitle, PageTitleContainer, PagesContainer, Pagination, PresentationHeader, PresentationHeaderButtons, PresentationHeaderTools, PresentationPanelContainer, PresentationPanelWrapper, PresentationWrapper, ProgressContainer, RoundedBackgroundContainer, SERVER_NOTIFICATION_EVENT, ScalingFactor, ServerNotificationsContext, ServerNotificationsProvider, SlideshowContainer, SmallPreviewContainer$1 as SmallPreviewContainer, SmallPreviewControl, SmallPreviewCounter, SmallPreviewImages, SmallPreviewLeft, SmallPreviewRight, StackBar, SvgImage, TIME_ZONE_FORMAT, TabsContainer, TextTrim, ThemeName, TitleContainer, TmsType, TopContainer, TopContainerButtons, TwoColumnContainer, UploadContainer, WidgetType, addDataSource, addDataSources, adjustColor, applyFiltersToCondition, applyQueryFilters, applyVarsToCondition, checkEqualOrIncludes, checkIsLoading, convertSpToTurfFeature, createConfigLayer, createConfigPage, createNewPageId, createTreeNode, dateOptions, debounce, decimalOpacityToHex, eqlParametersToPayload, findAttributeInExpression, formatArea, formatAttributeValue, formatChartRelatedValue, formatConditionValue, formatDataSourceCondition, formatDate$1 as formatDate, formatElementValue, formatLength, formatNumber, formatPolygonMeasure, getActualExtrusionHeight, getAttributeByName, getAttributeValue, getAttributesConfiguration, getChartAxes, getChartFilterName, getChartMarkers, getConfigFilter, getContainerComponent, getDashboardHeader, getDataFromAttributes, getDataFromRelatedFeatures, getDataSource, getDataSourceFilterValue, getDate, getDefaultConfig, getElementValue, getFeatureAttributes, getFeatureCardHeader, getFilterComponent, getFilterSelectedItems, getFilterValue, getFormattedAttributes, getGradientColors, getLayerDefinition, getLayerInfo, getLayerInfoFromDataSources, getPagesFromConfig, getPagesFromProjectInfo, getProxyService, getRelatedAttribute, getRenderElement, getResourceUrl, getRootElementId, getSelectedFilterValue, getSlideshowImages, getSvgUrl, getTemplateNameFromAttribute, getTotalFromAttributes, getTotalFromRelatedFeatures, hexToRgba, isCompositeLayerConfiguration, isEmptyElementValue, isEmptyValue, isHiddenEmptyValue, isLayerService, isNotValidSelectedTab, isNumeric, isObject, isProxyService, isVisibleContainer, numberOptions, parseClientStyle, parseIconNames, parseIconNamesFromClientStyle, pieChartTooltipFromAttributes, pieChartTooltipFromRelatedFeatures, pointOptions, removeDataSource, rgbToHex, roundTotalSum, sliceShownOtherItems, timeOptions, tooltipNameFromAttributes, tooltipValueFromAttributes, tooltipValueFromRelatedFeatures, transparentizeColor, treeNodesToProjectItems, useAppHeight, useAutoCompleteControl, useChartChange, useChartData, useDashboardHeader, useDataSources, useDebouncedCallback, useDiffPage, useExpandableContainers, useExportPdf, useFetchImageWithAuth, useFetchWithAuth, useGetConfigLayer, useGlobalContext, useHeaderRender, useHideIfEmptyDataSource, useIconsFromLayers, useLayerParams, useMapContext, useMapDraw, useMapImages, useProjectDashboardInit, usePythonTask, useRedrawLayer, useRelatedDataSourceAttributes, useRenderElement, useServerNotificationsContext, useShownOtherItems, useToggle, useUpdateDataSource, useWidgetConfig, useWidgetContext, useWidgetFilters, useWidgetPage, useWindowResize, useZoomToFeatures, useZoomToPoint };
|
|
11984
12000
|
//# sourceMappingURL=react.esm.js.map
|