@tabler/core 1.0.0-beta11 → 1.0.0-beta12

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 (112) hide show
  1. package/README.md +33 -10
  2. package/dist/css/demo.css +251 -379
  3. package/dist/css/demo.min.css +3 -3
  4. package/dist/css/demo.rtl.css +251 -379
  5. package/dist/css/demo.rtl.min.css +3 -3
  6. package/dist/css/tabler-flags.css +266 -529
  7. package/dist/css/tabler-flags.min.css +3 -3
  8. package/dist/css/tabler-flags.rtl.css +266 -529
  9. package/dist/css/tabler-flags.rtl.min.css +3 -3
  10. package/dist/css/tabler-payments.css +127 -252
  11. package/dist/css/tabler-payments.min.css +2 -2
  12. package/dist/css/tabler-payments.rtl.css +127 -252
  13. package/dist/css/tabler-payments.rtl.min.css +2 -2
  14. package/dist/css/tabler-vendors.css +480 -679
  15. package/dist/css/tabler-vendors.min.css +3 -3
  16. package/dist/css/tabler-vendors.rtl.css +480 -679
  17. package/dist/css/tabler-vendors.rtl.min.css +3 -3
  18. package/dist/css/tabler.css +10041 -14881
  19. package/dist/css/tabler.min.css +4 -4
  20. package/dist/css/tabler.rtl.css +10041 -14880
  21. package/dist/css/tabler.rtl.min.css +4 -4
  22. package/dist/js/demo-theme.js +32 -0
  23. package/dist/js/demo-theme.min.js +9 -0
  24. package/dist/js/demo.js +2 -12
  25. package/dist/js/demo.min.js +3 -3
  26. package/dist/js/tabler.esm.js +90 -61
  27. package/dist/js/tabler.esm.min.js +9 -3
  28. package/dist/js/tabler.js +112 -61
  29. package/dist/js/tabler.min.js +9 -3
  30. package/dist/libs/apexcharts/dist/apexcharts.amd.js +1 -1
  31. package/dist/libs/apexcharts/dist/apexcharts.common.js +3 -3
  32. package/dist/libs/apexcharts/dist/apexcharts.esm.js +3 -3
  33. package/dist/libs/apexcharts/dist/apexcharts.js +27 -8
  34. package/dist/libs/apexcharts/dist/apexcharts.min.js +3 -3
  35. package/dist/libs/bootstrap/dist/js/bootstrap.bundle.js +131 -107
  36. package/dist/libs/bootstrap/dist/js/bootstrap.bundle.js.map +1 -1
  37. package/dist/libs/bootstrap/dist/js/bootstrap.bundle.min.js +2 -2
  38. package/dist/libs/bootstrap/dist/js/bootstrap.bundle.min.js.map +1 -1
  39. package/dist/libs/bootstrap/dist/js/bootstrap.esm.js +70 -57
  40. package/dist/libs/bootstrap/dist/js/bootstrap.esm.js.map +1 -1
  41. package/dist/libs/bootstrap/dist/js/bootstrap.esm.min.js +2 -2
  42. package/dist/libs/bootstrap/dist/js/bootstrap.esm.min.js.map +1 -1
  43. package/dist/libs/bootstrap/dist/js/bootstrap.js +71 -58
  44. package/dist/libs/bootstrap/dist/js/bootstrap.js.map +1 -1
  45. package/dist/libs/bootstrap/dist/js/bootstrap.min.js +2 -2
  46. package/dist/libs/bootstrap/dist/js/bootstrap.min.js.map +1 -1
  47. package/dist/libs/jsvectormap/dist/js/jsvectormap.js +1061 -1066
  48. package/dist/libs/jsvectormap/dist/js/jsvectormap.min.js +1 -1
  49. package/dist/libs/nouislider/dist/nouislider.d.ts +1 -1
  50. package/package.json +68 -22
  51. package/src/js/demo-theme.js +25 -0
  52. package/src/js/demo.js +0 -17
  53. package/src/js/src/tabler.js +17 -0
  54. package/src/js/tabler.js +2 -0
  55. package/src/scss/_core.scss +1 -0
  56. package/src/scss/_mixins-override.scss +26 -26
  57. package/src/scss/_utilities.scss +2 -2
  58. package/src/scss/_variables.scss +207 -89
  59. package/src/scss/demo/_examples.scss +2 -2
  60. package/src/scss/demo/_highlight.scss +3 -3
  61. package/src/scss/demo.scss +4 -4
  62. package/src/scss/fonts/_webfonts.scss +0 -50
  63. package/src/scss/layout/_core.scss +2 -23
  64. package/src/scss/layout/_dark.scss +8 -6
  65. package/src/scss/layout/_footer.scss +2 -2
  66. package/src/scss/layout/_navbar.scss +7 -5
  67. package/src/scss/layout/_page.scss +8 -6
  68. package/src/scss/layout/_root.scss +37 -0
  69. package/src/scss/mixins/_functions.scss +2 -2
  70. package/src/scss/mixins/_mixins.scss +3 -2
  71. package/src/scss/ui/_accordion.scss +1 -1
  72. package/src/scss/ui/_alerts.scss +1 -1
  73. package/src/scss/ui/_avatars.scss +5 -5
  74. package/src/scss/ui/_badges.scss +2 -2
  75. package/src/scss/ui/_buttons.scss +25 -17
  76. package/src/scss/ui/_calendars.scss +8 -8
  77. package/src/scss/ui/_cards.scss +28 -31
  78. package/src/scss/ui/_carousel.scss +1 -1
  79. package/src/scss/ui/_chips.scss +0 -0
  80. package/src/scss/ui/_empty.scss +3 -3
  81. package/src/scss/ui/_flags.scss +2 -2
  82. package/src/scss/ui/_forms.scss +7 -7
  83. package/src/scss/ui/_grid.scss +8 -9
  84. package/src/scss/ui/_icons.scss +64 -4
  85. package/src/scss/ui/_legend.scss +8 -4
  86. package/src/scss/ui/_lists.scss +16 -13
  87. package/src/scss/ui/_markdown.scss +2 -3
  88. package/src/scss/ui/_modals.scss +1 -1
  89. package/src/scss/ui/_nav.scss +7 -7
  90. package/src/scss/ui/_offcanvas.scss +2 -2
  91. package/src/scss/ui/_pagination.scss +10 -6
  92. package/src/scss/ui/_placeholder.scss +1 -1
  93. package/src/scss/ui/_progress.scss +45 -6
  94. package/src/scss/ui/_ribbons.scss +5 -5
  95. package/src/scss/ui/_status.scss +2 -2
  96. package/src/scss/ui/_steps.scss +2 -2
  97. package/src/scss/ui/_tables.scss +26 -5
  98. package/src/scss/ui/_toasts.scss +0 -1
  99. package/src/scss/ui/_type.scss +45 -30
  100. package/src/scss/ui/forms/_form-check.scss +26 -1
  101. package/src/scss/ui/forms/_form-colorinput.scss +2 -2
  102. package/src/scss/ui/forms/_form-icon.scss +1 -1
  103. package/src/scss/ui/forms/_form-imagecheck.scss +4 -4
  104. package/src/scss/ui/forms/_form-selectgroup.scss +7 -7
  105. package/src/scss/ui/typo/_hr.scss +2 -3
  106. package/src/scss/utils/_colors.scss +14 -5
  107. package/src/scss/vendor/_dropzone.scss +1 -1
  108. package/src/scss/vendor/_jsvectormap.scss +7 -7
  109. package/src/scss/vendor/_litepicker.scss +11 -11
  110. package/src/scss/vendor/_plyr.scss +1 -1
  111. package/src/scss/vendor/_tinymce.scss +3 -3
  112. package/src/scss/vendor/_tom-select.scss +2 -0
@@ -251,454 +251,6 @@
251
251
  Object.assign(target.prototype, source);
252
252
  };
253
253
 
