@evergis/react 3.1.101 → 3.1.103

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Everpoint
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Everpoint
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # @evergis/react
2
-
3
- В данном репозитории находятся специфичные (в отличии от `@evergis/uilib-gl`) для `Evergis Online`,
4
- но в целом переиспользуемые на других проектах, построенных на Evergis API, React-компоненты.
5
-
6
- ***ВАЖНО!!!***: Разрабатываемые компоненты не должны иметь зависимостей
7
- от системы поддержки мультиязычности `Evergis Online`!
1
+ # @evergis/react
2
+
3
+ В данном репозитории находятся специфичные (в отличии от `@evergis/uilib-gl`) для `Evergis Online`,
4
+ но в целом переиспользуемые на других проектах, построенных на Evergis API, React-компоненты.
5
+
6
+ ***ВАЖНО!!!***: Разрабатываемые компоненты не должны иметь зависимостей
7
+ от системы поддержки мультиязычности `Evergis Online`!
@@ -9,4 +9,5 @@ export interface LayerProps {
9
9
  beforeId?: string;
10
10
  getLayerTempStyle?: ((layerName: string, type: ClientStyleItem["type"]) => Pick<ClientStyleItem, "layout" | "paint"> & Pick<ClientStyle, "settings">);
11
11
  onMount?: EffectCallback;
12
+ filterVersion?: string;
12
13
  }
@@ -1,3 +1,3 @@
1
1
  import { GeometryType } from '@evergis/api';
2
2
  import { ClientStyleItem } from '../../../types';
3
- export declare const getClientStyleItemPrefixSuffix: (geometryType: GeometryType, type: ClientStyleItem["type"]) => [string, string];
3
+ export declare const getClientStyleItemPrefixSuffix: (geometryType: GeometryType, itemType: ClientStyleItem["type"]) => [string, string];
@@ -0,0 +1 @@
1
+ export * from './parseIconNames';
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Извлекает имена иконок из выражения icon-image.
3
+ *
4
+ * Поддерживает:
5
+ * - Строки: "parking" → ["parking"]
6
+ * - match: ["match", ["get", "type"], "a", "icon-a", "b", "icon-b", "default"] → ["icon-a", "icon-b", "default"]
7
+ * - case: ["case", [...], "icon-a", "icon-b"] → ["icon-a", "icon-b"]
8
+ * - coalesce: ["coalesce", ["image", "icon-a"], ["image", "icon-b"]] → ["icon-a", "icon-b"]
9
+ * - image: ["image", "icon-a"] → ["icon-a"]
10
+ *
11
+ * @param iconImage - значение icon-image из layout
12
+ * @returns массив имён иконок
13
+ */
14
+ export declare const parseIconNames: (iconImage: unknown) => string[];
15
+ /**
16
+ * Извлекает все имена изображений из clientStyle.
17
+ * Включает иконки (icon-image) и паттерны (fill-pattern, line-pattern, fill-extrusion-pattern).
18
+ *
19
+ * @param clientStyle - конфигурация стиля слоя
20
+ * @returns массив уникальных имён изображений
21
+ */
22
+ export declare const parseIconNamesFromClientStyle: (clientStyle: {
23
+ items?: Array<{
24
+ layout?: Record<string, unknown>;
25
+ paint?: Record<string, unknown>;
26
+ }>;
27
+ } | undefined) => string[];
@@ -1,2 +1,3 @@
1
1
  export * from './classification';
2
2
  export * from './feature';
3
+ export * from './icons';
@@ -1,5 +1,7 @@
1
1
  export * from './useMapDraw';
2
2
  export * from './useMapContext';
3
+ export * from './useMapImages';
4
+ export * from './useIconsFromLayers';
3
5
  export * from './useRedrawLayer';
4
6
  export * from './useZoomToFeatures';
5
7
  export * from './useZoomToPoint';
