@evergis/react 3.1.5 → 3.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +1 -29
- package/dist/assets/index-CTzhzVha.css +90 -0
- package/dist/assets/react.esm-CTzhzVha.css +90 -0
- package/dist/components/ErrorBoundary/index.d.ts +12 -12
- package/dist/components/ErrorBoundary/types.d.ts +7 -7
- package/dist/components/Layer/Layer.d.ts +3 -3
- package/dist/components/Layer/RasterLayer.d.ts +3 -3
- package/dist/components/Layer/VectorLayer.d.ts +3 -3
- package/dist/components/Layer/constants.d.ts +5 -137
- package/dist/components/Layer/index.d.ts +3 -3
- package/dist/components/Layer/types.d.ts +12 -12
- package/dist/components/Layer/utils/getClientStyleItemPrefixSuffix.d.ts +3 -3
- package/dist/components/Map/Map.d.ts +3 -5
- package/dist/components/Map/index.d.ts +2 -2
- package/dist/components/Map/styled.d.ts +4 -4
- package/dist/components/Map/types.d.ts +8 -9
- package/dist/components/index.d.ts +3 -3
- package/dist/contexts/MapContext/MapContext.d.ts +2 -2
- package/dist/contexts/MapContext/MapProvider.d.ts +3 -3
- package/dist/contexts/MapContext/index.d.ts +3 -3
- package/dist/contexts/MapContext/types.d.ts +31 -31
- package/dist/contexts/ServerNotificationsContext/ServerNotificationsContext.d.ts +2 -2
- package/dist/contexts/ServerNotificationsContext/ServerNotificationsProvider.d.ts +3 -3
- package/dist/contexts/ServerNotificationsContext/hooks/useServerNotifications.d.ts +2 -2
- package/dist/contexts/ServerNotificationsContext/index.d.ts +3 -3
- package/dist/contexts/ServerNotificationsContext/types.d.ts +12 -12
- package/dist/contexts/index.d.ts +2 -2
- package/dist/core/classification/findAttributeInExpression.d.ts +2 -2
- package/dist/core/classification/getActualExtrusionHeight.d.ts +2 -2
- package/dist/core/classification/index.d.ts +3 -3
- package/dist/core/classification/parseClientStyle.d.ts +2 -2
- package/dist/core/feature/convertSpToTurfFeature.d.ts +3 -3
- package/dist/core/feature/index.d.ts +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/dist/react.esm.d.ts +99 -0
- package/dist/hooks/index.d.ts +5 -5
- package/dist/hooks/map/index.d.ts +5 -5
- package/dist/hooks/map/useMapContext.d.ts +1 -1
- package/dist/hooks/map/useMapDraw/customModes.d.ts +7 -7
- package/dist/hooks/map/useMapDraw/customStyles.d.ts +58 -58
- package/dist/hooks/map/useMapDraw/index.d.ts +1 -1
- package/dist/hooks/map/useRedrawLayer.d.ts +1 -1
- package/dist/hooks/map/useZoomToFeatures.d.ts +2 -2
- package/dist/hooks/map/useZoomToPoint.d.ts +1 -1
- package/dist/hooks/serverNotifications/index.d.ts +1 -1
- package/dist/hooks/serverNotifications/useServerNotificationsContext.d.ts +1 -1
- package/dist/hooks/useDebouncedCallback.d.ts +1 -1
- package/dist/hooks/useToggle.d.ts +1 -1
- package/dist/hooks/useWindowResize.d.ts +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +7963 -5
- package/dist/index.js.map +1 -0
- package/dist/react.esm.js +7792 -796
- package/dist/react.esm.js.map +1 -1
- package/dist/src/components/ErrorBoundary/index.d.ts +12 -0
- package/dist/src/components/ErrorBoundary/types.d.ts +7 -0
- package/dist/src/components/Layer/Layer.d.ts +3 -0
- package/dist/src/components/Layer/RasterLayer.d.ts +3 -0
- package/dist/src/components/Layer/VectorLayer.d.ts +3 -0
- package/dist/src/components/Layer/constants.d.ts +5 -0
- package/dist/src/components/Layer/index.d.ts +3 -0
- package/dist/src/components/Layer/types.d.ts +12 -0
- package/dist/src/components/Layer/utils/getClientStyleItemPrefixSuffix.d.ts +3 -0
- package/dist/src/components/Map/Map.d.ts +3 -0
- package/dist/src/components/Map/index.d.ts +2 -0
- package/dist/src/components/Map/styled.d.ts +4 -0
- package/dist/src/components/Map/types.d.ts +8 -0
- package/dist/src/components/index.d.ts +3 -0
- package/dist/src/contexts/MapContext/MapContext.d.ts +2 -0
- package/dist/src/contexts/MapContext/MapProvider.d.ts +3 -0
- package/dist/src/contexts/MapContext/index.d.ts +3 -0
- package/dist/src/contexts/MapContext/types.d.ts +31 -0
- package/dist/src/contexts/ServerNotificationsContext/ServerNotificationsContext.d.ts +2 -0
- package/dist/src/contexts/ServerNotificationsContext/ServerNotificationsProvider.d.ts +3 -0
- package/dist/src/contexts/ServerNotificationsContext/hooks/useServerNotifications.d.ts +2 -0
- package/dist/src/contexts/ServerNotificationsContext/index.d.ts +3 -0
- package/dist/src/contexts/ServerNotificationsContext/types.d.ts +12 -0
- package/dist/src/contexts/index.d.ts +2 -0
- package/dist/src/core/classification/findAttributeInExpression.d.ts +2 -0
- package/dist/src/core/classification/getActualExtrusionHeight.d.ts +2 -0
- package/dist/src/core/classification/index.d.ts +3 -0
- package/dist/src/core/classification/parseClientStyle.d.ts +2 -0
- package/dist/src/core/feature/convertSpToTurfFeature.d.ts +3 -0
- package/dist/src/core/feature/index.d.ts +1 -0
- package/dist/src/core/index.d.ts +2 -0
- package/dist/src/hooks/index.d.ts +5 -0
- package/dist/src/hooks/map/index.d.ts +5 -0
- package/dist/src/hooks/map/useMapContext.d.ts +1 -0
- package/dist/src/hooks/map/useMapDraw/customModes.d.ts +7 -0
- package/dist/src/hooks/map/useMapDraw/customStyles.d.ts +58 -0
- package/dist/src/hooks/map/useMapDraw/index.d.ts +1 -0
- package/dist/src/hooks/map/useRedrawLayer.d.ts +1 -0
- package/dist/src/hooks/map/useZoomToFeatures.d.ts +2 -0
- package/dist/src/hooks/map/useZoomToPoint.d.ts +1 -0
- package/dist/src/hooks/serverNotifications/index.d.ts +1 -0
- package/dist/src/hooks/serverNotifications/useServerNotificationsContext.d.ts +1 -0
- package/dist/src/hooks/useDebouncedCallback.d.ts +1 -0
- package/dist/src/hooks/useToggle.d.ts +1 -0
- package/dist/src/hooks/useWindowResize.d.ts +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/types/attribute.d.ts +20 -0
- package/dist/src/types/index.d.ts +2 -0
- package/dist/src/types/styling.d.ts +15 -0
- package/dist/src/utils/date.d.ts +16 -0
- package/dist/src/utils/debounce.d.ts +1 -0
- package/dist/src/utils/index.d.ts +4 -0
- package/dist/src/utils/isNumeric.d.ts +1 -0
- package/dist/src/utils/isObject.d.ts +1 -0
- package/dist/types/attribute.d.ts +20 -20
- package/dist/types/index.d.ts +2 -2
- package/dist/types/styling.d.ts +15 -15
- package/dist/utils/date.d.ts +16 -16
- package/dist/utils/debounce.d.ts +1 -1
- package/dist/utils/index.d.ts +4 -4
- package/dist/utils/isNumeric.d.ts +1 -1
- package/dist/utils/isObject.d.ts +1 -1
- package/package.json +18 -37
- package/dist/jest.config.d.ts +0 -11
- package/dist/react.cjs.development.js +0 -973
- package/dist/react.cjs.development.js.map +0 -1
- package/dist/react.cjs.production.min.js +0 -2
- package/dist/react.cjs.production.min.js.map +0 -1
|
@@ -1,973 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
-
|
|
7
|
-
var React = require('react');
|
|
8
|
-
var React__default = _interopDefault(React);
|
|
9
|
-
var MapGL = require('react-map-gl/mapbox');
|
|
10
|
-
var MapGL__default = _interopDefault(MapGL);
|
|
11
|
-
var api = require('@evergis/api');
|
|
12
|
-
var lodash = require('lodash');
|
|
13
|
-
var turf = require('@turf/turf');
|
|
14
|
-
require('@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css');
|
|
15
|
-
var styled = _interopDefault(require('styled-components'));
|
|
16
|
-
var MapboxDraw = _interopDefault(require('@mapbox/mapbox-gl-draw'));
|
|
17
|
-
var signalr = require('@microsoft/signalr');
|
|
18
|
-
var dateFns = require('date-fns');
|
|
19
|
-
require('mapbox-gl/dist/mapbox-gl.css');
|
|
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
|
-
function _callSuper(_this, derived, args) {
|
|
133
|
-
function isNativeReflectConstruct() {
|
|
134
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
135
|
-
if (Reflect.construct.sham) return false;
|
|
136
|
-
if (typeof Proxy === "function") return true;
|
|
137
|
-
|
|
138
|
-
try {
|
|
139
|
-
return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
140
|
-
} catch (e) {
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
derived = _getPrototypeOf(derived);
|
|
146
|
-
return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args));
|
|
147
|
-
}
|
|
148
|
-
let ErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
149
|
-
function ErrorBoundary() {
|
|
150
|
-
var _this2;
|
|
151
|
-
|
|
152
|
-
_classCallCheck(this, ErrorBoundary);
|
|
153
|
-
|
|
154
|
-
_this2 = _callSuper(this, ErrorBoundary, arguments);
|
|
155
|
-
_this2.state = {
|
|
156
|
-
hasError: false
|
|
157
|
-
};
|
|
158
|
-
return _this2;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
_inherits(ErrorBoundary, _Component);
|
|
162
|
-
|
|
163
|
-
return _createClass(ErrorBoundary, [{
|
|
164
|
-
key: "componentDidCatch",
|
|
165
|
-
value: function componentDidCatch(error) {
|
|
166
|
-
// eslint-disable-next-line no-console
|
|
167
|
-
console.error(error);
|
|
168
|
-
}
|
|
169
|
-
}, {
|
|
170
|
-
key: "render",
|
|
171
|
-
value: function render() {
|
|
172
|
-
const {
|
|
173
|
-
children,
|
|
174
|
-
errorContents
|
|
175
|
-
} = this.props;
|
|
176
|
-
const {
|
|
177
|
-
hasError
|
|
178
|
-
} = this.state;
|
|
179
|
-
return !hasError ? React__default.createElement(React__default.Fragment, null, children) : React__default.createElement(React__default.Fragment, null, errorContents);
|
|
180
|
-
}
|
|
181
|
-
}], [{
|
|
182
|
-
key: "getDerivedStateFromError",
|
|
183
|
-
value: function getDerivedStateFromError() {
|
|
184
|
-
return {
|
|
185
|
-
hasError: true
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
}]);
|
|
189
|
-
}(React.Component);
|
|
190
|
-
|
|
191
|
-
const DEFAULT_COLOR = "#00ffff";
|
|
192
|
-
const DEFAULT_OPACITY = 0.5;
|
|
193
|
-
const DEFAULT_SIZE = 4;
|
|
194
|
-
const DEFAULT_LINE_WIDTH = 1;
|
|
195
|
-
const DEFAULT_CIRCLE_PAINT = {
|
|
196
|
-
"circle-radius": DEFAULT_SIZE,
|
|
197
|
-
"circle-color": DEFAULT_COLOR,
|
|
198
|
-
"circle-opacity": DEFAULT_OPACITY,
|
|
199
|
-
"circle-stroke-width": 0,
|
|
200
|
-
"circle-stroke-color": DEFAULT_COLOR,
|
|
201
|
-
"circle-stroke-opacity": DEFAULT_OPACITY
|
|
202
|
-
};
|
|
203
|
-
const DEFAULT_FILL_PAINT = {
|
|
204
|
-
"fill-color": DEFAULT_COLOR,
|
|
205
|
-
"fill-opacity": DEFAULT_OPACITY
|
|
206
|
-
};
|
|
207
|
-
const DEFAULT_FILL_EXTRUSION_PAINT = {
|
|
208
|
-
"fill-extrusion-base": 0,
|
|
209
|
-
"fill-extrusion-vertical-gradient": true,
|
|
210
|
-
"fill-extrusion-color": DEFAULT_COLOR,
|
|
211
|
-
"fill-extrusion-opacity": DEFAULT_OPACITY,
|
|
212
|
-
"fill-extrusion-height": 0
|
|
213
|
-
};
|
|
214
|
-
const DEFAULT_LINE_PAINT = {
|
|
215
|
-
"line-color": DEFAULT_COLOR,
|
|
216
|
-
"line-width": DEFAULT_LINE_WIDTH,
|
|
217
|
-
"line-opacity": DEFAULT_OPACITY
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
const RasterLayer = (_ref) => {
|
|
221
|
-
let {
|
|
222
|
-
layer,
|
|
223
|
-
tileUrl,
|
|
224
|
-
visible,
|
|
225
|
-
beforeId
|
|
226
|
-
} = _ref;
|
|
227
|
-
|
|
228
|
-
if (!layer) {
|
|
229
|
-
return null;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
return React__default.createElement(MapGL.Source, {
|
|
233
|
-
id: layer.name,
|
|
234
|
-
type: "raster",
|
|
235
|
-
tiles: [tileUrl]
|
|
236
|
-
}, React__default.createElement(MapGL.Layer, {
|
|
237
|
-
id: layer.name,
|
|
238
|
-
type: "raster",
|
|
239
|
-
"source-layer": "default",
|
|
240
|
-
beforeId: beforeId,
|
|
241
|
-
layout: {
|
|
242
|
-
visibility: visible ? "visible" : "none"
|
|
243
|
-
}
|
|
244
|
-
}));
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
const getClientStyleItemPrefixSuffix = (geometryType, type) => {
|
|
248
|
-
switch (geometryType) {
|
|
249
|
-
case api.GeometryType.Point:
|
|
250
|
-
return ["point-layer-", ""];
|
|
251
|
-
|
|
252
|
-
case api.GeometryType.Polyline:
|
|
253
|
-
return ["polyline-layer-", ""];
|
|
254
|
-
|
|
255
|
-
case api.GeometryType.Polygon:
|
|
256
|
-
switch (type) {
|
|
257
|
-
case "line":
|
|
258
|
-
return ["polygon-stroke-layer-", "-stroke"];
|
|
259
|
-
|
|
260
|
-
case "fill-extrusion":
|
|
261
|
-
return ["polygon-extrusion-layer-", "-extrusion"];
|
|
262
|
-
|
|
263
|
-
default:
|
|
264
|
-
return ["polygon-layer-", ""];
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
default:
|
|
268
|
-
return ["", ""];
|
|
269
|
-
}
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
const findAttributeInExpression = expression => {
|
|
273
|
-
if (Array.isArray(expression) && expression.length === 2 && expression[0] === "get") {
|
|
274
|
-
return [expression[1]];
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
return expression.reduce((acc, curr) => {
|
|
278
|
-
if (!Array.isArray(curr)) {
|
|
279
|
-
return acc;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
if (curr[0] === "get") {
|
|
283
|
-
return [...new Set([...acc, curr[1]])];
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
return [...new Set([...acc, ...findAttributeInExpression(curr)])];
|
|
287
|
-
}, []);
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
const getActualExtrusionHeight = paint => {
|
|
291
|
-
return Array.isArray(paint == null ? void 0 : paint["fill-extrusion-height"]) && (paint == null ? void 0 : paint["fill-extrusion-height"][0]) === "+" ? paint == null ? void 0 : paint["fill-extrusion-height"][1] : paint == null ? void 0 : paint["fill-extrusion-height"];
|
|
292
|
-
};
|
|
293
|
-
|
|
294
|
-
const parseClientStyle = style => {
|
|
295
|
-
var _style$items;
|
|
296
|
-
|
|
297
|
-
if (!style) {
|
|
298
|
-
return [];
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
return style == null || (_style$items = style.items) == null ? void 0 : _style$items.reduce((acc, curr) => {
|
|
302
|
-
var _Object$entries;
|
|
303
|
-
|
|
304
|
-
if (!curr.paint || lodash.isEmpty(curr.paint)) {
|
|
305
|
-
return acc;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
return (_Object$entries = Object.entries(curr.paint)) == null ? void 0 : _Object$entries.reduce((paintAcc, _ref) => {
|
|
309
|
-
let [, value] = _ref;
|
|
310
|
-
|
|
311
|
-
if (!Array.isArray(value)) {
|
|
312
|
-
return paintAcc;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
return [...new Set([...paintAcc, ...findAttributeInExpression(value)])];
|
|
316
|
-
}, []);
|
|
317
|
-
}, []);
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
const convertSpToTurfFeature = geometry => {
|
|
321
|
-
if (!geometry) {
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
switch (geometry.type) {
|
|
326
|
-
case api.GeometryType.Point:
|
|
327
|
-
return turf.point(geometry.coordinates);
|
|
328
|
-
|
|
329
|
-
case api.GeometryType.Multipoint:
|
|
330
|
-
return turf.multiPoint(geometry.coordinates);
|
|
331
|
-
|
|
332
|
-
case api.GeometryType.Polyline:
|
|
333
|
-
return turf.multiLineString(geometry.coordinates);
|
|
334
|
-
|
|
335
|
-
case api.GeometryType.Polygon:
|
|
336
|
-
case api.GeometryType.Envelope:
|
|
337
|
-
return turf.polygon(geometry.coordinates);
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
const VectorLayer = (_ref) => {
|
|
342
|
-
var _layer$configuration;
|
|
343
|
-
|
|
344
|
-
let {
|
|
345
|
-
layer,
|
|
346
|
-
tileUrl,
|
|
347
|
-
visible,
|
|
348
|
-
beforeId,
|
|
349
|
-
getLayerTempStyle
|
|
350
|
-
} = _ref;
|
|
351
|
-
const clientStyle = layer == null || (_layer$configuration = layer.configuration) == null ? void 0 : _layer$configuration.clientStyle;
|
|
352
|
-
const {
|
|
353
|
-
idAttribute,
|
|
354
|
-
geometryType
|
|
355
|
-
} = layer.layerDefinition || {};
|
|
356
|
-
const renderLayerByGeometryType = React.useCallback(() => {
|
|
357
|
-
var _getLayerTempStyle, _getLayerTempStyle2, _getLayerTempStyle3, _getLayerTempStyle4, _getLayerTempStyle5, _getLayerTempStyle6, _getLayerTempStyle7, _getLayerTempStyle8, _getLayerTempStyle9, _getLayerTempStyle10, _getLayerTempStyle11, _getLayerTempStyle12, _getLayerTempStyle13, _getLayerTempStyle14;
|
|
358
|
-
|
|
359
|
-
const visibility = visible ? "visible" : "none";
|
|
360
|
-
|
|
361
|
-
switch (geometryType) {
|
|
362
|
-
case api.GeometryType.Point:
|
|
363
|
-
return React__default.createElement(MapGL.Layer, {
|
|
364
|
-
id: layer.name,
|
|
365
|
-
type: "circle",
|
|
366
|
-
"source-layer": "default",
|
|
367
|
-
beforeId: beforeId,
|
|
368
|
-
layout: _extends({}, getLayerTempStyle == null || (_getLayerTempStyle = getLayerTempStyle(layer.name, "circle")) == null ? void 0 : _getLayerTempStyle.layout, {
|
|
369
|
-
visibility
|
|
370
|
-
}),
|
|
371
|
-
paint: _extends({}, DEFAULT_CIRCLE_PAINT, getLayerTempStyle == null || (_getLayerTempStyle2 = getLayerTempStyle(layer.name, "circle")) == null ? void 0 : _getLayerTempStyle2.paint)
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
case api.GeometryType.Polygon:
|
|
375
|
-
return [React__default.createElement(MapGL.Layer, {
|
|
376
|
-
key: "polygon-layer-" + layer.name,
|
|
377
|
-
id: layer.name,
|
|
378
|
-
type: "fill",
|
|
379
|
-
"source-layer": "default",
|
|
380
|
-
beforeId: beforeId,
|
|
381
|
-
layout: _extends({}, getLayerTempStyle == null || (_getLayerTempStyle3 = getLayerTempStyle(layer.name, "fill")) == null ? void 0 : _getLayerTempStyle3.layout, {
|
|
382
|
-
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"
|
|
383
|
-
}),
|
|
384
|
-
paint: _extends({}, DEFAULT_FILL_PAINT, getLayerTempStyle == null || (_getLayerTempStyle6 = getLayerTempStyle(layer.name, "fill")) == null ? void 0 : _getLayerTempStyle6.paint)
|
|
385
|
-
}), React__default.createElement(MapGL.Layer, {
|
|
386
|
-
key: "polygon-stroke-layer-" + layer.name,
|
|
387
|
-
id: layer.name + "-stroke",
|
|
388
|
-
type: "line",
|
|
389
|
-
"source-layer": "default",
|
|
390
|
-
beforeId: beforeId,
|
|
391
|
-
layout: _extends({}, getLayerTempStyle == null || (_getLayerTempStyle7 = getLayerTempStyle(layer.name, "line")) == null ? void 0 : _getLayerTempStyle7.layout, {
|
|
392
|
-
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"
|
|
393
|
-
}),
|
|
394
|
-
paint: _extends({}, DEFAULT_LINE_PAINT, getLayerTempStyle == null || (_getLayerTempStyle10 = getLayerTempStyle(layer.name, "line")) == null ? void 0 : _getLayerTempStyle10.paint)
|
|
395
|
-
}), React__default.createElement(MapGL.Layer, {
|
|
396
|
-
key: "polygon-extrusion-layer-" + layer.name,
|
|
397
|
-
id: layer.name + "-extrusion",
|
|
398
|
-
type: "fill-extrusion",
|
|
399
|
-
"source-layer": "default",
|
|
400
|
-
beforeId: beforeId,
|
|
401
|
-
minzoom: 0,
|
|
402
|
-
maxzoom: 23,
|
|
403
|
-
layout: _extends({}, getLayerTempStyle == null || (_getLayerTempStyle11 = getLayerTempStyle(layer.name, "fill-extrusion")) == null ? void 0 : _getLayerTempStyle11.layout, {
|
|
404
|
-
visibility
|
|
405
|
-
}),
|
|
406
|
-
paint: _extends({}, DEFAULT_FILL_EXTRUSION_PAINT, getLayerTempStyle == null || (_getLayerTempStyle12 = getLayerTempStyle(layer.name, "fill-extrusion")) == null ? void 0 : _getLayerTempStyle12.paint)
|
|
407
|
-
})];
|
|
408
|
-
|
|
409
|
-
case api.GeometryType.Polyline:
|
|
410
|
-
return React__default.createElement(MapGL.Layer, {
|
|
411
|
-
id: layer.name,
|
|
412
|
-
type: "line",
|
|
413
|
-
"source-layer": "default",
|
|
414
|
-
beforeId: beforeId,
|
|
415
|
-
layout: _extends({}, getLayerTempStyle == null || (_getLayerTempStyle13 = getLayerTempStyle(layer.name, "line")) == null ? void 0 : _getLayerTempStyle13.layout, {
|
|
416
|
-
visibility
|
|
417
|
-
}),
|
|
418
|
-
paint: _extends({}, DEFAULT_LINE_PAINT, getLayerTempStyle == null || (_getLayerTempStyle14 = getLayerTempStyle(layer.name, "line")) == null ? void 0 : _getLayerTempStyle14.paint)
|
|
419
|
-
});
|
|
420
|
-
|
|
421
|
-
default:
|
|
422
|
-
return null;
|
|
423
|
-
}
|
|
424
|
-
}, [geometryType, layer, beforeId, visible, getLayerTempStyle == null ? void 0 : getLayerTempStyle(layer.name, "circle"), getLayerTempStyle == null ? void 0 : getLayerTempStyle(layer.name, "fill"), getLayerTempStyle == null ? void 0 : getLayerTempStyle(layer.name, "fill-extrusion"), getLayerTempStyle == null ? void 0 : getLayerTempStyle(layer.name, "line")]);
|
|
425
|
-
const renderClientStyle = React.useCallback(() => {
|
|
426
|
-
return clientStyle.items.map(mockItem => {
|
|
427
|
-
var _clientStyle$items, _getLayerTempStyle15, _getLayerTempStyle16, _currentSettings$fill, _currentSettings$fill2, _clientStyle$minzoom, _clientStyle$maxzoom, _getLayerTempStyle17, _getLayerTempStyle18;
|
|
428
|
-
|
|
429
|
-
const prefixSuffix = getClientStyleItemPrefixSuffix(geometryType, mockItem.type);
|
|
430
|
-
const isExtrusionItem = mockItem.type === "fill-extrusion";
|
|
431
|
-
const isPolygonPart = clientStyle.items.some(item => item.type === "fill-extrusion") && (mockItem.type === "fill" || mockItem.type === "line");
|
|
432
|
-
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;
|
|
433
|
-
|
|
434
|
-
const currentSettings = _extends({}, clientStyle == null ? void 0 : clientStyle.settings, getLayerTempStyle == null || (_getLayerTempStyle16 = getLayerTempStyle(layer.name, mockItem.type)) == null ? void 0 : _getLayerTempStyle16.settings);
|
|
435
|
-
|
|
436
|
-
const processedExtrusionHeight = getActualExtrusionHeight(fillExtrusionPaint);
|
|
437
|
-
const hasExtrusion = Boolean(processedExtrusionHeight);
|
|
438
|
-
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";
|
|
439
|
-
return React__default.createElement(MapGL.Layer, {
|
|
440
|
-
key: "" + prefixSuffix[0] + layer.name,
|
|
441
|
-
id: "" + layer.name + prefixSuffix[1],
|
|
442
|
-
type: mockItem.type,
|
|
443
|
-
"source-layer": "default",
|
|
444
|
-
beforeId: beforeId,
|
|
445
|
-
minzoom: (_clientStyle$minzoom = clientStyle == null ? void 0 : clientStyle.minzoom) != null ? _clientStyle$minzoom : 0,
|
|
446
|
-
maxzoom: (_clientStyle$maxzoom = clientStyle == null ? void 0 : clientStyle.maxzoom) != null ? _clientStyle$maxzoom : 23,
|
|
447
|
-
layout: _extends({}, mockItem.layout, getLayerTempStyle == null || (_getLayerTempStyle17 = getLayerTempStyle(layer.name, mockItem.type)) == null ? void 0 : _getLayerTempStyle17.layout, {
|
|
448
|
-
visibility
|
|
449
|
-
}),
|
|
450
|
-
paint: _extends({}, mockItem.paint, getLayerTempStyle == null || (_getLayerTempStyle18 = getLayerTempStyle(layer.name, mockItem.type)) == null ? void 0 : _getLayerTempStyle18.paint)
|
|
451
|
-
});
|
|
452
|
-
});
|
|
453
|
-
}, [beforeId, clientStyle, geometryType, layer.name, visible, getLayerTempStyle == null ? void 0 : getLayerTempStyle(layer.name, "circle"), getLayerTempStyle == null ? void 0 : getLayerTempStyle(layer.name, "fill"), getLayerTempStyle == null ? void 0 : getLayerTempStyle(layer.name, "fill-extrusion"), getLayerTempStyle == null ? void 0 : getLayerTempStyle(layer.name, "line")]);
|
|
454
|
-
|
|
455
|
-
if (!layer) {
|
|
456
|
-
return null;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
return React__default.createElement(MapGL.Source, {
|
|
460
|
-
promoteId: idAttribute,
|
|
461
|
-
id: layer.name,
|
|
462
|
-
type: "vector",
|
|
463
|
-
tiles: [tileUrl]
|
|
464
|
-
}, clientStyle != null && clientStyle.items ? renderClientStyle() : renderLayerByGeometryType());
|
|
465
|
-
};
|
|
466
|
-
|
|
467
|
-
const Layer = (_ref) => {
|
|
468
|
-
let {
|
|
469
|
-
layer,
|
|
470
|
-
layerType,
|
|
471
|
-
visible,
|
|
472
|
-
beforeId,
|
|
473
|
-
tileUrl,
|
|
474
|
-
onMount = () => null
|
|
475
|
-
} = _ref;
|
|
476
|
-
React.useEffect(onMount, []); // eslint-disable-line
|
|
477
|
-
|
|
478
|
-
if (!layer) {
|
|
479
|
-
return null;
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
if (layerType === "RasterTileLayer") {
|
|
483
|
-
return React__default.createElement(RasterLayer, {
|
|
484
|
-
layer: layer,
|
|
485
|
-
tileUrl: tileUrl,
|
|
486
|
-
visible: visible,
|
|
487
|
-
beforeId: beforeId
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
return React__default.createElement(VectorLayer, {
|
|
492
|
-
layer: layer,
|
|
493
|
-
tileUrl: tileUrl,
|
|
494
|
-
visible: visible,
|
|
495
|
-
beforeId: beforeId
|
|
496
|
-
});
|
|
497
|
-
};
|
|
498
|
-
|
|
499
|
-
var _templateObject;
|
|
500
|
-
const MapWrapper = /*#__PURE__*/styled.div(_templateObject || (_templateObject = /*#__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) => {
|
|
501
|
-
let {
|
|
502
|
-
$zIndex
|
|
503
|
-
} = _ref;
|
|
504
|
-
return $zIndex != null ? $zIndex : 1;
|
|
505
|
-
});
|
|
506
|
-
|
|
507
|
-
const customModes = MapboxDraw.modes;
|
|
508
|
-
const StaticMode = {};
|
|
509
|
-
|
|
510
|
-
StaticMode.onSetup = function () {
|
|
511
|
-
this.setActionableState(undefined);
|
|
512
|
-
return {};
|
|
513
|
-
};
|
|
514
|
-
|
|
515
|
-
StaticMode.toDisplayFeatures = function (state, geojson, display) {
|
|
516
|
-
display(geojson);
|
|
517
|
-
};
|
|
518
|
-
|
|
519
|
-
customModes.static = StaticMode;
|
|
520
|
-
|
|
521
|
-
const customStyles = [{
|
|
522
|
-
id: "gl-draw-point",
|
|
523
|
-
type: "circle",
|
|
524
|
-
filter: ["all", ["==", "$type", "Point"]],
|
|
525
|
-
paint: {
|
|
526
|
-
"circle-radius": 5,
|
|
527
|
-
"circle-color": "#D20C0C",
|
|
528
|
-
"circle-stroke-color": "#FFFFFF",
|
|
529
|
-
"circle-stroke-width": 3,
|
|
530
|
-
"circle-stroke-opacity": 0.3
|
|
531
|
-
}
|
|
532
|
-
}, {
|
|
533
|
-
id: "highlight-inactive-points",
|
|
534
|
-
type: "circle",
|
|
535
|
-
filter: ["all", ["==", "$type", "Point"], ["==", "meta", "feature"], ["==", "active", "false"]],
|
|
536
|
-
paint: {
|
|
537
|
-
"circle-radius": 5,
|
|
538
|
-
"circle-color": "#D20C0C",
|
|
539
|
-
"circle-stroke-color": "#FFFFFF",
|
|
540
|
-
"circle-stroke-width": 3,
|
|
541
|
-
"circle-stroke-opacity": 0.3
|
|
542
|
-
}
|
|
543
|
-
}, {
|
|
544
|
-
id: "highlight-active-points",
|
|
545
|
-
type: "circle",
|
|
546
|
-
filter: ["all", ["==", "$type", "Point"], ["==", "meta", "feature"], ["==", "active", "true"]],
|
|
547
|
-
paint: {
|
|
548
|
-
"circle-radius": 3,
|
|
549
|
-
"circle-color": "#fbb03b",
|
|
550
|
-
"circle-stroke-color": "#FFFFFF",
|
|
551
|
-
"circle-stroke-width": 1,
|
|
552
|
-
"circle-stroke-opacity": 0.3
|
|
553
|
-
}
|
|
554
|
-
}, {
|
|
555
|
-
id: "gl-draw-polygon-fill-static",
|
|
556
|
-
type: "fill",
|
|
557
|
-
filter: ["all", ["==", "$type", "Polygon"]],
|
|
558
|
-
paint: {
|
|
559
|
-
"fill-color": "#D20C0C",
|
|
560
|
-
"fill-outline-color": "#D20C0C",
|
|
561
|
-
"fill-opacity": 0.1
|
|
562
|
-
}
|
|
563
|
-
}, {
|
|
564
|
-
id: "gl-draw-line",
|
|
565
|
-
type: "line",
|
|
566
|
-
filter: ["all", ["==", "$type", "LineString"]],
|
|
567
|
-
layout: {
|
|
568
|
-
"line-cap": "round",
|
|
569
|
-
"line-join": "round"
|
|
570
|
-
},
|
|
571
|
-
paint: {
|
|
572
|
-
"line-color": "#D20C0C",
|
|
573
|
-
"line-dasharray": [0.2, 2],
|
|
574
|
-
"line-width": 2
|
|
575
|
-
}
|
|
576
|
-
}, {
|
|
577
|
-
id: "gl-draw-polygon-fill",
|
|
578
|
-
type: "fill",
|
|
579
|
-
filter: ["all", ["==", "$type", "Polygon"]],
|
|
580
|
-
paint: {
|
|
581
|
-
"fill-color": "#D20C0C",
|
|
582
|
-
"fill-outline-color": "#D20C0C",
|
|
583
|
-
"fill-opacity": 0.1
|
|
584
|
-
}
|
|
585
|
-
}, {
|
|
586
|
-
id: "gl-draw-polygon-midpoint",
|
|
587
|
-
type: "circle",
|
|
588
|
-
filter: ["all", ["==", "$type", "Point"], ["==", "meta", "midpoint"]],
|
|
589
|
-
paint: {
|
|
590
|
-
"circle-radius": 3,
|
|
591
|
-
"circle-color": "#fbb03b",
|
|
592
|
-
"circle-stroke-color": "#FFFFFF",
|
|
593
|
-
"circle-stroke-width": 1,
|
|
594
|
-
"circle-stroke-opacity": 0.3
|
|
595
|
-
}
|
|
596
|
-
}, {
|
|
597
|
-
id: "gl-draw-polygon-stroke-active",
|
|
598
|
-
type: "line",
|
|
599
|
-
filter: ["all", ["==", "$type", "Polygon"]],
|
|
600
|
-
layout: {
|
|
601
|
-
"line-cap": "round",
|
|
602
|
-
"line-join": "round"
|
|
603
|
-
},
|
|
604
|
-
paint: {
|
|
605
|
-
"line-color": "#D20C0C",
|
|
606
|
-
"line-dasharray": [0.2, 2],
|
|
607
|
-
"line-width": 2
|
|
608
|
-
}
|
|
609
|
-
}, {
|
|
610
|
-
id: "gl-draw-polygon-and-line-vertex-active",
|
|
611
|
-
type: "circle",
|
|
612
|
-
filter: ["all", ["==", "meta", "vertex"], ["==", "$type", "Point"]],
|
|
613
|
-
paint: {
|
|
614
|
-
"circle-radius": 3,
|
|
615
|
-
"circle-color": "#D20C0C",
|
|
616
|
-
"circle-stroke-color": "#FFFFFF",
|
|
617
|
-
"circle-stroke-width": 3,
|
|
618
|
-
"circle-stroke-opacity": 0.3
|
|
619
|
-
}
|
|
620
|
-
}];
|
|
621
|
-
|
|
622
|
-
const MapContext = /*#__PURE__*/React.createContext({});
|
|
623
|
-
|
|
624
|
-
const MapProvider = (_ref) => {
|
|
625
|
-
let {
|
|
626
|
-
basemapItems,
|
|
627
|
-
defaultBasemap,
|
|
628
|
-
children
|
|
629
|
-
} = _ref;
|
|
630
|
-
const map = React.useRef();
|
|
631
|
-
const draw = React.useRef();
|
|
632
|
-
const [loaded, setLoaded] = React.useState(false);
|
|
633
|
-
const [basemapName, setBasemapName] = React.useState(defaultBasemap);
|
|
634
|
-
return React__default.createElement(MapContext.Provider, {
|
|
635
|
-
value: {
|
|
636
|
-
map,
|
|
637
|
-
draw,
|
|
638
|
-
loaded,
|
|
639
|
-
setLoaded,
|
|
640
|
-
basemapItems,
|
|
641
|
-
basemapName,
|
|
642
|
-
setBasemapName,
|
|
643
|
-
defaultBasemap
|
|
644
|
-
}
|
|
645
|
-
}, children);
|
|
646
|
-
};
|
|
647
|
-
|
|
648
|
-
(function (BaseMapTheme) {
|
|
649
|
-
BaseMapTheme["Light"] = "light";
|
|
650
|
-
BaseMapTheme["Dark"] = "dark";
|
|
651
|
-
})(exports.BaseMapTheme || (exports.BaseMapTheme = {}));
|
|
652
|
-
|
|
653
|
-
const ServerNotificationsContext = /*#__PURE__*/React.createContext({});
|
|
654
|
-
|
|
655
|
-
const useServerNotifications = (url, initialized) => {
|
|
656
|
-
const hubConnection = React.useRef(null);
|
|
657
|
-
const [connection, setConnection] = React.useState(null);
|
|
658
|
-
React.useEffect(() => {
|
|
659
|
-
if (!initialized) {
|
|
660
|
-
return;
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
hubConnection.current = new signalr.HubConnectionBuilder().withUrl(url, {
|
|
664
|
-
withCredentials: true
|
|
665
|
-
}).configureLogging(signalr.LogLevel.Information).build();
|
|
666
|
-
hubConnection.current.start().then(() => console.info("Серверные нотификации подключены")).catch(err => console.info("Ошибка:", err)).finally(() => setConnection(hubConnection.current));
|
|
667
|
-
}, [initialized]); // eslint-disable-line
|
|
668
|
-
|
|
669
|
-
React.useEffect(() => {
|
|
670
|
-
if (!connection || connection.state !== "Connected") {
|
|
671
|
-
return;
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
connection.invoke("SubscribeNotifications", []).then(() => console.info("Подписка `SubscribeNotifications` оформлена")).catch(err => console.info("Ошибка подписки `SubscribeNotifications`:", err));
|
|
675
|
-
}, [connection]);
|
|
676
|
-
return connection;
|
|
677
|
-
};
|
|
678
|
-
|
|
679
|
-
const ServerNotificationsProvider = (_ref) => {
|
|
680
|
-
let {
|
|
681
|
-
url,
|
|
682
|
-
initialized,
|
|
683
|
-
children
|
|
684
|
-
} = _ref;
|
|
685
|
-
const connection = useServerNotifications(url, initialized);
|
|
686
|
-
const addSubscription = React.useCallback(async payload => {
|
|
687
|
-
if (!connection || connection.state !== "Connected" || !payload) {
|
|
688
|
-
return;
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
try {
|
|
692
|
-
const id = await connection.invoke("AddSubscription", payload);
|
|
693
|
-
console.info("Подписка добавлена, id:", id);
|
|
694
|
-
return id;
|
|
695
|
-
} catch (err) {
|
|
696
|
-
console.info("Ошибка добавления подписки:", err);
|
|
697
|
-
return Promise.resolve(null);
|
|
698
|
-
}
|
|
699
|
-
}, [connection]);
|
|
700
|
-
const updateSubscription = React.useCallback(async (id, payload) => {
|
|
701
|
-
if (!connection || connection.state !== "Connected" || !id || !payload) {
|
|
702
|
-
return;
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
try {
|
|
706
|
-
await connection.invoke("UpdateSubscription", id, payload);
|
|
707
|
-
} catch (err) {
|
|
708
|
-
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);
|
|
709
|
-
}
|
|
710
|
-
}, [connection]);
|
|
711
|
-
const unsubscribeById = React.useCallback(async id => {
|
|
712
|
-
if (!connection || connection.state !== "Connected" || !id) {
|
|
713
|
-
return;
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
try {
|
|
717
|
-
await connection.invoke("Unsubscribe", [id]);
|
|
718
|
-
} catch (err) {
|
|
719
|
-
console.info("\u041E\u0448\u0438\u0431\u043A\u0430 \u043E\u0442\u043F\u0438\u0441\u043A\u0438 \u043F\u043E " + id + ":", err);
|
|
720
|
-
}
|
|
721
|
-
}, [connection]);
|
|
722
|
-
return React__default.createElement(ServerNotificationsContext.Provider, {
|
|
723
|
-
value: {
|
|
724
|
-
connection,
|
|
725
|
-
addSubscription,
|
|
726
|
-
updateSubscription,
|
|
727
|
-
unsubscribeById
|
|
728
|
-
}
|
|
729
|
-
}, children);
|
|
730
|
-
};
|
|
731
|
-
|
|
732
|
-
const useMapContext = () => {
|
|
733
|
-
return React.useContext(MapContext);
|
|
734
|
-
};
|
|
735
|
-
|
|
736
|
-
const draw = /*#__PURE__*/new MapboxDraw({
|
|
737
|
-
displayControlsDefault: false,
|
|
738
|
-
styles: customStyles,
|
|
739
|
-
modes: customModes,
|
|
740
|
-
defaultMode: "draw_point",
|
|
741
|
-
controls: {
|
|
742
|
-
trash: true
|
|
743
|
-
}
|
|
744
|
-
});
|
|
745
|
-
const useMapDraw = function useMapDraw(triggerDeps) {
|
|
746
|
-
if (triggerDeps === void 0) {
|
|
747
|
-
triggerDeps = [];
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
const {
|
|
751
|
-
map,
|
|
752
|
-
draw: drawContext,
|
|
753
|
-
loaded,
|
|
754
|
-
basemapName
|
|
755
|
-
} = useMapContext();
|
|
756
|
-
React.useEffect(() => {
|
|
757
|
-
if (!loaded || !map.current) {
|
|
758
|
-
return;
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
drawContext.current = draw;
|
|
762
|
-
map.current.addControl(drawContext.current);
|
|
763
|
-
}, [loaded]); // eslint-disable-line
|
|
764
|
-
|
|
765
|
-
React.useEffect(() => {
|
|
766
|
-
if (map.current && map.current.hasControl(drawContext.current)) {
|
|
767
|
-
map.current.removeControl(drawContext.current);
|
|
768
|
-
map.current.addControl(drawContext.current);
|
|
769
|
-
}
|
|
770
|
-
}, [basemapName, ...triggerDeps]); // eslint-disable-line
|
|
771
|
-
};
|
|
772
|
-
|
|
773
|
-
const useRedrawLayer = () => {
|
|
774
|
-
const {
|
|
775
|
-
map
|
|
776
|
-
} = useMapContext();
|
|
777
|
-
return React.useCallback(layerName => {
|
|
778
|
-
const layerTileSource = map.current.getSource(layerName);
|
|
779
|
-
layerTileSource.setTiles(layerTileSource.tiles);
|
|
780
|
-
}, [map]);
|
|
781
|
-
};
|
|
782
|
-
|
|
783
|
-
const useZoomToFeatures = () => {
|
|
784
|
-
const {
|
|
785
|
-
map
|
|
786
|
-
} = useMapContext();
|
|
787
|
-
return React.useCallback((features, padding) => {
|
|
788
|
-
if (!features) {
|
|
789
|
-
return;
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
const currentFeatureCenter = turf.bbox({
|
|
793
|
-
type: "FeatureCollection",
|
|
794
|
-
features: features.map(feature => convertSpToTurfFeature(feature.geometry))
|
|
795
|
-
});
|
|
796
|
-
map.current.fitBounds(currentFeatureCenter, {
|
|
797
|
-
padding: padding != null ? padding : 150
|
|
798
|
-
});
|
|
799
|
-
}, [map]);
|
|
800
|
-
};
|
|
801
|
-
|
|
802
|
-
const useZoomToPoint = () => {
|
|
803
|
-
const {
|
|
804
|
-
map
|
|
805
|
-
} = useMapContext();
|
|
806
|
-
return React.useCallback((options, callback) => {
|
|
807
|
-
if (map.current) {
|
|
808
|
-
if (callback) {
|
|
809
|
-
map.current.once("moveend", () => {
|
|
810
|
-
callback();
|
|
811
|
-
});
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
map.current.flyTo(options);
|
|
815
|
-
} else {
|
|
816
|
-
callback == null || callback();
|
|
817
|
-
}
|
|
818
|
-
}, [map]);
|
|
819
|
-
};
|
|
820
|
-
|
|
821
|
-
const useServerNotificationsContext = () => {
|
|
822
|
-
return React.useContext(ServerNotificationsContext);
|
|
823
|
-
};
|
|
824
|
-
|
|
825
|
-
const NO_CONTENT_VALUE = "—";
|
|
826
|
-
|
|
827
|
-
(function (DateFormat) {
|
|
828
|
-
DateFormat["ClientDefaultFormat"] = "dd.MM.yyyy HH:mm";
|
|
829
|
-
DateFormat["DateTime"] = "dd.MM.yyyy HH:mm:ss";
|
|
830
|
-
DateFormat["UTC"] = "yyyy-MM-dd'T'HH:mm:ss.sssxxx";
|
|
831
|
-
DateFormat["AxisTooltip"] = "d MMMM yyyy";
|
|
832
|
-
})(exports.DateFormat || (exports.DateFormat = {}));
|
|
833
|
-
|
|
834
|
-
const stringDateParsers = [dateFns.parseJSON, dateFns.parseISO, rawDate => new Date(rawDate)];
|
|
835
|
-
const getDate = rawDate => {
|
|
836
|
-
if (!rawDate) return null;
|
|
837
|
-
|
|
838
|
-
if (typeof rawDate === "string") {
|
|
839
|
-
for (const parser of stringDateParsers) {
|
|
840
|
-
const date = parser(rawDate);
|
|
841
|
-
|
|
842
|
-
if (dateFns.isValid(date)) {
|
|
843
|
-
return dateFns.toDate(date);
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
return null;
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
const parsedDate = dateFns.toDate(rawDate);
|
|
851
|
-
return dateFns.isValid(parsedDate) ? parsedDate : null;
|
|
852
|
-
};
|
|
853
|
-
const formatDate = function formatDate(date, _temp) {
|
|
854
|
-
let {
|
|
855
|
-
dateFormat = exports.DateFormat.ClientDefaultFormat,
|
|
856
|
-
defaultValue = NO_CONTENT_VALUE
|
|
857
|
-
} = _temp === void 0 ? {} : _temp;
|
|
858
|
-
const dateValue = date ? getDate(date) : null;
|
|
859
|
-
|
|
860
|
-
if (dateFns.isValid(dateValue)) {
|
|
861
|
-
return dateFns.format(dateValue, dateFormat);
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
return defaultValue.toString();
|
|
865
|
-
};
|
|
866
|
-
|
|
867
|
-
const debounce = (callback, delay) => {
|
|
868
|
-
let timeId;
|
|
869
|
-
return function () {
|
|
870
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
871
|
-
args[_key] = arguments[_key];
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
if (timeId) {
|
|
875
|
-
window.clearTimeout(timeId);
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
timeId = window.setTimeout(() => {
|
|
879
|
-
callback(...args);
|
|
880
|
-
}, delay);
|
|
881
|
-
};
|
|
882
|
-
};
|
|
883
|
-
|
|
884
|
-
const isNumeric = number => !isNaN(parseFloat(number)) && isFinite(number);
|
|
885
|
-
|
|
886
|
-
function isObject(value) {
|
|
887
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
const useDebouncedCallback = interval => {
|
|
891
|
-
return React.useMemo(() => debounce(cb => {
|
|
892
|
-
cb();
|
|
893
|
-
}, interval), [interval]);
|
|
894
|
-
};
|
|
895
|
-
|
|
896
|
-
const useToggle = initial => {
|
|
897
|
-
const [state, setState] = React.useState(initial !== undefined ? initial : false);
|
|
898
|
-
const toggle = React.useCallback(() => setState(!state), [state]);
|
|
899
|
-
return [state, toggle, setState];
|
|
900
|
-
};
|
|
901
|
-
|
|
902
|
-
const DEBOUNCE_DELAY = 144;
|
|
903
|
-
const useWindowResize = (callback, delay) => {
|
|
904
|
-
const debounceCallback = React.useMemo(() => {
|
|
905
|
-
return callback ? debounce(callback, delay || DEBOUNCE_DELAY) : undefined;
|
|
906
|
-
}, [callback, delay]);
|
|
907
|
-
React.useEffect(() => {
|
|
908
|
-
debounceCallback && window.addEventListener("resize", debounceCallback);
|
|
909
|
-
return () => debounceCallback && window.removeEventListener("resize", debounceCallback);
|
|
910
|
-
}, [debounceCallback]);
|
|
911
|
-
};
|
|
912
|
-
|
|
913
|
-
const _excluded = ["zIndex", "lowerSiblings", "upperSiblings", "onError", "children"];
|
|
914
|
-
const Map = (_ref) => {
|
|
915
|
-
let {
|
|
916
|
-
zIndex,
|
|
917
|
-
lowerSiblings,
|
|
918
|
-
upperSiblings,
|
|
919
|
-
onError,
|
|
920
|
-
children
|
|
921
|
-
} = _ref,
|
|
922
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
923
|
-
|
|
924
|
-
const {
|
|
925
|
-
map,
|
|
926
|
-
setLoaded
|
|
927
|
-
} = useMapContext();
|
|
928
|
-
return React__default.createElement(MapWrapper, {
|
|
929
|
-
"$zIndex": zIndex
|
|
930
|
-
}, lowerSiblings, React__default.createElement(MapGL__default, Object.assign({}, rest, {
|
|
931
|
-
renderWorldCopies: true,
|
|
932
|
-
antialias: true,
|
|
933
|
-
doubleClickZoom: false,
|
|
934
|
-
cursor: "default",
|
|
935
|
-
onLoad: e => {
|
|
936
|
-
map.current = e.target;
|
|
937
|
-
map.current.on("error", onError);
|
|
938
|
-
setLoaded(true);
|
|
939
|
-
}
|
|
940
|
-
}), children), upperSiblings);
|
|
941
|
-
};
|
|
942
|
-
|
|
943
|
-
exports.DEFAULT_CIRCLE_PAINT = DEFAULT_CIRCLE_PAINT;
|
|
944
|
-
exports.DEFAULT_FILL_EXTRUSION_PAINT = DEFAULT_FILL_EXTRUSION_PAINT;
|
|
945
|
-
exports.DEFAULT_FILL_PAINT = DEFAULT_FILL_PAINT;
|
|
946
|
-
exports.DEFAULT_LINE_PAINT = DEFAULT_LINE_PAINT;
|
|
947
|
-
exports.ErrorBoundary = ErrorBoundary;
|
|
948
|
-
exports.Layer = Layer;
|
|
949
|
-
exports.Map = Map;
|
|
950
|
-
exports.MapContext = MapContext;
|
|
951
|
-
exports.MapProvider = MapProvider;
|
|
952
|
-
exports.NO_CONTENT_VALUE = NO_CONTENT_VALUE;
|
|
953
|
-
exports.ServerNotificationsContext = ServerNotificationsContext;
|
|
954
|
-
exports.ServerNotificationsProvider = ServerNotificationsProvider;
|
|
955
|
-
exports.convertSpToTurfFeature = convertSpToTurfFeature;
|
|
956
|
-
exports.debounce = debounce;
|
|
957
|
-
exports.findAttributeInExpression = findAttributeInExpression;
|
|
958
|
-
exports.formatDate = formatDate;
|
|
959
|
-
exports.getActualExtrusionHeight = getActualExtrusionHeight;
|
|
960
|
-
exports.getDate = getDate;
|
|
961
|
-
exports.isNumeric = isNumeric;
|
|
962
|
-
exports.isObject = isObject;
|
|
963
|
-
exports.parseClientStyle = parseClientStyle;
|
|
964
|
-
exports.useDebouncedCallback = useDebouncedCallback;
|
|
965
|
-
exports.useMapContext = useMapContext;
|
|
966
|
-
exports.useMapDraw = useMapDraw;
|
|
967
|
-
exports.useRedrawLayer = useRedrawLayer;
|
|
968
|
-
exports.useServerNotificationsContext = useServerNotificationsContext;
|
|
969
|
-
exports.useToggle = useToggle;
|
|
970
|
-
exports.useWindowResize = useWindowResize;
|
|
971
|
-
exports.useZoomToFeatures = useZoomToFeatures;
|
|
972
|
-
exports.useZoomToPoint = useZoomToPoint;
|
|
973
|
-
//# sourceMappingURL=react.cjs.development.js.map
|