@evergis/react 4.0.37 → 4.0.38
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/hooks/index.d.ts +1 -0
- package/dist/hooks/project/index.d.ts +5 -0
- package/dist/hooks/project/useCurrentPageLayers.d.ts +1 -0
- package/dist/hooks/project/useCustomFeatureSelect.d.ts +2 -0
- package/dist/hooks/project/useLayerHiddenAttributes.d.ts +1 -0
- package/dist/hooks/project/useMaxZoomTo.d.ts +1 -0
- package/dist/hooks/project/useVisibleProjectItems.d.ts +1 -0
- package/dist/index.js +72 -1
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +68 -2
- package/dist/react.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/hooks/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useCurrentPageLayers: () => import('../..').ConfigLayer[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useLayerHiddenAttributes: (layerName: string) => [string[], (updatedAttributes: string[]) => void];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useMaxZoomTo: () => ((layerName?: string) => [number | undefined, number | undefined]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useVisibleProjectItems: (applyMinMaxScale?: boolean) => import('../..').ConfigLayer[];
|
package/dist/index.js
CHANGED
|
@@ -5387,6 +5387,70 @@ const useLayerParams = (layer) => {
|
|
|
5387
5387
|
return layerParams;
|
|
5388
5388
|
};
|
|
5389
5389
|
|
|
5390
|
+
const useMaxZoomTo = () => {
|
|
5391
|
+
const { currentPage } = useWidgetPage();
|
|
5392
|
+
return React.useCallback((layerName) => {
|
|
5393
|
+
if (!layerName) {
|
|
5394
|
+
return [currentPage?.options?.maxZoomTo, undefined];
|
|
5395
|
+
}
|
|
5396
|
+
return [currentPage?.options?.maxZoomTo, currentPage?.layers?.find(item => item.name === layerName)?.maxZoomTo];
|
|
5397
|
+
}, [currentPage?.layers, currentPage?.options?.maxZoomTo]);
|
|
5398
|
+
};
|
|
5399
|
+
|
|
5400
|
+
const useCustomFeatureSelect = () => {
|
|
5401
|
+
const { currentPage } = useWidgetPage();
|
|
5402
|
+
return React.useCallback((layerName) => {
|
|
5403
|
+
if (!layerName) {
|
|
5404
|
+
return [currentPage?.options?.customFeatureSelect, undefined];
|
|
5405
|
+
}
|
|
5406
|
+
return [
|
|
5407
|
+
currentPage?.options?.customFeatureSelect,
|
|
5408
|
+
currentPage?.layers?.find(item => item.name === layerName)?.customFeatureSelect,
|
|
5409
|
+
];
|
|
5410
|
+
}, [currentPage?.layers, currentPage?.options?.customFeatureSelect]);
|
|
5411
|
+
};
|
|
5412
|
+
|
|
5413
|
+
const useCurrentPageLayers = () => {
|
|
5414
|
+
const { currentPage } = useWidgetPage();
|
|
5415
|
+
return React.useMemo(() => currentPage?.layers || [], [currentPage?.layers]);
|
|
5416
|
+
};
|
|
5417
|
+
|
|
5418
|
+
const useLayerHiddenAttributes = (layerName) => {
|
|
5419
|
+
const { currentPage, updateConfigPage } = useWidgetPage();
|
|
5420
|
+
const layerHiddenAttributes = React.useMemo(() => {
|
|
5421
|
+
return currentPage?.layers?.find(item => item.name === layerName)?.hiddenAttributes ?? [];
|
|
5422
|
+
}, [currentPage?.layers, layerName]);
|
|
5423
|
+
const updateLayerHiddenAttributes = React.useCallback((updatedHiddenAttributes) => {
|
|
5424
|
+
updateConfigPage({
|
|
5425
|
+
...currentPage,
|
|
5426
|
+
layers: currentPage?.layers?.map(item => {
|
|
5427
|
+
return item.name === layerName
|
|
5428
|
+
? {
|
|
5429
|
+
...item,
|
|
5430
|
+
hiddenAttributes: updatedHiddenAttributes,
|
|
5431
|
+
}
|
|
5432
|
+
: item;
|
|
5433
|
+
}),
|
|
5434
|
+
});
|
|
5435
|
+
}, [currentPage, layerName, updateConfigPage]);
|
|
5436
|
+
return [layerHiddenAttributes, updateLayerHiddenAttributes];
|
|
5437
|
+
};
|
|
5438
|
+
|
|
5439
|
+
const useVisibleProjectItems = (applyMinMaxScale) => {
|
|
5440
|
+
const { map } = useMapContext();
|
|
5441
|
+
const projectItems = useCurrentPageLayers();
|
|
5442
|
+
const zoomChange = React.useMemo(() => (applyMinMaxScale && map.current?.getZoom() !== undefined ? Math.round(map.current?.getZoom()) : undefined), [applyMinMaxScale, map.current?.getZoom()]);
|
|
5443
|
+
return React.useMemo(() => {
|
|
5444
|
+
if (map.current?.getZoom() === undefined) {
|
|
5445
|
+
return [];
|
|
5446
|
+
}
|
|
5447
|
+
return (projectItems?.filter(item => item.isVisible &&
|
|
5448
|
+
(!applyMinMaxScale ||
|
|
5449
|
+
(Math.round(map.current.getZoom()) >= (item.minScale ?? 0) &&
|
|
5450
|
+
Math.round(map.current.getZoom()) <= (item.maxScale ?? 30)))) ?? []);
|
|
5451
|
+
}, [projectItems, zoomChange, applyMinMaxScale]);
|
|
5452
|
+
};
|
|
5453
|
+
|
|
5390
5454
|
const useServerNotificationsContext = () => {
|
|
5391
5455
|
return React.useContext(ServerNotificationsContext);
|
|
5392
5456
|
};
|
|
@@ -8226,11 +8290,13 @@ const FeatureCardIconHeader = ({ isRow }) => {
|
|
|
8226
8290
|
const { layerInfo, feature } = useWidgetContext(exports.WidgetType.FeatureCard);
|
|
8227
8291
|
const { config } = useWidgetConfig(exports.WidgetType.FeatureCard);
|
|
8228
8292
|
const zoomToFeatures = useZoomToFeatures();
|
|
8293
|
+
const getMaxZoomTo = useMaxZoomTo();
|
|
8294
|
+
const [optionsMaxZoomTo, layerMaxZoomTo] = React.useMemo(() => getMaxZoomTo(layerInfo?.name), [layerInfo?.name, getMaxZoomTo]);
|
|
8229
8295
|
const { header } = config || {};
|
|
8230
8296
|
const { options } = header || {};
|
|
8231
8297
|
const { fontColor, bgColor, bigIcon } = options || {};
|
|
8232
8298
|
const renderElement = useHeaderRender(header);
|
|
8233
|
-
const handleIconClick = React.useCallback(() => zoomToFeatures([feature]), [zoomToFeatures, feature]);
|
|
8299
|
+
const handleIconClick = React.useCallback(() => zoomToFeatures([feature], { maxZoom: layerMaxZoomTo ?? optionsMaxZoomTo }), [zoomToFeatures, feature, layerMaxZoomTo, optionsMaxZoomTo]);
|
|
8234
8300
|
return (jsxRuntime.jsx(IconHeaderWrapper, { "$fontColor": fontColor, "$bgColor": bgColor, "$bigIcon": bigIcon, children: jsxRuntime.jsx(uilibGl.ThemeProvider, { theme: uilibGl.defaultTheme, children: jsxRuntime.jsxs(Header, { "$isRow": isRow, children: [jsxRuntime.jsxs(HeaderFrontView, { children: [jsxRuntime.jsxs(HeaderContainer, { children: [jsxRuntime.jsx(uilibGl.Tooltip, { arrow: true, placement: "top", content: t("zoomToFeature", { ns: "dashboard", defaultValue: "Приблизить к объекту" }), delay: [600, 0], children: ref => (jsxRuntime.jsx(LayerIconClickable, { ref: ref, onClick: handleIconClick, children: jsxRuntime.jsx(LayerIcon, { layerInfo: layerInfo }) })) }), jsxRuntime.jsx(FeatureCardTitle, { title: renderElement({
|
|
8235
8301
|
id: "title",
|
|
8236
8302
|
wrap: false,
|
|
@@ -12587,6 +12653,8 @@ exports.useAppHeight = useAppHeight;
|
|
|
12587
12653
|
exports.useAutoCompleteControl = useAutoCompleteControl;
|
|
12588
12654
|
exports.useChartChange = useChartChange;
|
|
12589
12655
|
exports.useChartData = useChartData;
|
|
12656
|
+
exports.useCurrentPageLayers = useCurrentPageLayers;
|
|
12657
|
+
exports.useCustomFeatureSelect = useCustomFeatureSelect;
|
|
12590
12658
|
exports.useDashboardHeader = useDashboardHeader;
|
|
12591
12659
|
exports.useDataSources = useDataSources;
|
|
12592
12660
|
exports.useDebouncedCallback = useDebouncedCallback;
|
|
@@ -12600,10 +12668,12 @@ exports.useGlobalContext = useGlobalContext;
|
|
|
12600
12668
|
exports.useHeaderRender = useHeaderRender;
|
|
12601
12669
|
exports.useHideIfEmptyDataSource = useHideIfEmptyDataSource;
|
|
12602
12670
|
exports.useIconsFromLayers = useIconsFromLayers;
|
|
12671
|
+
exports.useLayerHiddenAttributes = useLayerHiddenAttributes;
|
|
12603
12672
|
exports.useLayerParams = useLayerParams;
|
|
12604
12673
|
exports.useMapContext = useMapContext;
|
|
12605
12674
|
exports.useMapDraw = useMapDraw;
|
|
12606
12675
|
exports.useMapImages = useMapImages;
|
|
12676
|
+
exports.useMaxZoomTo = useMaxZoomTo;
|
|
12607
12677
|
exports.useProjectDashboardInit = useProjectDashboardInit;
|
|
12608
12678
|
exports.usePythonSandbox = usePythonSandbox;
|
|
12609
12679
|
exports.usePythonTask = usePythonTask;
|
|
@@ -12614,6 +12684,7 @@ exports.useServerNotificationsContext = useServerNotificationsContext;
|
|
|
12614
12684
|
exports.useShownOtherItems = useShownOtherItems;
|
|
12615
12685
|
exports.useToggle = useToggle;
|
|
12616
12686
|
exports.useUpdateDataSource = useUpdateDataSource;
|
|
12687
|
+
exports.useVisibleProjectItems = useVisibleProjectItems;
|
|
12617
12688
|
exports.useWidgetConfig = useWidgetConfig;
|
|
12618
12689
|
exports.useWidgetContext = useWidgetContext;
|
|
12619
12690
|
exports.useWidgetFilters = useWidgetFilters;
|