@evergis/react 2.0.192 → 2.0.194

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,12 +1,12 @@
1
1
  /// <reference types="react" />
2
- import { Color } from "@evergis/color/es/Color";
3
- import { SvgEditorField, SvgSymbolBg } from "../types";
4
- import { SvgPointSymbol } from "../../../core";
2
+ import { Color } from '@evergis/color/es/Color';
3
+ import { SvgEditorField, SvgSymbolBg } from '../types';
4
+ import { SvgPointSymbol } from '../../../core';
5
5
  export declare const useSvgSymbol: (symbol: SvgPointSymbol, skipOffset?: boolean | undefined) => {
6
6
  svgRef: import("react").MutableRefObject<HTMLElement | null>;
7
7
  initSvg: () => void;
8
8
  getSvgData: () => string;
9
- manipulateSvg: ({ svg, bg, newSymbol }: {
9
+ manipulateSvg: ({ svg, bg, newSymbol, }: {
10
10
  svg: string;
11
11
  bg?: SvgSymbolBg | undefined;
12
12
  newSymbol?: import("../../../core").ClientSymbol<"svgPointSymbol", import("@evergis/api").SvgPointSymbolDc, never> | undefined;
@@ -2582,11 +2582,17 @@ const checkLayerHasLegend = layerInfo => {
2582
2582
  return (paramValue == null ? void 0 : paramValue.type) === 'byAttribute';
2583
2583
  })) || false;
2584
2584
  };
2585
- const getTitleFromCondition = condition => {
2585
+ const getTitleFromCondition = _ref2 => {
2586
2586
  var _parts$;
2587
2587
 
2588
+ let {
2589
+ condition,
2590
+ attribute,
2591
+ formatValue
2592
+ } = _ref2;
2588
2593
  const parts = condition == null ? void 0 : condition.split(' == ');
2589
- return (parts == null ? void 0 : (_parts$ = parts[1]) == null ? void 0 : _parts$.slice(1, -1)) || '';
2594
+ const uniqueValue = (parts == null ? void 0 : (_parts$ = parts[1]) == null ? void 0 : _parts$.slice(1, -1)) || '';
2595
+ return attribute && formatValue ? formatValue(attribute.type, uniqueValue, attribute.stringFormat) : uniqueValue;
2590
2596
  };
2591
2597
  function createValueTitleFromCondition(paramValue, attribute, formatValue, index) {
2592
2598
  if (!attribute) return '';
@@ -2905,7 +2911,9 @@ const getMinimizedLegendValues = (attribute, classified, formatValue, index, oth
2905
2911
  }
2906
2912
 
2907
2913
  result.uniqueValue = formatValue ? formatValue(attribute.type, paramValue.value, attribute.stringFormat) : paramValue.value.toString();
2908
- result.title = getTitleFromCondition(paramValue.condition);
2914
+ result.title = getTitleFromCondition({
2915
+ condition: paramValue.condition
2916
+ });
2909
2917
  result.hiddenCondition = createHiddenCondition(attribute.name, attribute.type, getClassificationValue(paramValue.value, result.title, new ClassificationCondition(paramValue.condition)));
2910
2918
  return result;
2911
2919
  });
@@ -2926,7 +2934,9 @@ const getMaximizedLegendValues = (attribute, param, params, classified, symbol,
2926
2934
  const result = {
2927
2935
  symbol: createLegendSymbol(paramValue.value, param, params, symbol)
2928
2936
  };
2929
- result.title = isRangeCondition(paramValue.condition) ? createValueTitleFromCondition(paramValue, attribute, formatValue, sectionIndex) : getTitleFromCondition(paramValue.condition);
2937
+ result.title = isRangeCondition(paramValue.condition) ? createValueTitleFromCondition(paramValue, attribute, formatValue, sectionIndex) : getTitleFromCondition({
2938
+ condition: paramValue.condition
2939
+ });
2930
2940
  result.hiddenCondition = createHiddenCondition(attribute.name, attribute.type, getClassificationValue(paramValue.value, result.title, new ClassificationCondition(classified.values[index].condition)));
2931
2941
  return result;
2932
2942
  });
@@ -3212,7 +3222,7 @@ const textComparisonOperators = [...BASE_OPERATORS, ...CONTAINS_OPERATORS, ...ST
3212
3222
  })(exports.SvgSymbolBg || (exports.SvgSymbolBg = {}));
