@evergis/react 2.0.180 → 2.0.182
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/Legend/types.d.ts +10 -6
- package/dist/react.cjs.development.js +41 -65
- package/dist/react.cjs.development.js.map +1 -1
- package/dist/react.cjs.production.min.js +1 -1
- package/dist/react.cjs.production.min.js.map +1 -1
- package/dist/react.esm.js +42 -65
- package/dist/react.esm.js.map +1 -1
- package/dist/utils/legend.d.ts +6 -7
- package/package.json +3 -3
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ReactNode, RefObject } from "react";
|
|
2
|
-
import { AttributeType, PointLabelSymbolDc, SvgPointSymbolDc, StyleDc, FeatureLayerServiceInfoDc } from "@evergis/api";
|
|
2
|
+
import { AttributeType, PointLabelSymbolDc, SvgPointSymbolDc, StyleDc, FeatureLayerServiceInfoDc, AttributeFormatDc, FeatureDc } from "@evergis/api";
|
|
3
3
|
import { MaskedImage } from "@evergis/sgis/es/symbols/point/MaskedImage";
|
|
4
4
|
import { H3Symbol } from "@evergis/sgis/es/symbols/H3Symbol";
|
|
5
|
-
import {
|
|
5
|
+
import { Coordinates } from "@evergis/sgis/es/baseTypes";
|
|
6
|
+
import { ClassificationParameterExtended, LayerAttribute, LegendValueType, ParameterByAttribute, ParameterValue, StyleSymbolType, SvgPointSymbol } from "../../core";
|
|
6
7
|
import { SGisBrushFill, SGisImageFill, SGisPolygonSymbol, SGisPolylineSymbol } from "../../symbols";
|
|
7
8
|
export declare type ClassifyParameter = "fill.color" | "fill.hatchColor" | "stroke.width" | "stroke.color" | "textBackground.fill.color" | "background.fillColor" | "background.strokeColor" | "background.strokeWidth" | "figure.fillColor" | "fillColor" | "strokeColor" | "strokeWidth" | "fontColor" | "haloColor" | "size" | "symbol" | "angle" | "maskedColor" | "endingSize" | "beginningSize" | "maxObjectCount" | "gridSize" | "selectionObjectsLimit";
|
|
8
9
|
export interface ParameterInfo {
|
|
@@ -19,20 +20,23 @@ export declare const enum Units {
|
|
|
19
20
|
Count = "pcs",
|
|
20
21
|
Degrees = "\u00B0"
|
|
21
22
|
}
|
|
23
|
+
export declare type Positions = Coordinates | Coordinates[] | Coordinates[][];
|
|
24
|
+
export declare type FeaturedDcExtendedGeometry = Omit<FeatureDc["geometry"], "coordinates"> & {
|
|
25
|
+
coordinates?: Positions;
|
|
26
|
+
};
|
|
22
27
|
export declare type LegendProps = {
|
|
23
28
|
layerInfo: FeatureLayerServiceInfoDc;
|
|
29
|
+
formatValue?: (type: AttributeType, value: string | number | Date | FeaturedDcExtendedGeometry, stringFormat?: AttributeFormatDc) => string;
|
|
24
30
|
hiddenLegends?: Record<string, string[]>;
|
|
25
31
|
toggleHiddenLegend?: (layerName: string, hiddenCondition: string) => void;
|
|
26
32
|
};
|
|
27
|
-
export declare type LegendSectionProps = Pick<LegendProps, "hiddenLegends" | "toggleHiddenLegend"> & {
|
|
33
|
+
export declare type LegendSectionProps = Pick<LegendProps, "hiddenLegends" | "toggleHiddenLegend" | "formatValue"> & {
|
|
28
34
|
layerName: string;
|
|
29
35
|
symbol: StyleDc["symbol"];
|
|
30
36
|
parameter: ClassificationParameterExtended;
|
|
31
37
|
parameters: ClassificationParameterExtended[];
|
|
32
38
|
classified: ParameterByAttribute<ParameterValue>;
|
|
33
|
-
|
|
34
|
-
attributeTitle: string;
|
|
35
|
-
attributeType: AttributeType;
|
|
39
|
+
attribute: LayerAttribute;
|
|
36
40
|
index: number;
|
|
37
41
|
};
|
|
38
42
|
export declare type LegendSectionItem = Pick<LegendProps, "hiddenLegends" | "toggleHiddenLegend"> & {
|
|
@@ -1398,7 +1398,7 @@ const formatDate = function formatDate(date, _temp) {
|
|
|
1398
1398
|
return dateFns.format(dateValue, dateFormat);
|
|
1399
1399
|
}
|
|
1400
1400
|
|
|
1401
|
-
return
|
|
1401
|
+
return defaultValue.toString();
|
|
1402
1402
|
};
|
|
1403
1403
|
|
|
1404
1404
|
function numberWithSpaces(x, fractionDigits, delim) {
|
|
@@ -2544,39 +2544,25 @@ const isRangeCondition = condition => condition.includes("(");
|
|
|
2544
2544
|
const getSymbolParameterInfo = parameter => {
|
|
2545
2545
|
return PARAMETER_INFOS[parameter] || DEFAULT_PARAMETER_INFO;
|
|
2546
2546
|
};
|
|
2547
|
-
const
|
|
2548
|
-
var _ref;
|
|
2549
|
-
|
|
2550
|
-
if (type === api.AttributeType.DateTime) {
|
|
2551
|
-
return formatDate(value, {
|
|
2552
|
-
dateFormat: exports.DateFormat.DateTime
|
|
2553
|
-
});
|
|
2554
|
-
}
|
|
2555
|
-
|
|
2556
|
-
const {
|
|
2557
|
-
serialize
|
|
2558
|
-
} = getSymbolParameterInfo(calculatedParameter);
|
|
2559
|
-
return (_ref = value && typeof value === "number" ? serialize(value) : value) == null ? void 0 : _ref.toString();
|
|
2560
|
-
};
|
|
2561
|
-
const formatUniqueClassValue = value => {
|
|
2547
|
+
const formatUniqueClassValue = (value, formatValue) => {
|
|
2562
2548
|
const {
|
|
2563
2549
|
attribute,
|
|
2564
2550
|
uniqueValue
|
|
2565
2551
|
} = value;
|
|
2566
|
-
return attribute ? formatValue
|
|
2552
|
+
return attribute && formatValue ? formatValue(attribute.type, uniqueValue, attribute.stringFormat) : uniqueValue;
|
|
2567
2553
|
};
|
|
2568
|
-
const getRangeValues$1 = (
|
|
2554
|
+
const getRangeValues$1 = (_ref, isDouble, isDate, index) => {
|
|
2569
2555
|
let {
|
|
2570
2556
|
from,
|
|
2571
2557
|
to
|
|
2572
|
-
} =
|
|
2558
|
+
} = _ref;
|
|
2573
2559
|
return {
|
|
2574
2560
|
from: from !== null && index !== 0 ? isDate ? from : isDouble ? +from : +from + 1 : from,
|
|
2575
2561
|
to
|
|
2576
2562
|
};
|
|
2577
2563
|
};
|
|
2578
|
-
const formatRangeClassValue = (value, index) => {
|
|
2579
|
-
var _value$attribute, _value$attribute2;
|
|
2564
|
+
const formatRangeClassValue = (value, formatValue, index) => {
|
|
2565
|
+
var _value$attribute, _value$attribute2, _value$attribute3, _value$attribute4, _value$attribute5, _value$attribute6;
|
|
2580
2566
|
|
|
2581
2567
|
const isDouble = ((_value$attribute = value.attribute) == null ? void 0 : _value$attribute.type) === "Double";
|
|
2582
2568
|
const isDate = ((_value$attribute2 = value.attribute) == null ? void 0 : _value$attribute2.type) === "DateTime";
|
|
@@ -2584,8 +2570,8 @@ const formatRangeClassValue = (value, index) => {
|
|
|
2584
2570
|
from,
|
|
2585
2571
|
to
|
|
2586
2572
|
} = getRangeValues$1(value, isDouble, isDate, index);
|
|
2587
|
-
const formattedFrom =
|
|
2588
|
-
const formattedTo =
|
|
2573
|
+
const formattedFrom = formatValue ? formatValue((_value$attribute3 = value.attribute) == null ? void 0 : _value$attribute3.type, from, (_value$attribute4 = value.attribute) == null ? void 0 : _value$attribute4.stringFormat) : from;
|
|
2574
|
+
const formattedTo = formatValue ? formatValue((_value$attribute5 = value.attribute) == null ? void 0 : _value$attribute5.type, to, (_value$attribute6 = value.attribute) == null ? void 0 : _value$attribute6.stringFormat) : to;
|
|
2589
2575
|
|
|
2590
2576
|
if (from === null) {
|
|
2591
2577
|
return "" + formattedTo + (!isDate ? " и менее" : "");
|
|
@@ -2614,20 +2600,18 @@ const getTitleFromCondition = condition => {
|
|
|
2614
2600
|
return (_parts$ = parts[1]) == null ? void 0 : _parts$.slice(1, -1);
|
|
2615
2601
|
};
|
|
2616
2602
|
|
|
2617
|
-
function createValueTitle$1(paramValue,
|
|
2603
|
+
function createValueTitle$1(paramValue, attribute, formatValue, index) {
|
|
2618
2604
|
if (paramValue.title) return paramValue.title;
|
|
2619
2605
|
const value = {
|
|
2620
2606
|
parameterValue: getParameterValue(paramValue.value),
|
|
2621
|
-
attribute
|
|
2622
|
-
type: attributeType
|
|
2623
|
-
}
|
|
2607
|
+
attribute
|
|
2624
2608
|
};
|
|
2625
2609
|
const sign = getSignFromConditionPart(paramValue.condition, 1);
|
|
2626
2610
|
const isFirstFrom = sign.includes(">");
|
|
2627
2611
|
value.from = isFirstFrom ? getValueFromConditionPart(paramValue.condition, 1) : null;
|
|
2628
2612
|
value.to = paramValue.condition.includes(" && ") && isFirstFrom ? getValueFromConditionPart(paramValue.condition, 2) : !isFirstFrom ? getValueFromConditionPart(paramValue.condition, 1) : null;
|
|
2629
|
-
if (isRangeClass(value)) return formatRangeClassValue(value, index);
|
|
2630
|
-
if (isUniqueClass(value)) return formatUniqueClassValue(value);
|
|
2613
|
+
if (isRangeClass(value)) return formatRangeClassValue(value, formatValue, index);
|
|
2614
|
+
if (isUniqueClass(value)) return formatUniqueClassValue(value, formatValue);
|
|
2631
2615
|
return "";
|
|
2632
2616
|
} // Основывается на http://cf.everpoint.ru/pages/viewpage.action?pageId=45024217 ->
|
|
2633
2617
|
// пункт "Настраиваемые значения параметров символики в системе"
|
|
@@ -2902,19 +2886,17 @@ const createOtherHiddenCondition = (values, attributeName, attributeType) => {
|
|
|
2902
2886
|
|
|
2903
2887
|
return hiddenCondition;
|
|
2904
2888
|
};
|
|
2905
|
-
const getMinimizedLegendValues = (
|
|
2889
|
+
const getMinimizedLegendValues = (attribute, classified, formatValue, index, otherTitle) => {
|
|
2906
2890
|
const other = {
|
|
2907
2891
|
title: otherTitle,
|
|
2908
2892
|
parameterValue: classified.defaultValue,
|
|
2909
|
-
hiddenCondition: createOtherHiddenCondition(classified.values.map(val => getClassificationValue(val.value, otherTitle, new ClassificationCondition(val.condition))),
|
|
2893
|
+
hiddenCondition: createOtherHiddenCondition(classified.values.map(val => getClassificationValue(val.value, otherTitle, new ClassificationCondition(val.condition))), attribute.name, attribute.type)
|
|
2910
2894
|
};
|
|
2911
2895
|
const items = classified.values.map(paramValue => {
|
|
2912
2896
|
const parameterValue = getParameterValue(paramValue.value);
|
|
2913
2897
|
const result = {
|
|
2914
2898
|
parameterValue,
|
|
2915
|
-
attribute
|
|
2916
|
-
type: attributeType
|
|
2917
|
-
}
|
|
2899
|
+
attribute
|
|
2918
2900
|
};
|
|
2919
2901
|
|
|
2920
2902
|
if (isRangeCondition(paramValue.condition)) {
|
|
@@ -2922,38 +2904,38 @@ const getMinimizedLegendValues = (attributeName, attributeType, classified, inde
|
|
|
2922
2904
|
const to = getValueFromConditionPart(paramValue.condition, 2);
|
|
2923
2905
|
result.from = from ? isNumeric(from) ? +from : formatDate(from) : null;
|
|
2924
2906
|
result.to = to ? isNumeric(to) ? +to : formatDate(to) : null;
|
|
2925
|
-
result.title = createValueTitle$1(paramValue,
|
|
2907
|
+
result.title = createValueTitle$1(paramValue, attribute, formatValue, index);
|
|
2926
2908
|
return result;
|
|
2927
2909
|
}
|
|
2928
2910
|
|
|
2929
|
-
result.uniqueValue = formatValue
|
|
2911
|
+
result.uniqueValue = formatValue ? formatValue(attribute.type, paramValue.value, attribute.stringFormat) : paramValue.value.toString();
|
|
2930
2912
|
result.title = getTitleFromCondition(paramValue.condition);
|
|
2931
|
-
result.hiddenCondition = createHiddenCondition(
|
|
2913
|
+
result.hiddenCondition = createHiddenCondition(attribute.name, attribute.type, getClassificationValue(paramValue.value, result.title, new ClassificationCondition(paramValue.condition)));
|
|
2932
2914
|
return result;
|
|
2933
2915
|
});
|
|
2934
2916
|
|
|
2935
|
-
if (
|
|
2917
|
+
if (attribute.type !== api.AttributeType.String) {
|
|
2936
2918
|
items.reverse();
|
|
2937
2919
|
}
|
|
2938
2920
|
|
|
2939
2921
|
return [...items, other];
|
|
2940
2922
|
};
|
|
2941
|
-
const getMaximizedLegendValues = (
|
|
2923
|
+
const getMaximizedLegendValues = (attribute, param, params, classified, symbol, formatValue, sectionIndex, otherTitle) => {
|
|
2942
2924
|
const other = {
|
|
2943
2925
|
title: otherTitle,
|
|
2944
2926
|
symbol: createLegendSymbol(classified.defaultValue, param, params, symbol),
|
|
2945
|
-
hiddenCondition: createOtherHiddenCondition(classified.values.map(val => getClassificationValue(val.value, otherTitle, new ClassificationCondition(val.condition))),
|
|
2927
|
+
hiddenCondition: createOtherHiddenCondition(classified.values.map(val => getClassificationValue(val.value, otherTitle, new ClassificationCondition(val.condition))), attribute.name, attribute.type)
|
|
2946
2928
|
};
|
|
2947
2929
|
const items = classified.values.map((paramValue, index) => {
|
|
2948
2930
|
const result = {
|
|
2949
|
-
symbol: createLegendSymbol(
|
|
2931
|
+
symbol: createLegendSymbol(paramValue.value, param, params, symbol)
|
|
2950
2932
|
};
|
|
2951
|
-
result.title = isRangeCondition(paramValue.condition) ? createValueTitle$1(paramValue,
|
|
2952
|
-
result.hiddenCondition = createHiddenCondition(
|
|
2933
|
+
result.title = isRangeCondition(paramValue.condition) ? createValueTitle$1(paramValue, attribute, formatValue, sectionIndex) : getTitleFromCondition(paramValue.condition);
|
|
2934
|
+
result.hiddenCondition = createHiddenCondition(attribute.name, attribute.type, getClassificationValue(paramValue.value, result.title, new ClassificationCondition(classified.values[index].condition)));
|
|
2953
2935
|
return result;
|
|
2954
2936
|
});
|
|
2955
2937
|
|
|
2956
|
-
if (
|
|
2938
|
+
if (attribute.type !== api.AttributeType.String) {
|
|
2957
2939
|
items.reverse();
|
|
2958
2940
|
}
|
|
2959
2941
|
|
|
@@ -3503,28 +3485,26 @@ let SGisPolylineSymbol = /*#__PURE__*/function (_sPolylineSymbol) {
|
|
|
3503
3485
|
if (!isSimplePolylineSymbol(this.originalSymbol)) return _get(_getPrototypeOf(SGisPolylineSymbol.prototype), "renderFunction", this).call(this, feature, resolution, crs);
|
|
3504
3486
|
const {
|
|
3505
3487
|
ending,
|
|
3506
|
-
|
|
3507
|
-
beginning,
|
|
3508
|
-
endingSize
|
|
3488
|
+
beginning
|
|
3509
3489
|
} = this.originalSymbol;
|
|
3510
3490
|
const renders = [];
|
|
3511
3491
|
const featureCopy = feature.clone();
|
|
3512
3492
|
const beginningMiterRender = getLineMiterRender({
|
|
3513
3493
|
color: this.strokeColor,
|
|
3514
3494
|
// @ts-ignore
|
|
3515
|
-
kind: beginning,
|
|
3495
|
+
kind: beginning.type,
|
|
3516
3496
|
position: 'left',
|
|
3517
3497
|
// @ts-ignore
|
|
3518
|
-
size:
|
|
3498
|
+
size: beginning.size,
|
|
3519
3499
|
strokeWidth: this.strokeWidth
|
|
3520
3500
|
});
|
|
3521
3501
|
const endingMiterRender = getLineMiterRender({
|
|
3522
3502
|
color: this.strokeColor,
|
|
3523
3503
|
// @ts-ignore
|
|
3524
|
-
kind: ending,
|
|
3504
|
+
kind: ending.type,
|
|
3525
3505
|
position: 'right',
|
|
3526
3506
|
// @ts-ignore
|
|
3527
|
-
size:
|
|
3507
|
+
size: ending.size,
|
|
3528
3508
|
strokeWidth: this.strokeWidth
|
|
3529
3509
|
});
|
|
3530
3510
|
|
|
@@ -6375,9 +6355,8 @@ const LegendSection = _ref => {
|
|
|
6375
6355
|
classified,
|
|
6376
6356
|
hiddenLegends,
|
|
6377
6357
|
toggleHiddenLegend,
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
attributeType,
|
|
6358
|
+
attribute,
|
|
6359
|
+
formatValue,
|
|
6381
6360
|
index
|
|
6382
6361
|
} = _ref;
|
|
6383
6362
|
const {
|
|
@@ -6386,7 +6365,7 @@ const LegendSection = _ref => {
|
|
|
6386
6365
|
const [isExpanded, toggleExpanded] = useToggle();
|
|
6387
6366
|
const [maxRef, maxNode] = useNode();
|
|
6388
6367
|
const [minRef, minNode] = useNode();
|
|
6389
|
-
return React__default.createElement(MapLegendSectionContainer, null, React__default.createElement(MapLegendHeader, null,
|
|
6368
|
+
return React__default.createElement(MapLegendSectionContainer, null, React__default.createElement(MapLegendHeader, null, attribute.alias || attribute.name), React__default.createElement(LegendParameterDescription, {
|
|
6390
6369
|
parameter: parameter
|
|
6391
6370
|
}), React__default.createElement(MapLegendSectionItems, {
|
|
6392
6371
|
height: isExpanded ? ((maxNode == null ? void 0 : maxNode.offsetHeight) || 0) + 4 : minNode == null ? void 0 : minNode.offsetHeight
|
|
@@ -6398,15 +6377,15 @@ const LegendSection = _ref => {
|
|
|
6398
6377
|
hiddenLegends: hiddenLegends == null ? void 0 : hiddenLegends[layerName],
|
|
6399
6378
|
toggleHiddenLegend: toggleHiddenLegend,
|
|
6400
6379
|
parameter: parameter,
|
|
6401
|
-
attributeType:
|
|
6380
|
+
attributeType: attribute.type,
|
|
6402
6381
|
index: index,
|
|
6403
|
-
values: getMaximizedLegendValues(
|
|
6382
|
+
values: getMaximizedLegendValues(attribute, parameter, parameters, classified, symbol, formatValue, index, t("classification.other"))
|
|
6404
6383
|
}), React__default.createElement(MinimizedLegend, {
|
|
6405
6384
|
innerRef: minRef,
|
|
6406
6385
|
isShown: !isExpanded,
|
|
6407
|
-
values: getMinimizedLegendValues(attributeName, attributeType, classified, index, t("classification.other")),
|
|
6408
6386
|
hiddenLegends: hiddenLegends == null ? void 0 : hiddenLegends[layerName],
|
|
6409
|
-
parameter: parameter
|
|
6387
|
+
parameter: parameter,
|
|
6388
|
+
values: getMinimizedLegendValues(attribute, classified, formatValue, index, t("classification.other"))
|
|
6410
6389
|
})), React__default.createElement(MapLegendExpandButton, {
|
|
6411
6390
|
onClick: toggleExpanded
|
|
6412
6391
|
}, t(isExpanded ? "toggleMenu" : "Развернуть")));
|
|
@@ -6424,21 +6403,19 @@ const Legend = /*#__PURE__*/React.memo(_ref => {
|
|
|
6424
6403
|
const parameters = Object.keys(classified);
|
|
6425
6404
|
const attributes = getLayerAttributes(layerInfo.layerDefinition);
|
|
6426
6405
|
return React__default.createElement(MapLegendContainer, null, Object.keys(classified).map((param, index) => {
|
|
6427
|
-
var _classified$param$val, _layerInfo$style
|
|
6406
|
+
var _classified$param$val, _layerInfo$style;
|
|
6428
6407
|
|
|
6429
6408
|
const attributeName = getAttributeNameFromCondition((_classified$param$val = classified[param].values[0]) == null ? void 0 : _classified$param$val.condition);
|
|
6430
6409
|
return React__default.createElement(LegendSection, Object.assign({
|
|
6431
6410
|
key: index,
|
|
6432
6411
|
layerName: layerInfo.name,
|
|
6433
6412
|
symbol: (_layerInfo$style = layerInfo.style) == null ? void 0 : _layerInfo$style.symbol,
|
|
6434
|
-
|
|
6435
|
-
attributeTitle: ((_attributes$find = attributes.find(_ref2 => {
|
|
6413
|
+
attribute: attributes.find(_ref2 => {
|
|
6436
6414
|
let {
|
|
6437
6415
|
name
|
|
6438
6416
|
} = _ref2;
|
|
6439
6417
|
return name === attributeName;
|
|
6440
|
-
})
|
|
6441
|
-
attributeType: getAttributeType(layerInfo, attributeName),
|
|
6418
|
+
}),
|
|
6442
6419
|
classified: classified[param],
|
|
6443
6420
|
parameter: param,
|
|
6444
6421
|
parameters: parameters,
|
|
@@ -7017,7 +6994,6 @@ exports.formatLength = formatLength;
|
|
|
7017
6994
|
exports.formatPolygonMeasure = formatPolygonMeasure;
|
|
7018
6995
|
exports.formatRangeClassValue = formatRangeClassValue;
|
|
7019
6996
|
exports.formatUniqueClassValue = formatUniqueClassValue;
|
|
7020
|
-
exports.formatValue = formatValue$1;
|
|
7021
6997
|
exports.getAttributeFromCondition = getAttributeFromCondition;
|
|
7022
6998
|
exports.getAttributeNameFromClassified = getAttributeNameFromClassified;
|
|
7023
6999
|
exports.getAttributeNameFromCondition = getAttributeNameFromCondition;
|