@progress/kendo-charts 1.29.0 → 1.30.0-dev.202307190651
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.md +1 -1
- package/README.md +17 -0
- package/dist/cdn/js/kendo-charts.js +1 -1
- package/dist/cdn/main.js +1 -1
- package/dist/es/common/is-plain-object.js +3 -0
- package/dist/es/common/render-icon.js +166 -0
- package/dist/es/common.js +2 -0
- package/dist/es/map/layers/marker.js +18 -2
- package/dist/es/map/map.js +8 -4
- package/dist/es/map/navigator.js +8 -7
- package/dist/es/map/zoom.js +7 -6
- package/dist/es2015/common/is-plain-object.js +3 -0
- package/dist/es2015/common/render-icon.js +156 -0
- package/dist/es2015/common.js +2 -0
- package/dist/es2015/map/layers/marker.js +18 -2
- package/dist/es2015/map/map.js +8 -4
- package/dist/es2015/map/navigator.js +8 -7
- package/dist/es2015/map/zoom.js +7 -6
- package/dist/npm/main.js +201 -17
- package/dist/systemjs/kendo-charts.js +1 -1
- package/package.json +16 -13
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import isObject from './is-object';
|
|
2
|
+
import isPlainObject from './is-plain-object';
|
|
3
|
+
import isString from './is-string';
|
|
4
|
+
import deepExtend from './deep-extend';
|
|
5
|
+
import setDefaultOptions from './set-default-options';
|
|
6
|
+
import addClass from './add-class';
|
|
7
|
+
import removeClass from './remove-class';
|
|
8
|
+
|
|
9
|
+
var KICON = 'k-icon';
|
|
10
|
+
var KI_PREFFIX = 'k-i-';
|
|
11
|
+
var KSVGICON = 'k-svg-icon';
|
|
12
|
+
var KSVG_PREFFIX = 'k-svg-i-';
|
|
13
|
+
|
|
14
|
+
var HTMLBaseIcon = function HTMLBaseIcon(element, options) {
|
|
15
|
+
this.element = element;
|
|
16
|
+
this.options = deepExtend({}, this.options, options);
|
|
17
|
+
|
|
18
|
+
this.wrapper();
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
HTMLBaseIcon.prototype.wrapper = function wrapper () {
|
|
22
|
+
this.addClasses();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
HTMLBaseIcon.prototype.addClasses = function addClasses () {
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
HTMLBaseIcon.prototype.html = function html () {
|
|
29
|
+
return this.element.outerHTML;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
setDefaultOptions(HTMLBaseIcon, {
|
|
33
|
+
name: '',
|
|
34
|
+
size: 'none',
|
|
35
|
+
themeColor: 'none',
|
|
36
|
+
flip: 'default',
|
|
37
|
+
iconClass: '',
|
|
38
|
+
stylingOptions: [ 'size', 'themeColor', 'fill' ]
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
var HTMLFontIcon = (function (HTMLBaseIcon) {
|
|
42
|
+
function HTMLFontIcon(element, options) {
|
|
43
|
+
HTMLBaseIcon.call(this, element, options);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if ( HTMLBaseIcon ) HTMLFontIcon.__proto__ = HTMLBaseIcon;
|
|
47
|
+
HTMLFontIcon.prototype = Object.create( HTMLBaseIcon && HTMLBaseIcon.prototype );
|
|
48
|
+
HTMLFontIcon.prototype.constructor = HTMLFontIcon;
|
|
49
|
+
|
|
50
|
+
HTMLFontIcon.prototype.wrapper = function wrapper () {
|
|
51
|
+
// Find if there is an existing k-i- class appended to the element.
|
|
52
|
+
var currentIconClass = this.element.className.split(" ").find(function (x) { return x.startsWith(KI_PREFFIX); });
|
|
53
|
+
var className = this.options.icon ? ("" + (this.options.icon.startsWith(KI_PREFFIX) ? "" : KI_PREFFIX) + (this.options.icon)) : "";
|
|
54
|
+
|
|
55
|
+
this._className = className;
|
|
56
|
+
|
|
57
|
+
addClass(this.element, KICON);
|
|
58
|
+
removeClass(this.element, currentIconClass); // Remove any existing icons.
|
|
59
|
+
addClass(this.element, className);
|
|
60
|
+
addClass(this.element, this.options.iconClass || '');
|
|
61
|
+
|
|
62
|
+
HTMLBaseIcon.prototype.wrapper.call(this);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
return HTMLFontIcon;
|
|
66
|
+
}(HTMLBaseIcon));
|
|
67
|
+
|
|
68
|
+
setDefaultOptions(HTMLFontIcon, {
|
|
69
|
+
name: 'HTMLFontIcon',
|
|
70
|
+
icon: null
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
var HTMLSvgIcon = (function (HTMLBaseIcon) {
|
|
74
|
+
function HTMLSvgIcon(element, options) {
|
|
75
|
+
// Ensure that the inner contents of the wrapping span element are always removed for re-rendering purposes.
|
|
76
|
+
element.innerHTML = "";
|
|
77
|
+
|
|
78
|
+
HTMLBaseIcon.call(this, element, options);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if ( HTMLBaseIcon ) HTMLSvgIcon.__proto__ = HTMLBaseIcon;
|
|
82
|
+
HTMLSvgIcon.prototype = Object.create( HTMLBaseIcon && HTMLBaseIcon.prototype );
|
|
83
|
+
HTMLSvgIcon.prototype.constructor = HTMLSvgIcon;
|
|
84
|
+
|
|
85
|
+
HTMLSvgIcon.prototype.wrapper = function wrapper () {
|
|
86
|
+
var icon = this.options.icon;
|
|
87
|
+
var iconClass = this.options.iconClass;
|
|
88
|
+
var currentIconClass = this.element.className.split(" ").find(function (x) { return x.startsWith(KSVG_PREFFIX); });
|
|
89
|
+
|
|
90
|
+
if (!icon && iconClass) {
|
|
91
|
+
// match k-i-(some-icon-name)
|
|
92
|
+
var regex = /k-i-(\w+(?:-\w+)*)/;
|
|
93
|
+
var iconNameMatch = iconClass.match(regex);
|
|
94
|
+
if (iconNameMatch) {
|
|
95
|
+
icon = iconNameMatch[1];
|
|
96
|
+
iconClass = iconClass.replace(iconNameMatch[0], "");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (isString(icon)) {
|
|
101
|
+
icon = icon.replace("k-i-", "").replace(/-./g, function (x) { return x[1].toUpperCase(); });
|
|
102
|
+
icon = this.options.svgIcons[icon] || this.options.svgIcons[(icon + "Icon")];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
var className = icon && icon.name ? ("" + KSVG_PREFFIX + (icon.name)) : "";
|
|
106
|
+
this._className = className;
|
|
107
|
+
|
|
108
|
+
addClass(this.element, KSVGICON);
|
|
109
|
+
removeClass(this.element, currentIconClass);
|
|
110
|
+
addClass(this.element, className);
|
|
111
|
+
addClass(this.element, iconClass || "");
|
|
112
|
+
this.element.setAttribute("aria-hidden", "true");
|
|
113
|
+
|
|
114
|
+
if (icon && isPlainObject(icon)) {
|
|
115
|
+
var svgElement = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
116
|
+
svgElement.setAttribute("viewBox", icon.viewBox || "");
|
|
117
|
+
svgElement.setAttribute("focusable", "false");
|
|
118
|
+
svgElement.innerHTML = icon.content || "";
|
|
119
|
+
|
|
120
|
+
this.element.appendChild(svgElement);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
HTMLBaseIcon.prototype.wrapper.call(this);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
return HTMLSvgIcon;
|
|
127
|
+
}(HTMLBaseIcon));
|
|
128
|
+
|
|
129
|
+
setDefaultOptions(HTMLSvgIcon, {
|
|
130
|
+
name: 'HTMLSvgIcon',
|
|
131
|
+
icon: null,
|
|
132
|
+
svgIcons: {}
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
var ICON_TYPES = {
|
|
136
|
+
'svg': HTMLSvgIcon,
|
|
137
|
+
'font': HTMLFontIcon
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export default function renderIcon(iconElement, iconOptions) {
|
|
141
|
+
var element = iconElement;
|
|
142
|
+
var options = iconOptions;
|
|
143
|
+
|
|
144
|
+
if (!element
|
|
145
|
+
|| (isObject(element) && !(element instanceof HTMLElement))
|
|
146
|
+
|| isString(element)) {
|
|
147
|
+
options = element;
|
|
148
|
+
element = document.createElement("span");
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (isString(options)) {
|
|
152
|
+
options = {
|
|
153
|
+
icon: options
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (!options.type) {
|
|
158
|
+
options.type = 'svg';
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (!ICON_TYPES[options.type]) {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return (new ICON_TYPES[options.type](element, options).html());
|
|
166
|
+
}
|
package/dist/es/common.js
CHANGED
|
@@ -18,10 +18,12 @@ export { default as isArray } from './common/is-array';
|
|
|
18
18
|
export { default as isFunction } from './common/is-function';
|
|
19
19
|
export { default as isNumber } from './common/is-number';
|
|
20
20
|
export { default as isObject } from './common/is-object';
|
|
21
|
+
export { default as isPlainObject } from './common/is-plain-object';
|
|
21
22
|
export { default as isString } from './common/is-string';
|
|
22
23
|
export { default as map } from './common/map';
|
|
23
24
|
export { default as mousewheelDelta } from './common/mousewheel-delta';
|
|
24
25
|
export { default as FontLoader } from './common/font-loader';
|
|
26
|
+
export { default as renderIcon } from './common/render-icon';
|
|
25
27
|
export { default as setDefaultOptions } from './common/set-default-options';
|
|
26
28
|
export { default as sparseArrayLimits } from './common/sparse-array-limits';
|
|
27
29
|
export { default as styleValue } from './common/style-value';
|
|
@@ -4,7 +4,8 @@ import {
|
|
|
4
4
|
isArray,
|
|
5
5
|
getter,
|
|
6
6
|
deepExtend,
|
|
7
|
-
setDefaultOptions
|
|
7
|
+
setDefaultOptions,
|
|
8
|
+
renderIcon
|
|
8
9
|
} from '../../common';
|
|
9
10
|
|
|
10
11
|
import { Layer } from './layer';
|
|
@@ -285,8 +286,23 @@ export var Marker = (function (Class) {
|
|
|
285
286
|
var templateHtml = templateFn(this.dataItem);
|
|
286
287
|
var templateElement = convertToHtml(templateHtml);
|
|
287
288
|
element.appendChild(templateElement);
|
|
289
|
+
} else if (options.svgIcon) {
|
|
290
|
+
renderIcon(element, { icon: options.svgIcon, iconClass: "k-icon-xxl", svgIcons: this.options.icons.svgIcons, type: "svg" });
|
|
288
291
|
} else {
|
|
289
|
-
|
|
292
|
+
var iconOptions = { icon: "map-marker", iconClass: "k-icon-xxl", svgIcons: this.options.icons.svgIcons, type: this.options.icons.type };
|
|
293
|
+
|
|
294
|
+
if (options.shape) {
|
|
295
|
+
if (options.shape === "pinTarget") {
|
|
296
|
+
iconOptions.icon = "map-marker-target";
|
|
297
|
+
renderIcon(element, iconOptions);
|
|
298
|
+
} else if (options.shape === "pin") {
|
|
299
|
+
renderIcon(element, iconOptions);
|
|
300
|
+
} else {
|
|
301
|
+
addClass(element, 'k-icon k-icon-xxl k-i-marker-' + toHyphens(options.shape || 'pin'));
|
|
302
|
+
}
|
|
303
|
+
} else {
|
|
304
|
+
renderIcon(element, iconOptions);
|
|
305
|
+
}
|
|
290
306
|
}
|
|
291
307
|
|
|
292
308
|
if (options.title) {
|
package/dist/es/map/map.js
CHANGED
|
@@ -553,7 +553,7 @@ var Map = (function (Observable) {
|
|
|
553
553
|
|
|
554
554
|
Map.prototype._createNavigator = function _createNavigator (options) {
|
|
555
555
|
var element = this._createControlElement(options, 'topLeft');
|
|
556
|
-
var navigator = this.navigator = new Navigator(element, options);
|
|
556
|
+
var navigator = this.navigator = new Navigator(element, deepExtend({}, options, { icons: this.options.icons }));
|
|
557
557
|
|
|
558
558
|
this._navigatorPan = this._navigatorPan.bind(this);
|
|
559
559
|
navigator.bind('pan', this._navigatorPan);
|
|
@@ -585,7 +585,7 @@ var Map = (function (Observable) {
|
|
|
585
585
|
|
|
586
586
|
Map.prototype._createZoomControl = function _createZoomControl (options) {
|
|
587
587
|
var element = this._createControlElement(options, 'topLeft');
|
|
588
|
-
var zoomControl = this.zoomControl = new ZoomControl(element, options);
|
|
588
|
+
var zoomControl = this.zoomControl = new ZoomControl(element, options, this.options.icons);
|
|
589
589
|
|
|
590
590
|
this._zoomControlChange = this._zoomControlChange.bind(this);
|
|
591
591
|
zoomControl.bind('change', this._zoomControlChange);
|
|
@@ -641,7 +641,7 @@ var Map = (function (Observable) {
|
|
|
641
641
|
var type = options.type || 'shape';
|
|
642
642
|
var layerDefaults = this.options.layerDefaults[type];
|
|
643
643
|
var layerOptions = type === MARKER ?
|
|
644
|
-
deepExtend({}, this.options.markerDefaults, options) :
|
|
644
|
+
deepExtend({}, this.options.markerDefaults, options, { icons: this.options.icons }) :
|
|
645
645
|
deepExtend({}, layerDefaults, options);
|
|
646
646
|
|
|
647
647
|
var layerConstructor = layersMap[type];
|
|
@@ -670,7 +670,7 @@ var Map = (function (Observable) {
|
|
|
670
670
|
return;
|
|
671
671
|
}
|
|
672
672
|
|
|
673
|
-
this.markers = new MarkerLayer(this, this.options.markerDefaults);
|
|
673
|
+
this.markers = new MarkerLayer(this, deepExtend({}, this.options.markerDefaults, { icons: this.options.icons }));
|
|
674
674
|
this.markers.add(this.options.markers);
|
|
675
675
|
};
|
|
676
676
|
/* eslint-enable arrow-body-style */
|
|
@@ -935,6 +935,10 @@ setDefaultOptions(Map, {
|
|
|
935
935
|
0,
|
|
936
936
|
0
|
|
937
937
|
],
|
|
938
|
+
icons: {
|
|
939
|
+
type: "font",
|
|
940
|
+
svgIcons: {}
|
|
941
|
+
},
|
|
938
942
|
zoom: 3,
|
|
939
943
|
minSize: 256,
|
|
940
944
|
minZoom: 1,
|
package/dist/es/map/navigator.js
CHANGED
|
@@ -2,7 +2,8 @@ import {
|
|
|
2
2
|
deepExtend,
|
|
3
3
|
addClass,
|
|
4
4
|
keys,
|
|
5
|
-
setDefaultOptions
|
|
5
|
+
setDefaultOptions,
|
|
6
|
+
renderIcon
|
|
6
7
|
} from '../common';
|
|
7
8
|
|
|
8
9
|
import {
|
|
@@ -38,12 +39,12 @@ var directionsMap = {
|
|
|
38
39
|
}
|
|
39
40
|
};
|
|
40
41
|
|
|
41
|
-
function createButton(direction) {
|
|
42
|
+
function createButton(direction, iconOptions) {
|
|
42
43
|
var html =
|
|
43
44
|
'<button class="k-button k-button-square k-rounded-full k-button-flat k-button-flat-base k-icon-button ' +
|
|
44
45
|
directionsMap[direction].className +
|
|
45
46
|
'" aria-label="move ' + direction + '">' +
|
|
46
|
-
|
|
47
|
+
renderIcon({ icon: ("caret-alt-" + direction), iconClass: "k-button-icon", svgIcons: iconOptions.svgIcons, type: iconOptions.type }) +
|
|
47
48
|
'</button>';
|
|
48
49
|
|
|
49
50
|
return convertToHtml(html);
|
|
@@ -56,10 +57,10 @@ export var Navigator = (function (Observable) {
|
|
|
56
57
|
this.element = element;
|
|
57
58
|
this._initOptions(options);
|
|
58
59
|
|
|
59
|
-
var navigateUpButton = createButton("up");
|
|
60
|
-
var navigateRightlButton = createButton("right");
|
|
61
|
-
var navigateDownButton = createButton("down");
|
|
62
|
-
var navigateLeftButton = createButton("left");
|
|
60
|
+
var navigateUpButton = createButton("up", options.icons);
|
|
61
|
+
var navigateRightlButton = createButton("right", options.icons);
|
|
62
|
+
var navigateDownButton = createButton("down", options.icons);
|
|
63
|
+
var navigateLeftButton = createButton("left", options.icons);
|
|
63
64
|
|
|
64
65
|
this.element.appendChild(navigateUpButton);
|
|
65
66
|
this.element.appendChild(navigateRightlButton);
|
package/dist/es/map/zoom.js
CHANGED
|
@@ -3,7 +3,8 @@ import {
|
|
|
3
3
|
addClass,
|
|
4
4
|
keys,
|
|
5
5
|
hasClasses,
|
|
6
|
-
setDefaultOptions
|
|
6
|
+
setDefaultOptions,
|
|
7
|
+
renderIcon
|
|
7
8
|
} from '../common';
|
|
8
9
|
|
|
9
10
|
import {
|
|
@@ -17,12 +18,12 @@ import {
|
|
|
17
18
|
convertToHtml
|
|
18
19
|
} from './utils';
|
|
19
20
|
|
|
20
|
-
function createButton(direction,
|
|
21
|
+
function createButton(direction, icon, iconOptions) {
|
|
21
22
|
var html =
|
|
22
23
|
'<button class="k-button k-button-md k-rounded-md k-button-solid k-button-solid-base k-icon-button k-zoom-' + direction +
|
|
23
24
|
'" title="zoom-' + direction +
|
|
24
25
|
'" aria-label="zoom-' + direction + '">' +
|
|
25
|
-
|
|
26
|
+
renderIcon({ icon: icon, iconClass: "k-button-icon", svgIcons: iconOptions.svgIcons, type: iconOptions.type }) +
|
|
26
27
|
'</button>';
|
|
27
28
|
|
|
28
29
|
return convertToHtml(html);
|
|
@@ -35,13 +36,13 @@ var FF_MINUS = 173;
|
|
|
35
36
|
var CHANGE = "change";
|
|
36
37
|
|
|
37
38
|
export var ZoomControl = (function (Observable) {
|
|
38
|
-
function ZoomControl(element, options) {
|
|
39
|
+
function ZoomControl(element, options, iconOptions) {
|
|
39
40
|
Observable.call(this);
|
|
40
41
|
this.element = element;
|
|
41
42
|
this._initOptions(options);
|
|
42
43
|
|
|
43
|
-
var zoomInButton = createButton('in', '
|
|
44
|
-
var zoomOutButton = createButton('out', '
|
|
44
|
+
var zoomInButton = createButton('in', 'plus', iconOptions);
|
|
45
|
+
var zoomOutButton = createButton('out', 'minus', iconOptions);
|
|
45
46
|
|
|
46
47
|
this.element.appendChild(zoomInButton);
|
|
47
48
|
this.element.appendChild(zoomOutButton);
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import isObject from './is-object';
|
|
2
|
+
import isPlainObject from './is-plain-object';
|
|
3
|
+
import isString from './is-string';
|
|
4
|
+
import deepExtend from './deep-extend';
|
|
5
|
+
import setDefaultOptions from './set-default-options';
|
|
6
|
+
import addClass from './add-class';
|
|
7
|
+
import removeClass from './remove-class';
|
|
8
|
+
|
|
9
|
+
const KICON = 'k-icon';
|
|
10
|
+
const KI_PREFFIX = 'k-i-';
|
|
11
|
+
const KSVGICON = 'k-svg-icon';
|
|
12
|
+
const KSVG_PREFFIX = 'k-svg-i-';
|
|
13
|
+
|
|
14
|
+
class HTMLBaseIcon {
|
|
15
|
+
constructor(element, options) {
|
|
16
|
+
this.element = element;
|
|
17
|
+
this.options = deepExtend({}, this.options, options);
|
|
18
|
+
|
|
19
|
+
this.wrapper();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
wrapper() {
|
|
23
|
+
this.addClasses();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
addClasses() {
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
html() {
|
|
30
|
+
return this.element.outerHTML;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
setDefaultOptions(HTMLBaseIcon, {
|
|
35
|
+
name: '',
|
|
36
|
+
size: 'none',
|
|
37
|
+
themeColor: 'none',
|
|
38
|
+
flip: 'default',
|
|
39
|
+
iconClass: '',
|
|
40
|
+
stylingOptions: [ 'size', 'themeColor', 'fill' ]
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
class HTMLFontIcon extends HTMLBaseIcon {
|
|
44
|
+
constructor(element, options) {
|
|
45
|
+
super(element, options);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
wrapper() {
|
|
49
|
+
// Find if there is an existing k-i- class appended to the element.
|
|
50
|
+
let currentIconClass = this.element.className.split(" ").find(x => x.startsWith(KI_PREFFIX));
|
|
51
|
+
let className = this.options.icon ? `${this.options.icon.startsWith(KI_PREFFIX) ? "" : KI_PREFFIX}${this.options.icon}` : "";
|
|
52
|
+
|
|
53
|
+
this._className = className;
|
|
54
|
+
|
|
55
|
+
addClass(this.element, KICON);
|
|
56
|
+
removeClass(this.element, currentIconClass); // Remove any existing icons.
|
|
57
|
+
addClass(this.element, className);
|
|
58
|
+
addClass(this.element, this.options.iconClass || '');
|
|
59
|
+
|
|
60
|
+
super.wrapper();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
setDefaultOptions(HTMLFontIcon, {
|
|
65
|
+
name: 'HTMLFontIcon',
|
|
66
|
+
icon: null
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
class HTMLSvgIcon extends HTMLBaseIcon {
|
|
70
|
+
constructor(element, options) {
|
|
71
|
+
// Ensure that the inner contents of the wrapping span element are always removed for re-rendering purposes.
|
|
72
|
+
element.innerHTML = "";
|
|
73
|
+
|
|
74
|
+
super(element, options);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
wrapper() {
|
|
78
|
+
let icon = this.options.icon;
|
|
79
|
+
let iconClass = this.options.iconClass;
|
|
80
|
+
let currentIconClass = this.element.className.split(" ").find(x => x.startsWith(KSVG_PREFFIX));
|
|
81
|
+
|
|
82
|
+
if (!icon && iconClass) {
|
|
83
|
+
// match k-i-(some-icon-name)
|
|
84
|
+
const regex = /k-i-(\w+(?:-\w+)*)/;
|
|
85
|
+
let iconNameMatch = iconClass.match(regex);
|
|
86
|
+
if (iconNameMatch) {
|
|
87
|
+
icon = iconNameMatch[1];
|
|
88
|
+
iconClass = iconClass.replace(iconNameMatch[0], "");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (isString(icon)) {
|
|
93
|
+
icon = icon.replace("k-i-", "").replace(/-./g, x => x[1].toUpperCase());
|
|
94
|
+
icon = this.options.svgIcons[icon] || this.options.svgIcons[`${icon}Icon`];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
let className = icon && icon.name ? `${KSVG_PREFFIX}${icon.name}` : "";
|
|
98
|
+
this._className = className;
|
|
99
|
+
|
|
100
|
+
addClass(this.element, KSVGICON);
|
|
101
|
+
removeClass(this.element, currentIconClass);
|
|
102
|
+
addClass(this.element, className);
|
|
103
|
+
addClass(this.element, iconClass || "");
|
|
104
|
+
this.element.setAttribute("aria-hidden", "true");
|
|
105
|
+
|
|
106
|
+
if (icon && isPlainObject(icon)) {
|
|
107
|
+
let svgElement = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
108
|
+
svgElement.setAttribute("viewBox", icon.viewBox || "");
|
|
109
|
+
svgElement.setAttribute("focusable", "false");
|
|
110
|
+
svgElement.innerHTML = icon.content || "";
|
|
111
|
+
|
|
112
|
+
this.element.appendChild(svgElement);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
super.wrapper();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
setDefaultOptions(HTMLSvgIcon, {
|
|
120
|
+
name: 'HTMLSvgIcon',
|
|
121
|
+
icon: null,
|
|
122
|
+
svgIcons: {}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
const ICON_TYPES = {
|
|
126
|
+
'svg': HTMLSvgIcon,
|
|
127
|
+
'font': HTMLFontIcon
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export default function renderIcon(iconElement, iconOptions) {
|
|
131
|
+
let element = iconElement;
|
|
132
|
+
let options = iconOptions;
|
|
133
|
+
|
|
134
|
+
if (!element
|
|
135
|
+
|| (isObject(element) && !(element instanceof HTMLElement))
|
|
136
|
+
|| isString(element)) {
|
|
137
|
+
options = element;
|
|
138
|
+
element = document.createElement("span");
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (isString(options)) {
|
|
142
|
+
options = {
|
|
143
|
+
icon: options
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (!options.type) {
|
|
148
|
+
options.type = 'svg';
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (!ICON_TYPES[options.type]) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return (new ICON_TYPES[options.type](element, options).html());
|
|
156
|
+
}
|
package/dist/es2015/common.js
CHANGED
|
@@ -18,10 +18,12 @@ export { default as isArray } from './common/is-array';
|
|
|
18
18
|
export { default as isFunction } from './common/is-function';
|
|
19
19
|
export { default as isNumber } from './common/is-number';
|
|
20
20
|
export { default as isObject } from './common/is-object';
|
|
21
|
+
export { default as isPlainObject } from './common/is-plain-object';
|
|
21
22
|
export { default as isString } from './common/is-string';
|
|
22
23
|
export { default as map } from './common/map';
|
|
23
24
|
export { default as mousewheelDelta } from './common/mousewheel-delta';
|
|
24
25
|
export { default as FontLoader } from './common/font-loader';
|
|
26
|
+
export { default as renderIcon } from './common/render-icon';
|
|
25
27
|
export { default as setDefaultOptions } from './common/set-default-options';
|
|
26
28
|
export { default as sparseArrayLimits } from './common/sparse-array-limits';
|
|
27
29
|
export { default as styleValue } from './common/style-value';
|
|
@@ -4,7 +4,8 @@ import {
|
|
|
4
4
|
isArray,
|
|
5
5
|
getter,
|
|
6
6
|
deepExtend,
|
|
7
|
-
setDefaultOptions
|
|
7
|
+
setDefaultOptions,
|
|
8
|
+
renderIcon
|
|
8
9
|
} from '../../common';
|
|
9
10
|
|
|
10
11
|
import { Layer } from './layer';
|
|
@@ -267,8 +268,23 @@ export class Marker extends Class {
|
|
|
267
268
|
const templateHtml = templateFn(this.dataItem);
|
|
268
269
|
const templateElement = convertToHtml(templateHtml);
|
|
269
270
|
element.appendChild(templateElement);
|
|
271
|
+
} else if (options.svgIcon) {
|
|
272
|
+
renderIcon(element, { icon: options.svgIcon, iconClass: "k-icon-xxl", svgIcons: this.options.icons.svgIcons, type: "svg" });
|
|
270
273
|
} else {
|
|
271
|
-
|
|
274
|
+
let iconOptions = { icon: "map-marker", iconClass: "k-icon-xxl", svgIcons: this.options.icons.svgIcons, type: this.options.icons.type };
|
|
275
|
+
|
|
276
|
+
if (options.shape) {
|
|
277
|
+
if (options.shape === "pinTarget") {
|
|
278
|
+
iconOptions.icon = "map-marker-target";
|
|
279
|
+
renderIcon(element, iconOptions);
|
|
280
|
+
} else if (options.shape === "pin") {
|
|
281
|
+
renderIcon(element, iconOptions);
|
|
282
|
+
} else {
|
|
283
|
+
addClass(element, 'k-icon k-icon-xxl k-i-marker-' + toHyphens(options.shape || 'pin'));
|
|
284
|
+
}
|
|
285
|
+
} else {
|
|
286
|
+
renderIcon(element, iconOptions);
|
|
287
|
+
}
|
|
272
288
|
}
|
|
273
289
|
|
|
274
290
|
if (options.title) {
|
package/dist/es2015/map/map.js
CHANGED
|
@@ -527,7 +527,7 @@ class Map extends Observable {
|
|
|
527
527
|
|
|
528
528
|
_createNavigator(options) {
|
|
529
529
|
let element = this._createControlElement(options, 'topLeft');
|
|
530
|
-
let navigator = this.navigator = new Navigator(element, options);
|
|
530
|
+
let navigator = this.navigator = new Navigator(element, deepExtend({}, options, { icons: this.options.icons }));
|
|
531
531
|
|
|
532
532
|
this._navigatorPan = this._navigatorPan.bind(this);
|
|
533
533
|
navigator.bind('pan', this._navigatorPan);
|
|
@@ -559,7 +559,7 @@ class Map extends Observable {
|
|
|
559
559
|
|
|
560
560
|
_createZoomControl(options) {
|
|
561
561
|
let element = this._createControlElement(options, 'topLeft');
|
|
562
|
-
let zoomControl = this.zoomControl = new ZoomControl(element, options);
|
|
562
|
+
let zoomControl = this.zoomControl = new ZoomControl(element, options, this.options.icons);
|
|
563
563
|
|
|
564
564
|
this._zoomControlChange = this._zoomControlChange.bind(this);
|
|
565
565
|
zoomControl.bind('change', this._zoomControlChange);
|
|
@@ -613,7 +613,7 @@ class Map extends Observable {
|
|
|
613
613
|
let type = options.type || 'shape';
|
|
614
614
|
let layerDefaults = this.options.layerDefaults[type];
|
|
615
615
|
let layerOptions = type === MARKER ?
|
|
616
|
-
deepExtend({}, this.options.markerDefaults, options) :
|
|
616
|
+
deepExtend({}, this.options.markerDefaults, options, { icons: this.options.icons }) :
|
|
617
617
|
deepExtend({}, layerDefaults, options);
|
|
618
618
|
|
|
619
619
|
let layerConstructor = layersMap[type];
|
|
@@ -642,7 +642,7 @@ class Map extends Observable {
|
|
|
642
642
|
return;
|
|
643
643
|
}
|
|
644
644
|
|
|
645
|
-
this.markers = new MarkerLayer(this, this.options.markerDefaults);
|
|
645
|
+
this.markers = new MarkerLayer(this, deepExtend({}, this.options.markerDefaults, { icons: this.options.icons }));
|
|
646
646
|
this.markers.add(this.options.markers);
|
|
647
647
|
}
|
|
648
648
|
/* eslint-enable arrow-body-style */
|
|
@@ -905,6 +905,10 @@ setDefaultOptions(Map, {
|
|
|
905
905
|
0,
|
|
906
906
|
0
|
|
907
907
|
],
|
|
908
|
+
icons: {
|
|
909
|
+
type: "font",
|
|
910
|
+
svgIcons: {}
|
|
911
|
+
},
|
|
908
912
|
zoom: 3,
|
|
909
913
|
minSize: 256,
|
|
910
914
|
minZoom: 1,
|
|
@@ -2,7 +2,8 @@ import {
|
|
|
2
2
|
deepExtend,
|
|
3
3
|
addClass,
|
|
4
4
|
keys,
|
|
5
|
-
setDefaultOptions
|
|
5
|
+
setDefaultOptions,
|
|
6
|
+
renderIcon
|
|
6
7
|
} from '../common';
|
|
7
8
|
|
|
8
9
|
import {
|
|
@@ -38,12 +39,12 @@ const directionsMap = {
|
|
|
38
39
|
}
|
|
39
40
|
};
|
|
40
41
|
|
|
41
|
-
function createButton(direction) {
|
|
42
|
+
function createButton(direction, iconOptions) {
|
|
42
43
|
const html =
|
|
43
44
|
'<button class="k-button k-button-square k-rounded-full k-button-flat k-button-flat-base k-icon-button ' +
|
|
44
45
|
directionsMap[direction].className +
|
|
45
46
|
'" aria-label="move ' + direction + '">' +
|
|
46
|
-
|
|
47
|
+
renderIcon({ icon: `caret-alt-${direction}`, iconClass: "k-button-icon", svgIcons: iconOptions.svgIcons, type: iconOptions.type }) +
|
|
47
48
|
'</button>';
|
|
48
49
|
|
|
49
50
|
return convertToHtml(html);
|
|
@@ -56,10 +57,10 @@ export class Navigator extends Observable {
|
|
|
56
57
|
this.element = element;
|
|
57
58
|
this._initOptions(options);
|
|
58
59
|
|
|
59
|
-
const navigateUpButton = createButton("up");
|
|
60
|
-
const navigateRightlButton = createButton("right");
|
|
61
|
-
const navigateDownButton = createButton("down");
|
|
62
|
-
const navigateLeftButton = createButton("left");
|
|
60
|
+
const navigateUpButton = createButton("up", options.icons);
|
|
61
|
+
const navigateRightlButton = createButton("right", options.icons);
|
|
62
|
+
const navigateDownButton = createButton("down", options.icons);
|
|
63
|
+
const navigateLeftButton = createButton("left", options.icons);
|
|
63
64
|
|
|
64
65
|
this.element.appendChild(navigateUpButton);
|
|
65
66
|
this.element.appendChild(navigateRightlButton);
|