@evergis/react 3.1.124 → 3.1.126-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.
- package/dist/components/Dashboard/components/AddFeatureButton/index.d.ts +2 -2
- package/dist/components/Dashboard/hooks/useDataSources.d.ts +2 -2
- package/dist/components/Dashboard/hooks/useEditControl.d.ts +6 -0
- package/dist/components/Dashboard/types.d.ts +7 -11
- package/dist/components/Dashboard/utils/getControlTemplateName.d.ts +2 -2
- package/dist/components/Layer/types.d.ts +2 -2
- package/dist/components/Layer/utils/getClientStyleItemPrefixSuffix.d.ts +2 -2
- package/dist/core/index.d.ts +0 -1
- package/dist/hooks/map/useLayerParams.d.ts +1 -2
- package/dist/index.js +172 -166
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +175 -168
- package/dist/react.esm.js.map +1 -1
- package/dist/types/layer.d.ts +2 -2
- package/package.json +4 -4
- package/dist/components/Dashboard/hooks/useEditAttribute.d.ts +0 -6
- package/dist/core/feature/convertSpToTurfFeature.d.ts +0 -3
- package/dist/core/feature/index.d.ts +0 -1
package/dist/index.js
CHANGED
|
@@ -4264,11 +4264,11 @@ const getDataSource = (dataSourceName, dataSources) => dataSources?.find(({ name
|
|
|
4264
4264
|
const getDataSourceFilterValue = ({ filterName, filterProp, attributeAlias, dataSource, selectedFilters, }) => {
|
|
4265
4265
|
if (lodash.isNil(selectedFilters[filterName]))
|
|
4266
4266
|
return null;
|
|
4267
|
-
const feature = dataSource?.features?.find(({
|
|
4267
|
+
const feature = dataSource?.features?.find(({ properties }) => properties[attributeAlias] ===
|
|
4268
4268
|
(Array.isArray(selectedFilters[filterName].value)
|
|
4269
4269
|
? selectedFilters[filterName].value[0]
|
|
4270
4270
|
: selectedFilters[filterName].value));
|
|
4271
|
-
return feature?.
|
|
4271
|
+
return feature?.properties?.[filterProp];
|
|
4272
4272
|
};
|
|
4273
4273
|
|
|
4274
4274
|
const getSelectedFilterValue = (filterName, selectedFilters, defaultValue) => {
|
|
@@ -4386,9 +4386,12 @@ const createConfigPage = (props) => {
|
|
|
4386
4386
|
};
|
|
4387
4387
|
|
|
4388
4388
|
const getAttributesConfiguration = (layer) => {
|
|
4389
|
-
const configuration = layer?.configuration ??
|
|
4389
|
+
const configuration = layer?.configuration ??
|
|
4390
|
+
{};
|
|
4390
4391
|
const emptyAttributesConfiguration = {
|
|
4391
|
-
geometryAttribute: layer?.geometryType === api.
|
|
4392
|
+
geometryAttribute: layer?.geometryType === api.OgcGeometryType.Unknown
|
|
4393
|
+
? undefined
|
|
4394
|
+
: GEOMETRY_ATTRIBUTE,
|
|
4392
4395
|
idAttribute: DEFAULT_ID_ATTRIBUTE_NAME,
|
|
4393
4396
|
tableName: "",
|
|
4394
4397
|
};
|
|
@@ -4397,7 +4400,8 @@ const getAttributesConfiguration = (layer) => {
|
|
|
4397
4400
|
}
|
|
4398
4401
|
return {
|
|
4399
4402
|
...emptyAttributesConfiguration,
|
|
4400
|
-
...(configuration
|
|
4403
|
+
...(configuration
|
|
4404
|
+
.attributesConfiguration || {}),
|
|
4401
4405
|
};
|
|
4402
4406
|
};
|
|
4403
4407
|
|
|
@@ -4407,7 +4411,7 @@ const getLayerDefinition = (layer) => {
|
|
|
4407
4411
|
attributes: {},
|
|
4408
4412
|
geometryAttribute,
|
|
4409
4413
|
idAttribute,
|
|
4410
|
-
geometryType: api.
|
|
4414
|
+
geometryType: api.OgcGeometryType.Unknown,
|
|
4411
4415
|
titleAttribute: "",
|
|
4412
4416
|
};
|
|
4413
4417
|
if (!isLayerService(layer) || !("layerDefinition" in layer)) {
|
|
@@ -5185,73 +5189,6 @@ const useRedrawLayer = () => {
|
|
|
5185
5189
|
}, [map]);
|
|
5186
5190
|
};
|
|
5187
5191
|
|
|
5188
|
-
const findAttributeInExpression = (expression) => {
|
|
5189
|
-
if (Array.isArray(expression) && expression.length === 2 && expression[0] === "get") {
|
|
5190
|
-
return [expression[1]];
|
|
5191
|
-
}
|
|
5192
|
-
return expression.reduce((acc, curr) => {
|
|
5193
|
-
if (!Array.isArray(curr)) {
|
|
5194
|
-
return acc;
|
|
5195
|
-
}
|
|
5196
|
-
if (curr[0] === "get") {
|
|
5197
|
-
return [...new Set([...acc, curr[1]])];
|
|
5198
|
-
}
|
|
5199
|
-
return [...new Set([...acc, ...findAttributeInExpression(curr)])];
|
|
5200
|
-
}, []);
|
|
5201
|
-
};
|
|
5202
|
-
|
|
5203
|
-
const getActualExtrusionHeight = (paint) => {
|
|
5204
|
-
return Array.isArray(paint?.["fill-extrusion-height"]) && paint?.["fill-extrusion-height"][0] === "+"
|
|
5205
|
-
? paint?.["fill-extrusion-height"][1]
|
|
5206
|
-
: paint?.["fill-extrusion-height"];
|
|
5207
|
-
};
|
|
5208
|
-
|
|
5209
|
-
const extractAttributesFromObject = (obj) => {
|
|
5210
|
-
if (!obj || lodash.isEmpty(obj)) {
|
|
5211
|
-
return [];
|
|
5212
|
-
}
|
|
5213
|
-
return Object.entries(obj).reduce((acc, [, value]) => {
|
|
5214
|
-
if (!Array.isArray(value)) {
|
|
5215
|
-
return acc;
|
|
5216
|
-
}
|
|
5217
|
-
return [...new Set([...acc, ...findAttributeInExpression(value)])];
|
|
5218
|
-
}, []);
|
|
5219
|
-
};
|
|
5220
|
-
const parseClientStyle = (style) => {
|
|
5221
|
-
if (!style) {
|
|
5222
|
-
return [];
|
|
5223
|
-
}
|
|
5224
|
-
return style?.items?.reduce((acc, curr) => {
|
|
5225
|
-
const paintAttributes = extractAttributesFromObject(curr.paint);
|
|
5226
|
-
const layoutAttributes = extractAttributesFromObject(curr.layout);
|
|
5227
|
-
const filterAttributes = curr.filter
|
|
5228
|
-
? findAttributeInExpression(curr.filter)
|
|
5229
|
-
: [];
|
|
5230
|
-
return [...new Set([...acc, ...paintAttributes, ...layoutAttributes, ...filterAttributes])];
|
|
5231
|
-
}, []);
|
|
5232
|
-
};
|
|
5233
|
-
|
|
5234
|
-
const convertSpToTurfFeature = (geometry) => {
|
|
5235
|
-
if (!geometry) {
|
|
5236
|
-
return;
|
|
5237
|
-
}
|
|
5238
|
-
switch (geometry.type) {
|
|
5239
|
-
case api.GeometryType.Point:
|
|
5240
|
-
return turf.point(geometry.coordinates);
|
|
5241
|
-
case api.GeometryType.Multipoint:
|
|
5242
|
-
return turf.multiPoint(geometry.coordinates);
|
|
5243
|
-
case api.GeometryType.Polyline:
|
|
5244
|
-
return turf.multiLineString(geometry.coordinates);
|
|
5245
|
-
case api.GeometryType.Polygon:
|
|
5246
|
-
case api.GeometryType.Envelope:
|
|
5247
|
-
return turf.polygon(geometry.coordinates);
|
|
5248
|
-
case api.GeometryType.MultiPolygon:
|
|
5249
|
-
return turf.multiPolygon(geometry.coordinates);
|
|
5250
|
-
case api.GeometryType.GeometryCollection:
|
|
5251
|
-
return turf.geometryCollection(geometry.geometries);
|
|
5252
|
-
}
|
|
5253
|
-
};
|
|
5254
|
-
|
|
5255
5192
|
const useZoomToFeatures = () => {
|
|
5256
5193
|
const { map } = useMapContext();
|
|
5257
5194
|
return React.useCallback((features, padding) => {
|
|
@@ -5260,7 +5197,7 @@ const useZoomToFeatures = () => {
|
|
|
5260
5197
|
}
|
|
5261
5198
|
const currentFeatureCenter = turf.bbox({
|
|
5262
5199
|
type: "FeatureCollection",
|
|
5263
|
-
features: features
|
|
5200
|
+
features: features,
|
|
5264
5201
|
});
|
|
5265
5202
|
map.current.fitBounds(currentFeatureCenter, { padding: padding ?? 150 });
|
|
5266
5203
|
}, [map]);
|
|
@@ -5918,9 +5855,9 @@ function getValueIndex(items, attributes) {
|
|
|
5918
5855
|
const getChartMarkers = (items, markers, dataSources) => {
|
|
5919
5856
|
if (typeof markers === "string") {
|
|
5920
5857
|
const dataSource = getDataSource(markers, dataSources);
|
|
5921
|
-
return dataSource?.features?.map(({
|
|
5922
|
-
...
|
|
5923
|
-
value: getValueIndex(items,
|
|
5858
|
+
return dataSource?.features?.map(({ properties }) => ({
|
|
5859
|
+
...properties,
|
|
5860
|
+
value: getValueIndex(items, properties),
|
|
5924
5861
|
})) || [];
|
|
5925
5862
|
}
|
|
5926
5863
|
return (markers?.map(marker => ({
|
|
@@ -6087,8 +6024,8 @@ const useRenderContainerItem = (type, renderElement) => {
|
|
|
6087
6024
|
return React.useCallback((elementConfig, attribute) => {
|
|
6088
6025
|
const { id, options, style, children } = elementConfig || {};
|
|
6089
6026
|
const { hideEmpty, innerTemplateStyle } = options || {};
|
|
6090
|
-
const hasUnits = children?.some(
|
|
6091
|
-
const iconIndex = children?.findIndex(
|
|
6027
|
+
const hasUnits = children?.some(item => item.id === "units");
|
|
6028
|
+
const iconIndex = children?.findIndex(item => item.id === "icon");
|
|
6092
6029
|
const icon = children?.[iconIndex];
|
|
6093
6030
|
const hasIcon = !!icon;
|
|
6094
6031
|
const elementChildren = elementConfig?.children?.map(child => ({
|
|
@@ -6357,19 +6294,19 @@ const DataSourceProgressContainer = React.memo(({ config, elementConfig, type, i
|
|
|
6357
6294
|
const totalUnits = React.useMemo(() => unitsElement?.type === "attributeUnits"
|
|
6358
6295
|
? attributes?.find(({ attributeName }) => attributeName === unitsElement.attributeName)?.stringFormat
|
|
6359
6296
|
?.unitsLabel
|
|
6360
|
-
: dataSource?.features?.[0]?.
|
|
6297
|
+
: dataSource?.features?.[0]?.properties[unitsElement?.attributeName], [attributes, dataSource?.features, unitsElement?.attributeName, unitsElement?.type]);
|
|
6361
6298
|
const totalValue = React.useMemo(() => {
|
|
6362
6299
|
const attribute = attributes?.find(({ attributeName }) => attributeName === valueElement?.attributeName);
|
|
6363
6300
|
const { type: attributeType, stringFormat } = attribute || {};
|
|
6364
|
-
const result = dataSource?.features?.reduce((total, feature) => total + feature.
|
|
6301
|
+
const result = dataSource?.features?.reduce((total, feature) => total + feature.properties[valueElement?.attributeName], 0);
|
|
6365
6302
|
return formatAttributeValue({ t, type: attributeType, value: result, stringFormat, noUnits: !!unitsElement?.type });
|
|
6366
6303
|
}, [attributes, dataSource?.features, unitsElement?.type, valueElement?.attributeName]);
|
|
6367
6304
|
const currentMaxValue = React.useMemo(() => {
|
|
6368
6305
|
if (typeof maxValue === "string") {
|
|
6369
|
-
return dataSource?.features?.[0]?.
|
|
6306
|
+
return dataSource?.features?.[0]?.properties[maxValue];
|
|
6370
6307
|
}
|
|
6371
6308
|
return (maxValue ||
|
|
6372
|
-
dataSource?.features?.reduce((result, item) => Math.max(result, item.
|
|
6309
|
+
dataSource?.features?.reduce((result, item) => Math.max(result, item.properties[valueElement?.attributeName]), 0));
|
|
6373
6310
|
}, [dataSource?.features, maxValue, valueElement?.attributeName]);
|
|
6374
6311
|
if (!relatedDataSource)
|
|
6375
6312
|
return null;
|
|
@@ -7391,24 +7328,28 @@ const EditContainer = ({ type, elementConfig, renderElement }) => {
|
|
|
7391
7328
|
const getControlTemplateName = (type) => {
|
|
7392
7329
|
switch (type) {
|
|
7393
7330
|
case "dropdown":
|
|
7394
|
-
default:
|
|
7331
|
+
default:
|
|
7332
|
+
return exports.ContainerTemplate.EditDropdown;
|
|
7395
7333
|
}
|
|
7396
7334
|
};
|
|
7397
7335
|
|
|
7398
7336
|
const EditGroupContainer = React.memo(({ type, elementConfig, renderElement }) => {
|
|
7399
7337
|
const { config, attributes, layerInfo, expandedContainers } = useWidgetContext(type);
|
|
7400
7338
|
const getRenderContainerItem = useRenderContainerItem(type, renderElement);
|
|
7401
|
-
const {
|
|
7402
|
-
const {
|
|
7339
|
+
const { options } = elementConfig || {};
|
|
7340
|
+
const { controls } = options || {};
|
|
7403
7341
|
const renderContainer = React.useCallback((attribute) => {
|
|
7404
|
-
const
|
|
7342
|
+
const control = controls?.find(({ targetAttributeName }) => targetAttributeName === attribute);
|
|
7405
7343
|
const itemAttribute = attributes.find(({ name }) => name === attribute);
|
|
7406
|
-
const templateName =
|
|
7407
|
-
? getControlTemplateName(
|
|
7344
|
+
const templateName = control?.type
|
|
7345
|
+
? getControlTemplateName(control.type)
|
|
7408
7346
|
: getTemplateNameFromAttribute(itemAttribute);
|
|
7409
7347
|
const itemConfig = {
|
|
7410
7348
|
...elementConfig,
|
|
7411
|
-
children: elementConfig.children.map(child => ({
|
|
7349
|
+
children: elementConfig.children.map(child => ({
|
|
7350
|
+
...child,
|
|
7351
|
+
attributeName: attribute,
|
|
7352
|
+
})),
|
|
7412
7353
|
templateName,
|
|
7413
7354
|
};
|
|
7414
7355
|
const { expandable, expanded } = elementConfig.options;
|
|
@@ -7418,72 +7359,84 @@ const EditGroupContainer = React.memo(({ type, elementConfig, renderElement }) =
|
|
|
7418
7359
|
return null;
|
|
7419
7360
|
}
|
|
7420
7361
|
return (jsxRuntime.jsx(ContainerTemplateValue, { id: attribute, type: type, config: config, elementConfig: itemConfig, layerInfo: layerInfo, attributes: attributes, innerComponent: getContainerComponent(templateName), isVisible: isVisibleContainer(id, expandable, expanded, expandedContainers), renderElement: render }, attribute));
|
|
7421
|
-
}, [
|
|
7422
|
-
|
|
7362
|
+
}, [
|
|
7363
|
+
controls,
|
|
7364
|
+
attributes,
|
|
7365
|
+
elementConfig,
|
|
7366
|
+
getRenderContainerItem,
|
|
7367
|
+
type,
|
|
7368
|
+
config,
|
|
7369
|
+
layerInfo,
|
|
7370
|
+
expandedContainers,
|
|
7371
|
+
]);
|
|
7372
|
+
return controls?.length ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: controls.map(({ targetAttributeName }) => renderContainer(targetAttributeName)) })) : (renderContainer());
|
|
7423
7373
|
});
|
|
7424
7374
|
|
|
7425
|
-
const
|
|
7375
|
+
const useEditControl = (type, elementConfig) => {
|
|
7426
7376
|
const { attributes, controls, dataSources } = useWidgetContext(type);
|
|
7427
7377
|
const { children, options } = elementConfig || {};
|
|
7428
|
-
const {
|
|
7429
|
-
const
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
|
|
7441
|
-
|
|
7378
|
+
const { controls: controlsOption } = options || {};
|
|
7379
|
+
const valueElement = React.useMemo(() => children.find(({ id }) => id === "value"), [children]);
|
|
7380
|
+
const control = React.useMemo(() => controlsOption?.find(item => item.targetAttributeName === valueElement.attributeName), [controlsOption, valueElement.attributeName]);
|
|
7381
|
+
const value = React.useMemo(() => {
|
|
7382
|
+
const currentValue = controls[control?.targetAttributeName] === undefined
|
|
7383
|
+
? attributes.find(({ name }) => name === control.targetAttributeName)
|
|
7384
|
+
?.value
|
|
7385
|
+
: controls[control?.targetAttributeName];
|
|
7386
|
+
return currentValue ?? control?.defaultValue;
|
|
7387
|
+
}, [
|
|
7388
|
+
controls,
|
|
7389
|
+
control.targetAttributeName,
|
|
7390
|
+
control?.defaultValue,
|
|
7391
|
+
attributes,
|
|
7392
|
+
]);
|
|
7393
|
+
const dataSource = React.useMemo(() => dataSources?.find(({ name }) => name === control.relatedDataSource), [control.relatedDataSource, dataSources]);
|
|
7394
|
+
return React.useMemo(() => ({ control, value, dataSource }), [control, value, dataSource]);
|
|
7442
7395
|
};
|
|
7443
7396
|
|
|
7444
7397
|
const BASE_STYLE$2 = {
|
|
7445
7398
|
marginBottom: "1rem",
|
|
7446
7399
|
};
|
|
7447
|
-
const EditBooleanContainer = ({ type, elementConfig, renderElement }) => {
|
|
7400
|
+
const EditBooleanContainer = ({ type, elementConfig, renderElement, }) => {
|
|
7448
7401
|
const { changeControls } = useWidgetContext(type);
|
|
7449
|
-
const {
|
|
7402
|
+
const { control, value } = useEditControl(type, elementConfig);
|
|
7450
7403
|
const { id, style } = elementConfig || {};
|
|
7451
|
-
return (jsxRuntime.jsxs(Container, { id: id, isColumn: true, style: { ...BASE_STYLE$2, ...style }, children: [jsxRuntime.jsxs(ContainerAlias, { hasBottomMargin: true, children: [renderElement({ id: "alias" }), renderElement({ id: "tooltip" })] }), jsxRuntime.jsxs(ContainerValue, { children: [jsxRuntime.jsx(uilibGl.Checkbox, { label: "\u0414\u0430", checked: !!
|
|
7452
|
-
changeControls({ [
|
|
7453
|
-
} }), jsxRuntime.jsx(uilibGl.Checkbox, { label: "\u041D\u0435\u0442", checked: !
|
|
7454
|
-
changeControls({ [
|
|
7404
|
+
return (jsxRuntime.jsxs(Container, { id: id, isColumn: true, style: { ...BASE_STYLE$2, ...style }, children: [jsxRuntime.jsxs(ContainerAlias, { hasBottomMargin: true, children: [renderElement({ id: "alias" }), renderElement({ id: "tooltip" })] }), jsxRuntime.jsxs(ContainerValue, { children: [jsxRuntime.jsx(uilibGl.Checkbox, { label: "\u0414\u0430", checked: !!value, onChange: () => {
|
|
7405
|
+
changeControls({ [control.targetAttributeName]: true });
|
|
7406
|
+
} }), jsxRuntime.jsx(uilibGl.Checkbox, { label: "\u041D\u0435\u0442", checked: !value, onChange: () => {
|
|
7407
|
+
changeControls({ [control.targetAttributeName]: false });
|
|
7455
7408
|
} })] })] }));
|
|
7456
7409
|
};
|
|
7457
7410
|
|
|
7458
7411
|
const BASE_STYLE$1 = {
|
|
7459
7412
|
marginBottom: "1rem",
|
|
7460
7413
|
};
|
|
7461
|
-
const EditStringContainer = ({ type, elementConfig, renderElement }) => {
|
|
7414
|
+
const EditStringContainer = ({ type, elementConfig, renderElement, }) => {
|
|
7462
7415
|
const { changeControls } = useWidgetContext(type);
|
|
7463
|
-
const {
|
|
7416
|
+
const { control, value } = useEditControl(type, elementConfig);
|
|
7464
7417
|
const { id, style } = elementConfig || {};
|
|
7465
7418
|
const onChange = React.useCallback((e) => {
|
|
7466
|
-
changeControls({ [
|
|
7467
|
-
}, [changeControls,
|
|
7468
|
-
return (jsxRuntime.jsxs(Container, { id: id, isColumn: true, style: { ...BASE_STYLE$1, ...style }, children: [jsxRuntime.jsxs(ContainerAlias, { hasBottomMargin: true, children: [renderElement({ id: "alias" }), renderElement({ id: "tooltip" })] }), jsxRuntime.jsx(ContainerValue, { children: jsxRuntime.jsx(uilibGl.Input, { value:
|
|
7419
|
+
changeControls({ [control?.targetAttributeName]: e.target.value });
|
|
7420
|
+
}, [changeControls, control?.targetAttributeName]);
|
|
7421
|
+
return (jsxRuntime.jsxs(Container, { id: id, isColumn: true, style: { ...BASE_STYLE$1, ...style }, children: [jsxRuntime.jsxs(ContainerAlias, { hasBottomMargin: true, children: [renderElement({ id: "alias" }), renderElement({ id: "tooltip" })] }), jsxRuntime.jsx(ContainerValue, { children: jsxRuntime.jsx(uilibGl.Input, { value: value, width: "100%", onChange: onChange }) })] }));
|
|
7469
7422
|
};
|
|
7470
7423
|
|
|
7471
7424
|
const BASE_STYLE = {
|
|
7472
7425
|
marginBottom: "1rem",
|
|
7473
7426
|
};
|
|
7474
|
-
const EditDropdownContainer = ({ type, elementConfig, renderElement }) => {
|
|
7427
|
+
const EditDropdownContainer = ({ type, elementConfig, renderElement, }) => {
|
|
7475
7428
|
const { changeControls } = useWidgetContext(type);
|
|
7476
|
-
const {
|
|
7429
|
+
const { value, control, dataSource } = useEditControl(type, elementConfig);
|
|
7477
7430
|
const { id, style, options } = elementConfig || {};
|
|
7478
7431
|
const { placeholder, label, width } = options || {};
|
|
7479
7432
|
const optionsList = React.useMemo(() => dataSource?.features.map(item => {
|
|
7480
|
-
const
|
|
7481
|
-
return { text:
|
|
7482
|
-
}), [dataSource?.features,
|
|
7433
|
+
const currentValue = item.properties[control?.attributeName] || null;
|
|
7434
|
+
return { text: currentValue, value: currentValue };
|
|
7435
|
+
}), [dataSource?.features, control?.attributeName]);
|
|
7483
7436
|
const onChange = React.useCallback(([option]) => {
|
|
7484
|
-
changeControls({ [
|
|
7485
|
-
}, [
|
|
7486
|
-
return (jsxRuntime.jsxs(Container, { id: id, isColumn: true, style: { ...BASE_STYLE, ...style }, children: [jsxRuntime.jsxs(ContainerAlias, { hasBottomMargin: true, children: [renderElement({ id: "alias" }), renderElement({ id: "tooltip" })] }), jsxRuntime.jsx(ContainerValue, { children: jsxRuntime.jsx(uilibGl.Dropdown, { zIndex: 1000, label: label, placeholder: placeholder, options: optionsList, value:
|
|
7437
|
+
changeControls({ [control?.targetAttributeName]: option.value });
|
|
7438
|
+
}, [control?.targetAttributeName, changeControls]);
|
|
7439
|
+
return (jsxRuntime.jsxs(Container, { id: id, isColumn: true, style: { ...BASE_STYLE, ...style }, children: [jsxRuntime.jsxs(ContainerAlias, { hasBottomMargin: true, children: [renderElement({ id: "alias" }), renderElement({ id: "tooltip" })] }), jsxRuntime.jsx(ContainerValue, { children: jsxRuntime.jsx(uilibGl.Dropdown, { zIndex: 1000, label: label, placeholder: placeholder, options: optionsList, value: value, width: `${width ?? DEFAULT_DROPDOWN_WIDTH}px`, onChange: onChange }) })] }));
|
|
7487
7440
|
};
|
|
7488
7441
|
|
|
7489
7442
|
const ContainerDivider = styled(uilibGl.Divider) `
|
|
@@ -7820,12 +7773,12 @@ const LayerIcon = ({ layerInfo, error }) => {
|
|
|
7820
7773
|
return (jsxRuntime.jsx(AlertIconContainer, { children: jsxRuntime.jsx(uilibGl.Icon, { kind: "warning" }) }));
|
|
7821
7774
|
}
|
|
7822
7775
|
switch (layerInfo.geometryType) {
|
|
7823
|
-
case api.
|
|
7776
|
+
case api.OgcGeometryType.MultiLineString:
|
|
7824
7777
|
return jsxRuntime.jsx("img", { src: img$1, alt: "" });
|
|
7825
|
-
case api.
|
|
7826
|
-
case api.
|
|
7778
|
+
case api.OgcGeometryType.Polygon:
|
|
7779
|
+
case api.OgcGeometryType.MultiPolygon:
|
|
7827
7780
|
return jsxRuntime.jsx("img", { src: img, alt: "" });
|
|
7828
|
-
case api.
|
|
7781
|
+
case api.OgcGeometryType.Point:
|
|
7829
7782
|
default:
|
|
7830
7783
|
return jsxRuntime.jsx("img", { src: img$2, alt: "" });
|
|
7831
7784
|
}
|
|
@@ -8362,7 +8315,10 @@ const ElementControl = ({ elementConfig }) => {
|
|
|
8362
8315
|
const { t } = useGlobalContext();
|
|
8363
8316
|
const { attributes, layerInfo, dataSources, controls, changeControls } = useWidgetContext(exports.WidgetType.FeatureCard);
|
|
8364
8317
|
const { options, attributeName, defaultValue } = elementConfig || {};
|
|
8365
|
-
const { relatedDataSource, label, width, control, placeholder = t("selectValue", {
|
|
8318
|
+
const { relatedDataSource, label, width, control, placeholder = t("selectValue", {
|
|
8319
|
+
ns: "dashboard",
|
|
8320
|
+
defaultValue: "Выберите значение",
|
|
8321
|
+
}), } = options || {};
|
|
8366
8322
|
const attribute = React.useMemo(() => attributes?.find(({ name }) => name === control?.targetAttributeName), [attributes, control?.targetAttributeName]);
|
|
8367
8323
|
const dataSource = React.useMemo(() => getDataSource(relatedDataSource, dataSources), [relatedDataSource, dataSources]);
|
|
8368
8324
|
const items = React.useMemo(() => {
|
|
@@ -8370,14 +8326,17 @@ const ElementControl = ({ elementConfig }) => {
|
|
|
8370
8326
|
return [];
|
|
8371
8327
|
}
|
|
8372
8328
|
return dataSource.features.map(item => ({
|
|
8373
|
-
value: item.
|
|
8374
|
-
text: item.
|
|
8329
|
+
value: item.properties?.[attributeName] || "",
|
|
8330
|
+
text: item.properties?.[control?.attributeName || attributeName] || "",
|
|
8375
8331
|
}));
|
|
8376
|
-
}, [control?.
|
|
8332
|
+
}, [control?.attributeName, dataSource?.features, attributeName]);
|
|
8377
8333
|
const isDisabled = React.useMemo(() => {
|
|
8378
8334
|
const attr = layerInfo?.configuration?.attributesConfiguration?.attributes?.find(item => item.attributeName === control?.targetAttributeName);
|
|
8379
8335
|
return !attr?.isEditable;
|
|
8380
|
-
}, [
|
|
8336
|
+
}, [
|
|
8337
|
+
control?.targetAttributeName,
|
|
8338
|
+
layerInfo?.configuration?.attributesConfiguration?.attributes,
|
|
8339
|
+
]);
|
|
8381
8340
|
const handleChange = React.useCallback(([option]) => {
|
|
8382
8341
|
if (control?.targetAttributeName && changeControls) {
|
|
8383
8342
|
changeControls({
|
|
@@ -8385,7 +8344,9 @@ const ElementControl = ({ elementConfig }) => {
|
|
|
8385
8344
|
});
|
|
8386
8345
|
}
|
|
8387
8346
|
}, [changeControls, control?.targetAttributeName]);
|
|
8388
|
-
return (jsxRuntime.jsx(uilibGl.Dropdown, { zIndex: 1000, width: `${width ?? DEFAULT_DROPDOWN_WIDTH}px`, label: label, options: items, value: controls?.[control?.targetAttributeName] ??
|
|
8347
|
+
return (jsxRuntime.jsx(uilibGl.Dropdown, { zIndex: 1000, width: `${width ?? DEFAULT_DROPDOWN_WIDTH}px`, label: label, options: items, value: controls?.[control?.targetAttributeName] ??
|
|
8348
|
+
attribute?.value ??
|
|
8349
|
+
defaultValue, placeholder: placeholder, disabled: isDisabled, onChange: handleChange }));
|
|
8389
8350
|
};
|
|
8390
8351
|
|
|
8391
8352
|
const StyledIconFontSizeMixin = styled.css `
|
|
@@ -8699,7 +8660,7 @@ const ElementSlideshow = ({ elementConfig, type, renderElement }) => {
|
|
|
8699
8660
|
const images = React.useMemo(() => {
|
|
8700
8661
|
const dataSource = relatedDataSource ? dataSources?.find(({ name }) => name === relatedDataSource) : null;
|
|
8701
8662
|
const array = dataSource
|
|
8702
|
-
? dataSource.features.map(feature => feature.
|
|
8663
|
+
? dataSource.features.map(feature => feature.properties[attributeName])
|
|
8703
8664
|
: getSlideshowImages({
|
|
8704
8665
|
element: elementConfig,
|
|
8705
8666
|
attribute: attributes?.find(({ name }) => name === attributeName),
|
|
@@ -8882,20 +8843,20 @@ const getDataFromRelatedFeatures = ({ t, config, filters, relatedConfig, dataSou
|
|
|
8882
8843
|
}
|
|
8883
8844
|
const { colors } = config.options;
|
|
8884
8845
|
const layerDefinition = getLayerDefinition(layerInfo);
|
|
8885
|
-
let data =
|
|
8846
|
+
let data = [...dataSource?.features];
|
|
8886
8847
|
const sortAttribute = config?.options?.orderByValue
|
|
8887
8848
|
? relatedConfig.attributeName
|
|
8888
8849
|
: config?.options?.orderByTitle
|
|
8889
8850
|
? relatedConfig.attributeTitle
|
|
8890
8851
|
: null;
|
|
8891
8852
|
if (sortAttribute) {
|
|
8892
|
-
data.sort((a, b) => b.
|
|
8853
|
+
data.sort((a, b) => b.properties[sortAttribute] - a.properties[sortAttribute]);
|
|
8893
8854
|
}
|
|
8894
8855
|
const isOtherSliced = config?.options?.otherItems && config.options.otherItems < data.length;
|
|
8895
8856
|
const otherValue = isOtherSliced
|
|
8896
8857
|
? data
|
|
8897
8858
|
.slice(config.options.otherItems)
|
|
8898
|
-
.reduce((prev, {
|
|
8859
|
+
.reduce((prev, { properties }) => prev + properties[relatedConfig.attributeName], 0)
|
|
8899
8860
|
: null;
|
|
8900
8861
|
if (isOtherSliced) {
|
|
8901
8862
|
data = data.slice(0, config?.options?.otherItems);
|
|
@@ -8911,9 +8872,9 @@ const getDataFromRelatedFeatures = ({ t, config, filters, relatedConfig, dataSou
|
|
|
8911
8872
|
if (relatedConfig?.filterName && !filter) {
|
|
8912
8873
|
return acc;
|
|
8913
8874
|
}
|
|
8914
|
-
const attributeName = feature.
|
|
8915
|
-
const attributeTitle = feature.
|
|
8916
|
-
const attributeColor = feature.
|
|
8875
|
+
const attributeName = feature.properties[relatedConfig.attributeName];
|
|
8876
|
+
const attributeTitle = feature.properties[relatedConfig.attributeTitle];
|
|
8877
|
+
const attributeColor = feature.properties[relatedConfig.attributeColor];
|
|
8917
8878
|
return [
|
|
8918
8879
|
...acc,
|
|
8919
8880
|
{
|
|
@@ -8925,8 +8886,8 @@ const getDataFromRelatedFeatures = ({ t, config, filters, relatedConfig, dataSou
|
|
|
8925
8886
|
}),
|
|
8926
8887
|
value: attributeName === null ? null : Number(attributeName),
|
|
8927
8888
|
color: attributeColor || gradientArray?.[index] || FEATURE_CARD_OTHER_COLOR,
|
|
8928
|
-
min: filter?.attributeMin ? feature.
|
|
8929
|
-
max: filter?.attributeMin ? feature.
|
|
8889
|
+
min: filter?.attributeMin ? feature.properties[filter.attributeMin] : null,
|
|
8890
|
+
max: filter?.attributeMin ? feature.properties[filter.attributeMax] : null
|
|
8930
8891
|
}
|
|
8931
8892
|
];
|
|
8932
8893
|
}, []);
|
|
@@ -9092,7 +9053,7 @@ function getFeatureAttributes(feature = {}, layer, dataSource) {
|
|
|
9092
9053
|
if (!layerDefinition) {
|
|
9093
9054
|
return [];
|
|
9094
9055
|
}
|
|
9095
|
-
const currentAttributes = !feature && dataSource ? dataSource.features[0].
|
|
9056
|
+
const currentAttributes = !feature && dataSource ? dataSource.features[0].properties : feature?.properties;
|
|
9096
9057
|
const { id: idValue } = feature || {};
|
|
9097
9058
|
const { idAttribute, attributes } = layerDefinition || {};
|
|
9098
9059
|
const layerAttributes = idAttribute
|
|
@@ -9109,7 +9070,7 @@ function getFeatureAttributes(feature = {}, layer, dataSource) {
|
|
|
9109
9070
|
readOnly: true,
|
|
9110
9071
|
}
|
|
9111
9072
|
: {
|
|
9112
|
-
value: currentAttributes?.[attributeName] || dataSource?.features?.[0]?.
|
|
9073
|
+
value: currentAttributes?.[attributeName] || dataSource?.features?.[0]?.properties?.[attributeName],
|
|
9113
9074
|
readOnly: isCalculated || !isEditable,
|
|
9114
9075
|
};
|
|
9115
9076
|
const clientData = layer.layerAttributes?.find(layerAttribute => layerAttribute.attributeName === attributeName)?.clientData;
|
|
@@ -9281,10 +9242,10 @@ const getListOptions = (items, filterName, configFilters) => {
|
|
|
9281
9242
|
if (!filter)
|
|
9282
9243
|
return [];
|
|
9283
9244
|
return (items?.map(item => ({
|
|
9284
|
-
text: item.
|
|
9285
|
-
value: item.
|
|
9286
|
-
min: filter.attributeMin ? item.
|
|
9287
|
-
max: filter.attributeMax ? item.
|
|
9245
|
+
text: item.properties[filter.attributeAlias || DEFAULT_ATTRIBUTE_NAME],
|
|
9246
|
+
value: item.properties[filter.attributeValue || DEFAULT_ATTRIBUTE_NAME],
|
|
9247
|
+
min: filter.attributeMin ? item.properties[filter.attributeMin] : null,
|
|
9248
|
+
max: filter.attributeMax ? item.properties[filter.attributeMax] : null,
|
|
9288
9249
|
})) || []);
|
|
9289
9250
|
};
|
|
9290
9251
|
|
|
@@ -9596,8 +9557,8 @@ const RangeDateFilter = ({ type, filter }) => {
|
|
|
9596
9557
|
const { filterName, label, minValue, maxValue, withTime } = filter.options;
|
|
9597
9558
|
const configFilter = React.useMemo(() => getConfigFilter(filterName, configFilters), [configFilters, filterName]);
|
|
9598
9559
|
const dataSource = React.useMemo(() => getDataSource(configFilter?.relatedDataSource, dataSources), [configFilter?.relatedDataSource, dataSources]);
|
|
9599
|
-
const { minFromData, maxFromData } = React.useMemo(() => dataSource?.features?.reduce((prev, {
|
|
9600
|
-
const date = getDate(
|
|
9560
|
+
const { minFromData, maxFromData } = React.useMemo(() => dataSource?.features?.reduce((prev, { properties }) => {
|
|
9561
|
+
const date = getDate(properties[configFilter?.attributeValue]);
|
|
9601
9562
|
return {
|
|
9602
9563
|
minFromData: !prev.minFromData ? date : date < prev.minFromData ? date : prev.minFromData,
|
|
9603
9564
|
maxFromData: !prev.maxFromData ? date : date > prev.maxFromData ? date : prev.maxFromData
|
|
@@ -9818,7 +9779,7 @@ const ChipsFilter = ({ type, filter, elementConfig, }) => {
|
|
|
9818
9779
|
return [];
|
|
9819
9780
|
const features = dataSource.features;
|
|
9820
9781
|
return features.map(feature => {
|
|
9821
|
-
const attrs = feature.
|
|
9782
|
+
const attrs = feature.properties;
|
|
9822
9783
|
const text = attrs[configFilter.attributeAlias || DEFAULT_ATTRIBUTE_NAME];
|
|
9823
9784
|
const value = attrs[configFilter.attributeValue || DEFAULT_ATTRIBUTE_NAME];
|
|
9824
9785
|
const chipIcon = iconAttribute
|
|
@@ -10523,7 +10484,7 @@ const useDataSources = ({ type: widgetType, config, attributes, filters, layerPa
|
|
|
10523
10484
|
const queryResponse = await api.eql.getPagedQueryResult({ saveInHistory: false }, getProps);
|
|
10524
10485
|
const descriptionResponse = await api.eql.getQueryDescription(getProps);
|
|
10525
10486
|
return {
|
|
10526
|
-
items: queryResponse.
|
|
10487
|
+
items: queryResponse.features,
|
|
10527
10488
|
attributeDefinition: descriptionResponse,
|
|
10528
10489
|
};
|
|
10529
10490
|
}
|
|
@@ -10571,7 +10532,7 @@ const useDataSources = ({ type: widgetType, config, attributes, filters, layerPa
|
|
|
10571
10532
|
!!currentDataSources[index].url ||
|
|
10572
10533
|
!!currentDataSources[index].resourceId;
|
|
10573
10534
|
newDataSources[index].layerName = currentDataSources[index].layerName;
|
|
10574
|
-
const items = response.status === "rejected" ? null : response.value?.
|
|
10535
|
+
const items = response.status === "rejected" ? null : response.value?.features || response.items;
|
|
10575
10536
|
newDataSources[index].features =
|
|
10576
10537
|
response.status === "rejected"
|
|
10577
10538
|
? null
|
|
@@ -11002,7 +10963,7 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
|
|
|
11002
10963
|
const attribute = layerInfo?.layerDefinition.attributes[attributeName];
|
|
11003
10964
|
const dataSource = getDataSource(dataSourceName, dataSources);
|
|
11004
10965
|
const units = attributeUnits
|
|
11005
|
-
? dataSource?.features?.[0]?.
|
|
10966
|
+
? dataSource?.features?.[0]?.properties?.[attributeUnits]
|
|
11006
10967
|
: attribute?.stringFormat?.unitsLabel;
|
|
11007
10968
|
const formatValue = attribute
|
|
11008
10969
|
? formatAttributeValue({ t, type: attribute.type, value, stringFormat: attribute.stringFormat, noUnits: true })
|
|
@@ -11570,22 +11531,22 @@ const RasterLayer = ({ layer, tileUrl, visible, beforeId, filterVersion, }) => {
|
|
|
11570
11531
|
|
|
11571
11532
|
const getClientStyleItemPrefixSuffix = (geometryType, itemType) => {
|
|
11572
11533
|
switch (geometryType) {
|
|
11573
|
-
case api.
|
|
11534
|
+
case api.OgcGeometryType.Point:
|
|
11574
11535
|
switch (itemType) {
|
|
11575
11536
|
case "symbol":
|
|
11576
11537
|
return ["point-label-layer-", "-label"];
|
|
11577
11538
|
default:
|
|
11578
11539
|
return ["point-layer-", ""];
|
|
11579
11540
|
}
|
|
11580
|
-
case api.
|
|
11541
|
+
case api.OgcGeometryType.MultiLineString:
|
|
11581
11542
|
switch (itemType) {
|
|
11582
11543
|
case "symbol":
|
|
11583
11544
|
return ["polyline-label-layer-", "-label"];
|
|
11584
11545
|
default:
|
|
11585
11546
|
return ["polyline-layer-", ""];
|
|
11586
11547
|
}
|
|
11587
|
-
case api.
|
|
11588
|
-
case api.
|
|
11548
|
+
case api.OgcGeometryType.Polygon:
|
|
11549
|
+
case api.OgcGeometryType.MultiPolygon:
|
|
11589
11550
|
switch (itemType) {
|
|
11590
11551
|
case "line":
|
|
11591
11552
|
return ["polygon-stroke-layer-", "-stroke"];
|
|
@@ -11601,6 +11562,52 @@ const getClientStyleItemPrefixSuffix = (geometryType, itemType) => {
|
|
|
11601
11562
|
}
|
|
11602
11563
|
};
|
|
11603
11564
|
|
|
11565
|
+
const findAttributeInExpression = (expression) => {
|
|
11566
|
+
if (Array.isArray(expression) && expression.length === 2 && expression[0] === "get") {
|
|
11567
|
+
return [expression[1]];
|
|
11568
|
+
}
|
|
11569
|
+
return expression.reduce((acc, curr) => {
|
|
11570
|
+
if (!Array.isArray(curr)) {
|
|
11571
|
+
return acc;
|
|
11572
|
+
}
|
|
11573
|
+
if (curr[0] === "get") {
|
|
11574
|
+
return [...new Set([...acc, curr[1]])];
|
|
11575
|
+
}
|
|
11576
|
+
return [...new Set([...acc, ...findAttributeInExpression(curr)])];
|
|
11577
|
+
}, []);
|
|
11578
|
+
};
|
|
11579
|
+
|
|
11580
|
+
const getActualExtrusionHeight = (paint) => {
|
|
11581
|
+
return Array.isArray(paint?.["fill-extrusion-height"]) && paint?.["fill-extrusion-height"][0] === "+"
|
|
11582
|
+
? paint?.["fill-extrusion-height"][1]
|
|
11583
|
+
: paint?.["fill-extrusion-height"];
|
|
11584
|
+
};
|
|
11585
|
+
|
|
11586
|
+
const extractAttributesFromObject = (obj) => {
|
|
11587
|
+
if (!obj || lodash.isEmpty(obj)) {
|
|
11588
|
+
return [];
|
|
11589
|
+
}
|
|
11590
|
+
return Object.entries(obj).reduce((acc, [, value]) => {
|
|
11591
|
+
if (!Array.isArray(value)) {
|
|
11592
|
+
return acc;
|
|
11593
|
+
}
|
|
11594
|
+
return [...new Set([...acc, ...findAttributeInExpression(value)])];
|
|
11595
|
+
}, []);
|
|
11596
|
+
};
|
|
11597
|
+
const parseClientStyle = (style) => {
|
|
11598
|
+
if (!style) {
|
|
11599
|
+
return [];
|
|
11600
|
+
}
|
|
11601
|
+
return style?.items?.reduce((acc, curr) => {
|
|
11602
|
+
const paintAttributes = extractAttributesFromObject(curr.paint);
|
|
11603
|
+
const layoutAttributes = extractAttributesFromObject(curr.layout);
|
|
11604
|
+
const filterAttributes = curr.filter
|
|
11605
|
+
? findAttributeInExpression(curr.filter)
|
|
11606
|
+
: [];
|
|
11607
|
+
return [...new Set([...acc, ...paintAttributes, ...layoutAttributes, ...filterAttributes])];
|
|
11608
|
+
}, []);
|
|
11609
|
+
};
|
|
11610
|
+
|
|
11604
11611
|
const VectorLayer = ({ layer, tileUrl, visible, beforeId, getLayerTempStyle, filterVersion, }) => {
|
|
11605
11612
|
const clientStyle = layer?.configuration?.clientStyle;
|
|
11606
11613
|
const { idAttribute, geometryType } = layer.layerDefinition || {};
|
|
@@ -11632,7 +11639,7 @@ const VectorLayer = ({ layer, tileUrl, visible, beforeId, getLayerTempStyle, fil
|
|
|
11632
11639
|
const renderLayerByGeometryType = React.useCallback(() => {
|
|
11633
11640
|
const visibility = visible ? "visible" : "none";
|
|
11634
11641
|
switch (geometryType) {
|
|
11635
|
-
case api.
|
|
11642
|
+
case api.OgcGeometryType.Point:
|
|
11636
11643
|
return (jsxRuntime.jsx(MapGL.Layer, { id: layer.name, type: "circle", "source-layer": "default", beforeId: beforeId, layout: {
|
|
11637
11644
|
...getLayerTempStyle?.(layer.name, "circle")?.layout,
|
|
11638
11645
|
visibility,
|
|
@@ -11640,8 +11647,8 @@ const VectorLayer = ({ layer, tileUrl, visible, beforeId, getLayerTempStyle, fil
|
|
|
11640
11647
|
...DEFAULT_CIRCLE_PAINT,
|
|
11641
11648
|
...getLayerTempStyle?.(layer.name, "circle")?.paint,
|
|
11642
11649
|
} }));
|
|
11643
|
-
case api.
|
|
11644
|
-
case api.
|
|
11650
|
+
case api.OgcGeometryType.Polygon:
|
|
11651
|
+
case api.OgcGeometryType.MultiPolygon:
|
|
11645
11652
|
return [
|
|
11646
11653
|
jsxRuntime.jsx(MapGL.Layer, { id: layer.name, type: "fill", "source-layer": "default", beforeId: beforeId, layout: {
|
|
11647
11654
|
...getLayerTempStyle?.(layer.name, "fill")?.layout,
|
|
@@ -11679,7 +11686,7 @@ const VectorLayer = ({ layer, tileUrl, visible, beforeId, getLayerTempStyle, fil
|
|
|
11679
11686
|
...getLayerTempStyle?.(layer.name, "fill-extrusion")?.paint,
|
|
11680
11687
|
} }, `polygon-extrusion-layer-${layer.name}`),
|
|
11681
11688
|
];
|
|
11682
|
-
case api.
|
|
11689
|
+
case api.OgcGeometryType.MultiLineString:
|
|
11683
11690
|
return (jsxRuntime.jsx(MapGL.Layer, { id: layer.name, type: "line", "source-layer": "default", beforeId: beforeId, layout: {
|
|
11684
11691
|
...getLayerTempStyle?.(layer.name, "line")?.layout,
|
|
11685
11692
|
visibility,
|
|
@@ -11950,7 +11957,6 @@ exports.applyQueryFilters = applyQueryFilters;
|
|
|
11950
11957
|
exports.applyVarsToCondition = applyVarsToCondition;
|
|
11951
11958
|
exports.checkEqualOrIncludes = checkEqualOrIncludes;
|
|
11952
11959
|
exports.checkIsLoading = checkIsLoading;
|
|
11953
|
-
exports.convertSpToTurfFeature = convertSpToTurfFeature;
|
|
11954
11960
|
exports.createConfigLayer = createConfigLayer;
|
|
11955
11961
|
exports.createConfigPage = createConfigPage;
|
|
11956
11962
|
exports.createNewPageId = createNewPageId;
|