@evergis/react 3.1.2 → 3.1.4

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.
Files changed (78) hide show
  1. package/dist/components/{Map/components/Layer → Layer}/index.d.ts +1 -0
  2. package/dist/components/{Map/components/Layer → Layer}/types.d.ts +1 -1
  3. package/dist/components/{Map/components/Layer → Layer}/utils/getClientStyleItemPrefixSuffix.d.ts +1 -1
  4. package/dist/components/Map/index.d.ts +0 -1
  5. package/dist/components/index.d.ts +1 -3
  6. package/dist/contexts/MapContext/types.d.ts +31 -0
  7. package/dist/contexts/index.d.ts +2 -0
  8. package/dist/core/classification/parseClientStyle.d.ts +1 -1
  9. package/dist/core/feature/convertSpToTurfFeature.d.ts +2 -2
  10. package/dist/core/index.d.ts +0 -3
  11. package/dist/hooks/index.d.ts +2 -1
  12. package/dist/hooks/map/index.d.ts +1 -18
  13. package/dist/hooks/map/useMapContext.d.ts +1 -1
  14. package/dist/hooks/map/useMapDraw/customModes.d.ts +6 -1
  15. package/dist/hooks/map/useZoomToFeatures.d.ts +2 -2
  16. package/dist/hooks/serverNotifications/index.d.ts +0 -1
  17. package/dist/hooks/serverNotifications/useServerNotificationsContext.d.ts +1 -1
  18. package/dist/hooks/useDebouncedCallback.d.ts +1 -0
  19. package/dist/hooks/useWindowResize.d.ts +1 -0
  20. package/dist/index.d.ts +3 -0
  21. package/dist/react.cjs.development.js +630 -524
  22. package/dist/react.cjs.development.js.map +1 -1
  23. package/dist/react.cjs.production.min.js +1 -1
  24. package/dist/react.cjs.production.min.js.map +1 -1
  25. package/dist/react.esm.js +617 -506
  26. package/dist/react.esm.js.map +1 -1
  27. package/dist/types/index.d.ts +2 -0
  28. package/dist/utils/debounce.d.ts +1 -0
  29. package/dist/utils/index.d.ts +1 -1
  30. package/package.json +3 -3
  31. package/dist/components/Map/components/BuildingsLayer/BuildingsLayer.d.ts +0 -3
  32. package/dist/components/Map/components/BuildingsLayer/index.d.ts +0 -2
  33. package/dist/components/Map/components/BuildingsLayer/types.d.ts +0 -4
  34. package/dist/components/Map/components/index.d.ts +0 -2
  35. package/dist/components/MapContext/types.d.ts +0 -138
  36. package/dist/components/ResizablePanel/ResizablePanel.d.ts +0 -3
  37. package/dist/components/ResizablePanel/index.d.ts +0 -2
  38. package/dist/components/ResizablePanel/styled.d.ts +0 -11
  39. package/dist/components/ResizablePanel/types.d.ts +0 -14
  40. package/dist/core/attributes/index.d.ts +0 -1
  41. package/dist/core/geometrySelection/drawModeToGeometrySelectionType.d.ts +0 -3
  42. package/dist/core/geometrySelection/getGeometrySelectionTurfFeature.d.ts +0 -3
  43. package/dist/core/geometrySelection/index.d.ts +0 -2
  44. package/dist/core/types/index.d.ts +0 -2
  45. package/dist/core/types/map.d.ts +0 -5
  46. package/dist/hooks/map/useCurrentSelectedFeature.d.ts +0 -2
  47. package/dist/hooks/map/useEditingFeature.d.ts +0 -1
  48. package/dist/hooks/map/useEwktGeometry.d.ts +0 -1
  49. package/dist/hooks/map/useGeometryEditor.d.ts +0 -2
  50. package/dist/hooks/map/useGeometrySelection.d.ts +0 -2
  51. package/dist/hooks/map/useGeometrySelectionBuffer.d.ts +0 -1
  52. package/dist/hooks/map/useSelectFeaturesCount.d.ts +0 -1
  53. package/dist/hooks/map/useSelectFeaturesCurrentIndex.d.ts +0 -1
  54. package/dist/hooks/map/useSelectFeaturesGeometryMasking.d.ts +0 -1
  55. package/dist/hooks/map/useSelectFeaturesInitialized.d.ts +0 -1
  56. package/dist/hooks/map/useSelectFeaturesLayerName.d.ts +0 -1
  57. package/dist/hooks/map/useSelectFeaturesPagination.d.ts +0 -4
  58. package/dist/hooks/map/useSelectFeaturesStatisticsActive.d.ts +0 -1
  59. package/dist/hooks/map/useSelectFeaturesTotalCounts.d.ts +0 -1
  60. package/dist/hooks/map/useSelectedFeatures.d.ts +0 -2
  61. package/dist/hooks/map/useUpdateCurrentFeature.d.ts +0 -2
  62. package/dist/hooks/map/useZoomToLayer.d.ts +0 -7
  63. package/dist/hooks/useResizer.d.ts +0 -28
  64. package/dist/utils/geometryToWkt.d.ts +0 -2
  65. /package/dist/components/{Map/components/Layer → Layer}/Layer.d.ts +0 -0
  66. /package/dist/components/{Map/components/Layer → Layer}/RasterLayer.d.ts +0 -0
  67. /package/dist/components/{Map/components/Layer → Layer}/VectorLayer.d.ts +0 -0
  68. /package/dist/components/{Map/components/Layer → Layer}/constants.d.ts +0 -0
  69. /package/dist/{components → contexts}/MapContext/MapContext.d.ts +0 -0
  70. /package/dist/{components → contexts}/MapContext/MapProvider.d.ts +0 -0
  71. /package/dist/{components → contexts}/MapContext/index.d.ts +0 -0
  72. /package/dist/{components → contexts}/ServerNotificationsContext/ServerNotificationsContext.d.ts +0 -0
  73. /package/dist/{components → contexts}/ServerNotificationsContext/ServerNotificationsProvider.d.ts +0 -0
  74. /package/dist/{hooks/serverNotifications → contexts/ServerNotificationsContext/hooks}/useServerNotifications.d.ts +0 -0
  75. /package/dist/{components → contexts}/ServerNotificationsContext/index.d.ts +0 -0
  76. /package/dist/{components → contexts}/ServerNotificationsContext/types.d.ts +0 -0
  77. /package/dist/{core/attributes/types.d.ts → types/attribute.d.ts} +0 -0
  78. /package/dist/{core/types → types}/styling.d.ts +0 -0
package/dist/react.esm.js CHANGED
@@ -1,17 +1,269 @@
1
- import { isEmpty, isNil } from 'lodash-es';
1
+ import React, { Component, useCallback, useEffect, createContext, useRef, useState, useContext, useMemo } from 'react';
2
+ import styled from 'styled-components';
3
+ import MapGL, { Source, Layer as Layer$1 } from 'react-map-gl/mapbox';
2
4
  import { GeometryType } from '@evergis/api';
3
- import { polygon, multiLineString, multiPoint, point, bbox, toWgs84, lineString, toMercator } from '@turf/turf';
4
- import { useContext, useMemo, createContext, useCallback, useEffect, useRef, useState, useLayoutEffect } from 'react';
5
- import 'styled-components';
6
- import 'react-map-gl/mapbox';
5
+ import { isEmpty } from 'lodash-es';
6
+ import { polygon, multiLineString, multiPoint, point, bbox } from '@turf/turf';
7
7
  import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css';
8
- import 'find-and';
9
- import { isValid, toDate, format, parseJSON, parseISO } from 'date-fns';
10
- import { stringify } from 'wkt';
11
8
  import MapboxDraw from '@mapbox/mapbox-gl-draw';
12
9
  import { HubConnectionBuilder, LogLevel } from '@microsoft/signalr';
