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