3213
3223
 
3214
3224
  const convertSvgToBase64 = svg => "data:image/svg+xml;base64," + window.btoa(svg);
3215
- const createSvgGradient = (svg, values) => svg.gradient("linear", add => {
3225
+ const createSvgGradient = (svg, values) => svg.gradient('linear', add => {
3216
3226
  values == null ? void 0 : values.forEach((_ref, index) => {
3217
3227
  let {
3218
3228
  value
@@ -3234,8 +3244,8 @@ const manipulateSvgSymbol = (SVGContainer, symbol, svg, bg) => {
3234
3244
  background,
3235
3245
  figure
3236
3246
  } = symbol;
3237
- const isUploadedFile = !bg && !symbolData.includes("symbol-bg") && !symbolData.includes("symbol-figure");
3238
- const innerSvg = symbolData.replace(/<\?xml[^?]*\?>|<svg[^>]*>|<\/svg>/g, "");
3247
+ const isUploadedFile = !bg && !symbolData.includes('symbol-bg') && !symbolData.includes('symbol-figure');
3248
+ const innerSvg = symbolData.replace(/<\?xml[^?]*\?>|<svg[^>]*>|<\/svg>/g, '');
3239
3249
 
3240
3250
  if (isUploadedFile) {
3241
3251
  var _$exec;
@@ -3249,11 +3259,11 @@ const manipulateSvgSymbol = (SVGContainer, symbol, svg, bg) => {
3249
3259
 
3250
3260
  SVGContainer.size(size);
3251
3261
  } else {
3252
- const hasBg = bg || (innerSvg == null ? void 0 : innerSvg.includes("symbol-bg"));
3262
+ const hasBg = bg || (innerSvg == null ? void 0 : innerSvg.includes('symbol-bg'));
3253
3263
  let defaultSize = hasBg ? DEFAULT_SYMBOL_WITH_BG_SIZE : DEFAULT_SYMBOL_SIZE;
3254
3264
  const currentSize = size || defaultSize;
3255
3265
  let viewBox = [0, 0, defaultSize, defaultSize];
3256
- const strokeWidth = getParameterValue(background == null ? void 0 : background.strokeWidth) || (typeof (background == null ? void 0 : background.strokeColor) === "object" ? 1 : 0);
3266
+ const strokeWidth = getParameterValue(background == null ? void 0 : background.strokeWidth) || (typeof (background == null ? void 0 : background.strokeColor) === 'object' ? 1 : 0);
3257
3267
 
3258
3268
  if (strokeWidth) {
3259
3269
  defaultSize += strokeWidth;
@@ -3261,7 +3271,7 @@ const manipulateSvgSymbol = (SVGContainer, symbol, svg, bg) => {
3261
3271
  }
3262
3272
 
3263
3273
  if (hasBg) {
3264
- SVGContainer.size(currentSize + "px", currentSize + "px").viewbox(viewBox.join(" "));
3274
+ SVGContainer.size(currentSize + "px", currentSize + "px").viewbox(viewBox.join(' '));
3265
3275
  const currentBg = bg || (background == null ? void 0 : background.type);
3266
3276
 
3267
3277
  if (currentBg) {
@@ -3269,23 +3279,32 @@ const manipulateSvgSymbol = (SVGContainer, symbol, svg, bg) => {
3269
3279
  const fillColor = getParameterValue(background == null ? void 0 : background.fillColor);
3270
3280
  SVGContainer.svg(currentBg === exports.SvgSymbolBg.Circle ? "<circle\n id=\"symbol-bg\"\n cx=\"" + DEFAULT_SYMBOL_WITH_BG_SIZE / 2 + "\"\n cy=\"" + DEFAULT_SYMBOL_WITH_BG_SIZE / 2 + "\"\n r=\"" + DEFAULT_SYMBOL_WITH_BG_SIZE / 2 + "\"\n fill=\"" + (fillColor || DEFAULT_SYMBOL_FILL_COLOR) + "\"\n stroke=\"" + (strokeColor || DEFAULT_SYMBOL_STROKE_COLOR) + "\"\n stroke-width=\"" + strokeWidth + "\"\n />" : "<rect\n id=\"symbol-bg\"\n width=\"" + DEFAULT_SYMBOL_WITH_BG_SIZE + "\"\n height=\"" + DEFAULT_SYMBOL_WITH_BG_SIZE + "\"\n rx=\"4\"\n fill=\"" + (fillColor || DEFAULT_SYMBOL_FILL_COLOR) + "\"\n stroke=\"" + (strokeColor || DEFAULT_SYMBOL_STROKE_COLOR) + "\"\n stroke-width=\"" + strokeWidth + "\"\n />");
3271
3281
  SVGContainer.svg(innerSvg);
3272
- SVGContainer.find("#symbol-bg:not(:first-child)").each(item => item.remove());
3273
- SVGContainer.find(":not(#symbol-bg)").each(item => item.center(DEFAULT_SYMBOL_WITH_BG_SIZE / 2, DEFAULT_SYMBOL_WITH_BG_SIZE / 2).fill("white")); // eslint-disable-next-line max-depth
3282
+ SVGContainer.find('#symbol-bg:not(:first-child)').each(item => item.remove());
3283
+ SVGContainer.find(':not(#symbol-bg)').each(item => item.center(DEFAULT_SYMBOL_WITH_BG_SIZE / 2, DEFAULT_SYMBOL_WITH_BG_SIZE / 2).fill('white')); // eslint-disable-next-line max-depth
3274
3284
 
3275
3285
  if (isParameterByAttribute(background == null ? void 0 : background.fillColor)) {
3276
3286
  var _background$fillColor, _SVGContainer$find$;
3277
3287
 
3278
3288
  const gradient = createSvgGradient(SVGContainer, background == null ? void 0 : (_background$fillColor = background.fillColor) == null ? void 0 : _background$fillColor.values);
3279
- (_SVGContainer$find$ = SVGContainer.find("#symbol-bg")[0]) == null ? void 0 : _SVGContainer$find$.fill(gradient);
3289
+ (_SVGContainer$find$ = SVGContainer.find('#symbol-bg')[0]) == null ? void 0 : _SVGContainer$find$.fill(gradient);
3290
+
3291
+ if (isParameterByAttribute(background == null ? void 0 : background.strokeColor)) {
3292
+ var _SVGContainer$find$2;
3293
+
3294
+ (_SVGContainer$find$2 = SVGContainer.find('#symbol-bg')[0]) == null ? void 0 : _SVGContainer$find$2.stroke({
3295
+ color: gradient,
3296
+ opacity: 0.28
3297
+ });
3298
+ }
3280
3299
  }
3281
3300
  } else {
3282
3301
  SVGContainer.svg(innerSvg);
3283
3302
  }
3284
3303
  } else {
3285
3304
  const fillColor = getParameterValue(figure == null ? void 0 : figure.fillColor);
3286
- SVGContainer.size(currentSize + "px", currentSize + "px").viewbox(viewBox.join(" "));
3305
+ SVGContainer.size(currentSize + "px", currentSize + "px").viewbox(viewBox.join(' '));
3287
3306
  SVGContainer.svg(innerSvg);
3288
- SVGContainer.find("#symbol-figure").each(item => {
3307
+ SVGContainer.find('#symbol-figure').each(item => {
3289
3308
  item.center(DEFAULT_SYMBOL_SIZE / 2, DEFAULT_SYMBOL_SIZE / 2).fill(fillColor || DEFAULT_SYMBOL_FILL_COLOR);
3290
3309
  });
3291
3310
  }
@@ -3294,13 +3313,13 @@ const manipulateSvgSymbol = (SVGContainer, symbol, svg, bg) => {
3294
3313
  const rootTransform = (_$exec2 = /<svg[^>]*transform="([^"]+)"/g.exec(symbolData)) == null ? void 0 : _$exec2[1];
3295
3314
 
3296
3315
  if (rootTransform) {
3297
- const transformParts = rootTransform.slice(0, -1).split("(");
3316
+ const transformParts = rootTransform.slice(0, -1).split('(');
3298
3317
  SVGContainer.transform({
3299
- [transformParts[0]]: transformParts[1].split(",")
3318
+ [transformParts[0]]: transformParts[1].split(',')
3300
3319
  });
3301
3320
  }
3302
3321
 
3303
- const rotatedAngle = SVGContainer.transform("rotate");
3322
+ const rotatedAngle = SVGContainer.transform('rotate');
3304
3323
 
3305
3324
  if (rotatedAngle) {
3306
3325
  SVGContainer.rotate(-rotatedAngle, 0, 0);
@@ -6087,27 +6106,27 @@ const useSvgSymbol = (symbol, skipOffset) => {
6087
6106
  data,
6088
6107
  offset
6089
6108
  } = symbol;
6090
- const newValue = value instanceof Color.Color ? value.toString("rgba") : value;
6109
+ const newValue = value instanceof Color.Color ? value.toString('rgba') : value;
6091
6110
 
6092
6111
  const newSymbol = _extends({}, JSON.parse(JSON.stringify(symbol)), {
6093
6112
  offset: skipOffset ? DEFAULT_SYMBOL_OFFSET : isSizeClassification(field) ? getOffsetParameterValue(offset) : offset
6094
6113
  });
6095
6114
 
6096
- if (field.indexOf(".") !== -1) {
6115
+ if (field.indexOf('.') !== -1) {
6097
6116
  var _newSymbol$parts$;
6098
6117
 
6099
- const parts = field.split(".");
6118
+ const parts = field.split('.');
6100
6119
 
6101
6120
  if ((_newSymbol$parts$ = newSymbol[parts[0]]) != null && _newSymbol$parts$[parts[1]]) {
6102
6121
  newSymbol[parts[0]][parts[1]] = newValue;
6103
6122
  } else {
6104
6123
  newSymbol[parts[0]] = _extends({}, newSymbol[parts[0]], {
6105
6124
  [parts[1]]: newValue
6106
- }, parts[0] === "background" ? {
6125
+ }, parts[0] === 'background' ? {
6107
6126
  type: newSymbol.background.type,
6108
- id: "symbol-bg"
6109
- } : parts[0] === "figure" ? {
6110
- id: "symbol-figure"
6127
+ id: 'symbol-bg'
6128
+ } : parts[0] === 'figure' ? {
6129
+ id: 'symbol-figure'
6111
6130
  } : {});
6112
6131
  }
6113
6132
  } else {
@@ -6488,7 +6507,11 @@ const LegendChildren = _ref => {
6488
6507
  if (!attribute) return null;
6489
6508
  const hiddenCondition = createHiddenCondition(attribute.name, attribute.type, getClassificationValue(paramValue.symbol, paramValue.title, new ClassificationCondition(paramValue.condition)));
6490
6509
  const legendText = getLegendText({
6491
- title: isRangeCondition(paramValue.condition) ? createValueTitleFromCondition(paramValue, attribute, formatValue, index) : getTitleFromCondition(paramValue.condition),
6510
+ title: isRangeCondition(paramValue.condition) ? createValueTitleFromCondition(paramValue, attribute, formatValue, index) : getTitleFromCondition({
6511
+ condition: paramValue.condition,
6512
+ attribute,
6513
+ formatValue
6514
+ }),
6492
6515
  index,
6493
6516
  isDate: ((_getConditionAttribut = getConditionAttribute(attributes, paramValue.condition)) == null ? void 0 : _getConditionAttribut.type) === 'DateTime'
6494
6517
  });