@splunk/visualizations-shared 26.4.1 → 27.1.0
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/.loki/reference/chrome_docker_SizeAwareWrapper_50_parent.png +0 -0
- package/.loki/reference/chrome_docker_SizeAwareWrapper_Fix_size_container.png +0 -0
- package/.loki/reference/chrome_docker_SizeAwareWrapper_Flex_layout_container.png +0 -0
- package/.loki/reference/chrome_docker_SizeAwareWrapper_Flex_layout_container_with_extra_wrapper.png +0 -0
- package/Downloader.js +164 -403
- package/Downloader.js.map +7 -1
- package/FileDownloader.js +121 -557
- package/FileDownloader.js.map +7 -1
- package/JSONSchemaUtils.js +58 -134
- package/JSONSchemaUtils.js.map +7 -1
- package/Message.js +105 -270
- package/Message.js.map +7 -1
- package/RemoteIcon.js +272 -736
- package/RemoteIcon.js.map +7 -1
- package/RemoteImage.js +190 -458
- package/RemoteImage.js.map +7 -1
- package/SanitizeProps.js +117 -238
- package/SanitizeProps.js.map +7 -1
- package/SizeAwareWrapper.js +108 -306
- package/SizeAwareWrapper.js.map +7 -1
- package/SizeAwareWrapperDeprecated.js +117 -326
- package/SizeAwareWrapperDeprecated.js.map +7 -1
- package/VisualizationDocPage.js +212 -461
- package/VisualizationDocPage.js.map +7 -1
- package/colorConstants.js +81 -132
- package/colorConstants.js.map +7 -1
- package/colorUtils.js +47 -134
- package/colorUtils.js.map +7 -1
- package/configUtils.js +28 -112
- package/configUtils.js.map +7 -1
- package/console.js +45 -183
- package/console.js.map +7 -1
- package/dataSourceUtils.js +45 -140
- package/dataSourceUtils.js.map +7 -1
- package/domUtils.js +58 -122
- package/domUtils.js.map +7 -1
- package/hocUtils.js +45 -122
- package/hocUtils.js.map +7 -1
- package/i18n.js +168 -323
- package/i18n.js.map +7 -1
- package/iconUtils.js +47 -178
- package/iconUtils.js.map +7 -1
- package/mapUtils.js +45 -122
- package/mapUtils.js.map +7 -1
- package/numberUtils.js +101 -275
- package/numberUtils.js.map +7 -1
- package/package.json +18 -22
- package/previewVizMessage.js +28 -108
- package/previewVizMessage.js.map +7 -1
- package/propUtils.js +88 -212
- package/propUtils.js.map +7 -1
- package/schemaUtils.js +58 -185
- package/schemaUtils.js.map +7 -1
- package/simpleXMLOptions.js +142 -225
- package/simpleXMLOptions.js.map +7 -1
- package/style.js +65 -168
- package/style.js.map +7 -1
- package/testHelper.js +247 -303
- package/testHelper.js.map +7 -1
- package/themeUtils.js +63 -142
- package/themeUtils.js.map +7 -1
- package/trellisUtils.js +108 -276
- package/trellisUtils.js.map +7 -1
package/RemoteIcon.js
CHANGED
|
@@ -1,766 +1,302 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
/******/ }
|
|
54
|
-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
55
|
-
/******/ };
|
|
56
|
-
/******/
|
|
57
|
-
/******/ // create a fake namespace object
|
|
58
|
-
/******/ // mode & 1: value is a module id, require it
|
|
59
|
-
/******/ // mode & 2: merge all properties of value into the ns
|
|
60
|
-
/******/ // mode & 4: return value when already ns object
|
|
61
|
-
/******/ // mode & 8|1: behave like require
|
|
62
|
-
/******/ __webpack_require__.t = function(value, mode) {
|
|
63
|
-
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
64
|
-
/******/ if(mode & 8) return value;
|
|
65
|
-
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
66
|
-
/******/ var ns = Object.create(null);
|
|
67
|
-
/******/ __webpack_require__.r(ns);
|
|
68
|
-
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
69
|
-
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
70
|
-
/******/ return ns;
|
|
71
|
-
/******/ };
|
|
72
|
-
/******/
|
|
73
|
-
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
74
|
-
/******/ __webpack_require__.n = function(module) {
|
|
75
|
-
/******/ var getter = module && module.__esModule ?
|
|
76
|
-
/******/ function getDefault() { return module['default']; } :
|
|
77
|
-
/******/ function getModuleExports() { return module; };
|
|
78
|
-
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
79
|
-
/******/ return getter;
|
|
80
|
-
/******/ };
|
|
81
|
-
/******/
|
|
82
|
-
/******/ // Object.prototype.hasOwnProperty.call
|
|
83
|
-
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
84
|
-
/******/
|
|
85
|
-
/******/ // __webpack_public_path__
|
|
86
|
-
/******/ __webpack_require__.p = "";
|
|
87
|
-
/******/
|
|
88
|
-
/******/
|
|
89
|
-
/******/ // Load entry module and return exports
|
|
90
|
-
/******/ return __webpack_require__(__webpack_require__.s = 44);
|
|
91
|
-
/******/ })
|
|
92
|
-
/************************************************************************/
|
|
93
|
-
/******/ ([
|
|
94
|
-
/* 0 */
|
|
95
|
-
/***/ (function(module, exports) {
|
|
96
|
-
|
|
97
|
-
module.exports = require("prop-types");
|
|
98
|
-
|
|
99
|
-
/***/ }),
|
|
100
|
-
/* 1 */
|
|
101
|
-
/***/ (function(module, exports) {
|
|
102
|
-
|
|
103
|
-
module.exports = require("react");
|
|
104
|
-
|
|
105
|
-
/***/ }),
|
|
106
|
-
/* 2 */
|
|
107
|
-
/***/ (function(module, exports) {
|
|
108
|
-
|
|
109
|
-
module.exports = require("@babel/runtime/helpers/defineProperty");
|
|
110
|
-
|
|
111
|
-
/***/ }),
|
|
112
|
-
/* 3 */
|
|
113
|
-
/***/ (function(module, exports) {
|
|
114
|
-
|
|
115
|
-
module.exports = require("@babel/runtime/helpers/getPrototypeOf");
|
|
116
|
-
|
|
117
|
-
/***/ }),
|
|
118
|
-
/* 4 */,
|
|
119
|
-
/* 5 */
|
|
120
|
-
/***/ (function(module, exports) {
|
|
121
|
-
|
|
122
|
-
module.exports = require("@babel/runtime/helpers/classCallCheck");
|
|
123
|
-
|
|
124
|
-
/***/ }),
|
|
125
|
-
/* 6 */
|
|
126
|
-
/***/ (function(module, exports) {
|
|
127
|
-
|
|
128
|
-
module.exports = require("@babel/runtime/helpers/createClass");
|
|
129
|
-
|
|
130
|
-
/***/ }),
|
|
131
|
-
/* 7 */
|
|
132
|
-
/***/ (function(module, exports) {
|
|
133
|
-
|
|
134
|
-
module.exports = require("@babel/runtime/helpers/inherits");
|
|
135
|
-
|
|
136
|
-
/***/ }),
|
|
137
|
-
/* 8 */
|
|
138
|
-
/***/ (function(module, exports) {
|
|
139
|
-
|
|
140
|
-
module.exports = require("@babel/runtime/helpers/possibleConstructorReturn");
|
|
141
|
-
|
|
142
|
-
/***/ }),
|
|
143
|
-
/* 9 */
|
|
144
|
-
/***/ (function(module, exports) {
|
|
145
|
-
|
|
146
|
-
module.exports = require("@splunk/ui-utils/i18n");
|
|
147
|
-
|
|
148
|
-
/***/ }),
|
|
149
|
-
/* 10 */
|
|
150
|
-
/***/ (function(module, exports) {
|
|
151
|
-
|
|
152
|
-
module.exports = require("@babel/runtime/regenerator");
|
|
153
|
-
|
|
154
|
-
/***/ }),
|
|
155
|
-
/* 11 */,
|
|
156
|
-
/* 12 */
|
|
157
|
-
/***/ (function(module, exports) {
|
|
158
|
-
|
|
159
|
-
module.exports = require("@babel/runtime/helpers/slicedToArray");
|
|
160
|
-
|
|
161
|
-
/***/ }),
|
|
162
|
-
/* 13 */
|
|
163
|
-
/***/ (function(module, exports) {
|
|
164
|
-
|
|
165
|
-
module.exports = require("@babel/runtime/helpers/taggedTemplateLiteral");
|
|
166
|
-
|
|
167
|
-
/***/ }),
|
|
168
|
-
/* 14 */
|
|
169
|
-
/***/ (function(module, exports) {
|
|
170
|
-
|
|
171
|
-
module.exports = require("styled-components");
|
|
172
|
-
|
|
173
|
-
/***/ }),
|
|
174
|
-
/* 15 */,
|
|
175
|
-
/* 16 */,
|
|
176
|
-
/* 17 */
|
|
177
|
-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
178
|
-
|
|
179
|
-
"use strict";
|
|
180
|
-
__webpack_require__.r(__webpack_exports__);
|
|
181
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toPx", function() { return toPx; });
|
|
182
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toDimension", function() { return toDimension; });
|
|
183
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "arrayToCSSProp", function() { return arrayToCSSProp; });
|
|
184
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toMargin", function() { return toMargin; });
|
|
185
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toPadding", function() { return toPadding; });
|
|
186
|
-
/* harmony import */ var lodash_isNumber__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(18);
|
|
187
|
-
/* harmony import */ var lodash_isNumber__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_isNumber__WEBPACK_IMPORTED_MODULE_0__);
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* convert number to px
|
|
191
|
-
* @param {*} number
|
|
192
|
-
*/
|
|
193
|
-
|
|
194
|
-
var toPx = function toPx(number) {
|
|
195
|
-
var defaultNumber = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
196
|
-
return lodash_isNumber__WEBPACK_IMPORTED_MODULE_0___default()(number) ? "".concat(number, "px") : number || toPx(defaultNumber);
|
|
1
|
+
/* Copyright © 2020 Splunk Inc.
|
|
2
|
+
SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
|
|
3
|
+
in part without a valid written license from Splunk Inc. is PROHIBITED. */
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
+
mod
|
|
31
|
+
));
|
|
32
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
34
|
+
var __async = (__this, __arguments, generator) => {
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
var fulfilled = (value) => {
|
|
37
|
+
try {
|
|
38
|
+
step(generator.next(value));
|
|
39
|
+
} catch (e) {
|
|
40
|
+
reject(e);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var rejected = (value) => {
|
|
44
|
+
try {
|
|
45
|
+
step(generator.throw(value));
|
|
46
|
+
} catch (e) {
|
|
47
|
+
reject(e);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
51
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
52
|
+
});
|
|
197
53
|
};
|
|
198
|
-
/**
|
|
199
|
-
* generate width/height css properties
|
|
200
|
-
* @param {*} param0
|
|
201
|
-
*/
|
|
202
54
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
55
|
+
// src/RemoteIcon.jsx
|
|
56
|
+
var RemoteIcon_exports = {};
|
|
57
|
+
__export(RemoteIcon_exports, {
|
|
58
|
+
default: () => RemoteIcon_default
|
|
59
|
+
});
|
|
60
|
+
module.exports = __toCommonJS(RemoteIcon_exports);
|
|
207
61
|
|
|
62
|
+
// esm-externals:react
|
|
63
|
+
var react_exports = {};
|
|
64
|
+
__export(react_exports, {
|
|
65
|
+
default: () => react_default
|
|
66
|
+
});
|
|
67
|
+
var defaultImport = __toESM(require("react"));
|
|
68
|
+
__reExport(react_exports, require("react"));
|
|
69
|
+
var react_default = "default" in defaultImport ? defaultImport.default : defaultImport;
|
|
70
|
+
|
|
71
|
+
// esm-externals:prop-types
|
|
72
|
+
var prop_types_exports = {};
|
|
73
|
+
__export(prop_types_exports, {
|
|
74
|
+
default: () => prop_types_default
|
|
75
|
+
});
|
|
76
|
+
var defaultImport2 = __toESM(require("prop-types"));
|
|
77
|
+
__reExport(prop_types_exports, require("prop-types"));
|
|
78
|
+
var prop_types_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;
|
|
79
|
+
|
|
80
|
+
// esm-externals:styled-components
|
|
81
|
+
var styled_components_exports = {};
|
|
82
|
+
__export(styled_components_exports, {
|
|
83
|
+
default: () => styled_components_default
|
|
84
|
+
});
|
|
85
|
+
var defaultImport3 = __toESM(require("styled-components"));
|
|
86
|
+
__reExport(styled_components_exports, require("styled-components"));
|
|
87
|
+
var styled_components_default = "default" in defaultImport3 ? defaultImport3.default : defaultImport3;
|
|
88
|
+
|
|
89
|
+
// esm-externals:xmlserializer
|
|
90
|
+
var xmlserializer_exports = {};
|
|
91
|
+
__export(xmlserializer_exports, {
|
|
92
|
+
default: () => xmlserializer_default
|
|
93
|
+
});
|
|
94
|
+
var defaultImport4 = __toESM(require("xmlserializer"));
|
|
95
|
+
__reExport(xmlserializer_exports, require("xmlserializer"));
|
|
96
|
+
var xmlserializer_default = "default" in defaultImport4 ? defaultImport4.default : defaultImport4;
|
|
97
|
+
|
|
98
|
+
// esm-externals:@splunk/ui-utils/i18n
|
|
99
|
+
var i18n_exports = {};
|
|
100
|
+
__export(i18n_exports, {
|
|
101
|
+
default: () => i18n_default
|
|
102
|
+
});
|
|
103
|
+
var defaultImport5 = __toESM(require("@splunk/ui-utils/i18n"));
|
|
104
|
+
__reExport(i18n_exports, require("@splunk/ui-utils/i18n"));
|
|
105
|
+
var i18n_default = "default" in defaultImport5 ? defaultImport5.default : defaultImport5;
|
|
106
|
+
|
|
107
|
+
// esm-externals:@splunk/visualization-context/IconContext
|
|
108
|
+
var IconContext_exports = {};
|
|
109
|
+
__export(IconContext_exports, {
|
|
110
|
+
default: () => IconContext_default
|
|
111
|
+
});
|
|
112
|
+
var defaultImport6 = __toESM(require("@splunk/visualization-context/IconContext"));
|
|
113
|
+
__reExport(IconContext_exports, require("@splunk/visualization-context/IconContext"));
|
|
114
|
+
var IconContext_default = "default" in defaultImport6 ? defaultImport6.default : defaultImport6;
|
|
115
|
+
|
|
116
|
+
// esm-externals:lodash/isNumber
|
|
117
|
+
var isNumber_exports = {};
|
|
118
|
+
__export(isNumber_exports, {
|
|
119
|
+
default: () => isNumber_default
|
|
120
|
+
});
|
|
121
|
+
var defaultImport7 = __toESM(require("lodash/isNumber"));
|
|
122
|
+
__reExport(isNumber_exports, require("lodash/isNumber"));
|
|
123
|
+
var isNumber_default = "default" in defaultImport7 ? defaultImport7.default : defaultImport7;
|
|
124
|
+
|
|
125
|
+
// src/style.js
|
|
126
|
+
var toPx = (number, defaultNumber = 0) => isNumber_default(number) ? `${number}px` : number || toPx(defaultNumber);
|
|
127
|
+
var toDimension = ({ width, height }) => {
|
|
128
|
+
let css = "";
|
|
208
129
|
if (width) {
|
|
209
|
-
css =
|
|
130
|
+
css = `width: ${toPx(width)};`;
|
|
210
131
|
}
|
|
211
|
-
|
|
212
132
|
if (height) {
|
|
213
|
-
|
|
214
|
-
css = "".concat(css).concat(width ? '\n' : '', "height: ").concat(toPx(height), ";");
|
|
133
|
+
css = `${css}${width ? "\n" : ""}height: ${toPx(height)};`;
|
|
215
134
|
}
|
|
216
|
-
|
|
217
135
|
return css;
|
|
218
136
|
};
|
|
219
|
-
/**
|
|
220
|
-
* generate margin css property
|
|
221
|
-
*/
|
|
222
|
-
|
|
223
|
-
var arrayToCSSProp = function arrayToCSSProp(prop) {
|
|
224
|
-
var vals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0, 0];
|
|
225
|
-
|
|
226
|
-
if (Array.isArray(vals)) {
|
|
227
|
-
return "\n ".concat(prop, ": ").concat(toPx(vals[0]), " ").concat(toPx(vals[1]), " ").concat(toPx(vals[2]), " ").concat(toPx(vals[3]), ";\n ");
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
return "".concat(prop, ": ").concat(toPx(vals), ";");
|
|
231
|
-
};
|
|
232
|
-
/**
|
|
233
|
-
* generate margin css property
|
|
234
|
-
*/
|
|
235
|
-
|
|
236
|
-
var toMargin = function toMargin() {
|
|
237
|
-
var margins = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [0, 0, 0, 0];
|
|
238
|
-
return arrayToCSSProp('margin', margins);
|
|
239
|
-
};
|
|
240
|
-
/**
|
|
241
|
-
* generate padding css property
|
|
242
|
-
*/
|
|
243
|
-
|
|
244
|
-
var toPadding = function toPadding() {
|
|
245
|
-
var paddings = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [0, 0, 0, 0];
|
|
246
|
-
return arrayToCSSProp('padding', paddings);
|
|
247
|
-
};
|
|
248
137
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
/***/ }),
|
|
256
|
-
/* 19 */
|
|
257
|
-
/***/ (function(module, exports) {
|
|
258
|
-
|
|
259
|
-
module.exports = require("@babel/runtime/helpers/asyncToGenerator");
|
|
260
|
-
|
|
261
|
-
/***/ }),
|
|
262
|
-
/* 20 */
|
|
263
|
-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
264
|
-
|
|
265
|
-
"use strict";
|
|
266
|
-
__webpack_require__.r(__webpack_exports__);
|
|
267
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isRemoteIcon", function() { return isRemoteIcon; });
|
|
268
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isDataURI", function() { return isDataURI; });
|
|
269
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shouldChangeFill", function() { return shouldChangeFill; });
|
|
270
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shouldChangeStroke", function() { return shouldChangeStroke; });
|
|
271
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b64EncodeUnicode", function() { return b64EncodeUnicode; });
|
|
272
|
-
/**
|
|
273
|
-
* check if an icon is considered as remote icon
|
|
274
|
-
* @param {*} icon
|
|
275
|
-
*/
|
|
276
|
-
var isRemoteIcon = function isRemoteIcon() {
|
|
277
|
-
var icon = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
278
|
-
return icon.indexOf('://') > -1;
|
|
279
|
-
};
|
|
280
|
-
/**
|
|
281
|
-
* check if an icon is a dataURI
|
|
282
|
-
* @param {*} icon
|
|
283
|
-
*/
|
|
284
|
-
|
|
285
|
-
var isDataURI = function isDataURI() {
|
|
286
|
-
var icon = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
287
|
-
return icon.startsWith('data:image/svg+xml;base64');
|
|
288
|
-
};
|
|
289
|
-
/*
|
|
290
|
-
* check whether need update fill for svg children elements
|
|
291
|
-
* @params {Object} style
|
|
292
|
-
* @params {String} style.fillAttr <path fill="red" .../>
|
|
293
|
-
* @params {String} style.fillStyle. <path style="fill: red;" />
|
|
294
|
-
* @params {String} style.strokeAttr. <path stroke="red" .../>
|
|
295
|
-
* @params {String} style.strokeStyle <path style="stroke: red;" .../>
|
|
296
|
-
* @returns {Boolean} true means need
|
|
297
|
-
* remove fill style and change the fill attribute <path fill="currentColor" />
|
|
298
|
-
*/
|
|
299
|
-
|
|
300
|
-
var shouldChangeFill = function shouldChangeFill(_ref) {
|
|
301
|
-
var fillAttr = _ref.fillAttr,
|
|
302
|
-
fillStyle = _ref.fillStyle,
|
|
303
|
-
strokeAttr = _ref.strokeAttr,
|
|
304
|
-
strokeStyle = _ref.strokeStyle;
|
|
305
|
-
var noneFillAttr = !!fillAttr && (fillAttr === 'none' || fillAttr === 'transparent');
|
|
306
|
-
var noneFillStyle = !!fillStyle && (fillStyle === 'none' || fillStyle === 'transparent');
|
|
307
|
-
var noFillHasStroke = !fillAttr && !fillStyle && (!!strokeAttr || !!strokeStyle);
|
|
138
|
+
// src/iconUtils.js
|
|
139
|
+
var shouldChangeFill = ({ fillAttr, fillStyle, strokeAttr, strokeStyle }) => {
|
|
140
|
+
const noneFillAttr = !!fillAttr && (fillAttr === "none" || fillAttr === "transparent");
|
|
141
|
+
const noneFillStyle = !!fillStyle && (fillStyle === "none" || fillStyle === "transparent");
|
|
142
|
+
const noFillHasStroke = !fillAttr && !fillStyle && (!!strokeAttr || !!strokeStyle);
|
|
308
143
|
return !(noneFillAttr || noneFillStyle || noFillHasStroke);
|
|
309
144
|
};
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
* @params {String} style.strokeAttr. <path stroke="red" .../>
|
|
316
|
-
* @params {String} style.strokeStyle <path style="stroke: red;" .../>
|
|
317
|
-
* @returns {Boolean} true means need
|
|
318
|
-
* remove stroke style and change the stroke attribute <path stroke="currentColor" />
|
|
319
|
-
*/
|
|
320
|
-
|
|
321
|
-
var shouldChangeStroke = function shouldChangeStroke(_ref2) {
|
|
322
|
-
var fillAttr = _ref2.fillAttr,
|
|
323
|
-
fillStyle = _ref2.fillStyle,
|
|
324
|
-
strokeAttr = _ref2.strokeAttr,
|
|
325
|
-
strokeStyle = _ref2.strokeStyle;
|
|
326
|
-
var noneStrokeAttr = !!strokeAttr && (strokeAttr === 'none' || strokeAttr === 'transparent');
|
|
327
|
-
var noneStrokeStyle = !!strokeStyle && (strokeStyle === 'none' || strokeStyle === 'transparent');
|
|
328
|
-
var hasFill = !!fillAttr || !!fillStyle;
|
|
329
|
-
var noStroke = !strokeAttr && !strokeStyle;
|
|
145
|
+
var shouldChangeStroke = ({ fillAttr, fillStyle, strokeAttr, strokeStyle }) => {
|
|
146
|
+
const noneStrokeAttr = !!strokeAttr && (strokeAttr === "none" || strokeAttr === "transparent");
|
|
147
|
+
const noneStrokeStyle = !!strokeStyle && (strokeStyle === "none" || strokeStyle === "transparent");
|
|
148
|
+
const hasFill = !!fillAttr || !!fillStyle;
|
|
149
|
+
const noStroke = !strokeAttr && !strokeStyle;
|
|
330
150
|
return !(noneStrokeAttr || noneStrokeStyle || hasFill || noStroke);
|
|
331
151
|
};
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
/* 25 */,
|
|
354
|
-
/* 26 */,
|
|
355
|
-
/* 27 */,
|
|
356
|
-
/* 28 */
|
|
357
|
-
/***/ (function(module, exports) {
|
|
358
|
-
|
|
359
|
-
module.exports = require("xmlserializer");
|
|
360
|
-
|
|
361
|
-
/***/ }),
|
|
362
|
-
/* 29 */
|
|
363
|
-
/***/ (function(module, exports) {
|
|
364
|
-
|
|
365
|
-
module.exports = require("@splunk/visualization-context/IconContext");
|
|
366
|
-
|
|
367
|
-
/***/ }),
|
|
368
|
-
/* 30 */,
|
|
369
|
-
/* 31 */,
|
|
370
|
-
/* 32 */,
|
|
371
|
-
/* 33 */,
|
|
372
|
-
/* 34 */,
|
|
373
|
-
/* 35 */,
|
|
374
|
-
/* 36 */,
|
|
375
|
-
/* 37 */,
|
|
376
|
-
/* 38 */,
|
|
377
|
-
/* 39 */,
|
|
378
|
-
/* 40 */,
|
|
379
|
-
/* 41 */,
|
|
380
|
-
/* 42 */,
|
|
381
|
-
/* 43 */,
|
|
382
|
-
/* 44 */
|
|
383
|
-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
384
|
-
|
|
385
|
-
"use strict";
|
|
386
|
-
__webpack_require__.r(__webpack_exports__);
|
|
387
|
-
/* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(12);
|
|
388
|
-
/* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0__);
|
|
389
|
-
/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(19);
|
|
390
|
-
/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1__);
|
|
391
|
-
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5);
|
|
392
|
-
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_2__);
|
|
393
|
-
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6);
|
|
394
|
-
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_3__);
|
|
395
|
-
/* harmony import */ var _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7);
|
|
396
|
-
/* harmony import */ var _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_4__);
|
|
397
|
-
/* harmony import */ var _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8);
|
|
398
|
-
/* harmony import */ var _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_5__);
|
|
399
|
-
/* harmony import */ var _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(3);
|
|
400
|
-
/* harmony import */ var _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_6__);
|
|
401
|
-
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(2);
|
|
402
|
-
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7__);
|
|
403
|
-
/* harmony import */ var _babel_runtime_helpers_taggedTemplateLiteral__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(13);
|
|
404
|
-
/* harmony import */ var _babel_runtime_helpers_taggedTemplateLiteral__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_taggedTemplateLiteral__WEBPACK_IMPORTED_MODULE_8__);
|
|
405
|
-
/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(10);
|
|
406
|
-
/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_9__);
|
|
407
|
-
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(1);
|
|
408
|
-
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_10__);
|
|
409
|
-
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(0);
|
|
410
|
-
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_11__);
|
|
411
|
-
/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(14);
|
|
412
|
-
/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(styled_components__WEBPACK_IMPORTED_MODULE_12__);
|
|
413
|
-
/* harmony import */ var xmlserializer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(28);
|
|
414
|
-
/* harmony import */ var xmlserializer__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(xmlserializer__WEBPACK_IMPORTED_MODULE_13__);
|
|
415
|
-
/* harmony import */ var _splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(9);
|
|
416
|
-
/* harmony import */ var _splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_14__);
|
|
417
|
-
/* harmony import */ var _splunk_visualization_context_IconContext__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(29);
|
|
418
|
-
/* harmony import */ var _splunk_visualization_context_IconContext__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(_splunk_visualization_context_IconContext__WEBPACK_IMPORTED_MODULE_15__);
|
|
419
|
-
/* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(17);
|
|
420
|
-
/* harmony import */ var _iconUtils__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(20);
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
var _templateObject, _templateObject2;
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
function _createSuper(Derived) {
|
|
436
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
437
|
-
|
|
438
|
-
return function _createSuperInternal() {
|
|
439
|
-
var Super = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_6___default()(Derived),
|
|
440
|
-
result;
|
|
441
|
-
|
|
442
|
-
if (hasNativeReflectConstruct) {
|
|
443
|
-
var NewTarget = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_6___default()(this).constructor;
|
|
444
|
-
|
|
445
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
446
|
-
} else {
|
|
447
|
-
result = Super.apply(this, arguments);
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
return _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_5___default()(this, result);
|
|
451
|
-
};
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
function _isNativeReflectConstruct() {
|
|
455
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
456
|
-
if (Reflect.construct.sham) return false;
|
|
457
|
-
if (typeof Proxy === "function") return true;
|
|
458
|
-
|
|
459
|
-
try {
|
|
460
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
461
|
-
return true;
|
|
462
|
-
} catch (e) {
|
|
463
|
-
return false;
|
|
152
|
+
var b64EncodeUnicode = (str) => (
|
|
153
|
+
// first we use encodeURIComponent to get percent-encoded UTF-8,
|
|
154
|
+
// then we convert the percent encodings into raw bytes which
|
|
155
|
+
// can be fed into btoa.
|
|
156
|
+
btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (match, p1) => String.fromCharCode(`0x${p1}`)))
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
// src/RemoteIcon.jsx
|
|
160
|
+
var IconContainer = styled_components_default.div`
|
|
161
|
+
${(props) => toDimension({ width: props.width, height: props.height })};
|
|
162
|
+
margin: auto;
|
|
163
|
+
cursor: ${(props) => props.onClick ? "pointer" : "inherit"};
|
|
164
|
+
`;
|
|
165
|
+
var ColoredIcon = styled_components_default.img`
|
|
166
|
+
${(props) => toDimension({ width: props.width, height: props.height })};
|
|
167
|
+
opacity: ${(props) => props.opacity || 1};
|
|
168
|
+
`;
|
|
169
|
+
var _RemoteIcon = class _RemoteIcon extends react_exports.PureComponent {
|
|
170
|
+
constructor(props) {
|
|
171
|
+
super(props);
|
|
172
|
+
this.state = { iconDataURI: null };
|
|
464
173
|
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
var IconContainer = styled_components__WEBPACK_IMPORTED_MODULE_12___default.a.div(_templateObject || (_templateObject = _babel_runtime_helpers_taggedTemplateLiteral__WEBPACK_IMPORTED_MODULE_8___default()(["\n ", ";\n margin: auto;\n cursor: ", ";\n"])), function (props) {
|
|
478
|
-
return Object(_style__WEBPACK_IMPORTED_MODULE_16__["toDimension"])({
|
|
479
|
-
width: props.width,
|
|
480
|
-
height: props.height
|
|
481
|
-
});
|
|
482
|
-
}, function (props) {
|
|
483
|
-
return props.onClick ? 'pointer' : 'inherit';
|
|
484
|
-
});
|
|
485
|
-
var ColoredIcon = styled_components__WEBPACK_IMPORTED_MODULE_12___default.a.img(_templateObject2 || (_templateObject2 = _babel_runtime_helpers_taggedTemplateLiteral__WEBPACK_IMPORTED_MODULE_8___default()(["\n ", ";\n opacity: ", ";\n"])), function (props) {
|
|
486
|
-
return Object(_style__WEBPACK_IMPORTED_MODULE_16__["toDimension"])({
|
|
487
|
-
width: props.width,
|
|
488
|
-
height: props.height
|
|
489
|
-
});
|
|
490
|
-
}, function (props) {
|
|
491
|
-
return props.opacity || 1.0;
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
var RemoteIcon = /*#__PURE__*/function (_PureComponent) {
|
|
495
|
-
_babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_4___default()(RemoteIcon, _PureComponent);
|
|
496
|
-
|
|
497
|
-
var _super = _createSuper(RemoteIcon);
|
|
498
|
-
|
|
499
|
-
function RemoteIcon(props) {
|
|
500
|
-
var _this;
|
|
501
|
-
|
|
502
|
-
_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_2___default()(this, RemoteIcon);
|
|
503
|
-
|
|
504
|
-
_this = _super.call(this, props);
|
|
505
|
-
_this.state = {
|
|
506
|
-
iconDataURI: null
|
|
507
|
-
};
|
|
508
|
-
return _this;
|
|
509
|
-
} // eslint-disable-next-line camelcase
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_3___default()(RemoteIcon, [{
|
|
513
|
-
key: "UNSAFE_componentWillMount",
|
|
514
|
-
value: function UNSAFE_componentWillMount() {
|
|
174
|
+
// eslint-disable-next-line camelcase
|
|
175
|
+
UNSAFE_componentWillMount() {
|
|
176
|
+
this.getIcon(this.props.iconURL, this.props.color);
|
|
177
|
+
}
|
|
178
|
+
componentDidUpdate(prevProps) {
|
|
179
|
+
if (prevProps.iconURL !== this.props.iconURL || prevProps.color !== this.props.color) {
|
|
515
180
|
this.getIcon(this.props.iconURL, this.props.color);
|
|
516
181
|
}
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
var _this2 = this;
|
|
535
|
-
|
|
536
|
-
var getIconDataURI, iconDataURI;
|
|
537
|
-
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_9___default.a.wrap(function _callee2$(_context2) {
|
|
538
|
-
while (1) {
|
|
539
|
-
switch (_context2.prev = _context2.next) {
|
|
540
|
-
case 0:
|
|
541
|
-
getIconDataURI = /*#__PURE__*/function () {
|
|
542
|
-
var _ref = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_9___default.a.mark(function _callee() {
|
|
543
|
-
var iconRegistry, icon;
|
|
544
|
-
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_9___default.a.wrap(function _callee$(_context) {
|
|
545
|
-
while (1) {
|
|
546
|
-
switch (_context.prev = _context.next) {
|
|
547
|
-
case 0:
|
|
548
|
-
if (!_this2.isRegistryURL(iconURL)) {
|
|
549
|
-
_context.next = 15;
|
|
550
|
-
break;
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
iconRegistry = _this2.context;
|
|
554
|
-
|
|
555
|
-
if (!iconRegistry) {
|
|
556
|
-
_context.next = 13;
|
|
557
|
-
break;
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
_context.prev = 3;
|
|
561
|
-
_context.next = 6;
|
|
562
|
-
return iconRegistry.getByURL(iconURL);
|
|
563
|
-
|
|
564
|
-
case 6:
|
|
565
|
-
icon = _context.sent;
|
|
566
|
-
return _context.abrupt("return", icon.dataURI);
|
|
567
|
-
|
|
568
|
-
case 10:
|
|
569
|
-
_context.prev = 10;
|
|
570
|
-
_context.t0 = _context["catch"](3); // eslint-disable-next-line no-console
|
|
571
|
-
|
|
572
|
-
console.error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_14__["_"])(_context.t0));
|
|
573
|
-
|
|
574
|
-
case 13:
|
|
575
|
-
_context.next = 16;
|
|
576
|
-
break;
|
|
577
|
-
|
|
578
|
-
case 15:
|
|
579
|
-
return _context.abrupt("return", iconURL);
|
|
580
|
-
|
|
581
|
-
case 16:
|
|
582
|
-
return _context.abrupt("return", null);
|
|
583
|
-
|
|
584
|
-
case 17:
|
|
585
|
-
case "end":
|
|
586
|
-
return _context.stop();
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
}, _callee, null, [[3, 10]]);
|
|
590
|
-
}));
|
|
591
|
-
|
|
592
|
-
return function getIconDataURI() {
|
|
593
|
-
return _ref.apply(this, arguments);
|
|
594
|
-
};
|
|
595
|
-
}();
|
|
596
|
-
|
|
597
|
-
_context2.next = 3;
|
|
598
|
-
return getIconDataURI();
|
|
599
|
-
|
|
600
|
-
case 3:
|
|
601
|
-
iconDataURI = _context2.sent;
|
|
602
|
-
|
|
603
|
-
if (color) {
|
|
604
|
-
this.colorIcon(iconDataURI, color);
|
|
605
|
-
} else {
|
|
606
|
-
this.setState({
|
|
607
|
-
iconDataURI: iconDataURI
|
|
608
|
-
});
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
case 5:
|
|
612
|
-
case "end":
|
|
613
|
-
return _context2.stop();
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Check if the iconURL is a registry URL/dataURI/direct URL and fetch from the registry when required
|
|
185
|
+
* @param {String} iconURL
|
|
186
|
+
* @param {String} color
|
|
187
|
+
*/
|
|
188
|
+
getIcon(iconURL, color) {
|
|
189
|
+
return __async(this, null, function* () {
|
|
190
|
+
const getIconDataURI = () => __async(this, null, function* () {
|
|
191
|
+
if (this.isRegistryURL(iconURL)) {
|
|
192
|
+
const iconRegistry = this.context;
|
|
193
|
+
if (iconRegistry) {
|
|
194
|
+
try {
|
|
195
|
+
const icon = yield iconRegistry.getByURL(iconURL);
|
|
196
|
+
return icon.dataURI;
|
|
197
|
+
} catch (error) {
|
|
198
|
+
console.error((0, i18n_exports._)(error));
|
|
614
199
|
}
|
|
615
200
|
}
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
201
|
+
} else {
|
|
202
|
+
return iconURL;
|
|
203
|
+
}
|
|
204
|
+
return null;
|
|
205
|
+
});
|
|
206
|
+
const iconDataURI = yield getIconDataURI();
|
|
207
|
+
if (color) {
|
|
208
|
+
this.colorIcon(iconDataURI, color);
|
|
209
|
+
} else {
|
|
210
|
+
this.setState({ iconDataURI });
|
|
621
211
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
var children = svg.querySelectorAll('*');
|
|
667
|
-
svg.style.color = color; // Todo: need move this to IconRegistry after figure out the jest issue with XMLSerializer
|
|
668
|
-
|
|
669
|
-
for (var i = 0; i < children.length; i += 1) {
|
|
670
|
-
var child = children[i];
|
|
671
|
-
|
|
672
|
-
if (RemoteIcon.BASIC_SHAPES.includes(child.tagName)) {
|
|
673
|
-
var fillAttr = child.getAttribute('fill');
|
|
674
|
-
var fillStyle = child.style && child.style.fill;
|
|
675
|
-
var strokeAttr = child.getAttribute('stroke');
|
|
676
|
-
var strokeStyle = child.style && child.style.stroke;
|
|
677
|
-
|
|
678
|
-
if (Object(_iconUtils__WEBPACK_IMPORTED_MODULE_17__["shouldChangeFill"])({
|
|
679
|
-
fillAttr: fillAttr,
|
|
680
|
-
fillStyle: fillStyle,
|
|
681
|
-
strokeAttr: strokeAttr,
|
|
682
|
-
strokeStyle: strokeStyle
|
|
683
|
-
})) {
|
|
684
|
-
child.style.fill = '';
|
|
685
|
-
child.setAttribute('fill', 'currentColor');
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
if (Object(_iconUtils__WEBPACK_IMPORTED_MODULE_17__["shouldChangeStroke"])({
|
|
689
|
-
fillAttr: fillAttr,
|
|
690
|
-
fillStyle: fillStyle,
|
|
691
|
-
strokeAttr: strokeAttr,
|
|
692
|
-
strokeStyle: strokeStyle
|
|
693
|
-
})) {
|
|
694
|
-
child.style.stroke = '';
|
|
695
|
-
child.setAttribute('stroke', 'currentColor');
|
|
696
|
-
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* check if icon is a registry url
|
|
216
|
+
* @param {String} src
|
|
217
|
+
*/
|
|
218
|
+
isRegistryURL(src = "") {
|
|
219
|
+
const [type] = src.split("://");
|
|
220
|
+
return type !== "http" && type !== "https" && !src.startsWith("data:image/svg+xml;base64");
|
|
221
|
+
}
|
|
222
|
+
/*
|
|
223
|
+
* Color the icon:
|
|
224
|
+
* parse svg elements from the dataURI, change color style of svg, and change fill/stroke attribute/style of each svg basic shapes
|
|
225
|
+
* in the svg element to currentColor. At the end, convert the modified svg back to dataURI string.
|
|
226
|
+
*
|
|
227
|
+
* Limitation:
|
|
228
|
+
* if the svg is created with multiple pathes with different fill attributes, this method would
|
|
229
|
+
* convert all pathes' fill attribute to the color prop. It may change the view of the svg icon.
|
|
230
|
+
*
|
|
231
|
+
* @method colorIcon
|
|
232
|
+
* @params {DataURI} dataURI
|
|
233
|
+
* @params {String} color e.g. 'red' || '#ffffff'
|
|
234
|
+
*/
|
|
235
|
+
colorIcon(dataURI, color) {
|
|
236
|
+
fetch(dataURI).then((response) => response.text()).then((text) => {
|
|
237
|
+
const parser = new DOMParser();
|
|
238
|
+
const xmlDoc = parser.parseFromString(text, "text/xml");
|
|
239
|
+
const svg = xmlDoc.getElementsByTagName("svg")[0];
|
|
240
|
+
const children = svg.querySelectorAll("*");
|
|
241
|
+
svg.style.color = color;
|
|
242
|
+
for (let i = 0; i < children.length; i += 1) {
|
|
243
|
+
const child = children[i];
|
|
244
|
+
if (_RemoteIcon.BASIC_SHAPES.includes(child.tagName)) {
|
|
245
|
+
const fillAttr = child.getAttribute("fill");
|
|
246
|
+
const fillStyle = child.style && child.style.fill;
|
|
247
|
+
const strokeAttr = child.getAttribute("stroke");
|
|
248
|
+
const strokeStyle = child.style && child.style.stroke;
|
|
249
|
+
if (shouldChangeFill({ fillAttr, fillStyle, strokeAttr, strokeStyle })) {
|
|
250
|
+
child.style.fill = "";
|
|
251
|
+
child.setAttribute("fill", "currentColor");
|
|
252
|
+
}
|
|
253
|
+
if (shouldChangeStroke({ fillAttr, fillStyle, strokeAttr, strokeStyle })) {
|
|
254
|
+
child.style.stroke = "";
|
|
255
|
+
child.setAttribute("stroke", "currentColor");
|
|
697
256
|
}
|
|
698
257
|
}
|
|
699
|
-
|
|
700
|
-
var svgStr = Object(_iconUtils__WEBPACK_IMPORTED_MODULE_17__["b64EncodeUnicode"])(xmlserializer__WEBPACK_IMPORTED_MODULE_13___default.a.serializeToString(svg));
|
|
701
|
-
var iconDataURI = "data:image/svg+xml;base64,".concat(svgStr);
|
|
702
|
-
|
|
703
|
-
_this3.setState({
|
|
704
|
-
iconDataURI: iconDataURI
|
|
705
|
-
});
|
|
706
|
-
}).catch(function () {
|
|
707
|
-
// eslint-disable-next-line no-console
|
|
708
|
-
console.error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_14__["_"])('The icon cannot be colored properly.'));
|
|
709
|
-
});
|
|
710
|
-
}
|
|
711
|
-
}, {
|
|
712
|
-
key: "render",
|
|
713
|
-
value: function render() {
|
|
714
|
-
var iconDataURI = this.state.iconDataURI;
|
|
715
|
-
var _this$props = this.props,
|
|
716
|
-
width = _this$props.width,
|
|
717
|
-
height = _this$props.height,
|
|
718
|
-
opacity = _this$props.opacity,
|
|
719
|
-
onIconClick = _this$props.onIconClick;
|
|
720
|
-
|
|
721
|
-
if (!iconDataURI) {
|
|
722
|
-
return null;
|
|
723
258
|
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
259
|
+
const svgStr = b64EncodeUnicode(xmlserializer_default.serializeToString(svg));
|
|
260
|
+
const iconDataURI = `data:image/svg+xml;base64,${svgStr}`;
|
|
261
|
+
this.setState({ iconDataURI });
|
|
262
|
+
}).catch(() => {
|
|
263
|
+
console.error((0, i18n_exports._)("The icon cannot be colored properly."));
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
render() {
|
|
267
|
+
const { iconDataURI } = this.state;
|
|
268
|
+
const { width, height, opacity, onIconClick } = this.props;
|
|
269
|
+
if (!iconDataURI) {
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
return /* @__PURE__ */ react_default.createElement(IconContainer, { width, height, onClick: onIconClick }, /* @__PURE__ */ react_default.createElement(
|
|
273
|
+
ColoredIcon,
|
|
274
|
+
{
|
|
730
275
|
src: iconDataURI,
|
|
731
276
|
alt: "Remote Icon",
|
|
732
|
-
width
|
|
733
|
-
height
|
|
734
|
-
opacity
|
|
277
|
+
width,
|
|
278
|
+
height,
|
|
279
|
+
opacity,
|
|
735
280
|
referrerPolicy: "no-referrer"
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
width: prop_types__WEBPACK_IMPORTED_MODULE_11___default.a.number,
|
|
749
|
-
height: prop_types__WEBPACK_IMPORTED_MODULE_11___default.a.number,
|
|
750
|
-
opacity: prop_types__WEBPACK_IMPORTED_MODULE_11___default.a.number,
|
|
751
|
-
onIconClick: prop_types__WEBPACK_IMPORTED_MODULE_11___default.a.func
|
|
281
|
+
}
|
|
282
|
+
));
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
__publicField(_RemoteIcon, "contextType", IconContext_default);
|
|
286
|
+
__publicField(_RemoteIcon, "propTypes", {
|
|
287
|
+
iconURL: prop_types_default.string,
|
|
288
|
+
color: prop_types_default.string,
|
|
289
|
+
width: prop_types_default.number,
|
|
290
|
+
height: prop_types_default.number,
|
|
291
|
+
opacity: prop_types_default.number,
|
|
292
|
+
onIconClick: prop_types_default.func
|
|
752
293
|
});
|
|
753
|
-
|
|
754
|
-
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()(RemoteIcon, "defaultProps", {
|
|
294
|
+
__publicField(_RemoteIcon, "defaultProps", {
|
|
755
295
|
width: 100,
|
|
756
296
|
height: 100,
|
|
757
|
-
opacity: 1
|
|
297
|
+
opacity: 1
|
|
758
298
|
});
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
/***/ })
|
|
765
|
-
/******/ ]);
|
|
766
|
-
//# sourceMappingURL=RemoteIcon.js.map
|
|
299
|
+
__publicField(_RemoteIcon, "BASIC_SHAPES", ["path", "rect", "circle", "ellipse", "line", "polyline", "polygon"]);
|
|
300
|
+
var RemoteIcon = _RemoteIcon;
|
|
301
|
+
var RemoteIcon_default = RemoteIcon;
|
|
302
|
+
//# sourceMappingURL=RemoteIcon.js.map
|