@evergis/react 2.0.179 → 2.0.181

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.
@@ -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 { ClassificationParameterExtended, LegendValueType, ParameterByAttribute, ParameterValue, StyleSymbolType, SvgPointSymbol } from "../../core";
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
- attributeName: string;
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"> & {
@@ -45,7 +45,9 @@ var StaticImageSymbol = require('@evergis/sgis/es/symbols/point/StaticImageSymbo
45
45
  var Square = require('@evergis/sgis/es/symbols/point/Square');
46
46
  var MaskedImage = require('@evergis/sgis/es/symbols/point/MaskedImage');
47
47
  var H3Symbol = require('@evergis/sgis/es/symbols/H3Symbol');
48
+ var CombinedPolylineSymbol = require('@evergis/sgis/es/symbols/CombinedPolylineSymbol');
48
49
  var H3Feature = require('@evergis/sgis/es/features/H3Feature');
50
+ var CombinedPolyline = require('@evergis/sgis/es/features/CombinedPolyline');
49
51
  var Canvas = require('@evergis/sgis/es/painters/DomPainter/Canvas');
50
52
  var commonEvents = require('@evergis/sgis/es/commonEvents');
51
53
  var ClusterLayer$1 = require('@evergis/sgis/es/layers/ClusterLayer');
@@ -1396,7 +1398,7 @@ const formatDate = function formatDate(date, _temp) {
1396
1398
  return dateFns.format(dateValue, dateFormat);
1397
1399
  }
1398
1400
 
1399
- return "" + defaultValue;
1401
+ return defaultValue.toString();
1400
1402
  };
1401
1403
 
