@evergis/react 4.0.79 → 4.0.81
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/index.js +75 -50
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +75 -50
- package/dist/react.esm.js.map +1 -1
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -4519,6 +4519,56 @@ const addDataSources = (dashboardConfiguration, pageIndex, layerNames) => {
|
|
|
4519
4519
|
return newConfig.children;
|
|
4520
4520
|
};
|
|
4521
4521
|
|
|
4522
|
+
const isEmptyValue = (value) => value === "" || value === null || value === undefined;
|
|
4523
|
+
|
|
4524
|
+
const checkIsDateFormat = (value) => value.startsWith("#'") && value.endsWith("'");
|
|
4525
|
+
const checkIfNeedQuotes = (value, attributeType) => {
|
|
4526
|
+
return attributeType
|
|
4527
|
+
? !NUMERIC_ATTRIBUTE_TYPES.includes(attributeType)
|
|
4528
|
+
: typeof value === "number"
|
|
4529
|
+
? false
|
|
4530
|
+
: typeof value === "string" && !isNumeric(value) && !checkIsDateFormat(value);
|
|
4531
|
+
};
|
|
4532
|
+
const formatConditionValue = ({ value, attributeType, defaultValue, checkQuotes = true, isSetParams = false, }) => {
|
|
4533
|
+
if (isEmptyValue(value))
|
|
4534
|
+
return "";
|
|
4535
|
+
const formattedValue = Array.isArray(defaultValue) && !Array.isArray(value) ? [value] : value;
|
|
4536
|
+
const isArray = Array.isArray(formattedValue);
|
|
4537
|
+
let stringValue = formattedValue.toString();
|
|
4538
|
+
if (isArray) {
|
|
4539
|
+
return formattedValue.length && !formattedValue.every(item => !item)
|
|
4540
|
+
? `[${formattedValue
|
|
4541
|
+
.map(item => (checkQuotes && checkIfNeedQuotes(item, attributeType) ? `'${item}'` : item))
|
|
4542
|
+
.join(",")}]`
|
|
4543
|
+
: "";
|
|
4544
|
+
}
|
|
4545
|
+
if (isSetParams && checkIsDateFormat(stringValue)) {
|
|
4546
|
+
stringValue = stringValue.slice(2, -1);
|
|
4547
|
+
}
|
|
4548
|
+
return checkQuotes && checkIfNeedQuotes(stringValue, attributeType) ? `'${stringValue}'` : stringValue;
|
|
4549
|
+
};
|
|
4550
|
+
|
|
4551
|
+
/**
|
|
4552
|
+
* Объектное значение иерархического фильтра "tree" («уровень → массив id»),
|
|
4553
|
+
* в отличие от скалярных/массивных значений остальных фильтров.
|
|
4554
|
+
*/
|
|
4555
|
+
const isTreeFilterValue = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date);
|
|
4556
|
+
/**
|
|
4557
|
+
* Подставляет плейсхолдеры уровней `%name.l{N}` значениями id соответствующего уровня
|
|
4558
|
+
* (формат `[id1,id2,...]` для оператора IN). Уровни, отсутствующие в значении (или пустые),
|
|
4559
|
+
* не подставляются — плейсхолдер остаётся нетронутым, как и любой пустой `%`-плейсхолдер.
|
|
4560
|
+
*/
|
|
4561
|
+
const applyTreeFilterToCondition = (condition, name, value, isSingle) => {
|
|
4562
|
+
const filterName = `${FILTER_PREFIX}${name}`;
|
|
4563
|
+
return Object.keys(value).reduce((result, level) => {
|
|
4564
|
+
const formatted = formatConditionValue({ value: value[level], checkQuotes: !isSingle });
|
|
4565
|
+
if (!formatted) {
|
|
4566
|
+
return result;
|
|
4567
|
+
}
|
|
4568
|
+
return result.replace(new RegExp(`${filterName}\\.${level}\\b`, "g"), formatted);
|
|
4569
|
+
}, condition);
|
|
4570
|
+
};
|
|
4571
|
+
|
|
4522
4572
|
const getConfigFilter = (filterName, configFilters) => configFilters?.find(({ name }) => name === filterName);
|
|
4523
4573
|
|
|
4524
4574
|
const getDataSource = (dataSourceName, dataSources) => dataSources?.find(({ name }) => name === dataSourceName);
|
|
@@ -4604,6 +4654,14 @@ const applyQueryFilters = ({ parameters: configParameters, filters: configFilter
|
|
|
4604
4654
|
};
|
|
4605
4655
|
}
|
|
4606
4656
|
if (configParameters[key].includes(".")) {
|
|
4657
|
+
const selectedValue = selectedFilters?.[filterName]?.value;
|
|
4658
|
+
if (isTreeFilterValue(selectedValue)) {
|
|
4659
|
+
const levelValue = filterProp ? selectedValue[filterProp] : undefined;
|
|
4660
|
+
if (lodash.isNil(levelValue) || !levelValue.length) {
|
|
4661
|
+
return result;
|
|
4662
|
+
}
|
|
4663
|
+
return { ...result, [key]: levelValue };
|
|
4664
|
+
}
|
|
4607
4665
|
return {
|
|
4608
4666
|
...result,
|
|
4609
4667
|
[key]: getDataSourceFilterValue({
|
|
@@ -4677,56 +4735,6 @@ const createConfigPage = (props) => {
|
|
|
4677
4735
|
};
|
|
4678
4736
|
};
|
|
4679
4737
|
|
|
4680
|
-
const isEmptyValue = (value) => value === "" || value === null || value === undefined;
|
|
4681
|
-
|
|
4682
|
-
const checkIsDateFormat = (value) => value.startsWith("#'") && value.endsWith("'");
|
|
4683
|
-
const checkIfNeedQuotes = (value, attributeType) => {
|
|
4684
|
-
return attributeType
|
|
4685
|
-
? !NUMERIC_ATTRIBUTE_TYPES.includes(attributeType)
|
|
4686
|
-
: typeof value === "number"
|
|
4687
|
-
? false
|
|
4688
|
-
: typeof value === "string" && !isNumeric(value) && !checkIsDateFormat(value);
|
|
4689
|
-
};
|
|
4690
|
-
const formatConditionValue = ({ value, attributeType, defaultValue, checkQuotes = true, isSetParams = false, }) => {
|
|
4691
|
-
if (isEmptyValue(value))
|
|
4692
|
-
return "";
|
|
4693
|
-
const formattedValue = Array.isArray(defaultValue) && !Array.isArray(value) ? [value] : value;
|
|
4694
|
-
const isArray = Array.isArray(formattedValue);
|
|
4695
|
-
let stringValue = formattedValue.toString();
|
|
4696
|
-
if (isArray) {
|
|
4697
|
-
return formattedValue.length && !formattedValue.every(item => !item)
|
|
4698
|
-
? `[${formattedValue
|
|
4699
|
-
.map(item => (checkQuotes && checkIfNeedQuotes(item, attributeType) ? `'${item}'` : item))
|
|
4700
|
-
.join(",")}]`
|
|
4701
|
-
: "";
|
|
4702
|
-
}
|
|
4703
|
-
if (isSetParams && checkIsDateFormat(stringValue)) {
|
|
4704
|
-
stringValue = stringValue.slice(2, -1);
|
|
4705
|
-
}
|
|
4706
|
-
return checkQuotes && checkIfNeedQuotes(stringValue, attributeType) ? `'${stringValue}'` : stringValue;
|
|
4707
|
-
};
|
|
4708
|
-
|
|
4709
|
-
/**
|
|
4710
|
-
* Объектное значение иерархического фильтра "tree" («уровень → массив id»),
|
|
4711
|
-
* в отличие от скалярных/массивных значений остальных фильтров.
|
|
4712
|
-
*/
|
|
4713
|
-
const isTreeFilterValue = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date);
|
|
4714
|
-
/**
|
|
4715
|
-
* Подставляет плейсхолдеры уровней `%name.l{N}` значениями id соответствующего уровня
|
|
4716
|
-
* (формат `[id1,id2,...]` для оператора IN). Уровни, отсутствующие в значении (или пустые),
|
|
4717
|
-
* не подставляются — плейсхолдер остаётся нетронутым, как и любой пустой `%`-плейсхолдер.
|
|
4718
|
-
*/
|
|
4719
|
-
const applyTreeFilterToCondition = (condition, name, value, isSingle) => {
|
|
4720
|
-
const filterName = `${FILTER_PREFIX}${name}`;
|
|
4721
|
-
return Object.keys(value).reduce((result, level) => {
|
|
4722
|
-
const formatted = formatConditionValue({ value: value[level], checkQuotes: !isSingle });
|
|
4723
|
-
if (!formatted) {
|
|
4724
|
-
return result;
|
|
4725
|
-
}
|
|
4726
|
-
return result.replace(new RegExp(`${filterName}\\.${level}\\b`, "g"), formatted);
|
|
4727
|
-
}, condition);
|
|
4728
|
-
};
|
|
4729
|
-
|
|
4730
4738
|
const getAttributesConfiguration = (layer) => {
|
|
4731
4739
|
const layerAttributeConfiguration = layer?.configuration?.attributesConfiguration ?? {};
|
|
4732
4740
|
const { geometryAttribute, idAttribute } = layerAttributeConfiguration;
|
|
@@ -5185,6 +5193,7 @@ const loadSvgAsImage = (url, size, pixelRatio) => {
|
|
|
5185
5193
|
* ```
|
|
5186
5194
|
*/
|
|
5187
5195
|
const useMapImages = ({ images }) => {
|
|
5196
|
+
const { api } = useGlobalContext();
|
|
5188
5197
|
const { map, loaded: mapLoaded } = useMapContext();
|
|
5189
5198
|
const [loaded, setLoaded] = React.useState(false);
|
|
5190
5199
|
const [errors, setErrors] = React.useState({});
|
|
@@ -5212,6 +5221,22 @@ const useMapImages = ({ images }) => {
|
|
|
5212
5221
|
const size = config.size ?? 64;
|
|
5213
5222
|
const pixelRatio = config.pixelRatio ?? 1;
|
|
5214
5223
|
const sdf = config.sdf ?? false;
|
|
5224
|
+
// Картинка из каталога
|
|
5225
|
+
if (!config.url.startsWith("data:image") && !config.url.startsWith("http")) {
|
|
5226
|
+
try {
|
|
5227
|
+
const { data } = await loadSvgAsImage(URL.createObjectURL(await api.catalog.getFile(config.url)), size, pixelRatio);
|
|
5228
|
+
map.current.addImage(config.name, data, {
|
|
5229
|
+
sdf,
|
|
5230
|
+
pixelRatio,
|
|
5231
|
+
});
|
|
5232
|
+
loadedImagesRef.current.add(config.name);
|
|
5233
|
+
}
|
|
5234
|
+
catch (error) {
|
|
5235
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
5236
|
+
setErrors(prev => ({ ...prev, [config.name]: message }));
|
|
5237
|
+
throw error;
|
|
5238
|
+
}
|
|
5239
|
+
}
|
|
5215
5240
|
if (isSvgUrl(config.url)) {
|
|
5216
5241
|
// SVG: растеризуем через canvas
|
|
5217
5242
|
try {
|