254
- var Defaults = {
255
- map: 'world',
256
- backgroundColor: 'transparent',
257
- draggable: true,
258
- zoomButtons: true,
259
- zoomOnScroll: true,
260
- zoomOnScrollSpeed: 3,
261
- zoomMax: 12,
262
- zoomMin: 1,
263
- zoomAnimate: true,
264
- showTooltip: true,
265
- zoomStep: 1.5,
266
- bindTouchEvents: true,
267
- // Line options
268
- lineStyle: {
269
- stroke: '#808080',
270
- strokeWidth: 1,
271
- strokeLinecap: 'round'
272
- },
273
- // Marker options
274
- markersSelectable: false,
275
- markersSelectableOne: false,
276
- markerStyle: {
277
- initial: {
278
- r: 7,
279
- fill: '#374151',
280
- fillOpacity: 1,
281
- stroke: '#FFF',
282
- strokeWidth: 5,
283
- strokeOpacity: .5
284
- },
285
- hover: {
286
- fill: '#3cc0ff',
287
- cursor: 'pointer'
288
- },
289
- selected: {
290
- fill: 'blue'
291
- },
292
- selectedHover: {}
293
- },
294
- markerLabelStyle: {
295
- initial: {
296
- fontFamily: 'Verdana',
297
- fontSize: 12,
298
- fontWeight: 500,
299
- cursor: 'default',
300
- fill: '#374151'
301
- },
302
- hover: {
303
- cursor: 'pointer'
304
- },
305
- selected: {},
306
- selectedHover: {}
307
- },
308
- // Region options
309
- regionsSelectable: false,
310
- regionsSelectableOne: false,
311
- regionStyle: {
312
- initial: {
313
- fill: '#dee2e8',
314
- fillOpacity: 1,
315
- stroke: 'none',
316
- strokeWidth: 0
317
- },
318
- hover: {
319
- fillOpacity: .7,
320
- cursor: 'pointer'
321
- },
322
- selected: {
323
- fill: '#9ca3af'
324
- },
325
- selectedHover: {}
326
- },
327
- regionLabelStyle: {
328
- initial: {
329
- fontFamily: 'Verdana',
330
- fontSize: '12',
331
- fontWeight: 'bold',
332
- cursor: 'default',
333
- fill: '#35373e'
334
- },
335
- hover: {
336
- cursor: 'pointer'
337
- }
338
- }
339
- };
340
-
341
- function _inheritsLoose(subClass, superClass) {
342
- subClass.prototype = Object.create(superClass.prototype);
343
- subClass.prototype.constructor = subClass;
344
-
345
- _setPrototypeOf(subClass, superClass);
346
- }
347
-
348
- function _setPrototypeOf(o, p) {
349
- _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
350
- o.__proto__ = p;
351
- return o;
352
- };
353
- return _setPrototypeOf(o, p);
354
- }
355
-
356
- function _assertThisInitialized(self) {
357
- if (self === void 0) {
358
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
359
- }
360
-
361
- return self;
362
- }
363
-
364
- function _unsupportedIterableToArray(o, minLen) {
365
- if (!o) return;
366
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
367
- var n = Object.prototype.toString.call(o).slice(8, -1);
368
- if (n === "Object" && o.constructor) n = o.constructor.name;
369
- if (n === "Map" || n === "Set") return Array.from(o);
370
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
371
- }
372
-
373
- function _arrayLikeToArray(arr, len) {
374
- if (len == null || len > arr.length) len = arr.length;
375
-
376
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
377
-
378
- return arr2;
379
- }
380
-
381
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
382
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
383
- if (it) return (it = it.call(o)).next.bind(it);
384
-
385
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
386
- if (it) o = it;
387
- var i = 0;
388
- return function () {
389
- if (i >= o.length) return {
390
- done: true
391
- };
392
- return {
393
- done: false,
394
- value: o[i++]
395
- };
396
- };
397
- }
398
-
399
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
400
- }
401
-
402
- /**
403
- * ------------------------------------------------------------------------
404
- * Class Definition
405
- * ------------------------------------------------------------------------
406
- */
407
-
408
- var SVGElement = /*#__PURE__*/function () {
409
- function SVGElement(name, config) {
410
- this.node = this._createElement(name);
411
-
412
- if (config) {
413
- this.set(config);
414
- }
415
- } // Create new SVG element `svg`, `g`, `path`, `line`, `circle`, `image`, etc.
416
- // https://developer.mozilla.org/en-US/docs/Web/API/Document/createElementNS#important_namespace_uris
417
-
418
-
419
- var _proto = SVGElement.prototype;
420
-
421
- _proto._createElement = function _createElement(tagName) {
422
- return document.createElementNS('http://www.w3.org/2000/svg', tagName);
423
- };
424
-
425
- _proto.addClass = function addClass(className) {
426
- this.node.setAttribute('class', className);
427
- };
428
-
429
- _proto.getBBox = function getBBox() {
430
- return this.node.getBBox();
431
- } // Apply attributes on the current node element
432
- ;
433
-
434
- _proto.set = function set(property, value) {
435
- if (typeof property === 'object') {
436
- for (var attr in property) {
437
- this.applyAttr(attr, property[attr]);
438
- }
439
- } else {
440
- this.applyAttr(property, value);
441
- }
442
- };
443
-
444
- _proto.get = function get(property) {
445
- return this.style.initial[property];
446
- };
447
-
448
- _proto.applyAttr = function applyAttr(property, value) {
449
- this.node.setAttribute(hyphenate(property), value);
450
- };
451
-
452
- _proto.remove = function remove() {
453
- removeElement(this.node);
454
- };
455
-
456
- return SVGElement;
457
- }();
458
-
459
- /**
460
- * ------------------------------------------------------------------------
461
- * Class Definition
462
- * ------------------------------------------------------------------------
463
- */
464
-
465
- var SVGShapeElement = /*#__PURE__*/function (_SVGElement) {
466
- _inheritsLoose(SVGShapeElement, _SVGElement);
467
-
468
- function SVGShapeElement(name, config, style) {
469
- var _this;
470
-
471
- if (style === void 0) {
472
- style = {};
473
- }
474
-
475
- _this = _SVGElement.call(this, name, config) || this;
476
- _this.isHovered = false;
477
- _this.isSelected = false;
478
- _this.style = style;
479
- _this.style.current = {};
480
-
481
- _this.updateStyle();
482
-
483
- return _this;
484
- }
485
-
486
- var _proto = SVGShapeElement.prototype;
487
-
488
- _proto.setStyle = function setStyle(property, value) {
489
- if (typeof property === 'object') {
490
- merge(this.style.current, property);
491
- } else {
492
- var _merge;
493
-
494
- merge(this.style.current, (_merge = {}, _merge[property] = value, _merge));
495
- }
496
-
497
- this.updateStyle();
498
- };
499
-
500
- _proto.updateStyle = function updateStyle() {
501
- var attrs = {};
502
- merge(attrs, this.style.initial);
503
- merge(attrs, this.style.current);
504
-
505
- if (this.isHovered) {
506
- merge(attrs, this.style.hover);
507
- }
508
-
509
- if (this.isSelected) {
510
- merge(attrs, this.style.selected);
511
-
512
- if (this.isHovered) {
513
- merge(attrs, this.style.selectedHover);
514
- }
515
- }
516
-
517
- this.set(attrs);
518
- };
519
-
520
- return SVGShapeElement;
521
- }(SVGElement);
522
-
523
- /**
524
- * ------------------------------------------------------------------------
525
- * Class Definition
526
- * ------------------------------------------------------------------------
527
- */
528
-
529
- var SVGTextElement = /*#__PURE__*/function (_SVGShapeElement) {
530
- _inheritsLoose(SVGTextElement, _SVGShapeElement);
531
-
532
- function SVGTextElement(config, style) {
533
- return _SVGShapeElement.call(this, 'text', config, style) || this;
534
- }
535
-
536
- var _proto = SVGTextElement.prototype;
537
-
538
- _proto.applyAttr = function applyAttr(attr, value) {
539
- attr === 'text' ? this.node.textContent = value : _SVGShapeElement.prototype.applyAttr.call(this, attr, value);
540
- };
541
-
542
- return SVGTextElement;
543
- }(SVGShapeElement);
544
-
545
- /**
546
- * ------------------------------------------------------------------------
547
- * Class Definition
548
- * ------------------------------------------------------------------------
549
- */
550
-
551
- var SVGImageElement = /*#__PURE__*/function (_SVGShapeElement) {
552
- _inheritsLoose(SVGImageElement, _SVGShapeElement);
553
-
554
- function SVGImageElement(config, style) {
555
- return _SVGShapeElement.call(this, 'image', config, style) || this;
556
- }
557
-
558
- var _proto = SVGImageElement.prototype;
559
-
560
- _proto.applyAttr = function applyAttr(attr, value) {
561
- var imageUrl;
562
-
563
- if (attr === 'image') {
564
- // This get executed when we have url in series.markers[0].scale.someScale.url
565
- if (typeof value === 'object') {
566
- imageUrl = value.url;
567
- this.offset = value.offset || [0, 0];
568
- } else {
569
- imageUrl = value;
570
- this.offset = [0, 0];
571
- }
572
-
573
- this.node.setAttributeNS('http://www.w3.org/1999/xlink', 'href', imageUrl); // Set width and height then call this `applyAttr` again
574
-
575
- this.width = 23;
576
- this.height = 23;
577
- this.applyAttr('width', this.width);
578
- this.applyAttr('height', this.height);
579
- this.applyAttr('x', this.cx - this.width / 2 + this.offset[0]);
580
- this.applyAttr('y', this.cy - this.height / 2 + this.offset[1]);
581
- } else if (attr == 'cx') {
582
- this.cx = value;
583
-
584
- if (this.width) {
585
- this.applyAttr('x', value - this.width / 2 + this.offset[0]);
586
- }
587
- } else if (attr == 'cy') {
588
- this.cy = value;
589
-
590
- if (this.height) {
591
- this.applyAttr('y', value - this.height / 2 + this.offset[1]);
592
- }
593
- } else {
594
- // This time Call SVGElement
595
- _SVGShapeElement.prototype.applyAttr.apply(this, arguments);
596
- }
597
- };
598
-
599
- return SVGImageElement;
600
- }(SVGShapeElement);
601
-
602
- /**
603
- * ------------------------------------------------------------------------
604
- * Class Definition
605
- * ------------------------------------------------------------------------
606
- */
607
-
608
- var SVGCanvasElement = /*#__PURE__*/function (_SVGElement) {
609
- _inheritsLoose(SVGCanvasElement, _SVGElement);
610
-
611
- function SVGCanvasElement(container) {
612
- var _this;
613
-
614
- _this = _SVGElement.call(this, 'svg') || this; // Create svg element for holding the whole map
615
-
616
- _this._container = container; // Create the defs element
617
-
618
- _this._defsElement = new SVGElement('defs'); // Create group element which will hold the paths (regions)
619
-
620
- _this._rootElement = new SVGElement('g', {
621
- id: 'jvm-regions-group'
622
- }); // Append the defs element to the this.node (SVG tag)
623
-
624
- _this.node.appendChild(_this._defsElement.node); // Append the group to this.node (SVG tag)
625
-
626
-
627
- _this.node.appendChild(_this._rootElement.node); // Append this.node (SVG tag) to the container
628
-
629
-
630
- _this._container.appendChild(_this.node);
631
-
632
- return _this;
633
- }
634
-
635
- var _proto = SVGCanvasElement.prototype;
636
-
637
- _proto.setSize = function setSize(width, height) {
638
- this.node.setAttribute('width', width);
639
- this.node.setAttribute('height', height);
640
- };
641
-
642
- _proto.applyTransformParams = function applyTransformParams(scale, transX, transY) {
643
- this._rootElement.node.setAttribute('transform', "scale(" + scale + ") translate(" + transX + ", " + transY + ")");
644
- } // Create `path` element
645
- ;
646
-
647
- _proto.createPath = function createPath(config, style) {
648
- var path = new SVGShapeElement('path', config, style);
649
- path.node.setAttribute('fill-rule', 'evenodd');
650
- return this.add(path);
651
- } // Create `circle` element
652
- ;
653
-
654
- _proto.createCircle = function createCircle(config, style, group) {
655
- var circle = new SVGShapeElement('circle', config, style);
656
- return this.add(circle, group);
657
- } // Create `line` element
658
- ;
659
-
660
- _proto.createLine = function createLine(config, style, group) {
661
- var line = new SVGShapeElement('line', config, style);
662
- return this.add(line, group);
663
- } // Create `text` element
664
- ;
665
-
666
- _proto.createText = function createText(config, style, group) {
667
- var text = new SVGTextElement(config, style); // extends SVGShapeElement
668
-
669
- return this.add(text, group);
670
- } // Create `image` element
671
- ;
672
-
673
- _proto.createImage = function createImage(config, style, group) {
674
- var image = new SVGImageElement(config, style); // extends SVGShapeElement
675
-
676
- return this.add(image, group);
677
- } // Create `g` element
678
- ;
679
-
680
- _proto.createGroup = function createGroup(id) {
681
- var group = new SVGElement('g');
682
- this.node.appendChild(group.node);
683
-
684
- if (id) {
685
- group.node.id = id;
686
- }
687
-
688
- group.canvas = this;
689
- return group;
690
- } // Add some element to a spcific group or the root element if the group isn't given
691
- ;
692
-
693
- _proto.add = function add(element, group) {
694
- group = group || this._rootElement;
695
- group.node.appendChild(element.node);
696
- return element;
697
- };
698
-
699
- return SVGCanvasElement;
700
- }(SVGElement);
701
-
702
254
  var eventRegistry = {};
703
255
  var eventUid = 1;
