@evergis/react 4.0.36 → 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/components/Dashboard/headers/FeatureCardIconHeader/styled.d.ts +1 -0
- 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 +89 -20
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +85 -21
- package/dist/react.esm.js.map +1 -1
- package/package.json +2 -2
- package/dist/components/Dashboard/containers/TaskContainer/utils/buildEmptyFiltersFromResponse.d.ts +0 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare const LayerIconClickable: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
1
2
|
export declare const HeaderIcon: import('styled-components').StyledComponent<"div", any, import('@evergis/uilib-gl').FlexProps, never>;
|
|
2
3
|
export declare const IconHeaderWrapper: import('styled-components').StyledComponent<"div", any, {
|
|
3
4
|
$fontColor?: string;
|
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
|
@@ -9,9 +9,9 @@ var api = require('@evergis/api');
|
|
|
9
9
|
var Gradient = require('javascript-color-gradient');
|
|
10
10
|
var color$1 = require('@evergis/color');
|
|
11
11
|
var dateFns = require('date-fns');
|
|
12
|
+
var lodash = require('lodash');
|
|
12
13
|
var ru = require('date-fns/locale/ru');
|
|
13
14
|
var enUS = require('date-fns/locale/en-US');
|
|
14
|
-
var lodash = require('lodash');
|
|
15
15
|
var signalr = require('@microsoft/signalr');
|
|
16
16
|
var findAnd = require('find-and');
|
|
17
17
|
var jspdf = require('jspdf');
|
|
@@ -3829,15 +3829,16 @@ const formatNumberValue = (stringFormat, value, type, noUnits = false) => {
|
|
|
3829
3829
|
return currentValue?.toString() || "";
|
|
3830
3830
|
};
|
|
3831
3831
|
const formatAttributeValue = ({ t, type, value, stringFormat, noUnits = false }) => {
|
|
3832
|
+
const isNilValue = lodash.isNil(value);
|
|
3832
3833
|
if (type === api.AttributeType.Point) {
|
|
3833
|
-
if (!stringFormat?.format ||
|
|
3834
|
+
if (!stringFormat?.format || isNilValue) {
|
|
3834
3835
|
return null;
|
|
3835
3836
|
}
|
|
3836
3837
|
const { coordinates } = value;
|
|
3837
3838
|
return formatPointValue({ t, stringFormat, value: coordinates });
|
|
3838
3839
|
}
|
|
3839
3840
|
if (type === api.AttributeType.DateTime) {
|
|
3840
|
-
if (!stringFormat?.format ||
|
|
3841
|
+
if (!stringFormat?.format || isNilValue)
|
|
3841
3842
|
return null;
|
|
3842
3843
|
return formatDateValue(stringFormat, value);
|
|
3843
3844
|
}
|
|
@@ -3858,12 +3859,12 @@ const formatAttributeValue = ({ t, type, value, stringFormat, noUnits = false })
|
|
|
3858
3859
|
return formatNumberValue(stringFormat, value, type, noUnits);
|
|
3859
3860
|
}
|
|
3860
3861
|
if (type === api.AttributeType.Json) {
|
|
3861
|
-
if (
|
|
3862
|
+
if (isNilValue || value?.length === 0) {
|
|
3862
3863
|
return "";
|
|
3863
3864
|
}
|
|
3864
3865
|
return `${t("total", { ns: "table" })} ${value.length}`;
|
|
3865
3866
|
}
|
|
3866
|
-
return
|
|
3867
|
+
return !isNilValue ? value.toString() : "";
|
|
3867
3868
|
};
|
|
3868
3869
|
const formatNumber = (number) => {
|
|
3869
3870
|
let result = "";
|
|
@@ -5386,6 +5387,70 @@ const useLayerParams = (layer) => {
|
|
|
5386
5387
|
return layerParams;
|
|
5387
5388
|
};
|
|
5388
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
|
+
|
|
5389
5454
|
const useServerNotificationsContext = () => {
|
|
5390
5455
|
return React.useContext(ServerNotificationsContext);
|
|
5391
5456
|
};
|
|
@@ -6344,18 +6409,7 @@ const DataSourceInnerContainer = React.memo(({ config, elementConfig, feature, m
|
|
|
6344
6409
|
setSelectedTabId,
|
|
6345
6410
|
pageIndex,
|
|
6346
6411
|
type,
|
|
6347
|
-
}), [
|
|
6348
|
-
getRenderElement,
|
|
6349
|
-
config,
|
|
6350
|
-
elementConfig,
|
|
6351
|
-
attributes,
|
|
6352
|
-
layerInfo,
|
|
6353
|
-
expandedContainers,
|
|
6354
|
-
selectedTabId,
|
|
6355
|
-
setSelectedTabId,
|
|
6356
|
-
pageIndex,
|
|
6357
|
-
type,
|
|
6358
|
-
]);
|
|
6412
|
+
}), [config, elementConfig, attributes, layerInfo, expandedContainers, selectedTabId, setSelectedTabId, pageIndex, type]);
|
|
6359
6413
|
if (!InnerContainer) {
|
|
6360
6414
|
return null;
|
|
6361
6415
|
}
|
|
@@ -8150,6 +8204,11 @@ const FeatureCardGradientHeader = ({ isRow }) => {
|
|
|
8150
8204
|
}) })] }), jsxRuntime.jsx(FeatureCardButtons, {})] }) }) }) }));
|
|
8151
8205
|
};
|
|
8152
8206
|
|
|
8207
|
+
const LayerIconClickable = styled.div `
|
|
8208
|
+
display: flex;
|
|
8209
|
+
align-items: center;
|
|
8210
|
+
cursor: pointer;
|
|
8211
|
+
`;
|
|
8153
8212
|
const HeaderFontColorMixin = styled.css `
|
|
8154
8213
|
${HeaderTitleContainer}, ${HeaderTitleContainer} *, ${LayerDescription} {
|
|
8155
8214
|
color: ${({ $fontColor }) => $fontColor};
|
|
@@ -8227,13 +8286,18 @@ const IconHeaderWrapper = styled.div `
|
|
|
8227
8286
|
`;
|
|
8228
8287
|
|
|
8229
8288
|
const FeatureCardIconHeader = ({ isRow }) => {
|
|
8230
|
-
const {
|
|
8289
|
+
const { t } = useGlobalContext();
|
|
8290
|
+
const { layerInfo, feature } = useWidgetContext(exports.WidgetType.FeatureCard);
|
|
8231
8291
|
const { config } = useWidgetConfig(exports.WidgetType.FeatureCard);
|
|
8292
|
+
const zoomToFeatures = useZoomToFeatures();
|
|
8293
|
+
const getMaxZoomTo = useMaxZoomTo();
|
|
8294
|
+
const [optionsMaxZoomTo, layerMaxZoomTo] = React.useMemo(() => getMaxZoomTo(layerInfo?.name), [layerInfo?.name, getMaxZoomTo]);
|
|
8232
8295
|
const { header } = config || {};
|
|
8233
8296
|
const { options } = header || {};
|
|
8234
8297
|
const { fontColor, bgColor, bigIcon } = options || {};
|
|
8235
8298
|
const renderElement = useHeaderRender(header);
|
|
8236
|
-
|
|
8299
|
+
const handleIconClick = React.useCallback(() => zoomToFeatures([feature], { maxZoom: layerMaxZoomTo ?? optionsMaxZoomTo }), [zoomToFeatures, feature, layerMaxZoomTo, optionsMaxZoomTo]);
|
|
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({
|
|
8237
8301
|
id: "title",
|
|
8238
8302
|
wrap: false,
|
|
8239
8303
|
}), description: renderElement({
|
|
@@ -9535,7 +9599,7 @@ function getFeatureAttributes(feature = {}, layer, dataSource) {
|
|
|
9535
9599
|
readOnly: true,
|
|
9536
9600
|
}
|
|
9537
9601
|
: {
|
|
9538
|
-
value: currentAttributes?.[attributeName]
|
|
9602
|
+
value: currentAttributes?.[attributeName] ?? dataSource?.features?.[0]?.properties?.[attributeName],
|
|
9539
9603
|
readOnly: attributeConfigurationType === api.AttributeConfigurationType.Calculated || !isEditable,
|
|
9540
9604
|
};
|
|
9541
9605
|
const clientData = layer?.configuration?.attributesConfiguration?.attributes?.find(layerAttribute => layerAttribute.attributeName === attributeName)?.clientData;
|
|
@@ -12589,6 +12653,8 @@ exports.useAppHeight = useAppHeight;
|
|
|
12589
12653
|
exports.useAutoCompleteControl = useAutoCompleteControl;
|
|
12590
12654
|
exports.useChartChange = useChartChange;
|
|
12591
12655
|
exports.useChartData = useChartData;
|
|
12656
|
+
exports.useCurrentPageLayers = useCurrentPageLayers;
|
|
12657
|
+
exports.useCustomFeatureSelect = useCustomFeatureSelect;
|
|
12592
12658
|
exports.useDashboardHeader = useDashboardHeader;
|
|
12593
12659
|
exports.useDataSources = useDataSources;
|
|
12594
12660
|
exports.useDebouncedCallback = useDebouncedCallback;
|
|
@@ -12602,10 +12668,12 @@ exports.useGlobalContext = useGlobalContext;
|
|
|
12602
12668
|
exports.useHeaderRender = useHeaderRender;
|
|
12603
12669
|
exports.useHideIfEmptyDataSource = useHideIfEmptyDataSource;
|
|
12604
12670
|
exports.useIconsFromLayers = useIconsFromLayers;
|
|
12671
|
+
exports.useLayerHiddenAttributes = useLayerHiddenAttributes;
|
|
12605
12672
|
exports.useLayerParams = useLayerParams;
|
|
12606
12673
|
exports.useMapContext = useMapContext;
|
|
12607
12674
|
exports.useMapDraw = useMapDraw;
|
|
12608
12675
|
exports.useMapImages = useMapImages;
|
|
12676
|
+
exports.useMaxZoomTo = useMaxZoomTo;
|
|
12609
12677
|
exports.useProjectDashboardInit = useProjectDashboardInit;
|
|
12610
12678
|
exports.usePythonSandbox = usePythonSandbox;
|
|
12611
12679
|
exports.usePythonTask = usePythonTask;
|
|
@@ -12616,6 +12684,7 @@ exports.useServerNotificationsContext = useServerNotificationsContext;
|
|
|
12616
12684
|
exports.useShownOtherItems = useShownOtherItems;
|
|
12617
12685
|
exports.useToggle = useToggle;
|
|
12618
12686
|
exports.useUpdateDataSource = useUpdateDataSource;
|
|
12687
|
+
exports.useVisibleProjectItems = useVisibleProjectItems;
|
|
12619
12688
|
exports.useWidgetConfig = useWidgetConfig;
|
|
12620
12689
|
exports.useWidgetContext = useWidgetContext;
|
|
12621
12690
|
exports.useWidgetFilters = useWidgetFilters;
|