@nextgis/ngw-leaflet 1.12.0 → 1.12.1

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.
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-leaflet; version: 1.12.0; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 1.12.1; author: NextGIS */
2
2
  import 'leaflet/dist/leaflet.css';
3
3
  import { Icon } from 'leaflet';
4
4
  import { NgwMap } from '@nextgis/ngw-map';
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-leaflet; version: 1.12.0; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 1.12.1; author: NextGIS */
2
2
  var NgwLeaflet = (function () {
3
3
  'use strict';
4
4
 
@@ -15399,6 +15399,9 @@ var NgwLeaflet = (function () {
15399
15399
 
15400
15400
  function isObject$1(val) {
15401
15401
  return Object.prototype.toString.call(val) === '[object Object]';
15402
+ }
15403
+ function isArray(val) {
15404
+ return Object.prototype.toString.call(val) === '[object Array]';
15402
15405
  }
15403
15406
 
15404
15407
  function fixUrlStr(url) {
@@ -16462,6 +16465,9 @@ var NgwLeaflet = (function () {
16462
16465
  'movestart',
16463
16466
  'move',
16464
16467
  'moveend',
16468
+ 'mousemove',
16469
+ 'mouseout',
16470
+ 'mouseover',
16465
16471
  ];
16466
16472
  if (opt && opt.include) {
16467
16473
  events = events.filter(function (x) { return opt.include.includes(x); });
@@ -18251,6 +18257,11 @@ var NgwLeaflet = (function () {
18251
18257
  xhr.abort();
18252
18258
  });
18253
18259
  }
18260
+ if (options.signal) {
18261
+ options.signal.addEventListener('abort', function () {
18262
+ xhr.abort();
18263
+ });
18264
+ }
18254
18265
  xhr.send(data);
18255
18266
  };
18256
18267
  }
@@ -18392,7 +18403,12 @@ var NgwLeaflet = (function () {
18392
18403
  forCache.id = resource;
18393
18404
  }
18394
18405
  else if (isObject(resource)) {
18395
- forCache.id = resource.id;
18406
+ if (resource.id !== undefined) {
18407
+ forCache.id = resource.id;
18408
+ }
18409
+ else if (resource.keyname) {
18410
+ forCache.keyname = resource.keyname;
18411
+ }
18396
18412
  }
18397
18413
  var makeRequest = function () {
18398
18414
  if (typeof resource === 'string') {
@@ -18494,20 +18510,35 @@ var NgwLeaflet = (function () {
18494
18510
  };
18495
18511
  ResourcesControl.prototype.getChildrenOf = function (resource, requestOptions) {
18496
18512
  var _this = this;
18497
- return this.getId(resource).then(function (parent) {
18498
- return _this.connector
18499
- .get('resource.collection', __assign({ cache: true }, requestOptions), {
18500
- parent: parent,
18501
- })
18502
- .then(function (items) {
18503
- for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
18504
- var i = items_1[_i];
18505
- _this.cache.add('resource.item', CancelablePromise.resolve(i), {
18506
- id: i.resource.id,
18507
- });
18513
+ return this.getIdOrFail(resource).then(function (parent) {
18514
+ return _this._getChildrenOf(parent, requestOptions);
18515
+ });
18516
+ };
18517
+ ResourcesControl.prototype._getChildrenOf = function (parent, requestOptions, _items) {
18518
+ var _this = this;
18519
+ if (_items === void 0) { _items = []; }
18520
+ return this.connector
18521
+ .get('resource.collection', __assign({ cache: true }, requestOptions), {
18522
+ parent: parent,
18523
+ })
18524
+ .then(function (items) {
18525
+ var recursivePromises = [];
18526
+ for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
18527
+ var item = items_1[_i];
18528
+ _this.cache.add('resource.item', CancelablePromise.resolve(item), {
18529
+ id: item.resource.id,
18530
+ });
18531
+ _items.push(item);
18532
+ if ((requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.recursive) && item.resource.children) {
18533
+ recursivePromises.push(_this._getChildrenOf(item.resource.id, requestOptions, _items));
18508
18534
  }
18509
- return items;
18510
- });
18535
+ }
18536
+ if (recursivePromises.length) {
18537
+ return CancelablePromise.all(recursivePromises).then(function () {
18538
+ return _items;
18539
+ });
18540
+ }
18541
+ return _items;
18511
18542
  });
18512
18543
  };
18513
18544
  ResourcesControl.prototype.update = function (resource, data) {
@@ -19388,6 +19419,7 @@ var NgwLeaflet = (function () {
19388
19419
  }
19389
19420
 
19390
19421
  function prepareNgwFieldsToPropertiesFilter(fields) {
19422
+ console.log(fields);
19391
19423
  var f;
19392
19424
  var _loop_1 = function () {
19393
19425
  var field = fields[f];
@@ -19407,6 +19439,9 @@ var NgwLeaflet = (function () {
19407
19439
  fields[f] = new (Date.bind.apply(Date, __spreadArray([void 0], dt_1, false)))().toISOString();
19408
19440
  }
19409
19441
  }
19442
+ else if (f === 'id' && typeof field === 'string') {
19443
+ fields[f] = field.split(',').map(Number);
19444
+ }
19410
19445
  };
19411
19446
  for (f in fields) {
19412
19447
  _loop_1();
@@ -19419,7 +19454,7 @@ var NgwLeaflet = (function () {
19419
19454
  if (filters) {
19420
19455
  return createFeatureFieldFilterQueries(__assign(__assign({}, options), { filters: filters })).then(function (data) {
19421
19456
  var _a;
19422
- var clientFilterValidate = (_a = options.clientFilterValidate) !== null && _a !== void 0 ? _a : true;
19457
+ var clientFilterValidate = (_a = options.clientFilterValidate) !== null && _a !== void 0 ? _a : isFilterWithAnyCase(filters);
19423
19458
  // Additional client-side filter check
19424
19459
  if (clientFilterValidate) {
19425
19460
  data = data.filter(function (y) {
@@ -19434,6 +19469,21 @@ var NgwLeaflet = (function () {
19434
19469
  else {
19435
19470
  return fetchNgwLayerItemsRequest(options);
19436
19471
  }
19472
+ }
19473
+ function isFilterWithAnyCase(filters) {
19474
+ if (filters[0] === 'any') {
19475
+ return true;
19476
+ }
19477
+ for (var i = 1; i < filters.length; i++) {
19478
+ var p = filters[i];
19479
+ if (isArray(p)) {
19480
+ var deep = isFilterWithAnyCase(p);
19481
+ if (deep) {
19482
+ return true;
19483
+ }
19484
+ }
19485
+ }
19486
+ return false;
19437
19487
  }
19438
19488
 
19439
19489
  function fetchNgwLayerFeatures(options) {
@@ -21983,7 +22033,6 @@ var NgwLeaflet = (function () {
21983
22033
 
21984
22034
  function getIdentifyItems(identify, multiple) {
21985
22035
  if (multiple === void 0) { multiple = false; }
21986
- var params;
21987
22036
  var resources = [];
21988
22037
  var paramsList = [];
21989
22038
  for (var l in identify) {
@@ -22004,14 +22053,9 @@ var NgwLeaflet = (function () {
22004
22053
  if ('features' in identifyItem) {
22005
22054
  var layerFeatures = identifyItem.features;
22006
22055
  var resourceId = Number(l);
22007
- var feature = layerFeatures[0];
22008
- if (feature) {
22009
- params = {
22010
- featureId: feature.id,
22011
- resourceId: resourceId,
22012
- feature: feature,
22013
- };
22014
- paramsList.push(params);
22056
+ var featureParams = createParamsFromFeatures(layerFeatures, resourceId, multiple);
22057
+ if (featureParams.length) {
22058
+ paramsList.push.apply(paramsList, featureParams);
22015
22059
  if (!multiple) {
22016
22060
  break;
22017
22061
  }
@@ -22020,6 +22064,22 @@ var NgwLeaflet = (function () {
22020
22064
  }
22021
22065
  return paramsList;
22022
22066
  }
22067
+ function createParamsFromFeatures(features, resourceId, multiple) {
22068
+ var featureParams = [];
22069
+ for (var _i = 0, features_1 = features; _i < features_1.length; _i++) {
22070
+ var feature = features_1[_i];
22071
+ var params = {
22072
+ featureId: feature.id,
22073
+ resourceId: resourceId,
22074
+ feature: feature,
22075
+ };
22076
+ featureParams.push(params);
22077
+ if (!multiple) {
22078
+ break;
22079
+ }
22080
+ }
22081
+ return featureParams;
22082
+ }
22023
22083
  function fetchIdentifyGeoJson(options) {
22024
22084
  var connector = options.connector, identify = options.identify;
22025
22085
  for (var l in identify) {
@@ -24247,11 +24307,16 @@ var NgwLeaflet = (function () {
24247
24307
  this._universalEvents = [
24248
24308
  'move',
24249
24309
  'zoom',
24250
- 'moveend',
24251
24310
  'zoomend',
24252
24311
  'zoomstart',
24312
+ 'moveend',
24253
24313
  'movestart',
24254
24314
  ];
24315
+ this._positionEvents = [
24316
+ 'mousemove',
24317
+ 'mouseout',
24318
+ 'mouseover',
24319
+ ];
24255
24320
  }
24256
24321
  LeafletMapAdapter.prototype.create = function (options) {
24257
24322
  var _this = this;
@@ -24504,9 +24569,22 @@ var NgwLeaflet = (function () {
24504
24569
  map.on('click', function (evt) {
24505
24570
  _this.onMapClick(evt);
24506
24571
  });
24507
- this._universalEvents.forEach(function (e) {
24572
+ var _loop_1 = function (e) {
24508
24573
  map.on(e, function () { return _this.emitter.emit(e, _this); }, map);
24509
- });
24574
+ };
24575
+ for (var _i = 0, _a = this._universalEvents; _i < _a.length; _i++) {
24576
+ var e = _a[_i];
24577
+ _loop_1(e);
24578
+ }
24579
+ var _loop_2 = function (e) {
24580
+ map.on(e, function (evt) {
24581
+ return _this.emitter.emit(e, convertMapClickEvent(evt));
24582
+ }, map);
24583
+ };
24584
+ for (var _b = 0, _c = this._positionEvents; _b < _c.length; _b++) {
24585
+ var e = _c[_b];
24586
+ _loop_2(e);
24587
+ }
24510
24588
  }
24511
24589
  };
24512
24590
  LeafletMapAdapter.layerAdapters = {