@evergis/react 4.0.113 → 4.0.115
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/types.d.ts +4 -3
- package/dist/components/Dashboard/utils/index.d.ts +0 -1
- package/dist/index.js +29 -22
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +29 -23
- package/dist/react.esm.js.map +1 -1
- package/dist/utils/format.d.ts +9 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/roundTotalSum.d.ts +2 -0
- package/package.json +2 -2
- package/dist/components/Dashboard/utils/roundTotalSum.d.ts +0 -1
|
@@ -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 {
|
|
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?:
|
|
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?:
|
|
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,23 @@ 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 COMPACT_FRACTION_DIGITS = 1;
|
|
3813
|
+
const roundTotalSum = (value, fractionDigits) => {
|
|
3814
|
+
if (!value)
|
|
3815
|
+
return "";
|
|
3816
|
+
const digits = fractionDigits ?? COMPACT_FRACTION_DIGITS;
|
|
3817
|
+
if (value >= MILLION) {
|
|
3818
|
+
return `${(value / MILLION).toFixed(digits)}M`;
|
|
3819
|
+
}
|
|
3820
|
+
if (value >= TEN_THOUSANDS) {
|
|
3821
|
+
return `${(value / THOUSAND).toFixed(digits)}K`;
|
|
3822
|
+
}
|
|
3823
|
+
return value;
|
|
3824
|
+
};
|
|
3825
|
+
|
|
3809
3826
|
const TIME_ZONE_FORMAT = ' "GMT"z'; // eslint-disable-line
|
|
3810
3827
|
exports.ScalingFactor = void 0;
|
|
3811
3828
|
(function (ScalingFactor) {
|
|
@@ -3934,8 +3951,9 @@ const formatDateValue = (stringFormat, dateValue) => {
|
|
|
3934
3951
|
const timeFormat = (timeOptionValue && dateFns.format(value, showTimeZone ? `${timeOptionValue} zz` : timeOptionValue)) || "";
|
|
3935
3952
|
return dateFormat ? `${dateFormat} ${timeFormat}` : "";
|
|
3936
3953
|
};
|
|
3954
|
+
const appendUnitsLabel = (value, unitsLabel, noUnits) => (unitsLabel && !noUnits ? `${value} ${unitsLabel}` : value)?.toString() || "";
|
|
3937
3955
|
const formatNumberValue = (stringFormat, value, type, noUnits = false) => {
|
|
3938
|
-
const { scalingFactor, rounding, splitDigitGroup, unitsLabel } = stringFormat || {};
|
|
3956
|
+
const { scalingFactor, rounding, splitDigitGroup, roundDigitGroup, unitsLabel } = stringFormat || {};
|
|
3939
3957
|
const isIntValue = [api.AttributeType.Int32, api.AttributeType.Int64].includes(type);
|
|
3940
3958
|
const isDefaultScaling = stringFormat && stringFormat.scalingFactor === +numberOptions[0].value;
|
|
3941
3959
|
let currentValue = value;
|
|
@@ -3945,7 +3963,14 @@ const formatNumberValue = (stringFormat, value, type, noUnits = false) => {
|
|
|
3945
3963
|
if (scalingFactor) {
|
|
3946
3964
|
currentValue *= scalingFactor;
|
|
3947
3965
|
}
|
|
3948
|
-
|
|
3966
|
+
const hasRounding = !lodash.isNil(rounding);
|
|
3967
|
+
const compactValue = roundDigitGroup
|
|
3968
|
+
? roundTotalSum(Number(currentValue), hasRounding ? rounding : undefined)
|
|
3969
|
+
: null;
|
|
3970
|
+
if (typeof compactValue === "string" && compactValue) {
|
|
3971
|
+
return appendUnitsLabel(compactValue, unitsLabel, noUnits);
|
|
3972
|
+
}
|
|
3973
|
+
if (hasRounding && (!isIntValue || !isDefaultScaling)) {
|
|
3949
3974
|
currentValue = currentValue && Number(currentValue).toFixed(rounding);
|
|
3950
3975
|
}
|
|
3951
3976
|
if (splitDigitGroup) {
|
|
@@ -3954,10 +3979,7 @@ const formatNumberValue = (stringFormat, value, type, noUnits = false) => {
|
|
|
3954
3979
|
if (currentValue) {
|
|
3955
3980
|
currentValue = currentValue.toString().replace(".", ",");
|
|
3956
3981
|
}
|
|
3957
|
-
|
|
3958
|
-
currentValue = `${currentValue} ${unitsLabel}`;
|
|
3959
|
-
}
|
|
3960
|
-
return currentValue?.toString() || "";
|
|
3982
|
+
return appendUnitsLabel(currentValue, unitsLabel, noUnits);
|
|
3961
3983
|
};
|
|
3962
3984
|
const formatAttributeValue = ({ t, type, value, stringFormat, noUnits = false }) => {
|
|
3963
3985
|
const isNilValue = lodash.isNil(value);
|
|
@@ -14177,22 +14199,6 @@ const removeDataSource = (dashboardConfiguration, name, pageIndex) => {
|
|
|
14177
14199
|
return newConfig;
|
|
14178
14200
|
};
|
|
14179
14201
|
|
|
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
14202
|
const updateDataSource = (dashboardConfiguration, name, pageIndex, data) => {
|
|
14197
14203
|
const newConfig = JSON.parse(JSON.stringify(dashboardConfiguration));
|
|
14198
14204
|
if (newConfig.dataSources?.length) {
|
|
@@ -15216,6 +15222,7 @@ exports.AttributeGalleryContainer = AttributeGalleryContainer;
|
|
|
15216
15222
|
exports.AttributeLabel = AttributeLabel;
|
|
15217
15223
|
exports.BASE_CONTAINER_STYLE = BASE_CONTAINER_STYLE;
|
|
15218
15224
|
exports.CHART_TYPES = CHART_TYPES;
|
|
15225
|
+
exports.COMPACT_FRACTION_DIGITS = COMPACT_FRACTION_DIGITS;
|
|
15219
15226
|
exports.CONFIG_PAGES_ID = CONFIG_PAGES_ID;
|
|
15220
15227
|
exports.CONFIG_PAGE_ID = CONFIG_PAGE_ID;
|
|
15221
15228
|
exports.CameraContainer = CameraContainer;
|