@evergis/react 3.1.118 → 3.1.120-alpha.0

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,4 +1,4 @@
1
- import { QueryLayerServiceConfigurationDc } from '@evergis/api';
1
+ import { PagedFeaturesListDc, QueryLayerServiceConfigurationDc } from '@evergis/api';
2
2
  import { ClientFeatureAttribute, ConfigContainerChild, ConfigDataSource, DataSourcePromise, EqlDataSource, FetchedDataSource, SelectedFilters, WidgetType } from '../types';
3
3
  export declare const useDataSources: ({ type: widgetType, config, attributes, filters, layerParams, eqlParameters, }: {
4
4
  type?: WidgetType;
@@ -8,7 +8,7 @@ export declare const useDataSources: ({ type: widgetType, config, attributes, fi
8
8
  layerParams?: Record<string, string>;
9
9
  eqlParameters?: QueryLayerServiceConfigurationDc["eqlParameters"];
10
10
  }) => {
11
- getDataSourcePromises: ({ ds, query, parameters, layerName, limit, condition, url, resourceId }: ConfigDataSource, newFilters?: SelectedFilters, offset?: number) => Promise<EqlDataSource | import('@evergis/api').PagedFeaturesListDc>;
11
+ getDataSourcePromises: ({ ds, query, parameters, layerName, limit, condition, url, resourceId }: ConfigDataSource, newFilters?: SelectedFilters, offset?: number) => Promise<EqlDataSource | PagedFeaturesListDc>;
12
12
  getUpdatingDataSources: () => ConfigDataSource[];
13
13
  getUpdatedDataSources: (responses: DataSourcePromise[], currentDataSources: ConfigDataSource[], otherDataSources: FetchedDataSource[]) => any;
14
14
  zoomToLayersExtent: (layers: Array<{
@@ -1,3 +1,2 @@
1
1
  export * from './classification';
2
- export * from './feature';
3
2
  export * from './icons';
package/dist/index.js CHANGED
@@ -4258,11 +4258,11 @@ const getDataSource = (dataSourceName, dataSources) => dataSources?.find(({ name
4258
4258
  const getDataSourceFilterValue = ({ filterName, filterProp, attributeAlias, dataSource, selectedFilters, }) => {
4259
4259
  if (lodash.isNil(selectedFilters[filterName]))
4260
4260
  return null;
4261
- const feature = dataSource?.features?.find(({ attributes }) => attributes[attributeAlias] ===
4261
+ const feature = dataSource?.features?.find(({ properties }) => properties[attributeAlias] ===
4262
4262
  (Array.isArray(selectedFilters[filterName].value)
4263
4263
  ? selectedFilters[filterName].value[0]
4264
4264
  : selectedFilters[filterName].value));
4265
- return feature?.attributes?.[filterProp];
4265
+ return feature?.properties?.[filterProp];
4266
4266
  };
4267
4267
 
4268
4268
  const getSelectedFilterValue = (filterName, selectedFilters, defaultValue) => {
@@ -5179,73 +5179,6 @@ const useRedrawLayer = () => {
5179
5179
  }, [map]);
5180
5180
  };
5181
5181
 
5182
- const findAttributeInExpression = (expression) => {
5183
- if (Array.isArray(expression) && expression.length === 2 && expression[0] === "get") {
5184
- return [expression[1]];
5185
- }
5186
- return expression.reduce((acc, curr) => {
5187
- if (!Array.isArray(curr)) {
5188
- return acc;
5189
- }
5190
- if (curr[0] === "get") {
5191
- return [...new Set([...acc, curr[1]])];
5192
- }
5193
- return [...new Set([...acc, ...findAttributeInExpression(curr)])];
5194
- }, []);
5195
- };
5196
-
5197
- const getActualExtrusionHeight = (paint) => {
5198
- return Array.isArray(paint?.["fill-extrusion-height"]) && paint?.["fill-extrusion-height"][0] === "+"
5199
- ? paint?.["fill-extrusion-height"][1]
5200
- : paint?.["fill-extrusion-height"];
5201
- };
5202
-
5203
- const extractAttributesFromObject = (obj) => {
5204
- if (!obj || lodash.isEmpty(obj)) {
5205
- return [];
5206
- }
5207
- return Object.entries(obj).reduce((acc, [, value]) => {
5208
- if (!Array.isArray(value)) {
5209
- return acc;
5210
- }
5211
- return [...new Set([...acc, ...findAttributeInExpression(value)])];
5212
- }, []);
5213
- };
5214
- const parseClientStyle = (style) => {
5215
- if (!style) {
5216
- return [];
5217
- }
5218
- return style?.items?.reduce((acc, curr) => {
5219
- const paintAttributes = extractAttributesFromObject(curr.paint);
5220
- const layoutAttributes = extractAttributesFromObject(curr.layout);
5221
- const filterAttributes = curr.filter
5222
- ? findAttributeInExpression(curr.filter)
5223
- : [];
5224
- return [...new Set([...acc, ...paintAttributes, ...layoutAttributes, ...filterAttributes])];
5225
- }, []);
5226
- };
5227
-
5228
- const convertSpToTurfFeature = (geometry) => {
5229
- if (!geometry) {
5230
- return;
5231
- }
5232
- switch (geometry.type) {
5233
- case api.GeometryType.Point:
5234
- return turf.point(geometry.coordinates);
5235
- case api.GeometryType.Multipoint:
5236
- return turf.multiPoint(geometry.coordinates);
5237
- case api.GeometryType.Polyline:
5238
- return turf.multiLineString(geometry.coordinates);
5239
- case api.GeometryType.Polygon:
5240
- case api.GeometryType.Envelope:
5241
- return turf.polygon(geometry.coordinates);
5242
- case api.GeometryType.MultiPolygon:
5243
- return turf.multiPolygon(geometry.coordinates);
5244
- case api.GeometryType.GeometryCollection:
5245
- return turf.geometryCollection(geometry.geometries);
5246
- }
5247
- };
5248
-
5249
5182
  const useZoomToFeatures = () => {
5250
5183
  const { map } = useMapContext();
5251
5184
  return React.useCallback((features, padding) => {
@@ -5254,7 +5187,7 @@ const useZoomToFeatures = () => {
5254
5187
  }
5255
5188
  const currentFeatureCenter = turf.bbox({
5256
5189
  type: "FeatureCollection",
5257
- features: features.map(feature => convertSpToTurfFeature(feature.geometry)),
5190
+ features: features,
5258
5191
  });
5259
5192
  map.current.fitBounds(currentFeatureCenter, { padding: padding ?? 150 });
5260
5193
  }, [map]);
@@ -5528,7 +5461,7 @@ const LayerTree = ({ layers, onlyMainTools }) => {
5528
5461
  page.layers = treeNodesToProjectItems(page.layers, updatedNodes);
5529
5462
  updateProject(newProjectInfo);
5530
5463
  }, [pageIndex, projectInfo, updateProject]);
5531
- return (jsxRuntime.jsx(uilibGl.DraggableTree, { nodes: nodes, disableDrag: onlyMainTools, options: { pastePlaceholderHeight: "0.0625rem" }, onUpdate: onUpdate }));
5464
+ return (jsxRuntime.jsx(uilibGl.DraggableTree, { nodes: nodes, disableDrag: onlyMainTools, options: { pastePlaceholderHeight: "0.025rem" }, onUpdate: onUpdate }));
5532
5465
  };
5533
5466
 
5534
5467
  const LayersListWrapper = styled(uilibGl.Flex) `
@@ -5541,6 +5474,7 @@ const LayerListContainer = styled(uilibGl.Flex) `
5541
5474
  flex-grow: 1;
5542
5475
  height: 100%;
5543
5476
  box-sizing: border-box;
5477
+ padding-top: 0.25rem;
5544
5478
  `;
5545
5479
 
5546
5480
  const ElementValueWrapper = styled.div `
@@ -5911,9 +5845,9 @@ function getValueIndex(items, attributes) {
5911
5845
  const getChartMarkers = (items, markers, dataSources) => {
5912
5846
  if (typeof markers === "string") {
5913
5847
  const dataSource = getDataSource(markers, dataSources);
5914
- return dataSource?.features?.map(({ attributes }) => ({
5915
- ...attributes,
5916
- value: getValueIndex(items, attributes),
5848
+ return dataSource?.features?.map(({ properties }) => ({
5849
+ ...properties,
5850
+ value: getValueIndex(items, properties),
5917
5851
  })) || [];
5918
5852
  }
5919
5853
  return (markers?.map(marker => ({
@@ -6350,19 +6284,19 @@ const DataSourceProgressContainer = React.memo(({ config, elementConfig, type, i
6350
6284
  const totalUnits = React.useMemo(() => unitsElement?.type === "attributeUnits"
6351
6285
  ? attributes?.find(({ attributeName }) => attributeName === unitsElement.attributeName)?.stringFormat
6352
6286
  ?.unitsLabel
6353
- : dataSource?.features?.[0]?.attributes[unitsElement?.attributeName], [attributes, dataSource?.features, unitsElement?.attributeName, unitsElement?.type]);
6287
+ : dataSource?.features?.[0]?.properties[unitsElement?.attributeName], [attributes, dataSource?.features, unitsElement?.attributeName, unitsElement?.type]);
6354
6288
  const totalValue = React.useMemo(() => {
6355
6289
  const attribute = attributes?.find(({ attributeName }) => attributeName === valueElement?.attributeName);
6356
6290
  const { type: attributeType, stringFormat } = attribute || {};
6357
- const result = dataSource?.features?.reduce((total, feature) => total + feature.attributes[valueElement?.attributeName], 0);
6291
+ const result = dataSource?.features?.reduce((total, feature) => total + feature.properties[valueElement?.attributeName], 0);
6358
6292
  return formatAttributeValue({ t, type: attributeType, value: result, stringFormat, noUnits: !!unitsElement?.type });
6359
6293
  }, [attributes, dataSource?.features, unitsElement?.type, valueElement?.attributeName]);
6360
6294
  const currentMaxValue = React.useMemo(() => {
6361
6295
  if (typeof maxValue === "string") {
6362
- return dataSource?.features?.[0]?.attributes[maxValue];
6296
+ return dataSource?.features?.[0]?.properties[maxValue];
6363
6297
  }
6364
6298
  return (maxValue ||
6365
- dataSource?.features?.reduce((result, item) => Math.max(result, item.attributes[valueElement?.attributeName]), 0));
6299
+ dataSource?.features?.reduce((result, item) => Math.max(result, item.properties[valueElement?.attributeName]), 0));
6366
6300
  }, [dataSource?.features, maxValue, valueElement?.attributeName]);
6367
6301
  if (!relatedDataSource)
6368
6302
  return null;
@@ -7746,7 +7680,7 @@ const LayerIconContainer = styled.div `
7746
7680
  align-items: center;
7747
7681
  justify-content: center;
7748
7682
  min-width: 2rem;
7749
- margin-right: 0.75rem;
7683
+ margin-right: 0.5rem;
7750
7684
  `;
7751
7685
  const AlertIconContainer = styled(uilibGl.Flex) `
7752
7686
  align-items: center;
@@ -8179,7 +8113,7 @@ const useCameraAttribute = (cameraId) => {
8179
8113
  // const { api } = useGlobalContext();
8180
8114
  const [currentIndex, setCurrentIndex] = React.useState(0);
8181
8115
  const [currentPage, setCurrentPage] = React.useState(0);
8182
- const [timeline, /* setTimeline*/] = React.useState([]);
8116
+ const [timeline, /* setTimeline*/] = React.useState /* <ArchiveTimelineItemDc[]>*/([]);
8183
8117
  const [isLoadingSnapshot, setLoadingSnapshot] = React.useState(false);
8184
8118
  const [isLoadingTimeline, setLoadingTimeline] = React.useState(false);
8185
8119
  const [isOpenGallery, toggleGallery] = useToggle();
@@ -8323,8 +8257,8 @@ const ElementControl = ({ elementConfig }) => {
8323
8257
  return [];
8324
8258
  }
8325
8259
  return dataSource.features.map(item => ({
8326
- value: item.attributes?.[attributeName] || "",
8327
- text: item.attributes?.[control?.attributeAlias || attributeName] || "",
8260
+ value: item.properties?.[attributeName] || "",
8261
+ text: item.properties?.[control?.attributeAlias || attributeName] || "",
8328
8262
  }));
8329
8263
  }, [control?.attributeAlias, dataSource?.features, attributeName]);
8330
8264
  const isDisabled = React.useMemo(() => {
@@ -8652,7 +8586,7 @@ const ElementSlideshow = ({ elementConfig, type, renderElement }) => {
8652
8586
  const images = React.useMemo(() => {
8653
8587
  const dataSource = relatedDataSource ? dataSources?.find(({ name }) => name === relatedDataSource) : null;
8654
8588
  const array = dataSource
8655
- ? dataSource.features.map(feature => feature.attributes[attributeName])
8589
+ ? dataSource.features.map(feature => feature.properties[attributeName])
8656
8590
  : getSlideshowImages({
8657
8591
  element: elementConfig,
8658
8592
  attribute: attributes?.find(({ name }) => name === attributeName),
@@ -9045,7 +8979,7 @@ function getFeatureAttributes(feature = {}, layer, dataSource) {
9045
8979
  if (!layerDefinition) {
9046
8980
  return [];
9047
8981
  }
9048
- const currentAttributes = !feature && dataSource ? dataSource.features[0].attributes : feature?.attributes;
8982
+ const currentAttributes = !feature && dataSource ? dataSource.features[0].properties : feature?.properties;
9049
8983
  const { id: idValue } = feature || {};
9050
8984
  const { idAttribute, attributes } = layerDefinition || {};
9051
8985
  const layerAttributes = idAttribute
@@ -9062,7 +8996,7 @@ function getFeatureAttributes(feature = {}, layer, dataSource) {
9062
8996
  readOnly: true,
9063
8997
  }
9064
8998
  : {
9065
- value: currentAttributes?.[attributeName] || dataSource?.features?.[0]?.attributes?.[attributeName],
8999
+ value: currentAttributes?.[attributeName] || dataSource?.features?.[0]?.properties?.[attributeName],
9066
9000
  readOnly: isCalculated || !isEditable,
9067
9001
  };
9068
9002
  const clientData = layer.layerAttributes?.find(layerAttribute => layerAttribute.attributeName === attributeName)?.clientData;
@@ -9234,10 +9168,10 @@ const getListOptions = (items, filterName, configFilters) => {
9234
9168
  if (!filter)
9235
9169
  return [];
9236
9170
  return (items?.map(item => ({
9237
- text: item.attributes[filter.attributeAlias || DEFAULT_ATTRIBUTE_NAME],
9238
- value: item.attributes[filter.attributeValue || DEFAULT_ATTRIBUTE_NAME],
9239
- min: filter.attributeMin ? item.attributes[filter.attributeMin] : null,
9240
- max: filter.attributeMax ? item.attributes[filter.attributeMax] : null,
9171
+ text: item.properties[filter.attributeAlias || DEFAULT_ATTRIBUTE_NAME],
9172
+ value: item.properties[filter.attributeValue || DEFAULT_ATTRIBUTE_NAME],
9173
+ min: filter.attributeMin ? item.properties[filter.attributeMin] : null,
9174
+ max: filter.attributeMax ? item.properties[filter.attributeMax] : null,
9241
9175
  })) || []);
9242
9176
  };
9243
9177
 
@@ -9549,8 +9483,8 @@ const RangeDateFilter = ({ type, filter }) => {
9549
9483
  const { filterName, label, minValue, maxValue, withTime } = filter.options;
9550
9484
  const configFilter = React.useMemo(() => getConfigFilter(filterName, configFilters), [configFilters, filterName]);
9551
9485
  const dataSource = React.useMemo(() => getDataSource(configFilter?.relatedDataSource, dataSources), [configFilter?.relatedDataSource, dataSources]);
9552
- const { minFromData, maxFromData } = React.useMemo(() => dataSource?.features?.reduce((prev, { attributes }) => {
9553
- const date = getDate(attributes[configFilter?.attributeValue]);
9486
+ const { minFromData, maxFromData } = React.useMemo(() => dataSource?.features?.reduce((prev, { properties }) => {
9487
+ const date = getDate(properties[configFilter?.attributeValue]);
9554
9488
  return {
9555
9489
  minFromData: !prev.minFromData ? date : date < prev.minFromData ? date : prev.minFromData,
9556
9490
  maxFromData: !prev.maxFromData ? date : date > prev.maxFromData ? date : prev.maxFromData
@@ -9771,7 +9705,7 @@ const ChipsFilter = ({ type, filter, elementConfig, }) => {
9771
9705
  return [];
9772
9706
  const features = dataSource.features;
9773
9707
  return features.map(feature => {
9774
- const attrs = feature.attributes;
9708
+ const attrs = feature.properties;
9775
9709
  const text = attrs[configFilter.attributeAlias || DEFAULT_ATTRIBUTE_NAME];
9776
9710
  const value = attrs[configFilter.attributeValue || DEFAULT_ATTRIBUTE_NAME];
9777
9711
  const chipIcon = iconAttribute
@@ -10476,7 +10410,7 @@ const useDataSources = ({ type: widgetType, config, attributes, filters, layerPa
10476
10410
  const queryResponse = await api.eql.getPagedQueryResult({ saveInHistory: false }, getProps);
10477
10411
  const descriptionResponse = await api.eql.getQueryDescription(getProps);
10478
10412
  return {
10479
- items: queryResponse.items,
10413
+ items: queryResponse.features,
10480
10414
  attributeDefinition: descriptionResponse,
10481
10415
  };
10482
10416
  }
@@ -10524,7 +10458,7 @@ const useDataSources = ({ type: widgetType, config, attributes, filters, layerPa
10524
10458
  !!currentDataSources[index].url ||
10525
10459
  !!currentDataSources[index].resourceId;
10526
10460
  newDataSources[index].layerName = currentDataSources[index].layerName;
10527
- const items = response.status === "rejected" ? null : response.value?.items || response.items;
10461
+ const items = response.status === "rejected" ? null : response.value?.features || response.items;
10528
10462
  newDataSources[index].features =
10529
10463
  response.status === "rejected"
10530
10464
  ? null
@@ -10955,7 +10889,7 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
10955
10889
  const attribute = layerInfo?.layerDefinition.attributes[attributeName];
10956
10890
  const dataSource = getDataSource(dataSourceName, dataSources);
10957
10891
  const units = attributeUnits
10958
- ? dataSource?.features?.[0]?.attributes?.[attributeUnits]
10892
+ ? dataSource?.features?.[0]?.properties?.[attributeUnits]
10959
10893
  : attribute?.stringFormat?.unitsLabel;
10960
10894
  const formatValue = attribute
10961
10895
  ? formatAttributeValue({ t, type: attribute.type, value, stringFormat: attribute.stringFormat, noUnits: true })
@@ -11554,6 +11488,52 @@ const getClientStyleItemPrefixSuffix = (geometryType, itemType) => {
11554
11488
  }
11555
11489
  };
11556
11490
 
11491
+ const findAttributeInExpression = (expression) => {
11492
+ if (Array.isArray(expression) && expression.length === 2 && expression[0] === "get") {
11493
+ return [expression[1]];
11494
+ }
11495
+ return expression.reduce((acc, curr) => {
11496
+ if (!Array.isArray(curr)) {
11497
+ return acc;
11498
+ }
11499
+ if (curr[0] === "get") {
11500
+ return [...new Set([...acc, curr[1]])];
11501
+ }
11502
+ return [...new Set([...acc, ...findAttributeInExpression(curr)])];
11503
+ }, []);
11504
+ };
11505
+
11506
+ const getActualExtrusionHeight = (paint) => {
11507
+ return Array.isArray(paint?.["fill-extrusion-height"]) && paint?.["fill-extrusion-height"][0] === "+"
11508
+ ? paint?.["fill-extrusion-height"][1]
11509
+ : paint?.["fill-extrusion-height"];
11510
+ };
11511
+
11512
+ const extractAttributesFromObject = (obj) => {
11513
+ if (!obj || lodash.isEmpty(obj)) {
11514
+ return [];
11515
+ }
11516
+ return Object.entries(obj).reduce((acc, [, value]) => {
11517
+ if (!Array.isArray(value)) {
11518
+ return acc;
11519
+ }
11520
+ return [...new Set([...acc, ...findAttributeInExpression(value)])];
11521
+ }, []);
11522
+ };
11523
+ const parseClientStyle = (style) => {
11524
+ if (!style) {
11525
+ return [];
11526
+ }
11527
+ return style?.items?.reduce((acc, curr) => {
11528
+ const paintAttributes = extractAttributesFromObject(curr.paint);
11529
+ const layoutAttributes = extractAttributesFromObject(curr.layout);
11530
+ const filterAttributes = curr.filter
11531
+ ? findAttributeInExpression(curr.filter)
11532
+ : [];
11533
+ return [...new Set([...acc, ...paintAttributes, ...layoutAttributes, ...filterAttributes])];
11534
+ }, []);
11535
+ };
11536
+
11557
11537
  const VectorLayer = ({ layer, tileUrl, visible, beforeId, getLayerTempStyle, filterVersion, }) => {
11558
11538
  const clientStyle = layer?.configuration?.clientStyle;
11559
11539
  const { idAttribute, geometryType } = layer.layerDefinition || {};
@@ -11903,7 +11883,6 @@ exports.applyQueryFilters = applyQueryFilters;
11903
11883
  exports.applyVarsToCondition = applyVarsToCondition;
11904
11884
  exports.checkEqualOrIncludes = checkEqualOrIncludes;
11905
11885
  exports.checkIsLoading = checkIsLoading;
11906
- exports.convertSpToTurfFeature = convertSpToTurfFeature;
11907
11886
  exports.createConfigLayer = createConfigLayer;
11908
11887
  exports.createConfigPage = createConfigPage;
11909
11888
  exports.createNewPageId = createNewPageId;