1402
1404
  function numberWithSpaces(x, fractionDigits, delim) {
@@ -2542,39 +2544,25 @@ const isRangeCondition = condition => condition.includes("(");
2542
2544
  const getSymbolParameterInfo = parameter => {
2543
2545
  return PARAMETER_INFOS[parameter] || DEFAULT_PARAMETER_INFO;
2544
2546
  };
2545
- const formatValue$1 = (value, type, calculatedParameter) => {
2546
- var _ref;
2547
-
2548
- if (type === api.AttributeType.DateTime) {
2549
- return formatDate(value, {
2550
- dateFormat: exports.DateFormat.DateTime
2551
- });
2552
- }
2553
-
2554
- const {
2555
- serialize
2556
- } = getSymbolParameterInfo(calculatedParameter);
2557
- return (_ref = value && typeof value === "number" ? serialize(value) : value) == null ? void 0 : _ref.toString();
2558
- };
2559
- const formatUniqueClassValue = value => {
2547
+ const formatUniqueClassValue = (value, formatValue) => {
2560
2548
  const {
2561
2549
  attribute,
2562
2550
  uniqueValue
2563
2551
  } = value;
2564
- return attribute ? formatValue$1(uniqueValue, attribute.type) : uniqueValue;
2552
+ return attribute && formatValue ? formatValue(attribute.type, uniqueValue, attribute.stringFormat) : uniqueValue;
2565
2553
  };
2566
- const getRangeValues$1 = (_ref2, isDouble, isDate, index) => {
2554
+ const getRangeValues$1 = (_ref, isDouble, isDate, index) => {
2567
2555
  let {
2568
2556
  from,
2569
2557
  to
2570
- } = _ref2;
2558
+ } = _ref;
2571
2559
  return {
2572
2560
  from: from !== null && index !== 0 ? isDate ? from : isDouble ? +from : +from + 1 : from,
2573
2561
  to
2574
2562
  };
2575
2563
  };
2576
- const formatRangeClassValue = (value, index) => {
2577
- 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;
2578
2566
 
2579
2567
  const isDouble = ((_value$attribute = value.attribute) == null ? void 0 : _value$attribute.type) === "Double";
2580
2568
  const isDate = ((_value$attribute2 = value.attribute) == null ? void 0 : _value$attribute2.type) === "DateTime";
@@ -2582,8 +2570,8 @@ const formatRangeClassValue = (value, index) => {
2582
2570
  from,
2583
2571
  to
2584
2572
  } = getRangeValues$1(value, isDouble, isDate, index);
2585
- const formattedFrom = isDate && from ? formatDate(from) : from;
2586
- const formattedTo = isDate && to ? formatDate(to) : to;
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;
2587
2575
 
2588
2576
  if (from === null) {
2589
2577
  return "" + formattedTo + (!isDate ? " и менее" : "");
@@ -2612,20 +2600,18 @@ const getTitleFromCondition = condition => {
2612
2600
  return (_parts$ = parts[1]) == null ? void 0 : _parts$.slice(1, -1);
2613
2601
  };
2614
2602
 
2615
- function createValueTitle$1(paramValue, attributeType, index) {
2603
+ function createValueTitle$1(paramValue, attribute, formatValue, index) {
2616
2604
  if (paramValue.title) return paramValue.title;
2617
2605
  const value = {
2618
2606
  parameterValue: getParameterValue(paramValue.value),
2619
- attribute: {
2620
- type: attributeType
2621
- }
2607
+ attribute
2622
2608
  };
2623
2609
  const sign = getSignFromConditionPart(paramValue.condition, 1);
2624
2610
  const isFirstFrom = sign.includes(">");
2625
2611
  value.from = isFirstFrom ? getValueFromConditionPart(paramValue.condition, 1) : null;
2626
2612
  value.to = paramValue.condition.includes(" && ") && isFirstFrom ? getValueFromConditionPart(paramValue.condition, 2) : !isFirstFrom ? getValueFromConditionPart(paramValue.condition, 1) : null;
2627
- if (isRangeClass(value)) return formatRangeClassValue(value, index);
2628
- if (isUniqueClass(value)) return formatUniqueClassValue(value);
2613
+ if (isRangeClass(value)) return formatRangeClassValue(value, formatValue, index);
2614
+ if (isUniqueClass(value)) return formatUniqueClassValue(value, formatValue);
2629
2615
  return "";
2630
2616
  } // Основывается на http://cf.everpoint.ru/pages/viewpage.action?pageId=45024217 ->
2631
2617
  // пункт "Настраиваемые значения параметров символики в системе"
@@ -2900,19 +2886,17 @@ const createOtherHiddenCondition = (values, attributeName, attributeType) => {
2900
2886
 
2901
2887
  return hiddenCondition;
2902
2888
  };
2903
- const getMinimizedLegendValues = (attributeName, attributeType, classified, index, otherTitle) => {
2889
+ const getMinimizedLegendValues = (attribute, classified, formatValue, index, otherTitle) => {
2904
2890
  const other = {
2905
2891
  title: otherTitle,
2906
2892
  parameterValue: classified.defaultValue,
2907
- hiddenCondition: createOtherHiddenCondition(classified.values.map(val => getClassificationValue(val.value, otherTitle, new ClassificationCondition(val.condition))), attributeName, attributeType)
2893
+ hiddenCondition: createOtherHiddenCondition(classified.values.map(val => getClassificationValue(val.value, otherTitle, new ClassificationCondition(val.condition))), attribute.name, attribute.type)
2908
2894
  };
2909
2895
  const items = classified.values.map(paramValue => {
2910
2896
  const parameterValue = getParameterValue(paramValue.value);
2911
2897
  const result = {
2912
2898
  parameterValue,
2913
- attribute: {
2914
- type: attributeType
2915
- }
2899
+ attribute
2916
2900
  };
2917
2901
 
2918
2902
  if (isRangeCondition(paramValue.condition)) {
@@ -2920,38 +2904,38 @@ const getMinimizedLegendValues = (attributeName, attributeType, classified, inde
2920
2904
  const to = getValueFromConditionPart(paramValue.condition, 2);
2921
2905
  result.from = from ? isNumeric(from) ? +from : formatDate(from) : null;
2922
2906
  result.to = to ? isNumeric(to) ? +to : formatDate(to) : null;
2923
- result.title = createValueTitle$1(paramValue, attributeType, index);
2907
+ result.title = createValueTitle$1(paramValue, attribute, formatValue, index);
2924
2908
  return result;
2925
2909
  }
2926
2910
 
2927
- result.uniqueValue = formatValue$1(paramValue.value);
2911
+ result.uniqueValue = formatValue ? formatValue(attribute.type, paramValue.value, attribute.stringFormat) : paramValue.value.toString();
2928
2912
  result.title = getTitleFromCondition(paramValue.condition);
2929
- result.hiddenCondition = createHiddenCondition(attributeName, attributeType, getClassificationValue(paramValue.value, result.title, new ClassificationCondition(paramValue.condition)));
2913
+ result.hiddenCondition = createHiddenCondition(attribute.name, attribute.type, getClassificationValue(paramValue.value, result.title, new ClassificationCondition(paramValue.condition)));
2930
2914
  return result;
2931
2915
  });
2932
2916
 
2933
- if (attributeType !== api.AttributeType.String) {
2917
+ if (attribute.type !== api.AttributeType.String) {
2934
2918
  items.reverse();
2935
2919
  }
2936
2920
 
2937
2921
  return [...items, other];
2938
2922
  };
2939
- const getMaximizedLegendValues = (attributeName, attributeType, param, params, classified, symbol, sectionIndex, otherTitle) => {
2923
+ const getMaximizedLegendValues = (attribute, param, params, classified, symbol, formatValue, sectionIndex, otherTitle) => {
2940
2924
  const other = {
2941
2925
  title: otherTitle,
2942
2926
  symbol: createLegendSymbol(classified.defaultValue, param, params, symbol),
2943
- hiddenCondition: createOtherHiddenCondition(classified.values.map(val => getClassificationValue(val.value, otherTitle, new ClassificationCondition(val.condition))), attributeName, attributeType)
2927
+ hiddenCondition: createOtherHiddenCondition(classified.values.map(val => getClassificationValue(val.value, otherTitle, new ClassificationCondition(val.condition))), attribute.name, attribute.type)
2944
2928
  };
2945
2929
  const items = classified.values.map((paramValue, index) => {
2946
2930
  const result = {
2947
- symbol: createLegendSymbol(classified.values[index].value, param, params, symbol)
2931
+ symbol: createLegendSymbol(paramValue.value, param, params, symbol)
2948
2932
  };
2949
- result.title = isRangeCondition(paramValue.condition) ? createValueTitle$1(paramValue, attributeType, sectionIndex) : getTitleFromCondition(paramValue.condition);
2950
- result.hiddenCondition = createHiddenCondition(attributeName, attributeType, getClassificationValue(classified.values[index].value, result.title, new ClassificationCondition(classified.values[index].condition)));
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)));
2951
2935
  return result;
2952
2936
  });
2953
2937
 
2954
- if (attributeType !== api.AttributeType.String) {
2938
+ if (attribute.type !== api.AttributeType.String) {
2955
2939
  items.reverse();
2956
2940
  }
2957
2941
 
@@ -4154,7 +4138,7 @@ function isSGisH3Symbol(symbol) {
4154
4138
  return symbol instanceof H3Symbol.H3Symbol;
4155
4139
  }
4156
4140
  function isSGisCombinedPolylineSymbol(symbol) {
4157
- return symbol.type === "combinedPolylineSymbol";
4141
+ return symbol instanceof CombinedPolylineSymbol.CombinedPolylineSymbol;
4158
4142
  }
4159
4143
  function isSGisClusterSymbol(symbol) {
4160
4144
  return !!symbol.singleObjectSymbol;
@@ -4172,6 +4156,9 @@ const pointFeature = /*#__PURE__*/new PointFeature.PointFeature([50, -50], {
4172
4156
  const lineFeature = /*#__PURE__*/new Polyline.Polyline([[0, -57], [26, -57], [40, -35], [60, -65], [74, -43], [100, -43]], {
4173
4157
  crs: Crs.plain
4174
4158
  });
4159
+ const combinedLineFeature = /*#__PURE__*/new CombinedPolyline.CombinedPolyline([[0, -57], [26, -57], [40, -35], [60, -65], [74, -43], [100, -43]], {
4160
+ crs: Crs.plain
4161
+ });
4175
4162
  const polygonFeature = /*#__PURE__*/new Polygon.Polygon([[20, -20], [80, -20], [80, -80], [20, -80]], {
4176
4163
  crs: Crs.plain
4177
4164
  });
@@ -4193,14 +4180,14 @@ const MAP_LEGEND_FEATURES = {
4193
4180
  const LEGEND_FEATURES = {
4194
4181
  point: pointFeature,
4195
4182
  polyline: lineLegendFeature,
4196
- combinedPolyline: lineLegendFeature,
4183
+ combinedPolyline: combinedLineFeature,
4197
4184
  polygon: polygonLegendFeature,
4198
4185
  h3grid: h3gridFeature
4199
4186
  };
4200
4187
  const MOCK_FEATURES = {
4201
4188
  point: pointFeature,
4202
4189
  polyline: lineFeature,
4203
- combinedPolyline: lineFeature,
4190
+ combinedPolyline: combinedLineFeature,
4204
4191
  polygon: polygonFeature,
4205
4192
  h3grid: h3gridFeature
4206
4193
  };
@@ -6370,9 +6357,8 @@ const LegendSection = _ref => {
6370
6357
  classified,
6371
6358
  hiddenLegends,
6372
6359
  toggleHiddenLegend,
6373
- attributeName,
6374
- attributeTitle,
6375
- attributeType,
6360
+ attribute,
6361
+ formatValue,
6376
6362
  index
6377
6363
  } = _ref;
6378
6364
  const {
@@ -6381,7 +6367,7 @@ const LegendSection = _ref => {
6381
6367
  const [isExpanded, toggleExpanded] = useToggle();
6382
6368
  const [maxRef, maxNode] = useNode();
6383
6369
  const [minRef, minNode] = useNode();
6384
- return React__default.createElement(MapLegendSectionContainer, null, React__default.createElement(MapLegendHeader, null, attributeTitle), React__default.createElement(LegendParameterDescription, {
6370
+ return React__default.createElement(MapLegendSectionContainer, null, React__default.createElement(MapLegendHeader, null, attribute.alias || attribute.name), React__default.createElement(LegendParameterDescription, {
6385
6371
  parameter: parameter
6386
6372
  }), React__default.createElement(MapLegendSectionItems, {
6387
6373
  height: isExpanded ? ((maxNode == null ? void 0 : maxNode.offsetHeight) || 0) + 4 : minNode == null ? void 0 : minNode.offsetHeight
@@ -6393,15 +6379,15 @@ const LegendSection = _ref => {
6393
6379
  hiddenLegends: hiddenLegends == null ? void 0 : hiddenLegends[layerName],
6394
6380
  toggleHiddenLegend: toggleHiddenLegend,
6395
6381
  parameter: parameter,
6396
- attributeType: attributeType,
6382
+ attributeType: attribute.type,
6397
6383
  index: index,
6398
- values: getMaximizedLegendValues(attributeName, attributeType, parameter, parameters, classified, symbol, index, t("classification.other"))
6384
+ values: getMaximizedLegendValues(attribute, parameter, parameters, classified, symbol, formatValue, index, t("classification.other"))
6399
6385
  }), React__default.createElement(MinimizedLegend, {
6400
6386
  innerRef: minRef,
6401
6387
  isShown: !isExpanded,
6402
- values: getMinimizedLegendValues(attributeName, attributeType, classified, index, t("classification.other")),
6403
6388
  hiddenLegends: hiddenLegends == null ? void 0 : hiddenLegends[layerName],
6404
- parameter: parameter
6389
+ parameter: parameter,
6390
+ values: getMinimizedLegendValues(attribute, classified, formatValue, index, t("classification.other"))
6405
6391
  })), React__default.createElement(MapLegendExpandButton, {
6406
6392
  onClick: toggleExpanded
6407
6393
  }, t(isExpanded ? "toggleMenu" : "Развернуть")));
@@ -6419,21 +6405,19 @@ const Legend = /*#__PURE__*/React.memo(_ref => {
6419
6405
  const parameters = Object.keys(classified);
6420
6406
  const attributes = getLayerAttributes(layerInfo.layerDefinition);
6421
6407
  return React__default.createElement(MapLegendContainer, null, Object.keys(classified).map((param, index) => {
6422
- var _classified$param$val, _layerInfo$style, _attributes$find;
6408
+ var _classified$param$val, _layerInfo$style;
6423
6409
 
6424
6410
  const attributeName = getAttributeNameFromCondition((_classified$param$val = classified[param].values[0]) == null ? void 0 : _classified$param$val.condition);
6425
6411
  return React__default.createElement(LegendSection, Object.assign({
6426
6412
  key: index,
6427
6413
  layerName: layerInfo.name,
6428
6414
  symbol: (_layerInfo$style = layerInfo.style) == null ? void 0 : _layerInfo$style.symbol,
6429
- attributeName: attributeName,
6430
- attributeTitle: ((_attributes$find = attributes.find(_ref2 => {
6415
+ attribute: attributes.find(_ref2 => {
6431
6416
  let {
6432
6417
  name
6433
6418
  } = _ref2;
6434
6419
  return name === attributeName;
6435
- })) == null ? void 0 : _attributes$find.alias) || attributeName,
6436
- attributeType: getAttributeType(layerInfo, attributeName),
6420
+ }),
6437
6421
  classified: classified[param],
6438
6422
  parameter: param,
6439
6423
  parameters: parameters,
@@ -7012,7 +6996,6 @@ exports.formatLength = formatLength;
7012
6996
  exports.formatPolygonMeasure = formatPolygonMeasure;
7013
6997
  exports.formatRangeClassValue = formatRangeClassValue;
7014
6998
  exports.formatUniqueClassValue = formatUniqueClassValue;
7015
- exports.formatValue = formatValue$1;
7016
6999
  exports.getAttributeFromCondition = getAttributeFromCondition;
7017
7000
  exports.getAttributeNameFromClassified = getAttributeNameFromClassified;
7018
7001
  exports.getAttributeNameFromCondition = getAttributeNameFromCondition;