@evergis/react 3.1.23 → 3.1.25
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/useWidgetContext.d.ts +5 -4
- package/dist/components/Dashboard/hooks/useWidgetPage.d.ts +2 -1
- package/dist/components/Dashboard/utils/getLayerInfo.d.ts +8 -0
- package/dist/components/Dashboard/utils/index.d.ts +1 -0
- package/dist/contexts/DashboardContext/types.d.ts +25 -24
- package/dist/contexts/GlobalContext/types.d.ts +5 -5
- package/dist/contexts/index.d.ts +0 -1
- package/dist/index.js +73 -16
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +70 -15
- package/dist/react.esm.js.map +1 -1
- package/package.json +2 -2
- package/dist/contexts/ConfigContext/index.d.ts +0 -4
- package/dist/contexts/ConfigContext/types.d.ts +0 -5
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { WidgetType } from '../types';
|
|
2
2
|
export declare const useWidgetContext: (type?: WidgetType) => {
|
|
3
|
+
config: import('../types').ConfigContainer;
|
|
3
4
|
projectInfo: import('@evergis/api').ExtendedProjectInfoDc;
|
|
4
5
|
layerInfos: import('../../..').LayerInfo[];
|
|
5
6
|
updateProject: (projectInfo: import('@evergis/api').ExtendedProjectInfoDc) => void;
|
|
@@ -13,10 +14,10 @@ export declare const useWidgetContext: (type?: WidgetType) => {
|
|
|
13
14
|
feature: import('../../..').SelectedFeature;
|
|
14
15
|
closeFeatureCard: VoidFunction;
|
|
15
16
|
components: {
|
|
16
|
-
LayerItem
|
|
17
|
-
ProjectCatalogMenu
|
|
18
|
-
ProjectPanelMenu
|
|
19
|
-
ProjectPagesMenu
|
|
17
|
+
LayerItem?: import('react').FC<import('../..').LayerItemProps>;
|
|
18
|
+
ProjectCatalogMenu?: import('react').FC;
|
|
19
|
+
ProjectPanelMenu?: import('react').FC;
|
|
20
|
+
ProjectPagesMenu?: import('react').FC;
|
|
20
21
|
};
|
|
21
22
|
isLoading: boolean;
|
|
22
23
|
pageIndex: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigContainerChild, WidgetType } from '../types';
|
|
1
|
+
import { ConfigContainerChild, ConfigLayer, WidgetType } from '../types';
|
|
2
2
|
export declare const useWidgetPage: (type?: WidgetType) => {
|
|
3
3
|
pageIndex: number;
|
|
4
4
|
currentPage: ConfigContainerChild;
|
|
@@ -6,4 +6,5 @@ export declare const useWidgetPage: (type?: WidgetType) => {
|
|
|
6
6
|
updateConfigPage: (newConfig: ConfigContainerChild) => void;
|
|
7
7
|
addConfigPage: () => void;
|
|
8
8
|
deleteConfigPage: (index: number) => void;
|
|
9
|
+
updateConfigLayer: (name: string, newProps: Omit<ConfigLayer, "name">) => void;
|
|
9
10
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ProxyServiceInfoDc, ServiceInfoDc } from '@evergis/api';
|
|
2
|
+
import { LayerInfo, ProxyServiceInfo } from '../../../types';
|
|
3
|
+
export declare const isCompositeLayerConfiguration: (value?: unknown) => value is ServiceInfoDc;
|
|
4
|
+
export declare const isProxyService: (value?: unknown) => value is ProxyServiceInfoDc;
|
|
5
|
+
export declare const getProxyService: (layer?: ServiceInfoDc) => ProxyServiceInfo;
|
|
6
|
+
export declare function getLayerInfo(layer?: ServiceInfoDc & {
|
|
7
|
+
type?: string;
|
|
8
|
+
}): LayerInfo;
|
|
@@ -32,6 +32,7 @@ export * from './getFilterSelectedItems';
|
|
|
32
32
|
export * from './getFilterValue';
|
|
33
33
|
export * from './getFormattedAttributes';
|
|
34
34
|
export * from './getLayerDefinition';
|
|
35
|
+
export * from './getLayerInfo';
|
|
35
36
|
export * from './getLayerInfoFromDataSources';
|
|
36
37
|
export * from './getPagesFromConfig';
|
|
37
38
|
export * from './getPagesFromProjectInfo';
|
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
import { FC, PropsWithChildren } from 'react';
|
|
2
2
|
import { ExtendedProjectInfoDc } from '@evergis/api';
|
|
3
|
-
import { DashboardLayerPayload, DashboardState, LayerItemProps, SelectedFilters, WidgetDataSource } from '../../components';
|
|
3
|
+
import { ConfigContainer, DashboardLayerPayload, DashboardState, LayerItemProps, SelectedFilters, WidgetDataSource } from '../../components';
|
|
4
4
|
import { LayerInfo } from '../../types';
|
|
5
5
|
export type DashboardContextProps = PropsWithChildren<{
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
config?: ConfigContainer;
|
|
7
|
+
projectInfo?: ExtendedProjectInfoDc;
|
|
8
|
+
updateProject?: (projectInfo: ExtendedProjectInfoDc) => void;
|
|
9
|
+
pageIndex?: number;
|
|
10
|
+
layerInfos?: LayerInfo[];
|
|
11
|
+
dataSources?: WidgetDataSource[];
|
|
12
|
+
geometryFilter?: boolean;
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
filters?: SelectedFilters;
|
|
15
|
+
dashboardLayers?: DashboardState["layers"];
|
|
16
|
+
setDashboardLayer?: (props: DashboardLayerPayload) => void;
|
|
17
|
+
selectedTabId?: string;
|
|
18
|
+
components?: {
|
|
19
|
+
LayerItem?: FC<LayerItemProps>;
|
|
20
|
+
ProjectCatalogMenu?: FC;
|
|
21
|
+
ProjectPanelMenu?: FC;
|
|
22
|
+
ProjectPagesMenu?: FC;
|
|
22
23
|
};
|
|
23
|
-
changeFilters
|
|
24
|
-
expandedContainers
|
|
25
|
-
expandContainer
|
|
26
|
-
setSelectedTabId
|
|
27
|
-
nextPage
|
|
28
|
-
prevPage
|
|
29
|
-
changePage
|
|
24
|
+
changeFilters?: (filters: SelectedFilters, resetFilters?: string[]) => void;
|
|
25
|
+
expandedContainers?: Record<string, boolean>;
|
|
26
|
+
expandContainer?: (id: string, expanded?: boolean) => void;
|
|
27
|
+
setSelectedTabId?: (tab: string) => void;
|
|
28
|
+
nextPage?: (total: number) => void;
|
|
29
|
+
prevPage?: (total: number) => void;
|
|
30
|
+
changePage?: (pageIndex: number) => void;
|
|
30
31
|
}>;
|
|
@@ -2,9 +2,9 @@ import { PropsWithChildren } from 'react';
|
|
|
2
2
|
import { i18n } from 'i18next';
|
|
3
3
|
import { Api } from '@evergis/api';
|
|
4
4
|
export type GlobalContextProps = PropsWithChildren<{
|
|
5
|
-
t
|
|
6
|
-
language
|
|
7
|
-
ewktGeometry
|
|
8
|
-
themeName
|
|
9
|
-
api
|
|
5
|
+
t?: i18n["t"];
|
|
6
|
+
language?: string;
|
|
7
|
+
ewktGeometry?: string;
|
|
8
|
+
themeName?: string;
|
|
9
|
+
api?: Api;
|
|
10
10
|
}>;
|
package/dist/contexts/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -3798,11 +3798,6 @@ const isLayerService = (value) => isObject(value) && "name" in value;
|
|
|
3798
3798
|
|
|
3799
3799
|
const isNumeric = (number) => !isNaN(parseFloat(number)) && isFinite(number);
|
|
3800
3800
|
|
|
3801
|
-
const ConfigContext = React.createContext({});
|
|
3802
|
-
const ConfigProvider = React.memo(({ children, config }) => {
|
|
3803
|
-
return jsxRuntime.jsx(ConfigContext.Provider, { value: { config }, children: children });
|
|
3804
|
-
});
|
|
3805
|
-
|
|
3806
3801
|
const DashboardContext = React.createContext({});
|
|
3807
3802
|
const DashboardProvider = React.memo(({ children, ...props }) => {
|
|
3808
3803
|
return jsxRuntime.jsx(DashboardContext.Provider, { value: props, children: children });
|
|
@@ -3916,9 +3911,10 @@ const ServerNotificationsProvider = ({ url, initialized, children }) => {
|
|
|
3916
3911
|
};
|
|
3917
3912
|
|
|
3918
3913
|
const useWidgetContext = (type = exports.WidgetType.Dashboard) => {
|
|
3919
|
-
const { projectInfo, updateProject, layerInfos, geometryFilter, dashboardLayers, setDashboardLayer, components: dashboardComponents, pageIndex: projectPageIndex, selectedTabId: projectSelectedTabId, setSelectedTabId: setProjectSelectedTabId, dataSources: projectDataSources, loading: projectLoading, filters: projectFilters, changeFilters: projectChangeFilters, expandContainer: projectExpandContainer, expandedContainers: projectExpandedContainers, nextPage: projectNextPage, prevPage: projectPrevPage, changePage: projectChangePage, } = React.useContext(DashboardContext) || {};
|
|
3914
|
+
const { config, projectInfo, updateProject, layerInfos, geometryFilter, dashboardLayers, setDashboardLayer, components: dashboardComponents, pageIndex: projectPageIndex, selectedTabId: projectSelectedTabId, setSelectedTabId: setProjectSelectedTabId, dataSources: projectDataSources, loading: projectLoading, filters: projectFilters, changeFilters: projectChangeFilters, expandContainer: projectExpandContainer, expandedContainers: projectExpandedContainers, nextPage: projectNextPage, prevPage: projectPrevPage, changePage: projectChangePage, } = React.useContext(DashboardContext) || {};
|
|
3920
3915
|
const { layerInfo, attributes, feature, closeFeatureCard, pageIndex: featurePageIndex, selectedTabId: featureSelectedTabId, setSelectedTabId: setFeatureSelectedTabId, dataSources: featureDataSources, loading: featureLoading, filters: featureFilters, changeFilters: featureChangeFilters, expandContainer: featureExpandContainer, expandedContainers: featureExpandedContainers, nextPage: featureNextPage, prevPage: featurePrevPage, changePage: featureChangePage, } = React.useContext(FeatureCardContext) || {};
|
|
3921
3916
|
return {
|
|
3917
|
+
config,
|
|
3922
3918
|
projectInfo,
|
|
3923
3919
|
layerInfos,
|
|
3924
3920
|
updateProject,
|
|
@@ -3931,7 +3927,7 @@ const useWidgetContext = (type = exports.WidgetType.Dashboard) => {
|
|
|
3931
3927
|
closeFeatureCard,
|
|
3932
3928
|
components: dashboardComponents,
|
|
3933
3929
|
isLoading: type === exports.WidgetType.Dashboard ? projectLoading : featureLoading,
|
|
3934
|
-
pageIndex: type === exports.WidgetType.Dashboard ? projectPageIndex : featurePageIndex,
|
|
3930
|
+
pageIndex: type === exports.WidgetType.Dashboard ? projectPageIndex || 1 : featurePageIndex || 1,
|
|
3935
3931
|
filters: type === exports.WidgetType.Dashboard ? projectFilters : featureFilters,
|
|
3936
3932
|
changeFilters: type === exports.WidgetType.Dashboard ? projectChangeFilters : featureChangeFilters,
|
|
3937
3933
|
dataSources: type === exports.WidgetType.Dashboard ? projectDataSources : featureDataSources,
|
|
@@ -5957,7 +5953,7 @@ const ChartContainer = React.memo(({ elementConfig, isVisible, type, renderEleme
|
|
|
5957
5953
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ExpandableTitle, { elementConfig: elementConfig, type: type, renderElement: renderElement }), isVisible && (jsxRuntime.jsxs(Container, { isColumn: true, children: [aliasElement && jsxRuntime.jsx(ContainerAlias, { hasBottomMargin: true, children: renderElement({ id: "alias" }) }), jsxRuntime.jsx(ContainerValue, { column: !twoColumns, alignItems: "center", children: hasItems ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ContainerChart, { children: renderElement({ id: "chart" }) }), jsxRuntime.jsx(ContainerLegend, { children: renderElement({ id: "legend" }) })] })) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: "\u2014" })) })] }))] }));
|
|
5958
5954
|
});
|
|
5959
5955
|
|
|
5960
|
-
const PagesContainer = React.memo(({ type }) => {
|
|
5956
|
+
const PagesContainer = React.memo(({ type = exports.WidgetType.Dashboard }) => {
|
|
5961
5957
|
const { config } = useWidgetConfig(type);
|
|
5962
5958
|
const { pageIndex, currentPage } = useWidgetPage(type);
|
|
5963
5959
|
const { selectedTabId, setSelectedTabId, expandedContainers, attributes } = useWidgetContext(type);
|
|
@@ -8427,6 +8423,56 @@ const getFormattedAttributes = (t, data, attributes, config) => {
|
|
|
8427
8423
|
: attributes;
|
|
8428
8424
|
};
|
|
8429
8425
|
|
|
8426
|
+
const isCompositeLayerConfiguration = (value) => isObject(value) && "name" in value;
|
|
8427
|
+
const isProxyService = (value) => isLayerService(value) && ("sourceType" in value || value.type === "RemoteTileService");
|
|
8428
|
+
const getProxyService = (layer) => {
|
|
8429
|
+
if (!isProxyService(layer))
|
|
8430
|
+
return {
|
|
8431
|
+
layers: [],
|
|
8432
|
+
sourceType: "",
|
|
8433
|
+
sourceUrl: "",
|
|
8434
|
+
copyrightText: "",
|
|
8435
|
+
legend: {
|
|
8436
|
+
layers: [],
|
|
8437
|
+
},
|
|
8438
|
+
};
|
|
8439
|
+
const { layers, sourceType, sourceUrl, legend, copyrightText } = layer;
|
|
8440
|
+
return {
|
|
8441
|
+
layers: layers || [],
|
|
8442
|
+
copyrightText: copyrightText || "",
|
|
8443
|
+
sourceUrl: sourceUrl || "",
|
|
8444
|
+
sourceType: sourceType || "",
|
|
8445
|
+
legend: {
|
|
8446
|
+
layers: (legend && legend.layers) || [],
|
|
8447
|
+
},
|
|
8448
|
+
};
|
|
8449
|
+
};
|
|
8450
|
+
function getLayerInfo(layer) {
|
|
8451
|
+
const configuration = layer?.configuration ?? {};
|
|
8452
|
+
const attributesConfiguration = getAttributesConfiguration(layer);
|
|
8453
|
+
const layerDefinition = getLayerDefinition(layer);
|
|
8454
|
+
const configLayers = ("layers" in configuration && configuration.layers) || [];
|
|
8455
|
+
return {
|
|
8456
|
+
type: layer?.type,
|
|
8457
|
+
...(layer || {}),
|
|
8458
|
+
name: layer?.name || "",
|
|
8459
|
+
configuration: {
|
|
8460
|
+
...configuration,
|
|
8461
|
+
layers: configLayers.filter(isCompositeLayerConfiguration),
|
|
8462
|
+
attributesConfiguration,
|
|
8463
|
+
},
|
|
8464
|
+
acl: configuration.acl,
|
|
8465
|
+
condition: ("condition" in configuration && configuration.condition) || undefined,
|
|
8466
|
+
tableName: attributesConfiguration.tableName,
|
|
8467
|
+
idAttribute: attributesConfiguration.idAttribute,
|
|
8468
|
+
titleAttribute: layerDefinition.titleAttribute || attributesConfiguration.titleAttribute,
|
|
8469
|
+
geometryAttribute: attributesConfiguration.geometryAttribute,
|
|
8470
|
+
layerAttributes: attributesConfiguration.attributes,
|
|
8471
|
+
srId: layerDefinition.srId,
|
|
8472
|
+
proxy: getProxyService(layer),
|
|
8473
|
+
};
|
|
8474
|
+
}
|
|
8475
|
+
|
|
8430
8476
|
const getLayerInfoFromDataSources = (layerInfos, dataSources, relatedDataSource) => layerInfos?.find(({ name }) => name === dataSources?.find(item => item.name === relatedDataSource)?.layerName);
|
|
8431
8477
|
|
|
8432
8478
|
const getPagesFromConfig = (config) => config?.children?.[0]?.children;
|
|
@@ -8612,8 +8658,7 @@ const tooltipValueFromRelatedFeatures = (t, value, relatedAttributes, layerInfo)
|
|
|
8612
8658
|
};
|
|
8613
8659
|
|
|
8614
8660
|
const useWidgetConfig = (type = exports.WidgetType.Dashboard) => {
|
|
8615
|
-
const { config: configProp } =
|
|
8616
|
-
const { projectInfo, layerInfo } = useWidgetContext(type);
|
|
8661
|
+
const { config: configProp, projectInfo, layerInfo } = useWidgetContext(type);
|
|
8617
8662
|
const config = React.useMemo(() => {
|
|
8618
8663
|
if (configProp) {
|
|
8619
8664
|
return configProp;
|
|
@@ -8681,7 +8726,17 @@ const useWidgetPage = (type = exports.WidgetType.Dashboard) => {
|
|
|
8681
8726
|
changePage(pageIndex > 1 ? pageIndex - 1 : 1);
|
|
8682
8727
|
}
|
|
8683
8728
|
}, [changePage, pageIndex, projectInfo, updateProject]);
|
|
8684
|
-
|
|
8729
|
+
const updateConfigLayer = React.useCallback((name, newProps) => {
|
|
8730
|
+
const newProjectInfo = JSON.parse(JSON.stringify(projectInfo));
|
|
8731
|
+
const pages = getPagesFromProjectInfo(newProjectInfo);
|
|
8732
|
+
const page = pages?.[pageIndex - 1];
|
|
8733
|
+
const index = page?.layers?.findIndex(layer => layer.name === name) ?? -1;
|
|
8734
|
+
if (index === -1)
|
|
8735
|
+
return;
|
|
8736
|
+
page.layers[index] = { ...page.layers[index], ...newProps };
|
|
8737
|
+
updateProject(newProjectInfo);
|
|
8738
|
+
}, [projectInfo, pageIndex, updateProject]);
|
|
8739
|
+
return { pageIndex, currentPage, changePage, updateConfigPage, addConfigPage, deleteConfigPage, updateConfigLayer };
|
|
8685
8740
|
};
|
|
8686
8741
|
|
|
8687
8742
|
const useChartData = ({ element, type }) => {
|
|
@@ -9367,13 +9422,13 @@ const DashboardLoading = React.memo(() => {
|
|
|
9367
9422
|
|
|
9368
9423
|
const Dashboard = React.memo(({ type = exports.WidgetType.Dashboard, config }) => {
|
|
9369
9424
|
const { dataSources, isLoading } = useWidgetContext(type);
|
|
9370
|
-
const { currentPage } = useWidgetPage();
|
|
9425
|
+
const { currentPage } = useWidgetPage(type);
|
|
9371
9426
|
const isDiffPage = useDiffPage(type);
|
|
9372
|
-
const dataSourceLoading = React.useMemo(() => currentPage?.dataSources?.length && !dataSources?.length && isLoading, [currentPage?.dataSources?.length, dataSources?.length, isLoading]);
|
|
9427
|
+
const dataSourceLoading = React.useMemo(() => !!currentPage?.dataSources?.length && !dataSources?.length && isLoading, [currentPage?.dataSources?.length, dataSources?.length, isLoading]);
|
|
9373
9428
|
if (dataSourceLoading || isDiffPage) {
|
|
9374
9429
|
return (jsxRuntime.jsx(DashboardLoading, {}));
|
|
9375
9430
|
}
|
|
9376
|
-
return (jsxRuntime.jsx(
|
|
9431
|
+
return (jsxRuntime.jsx(PagesContainer, { type: type }));
|
|
9377
9432
|
});
|
|
9378
9433
|
|
|
9379
9434
|
const CardCheckbox = styled(uilibGl.Checkbox) `
|
|
@@ -9856,8 +9911,6 @@ exports.Chart = Chart;
|
|
|
9856
9911
|
exports.ChartContainer = ChartContainer;
|
|
9857
9912
|
exports.ChartLegend = ChartLegend;
|
|
9858
9913
|
exports.ChartLoading = ChartLoading;
|
|
9859
|
-
exports.ConfigContext = ConfigContext;
|
|
9860
|
-
exports.ConfigProvider = ConfigProvider;
|
|
9861
9914
|
exports.ContainerChildren = ContainerChildren;
|
|
9862
9915
|
exports.ContainerLoading = ContainerLoading;
|
|
9863
9916
|
exports.ContainerWrapper = ContainerWrapper;
|
|
@@ -10040,9 +10093,11 @@ exports.getFilterValue = getFilterValue;
|
|
|
10040
10093
|
exports.getFormattedAttributes = getFormattedAttributes;
|
|
10041
10094
|
exports.getGradientColors = getGradientColors;
|
|
10042
10095
|
exports.getLayerDefinition = getLayerDefinition;
|
|
10096
|
+
exports.getLayerInfo = getLayerInfo;
|
|
10043
10097
|
exports.getLayerInfoFromDataSources = getLayerInfoFromDataSources;
|
|
10044
10098
|
exports.getPagesFromConfig = getPagesFromConfig;
|
|
10045
10099
|
exports.getPagesFromProjectInfo = getPagesFromProjectInfo;
|
|
10100
|
+
exports.getProxyService = getProxyService;
|
|
10046
10101
|
exports.getRelatedAttribute = getRelatedAttribute;
|
|
10047
10102
|
exports.getRenderElement = getRenderElement;
|
|
10048
10103
|
exports.getResourceUrl = getResourceUrl;
|
|
@@ -10052,6 +10107,7 @@ exports.getSvgUrl = getSvgUrl;
|
|
|
10052
10107
|
exports.getTotalFromAttributes = getTotalFromAttributes;
|
|
10053
10108
|
exports.getTotalFromRelatedFeatures = getTotalFromRelatedFeatures;
|
|
10054
10109
|
exports.hexToRgba = hexToRgba;
|
|
10110
|
+
exports.isCompositeLayerConfiguration = isCompositeLayerConfiguration;
|
|
10055
10111
|
exports.isEmptyElementValue = isEmptyElementValue;
|
|
10056
10112
|
exports.isEmptyValue = isEmptyValue;
|
|
10057
10113
|
exports.isHiddenEmptyValue = isHiddenEmptyValue;
|
|
@@ -10059,6 +10115,7 @@ exports.isLayerService = isLayerService;
|
|
|
10059
10115
|
exports.isNotValidSelectedTab = isNotValidSelectedTab;
|
|
10060
10116
|
exports.isNumeric = isNumeric;
|
|
10061
10117
|
exports.isObject = isObject;
|
|
10118
|
+
exports.isProxyService = isProxyService;
|
|
10062
10119
|
exports.isVisibleContainer = isVisibleContainer;
|
|
10063
10120
|
exports.numberOptions = numberOptions;
|
|
10064
10121
|
exports.parseClientStyle = parseClientStyle;
|