704
256
  /**
@@ -999,8 +551,69 @@
999
551
  lastTouchesLength = touches.length;
1000
552
  };
1001
553
 
1002
- EventHandler.on(map.container, 'touchstart', handleTouchEvent);
1003
- EventHandler.on(map.container, 'touchmove', handleTouchEvent);
554
+ EventHandler.on(map.container, 'touchstart', handleTouchEvent);
555
+ EventHandler.on(map.container, 'touchmove', handleTouchEvent);
556
+ }
557
+
558
+ function _inheritsLoose(subClass, superClass) {
559
+ subClass.prototype = Object.create(superClass.prototype);
560
+ subClass.prototype.constructor = subClass;
561
+
562
+ _setPrototypeOf(subClass, superClass);
563
+ }
564
+
565
+ function _setPrototypeOf(o, p) {
566
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
567
+ o.__proto__ = p;
568
+ return o;
569
+ };
570
+ return _setPrototypeOf(o, p);
571
+ }
572
+
573
+ function _assertThisInitialized(self) {
574
+ if (self === void 0) {
575
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
576
+ }
577
+
578
+ return self;
579
+ }
580
+
581
+ function _unsupportedIterableToArray(o, minLen) {
582
+ if (!o) return;
583
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
584
+ var n = Object.prototype.toString.call(o).slice(8, -1);
585
+ if (n === "Object" && o.constructor) n = o.constructor.name;
586
+ if (n === "Map" || n === "Set") return Array.from(o);
587
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
588
+ }
589
+
590
+ function _arrayLikeToArray(arr, len) {
591
+ if (len == null || len > arr.length) len = arr.length;
592
+
593
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
594
+
595
+ return arr2;
596
+ }
597
+
598
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
599
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
600
+ if (it) return (it = it.call(o)).next.bind(it);
601
+
602
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
603
+ if (it) o = it;
604
+ var i = 0;
605
+ return function () {
606
+ if (i >= o.length) return {
607
+ done: true
608
+ };
609
+ return {
610
+ done: false,
611
+ value: o[i++]
612
+ };
613
+ };
614
+ }
615
+
616
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1004
617
  }
1005
618
 
1006
619
  /**
@@ -1123,7 +736,7 @@
1123
736
 
1124
737
 
1125
738
  if (label && text) {
1126
- var offsets = _this.getLabelOffsets(code);
739
+ var offsets = _this.getLabelOffsets(code, label);
1127
740
 
1128
741
  _this.labelX = bbox.x + bbox.width / 2 + offsets[0];
1129
742
  _this.labelY = bbox.y + bbox.height / 2 + offsets[1];
@@ -1169,7 +782,7 @@
1169
782
 
1170
783
  function createRegions() {
1171
784
  var code, region;
1172
- this.regionLabelsGroup = this.regionLabelsGroup || this.canvas.createGroup('jvm-regions-labels-group');
785
+ this._regionLabelsGroup = this._regionLabelsGroup || this.canvas.createGroup('jvm-regions-labels-group');
1173
786
 
1174
787
  for (code in this.mapData.paths) {
1175
788
  region = new Region({
@@ -1178,7 +791,7 @@
1178
791
  path: this.mapData.paths[code].path,
1179
792
  style: merge({}, this.params.regionStyle),
1180
793
  labelStyle: this.params.regionLabelStyle,
1181
- labelsGroup: this.regionLabelsGroup,
794
+ labelsGroup: this._regionLabelsGroup,
1182
795
  label: this.params.labels && this.params.labels.regions
1183
796
  });
1184
797
  this.regions[code] = {
@@ -1311,7 +924,7 @@
1311
924
  dataIndex: index,
1312
925
  cx: cx,
1313
926
  cy: cy
1314
- }, _this._getStyle(), group);
927
+ }, style, group);
1315
928
 
1316
929
  _this.shape.addClass('jvm-marker jvm-element');
1317
930
 
@@ -1337,765 +950,1141 @@
1337
950
  }
1338
951
  };
1339
952
 
1340
- _proto._createLabel = function _createLabel(_ref2) {
1341
- var index = _ref2.index,
1342
- map = _ref2.map,
1343
- label = _ref2.label,
1344
- labelsGroup = _ref2.labelsGroup,
1345
- cx = _ref2.cx,
1346
- cy = _ref2.cy,
1347
- marker = _ref2.marker,
1348
- isRecentlyCreated = _ref2.isRecentlyCreated;
1349
- var labelText = this.getLabelText(index, label);
1350
- this._labelX = cx / map.scale - map.transX;
1351
- this._labelY = cy / map.scale - map.transY;
1352
- this._offsets = isRecentlyCreated && marker.offsets ? marker.offsets : this.getLabelOffsets(index, label);
1353
- this.label = map.canvas.createText({
1354
- text: labelText,
1355
- dataIndex: index,
1356
- x: this._labelX,
1357
- y: this._labelY,
1358
- dy: '0.6ex'
1359
- }, map.params.markerLabelStyle, labelsGroup);
1360
- this.label.addClass('jvm-marker jvm-element');
953
+ _proto._createLabel = function _createLabel(_ref2) {
954
+ var index = _ref2.index,
955
+ map = _ref2.map,
956
+ label = _ref2.label,
957
+ labelsGroup = _ref2.labelsGroup,
958
+ cx = _ref2.cx,
959
+ cy = _ref2.cy,
960
+ marker = _ref2.marker,
961
+ isRecentlyCreated = _ref2.isRecentlyCreated;
962
+ var labelText = this.getLabelText(index, label);
963
+ this._labelX = cx / map.scale - map.transX;
964
+ this._labelY = cy / map.scale - map.transY;
965
+ this._offsets = isRecentlyCreated && marker.offsets ? marker.offsets : this.getLabelOffsets(index, label);
966
+ this.label = map.canvas.createText({
967
+ text: labelText,
968
+ dataIndex: index,
969
+ x: this._labelX,
970
+ y: this._labelY,
971
+ dy: '0.6ex'
972
+ }, map.params.markerLabelStyle, labelsGroup);
973
+ this.label.addClass('jvm-marker jvm-element');
974
+
975
+ if (isRecentlyCreated) {
976
+ this.updateLabelPosition();
977
+ }
978
+ };
979
+
980
+ return Marker;
981
+ }(BaseComponent);
982
+
983
+ inherit(Marker, Interactable);
984
+
985
+ function createMarkers(markers, isRecentlyCreated) {
986
+ var _this = this;
987
+
988
+ if (markers === void 0) {
989
+ markers = {};
990
+ }
991
+
992
+ if (isRecentlyCreated === void 0) {
993
+ isRecentlyCreated = false;
994
+ }
995
+
996
+ var config, marker, point, uid; // Create groups for holding markers and markers labels
997
+ // We're checking if `markersGroup` exists or not becuase we may add markers after the map has loaded
998
+ // So we will append the futured markers to this group as well.
999
+
1000
+ this._markersGroup = this._markersGroup || this.canvas.createGroup('jvm-markers-group');
1001
+ this._markerLabelsGroup = this._markerLabelsGroup || this.canvas.createGroup('jvm-markers-labels-group');
1002
+
1003
+ for (var index in markers) {
1004
+ config = markers[index];
1005
+ point = this.getMarkerPosition(config);
1006
+ uid = config.coords.join(':');
1007
+
1008
+ if (!point) {
1009
+ continue;
1010
+ } // We're checking if recently created marker does already exist
1011
+ // If exists we don't need to create it again, so we'll continute
1012
+ // Becuase we may have more than one marker submitted via `addMarkers` method.
1013
+
1014
+
1015
+ if (isRecentlyCreated) {
1016
+ if (Object.keys(this.markers).filter(function (i) {
1017
+ return _this.markers[i]._uid === uid;
1018
+ }).length) {
1019
+ continue;
1020
+ }
1021
+
1022
+ index = Object.keys(this.markers).length;
1023
+ }
1024
+
1025
+ marker = new Marker({
1026
+ index: index,
1027
+ map: this,
1028
+ // Merge the `markerStyle` object with the marker config `style` if presented.
1029
+ style: merge(this.params.markerStyle, {
1030
+ initial: config.style || {}
1031
+ }, true),
1032
+ label: this.params.labels && this.params.labels.markers,
1033
+ labelsGroup: this._markerLabelsGroup,
1034
+ cx: point.x,
1035
+ cy: point.y,
1036
+ group: this._markersGroup,
1037
+ marker: config,
1038
+ isRecentlyCreated: isRecentlyCreated
1039
+ }); // Check for marker duplication
1040
+ // this is useful when for example: a user clicks a button for creating marker two times
1041
+ // so it will remove the old one and the new one will take its place.
1042
+
1043
+ if (this.markers[index]) {
1044
+ this.removeMarkers([index]);
1045
+ }
1046
+
1047
+ this.markers[index] = {
1048
+ _uid: uid,
1049
+ config: config,
1050
+ element: marker
1051
+ };
1052
+ }
1053
+ }
1054
+
1055
+ /**
1056
+ * ------------------------------------------------------------------------
1057
+ * Class Definition
1058
+ * ------------------------------------------------------------------------
1059
+ */
1060
+
1061
+ var Legend = /*#__PURE__*/function () {
1062
+ function Legend(options) {
1063
+ if (options === void 0) {
1064
+ options = {};
1065
+ }
1066
+
1067
+ this._options = options;
1068
+ this._map = this._options.map;
1069
+ this._series = this._options.series;
1070
+ this._body = createElement('div', 'jvm-legend');
1071
+
1072
+ if (this._options.cssClass) {
1073
+ this._body.setAttribute('class', this._options.cssClass);
1074
+ }
1075
+
1076
+ if (options.vertical) {
1077
+ this._map.legendVertical.appendChild(this._body);
1078
+ } else {
1079
+ this._map.legendHorizontal.appendChild(this._body);
1080
+ }
1081
+
1082
+ this.render();
1083
+ }
1084
+
1085
+ var _proto = Legend.prototype;
1086
+
1087
+ _proto.render = function render() {
1088
+ var ticks = this._series.scale.getTicks(),
1089
+ inner = createElement('div', 'jvm-legend-inner'),
1090
+ tick,
1091
+ sample,
1092
+ label;
1093
+
1094
+ this._body.innderHTML = '';
1095
+
1096
+ if (this._options.title) {
1097
+ var legendTitle = createElement('div', 'jvm-legend-title', this._options.title);
1098
+
1099
+ this._body.appendChild(legendTitle);
1100
+ }
1101
+
1102
+ this._body.appendChild(inner);
1103
+
1104
+ for (var i = 0; i < ticks.length; i++) {
1105
+ tick = createElement('div', 'jvm-legend-tick');
1106
+ sample = createElement('div', 'jvm-legend-tick-sample');
1107
+
1108
+ switch (this._series.config.attribute) {
1109
+ case 'fill':
1110
+ if (isImageUrl(ticks[i].value)) {
1111
+ sample.style.background = "url(" + ticks[i].value + ")";
1112
+ } else {
1113
+ sample.style.background = ticks[i].value;
1114
+ }
1115
+
1116
+ break;
1117
+
1118
+ case 'stroke':
1119
+ sample.style.background = ticks[i].value;
1120
+ break;
1121
+
1122
+ case 'image':
1123
+ sample.style.background = "url(" + (typeof ticks[i].value === 'object' ? ticks[i].value.url : ticks[i].value) + ") no-repeat center center";
1124
+ sample.style.backgroundSize = 'cover';
1125
+ break;
1126
+ }
1127
+
1128
+ tick.appendChild(sample);
1129
+ label = ticks[i].label;
1130
+
1131
+ if (this._options.labelRender) {
1132
+ label = this._options.labelRender(label);
1133
+ }
1134
+
1135
+ var tickText = createElement('div', 'jvm-legend-tick-text', label);
1136
+ tick.appendChild(tickText);
1137
+ inner.appendChild(tick);
1138
+ }
1139
+ };
1140
+
1141
+ return Legend;
1142
+ }();
1143
+
1144
+ /**
1145
+ * ------------------------------------------------------------------------
1146
+ * Class Definition
1147
+ * ------------------------------------------------------------------------
1148
+ */
1149
+ var OrdinalScale = /*#__PURE__*/function () {
1150
+ function OrdinalScale(scale) {
1151
+ this._scale = scale;
1152
+ }
1153
+
1154
+ var _proto = OrdinalScale.prototype;
1155
+
1156
+ _proto.getValue = function getValue(value) {
1157
+ return this._scale[value];
1158
+ };
1159
+
1160
+ _proto.getTicks = function getTicks() {
1161
+ var ticks = [];
1162
+
1163
+ for (var key in this._scale) {
1164
+ ticks.push({
1165
+ label: key,
1166
+ value: this._scale[key]
1167
+ });
1168
+ }
1169
+
1170
+ return ticks;
1171
+ };
1172
+
1173
+ return OrdinalScale;
1174
+ }();
1175
+
1176
+ /**
1177
+ * ------------------------------------------------------------------------
1178
+ * Class Definition
1179
+ * ------------------------------------------------------------------------
1180
+ */
1181
+
1182
+ var Series = /*#__PURE__*/function () {
1183
+ function Series(config, elements, map) {
1184
+ if (config === void 0) {
1185
+ config = {};
1186
+ }
1187
+
1188
+ // Private
1189
+ this._map = map;
1190
+ this._elements = elements; // Could be markers or regions
1191
+
1192
+ this._values = config.values || {}; // Protected
1193
+
1194
+ this.config = config;
1195
+ this.config.attribute = config.attribute || 'fill'; // Set initial attributes
1196
+
1197
+ if (config.attributes) {
1198
+ this.setAttributes(config.attributes);
1199
+ }
1200
+
1201
+ if (typeof config.scale === 'object') {
1202
+ this.scale = new OrdinalScale(config.scale);
1203
+ }
1204
+
1205
+ if (this.config.legend) {
1206
+ this.legend = new Legend(merge({
1207
+ map: this._map,
1208
+ series: this
1209
+ }, this.config.legend));
1210
+ }
1211
+
1212
+ this.setValues(this._values);
1213
+ }
1214
+
1215
+ var _proto = Series.prototype;
1216
+
1217
+ _proto.setValues = function setValues(values) {
1218
+ var attrs = {};
1219
+
1220
+ for (var key in values) {
1221
+ if (values[key]) {
1222
+ attrs[key] = this.scale.getValue(values[key]);
1223
+ }
1224
+ }
1225
+
1226
+ this.setAttributes(attrs);
1227
+ };
1228
+
1229
+ _proto.setAttributes = function setAttributes(attrs) {
1230
+ for (var code in attrs) {
1231
+ if (this._elements[code]) {
1232
+ this._elements[code].element.setStyle(this.config.attribute, attrs[code]);
1233
+ }
1234
+ }
1235
+ };
1236
+
1237
+ _proto.clear = function clear() {
1238
+ var key,
1239
+ attrs = {};
1361
1240
 
1362
- if (isRecentlyCreated) {
1363
- this.updateLabelPosition();
1241
+ for (key in this._values) {
1242
+ if (this._elements[key]) {
1243
+ attrs[key] = this._elements[key].element.shape.style.initial[this.config.attribute];
1244
+ }
1364
1245
  }
1365
- };
1366
1246
 
1367
- _proto._getStyle = function _getStyle() {
1368
- var style = {};
1247
+ this.setAttributes(attrs);
1248
+ this._values = {};
1249
+ };
1369
1250
 
1370
- if (this._isImage) {
1371
- style.initial = {
1372
- image: this.config.style.initial.image
1373
- };
1374
- } else {
1375
- style = this.config.style;
1376
- }
1251
+ return Series;
1252
+ }();
1377
1253
 
1378
- return style;
1254
+ function createSeries() {
1255
+ this.series = {
1256
+ markers: [],
1257
+ regions: []
1379
1258
  };
1380
1259
 
1381
- return Marker;
1382
- }(BaseComponent);
1260
+ for (var key in this.params.series) {
1261
+ for (var i = 0; i < this.params.series[key].length; i++) {
1262
+ this.series[key][i] = new Series(this.params.series[key][i], this[key], this);
1263
+ }
1264
+ }
1265
+ }
1383
1266
 
