@evergis/react 4.0.113 → 4.0.114

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.
@@ -4,8 +4,9 @@ import { i18n } from 'i18next';
4
4
  import { PieChartData, BarChartMarker } from '@evergis/charts';
5
5
  import { IconTypesKeys, IOption } from '@evergis/uilib-gl';
6
6
  import { CircleLayerSpecification, FillLayerSpecification, LineLayerSpecification } from 'maplibre-gl';
7
- import { AttributeFormatConfigurationDc, AttributeType, EqlRequestDc, FeatureDc, OgcGeometryType, PagedFeaturesListDc, PositionDc, QueryLayerServiceInfoDc, RemoteTaskStatus, StringSubType, AttributesConfigurationDc } from '@evergis/api';
7
+ import { AttributeType, EqlRequestDc, FeatureDc, OgcGeometryType, PagedFeaturesListDc, PositionDc, QueryLayerServiceInfoDc, RemoteTaskStatus, StringSubType, AttributesConfigurationDc } from '@evergis/api';
8
8
  import { FeatureAttributeValue, EditGeometryType, ThemeName } from '../../types';
9
+ import { AttributeFormatConfiguration } from '../../utils/format';
9
10
  import { InnerContainerProps } from './containers/DataSourceInnerContainer/types';
10
11
  export * from './componentTypes';
11
12
  export * from './branded';
@@ -388,7 +389,7 @@ export interface ConfigDataSourceAttribute {
388
389
  alias?: string;
389
390
  type?: AttributeType;
390
391
  description?: string;
391
- stringFormat?: AttributeFormatConfigurationDc;
392
+ stringFormat?: AttributeFormatConfiguration;
392
393
  }
393
394
  export interface ConfigDataSource {
394
395
  name: string;
@@ -669,6 +670,6 @@ export type ClientFeatureAttribute = {
669
670
  type: AttributeType;
670
671
  readOnly?: boolean;
671
672
  subType?: StringSubType;
672
- stringFormat?: AttributeFormatConfigurationDc;
673
+ stringFormat?: AttributeFormatConfiguration;
673
674
  clientData?: unknown;
674
675
  };
@@ -66,7 +66,6 @@ export * from './mergeAttributeConfigurations';
66
66
  export * from './pieChartTooltipFromAttributes';
67
67
  export * from './pieChartTooltipFromRelatedFeatures';
68
68
  export * from './removeDataSource';
69
- export * from './roundTotalSum';
70
69
  export * from './updateDataSource';
71
70
  export * from './sliceShownOtherItems';
72
71
  export * from './toCssSize';
package/dist/index.js CHANGED
@@ -3806,6 +3806,22 @@ const debounce = (callback, delay) => {
3806
3806
  };
3807
3807
  };
3808
3808
 
3809
+ const MILLION = 1000000;
3810
+ const TEN_THOUSANDS = 10000;
3811
+ const THOUSAND = 1000;
3812
+ const FRACTION_DIGITS = 1;
3813
+ const roundTotalSum = (value) => {
3814
+ if (!value)
3815
+ return "";
3816
+ if (value >= MILLION) {
3817
+ return `${(value / MILLION).toFixed(FRACTION_DIGITS)}M`;
3818
+ }
3819
+ if (value >= TEN_THOUSANDS) {
3820
+ return `${(value / THOUSAND).toFixed(FRACTION_DIGITS)}K`;
3821
+ }
3822
+ return value;
3823
+ };
3824
+
3809
3825
  const TIME_ZONE_FORMAT = ' "GMT"z'; // eslint-disable-line
3810
3826
  exports.ScalingFactor = void 0;
3811
3827
  (function (ScalingFactor) {
@@ -3934,8 +3950,9 @@ const formatDateValue = (stringFormat, dateValue) => {
3934
3950
  const timeFormat = (timeOptionValue && dateFns.format(value, showTimeZone ? `${timeOptionValue} zz` : timeOptionValue)) || "";
3935
3951
  return dateFormat ? `${dateFormat} ${timeFormat}` : "";
3936
3952
  };
3953
+ const appendUnitsLabel = (value, unitsLabel, noUnits) => (unitsLabel && !noUnits ? `${value} ${unitsLabel}` : value)?.toString() || "";
3937
3954
  const formatNumberValue = (stringFormat, value, type, noUnits = false) => {
3938
- const { scalingFactor, rounding, splitDigitGroup, unitsLabel } = stringFormat || {};
3955
+ const { scalingFactor, rounding, splitDigitGroup, roundDigitGroup, unitsLabel } = stringFormat || {};
3939
3956
  const isIntValue = [api.AttributeType.Int32, api.AttributeType.Int64].includes(type);
3940
3957
  const isDefaultScaling = stringFormat && stringFormat.scalingFactor === +numberOptions[0].value;
3941
3958
  let currentValue = value;
@@ -3945,6 +3962,10 @@ const formatNumberValue = (stringFormat, value, type, noUnits = false) => {
3945
3962
  if (scalingFactor) {
3946
3963
  currentValue *= scalingFactor;
3947
3964
  }
3965
+ const compactValue = roundDigitGroup ? roundTotalSum(Number(currentValue)) : null;
3966
+ if (typeof compactValue === "string" && compactValue) {
3967
+ return appendUnitsLabel(compactValue, unitsLabel, noUnits);
3968
+ }
3948
3969
  if ((rounding || rounding === 0) && (!isIntValue || (isIntValue && !isDefaultScaling))) {
3949
3970
  currentValue = currentValue && Number(currentValue).toFixed(rounding);
3950
3971
  }
@@ -3954,10 +3975,7 @@ const formatNumberValue = (stringFormat, value, type, noUnits = false) => {
3954
3975
  if (currentValue) {
3955
3976
  currentValue = currentValue.toString().replace(".", ",");
3956
3977
  }
3957
- if (unitsLabel && !noUnits) {
3958
- currentValue = `${currentValue} ${unitsLabel}`;
3959
- }
3960
- return currentValue?.toString() || "";
3978
+ return appendUnitsLabel(currentValue, unitsLabel, noUnits);
3961
3979
  };
3962
3980
  const formatAttributeValue = ({ t, type, value, stringFormat, noUnits = false }) => {
3963
3981
  const isNilValue = lodash.isNil(value);
@@ -14177,22 +14195,6 @@ const removeDataSource = (dashboardConfiguration, name, pageIndex) => {
14177
14195
  return newConfig;
14178
14196
  };
14179
14197
 
14180
- const BILLION = 1000000;
14181
- const TEN_THOUSANDS = 10000;
14182
- const THOUSAND = 1000;
14183
- const FRACTION_DIGITS = 1;
14184
- const roundTotalSum = (value) => {
14185
- if (!value)
14186
- return "";
14187
- if (value >= BILLION) {
14188
- return `${(value / BILLION).toFixed(FRACTION_DIGITS)}M`;
14189
- }
14190
- if (value >= TEN_THOUSANDS) {
14191
- return `${(value / THOUSAND).toFixed(FRACTION_DIGITS)}K`;
14192
- }
14193
- return value;
14194
- };
14195
-
14196
14198
  const updateDataSource = (dashboardConfiguration, name, pageIndex, data) => {
14197
14199
  const newConfig = JSON.parse(JSON.stringify(dashboardConfiguration));
14198
14200
  if (newConfig.dataSources?.length) {