10
+ import { isValid, toDate, format, parseJSON, parseISO } from 'date-fns';
13
11
  import 'mapbox-gl/dist/mapbox-gl.css';
14
12
 
13
+ function _classCallCheck(instance, Constructor) {
14
+ if (!(instance instanceof Constructor)) {
15
+ throw new TypeError("Cannot call a class as a function");
16
+ }
17
+ }
18
+
19
+ function _defineProperties(target, props) {
20
+ for (var i = 0; i < props.length; i++) {
21
+ var descriptor = props[i];
22
+ descriptor.enumerable = descriptor.enumerable || false;
23
+ descriptor.configurable = true;
24
+ if ("value" in descriptor) descriptor.writable = true;
25
+ Object.defineProperty(target, descriptor.key, descriptor);
26
+ }
27
+ }
28
+
29
+ function _createClass(Constructor, protoProps, staticProps) {
30
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
31
+ if (staticProps) _defineProperties(Constructor, staticProps);
32
+ return Constructor;
33
+ }
34
+
35
+ function _extends() {
36
+ _extends = Object.assign || function (target) {
37
+ for (var i = 1; i < arguments.length; i++) {
38
+ var source = arguments[i];
39
+
40
+ for (var key in source) {
41
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
42
+ target[key] = source[key];
43
+ }
44
+ }
45
+ }
46
+
47
+ return target;
48
+ };
49
+
50
+ return _extends.apply(this, arguments);
51
+ }
52
+
53
+ function _inherits(subClass, superClass) {
54
+ if (typeof superClass !== "function" && superClass !== null) {
55
+ throw new TypeError("Super expression must either be null or a function");
56
+ }
57
+
58
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
59
+ constructor: {
60
+ value: subClass,
61
+ writable: true,
62
+ configurable: true
63
+ }
64
+ });
65
+ if (superClass) _setPrototypeOf(subClass, superClass);
66
+ }
67
+
68
+ function _getPrototypeOf(o) {
69
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
70
+ return o.__proto__ || Object.getPrototypeOf(o);
71
+ };
72
+ return _getPrototypeOf(o);
73
+ }
74
+
75
+ function _setPrototypeOf(o, p) {
76
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
77
+ o.__proto__ = p;
78
+ return o;
79
+ };
80
+
81
+ return _setPrototypeOf(o, p);
82
+ }
83
+
84
+ function _objectWithoutPropertiesLoose(source, excluded) {
85
+ if (source == null) return {};
86
+ var target = {};
87
+ var sourceKeys = Object.keys(source);
88
+ var key, i;
89
+
90
+ for (i = 0; i < sourceKeys.length; i++) {
91
+ key = sourceKeys[i];
92
+ if (excluded.indexOf(key) >= 0) continue;
93
+ target[key] = source[key];
94
+ }
95
+
96
+ return target;
97
+ }
98
+
99
+ function _assertThisInitialized(self) {
100
+ if (self === void 0) {
101
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
102
+ }
103
+
104
+ return self;
105
+ }
106
+
107
+ function _possibleConstructorReturn(self, call) {
108
+ if (call && (typeof call === "object" || typeof call === "function")) {
109
+ return call;
110
+ }
111
+
112
+ return _assertThisInitialized(self);
113
+ }
114
+
115
+ function _taggedTemplateLiteralLoose(strings, raw) {
116
+ if (!raw) {
117
+ raw = strings.slice(0);
118
+ }
119
+
120
+ strings.raw = raw;
121
+ return strings;
122
+ }
123
+
124
+ var _templateObject;
125
+ const ErrorBoundaryContainer = /*#__PURE__*/styled.div(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100vh;\n"])));
126
+
127
+ function _callSuper(_this, derived, args) {
128
+ function isNativeReflectConstruct() {
129
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
130
+ if (Reflect.construct.sham) return false;
131
+ if (typeof Proxy === "function") return true;
132
+
133
+ try {
134
+ return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
135
+ } catch (e) {
136
+ return false;
137
+ }
138
+ }
139
+
140
+ derived = _getPrototypeOf(derived);
141
+ return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args));
142
+ }
143
+ let ErrorBoundary = /*#__PURE__*/function (_Component) {
144
+ function ErrorBoundary() {
145
+ var _this2;
146
+
147
+ _classCallCheck(this, ErrorBoundary);
148
+
149
+ _this2 = _callSuper(this, ErrorBoundary, arguments);
150
+ _this2.state = {
151
+ hasError: false
152
+ };
153
+ return _this2;
154
+ }
155
+
156
+ _inherits(ErrorBoundary, _Component);
157
+
158
+ return _createClass(ErrorBoundary, [{
159
+ key: "componentDidCatch",
160
+ value: function componentDidCatch(error) {
161
+ // eslint-disable-next-line no-console
162
+ console.error(error);
163
+ }
164
+ }, {
165
+ key: "render",
166
+ value: function render() {
167
+ const {
168
+ children,
169
+ errorContents
170
+ } = this.props;
171
+ const {
172
+ hasError
173
+ } = this.state;
174
+ return !hasError ? React.createElement(React.Fragment, null, children) : React.createElement(ErrorBoundaryContainer, null, errorContents);
175
+ }
176
+ }], [{
177
+ key: "getDerivedStateFromError",
178
+ value: function getDerivedStateFromError() {
179
+ return {
180
+ hasError: true
181
+ };
182
+ }
183
+ }]);
184
+ }(Component);
185
+
186
+ const DEFAULT_COLOR = "#00ffff";
187
+ const DEFAULT_OPACITY = 0.5;
188
+ const DEFAULT_SIZE = 4;
189
+ const DEFAULT_LINE_WIDTH = 1;
190
+ const DEFAULT_CIRCLE_PAINT = {
191
+ "circle-radius": DEFAULT_SIZE,
192
+ "circle-color": DEFAULT_COLOR,
193
+ "circle-opacity": DEFAULT_OPACITY,
194
+ "circle-stroke-width": 0,
195
+ "circle-stroke-color": DEFAULT_COLOR,
196
+ "circle-stroke-opacity": DEFAULT_OPACITY
197
+ };
198
+ const DEFAULT_FILL_PAINT = {
199
+ "fill-color": DEFAULT_COLOR,
200
+ "fill-opacity": DEFAULT_OPACITY
201
+ };
202
+ const DEFAULT_FILL_EXTRUSION_PAINT = {
203
+ "fill-extrusion-base": 0,
204
+ "fill-extrusion-vertical-gradient": true,
205
+ "fill-extrusion-color": DEFAULT_COLOR,
206
+ "fill-extrusion-opacity": DEFAULT_OPACITY,
207
+ "fill-extrusion-height": 0
208
+ };
209
+ const DEFAULT_LINE_PAINT = {
210
+ "line-color": DEFAULT_COLOR,
211
+ "line-width": DEFAULT_LINE_WIDTH,
212
+ "line-opacity": DEFAULT_OPACITY
213
+ };
214
+
215
+ const RasterLayer = (_ref) => {
216
+ let {
217
+ layer,
218
+ tileUrl,
219
+ visible,
220
+ beforeId
221
+ } = _ref;
222
+
223
+ if (!layer) {
224
+ return null;
225
+ }
226
+
227
+ return React.createElement(Source, {
228
+ id: layer.name,
229
+ type: "raster",
230
+ tiles: [tileUrl]
231
+ }, React.createElement(Layer$1, {
232
+ id: layer.name,
233
+ type: "raster",
234
+ "source-layer": "default",
235
+ beforeId: beforeId,
236
+ layout: {
237
+ visibility: visible ? "visible" : "none"
238
+ }
239
+ }));
240
+ };
241
+
242
+ const getClientStyleItemPrefixSuffix = (geometryType, type) => {
243
+ switch (geometryType) {
244
+ case GeometryType.Point:
245
+ return ["point-layer-", ""];
246
+
247
+ case GeometryType.Polyline:
248
+ return ["polyline-layer-", ""];
249
+
250
+ case GeometryType.Polygon:
251
+ switch (type) {
252
+ case "line":
253
+ return ["polygon-stroke-layer-", "-stroke"];
254
+
255
+ case "fill-extrusion":
256
+ return ["polygon-extrusion-layer-", "-extrusion"];
257
+
258
+ default:
259
+ return ["polygon-layer-", ""];
260
+ }
261
+
262
+ default:
263
+ return ["", ""];
264
+ }
265
+ };
266
+
15
267
  const findAttributeInExpression = expression => {
16
268
  if (Array.isArray(expression) && expression.length === 2 && expression[0] === "get") {
17
269
  return [expression[1]];
@@ -81,222 +333,175 @@ const convertSpToTurfFeature = geometry => {
81
333
  }
82
334
  };
83
335
 
84
- function _extends() {
85
- _extends = Object.assign || function (target) {
86
- for (var i = 1; i < arguments.length; i++) {
87
- var source = arguments[i];
88
-
89
- for (var key in source) {
90
- if (Object.prototype.hasOwnProperty.call(source, key)) {
91
- target[key] = source[key];
92
- }
93
- }
94
- }
336
+ const VectorLayer = (_ref) => {
337
+ var _layer$configuration;
95
338
 
96
- return target;
97
- };
98
-
99
- return _extends.apply(this, arguments);
100
- }
101
-
102
- const useMapContext = () => {
103
- return useContext(MapContext);
104
- };
105
-
106
- const useCurrentSelectedFeature = () => {
107
- const {
108
- selectFeatures
109
- } = useMapContext();
110
- return useMemo(() => {
111
- var _selectFeatures$featu;
112
-
113
- return (_selectFeatures$featu = selectFeatures.features) == null || (_selectFeatures$featu = _selectFeatures$featu[selectFeatures.layerName]) == null ? void 0 : _selectFeatures$featu.find(item => item.id === selectFeatures.currentId);
114
- }, [selectFeatures]);
115
- };
116
-
117
- const MapContext = /*#__PURE__*/createContext({});
118
-
119
- var BaseMapTheme;
120
-
121
- (function (BaseMapTheme) {
122
- BaseMapTheme["Light"] = "light";
123
- BaseMapTheme["Dark"] = "dark";
124
- })(BaseMapTheme || (BaseMapTheme = {}));
125
-
126
- var GeometrySelectionTypes;
127
-
128
- (function (GeometrySelectionTypes) {
129
- GeometrySelectionTypes["Point"] = "select_point";
130
- GeometrySelectionTypes["Line"] = "select_line";
131
- GeometrySelectionTypes["Circle"] = "select_circle";
132
- GeometrySelectionTypes["Rect"] = "select_rect";
133
- GeometrySelectionTypes["Polygon"] = "select_polygon";
134
- GeometrySelectionTypes["Zones"] = "zones_selection";
135
- GeometrySelectionTypes["Coordinates"] = "xy";
136
- GeometrySelectionTypes["Route"] = "selection_route";
137
- })(GeometrySelectionTypes || (GeometrySelectionTypes = {}));
138
-
139
- var GeometrySelectionToolTypes;
140
-
141
- (function (GeometrySelectionToolTypes) {
142
- GeometrySelectionToolTypes["Replace"] = "Replace";
143
- GeometrySelectionToolTypes["Unite"] = "Unite";
144
- GeometrySelectionToolTypes["Crop"] = "Crop";
145
- GeometrySelectionToolTypes["Edit"] = "Edit";
146
- })(GeometrySelectionToolTypes || (GeometrySelectionToolTypes = {}));
147
-
148
- var GeometrySelectionZoneTypes;
149
-
150
- (function (GeometrySelectionZoneTypes) {
151
- GeometrySelectionZoneTypes["Walking"] = "Walking";
152
- GeometrySelectionZoneTypes["Car"] = "Car";
153
- })(GeometrySelectionZoneTypes || (GeometrySelectionZoneTypes = {}));
154
-
155
- var GeometrySelectionRouteTypes;
156
-
157
- (function (GeometrySelectionRouteTypes) {
158
- GeometrySelectionRouteTypes["Walking"] = "Walking";
159
- GeometrySelectionRouteTypes["Car"] = "Car";
160
- })(GeometrySelectionRouteTypes || (GeometrySelectionRouteTypes = {}));
161
-
162
- var GeometryEditorMode;
163
-
164
- (function (GeometryEditorMode) {
165
- GeometryEditorMode[GeometryEditorMode["Create"] = 0] = "Create";
166
- GeometryEditorMode[GeometryEditorMode["Edit"] = 1] = "Edit";
167
- GeometryEditorMode[GeometryEditorMode["Transform"] = 2] = "Transform";
168
- GeometryEditorMode[GeometryEditorMode["Expand"] = 3] = "Expand";
169
- GeometryEditorMode[GeometryEditorMode["Unite"] = 4] = "Unite";
170
- GeometryEditorMode[GeometryEditorMode["Subtract"] = 5] = "Subtract";
171
- })(GeometryEditorMode || (GeometryEditorMode = {}));
172
-
173
- const useGeometryEditor = () => {
174
- const {
175
- geometryEditor,
176
- setGeometryEditor
177
- } = useMapContext();
178
- const update = useCallback(newState => {
179
- setGeometryEditor(prevState => _extends({}, prevState, newState));
180
- }, [setGeometryEditor]);
181
- return [geometryEditor, update];
182
- };
183
-
184
- const useEditingFeature = () => {
185
- const [{
186
- layerName,
187
- active,
188
- mode
189
- }] = useGeometryEditor();
190
- const currentSelectedFeature = useCurrentSelectedFeature();
191
- return useMemo(() => {
192
- return active && (mode === GeometryEditorMode.Edit && layerName === (currentSelectedFeature == null ? void 0 : currentSelectedFeature.layer) || mode === GeometryEditorMode.Create);
193
- }, [active, currentSelectedFeature, layerName, mode]);
194
- };
195
-
196
- const useGeometrySelection = () => {
339
+ let {
340
+ layer,
341
+ tileUrl,
342
+ visible,
343
+ beforeId,
344
+ getLayerTempStyle,
345
+ onMount = () => null
346
+ } = _ref;
347
+ const clientStyle = layer == null || (_layer$configuration = layer.configuration) == null ? void 0 : _layer$configuration.clientStyle;
197
348
  const {
198
- geometrySelection,
199
- setGeometrySelection
200
- } = useMapContext();
201
- const updateGeometrySelection = useCallback(newState => {
202
- setGeometrySelection(prevState => _extends({}, prevState, newState));
203
- }, [setGeometrySelection]);
204
- return [geometrySelection, updateGeometrySelection];
205
- };
206
-
207
- const NO_CONTENT_VALUE = "—";
208
- var DateFormat;
209
-
210
- (function (DateFormat) {
211
- DateFormat["ClientDefaultFormat"] = "dd.MM.yyyy HH:mm";
212
- DateFormat["DateTime"] = "dd.MM.yyyy HH:mm:ss";
213
- DateFormat["UTC"] = "yyyy-MM-dd'T'HH:mm:ss.sssxxx";
214
- DateFormat["AxisTooltip"] = "d MMMM yyyy";
215
- })(DateFormat || (DateFormat = {}));
216
-
217
- const stringDateParsers = [parseJSON, parseISO, rawDate => new Date(rawDate)];
218
- const getDate = rawDate => {
219
- if (!rawDate) return null;
349
+ idAttribute,
350
+ geometryType
351
+ } = layer.layerDefinition || {};
352
+ const renderLayerByGeometryType = useCallback(() => {
353
+ var _getLayerTempStyle, _getLayerTempStyle2, _getLayerTempStyle3, _getLayerTempStyle4, _getLayerTempStyle5, _getLayerTempStyle6, _getLayerTempStyle7, _getLayerTempStyle8, _getLayerTempStyle9, _getLayerTempStyle10, _getLayerTempStyle11, _getLayerTempStyle12, _getLayerTempStyle13, _getLayerTempStyle14;
354
+
355
+ const visibility = visible ? "visible" : "none";
356
+
357
+ switch (geometryType) {
358
+ case GeometryType.Point:
359
+ return React.createElement(Layer$1, {
360
+ id: layer.name,
361
+ type: "circle",
362
+ "source-layer": "default",
363
+ beforeId: beforeId,
364
+ layout: _extends({}, getLayerTempStyle == null || (_getLayerTempStyle = getLayerTempStyle(layer.name, "circle")) == null ? void 0 : _getLayerTempStyle.layout, {
365
+ visibility
366
+ }),
367
+ paint: _extends({}, DEFAULT_CIRCLE_PAINT, getLayerTempStyle == null || (_getLayerTempStyle2 = getLayerTempStyle(layer.name, "circle")) == null ? void 0 : _getLayerTempStyle2.paint)
368
+ });
220
369
 
221
- if (typeof rawDate === "string") {
222
- for (const parser of stringDateParsers) {
223
- const date = parser(rawDate);
370
+ case GeometryType.Polygon:
371
+ return [React.createElement(Layer$1, {
372
+ key: "polygon-layer-" + layer.name,
373
+ id: layer.name,
374
+ type: "fill",
375
+ "source-layer": "default",
376
+ beforeId: beforeId,
377
+ layout: _extends({}, getLayerTempStyle == null || (_getLayerTempStyle3 = getLayerTempStyle(layer.name, "fill")) == null ? void 0 : _getLayerTempStyle3.layout, {
378
+ visibility: visible && (getLayerTempStyle == null || (_getLayerTempStyle4 = getLayerTempStyle(layer.name, "fill-extrusion")) == null || (_getLayerTempStyle4 = _getLayerTempStyle4.settings) == null || (_getLayerTempStyle4 = _getLayerTempStyle4.fill) == null ? void 0 : _getLayerTempStyle4.showBottomSurface) !== false && Boolean(getActualExtrusionHeight(_extends({}, DEFAULT_FILL_EXTRUSION_PAINT, getLayerTempStyle == null || (_getLayerTempStyle5 = getLayerTempStyle(layer.name, "fill-extrusion")) == null ? void 0 : _getLayerTempStyle5.paint))) ? "visible" : "none"
379
+ }),
380
+ paint: _extends({}, DEFAULT_FILL_PAINT, getLayerTempStyle == null || (_getLayerTempStyle6 = getLayerTempStyle(layer.name, "fill")) == null ? void 0 : _getLayerTempStyle6.paint)
381
+ }), React.createElement(Layer$1, {
382
+ key: "polygon-stroke-layer-" + layer.name,
383
+ id: layer.name + "-stroke",
384
+ type: "line",
385
+ "source-layer": "default",
386
+ beforeId: beforeId,
387
+ layout: _extends({}, getLayerTempStyle == null || (_getLayerTempStyle7 = getLayerTempStyle(layer.name, "line")) == null ? void 0 : _getLayerTempStyle7.layout, {
388
+ visibility: visible && (getLayerTempStyle == null || (_getLayerTempStyle8 = getLayerTempStyle(layer.name, "fill-extrusion")) == null || (_getLayerTempStyle8 = _getLayerTempStyle8.settings) == null || (_getLayerTempStyle8 = _getLayerTempStyle8.fill) == null ? void 0 : _getLayerTempStyle8.showBottomSurface) !== false && Boolean(getActualExtrusionHeight(_extends({}, DEFAULT_FILL_EXTRUSION_PAINT, getLayerTempStyle == null || (_getLayerTempStyle9 = getLayerTempStyle(layer.name, "fill-extrusion")) == null ? void 0 : _getLayerTempStyle9.paint))) ? "visible" : "none"
389
+ }),
390
+ paint: _extends({}, DEFAULT_LINE_PAINT, getLayerTempStyle == null || (_getLayerTempStyle10 = getLayerTempStyle(layer.name, "line")) == null ? void 0 : _getLayerTempStyle10.paint)
391
+ }), React.createElement(Layer$1, {
392
+ key: "polygon-extrusion-layer-" + layer.name,
393
+ id: layer.name + "-extrusion",
394
+ type: "fill-extrusion",
395
+ "source-layer": "default",
396
+ beforeId: beforeId,
397
+ minzoom: 0,
398
+ maxzoom: 23,
399
+ layout: _extends({}, getLayerTempStyle == null || (_getLayerTempStyle11 = getLayerTempStyle(layer.name, "fill-extrusion")) == null ? void 0 : _getLayerTempStyle11.layout, {
400
+ visibility
401
+ }),
402
+ paint: _extends({}, DEFAULT_FILL_EXTRUSION_PAINT, getLayerTempStyle == null || (_getLayerTempStyle12 = getLayerTempStyle(layer.name, "fill-extrusion")) == null ? void 0 : _getLayerTempStyle12.paint)
403
+ })];
404
+
405
+ case GeometryType.Polyline:
406
+ return React.createElement(Layer$1, {
407
+ id: layer.name,
408
+ type: "line",
409
+ "source-layer": "default",
410
+ beforeId: beforeId,
411
+ layout: _extends({}, getLayerTempStyle == null || (_getLayerTempStyle13 = getLayerTempStyle(layer.name, "line")) == null ? void 0 : _getLayerTempStyle13.layout, {
412
+ visibility
413
+ }),
414
+ paint: _extends({}, DEFAULT_LINE_PAINT, getLayerTempStyle == null || (_getLayerTempStyle14 = getLayerTempStyle(layer.name, "line")) == null ? void 0 : _getLayerTempStyle14.paint)
415
+ });
224
416
 
225
- if (isValid(date)) {
226
- return toDate(date);
227
- }
417
+ default:
418
+ return null;
228
419
  }
420
+ }, [geometryType, layer, beforeId, getLayerTempStyle, visible]);
421
+ const renderClientStyle = useCallback(() => {
422
+ return clientStyle.items.map(mockItem => {
423
+ var _clientStyle$items, _getLayerTempStyle15, _getLayerTempStyle16, _currentSettings$fill, _currentSettings$fill2, _clientStyle$minzoom, _clientStyle$maxzoom, _getLayerTempStyle17, _getLayerTempStyle18;
424
+
425
+ const prefixSuffix = getClientStyleItemPrefixSuffix(geometryType, mockItem.type);
426
+ const isExtrusionItem = mockItem.type === "fill-extrusion";
427
+ const isPolygonPart = clientStyle.items.some(item => item.type === "fill-extrusion") && (mockItem.type === "fill" || mockItem.type === "line");
428
+ const fillExtrusionPaint = isPolygonPart || isExtrusionItem ? _extends({}, (_clientStyle$items = clientStyle.items) == null || (_clientStyle$items = _clientStyle$items.find(item => item.type === "fill-extrusion")) == null ? void 0 : _clientStyle$items.paint, getLayerTempStyle == null || (_getLayerTempStyle15 = getLayerTempStyle(layer.name, "fill-extrusion")) == null ? void 0 : _getLayerTempStyle15.paint) : undefined;
429
+
430
+ const currentSettings = _extends({}, clientStyle == null ? void 0 : clientStyle.settings, getLayerTempStyle == null || (_getLayerTempStyle16 = getLayerTempStyle(layer.name, mockItem.type)) == null ? void 0 : _getLayerTempStyle16.settings);
431
+
432
+ const processedExtrusionHeight = getActualExtrusionHeight(fillExtrusionPaint);
433
+ const hasExtrusion = Boolean(processedExtrusionHeight);
434
+ const visibility = visible && (isExtrusionItem && hasExtrusion || !isPolygonPart && !isExtrusionItem || isPolygonPart && (!hasExtrusion || ((_currentSettings$fill = currentSettings == null || (_currentSettings$fill2 = currentSettings.fill) == null ? void 0 : _currentSettings$fill2.showBottomSurface) != null ? _currentSettings$fill : true))) ? "visible" : "none";
435
+ return React.createElement(Layer$1, {
436
+ key: "" + prefixSuffix[0] + layer.name,
437
+ id: "" + layer.name + prefixSuffix[1],
438
+ type: mockItem.type,
439
+ "source-layer": "default",
440
+ beforeId: beforeId,
441
+ minzoom: (_clientStyle$minzoom = clientStyle == null ? void 0 : clientStyle.minzoom) != null ? _clientStyle$minzoom : 0,
442
+ maxzoom: (_clientStyle$maxzoom = clientStyle == null ? void 0 : clientStyle.maxzoom) != null ? _clientStyle$maxzoom : 23,
443
+ layout: _extends({}, mockItem.layout, getLayerTempStyle == null || (_getLayerTempStyle17 = getLayerTempStyle(layer.name, mockItem.type)) == null ? void 0 : _getLayerTempStyle17.layout, {
444
+ visibility
445
+ }),
446
+ paint: _extends({}, mockItem.paint, getLayerTempStyle == null || (_getLayerTempStyle18 = getLayerTempStyle(layer.name, mockItem.type)) == null ? void 0 : _getLayerTempStyle18.paint)
447
+ });
448
+ });
449
+ }, [beforeId, clientStyle, geometryType, layer.name, visible, getLayerTempStyle]);
450
+ useEffect(onMount, [layer.name]); // eslint-disable-line
229
451
 
452
+ if (!layer) {
230
453
  return null;
231
454
  }
232
455
 
233
- const parsedDate = toDate(rawDate);
234
- return isValid(parsedDate) ? parsedDate : null;
456
+ return React.createElement(Source, {
457
+ promoteId: idAttribute,
458
+ id: layer.name,
459
+ type: "vector",
460
+ tiles: [tileUrl]
461
+ }, clientStyle != null && clientStyle.items ? renderClientStyle() : renderLayerByGeometryType());
235
462
  };
236
- const formatDate = function formatDate(date, _temp) {
237
- let {
238
- dateFormat = DateFormat.ClientDefaultFormat,
239
- defaultValue = NO_CONTENT_VALUE
240
- } = _temp === void 0 ? {} : _temp;
241
- const dateValue = date ? getDate(date) : null;
242
463
 
243
- if (isValid(dateValue)) {
244
- return format(dateValue, dateFormat);
245
- }
246
-
247
- return defaultValue.toString();
248
- };
464
+ const Layer = (_ref) => {
465
+ let {
466
+ layer,
467
+ layerType,
468
+ visible,
469
+ beforeId,
470
+ tileUrl,
471
+ onMount = () => null
472
+ } = _ref;
473
+ useEffect(onMount, [layer.name]); // eslint-disable-line
249
474
 
250
- const geometryToWkt = function geometryToWkt(features) {
251
- if (features === void 0) {
252
- features = [];
475
+ if (!layer) {
476
+ return null;
253
477
  }
254
478
 
255
- if (features.length === 0) {
256
- return "";
479
+ if (layerType === "RasterTileLayer") {
480
+ return React.createElement(RasterLayer, {
481
+ layer: layer,
482
+ tileUrl: tileUrl,
483
+ visible: visible,
484
+ beforeId: beforeId,
485
+ onMount: onMount
486
+ });
257
487
  }
258
488
 
259
- return stringify(features[0]);
260
- };
261
-
262
- const isNumeric = number => !isNaN(parseFloat(number)) && isFinite(number);
263
-
264
- function isObject(value) {
265
- return typeof value === "object" && value !== null && !Array.isArray(value);
266
- }
267
-
268
- const useEwktGeometry = () => {
269
- const [{
270
- history,
271
- type
272
- }] = useGeometrySelection();
273
- return useMemo(() => {
274
- var _history$zones$histor, _history$zones$histor2;
275
-
276
- if (history.step === -1) {
277
- return "";
278
- }
279
-
280
- return type === GeometrySelectionTypes.Zones ? !isEmpty((_history$zones$histor = history.zones[history.step]) == null ? void 0 : _history$zones$histor[0]) ? "SRID=3857;" + geometryToWkt((_history$zones$histor2 = history.zones[history.step]) == null ? void 0 : _history$zones$histor2[0]) : "SRID=3857;" + geometryToWkt(history.features[history.step]) : "SRID=3857;" + geometryToWkt(history.features[history.step]);
281
- }, [history.features, history.step, history.zones, type]);
489
+ return React.createElement(VectorLayer, {
490
+ layer: layer,
491
+ tileUrl: tileUrl,
492
+ visible: visible,
493
+ beforeId: beforeId,
494
+ onMount: onMount
495
+ });
282
496
  };
283
497
 
284
- const useGeometrySelectionBuffer = () => {
285
- const [{
286
- settings: {
287
- bufferRadius,
288
- bufferMultiplier
289
- },
290
- isBuffer
291
- }] = useGeometrySelection();
292
- return useMemo(() => {
293
- if (!isBuffer || !bufferRadius) {
294
- return undefined;
295
- }
296
-
297
- return Number((+bufferRadius || 0) * +bufferMultiplier).toFixed(2);
298
- }, [isBuffer, bufferRadius, bufferMultiplier]);
299
- };
498
+ var _templateObject$1;
499
+ const MapWrapper = /*#__PURE__*/styled.div(_templateObject$1 || (_templateObject$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n width: 100%;\n height: 100%;\n box-sizing: border-box;\n z-index: ", ";\n\n .mapbox-gl-draw_trash {\n display: none;\n }\n\n .mapboxgl-ctrl-logo {\n display: none;\n }\n\n .mapboxgl-ctrl.mapboxgl-ctrl-attrib {\n display: none;\n }\n\n .mapboxgl-ctrl-geocoder.mapboxgl-ctrl {\n width: 350px;\n }\n"])), (_ref) => {
500
+ let {
501
+ $zIndex
502
+ } = _ref;
503
+ return $zIndex != null ? $zIndex : 1;
504
+ });
300
505
 
301
506
  const customModes = MapboxDraw.modes;
302
507
  const StaticMode = {};
@@ -413,6 +618,122 @@ const customStyles = [{
413
618
  }
414
619
  }];
415
620
 
621
+ const MapContext = /*#__PURE__*/createContext({});
622
+
623
+ const MapProvider = (_ref) => {
624
+ let {
625
+ basemapItems,
626
+ defaultBasemap,
627
+ children
628
+ } = _ref;
629
+ const map = useRef();
630
+ const draw = useRef();
631
+ const [loaded, setLoaded] = useState(false);
632
+ const [basemapName, setBasemapName] = useState(defaultBasemap);
633
+ return React.createElement(MapContext.Provider, {
634
+ value: {
635
+ map,
636
+ draw,
637
+ loaded,
638
+ setLoaded,
639
+ basemapItems,
640
+ basemapName,
641
+ setBasemapName,
642
+ defaultBasemap
643
+ }
644
+ }, children);
645
+ };
646
+
647
+ var BaseMapTheme;
648
+
649
+ (function (BaseMapTheme) {
650
+ BaseMapTheme["Light"] = "light";
651
+ BaseMapTheme["Dark"] = "dark";
652
+ })(BaseMapTheme || (BaseMapTheme = {}));
653
+
654
+ const ServerNotificationsContext = /*#__PURE__*/createContext({});
655
+
656
+ const useServerNotifications = (url, initialized) => {
657
+ const hubConnection = useRef(null);
658
+ const [connection, setConnection] = useState(null);
659
+ useEffect(() => {
660
+ if (!initialized) {
661
+ return;
662
+ }
663
+
664
+ hubConnection.current = new HubConnectionBuilder().withUrl(url, {
665
+ withCredentials: true
666
+ }).configureLogging(LogLevel.Information).build();
667
+ hubConnection.current.start().then(() => console.info("Серверные нотификации подключены")).catch(err => console.info("Ошибка:", err)).finally(() => setConnection(hubConnection.current));
668
+ }, [initialized]); // eslint-disable-line
669
+
670
+ useEffect(() => {
671
+ if (!connection || connection.state !== "Connected") {
672
+ return;
673
+ }
674
+
675
+ connection.invoke("SubscribeNotifications", []).then(() => console.info("Подписка `SubscribeNotifications` оформлена")).catch(err => console.info("Ошибка подписки `SubscribeNotifications`:", err));
676
+ }, [connection]);
677
+ return connection;
678
+ };
679
+
680
+ const ServerNotificationsProvider = (_ref) => {
681
+ let {
682
+ url,
683
+ initialized,
684
+ children
685
+ } = _ref;
686
+ const connection = useServerNotifications(url, initialized);
687
+ const addSubscription = useCallback(async payload => {
688
+ if (!connection || connection.state !== "Connected" || !payload) {
689
+ return;
690
+ }
691
+
692
+ try {
693
+ const id = await connection.invoke("AddSubscription", payload);
694
+ console.info("Подписка добавлена, id:", id);
695
+ return id;
696
+ } catch (err) {
697
+ console.info("Ошибка добавления подписки:", err);
698
+ return Promise.resolve(null);
699
+ }
700
+ }, [connection]);
701
+ const updateSubscription = useCallback(async (id, payload) => {
702
+ if (!connection || connection.state !== "Connected" || !id || !payload) {
703
+ return;
704
+ }
705
+
706
+ try {
707
+ await connection.invoke("UpdateSubscription", id, payload);
708
+ } catch (err) {
709
+ console.info("\u041E\u0448\u0438\u0431\u043A\u0430 \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0438\u044F \u043F\u043E\u0434\u043F\u0438\u0441\u043A\u0438 " + id + ":", err);
710
+ }
711
+ }, [connection]);
712
+ const unsubscribeById = useCallback(async id => {
713
+ if (!connection || connection.state !== "Connected" || !id) {
714
+ return;
715
+ }
716
+
717
+ try {
718
+ await connection.invoke("Unsubscribe", [id]);
719
+ } catch (err) {
720
+ console.info("\u041E\u0448\u0438\u0431\u043A\u0430 \u043E\u0442\u043F\u0438\u0441\u043A\u0438 \u043F\u043E " + id + ":", err);
721
+ }
722
+ }, [connection]);
723
+ return React.createElement(ServerNotificationsContext.Provider, {
724
+ value: {
725
+ connection,
726
+ addSubscription,
727
+ updateSubscription,
728
+ unsubscribeById
729
+ }
730
+ }, children);
731
+ };
732
+
733
+ const useMapContext = () => {
734
+ return useContext(MapContext);
735
+ };
736
+
416
737
  const draw = /*#__PURE__*/new MapboxDraw({
417
738
  displayControlsDefault: false,
418
739
  styles: customStyles,
@@ -460,124 +781,6 @@ const useRedrawLayer = () => {
460
781
  }, [map]);
461
782
  };
462
783
 
463
- const useSelectedFeatures = () => {
464
- var _selectFeatures$featu;
465
-
466
- const {
467
- selectFeatures,
468
- setSelectedFeatures
469
- } = useMapContext();
470
- const updatSelectedFeatures = useCallback(features => {
471
- setSelectedFeatures(features);
472
- }, [setSelectedFeatures]);
473
- return [(_selectFeatures$featu = selectFeatures.features) != null ? _selectFeatures$featu : {}, updatSelectedFeatures];
474
- };
475
-
476
- const useSelectFeaturesCount = () => {
477
- const {
478
- selectFeatures
479
- } = useMapContext();
480
- return useMemo(() => {
481
- var _selectFeatures$featu, _selectFeatures$featu2;
482
-
483
- return (_selectFeatures$featu = (_selectFeatures$featu2 = selectFeatures.features) == null || (_selectFeatures$featu2 = _selectFeatures$featu2[selectFeatures.layerName]) == null ? void 0 : _selectFeatures$featu2.length) != null ? _selectFeatures$featu : 0;
484
- }, [selectFeatures]);
485
- };
486
-
487
- const useSelectFeaturesCurrentIndex = () => {
488
- const {
489
- selectFeatures
490
- } = useMapContext();
491
- return useMemo(() => {
492
- var _selectFeatures$featu, _selectFeatures$featu2;
493
-
494
- return (_selectFeatures$featu = selectFeatures.features) != null && (_selectFeatures$featu = _selectFeatures$featu[selectFeatures.layerName]) != null && _selectFeatures$featu.length ? (_selectFeatures$featu2 = selectFeatures.features) == null || (_selectFeatures$featu2 = _selectFeatures$featu2[selectFeatures.layerName]) == null ? void 0 : _selectFeatures$featu2.findIndex(feature => feature.id === selectFeatures.currentId) : -1;
495
- }, [selectFeatures]);
496
- };
497
-
498
- const useSelectFeaturesGeometryMasking = () => {
499
- const {
500
- selectFeatures,
501
- setSelectFeaturesGeometryMasking
502
- } = useMapContext();
503
- const update = useCallback(state => {
504
- setSelectFeaturesGeometryMasking(state);
505
- }, [setSelectFeaturesGeometryMasking]);
506
- return [selectFeatures.geometryMasking, update];
507
- };
508
-
509
- const useSelectFeaturesInitialized = () => {
510
- const {
511
- selectFeatures,
512
- setSelectFeaturesInitialized
513
- } = useMapContext();
514
- const update = useCallback(state => {
515
- setSelectFeaturesInitialized(state);
516
- }, [setSelectFeaturesInitialized]);
517
- return [selectFeatures.initialized, update];
518
- };
519
-
520
- const useSelectFeaturesLayerName = () => {
521
- const {
522
- selectFeatures,
523
- setSelectFeaturesLayerName
524
- } = useMapContext();
525
- const update = useCallback(name => {
526
- setSelectFeaturesLayerName(name);
527
- }, [setSelectFeaturesLayerName]);
528
- return [selectFeatures.layerName, update];
529
- };
530
-
531
- const useSelectFeaturesPagination = () => {
532
- const {
533
- setNextFeature,
534
- setPrevFeature
535
- } = useMapContext();
536
- const onNext = useCallback(() => {
537
- setNextFeature();
538
- }, [setNextFeature]);
539
- const onPrev = useCallback(() => {
540
- setPrevFeature();
541
- }, [setPrevFeature]);
542
- return {
543
- onNext,
544
- onPrev
545
- };
546
- };
547
-
548
- const useSelectFeaturesStatisticsActive = () => {
549
- const {
550
- selectFeatures,
551
- setSelectFeaturesStatisticsActive
552
- } = useMapContext();
553
- const update = useCallback(state => {
554
- setSelectFeaturesStatisticsActive(state);
555
- }, [setSelectFeaturesStatisticsActive]);
556
- return [selectFeatures.statisticsActive, update];
557
- };
558
-
559
- const useSelectFeaturesTotalCounts = () => {
560
- var _selectFeatures$total;
561
-
562
- const {
563
- selectFeatures,
564
- setSelectedFeaturesTotalCounts
565
- } = useMapContext();
566
- const update = useCallback(totalCounts => {
567
- setSelectedFeaturesTotalCounts(totalCounts);
568
- }, [setSelectedFeaturesTotalCounts]);
569
- return [(_selectFeatures$total = selectFeatures.totalCounts) != null ? _selectFeatures$total : {}, update];
570
- };
571
-
572
- const useUpdateCurrentFeature = () => {
573
- const {
574
- updateCurrentFeature
575
- } = useMapContext();
576
- return useCallback(values => {
577
- updateCurrentFeature(values);
578
- }, [updateCurrentFeature]);
579
- };
580
-
581
784
  const useZoomToFeatures = () => {
582
785
  const {
583
786
  map
@@ -597,24 +800,6 @@ const useZoomToFeatures = () => {
597
800
  }, [map]);
598
801
  };
599
802
 
600
- const DEFAULT_PADDING = 50;
601
- const useZoomToLayer = () => {
602
- const {
603
- map
604
- } = useMapContext();
605
- return useCallback(async (bulkExtent, options) => {
606
- var _options$padding;
607
-
608
- if (!bulkExtent || !bulkExtent.overall) {
609
- return;
610
- }
611
-
612
- map.current.fitBounds([...bulkExtent.overall.coordinates[0], ...bulkExtent.overall.coordinates[1]], {
613
- padding: (_options$padding = options == null ? void 0 : options.padding) != null ? _options$padding : DEFAULT_PADDING
614
- });
615
- }, [map]);
616
- };
617
-
618
803
  const useZoomToPoint = () => {
619
804
  const {
620
805
  map
@@ -634,153 +819,80 @@ const useZoomToPoint = () => {
634
819
  }, [map]);
635
820
  };
636
821
 
637
- const useServerNotifications = (url, initialized) => {
638
- const hubConnection = useRef(null);
639
- const [connection, setConnection] = useState(null);
640
- useEffect(() => {
641
- if (!initialized) {
642
- return;
643
- }
644
-
645
- hubConnection.current = new HubConnectionBuilder().withUrl(url, {
646
- withCredentials: true
647
- }).configureLogging(LogLevel.Information).build();
648
- hubConnection.current.start().then(() => console.info("Серверные нотификации подключены")).catch(err => console.info("Ошибка:", err)).finally(() => setConnection(hubConnection.current));
649
- }, [initialized]); // eslint-disable-line
650
-
651
- useEffect(() => {
652
- if (!connection || connection.state !== "Connected") {
653
- return;
654
- }
655
-
656
- connection.invoke("SubscribeNotifications", []).then(() => console.info("Подписка `SubscribeNotifications` оформлена")).catch(err => console.info("Ошибка подписки `SubscribeNotifications`:", err));
657
- }, [connection]);
658
- return connection;
659
- };
660
-
661
- const ServerNotificationsContext = /*#__PURE__*/createContext({});
662
-
663
822
  const useServerNotificationsContext = () => {
664
823
  return useContext(ServerNotificationsContext);
665
824
  };
666
825
 
667
- var VerticalPosition;
668
-
669
- (function (VerticalPosition) {
670
- VerticalPosition["Top"] = "top";
671
- VerticalPosition["Bottom"] = "bottom";
672
- })(VerticalPosition || (VerticalPosition = {}));
673
-
674
- var HorizontalPosition;
826
+ const NO_CONTENT_VALUE = "—";
827
+ var DateFormat;
675
828
 
676
- (function (HorizontalPosition) {
677
- HorizontalPosition["Left"] = "left";
678
- HorizontalPosition["Right"] = "right";
679
- })(HorizontalPosition || (HorizontalPosition = {}));
829
+ (function (DateFormat) {
830
+ DateFormat["ClientDefaultFormat"] = "dd.MM.yyyy HH:mm";
831
+ DateFormat["DateTime"] = "dd.MM.yyyy HH:mm:ss";
832
+ DateFormat["UTC"] = "yyyy-MM-dd'T'HH:mm:ss.sssxxx";
833
+ DateFormat["AxisTooltip"] = "d MMMM yyyy";
834
+ })(DateFormat || (DateFormat = {}));
680
835
 
681
- const useResizer = (_ref) => {
682
- let {
683
- handleVerticalPosition,
684
- handleHorizontalPosition,
685
- minWidth = Number.MIN_SAFE_INTEGER,
686
- maxWidth = Number.MAX_SAFE_INTEGER,
687
- horizontal = true,
688
- minHeight = Number.MIN_SAFE_INTEGER,
689
- maxHeight = Number.MAX_SAFE_INTEGER,
690
- vertical = true,
691
- useResize = false,
692
- onResize,
693
- onResizeEnd,
694
- onResizeStart
695
- } = _ref;
696
- const containerRef = useRef();
697
- const verticalHandleRef = useRef();
698
- const horizontalHandleRef = useRef();
699
- const updateSizes = useCallback((width, height) => {
700
- var _horizontalHandleRef$, _verticalHandleRef$cu;
836
+ const stringDateParsers = [parseJSON, parseISO, rawDate => new Date(rawDate)];
837
+ const getDate = rawDate => {
838
+ if (!rawDate) return null;
701
839
 
702
- let newWidth = width;
703
- let newHeight = height;
840
+ if (typeof rawDate === "string") {
841
+ for (const parser of stringDateParsers) {
842
+ const date = parser(rawDate);
704
843
 
705
- if (horizontal && newWidth < minWidth) {
706
- newWidth = minWidth;
844
+ if (isValid(date)) {
845
+ return toDate(date);
846
+ }
707
847
  }
708
848
 
709
- if (horizontal && newWidth > Math.min(window.innerWidth - ((_horizontalHandleRef$ = horizontalHandleRef.current) == null ? void 0 : _horizontalHandleRef$.clientWidth), maxWidth)) {
710
- newWidth = maxWidth;
711
- }
849
+ return null;
850
+ }
712
851
 
713
- if (vertical && newHeight < minHeight) {
714
- newHeight = minHeight;
715
- }
852
+ const parsedDate = toDate(rawDate);
853
+ return isValid(parsedDate) ? parsedDate : null;
854
+ };
855
+ const formatDate = function formatDate(date, _temp) {
856
+ let {
857
+ dateFormat = DateFormat.ClientDefaultFormat,
858
+ defaultValue = NO_CONTENT_VALUE
859
+ } = _temp === void 0 ? {} : _temp;
860
+ const dateValue = date ? getDate(date) : null;
716
861
 
717
- if (vertical && newHeight > Math.min(window.innerHeight - ((_verticalHandleRef$cu = verticalHandleRef.current) == null ? void 0 : _verticalHandleRef$cu.clientHeight), maxHeight)) {
718
- newHeight = maxHeight;
719
- }
862
+ if (isValid(dateValue)) {
863
+ return format(dateValue, dateFormat);
864
+ }
720
865
 
721
- if (horizontal) {
722
- requestAnimationFrame(() => {
723
- if (!isNil(containerRef.current)) {
724
- containerRef.current.style.width = newWidth + "px";
725
- }
726
- });
866
+ return defaultValue.toString();
867
+ };
868
+
869
+ const debounce = (callback, delay) => {
870
+ let timeId;
871
+ return function () {
872
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
873
+ args[_key] = arguments[_key];
727
874
  }
728
875
 
729
- if (vertical) {
730
- requestAnimationFrame(() => {
731
- if (!isNil(containerRef.current)) {
732
- containerRef.current.style.height = newHeight + "px";
733
- }
734
- });
876
+ if (timeId) {
877
+ window.clearTimeout(timeId);
735
878
  }
736
879
 
737
- onResize == null || onResize(newWidth, newHeight);
738
- }, [minWidth, maxWidth, minHeight, maxHeight, horizontal, vertical]);
739
- const onPointerMove = useCallback(pointerMoveEvent => {
740
- var _containerRef$current, _containerRef$current2, _containerRef$current3;
741
-
742
- const {
743
- x,
744
- y
745
- } = (_containerRef$current = containerRef.current) == null ? void 0 : _containerRef$current.getBoundingClientRect();
746
- const reverseHorizontal = handleHorizontalPosition === HorizontalPosition.Right;
747
- const reverseVertical = handleVerticalPosition === VerticalPosition.Bottom;
748
- const newWidth = reverseHorizontal ? pointerMoveEvent.pageX - x : ((_containerRef$current2 = containerRef.current) == null ? void 0 : _containerRef$current2.offsetWidth) + x - pointerMoveEvent.pageX;
749
- const newHeight = reverseVertical ? pointerMoveEvent.pageY - y : ((_containerRef$current3 = containerRef.current) == null ? void 0 : _containerRef$current3.offsetHeight) + y - pointerMoveEvent.pageY;
750
- document.body.style.userSelect = "none";
751
- updateSizes(newWidth, newHeight);
752
- }, [updateSizes]);
753
- const onPointerDown = useCallback(() => {
754
- const onPointerUp = () => {
755
- document.body.style.userSelect = "initial";
756
- document.body.removeEventListener("pointermove", onPointerMove);
757
-
758
- if (!isNil(containerRef.current)) {
759
- onResizeEnd == null || onResizeEnd(containerRef.current.offsetWidth, containerRef.current.offsetHeight);
760
- }
761
- };
880
+ timeId = window.setTimeout(() => {
881
+ callback(...args);
882
+ }, delay);
883
+ };
884
+ };
762
885
 
763
- if (!isNil(containerRef.current)) {
764
- onResizeStart == null || onResizeStart(containerRef.current.offsetWidth, containerRef.current.offsetHeight);
765
- }
886
+ const isNumeric = number => !isNaN(parseFloat(number)) && isFinite(number);
766
887
 
767
- document.body.addEventListener("pointermove", onPointerMove);
768
- document.body.addEventListener("pointerup", onPointerUp, {
769
- once: true
770
- });
771
- }, [onPointerMove]); // eslint-disable-line
888
+ function isObject(value) {
889
+ return typeof value === "object" && value !== null && !Array.isArray(value);
890
+ }
772
891
 
773
- useLayoutEffect(() => {
774
- if (useResize && !isNil(containerRef.current)) {
775
- updateSizes(containerRef.current.offsetWidth, containerRef.current.offsetHeight);
776
- }
777
- }, [updateSizes, useResize]);
778
- return {
779
- containerRef,
780
- verticalHandleRef,
781
- horizontalHandleRef,
782
- onPointerDown
783
- };
892
+ const useDebouncedCallback = interval => {
893
+ return useMemo(() => debounce(cb => {
894
+ cb();
895
+ }, interval), [interval]);
784
896
  };
785
897
 
786
898
  const useToggle = initial => {
@@ -789,47 +901,46 @@ const useToggle = initial => {
789
901
  return [state, toggle, setState];
790
902
  };
791
903
 
792
- const drawModeToGeometrySelectionType = mode => {
793
- switch (mode) {
794
- case "draw_point":
795
- return GeometrySelectionTypes.Point;
796
-
797
- case "draw_polygon":
798
- return GeometrySelectionTypes.Polygon;
799
-
800
- case "draw_line_string":
801
- return GeometrySelectionTypes.Line;
802
-
803
- default:
804
- return GeometrySelectionTypes.Point;
805
- }
904
+ const DEBOUNCE_DELAY = 144;
905
+ const useWindowResize = (callback, delay) => {
906
+ const debounceCallback = useMemo(() => {
907
+ return callback ? debounce(callback, delay || DEBOUNCE_DELAY) : undefined;
908
+ }, [callback, delay]);
909
+ useEffect(() => {
910
+ debounceCallback && window.addEventListener("resize", debounceCallback);
911
+ return () => debounceCallback && window.removeEventListener("resize", debounceCallback);
912
+ }, [debounceCallback]);
806
913
  };
807
914
 
808
- const getGeometrySelectionTurfFeature = (coordinates, selectionType, toWgs) => {
809
- if (toWgs) {
810
- switch (selectionType) {
811
- case GeometrySelectionTypes.Point:
812
- return toWgs84(point(coordinates));
813
-
814
- case GeometrySelectionTypes.Polygon:
815
- return toWgs84(polygon(coordinates));
915
+ const _excluded = ["zIndex", "lowerSiblings", "upperSiblings", "drawTriggerDeps", "onError", "children"];
916
+ const Map = (_ref) => {
917
+ let {
918
+ zIndex,
919
+ lowerSiblings,
920
+ upperSiblings,
921
+ onError,
922
+ children
923
+ } = _ref,
924
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
816
925
 
817
- case GeometrySelectionTypes.Line:
818
- return toWgs84(lineString(coordinates));
926
+ const {
927
+ map,
928
+ setLoaded
929
+ } = useMapContext();
930
+ return React.createElement(MapWrapper, {
931
+ "$zIndex": zIndex
932
+ }, lowerSiblings, React.createElement(MapGL, Object.assign({}, rest, {
933
+ renderWorldCopies: true,
934
+ antialias: true,
935
+ doubleClickZoom: false,
936
+ cursor: "default",
937
+ onLoad: e => {
938
+ map.current = e.target;
939
+ map.current.on("error", onError);
940
+ setLoaded(true);
819
941
  }
820
- }
821
-
822
- switch (selectionType) {
823
- case GeometrySelectionTypes.Point:
824
- return toMercator(point(coordinates));
825
-
826
- case GeometrySelectionTypes.Polygon:
827
- return toMercator(polygon(coordinates));
828
-
829
- case GeometrySelectionTypes.Line:
830
- return toMercator(lineString(coordinates));
831
- }
942
+ }), children), upperSiblings);
832
943
  };
833
944
 
834
- export { DateFormat, HorizontalPosition, NO_CONTENT_VALUE, VerticalPosition, convertSpToTurfFeature, drawModeToGeometrySelectionType, findAttributeInExpression, formatDate, geometryToWkt, getActualExtrusionHeight, getDate, getGeometrySelectionTurfFeature, isNumeric, isObject, parseClientStyle, useCurrentSelectedFeature, useEditingFeature, useEwktGeometry, useGeometryEditor, useGeometrySelection, useGeometrySelectionBuffer, useMapContext, useMapDraw, useRedrawLayer, useResizer, useSelectFeaturesCount, useSelectFeaturesCurrentIndex, useSelectFeaturesGeometryMasking, useSelectFeaturesInitialized, useSelectFeaturesLayerName, useSelectFeaturesPagination, useSelectFeaturesStatisticsActive, useSelectFeaturesTotalCounts, useSelectedFeatures, useServerNotifications, useServerNotificationsContext, useToggle, useUpdateCurrentFeature, useZoomToFeatures, useZoomToLayer, useZoomToPoint };
945
+ export { BaseMapTheme, DEFAULT_CIRCLE_PAINT, DEFAULT_FILL_EXTRUSION_PAINT, DEFAULT_FILL_PAINT, DEFAULT_LINE_PAINT, DateFormat, ErrorBoundary, Layer, Map, MapContext, MapProvider, NO_CONTENT_VALUE, ServerNotificationsContext, ServerNotificationsProvider, convertSpToTurfFeature, debounce, findAttributeInExpression, formatDate, getActualExtrusionHeight, getDate, isNumeric, isObject, parseClientStyle, useDebouncedCallback, useMapContext, useMapDraw, useRedrawLayer, useServerNotificationsContext, useToggle, useWindowResize, useZoomToFeatures, useZoomToPoint };
835
946
  //# sourceMappingURL=react.esm.js.map