1384
- inherit(Marker, Interactable);
1267
+ function applyTransform() {
1268
+ var maxTransX, maxTransY, minTransX, minTransY;
1385
1269
 
1386
- function createMarkers(markers, isRecentlyCreated) {
1387
- var _this = this;
1270
+ if (this.defaultWidth * this.scale <= this.width) {
1271
+ maxTransX = (this.width - this.defaultWidth * this.scale) / (2 * this.scale);
1272
+ minTransX = (this.width - this.defaultWidth * this.scale) / (2 * this.scale);
1273
+ } else {
1274
+ maxTransX = 0;
1275
+ minTransX = (this.width - this.defaultWidth * this.scale) / this.scale;
1276
+ }
1388
1277
 
1389
- if (markers === void 0) {
1390
- markers = {};
1278
+ if (this.defaultHeight * this.scale <= this.height) {
1279
+ maxTransY = (this.height - this.defaultHeight * this.scale) / (2 * this.scale);
1280
+ minTransY = (this.height - this.defaultHeight * this.scale) / (2 * this.scale);
1281
+ } else {
1282
+ maxTransY = 0;
1283
+ minTransY = (this.height - this.defaultHeight * this.scale) / this.scale;
1391
1284
  }
1392
1285
 
1393
- if (isRecentlyCreated === void 0) {
1394
- isRecentlyCreated = false;
1286
+ if (this.transY > maxTransY) {
1287
+ this.transY = maxTransY;
1288
+ } else if (this.transY < minTransY) {
1289
+ this.transY = minTransY;
1395
1290
  }
1396
1291
 
1397
- var markerConfig, marker, point, uid; // Create groups for holding markers and markers labels
1398
- // We're checking if `markersGroup` exists or not becuase we may add markers after the map has loaded
1399
- // So we will append the futured markers to this group as well.
1292
+ if (this.transX > maxTransX) {
1293
+ this.transX = maxTransX;
1294
+ } else if (this.transX < minTransX) {
1295
+ this.transX = minTransX;
1296
+ }
1400
1297
 
1401
- this.markersGroup = this.markersGroup || this.canvas.createGroup('jvm-markers-group');
1402
- this.markerLabelsGroup = this.markerLabelsGroup || this.canvas.createGroup('jvm-markers-labels-group');
1298
+ this.canvas.applyTransformParams(this.scale, this.transX, this.transY);
1403
1299
 
1404
- for (var index in markers) {
1405
- markerConfig = markers[index];
1406
- point = this.getMarkerPosition(markerConfig);
1407
- uid = markerConfig.coords.join(':'); // We're checking if recently created marker does already exist
1408
- // If exists we don't need to create it again, so we'll continute
1409
- // Becuase we may have more than one marker.
1300
+ if (this.markers) {
1301
+ this._repositionMarkers();
1302
+ }
1410
1303
 
1411
- if (isRecentlyCreated) {
1412
- if (Object.keys(this.markers).filter(function (i) {
1413
- return _this.markers[i]._uid === uid;
1414
- }).length) {
1415
- continue;
1416
- }
1304
+ if (this.lines) {
1305
+ this._repositionLines();
1306
+ }
1417
1307
 
1418
- index = Object.keys(this.markers).length;
1419
- }
1308
+ this._repositionLabels();
1309
+ }
1420
1310
 
1421
- if (point !== false) {
1422
- marker = new Marker({
1423
- index: index,
1424
- map: this,
1425
- // Merge the `markerStyle` object with the marker config `style` if presented.
1426
- style: merge(this.params.markerStyle, {
1427
- initial: markerConfig.style || {}
1428
- }, true),
1429
- label: this.params.labels && this.params.labels.markers,
1430
- labelsGroup: this.markerLabelsGroup,
1431
- cx: point.x,
1432
- cy: point.y,
1433
- group: this.markersGroup,
1434
- marker: markerConfig,
1435
- isRecentlyCreated: isRecentlyCreated
1436
- }); // Check for marker duplication
1437
- // this is useful when for example: a user clicks a button for creating marker two times
1438
- // so it will remove the old one and the new one will take its place.
1439
-
1440
- if (this.markers[index]) {
1441
- this.removeMarkers([index]);
1442
- }
1311
+ function resize() {
1312
+ var curBaseScale = this.baseScale;
1443
1313
 
1444
- this.markers[index] = {
1445
- _uid: uid,
1446
- config: markerConfig,
1447
- element: marker
1448
- };
1449
- }
1314
+ if (this.width / this.height > this.defaultWidth / this.defaultHeight) {
1315
+ this.baseScale = this.height / this.defaultHeight;
1316
+ this.baseTransX = Math.abs(this.width - this.defaultWidth * this.baseScale) / (2 * this.baseScale);
1317
+ } else {
1318
+ this.baseScale = this.width / this.defaultWidth;
1319
+ this.baseTransY = Math.abs(this.height - this.defaultHeight * this.baseScale) / (2 * this.baseScale);
1450
1320
  }
1321
+
1322
+ this.scale *= this.baseScale / curBaseScale;
1323
+ this.transX *= this.baseScale / curBaseScale;
1324
+ this.transY *= this.baseScale / curBaseScale;
1451
1325
  }
1452
1326
 
1453
- /**
1454
- * ------------------------------------------------------------------------
1455
- * Class Definition
1456
- * ------------------------------------------------------------------------
1457
- */
1327
+ function setScale(scale, anchorX, anchorY, isCentered, animate) {
1328
+ var _this = this;
1458
1329
 
1459
- var Legend = /*#__PURE__*/function () {
1460
- function Legend(options) {
1461
- if (options === void 0) {
1462
- options = {};
1463
- }
1330
+ var zoomStep,
1331
+ interval,
1332
+ i = 0,
1333
+ count = Math.abs(Math.round((scale - this.scale) * 60 / Math.max(scale, this.scale))),
1334
+ scaleStart,
1335
+ scaleDiff,
1336
+ transXStart,
1337
+ transXDiff,
1338
+ transYStart,
1339
+ transYDiff,
1340
+ transX,
1341
+ transY;
1464
1342
 
1465
- this._options = options;
1466
- this._map = this._options.map;
1467
- this._series = this._options.series;
1468
- this._body = createElement('div', 'jvm-legend');
1343
+ if (scale > this.params.zoomMax * this.baseScale) {
1344
+ scale = this.params.zoomMax * this.baseScale;
1345
+ } else if (scale < this.params.zoomMin * this.baseScale) {
1346
+ scale = this.params.zoomMin * this.baseScale;
1347
+ }
1469
1348
 
1470
- if (this._options.cssClass) {
1471
- this._body.setAttribute('class', this._options.cssClass);
1472
- }
1349
+ if (typeof anchorX != 'undefined' && typeof anchorY != 'undefined') {
1350
+ zoomStep = scale / this.scale;
1473
1351
 
1474
- if (options.vertical) {
1475
- this._map.legendVertical.appendChild(this._body);
1352
+ if (isCentered) {
1353
+ transX = anchorX + this.defaultWidth * (this.width / (this.defaultWidth * scale)) / 2;
1354
+ transY = anchorY + this.defaultHeight * (this.height / (this.defaultHeight * scale)) / 2;
1476
1355
  } else {
1477
- this._map.legendHorizontal.appendChild(this._body);
1356
+ transX = this.transX - (zoomStep - 1) / scale * anchorX;
1357
+ transY = this.transY - (zoomStep - 1) / scale * anchorY;
1478
1358
  }
1479
-
1480
- this.render();
1481
1359
  }
1482
1360
 
1483
- var _proto = Legend.prototype;
1361
+ if (animate && count > 0) {
1362
+ scaleStart = this.scale;
1363
+ scaleDiff = (scale - scaleStart) / count;
1364
+ transXStart = this.transX * this.scale;
1365
+ transYStart = this.transY * this.scale;
1366
+ transXDiff = (transX * scale - transXStart) / count;
1367
+ transYDiff = (transY * scale - transYStart) / count;
1368
+ interval = setInterval(function () {
1369
+ i += 1;
1370
+ _this.scale = scaleStart + scaleDiff * i;
1371
+ _this.transX = (transXStart + transXDiff * i) / _this.scale;
1372
+ _this.transY = (transYStart + transYDiff * i) / _this.scale;
1484
1373
 
1485
- _proto.render = function render() {
1486
- var ticks = this._series.scale.getTicks(),
1487
- inner = createElement('div', 'jvm-legend-inner'),
1488
- tick,
1489
- sample,
1490
- label;
1374
+ _this._applyTransform();
1491
1375
 
1492
- this._body.innderHTML = '';
1376
+ if (i == count) {
1377
+ clearInterval(interval);
1493
1378
 
1494
- if (this._options.title) {
1495
- var legendTitle = createElement('div', 'jvm-legend-title', this._options.title);
1379
+ _this._emit(Events.onViewportChange, [_this.scale, _this.transX, _this.transY]);
1380
+ }
1381
+ }, 10);
1382
+ } else {
1383
+ this.transX = transX;
1384
+ this.transY = transY;
1385
+ this.scale = scale;
1496
1386
 
1497
- this._body.appendChild(legendTitle);
1498
- }
1387
+ this._applyTransform();
1499
1388
 
1500
- this._body.appendChild(inner);
1389
+ this._emit(Events.onViewportChange, [this.scale, this.transX, this.transY]);
1390
+ }
1391
+ }
1501
1392
 
1502
- for (var i = 0; i < ticks.length; i++) {
1503
- tick = createElement('div', 'jvm-legend-tick');
1504
- sample = createElement('div', 'jvm-legend-tick-sample');
1393
+ function setFocus(config) {
1394
+ var _this = this;
1505
1395
 
1506
- switch (this._series.config.attribute) {
1507
- case 'fill':
1508
- if (isImageUrl(ticks[i].value)) {
1509
- sample.style.background = "url(" + ticks[i].value + ")";
1510
- } else {
1511
- sample.style.background = ticks[i].value;
1512
- }
1396
+ if (config === void 0) {
1397
+ config = {};
1398
+ }
1513
1399
 
1514
- break;
1400
+ var bbox,
1401
+ codes = [];
1515
1402
 
1516
- case 'stroke':
1517
- sample.style.background = ticks[i].value;
1518
- break;
1403
+ if (config.region) {
1404
+ codes.push(config.region);
1405
+ } else if (config.regions) {
1406
+ codes = config.regions;
1407
+ }
1519
1408
 
1520
- case 'image':
1521
- sample.style.background = "url(" + (typeof ticks[i].value === 'object' ? ticks[i].value.url : ticks[i].value) + ") no-repeat center center";
1522
- sample.style.backgroundSize = 'cover';
1523
- break;
1409
+ if (codes.length) {
1410
+ codes.forEach(function (code) {
1411
+ if (_this.regions[code]) {
1412
+ var itemBbox = _this.regions[code].element.shape.getBBox();
1413
+
1414
+ if (itemBbox) {
1415
+ // Handle the first loop
1416
+ if (typeof bbox == 'undefined') {
1417
+ bbox = itemBbox;
1418
+ } else {
1419
+ // get the old bbox properties plus the current
1420
+ // this kinda incrementing the old values and the new values
1421
+ bbox = {
1422
+ x: Math.min(bbox.x, itemBbox.x),
1423
+ y: Math.min(bbox.y, itemBbox.y),
1424
+ width: Math.max(bbox.x + bbox.width, itemBbox.x + itemBbox.width) - Math.min(bbox.x, itemBbox.x),
1425
+ height: Math.max(bbox.y + bbox.height, itemBbox.y + itemBbox.height) - Math.min(bbox.y, itemBbox.y)
1426
+ };
1427
+ }
1428
+ }
1524
1429
  }
1430
+ });
1431
+ return this._setScale(Math.min(this.width / bbox.width, this.height / bbox.height), -(bbox.x + bbox.width / 2), -(bbox.y + bbox.height / 2), true, config.animate);
1432
+ } else if (config.coords) {
1433
+ var point = this.coordsToPoint(config.coords[0], config.coords[1]);
1434
+ var x = this.transX - point.x / this.scale;
1435
+ var y = this.transY - point.y / this.scale;
1436
+ return this._setScale(config.scale * this.baseScale, x, y, true, config.animate);
1437
+ }
1438
+ }
1525
1439
 
1526
- tick.appendChild(sample);
1527
- label = ticks[i].label;
1440
+ function updateSize() {
1441
+ this.width = this.container.offsetWidth;
1442
+ this.height = this.container.offsetHeight;
1528
1443
 
1529
- if (this._options.labelRender) {
1530
- label = this._options.labelRender(label);
1531
- }
1444
+ this._resize();
1532
1445
 
1533
- var tickText = createElement('div', 'jvm-legend-tick-text', label);
1534
- tick.appendChild(tickText);
1535
- inner.appendChild(tick);
1536
- }
1537
- };
1446
+ this.canvas.setSize(this.width, this.height);
1538
1447
 
1539
- return Legend;
1540
- }();
1448
+ this._applyTransform();
1449
+ }
1541
1450
 
1542
1451
  /**
1543
1452
  * ------------------------------------------------------------------------
1544
- * Class Definition
1453
+ * Object
1545
1454
  * ------------------------------------------------------------------------
1546
1455
  */
1547
- var OrdinalScale = /*#__PURE__*/function () {
1548
- function OrdinalScale(scale) {
1549
- this._scale = scale;
1550
- }
1551
-
1552
- var _proto = OrdinalScale.prototype;
1553
-
1554
- _proto.getValue = function getValue(value) {
1555
- return this._scale[value];
1556
- };
1557
-
1558
- _proto.getTicks = function getTicks() {
1559
- var ticks = [];
1560
-
1561
- for (var key in this._scale) {
1562
- ticks.push({
1563
- label: key,
1564
- value: this._scale[key]
1565
- });
1566
- }
1456
+ var Proj = {
1457
+ /* sgn(n){
1458
+ if (n > 0) {
1459
+ return 1;
1460
+ } else if (n < 0) {
1461
+ return -1;
1462
+ } else {
1463
+ return n;
1464
+ }
1465
+ }, */
1466
+ mill: function mill(lat, lng, c) {
1467
+ return {
1468
+ x: this.radius * (lng - c) * this.radDeg,
1469
+ y: -this.radius * Math.log(Math.tan((45 + 0.4 * lat) * this.radDeg)) / 0.8
1470
+ };
1471
+ },
1567
1472
 
1568
- return ticks;
1569
- };
1473
+ /* mill_inv(x, y, c) {
1474
+ return {
1475
+ lat: (2.5 * Math.atan(Math.exp(0.8 * y / this.radius)) - 5 * Math.PI / 8) * this.degRad,
1476
+ lng: (c * this.radDeg + x / this.radius) * this.degRad
1477
+ };
1478
+ }, */
1479
+ merc: function merc(lat, lng, c) {
1480
+ return {
1481
+ x: this.radius * (lng - c) * this.radDeg,
1482
+ y: -this.radius * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360))
1483
+ };
1484
+ },
1570
1485
 
1571
- return OrdinalScale;
1572
- }();
1486
+ /* merc_inv(x, y, c) {
1487
+ return {
1488
+ lat: (2 * Math.atan(Math.exp(y / this.radius)) - Math.PI / 2) * this.degRad,
1489
+ lng: (c * this.radDeg + x / this.radius) * this.degRad
1490
+ };
1491
+ }, */
1492
+ aea: function aea(lat, lng, c) {
1493
+ var fi0 = 0,
1494
+ lambda0 = c * this.radDeg,
1495
+ fi1 = 29.5 * this.radDeg,
1496
+ fi2 = 45.5 * this.radDeg,
1497
+ fi = lat * this.radDeg,
1498
+ lambda = lng * this.radDeg,
1499
+ n = (Math.sin(fi1) + Math.sin(fi2)) / 2,
1500
+ C = Math.cos(fi1) * Math.cos(fi1) + 2 * n * Math.sin(fi1),
1501
+ theta = n * (lambda - lambda0),
1502
+ ro = Math.sqrt(C - 2 * n * Math.sin(fi)) / n,
1503
+ ro0 = Math.sqrt(C - 2 * n * Math.sin(fi0)) / n;
1504
+ return {
1505
+ x: ro * Math.sin(theta) * this.radius,
1506
+ y: -(ro0 - ro * Math.cos(theta)) * this.radius
1507
+ };
1508
+ },
1573
1509
 
1574
- /**
1575
- * ------------------------------------------------------------------------
1576
- * Class Definition
1577
- * ------------------------------------------------------------------------
1578
- */
1510
+ /* aea_inv(xCoord, yCoord, c) {
1511
+ var x = xCoord / this.radius,
1512
+ y = yCoord / this.radius,
1513
+ fi0 = 0,
1514
+ lambda0 = c * this.radDeg,
1515
+ fi1 = 29.5 * this.radDeg,
1516
+ fi2 = 45.5 * this.radDeg,
1517
+ n = (Math.sin(fi1)+Math.sin(fi2)) / 2,
1518
+ C = Math.cos(fi1)*Math.cos(fi1)+2*n*Math.sin(fi1),
1519
+ ro0 = Math.sqrt(C-2*n*Math.sin(fi0))/n,
1520
+ ro = Math.sqrt(x*x+(ro0-y)*(ro0-y)),
1521
+ theta = Math.atan( x / (ro0 - y) );
1522
+ return {
1523
+ lat: (Math.asin((C - ro * ro * n * n) / (2 * n))) * this.degRad,
1524
+ lng: (lambda0 + theta / n) * this.degRad
1525
+ };
1526
+ }, */
1527
+ lcc: function lcc(lat, lng, c) {
1528
+ var fi0 = 0,
1529
+ lambda0 = c * this.radDeg,
1530
+ lambda = lng * this.radDeg,
1531
+ fi1 = 33 * this.radDeg,
1532
+ fi2 = 45 * this.radDeg,
1533
+ fi = lat * this.radDeg,
1534
+ n = Math.log(Math.cos(fi1) * (1 / Math.cos(fi2))) / Math.log(Math.tan(Math.PI / 4 + fi2 / 2) * (1 / Math.tan(Math.PI / 4 + fi1 / 2))),
1535
+ F = Math.cos(fi1) * Math.pow(Math.tan(Math.PI / 4 + fi1 / 2), n) / n,
1536
+ ro = F * Math.pow(1 / Math.tan(Math.PI / 4 + fi / 2), n),
1537
+ ro0 = F * Math.pow(1 / Math.tan(Math.PI / 4 + fi0 / 2), n);
1538
+ return {
1539
+ x: ro * Math.sin(n * (lambda - lambda0)) * this.radius,
1540
+ y: -(ro0 - ro * Math.cos(n * (lambda - lambda0))) * this.radius
1541
+ };
1542
+ }
1543
+ /* lcc_inv(xCoord, yCoord, c) {
1544
+ var x = xCoord / this.radius,
1545
+ y = yCoord / this.radius,
1546
+ fi0 = 0,
1547
+ lambda0 = c * this.radDeg,
1548
+ fi1 = 33 * this.radDeg,
1549
+ fi2 = 45 * this.radDeg,
1550
+ n = Math.log( Math.cos(fi1) * (1 / Math.cos(fi2)) ) / Math.log( Math.tan( Math.PI / 4 + fi2 / 2) * (1 / Math.tan( Math.PI / 4 + fi1 / 2) ) ),
1551
+ F = ( Math.cos(fi1) * Math.pow( Math.tan( Math.PI / 4 + fi1 / 2 ), n ) ) / n,
1552
+ ro0 = F * Math.pow( 1 / Math.tan( Math.PI / 4 + fi0 / 2 ), n ),
1553
+ ro = this.sgn(n) * Math.sqrt(x*x+(ro0-y)*(ro0-y)),
1554
+ theta = Math.atan( x / (ro0 - y) );
1555
+ return {
1556
+ lat: (2 * Math.atan(Math.pow(F/ro, 1/n)) - Math.PI / 2) * this.degRad,
1557
+ lng: (lambda0 + theta / n) * this.degRad
1558
+ };
1559
+ } */
1579
1560
 
1580
- var Series = /*#__PURE__*/function () {
1581
- function Series(config, elements, map) {
1582
- if (config === void 0) {
1583
- config = {};
1584
- }
1561
+ };
1562
+ Proj.degRad = 180 / Math.PI;
1563
+ Proj.radDeg = Math.PI / 180;
1564
+ Proj.radius = 6381372;
1585
1565
 
1586
- // Private
1587
- this._map = map;
1588
- this._elements = elements; // Could be markers or regions
1566
+ function coordsToPoint(lat, lng) {
1567
+ var point,
1568
+ proj = Map.maps[this.params.map].projection,
1569
+ centralMeridian = proj.centralMeridian,
1570
+ inset,
1571
+ bbox;
1572
+ point = Proj[proj.type](lat, lng, centralMeridian);
1573
+ inset = this.getInsetForPoint(point.x, point.y);
1589
1574
 
1590
- this._values = config.values || {}; // Protected
1575
+ if (inset) {
1576
+ bbox = inset.bbox;
1577
+ point.x = (point.x - bbox[0].x) / (bbox[1].x - bbox[0].x) * inset.width * this.scale;
1578
+ point.y = (point.y - bbox[0].y) / (bbox[1].y - bbox[0].y) * inset.height * this.scale;
1579
+ return {
1580
+ x: point.x + this.transX * this.scale + inset.left * this.scale,
1581
+ y: point.y + this.transY * this.scale + inset.top * this.scale
1582
+ };
1583
+ }
1591
1584
 
1592
- this.config = config;
1593
- this.config.attribute = config.attribute || 'fill'; // Set initial attributes
1585
+ return false;
1586
+ }
1594
1587
 
1595
- if (config.attributes) {
1596
- this.setAttributes(config.attributes);
1597
- }
1588
+ function getInsetForPoint(x, y) {
1589
+ var index,
1590
+ bbox,
1591
+ insets = Map.maps[this.params.map].insets;
1598
1592
 
1599
- if (typeof config.scale === 'object') {
1600
- this.scale = new OrdinalScale(config.scale);
1601
- }
1593
+ for (index = 0; index < insets.length; index++) {
1594
+ bbox = insets[index].bbox;
1602
1595
 
1603
- if (this.config.legend) {
1604
- this.legend = new Legend(merge({
1605
- map: this._map,
1606
- series: this
1607
- }, this.config.legend));
1596
+ if (x > bbox[0].x && x < bbox[1].x && y > bbox[0].y && y < bbox[1].y) {
1597
+ return insets[index];
1608
1598
  }
1609
-
1610
- this.setValues(this._values);
1611
1599
  }
1600
+ }
1612
1601
 
1613
- var _proto = Series.prototype;
1614
-
1615
- _proto.setValues = function setValues(values) {
1616
- var attrs = {};
1602
+ function getMarkerPosition(_ref) {
1603
+ var coords = _ref.coords;
1617
1604
 
1618
- for (var key in values) {
1619
- if (values[key]) {
1620
- attrs[key] = this.scale.getValue(values[key]);
1621
- }
1622
- }
1605
+ if (Map.maps[this.params.map].projection) {
1606
+ return this.coordsToPoint.apply(this, coords);
1607
+ }
1623
1608
 
1624
- this.setAttributes(attrs);
1609
+ return {
1610
+ x: coords[0] * this.scale + this.transX * this.scale,
1611
+ y: coords[1] * this.scale + this.transY * this.scale
1625
1612
  };
1613
+ }
1626
1614
 
1627
- _proto.setAttributes = function setAttributes(attrs) {
1628
- for (var code in attrs) {
1629
- if (this._elements[code]) {
1630
- this._elements[code].element.setStyle(this.config.attribute, attrs[code]);
1631
- }
1632
- }
1633
- };
1615
+ function repositionLines() {
1616
+ var point1 = false,
1617
+ point2 = false;
1618
+
1619
+ for (var index in this.lines) {
1620
+ for (var mindex in this.markers) {
1621
+ var marker = this.markers[mindex]; // console.log(this.lines[index], index);
1634
1622
 
1635
- _proto.clear = function clear() {
1636
- var key,
1637
- attrs = {};
1623
+ if (marker.config.name === this.lines[index].config.from) {
1624
+ point1 = this.getMarkerPosition(marker.config);
1625
+ }
1638
1626
 
1639
- for (key in this._values) {
1640
- if (this._elements[key]) {
1641
- attrs[key] = this._elements[key].element.shape.style.initial[this.config.attribute];
1627
+ if (marker.config.name === this.lines[index].config.to) {
1628
+ point2 = this.getMarkerPosition(marker.config);
1642
1629
  }
1643
1630
  }
1644
1631
 
1645
- this.setAttributes(attrs);
1646
- this._values = {};
1647
- };
1632
+ if (point1 !== false && point2 !== false) {
1633
+ this.lines[index].setStyle({
1634
+ x1: point1.x,
1635
+ y1: point1.y,
1636
+ x2: point2.x,
1637
+ y2: point2.y
1638
+ });
1639
+ }
1640
+ }
1641
+ }
1648
1642
 
1649
- return Series;
1650
- }();
1643
+ function repositionMarkers() {
1644
+ var point;
1651
1645
 
1652
- function createSeries() {
1653
- this.series = {
1654
- markers: [],
1655
- regions: []
1656
- };
1646
+ for (var index in this.markers) {
1647
+ point = this.getMarkerPosition(this.markers[index].config);
1657
1648
 
1658
- for (var key in this.params.series) {
1659
- for (var i = 0; i < this.params.series[key].length; i++) {
1660
- this.series[key][i] = new Series(this.params.series[key][i], this[key], this);
1649
+ if (point !== false) {
1650
+ this.markers[index].element.setStyle({
1651
+ cx: point.x,
1652
+ cy: point.y
1653
+ });
1661
1654
  }
1662
1655
  }
1663
1656
  }
1664
1657
 
1665
- function applyTransform() {
1666
- var maxTransX, maxTransY, minTransX, minTransY;
1667
-
1668
- if (this.defaultWidth * this.scale <= this.width) {
1669
- maxTransX = (this.width - this.defaultWidth * this.scale) / (2 * this.scale);
1670
- minTransX = (this.width - this.defaultWidth * this.scale) / (2 * this.scale);
1671
- } else {
1672
- maxTransX = 0;
1673
- minTransX = (this.width - this.defaultWidth * this.scale) / this.scale;
1674
- }
1658
+ function repositionLabels() {
1659
+ var labels = this.params.labels;
1675
1660
 
1676
- if (this.defaultHeight * this.scale <= this.height) {
1677
- maxTransY = (this.height - this.defaultHeight * this.scale) / (2 * this.scale);
1678
- minTransY = (this.height - this.defaultHeight * this.scale) / (2 * this.scale);
1679
- } else {
1680
- maxTransY = 0;
1681
- minTransY = (this.height - this.defaultHeight * this.scale) / this.scale;
1682
- }
1661
+ if (!labels) {
1662
+ return;
1663
+ } // Regions labels
1683
1664
 
1684
- if (this.transY > maxTransY) {
1685
- this.transY = maxTransY;
1686
- } else if (this.transY < minTransY) {
1687
- this.transY = minTransY;
1688
- }
1689
1665
 
1690
- if (this.transX > maxTransX) {
1691
- this.transX = maxTransX;
1692
- } else if (this.transX < minTransX) {
1693
- this.transX = minTransX;
1694
- }
1666
+ if (labels.regions) {
1667
+ for (var key in this.regions) {
1668
+ this.regions[key].element.updateLabelPosition();
1669
+ }
1670
+ } // Markers labels
1695
1671
 
1696
- this.canvas.applyTransformParams(this.scale, this.transX, this.transY);
1697
1672
 
1698
- if (this.markers) {
1699
- this._repositionMarkers();
1673
+ if (labels.markers) {
1674
+ for (var _key in this.markers) {
1675
+ this.markers[_key].element.updateLabelPosition();
1676
+ }
1700
1677
  }
1678
+ }
1701
1679
 
1702
- if (this.lines) {
1703
- this._repositionLines();
1680
+ var core = {
1681
+ _setupContainerEvents: setupContainerEvents,
1682
+ _setupElementEvents: setupElementEvents,
1683
+ _setupZoomButtons: setupZoomButtons,
1684
+ _setupContainerTouchEvents: setupContainerTouchEvents,
1685
+ _createRegions: createRegions,
1686
+ _createLines: createLines,
1687
+ _createMarkers: createMarkers,
1688
+ _createSeries: createSeries,
1689
+ _applyTransform: applyTransform,
1690
+ _resize: resize,
1691
+ _setScale: setScale,
1692
+ setFocus: setFocus,
1693
+ updateSize: updateSize,
1694
+ coordsToPoint: coordsToPoint,
1695
+ getInsetForPoint: getInsetForPoint,
1696
+ getMarkerPosition: getMarkerPosition,
1697
+ _repositionLines: repositionLines,
1698
+ _repositionMarkers: repositionMarkers,
1699
+ _repositionLabels: repositionLabels
1700
+ };
1701
+
1702
+ var Defaults = {
1703
+ map: 'world',
1704
+ backgroundColor: 'transparent',
1705
+ draggable: true,
1706
+ zoomButtons: true,
1707
+ zoomOnScroll: true,
1708
+ zoomOnScrollSpeed: 3,
1709
+ zoomMax: 12,
1710
+ zoomMin: 1,
1711
+ zoomAnimate: true,
1712
+ showTooltip: true,
1713
+ zoomStep: 1.5,
1714
+ bindTouchEvents: true,
1715
+ // Line options
1716
+ lineStyle: {
1717
+ stroke: '#808080',
1718
+ strokeWidth: 1,
1719
+ strokeLinecap: 'round'
1720
+ },
1721
+ // Marker options
1722
+ markersSelectable: false,
1723
+ markersSelectableOne: false,
1724
+ markerStyle: {
1725
+ initial: {
1726
+ r: 7,
1727
+ fill: '#374151',
1728
+ fillOpacity: 1,
1729
+ stroke: '#FFF',
1730
+ strokeWidth: 5,
1731
+ strokeOpacity: .5
1732
+ },
1733
+ hover: {
1734
+ fill: '#3cc0ff',
1735
+ cursor: 'pointer'
1736
+ },
1737
+ selected: {
1738
+ fill: 'blue'
1739
+ },
1740
+ selectedHover: {}
1741
+ },
1742
+ markerLabelStyle: {
1743
+ initial: {
1744
+ fontFamily: 'Verdana',
1745
+ fontSize: 12,
1746
+ fontWeight: 500,
1747
+ cursor: 'default',
1748
+ fill: '#374151'
1749
+ },
1750
+ hover: {
1751
+ cursor: 'pointer'
1752
+ },
1753
+ selected: {},
1754
+ selectedHover: {}
1755
+ },
1756
+ // Region options
1757
+ regionsSelectable: false,
1758
+ regionsSelectableOne: false,
1759
+ regionStyle: {
1760
+ initial: {
1761
+ fill: '#dee2e8',
1762
+ fillOpacity: 1,
1763
+ stroke: 'none',
1764
+ strokeWidth: 0
1765
+ },
1766
+ hover: {
1767
+ fillOpacity: .7,
1768
+ cursor: 'pointer'
1769
+ },
1770
+ selected: {
1771
+ fill: '#9ca3af'
1772
+ },
1773
+ selectedHover: {}
1774
+ },
1775
+ regionLabelStyle: {
1776
+ initial: {
1777
+ fontFamily: 'Verdana',
1778
+ fontSize: '12',
1779
+ fontWeight: 'bold',
1780
+ cursor: 'default',
1781
+ fill: '#35373e'
1782
+ },
1783
+ hover: {
1784
+ cursor: 'pointer'
1785
+ }
1704
1786
  }
1787
+ };
1705
1788
 
1706
- this._repositionLabels();
1707
- }
1789
+ /**
1790
+ * ------------------------------------------------------------------------
1791
+ * Class Definition
1792
+ * ------------------------------------------------------------------------
1793
+ */
1708
1794
 
1709
- function resize() {
1710
- var curBaseScale = this.baseScale;
1795
+ var SVGElement = /*#__PURE__*/function () {
1796
+ function SVGElement(name, config) {
1797
+ this.node = this._createElement(name);
1711
1798
 
1712
- if (this.width / this.height > this.defaultWidth / this.defaultHeight) {
1713
- this.baseScale = this.height / this.defaultHeight;
1714
- this.baseTransX = Math.abs(this.width - this.defaultWidth * this.baseScale) / (2 * this.baseScale);
1715
- } else {
1716
- this.baseScale = this.width / this.defaultWidth;
1717
- this.baseTransY = Math.abs(this.height - this.defaultHeight * this.baseScale) / (2 * this.baseScale);
1718
- }
1799
+ if (config) {
1800
+ this.set(config);
1801
+ }
1802
+ } // Create new SVG element `svg`, `g`, `path`, `line`, `circle`, `image`, etc.
1803
+ // https://developer.mozilla.org/en-US/docs/Web/API/Document/createElementNS#important_namespace_uris
1719
1804
 
1720
- this.scale *= this.baseScale / curBaseScale;
1721
- this.transX *= this.baseScale / curBaseScale;
1722
- this.transY *= this.baseScale / curBaseScale;
1723
- }
1724
1805
 
1725
- function setScale(scale, anchorX, anchorY, isCentered, animate) {
1726
- var _this = this;
1806
+ var _proto = SVGElement.prototype;
1727
1807
 
1728
- var zoomStep,
1729
- interval,
1730
- i = 0,
1731
- count = Math.abs(Math.round((scale - this.scale) * 60 / Math.max(scale, this.scale))),
1732
- scaleStart,
1733
- scaleDiff,
1734
- transXStart,
1735
- transXDiff,
1736
- transYStart,
1737
- transYDiff,
1738
- transX,
1739
- transY;
1808
+ _proto._createElement = function _createElement(tagName) {
1809
+ return document.createElementNS('http://www.w3.org/2000/svg', tagName);
1810
+ };
1740
1811
 
1741
- if (scale > this.params.zoomMax * this.baseScale) {
1742
- scale = this.params.zoomMax * this.baseScale;
1743
- } else if (scale < this.params.zoomMin * this.baseScale) {
1744
- scale = this.params.zoomMin * this.baseScale;
1745
- }
1812
+ _proto.addClass = function addClass(className) {
1813
+ this.node.setAttribute('class', className);
1814
+ };
1746
1815
 
1747
- if (typeof anchorX != 'undefined' && typeof anchorY != 'undefined') {
1748
- zoomStep = scale / this.scale;
1816
+ _proto.getBBox = function getBBox() {
1817
+ return this.node.getBBox();
1818
+ } // Apply attributes on the current node element
1819
+ ;
1749
1820
 
1750
- if (isCentered) {
1751
- transX = anchorX + this.defaultWidth * (this.width / (this.defaultWidth * scale)) / 2;
1752
- transY = anchorY + this.defaultHeight * (this.height / (this.defaultHeight * scale)) / 2;
1821
+ _proto.set = function set(property, value) {
1822
+ if (typeof property === 'object') {
1823
+ for (var attr in property) {
1824
+ this.applyAttr(attr, property[attr]);
1825
+ }
1753
1826
  } else {
1754
- transX = this.transX - (zoomStep - 1) / scale * anchorX;
1755
- transY = this.transY - (zoomStep - 1) / scale * anchorY;
1827
+ this.applyAttr(property, value);
1756
1828
  }
1757
- }
1758
-
1759
- if (animate && count > 0) {
1760
- scaleStart = this.scale;
1761
- scaleDiff = (scale - scaleStart) / count;
1762
- transXStart = this.transX * this.scale;
1763
- transYStart = this.transY * this.scale;
1764
- transXDiff = (transX * scale - transXStart) / count;
1765
- transYDiff = (transY * scale - transYStart) / count;
1766
- interval = setInterval(function () {
1767
- i += 1;
1768
- _this.scale = scaleStart + scaleDiff * i;
1769
- _this.transX = (transXStart + transXDiff * i) / _this.scale;
1770
- _this.transY = (transYStart + transYDiff * i) / _this.scale;
1829
+ };
1771
1830
 
1772
- _this._applyTransform();
1831
+ _proto.get = function get(property) {
1832
+ return this.style.initial[property];
1833
+ };
1773
1834
 
1774
- if (i == count) {
1775
- clearInterval(interval);
1835
+ _proto.applyAttr = function applyAttr(property, value) {
1836
+ this.node.setAttribute(hyphenate(property), value);
1837
+ };
1776
1838
 
1777
- _this._emit(Events.onViewportChange, [_this.scale, _this.transX, _this.transY]);
1778
- }
1779
- }, 10);
1780
- } else {
1781
- this.transX = transX;
1782
- this.transY = transY;
1783
- this.scale = scale;
1839
+ _proto.remove = function remove() {
1840
+ removeElement(this.node);
1841
+ };
1784
1842
 
1785
- this._applyTransform();
1843
+ return SVGElement;
1844
+ }();
1786
1845
 
1787
- this._emit(Events.onViewportChange, [this.scale, this.transX, this.transY]);
1788
- }
1789
- }
1846
+ /**
1847
+ * ------------------------------------------------------------------------
1848
+ * Class Definition
1849
+ * ------------------------------------------------------------------------
1850
+ */
1790
1851
 
1791
- function setFocus(config) {
1792
- var _this = this;
1852
+ var SVGShapeElement = /*#__PURE__*/function (_SVGElement) {
1853
+ _inheritsLoose(SVGShapeElement, _SVGElement);
1793
1854
 
1794
- if (config === void 0) {
1795
- config = {};
1796
- }
1855
+ function SVGShapeElement(name, config, style) {
1856
+ var _this;
1797
1857
 
1798
- var bbox,
1799
- codes = [];
1858
+ if (style === void 0) {
1859
+ style = {};
1860
+ }
1800
1861
 
1801
- if (config.region) {
1802
- codes.push(config.region);
1803
- } else if (config.regions) {
1804
- codes = config.regions;
1805
- }
1862
+ _this = _SVGElement.call(this, name, config) || this;
1863
+ _this.isHovered = false;
1864
+ _this.isSelected = false;
1865
+ _this.style = style;
1866
+ _this.style.current = {};
1806
1867
 
1807
- if (codes.length) {
1808
- codes.forEach(function (code) {
1809
- if (_this.regions[code]) {
1810
- var itemBbox = _this.regions[code].element.shape.getBBox();
1868
+ _this.updateStyle();
1811
1869
 
1812
- if (itemBbox) {
1813
- // Handle the first loop
1814
- if (typeof bbox == 'undefined') {
1815
- bbox = itemBbox;
1816
- } else {
1817
- // get the old bbox properties plus the current
1818
- // this kinda incrementing the old values and the new values
1819
- bbox = {
1820
- x: Math.min(bbox.x, itemBbox.x),
1821
- y: Math.min(bbox.y, itemBbox.y),
1822
- width: Math.max(bbox.x + bbox.width, itemBbox.x + itemBbox.width) - Math.min(bbox.x, itemBbox.x),
1823
- height: Math.max(bbox.y + bbox.height, itemBbox.y + itemBbox.height) - Math.min(bbox.y, itemBbox.y)
1824
- };
1825
- }
1826
- }
1827
- }
1828
- });
1829
- return this._setScale(Math.min(this.width / bbox.width, this.height / bbox.height), -(bbox.x + bbox.width / 2), -(bbox.y + bbox.height / 2), true, config.animate);
1830
- } else if (config.coords) {
1831
- var point = this.coordsToPoint(config.coords[0], config.coords[1]);
1832
- var x = this.transX - point.x / this.scale;
1833
- var y = this.transY - point.y / this.scale;
1834
- return this._setScale(config.scale * this.baseScale, x, y, true, config.animate);
1870
+ return _this;
1835
1871
  }
1836
- }
1837
1872
 
1838
- function updateSize() {
1839
- this.width = this.container.offsetWidth;
1840
- this.height = this.container.offsetHeight;
1873
+ var _proto = SVGShapeElement.prototype;
1841
1874
 
1842
- this._resize();
1875
+ _proto.setStyle = function setStyle(property, value) {
1876
+ if (typeof property === 'object') {
1877
+ merge(this.style.current, property);
1878
+ } else {
1879
+ var _merge;
1843
1880
 
1844
- this.canvas.setSize(this.width, this.height);
1881
+ merge(this.style.current, (_merge = {}, _merge[property] = value, _merge));
1882
+ }
1845
1883
 
1846
- this._applyTransform();
1847
- }
1884
+ this.updateStyle();
1885
+ };
1848
1886
 
1849
- /**
1850
- * ------------------------------------------------------------------------
1851
- * Object
1852
- * ------------------------------------------------------------------------
1853
- */
1854
- var Proj = {
1855
- /* sgn(n){
1856
- if (n > 0) {
1857
- return 1;
1858
- } else if (n < 0) {
1859
- return -1;
1860
- } else {
1861
- return n;
1862
- }
1863
- }, */
1864
- mill: function mill(lat, lng, c) {
1865
- return {
1866
- x: this.radius * (lng - c) * this.radDeg,
1867
- y: -this.radius * Math.log(Math.tan((45 + 0.4 * lat) * this.radDeg)) / 0.8
1868
- };
1869
- },
1887
+ _proto.updateStyle = function updateStyle() {
1888
+ var attrs = {};
1889
+ merge(attrs, this.style.initial);
1890
+ merge(attrs, this.style.current);
1870
1891
 
1871
- /* mill_inv(x, y, c) {
1872
- return {
1873
- lat: (2.5 * Math.atan(Math.exp(0.8 * y / this.radius)) - 5 * Math.PI / 8) * this.degRad,
1874
- lng: (c * this.radDeg + x / this.radius) * this.degRad
1875
- };
1876
- }, */
1877
- merc: function merc(lat, lng, c) {
1878
- return {
1879
- x: this.radius * (lng - c) * this.radDeg,
1880
- y: -this.radius * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360))
1881
- };
1882
- },
1892
+ if (this.isHovered) {
1893
+ merge(attrs, this.style.hover);
1894
+ }
1883
1895
 
1884
- /* merc_inv(x, y, c) {
1885
- return {
1886
- lat: (2 * Math.atan(Math.exp(y / this.radius)) - Math.PI / 2) * this.degRad,
1887
- lng: (c * this.radDeg + x / this.radius) * this.degRad
1888
- };
1889
- }, */
1890
- aea: function aea(lat, lng, c) {
1891
- var fi0 = 0,
1892
- lambda0 = c * this.radDeg,
1893
- fi1 = 29.5 * this.radDeg,
1894
- fi2 = 45.5 * this.radDeg,
1895
- fi = lat * this.radDeg,
1896
- lambda = lng * this.radDeg,
1897
- n = (Math.sin(fi1) + Math.sin(fi2)) / 2,
1898
- C = Math.cos(fi1) * Math.cos(fi1) + 2 * n * Math.sin(fi1),
1899
- theta = n * (lambda - lambda0),
1900
- ro = Math.sqrt(C - 2 * n * Math.sin(fi)) / n,
1901
- ro0 = Math.sqrt(C - 2 * n * Math.sin(fi0)) / n;
1902
- return {
1903
- x: ro * Math.sin(theta) * this.radius,
1904
- y: -(ro0 - ro * Math.cos(theta)) * this.radius
1905
- };
1906
- },
1896
+ if (this.isSelected) {
1897
+ merge(attrs, this.style.selected);
1907
1898
 
1908
- /* aea_inv(xCoord, yCoord, c) {
1909
- var x = xCoord / this.radius,
1910
- y = yCoord / this.radius,
1911
- fi0 = 0,
1912
- lambda0 = c * this.radDeg,
1913
- fi1 = 29.5 * this.radDeg,
1914
- fi2 = 45.5 * this.radDeg,
1915
- n = (Math.sin(fi1)+Math.sin(fi2)) / 2,
1916
- C = Math.cos(fi1)*Math.cos(fi1)+2*n*Math.sin(fi1),
1917
- ro0 = Math.sqrt(C-2*n*Math.sin(fi0))/n,
1918
- ro = Math.sqrt(x*x+(ro0-y)*(ro0-y)),
1919
- theta = Math.atan( x / (ro0 - y) );
1920
- return {
1921
- lat: (Math.asin((C - ro * ro * n * n) / (2 * n))) * this.degRad,
1922
- lng: (lambda0 + theta / n) * this.degRad
1923
- };
1924
- }, */
1925
- lcc: function lcc(lat, lng, c) {
1926
- var fi0 = 0,
1927
- lambda0 = c * this.radDeg,
1928
- lambda = lng * this.radDeg,
1929
- fi1 = 33 * this.radDeg,
1930
- fi2 = 45 * this.radDeg,
1931
- fi = lat * this.radDeg,
1932
- n = Math.log(Math.cos(fi1) * (1 / Math.cos(fi2))) / Math.log(Math.tan(Math.PI / 4 + fi2 / 2) * (1 / Math.tan(Math.PI / 4 + fi1 / 2))),
1933
- F = Math.cos(fi1) * Math.pow(Math.tan(Math.PI / 4 + fi1 / 2), n) / n,
1934
- ro = F * Math.pow(1 / Math.tan(Math.PI / 4 + fi / 2), n),
1935
- ro0 = F * Math.pow(1 / Math.tan(Math.PI / 4 + fi0 / 2), n);
1936
- return {
1937
- x: ro * Math.sin(n * (lambda - lambda0)) * this.radius,
1938
- y: -(ro0 - ro * Math.cos(n * (lambda - lambda0))) * this.radius
1939
- };
1940
- }
1941
- /* lcc_inv(xCoord, yCoord, c) {
1942
- var x = xCoord / this.radius,
1943
- y = yCoord / this.radius,
1944
- fi0 = 0,
1945
- lambda0 = c * this.radDeg,
1946
- fi1 = 33 * this.radDeg,
1947
- fi2 = 45 * this.radDeg,
1948
- n = Math.log( Math.cos(fi1) * (1 / Math.cos(fi2)) ) / Math.log( Math.tan( Math.PI / 4 + fi2 / 2) * (1 / Math.tan( Math.PI / 4 + fi1 / 2) ) ),
1949
- F = ( Math.cos(fi1) * Math.pow( Math.tan( Math.PI / 4 + fi1 / 2 ), n ) ) / n,
1950
- ro0 = F * Math.pow( 1 / Math.tan( Math.PI / 4 + fi0 / 2 ), n ),
1951
- ro = this.sgn(n) * Math.sqrt(x*x+(ro0-y)*(ro0-y)),
1952
- theta = Math.atan( x / (ro0 - y) );
1953
- return {
1954
- lat: (2 * Math.atan(Math.pow(F/ro, 1/n)) - Math.PI / 2) * this.degRad,
1955
- lng: (lambda0 + theta / n) * this.degRad
1956
- };
1957
- } */
1899
+ if (this.isHovered) {
1900
+ merge(attrs, this.style.selectedHover);
1901
+ }
1902
+ }
1958
1903
 
1959
- };
1960
- Proj.degRad = 180 / Math.PI;
1961
- Proj.radDeg = Math.PI / 180;
1962
- Proj.radius = 6381372;
1904
+ this.set(attrs);
1905
+ };
1906
+
1907
+ return SVGShapeElement;
1908
+ }(SVGElement);
1963
1909
 
1964
- function coordsToPoint(lat, lng) {
1965
- var point,
1966
- proj = Map.maps[this.params.map].projection,
1967
- centralMeridian = proj.centralMeridian,
1968
- inset,
1969
- bbox;
1970
- point = Proj[proj.type](lat, lng, centralMeridian);
1971
- inset = this.getInsetForPoint(point.x, point.y);
1910
+ /**
1911
+ * ------------------------------------------------------------------------
1912
+ * Class Definition
1913
+ * ------------------------------------------------------------------------
1914
+ */
1972
1915
 
1973
- if (inset) {
1974
- bbox = inset.bbox;
1975
- point.x = (point.x - bbox[0].x) / (bbox[1].x - bbox[0].x) * inset.width * this.scale;
1976
- point.y = (point.y - bbox[0].y) / (bbox[1].y - bbox[0].y) * inset.height * this.scale;
1977
- return {
1978
- x: point.x + this.transX * this.scale + inset.left * this.scale,
1979
- y: point.y + this.transY * this.scale + inset.top * this.scale
1980
- };
1916
+ var SVGTextElement = /*#__PURE__*/function (_SVGShapeElement) {
1917
+ _inheritsLoose(SVGTextElement, _SVGShapeElement);
1918
+
1919
+ function SVGTextElement(config, style) {
1920
+ return _SVGShapeElement.call(this, 'text', config, style) || this;
1981
1921
  }
1982
1922
 
1983
- return false;
1984
- }
1923
+ var _proto = SVGTextElement.prototype;
1985
1924
 
1986
- function getInsetForPoint(x, y) {
1987
- var index,
1988
- bbox,
1989
- insets = Map.maps[this.params.map].insets;
1925
+ _proto.applyAttr = function applyAttr(attr, value) {
1926
+ attr === 'text' ? this.node.textContent = value : _SVGShapeElement.prototype.applyAttr.call(this, attr, value);
1927
+ };
1990
1928
 
1991
- for (index = 0; index < insets.length; index++) {
1992
- bbox = insets[index].bbox;
1929
+ return SVGTextElement;
1930
+ }(SVGShapeElement);
1993
1931
 
1994
- if (x > bbox[0].x && x < bbox[1].x && y > bbox[0].y && y < bbox[1].y) {
1995
- return insets[index];
1996
- }
1997
- }
1998
- }
1932
+ /**
1933
+ * ------------------------------------------------------------------------
1934
+ * Class Definition
1935
+ * ------------------------------------------------------------------------
1936
+ */
1999
1937
 
2000
- function getMarkerPosition(_ref) {
2001
- var coords = _ref.coords;
1938
+ var SVGImageElement = /*#__PURE__*/function (_SVGShapeElement) {
1939
+ _inheritsLoose(SVGImageElement, _SVGShapeElement);
2002
1940
 
2003
- if (Map.maps[this.params.map].projection) {
2004
- return this.coordsToPoint.apply(this, coords);
1941
+ function SVGImageElement(config, style) {
1942
+ return _SVGShapeElement.call(this, 'image', config, style) || this;
2005
1943
  }
2006
1944
 
2007
- return {
2008
- x: coords[0] * this.scale + this.transX * this.scale,
2009
- y: coords[1] * this.scale + this.transY * this.scale
2010
- };
2011
- }
1945
+ var _proto = SVGImageElement.prototype;
2012
1946
 
2013
- function repositionLines() {
2014
- var point1 = false,
2015
- point2 = false;
1947
+ _proto.applyAttr = function applyAttr(attr, value) {
1948
+ var imageUrl;
2016
1949
 
2017
- for (var index in this.lines) {
2018
- for (var mindex in this.markers) {
2019
- var marker = this.markers[mindex]; // console.log(this.lines[index], index);
1950
+ if (attr === 'image') {
1951
+ // This get executed when we have url in series.markers[0].scale.someScale.url
1952
+ if (typeof value === 'object') {
1953
+ imageUrl = value.url;
1954
+ this.offset = value.offset || [0, 0];
1955
+ } else {
1956
+ imageUrl = value;
1957
+ this.offset = [0, 0];
1958
+ }
2020
1959
 
2021
- if (marker.config.name === this.lines[index].config.from) {
2022
- point1 = this.getMarkerPosition(marker.config);
1960
+ this.node.setAttributeNS('http://www.w3.org/1999/xlink', 'href', imageUrl); // Set width and height then call this `applyAttr` again
1961
+
1962
+ this.width = 23;
1963
+ this.height = 23;
1964
+ this.applyAttr('width', this.width);
1965
+ this.applyAttr('height', this.height);
1966
+ this.applyAttr('x', this.cx - this.width / 2 + this.offset[0]);
1967
+ this.applyAttr('y', this.cy - this.height / 2 + this.offset[1]);
1968
+ } else if (attr == 'cx') {
1969
+ this.cx = value;
1970
+
1971
+ if (this.width) {
1972
+ this.applyAttr('x', value - this.width / 2 + this.offset[0]);
2023
1973
  }
1974
+ } else if (attr == 'cy') {
1975
+ this.cy = value;
2024
1976
 
2025
- if (marker.config.name === this.lines[index].config.to) {
2026
- point2 = this.getMarkerPosition(marker.config);
1977
+ if (this.height) {
1978
+ this.applyAttr('y', value - this.height / 2 + this.offset[1]);
2027
1979
  }
1980
+ } else {
1981
+ // This time Call SVGElement
1982
+ _SVGShapeElement.prototype.applyAttr.apply(this, arguments);
2028
1983
  }
1984
+ };
2029
1985
 
2030
- if (point1 !== false && point2 !== false) {
2031
- this.lines[index].setStyle({
2032
- x1: point1.x,
2033
- y1: point1.y,
2034
- x2: point2.x,
2035
- y2: point2.y
2036
- });
2037
- }
2038
- }
2039
- }
1986
+ return SVGImageElement;
1987
+ }(SVGShapeElement);
2040
1988
 
2041
- function repositionMarkers() {
2042
- var point;
1989
+ /**
1990
+ * ------------------------------------------------------------------------
1991
+ * Class Definition
1992
+ * ------------------------------------------------------------------------
1993
+ */
2043
1994
 
2044
- for (var index in this.markers) {
2045
- point = this.getMarkerPosition(this.markers[index].config);
1995
+ var SVGCanvasElement = /*#__PURE__*/function (_SVGElement) {
1996
+ _inheritsLoose(SVGCanvasElement, _SVGElement);
2046
1997
 
2047
- if (point !== false) {
2048
- this.markers[index].element.setStyle({
2049
- cx: point.x,
2050
- cy: point.y
2051
- });
2052
- }
1998
+ function SVGCanvasElement(container) {
1999
+ var _this;
2000
+
2001
+ _this = _SVGElement.call(this, 'svg') || this; // Create svg element for holding the whole map
2002
+
2003
+ _this._container = container; // Create the defs element
2004
+
2005
+ _this._defsElement = new SVGElement('defs'); // Create group element which will hold the paths (regions)
2006
+
2007
+ _this._rootElement = new SVGElement('g', {
2008
+ id: 'jvm-regions-group'
2009
+ }); // Append the defs element to the this.node (SVG tag)
2010
+
2011
+ _this.node.appendChild(_this._defsElement.node); // Append the group to this.node (SVG tag)
2012
+
2013
+
2014
+ _this.node.appendChild(_this._rootElement.node); // Append this.node (SVG tag) to the container
2015
+
2016
+
2017
+ _this._container.appendChild(_this.node);
2018
+
2019
+ return _this;
2053
2020
  }
2054
- }
2055
2021
 
2056
- function repositionLabels() {
2057
- var labels = this.params.labels;
2022
+ var _proto = SVGCanvasElement.prototype;
2058
2023
 
2059
- if (!labels) {
2060
- return;
2061
- } // Regions labels
2024
+ _proto.setSize = function setSize(width, height) {
2025
+ this.node.setAttribute('width', width);
2026
+ this.node.setAttribute('height', height);
2027
+ };
2062
2028
 
2029
+ _proto.applyTransformParams = function applyTransformParams(scale, transX, transY) {
2030
+ this._rootElement.node.setAttribute('transform', "scale(" + scale + ") translate(" + transX + ", " + transY + ")");
2031
+ } // Create `path` element
2032
+ ;
2063
2033
 
2064
- if (labels.regions) {
2065
- for (var key in this.regions) {
2066
- this.regions[key].element.updateLabelPosition();
2067
- }
2068
- } // Markers labels
2034
+ _proto.createPath = function createPath(config, style) {
2035
+ var path = new SVGShapeElement('path', config, style);
2036
+ path.node.setAttribute('fill-rule', 'evenodd');
2037
+ return this.add(path);
2038
+ } // Create `circle` element
2039
+ ;
2069
2040
 
2041
+ _proto.createCircle = function createCircle(config, style, group) {
2042
+ var circle = new SVGShapeElement('circle', config, style);
2043
+ return this.add(circle, group);
2044
+ } // Create `line` element
2045
+ ;
2070
2046
 
2071
- if (labels.markers) {
2072
- for (var _key in this.markers) {
2073
- this.markers[_key].element.updateLabelPosition();
2047
+ _proto.createLine = function createLine(config, style, group) {
2048
+ var line = new SVGShapeElement('line', config, style);
2049
+ return this.add(line, group);
2050
+ } // Create `text` element
2051
+ ;
2052
+
2053
+ _proto.createText = function createText(config, style, group) {
2054
+ var text = new SVGTextElement(config, style); // extends SVGShapeElement
2055
+
2056
+ return this.add(text, group);
2057
+ } // Create `image` element
2058
+ ;
2059
+
2060
+ _proto.createImage = function createImage(config, style, group) {
2061
+ var image = new SVGImageElement(config, style); // extends SVGShapeElement
2062
+
2063
+ return this.add(image, group);
2064
+ } // Create `g` element
2065
+ ;
2066
+
2067
+ _proto.createGroup = function createGroup(id) {
2068
+ var group = new SVGElement('g');
2069
+ this.node.appendChild(group.node);
2070
+
2071
+ if (id) {
2072
+ group.node.id = id;
2074
2073
  }
2075
- }
2076
- }
2077
2074
 
2078
- var MapPrototypes = {
2079
- _setupContainerEvents: setupContainerEvents,
2080
- _setupElementEvents: setupElementEvents,
2081
- _setupZoomButtons: setupZoomButtons,
2082
- _setupContainerTouchEvents: setupContainerTouchEvents,
2083
- _createRegions: createRegions,
2084
- _createLines: createLines,
2085
- _createMarkers: createMarkers,
2086
- _createSeries: createSeries,
2087
- _applyTransform: applyTransform,
2088
- _resize: resize,
2089
- _setScale: setScale,
2090
- setFocus: setFocus,
2091
- updateSize: updateSize,
2092
- coordsToPoint: coordsToPoint,
2093
- getInsetForPoint: getInsetForPoint,
2094
- getMarkerPosition: getMarkerPosition,
2095
- _repositionLines: repositionLines,
2096
- _repositionMarkers: repositionMarkers,
2097
- _repositionLabels: repositionLabels
2098
- };
2075
+ group.canvas = this;
2076
+ return group;
2077
+ } // Add some element to a spcific group or the root element if the group isn't given
2078
+ ;
2079
+
2080
+ _proto.add = function add(element, group) {
2081
+ group = group || this._rootElement;
2082
+ group.node.appendChild(element.node);
2083
+ return element;
2084
+ };
2085
+
2086
+ return SVGCanvasElement;
2087
+ }(SVGElement);
2099
2088
 
2100
2089
  /**
2101
2090
  * ------------------------------------------------------------------------
@@ -2176,12 +2165,18 @@
2176
2165
  this._tooltip.classList.remove('active');
2177
2166
  };
2178
2167
 
2179
- _proto.text = function text(string) {
2168
+ _proto.text = function text(string, html) {
2169
+ if (html === void 0) {
2170
+ html = false;
2171
+ }
2172
+
2173
+ var property = html ? 'innerHTML' : 'textContent';
2174
+
2180
2175
  if (!string) {
2181
- return this._tooltip.textContent;
2176
+ return this._tooltip[property];
2182
2177
  }
2183
2178
 
2184
- this._tooltip.textContent = string;
2179
+ this._tooltip[property] = string;
2185
2180
  };
2186
2181
 
2187
2182
  _proto.css = function css(_css) {
@@ -2622,7 +2617,7 @@
2622
2617
 
2623
2618
  Map.maps = {};
2624
2619
  Map.defaults = Defaults;
2625
- Object.assign(Map.prototype, MapPrototypes);
2620
+ Object.assign(Map.prototype, core);
2626
2621
 
2627
2622
  /**
2628
2623
  * jsVectorMap