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