@@ -0,0 +1,52 @@
1
+ import { ClientStyle } from '../../types/styling';
2
+ export interface LayerIconConfig {
3
+ /** Идентификатор слоя */
4
+ layerId: string;
5
+ /** Конфигурация стиля слоя */
6
+ clientStyle?: ClientStyle;
7
+ }
8
+ export interface UseIconsFromLayersOptions {
9
+ /** Массив конфигураций слоёв */
10
+ layers: LayerIconConfig[];
11
+ /** Базовый URL для иконок по умолчанию (если не указан в clientStyle.icons) */
12
+ baseUrl?: string;
13
+ /** Расширение файлов иконок по умолчанию */
14
+ defaultExtension?: string;
15
+ }
16
+ export interface UseIconsFromLayersResult {
17
+ /** Загружены ли все иконки */
18
+ loaded: boolean;
19
+ /** Ошибки загрузки (имя иконки -> сообщение об ошибке) */
20
+ errors: Record<string, string>;
21
+ /** Массив имён иконок, которые были запрошены */
22
+ requestedIcons: string[];
23
+ }
24
+ /**
25
+ * Хук для автоматической загрузки иконок из clientStyle слоёв.
26
+ *
27
+ * Парсит все icon-image выражения из clientStyle.items и загружает
28
+ * соответствующие иконки из clientStyle.icons или по конвенции baseUrl.
29
+ *
30
+ * @example
31
+ * ```tsx
32
+ * const layers = [
33
+ * {
34
+ * layerId: 'parking',
35
+ * clientStyle: {
36
+ * icons: [
37
+ * { name: 'parking-icon', url: '/icons/parking.svg', sdf: true }
38
+ * ],
39
+ * items: [{
40
+ * type: 'symbol',
41
+ * layout: { 'icon-image': 'parking-icon' }
42
+ * }]
43
+ * }
44
+ * }
45
+ * ];
46
+ *
47
+ * const { loaded, errors } = useIconsFromLayers({ layers });
48
+ *
49
+ * if (!loaded) return <Loading />;
50
+ * ```
51
+ */
52
+ export declare const useIconsFromLayers: ({ layers, baseUrl, defaultExtension, }: UseIconsFromLayersOptions) => UseIconsFromLayersResult;
@@ -0,0 +1,48 @@
1
+ export interface MapImageConfig {
2
+ /** Уникальное имя иконки для использования в icon-image */
3
+ name: string;
4
+ /** URL изображения (PNG, SVG или data URL) */
5
+ url: string;
6
+ /** SDF режим для перекрашивания иконки через icon-color */
7
+ sdf?: boolean;
8
+ /** Размер иконки в пикселях (для SVG растеризации, по умолчанию 64) */
9
+ size?: number;
10
+ /** Pixel ratio для retina экранов (1 или 2, по умолчанию 1) */
11
+ pixelRatio?: number;
12
+ }
13
+ export interface UseMapImagesOptions {
14
+ /** Массив конфигураций иконок для загрузки */
15
+ images: MapImageConfig[];
16
+ }
17
+ export interface UseMapImagesResult {
18
+ /** Загружены ли все иконки */
19
+ loaded: boolean;
20
+ /** Ошибки загрузки (имя иконки -> сообщение об ошибке) */
21
+ errors: Record<string, string>;
22
+ /** Загрузить дополнительную иконку */
23
+ addImage: (config: MapImageConfig) => Promise<void>;
24
+ /** Удалить иконку с карты */
25
+ removeImage: (name: string) => void;
26
+ /** Проверить есть ли иконка */
27
+ hasImage: (name: string) => boolean;
28
+ }
29
+ /**
30
+ * Хук для загрузки пользовательских иконок в карту Mapbox.
31
+ *
32
+ * Поддерживает PNG, SVG и data URL. SVG автоматически растеризуется.
33
+ *
34
+ * @example
35
+ * ```tsx
36
+ * const { loaded } = useMapImages({
37
+ * images: [
38
+ * { name: 'my-parking', url: '/icons/parking.png' },
39
+ * { name: 'my-marker', url: '/icons/marker.svg', sdf: true, size: 48 },
40
+ * { name: 'my-logo', url: '/icons/logo.png', pixelRatio: 2 },
41
+ * ]
42
+ * });
43
+ *
44
+ * // В clientStyle:
45
+ * { "icon-image": "my-parking" }
46
+ * ```
47
+ */
48
+ export declare const useMapImages: ({ images }: UseMapImagesOptions) => UseMapImagesResult;