@splunk/visualizations-shared 27.5.0 → 28.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/.eslintrc.json +5 -0
- package/AsyncStoryDecorator.js +64 -0
- package/AsyncStoryDecorator.js.map +7 -0
- package/Downloader.js +41 -40
- package/Downloader.js.map +2 -2
- package/FileDownloader.js +25 -40
- package/FileDownloader.js.map +2 -2
- package/Message.js +10 -41
- package/Message.js.map +4 -4
- package/RemoteIcon.js +35 -48
- package/RemoteIcon.js.map +4 -4
- package/RemoteImage.js +27 -43
- package/RemoteImage.js.map +4 -4
- package/SanitizeProps.js +1 -0
- package/SanitizeProps.js.map +2 -2
- package/SizeAwareWrapper.js +16 -29
- package/SizeAwareWrapper.js.map +3 -3
- package/VisualizationDocPage.js +34 -88
- package/VisualizationDocPage.js.map +4 -4
- package/colorConstants.js +5 -1
- package/colorConstants.js.map +2 -2
- package/i18n.js +12 -3
- package/i18n.js.map +2 -2
- package/numberUtils.js.map +2 -2
- package/package.json +21 -19
- package/SizeAwareWrapperDeprecated.js +0 -145
- package/SizeAwareWrapperDeprecated.js.map +0 -7
package/RemoteIcon.js
CHANGED
|
@@ -7,7 +7,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
7
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
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
10
|
var __export = (target, all) => {
|
|
12
11
|
for (var name in all)
|
|
13
12
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -30,7 +29,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
29
|
mod
|
|
31
30
|
));
|
|
32
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
34
32
|
var __async = (__this, __arguments, generator) => {
|
|
35
33
|
return new Promise((resolve, reject) => {
|
|
36
34
|
var fulfilled = (value) => {
|
|
@@ -52,7 +50,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
52
50
|
});
|
|
53
51
|
};
|
|
54
52
|
|
|
55
|
-
// src/RemoteIcon.
|
|
53
|
+
// src/RemoteIcon.tsx
|
|
56
54
|
var RemoteIcon_exports = {};
|
|
57
55
|
__export(RemoteIcon_exports, {
|
|
58
56
|
default: () => RemoteIcon_default
|
|
@@ -68,59 +66,50 @@ var defaultImport = __toESM(require("react"));
|
|
|
68
66
|
__reExport(react_exports, require("react"));
|
|
69
67
|
var react_default = "default" in defaultImport ? defaultImport.default : defaultImport;
|
|
70
68
|
|
|
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
69
|
// esm-externals:styled-components
|
|
81
70
|
var styled_components_exports = {};
|
|
82
71
|
__export(styled_components_exports, {
|
|
83
72
|
default: () => styled_components_default
|
|
84
73
|
});
|
|
85
|
-
var
|
|
74
|
+
var defaultImport2 = __toESM(require("styled-components"));
|
|
86
75
|
__reExport(styled_components_exports, require("styled-components"));
|
|
87
|
-
var styled_components_default = "default" in
|
|
76
|
+
var styled_components_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;
|
|
88
77
|
|
|
89
78
|
// esm-externals:xmlserializer
|
|
90
79
|
var xmlserializer_exports = {};
|
|
91
80
|
__export(xmlserializer_exports, {
|
|
92
81
|
default: () => xmlserializer_default
|
|
93
82
|
});
|
|
94
|
-
var
|
|
83
|
+
var defaultImport3 = __toESM(require("xmlserializer"));
|
|
95
84
|
__reExport(xmlserializer_exports, require("xmlserializer"));
|
|
96
|
-
var xmlserializer_default = "default" in
|
|
85
|
+
var xmlserializer_default = "default" in defaultImport3 ? defaultImport3.default : defaultImport3;
|
|
97
86
|
|
|
98
87
|
// esm-externals:@splunk/ui-utils/i18n
|
|
99
88
|
var i18n_exports = {};
|
|
100
89
|
__export(i18n_exports, {
|
|
101
90
|
default: () => i18n_default
|
|
102
91
|
});
|
|
103
|
-
var
|
|
92
|
+
var defaultImport4 = __toESM(require("@splunk/ui-utils/i18n"));
|
|
104
93
|
__reExport(i18n_exports, require("@splunk/ui-utils/i18n"));
|
|
105
|
-
var i18n_default = "default" in
|
|
94
|
+
var i18n_default = "default" in defaultImport4 ? defaultImport4.default : defaultImport4;
|
|
106
95
|
|
|
107
96
|
// esm-externals:@splunk/visualization-context/IconContext
|
|
108
97
|
var IconContext_exports = {};
|
|
109
98
|
__export(IconContext_exports, {
|
|
110
99
|
default: () => IconContext_default
|
|
111
100
|
});
|
|
112
|
-
var
|
|
101
|
+
var defaultImport5 = __toESM(require("@splunk/visualization-context/IconContext"));
|
|
113
102
|
__reExport(IconContext_exports, require("@splunk/visualization-context/IconContext"));
|
|
114
|
-
var IconContext_default = "default" in
|
|
103
|
+
var IconContext_default = "default" in defaultImport5 ? defaultImport5.default : defaultImport5;
|
|
115
104
|
|
|
116
105
|
// esm-externals:lodash/isNumber
|
|
117
106
|
var isNumber_exports = {};
|
|
118
107
|
__export(isNumber_exports, {
|
|
119
108
|
default: () => isNumber_default
|
|
120
109
|
});
|
|
121
|
-
var
|
|
110
|
+
var defaultImport6 = __toESM(require("lodash/isNumber"));
|
|
122
111
|
__reExport(isNumber_exports, require("lodash/isNumber"));
|
|
123
|
-
var isNumber_default = "default" in
|
|
112
|
+
var isNumber_default = "default" in defaultImport6 ? defaultImport6.default : defaultImport6;
|
|
124
113
|
|
|
125
114
|
// src/style.js
|
|
126
115
|
var toPx = (number, defaultNumber = 0) => isNumber_default(number) ? `${number}px` : number || toPx(defaultNumber);
|
|
@@ -156,7 +145,7 @@ var b64EncodeUnicode = (str) => (
|
|
|
156
145
|
btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (match, p1) => String.fromCharCode(`0x${p1}`)))
|
|
157
146
|
);
|
|
158
147
|
|
|
159
|
-
// src/RemoteIcon.
|
|
148
|
+
// src/RemoteIcon.tsx
|
|
160
149
|
var IconContainer = styled_components_default.div`
|
|
161
150
|
${(props) => toDimension({ width: props.width, height: props.height })};
|
|
162
151
|
margin: auto;
|
|
@@ -234,29 +223,40 @@ var _RemoteIcon = class _RemoteIcon extends react_exports.PureComponent {
|
|
|
234
223
|
*/
|
|
235
224
|
colorIcon(dataURI, color) {
|
|
236
225
|
fetch(dataURI).then((response) => response.text()).then((text) => {
|
|
226
|
+
var _a, _b;
|
|
237
227
|
const parser = new DOMParser();
|
|
238
228
|
const xmlDoc = parser.parseFromString(text, "text/xml");
|
|
239
229
|
const svg = xmlDoc.getElementsByTagName("svg")[0];
|
|
240
230
|
const children = svg.querySelectorAll("*");
|
|
241
231
|
svg.style.color = color;
|
|
242
|
-
for (
|
|
243
|
-
const child = children[i];
|
|
232
|
+
for (const child of children) {
|
|
244
233
|
if (_RemoteIcon.BASIC_SHAPES.includes(child.tagName)) {
|
|
245
234
|
const fillAttr = child.getAttribute("fill");
|
|
246
|
-
const fillStyle = child.style
|
|
235
|
+
const fillStyle = (_a = child.style) == null ? void 0 : _a.fill;
|
|
247
236
|
const strokeAttr = child.getAttribute("stroke");
|
|
248
|
-
const strokeStyle = child.style
|
|
249
|
-
if (shouldChangeFill({
|
|
237
|
+
const strokeStyle = (_b = child.style) == null ? void 0 : _b.stroke;
|
|
238
|
+
if (shouldChangeFill({
|
|
239
|
+
fillAttr,
|
|
240
|
+
fillStyle,
|
|
241
|
+
strokeAttr,
|
|
242
|
+
strokeStyle
|
|
243
|
+
})) {
|
|
250
244
|
child.style.fill = "";
|
|
251
245
|
child.setAttribute("fill", "currentColor");
|
|
252
246
|
}
|
|
253
|
-
if (shouldChangeStroke({
|
|
247
|
+
if (shouldChangeStroke({
|
|
248
|
+
fillAttr,
|
|
249
|
+
fillStyle,
|
|
250
|
+
strokeAttr,
|
|
251
|
+
strokeStyle
|
|
252
|
+
})) {
|
|
254
253
|
child.style.stroke = "";
|
|
255
254
|
child.setAttribute("stroke", "currentColor");
|
|
256
255
|
}
|
|
257
256
|
}
|
|
258
257
|
}
|
|
259
|
-
const
|
|
258
|
+
const s = xmlserializer_exports.serializeToString(svg);
|
|
259
|
+
const svgStr = b64EncodeUnicode(s);
|
|
260
260
|
const iconDataURI = `data:image/svg+xml;base64,${svgStr}`;
|
|
261
261
|
this.setState({ iconDataURI });
|
|
262
262
|
}).catch(() => {
|
|
@@ -265,15 +265,15 @@ var _RemoteIcon = class _RemoteIcon extends react_exports.PureComponent {
|
|
|
265
265
|
}
|
|
266
266
|
render() {
|
|
267
267
|
const { iconDataURI } = this.state;
|
|
268
|
-
const { width, height, opacity, onIconClick } = this.props;
|
|
268
|
+
const { alt = (0, i18n_exports._)("Remote Icon"), width = 100, height = 100, opacity = 1, onIconClick } = this.props;
|
|
269
269
|
if (!iconDataURI) {
|
|
270
270
|
return null;
|
|
271
271
|
}
|
|
272
|
-
return /* @__PURE__ */
|
|
272
|
+
return /* @__PURE__ */ react_exports.createElement(IconContainer, { width, height, onClick: onIconClick }, /* @__PURE__ */ react_exports.createElement(
|
|
273
273
|
ColoredIcon,
|
|
274
274
|
{
|
|
275
275
|
src: iconDataURI,
|
|
276
|
-
alt
|
|
276
|
+
alt,
|
|
277
277
|
width,
|
|
278
278
|
height,
|
|
279
279
|
opacity,
|
|
@@ -282,21 +282,8 @@ var _RemoteIcon = class _RemoteIcon extends react_exports.PureComponent {
|
|
|
282
282
|
));
|
|
283
283
|
}
|
|
284
284
|
};
|
|
285
|
-
|
|
286
|
-
|
|
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
|
|
293
|
-
});
|
|
294
|
-
__publicField(_RemoteIcon, "defaultProps", {
|
|
295
|
-
width: 100,
|
|
296
|
-
height: 100,
|
|
297
|
-
opacity: 1
|
|
298
|
-
});
|
|
299
|
-
__publicField(_RemoteIcon, "BASIC_SHAPES", ["path", "rect", "circle", "ellipse", "line", "polyline", "polygon"]);
|
|
285
|
+
_RemoteIcon.contextType = IconContext_default;
|
|
286
|
+
_RemoteIcon.BASIC_SHAPES = ["path", "rect", "circle", "ellipse", "line", "polyline", "polygon"];
|
|
300
287
|
var RemoteIcon = _RemoteIcon;
|
|
301
288
|
var RemoteIcon_default = RemoteIcon;
|
|
302
289
|
//# sourceMappingURL=RemoteIcon.js.map
|
package/RemoteIcon.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["src/RemoteIcon.
|
|
4
|
-
"sourcesContent": ["/* eslint-disable class-methods-use-this */\nimport React, { PureComponent } from 'react';\nimport T from 'prop-types';\nimport styled from 'styled-components';\nimport xmlserializer from 'xmlserializer';\nimport { _ } from '@splunk/ui-utils/i18n';\nimport IconContext from '@splunk/visualization-context/IconContext';\nimport { toDimension } from './style';\nimport { shouldChangeFill, shouldChangeStroke, b64EncodeUnicode } from './iconUtils';\n\nconst IconContainer = styled.div`\n ${props => toDimension({ width: props.width, height: props.height })};\n margin: auto;\n cursor: ${props => (props.onClick ? 'pointer' : 'inherit')};\n`;\nconst ColoredIcon = styled.img`\n ${props => toDimension({ width: props.width, height: props.height })};\n opacity: ${props => props.opacity || 1.0};\n`;\n\nclass RemoteIcon extends PureComponent {\n static contextType = IconContext;\n\n static propTypes = {\n iconURL: T.string,\n color: T.string,\n width: T.number,\n height: T.number,\n opacity: T.number,\n onIconClick: T.func,\n };\n\n static defaultProps = {\n width: 100,\n height: 100,\n opacity: 1.0,\n };\n\n static BASIC_SHAPES = ['path', 'rect', 'circle', 'ellipse', 'line', 'polyline', 'polygon'];\n\n constructor(props) {\n super(props);\n this.state = { iconDataURI: null };\n }\n\n // eslint-disable-next-line camelcase\n UNSAFE_componentWillMount() {\n this.getIcon(this.props.iconURL, this.props.color);\n }\n\n componentDidUpdate(prevProps) {\n if (prevProps.iconURL !== this.props.iconURL || prevProps.color !== this.props.color) {\n this.getIcon(this.props.iconURL, this.props.color);\n }\n }\n\n /**\n * Check if the iconURL is a registry URL/dataURI/direct URL and fetch from the registry when required\n * @param {String} iconURL\n * @param {String} color\n */\n async getIcon(iconURL, color) {\n const getIconDataURI = async () => {\n if (this.isRegistryURL(iconURL)) {\n const iconRegistry = this.context;\n if (iconRegistry) {\n try {\n const icon = await iconRegistry.getByURL(iconURL);\n return icon.dataURI;\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(_(error));\n }\n }\n } else {\n return iconURL;\n }\n return null;\n };\n\n const iconDataURI = await getIconDataURI();\n\n if (color) {\n this.colorIcon(iconDataURI, color);\n } else {\n this.setState({ iconDataURI });\n }\n }\n\n /**\n * check if icon is a registry url\n * @param {String} src\n */\n isRegistryURL(src = '') {\n const [type] = src.split('://');\n return type !== 'http' && type !== 'https' && !src.startsWith('data:image/svg+xml;base64');\n }\n\n /*\n * Color the icon:\n * parse svg elements from the dataURI, change color style of svg, and change fill/stroke attribute/style of each svg basic shapes\n * in the svg element to currentColor. At the end, convert the modified svg back to dataURI string.\n *\n * Limitation:\n * if the svg is created with multiple pathes with different fill attributes, this method would\n * convert all pathes' fill attribute to the color prop. It may change the view of the svg icon.\n *\n * @method colorIcon\n * @params {DataURI} dataURI\n * @params {String} color e.g. 'red' || '#ffffff'\n */\n colorIcon(dataURI, color) {\n fetch(dataURI)\n .then(response => response.text())\n .then(text => {\n const parser = new DOMParser();\n const xmlDoc = parser.parseFromString(text, 'text/xml');\n const svg = xmlDoc.getElementsByTagName('svg')[0];\n const children = svg.querySelectorAll('*');\n svg.style.color = color;\n\n // Todo: need move this to IconRegistry after figure out the jest issue with XMLSerializer\n for (let i = 0; i < children.length; i += 1) {\n const child = children[i];\n\n if (RemoteIcon.BASIC_SHAPES.includes(child.tagName)) {\n const fillAttr = child.getAttribute('fill');\n const fillStyle = child.style && child.style.fill;\n const strokeAttr = child.getAttribute('stroke');\n const strokeStyle = child.style && child.style.stroke;\n\n if (shouldChangeFill({ fillAttr, fillStyle, strokeAttr, strokeStyle })) {\n child.style.fill = '';\n child.setAttribute('fill', 'currentColor');\n }\n\n if (shouldChangeStroke({ fillAttr, fillStyle, strokeAttr, strokeStyle })) {\n child.style.stroke = '';\n child.setAttribute('stroke', 'currentColor');\n }\n }\n }\n\n const svgStr = b64EncodeUnicode(xmlserializer.serializeToString(svg));\n const iconDataURI = `data:image/svg+xml;base64,${svgStr}`;\n this.setState({ iconDataURI });\n })\n .catch(() => {\n // eslint-disable-next-line no-console\n console.error(_('The icon cannot be colored properly.'));\n });\n }\n\n render() {\n const { iconDataURI } = this.state;\n const { width, height, opacity, onIconClick } = this.props;\n\n if (!iconDataURI) {\n return null;\n }\n return (\n <IconContainer width={width} height={height} onClick={onIconClick}>\n <ColoredIcon\n src={iconDataURI}\n alt=\"Remote Icon\"\n width={width}\n height={height}\n opacity={opacity}\n referrerPolicy=\"no-referrer\"\n />\n </IconContainer>\n );\n }\n}\n\nexport default RemoteIcon;\n", "\nimport * as defaultImport from \"react\";\nexport * from \"react\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"prop-types\";\nexport * from \"prop-types\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"styled-components\";\nexport * from \"styled-components\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"xmlserializer\";\nexport * from \"xmlserializer\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"@splunk/ui-utils/i18n\";\nexport * from \"@splunk/ui-utils/i18n\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"@splunk/visualization-context/IconContext\";\nexport * from \"@splunk/visualization-context/IconContext\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"lodash/isNumber\";\nexport * from \"lodash/isNumber\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "import isNumber from 'lodash/isNumber';\n\n/**\n * convert number to px\n * @param {*} number\n */\nexport const toPx = (number, defaultNumber = 0) =>\n isNumber(number) ? `${number}px` : number || toPx(defaultNumber);\n\n/**\n * generate width/height css properties\n * @param {*} param0\n */\nexport const toDimension = ({ width, height }) => {\n let css = '';\n if (width) {\n css = `width: ${toPx(width)};`;\n }\n if (height) {\n // only add a linebreak if width was also set\n css = `${css}${width ? '\\n' : ''}height: ${toPx(height)};`;\n }\n return css;\n};\n\n/**\n * generate margin css property\n */\nexport const arrayToCSSProp = (prop, vals = [0, 0, 0, 0]) => {\n if (Array.isArray(vals)) {\n return `\n ${prop}: ${toPx(vals[0])} ${toPx(vals[1])} ${toPx(vals[2])} ${toPx(vals[3])};\n `;\n }\n\n return `${prop}: ${toPx(vals)};`;\n};\n\n/**\n * generate margin css property\n */\nexport const toMargin = (margins = [0, 0, 0, 0]) => arrayToCSSProp('margin', margins);\n\n/**\n * generate padding css property\n */\nexport const toPadding = (paddings = [0, 0, 0, 0]) => arrayToCSSProp('padding', paddings);\n", "/**\n * check if an icon is considered as remote icon\n * @param {*} icon\n */\nexport const isRemoteIcon = (icon = '') => icon.indexOf('://') > -1;\n\n/**\n * check if an icon is a dataURI\n * @param {*} icon\n */\nexport const isDataURI = (icon = '') => icon.startsWith('data:image/svg+xml;base64');\n\n/*\n * check whether need update fill for svg children elements\n * @params {Object} style\n * @params {String} style.fillAttr <path fill=\"red\" .../>\n * @params {String} style.fillStyle. <path style=\"fill: red;\" />\n * @params {String} style.strokeAttr. <path stroke=\"red\" .../>\n * @params {String} style.strokeStyle <path style=\"stroke: red;\" .../>\n * @returns {Boolean} true means need\n * remove fill style and change the fill attribute <path fill=\"currentColor\" />\n */\nexport const shouldChangeFill = ({ fillAttr, fillStyle, strokeAttr, strokeStyle }) => {\n const noneFillAttr = !!fillAttr && (fillAttr === 'none' || fillAttr === 'transparent');\n const noneFillStyle = !!fillStyle && (fillStyle === 'none' || fillStyle === 'transparent');\n const noFillHasStroke = !fillAttr && !fillStyle && (!!strokeAttr || !!strokeStyle);\n return !(noneFillAttr || noneFillStyle || noFillHasStroke);\n};\n\n/*\n * check whether need update stroke for svg children elements\n * @params {Object} style\n * @params {String} style.fillAttr <path fill=\"red\" .../>\n * @params {String} style.fillStyle. <path style=\"fill: red;\" />\n * @params {String} style.strokeAttr. <path stroke=\"red\" .../>\n * @params {String} style.strokeStyle <path style=\"stroke: red;\" .../>\n * @returns {Boolean} true means need\n * remove stroke style and change the stroke attribute <path stroke=\"currentColor\" />\n */\nexport const shouldChangeStroke = ({ fillAttr, fillStyle, strokeAttr, strokeStyle }) => {\n const noneStrokeAttr = !!strokeAttr && (strokeAttr === 'none' || strokeAttr === 'transparent');\n const noneStrokeStyle = !!strokeStyle && (strokeStyle === 'none' || strokeStyle === 'transparent');\n const hasFill = !!fillAttr || !!fillStyle;\n const noStroke = !strokeAttr && !strokeStyle;\n return !(noneStrokeAttr || noneStrokeStyle || hasFill || noStroke);\n};\n\n/*\n * base64 encoding\n * @param {String} str\n * @return {Base64} string using based-64 encoding\n */\nexport const b64EncodeUnicode = str =>\n // first we use encodeURIComponent to get percent-encoded UTF-8,\n // then we convert the percent encodings into raw bytes which\n // can be fed into btoa.\n btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (match, p1) => String.fromCharCode(`0x${p1}`)));\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["defaultImport", "defaultImport", "defaultImport", "defaultImport", "defaultImport"
|
|
3
|
+
"sources": ["src/RemoteIcon.tsx", "esm-externals:react", "esm-externals:styled-components", "esm-externals:xmlserializer", "esm-externals:@splunk/ui-utils/i18n", "esm-externals:@splunk/visualization-context/IconContext", "esm-externals:lodash/isNumber", "src/style.js", "src/iconUtils.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable class-methods-use-this */\nimport * as React from 'react';\nimport styled from 'styled-components';\nimport * as xmlserializer from 'xmlserializer';\nimport { _ } from '@splunk/ui-utils/i18n';\nimport IconContext from '@splunk/visualization-context/IconContext';\nimport { toDimension } from './style';\nimport { shouldChangeFill, shouldChangeStroke, b64EncodeUnicode } from './iconUtils';\n\ninterface RemoteIconProps {\n alt?: string;\n iconURL?: string;\n color?: string;\n width?: number;\n height?: number;\n opacity?: number;\n onIconClick?: (event: React.MouseEvent<HTMLDivElement>) => void;\n}\n\ninterface RemoteIconState {\n iconDataURI: string | null;\n}\n\nconst IconContainer = styled.div<RemoteIconProps>`\n ${props => toDimension({ width: props.width, height: props.height })};\n margin: auto;\n cursor: ${props => (props.onClick ? 'pointer' : 'inherit')};\n`;\n\nconst ColoredIcon = styled.img<RemoteIconProps>`\n ${props => toDimension({ width: props.width, height: props.height })};\n opacity: ${props => props.opacity || 1.0};\n`;\n\nclass RemoteIcon extends React.PureComponent<RemoteIconProps, RemoteIconState> {\n static readonly contextType: IconContext = IconContext;\n\n static readonly BASIC_SHAPES = ['path', 'rect', 'circle', 'ellipse', 'line', 'polyline', 'polygon'];\n\n constructor(props: RemoteIconProps) {\n super(props);\n this.state = { iconDataURI: null };\n }\n\n // eslint-disable-next-line camelcase\n UNSAFE_componentWillMount() {\n this.getIcon(this.props.iconURL, this.props.color);\n }\n\n componentDidUpdate(prevProps) {\n if (prevProps.iconURL !== this.props.iconURL || prevProps.color !== this.props.color) {\n this.getIcon(this.props.iconURL, this.props.color);\n }\n }\n\n /**\n * Check if the iconURL is a registry URL/dataURI/direct URL and fetch from the registry when required\n * @param {String} iconURL\n * @param {String} color\n */\n async getIcon(iconURL, color) {\n const getIconDataURI = async () => {\n if (this.isRegistryURL(iconURL)) {\n const iconRegistry: IconContext = this.context;\n if (iconRegistry) {\n try {\n const icon = (await iconRegistry.getByURL(iconURL)) as any;\n return icon.dataURI;\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(_(error));\n }\n }\n } else {\n return iconURL;\n }\n return null;\n };\n\n const iconDataURI = await getIconDataURI();\n\n if (color) {\n this.colorIcon(iconDataURI, color);\n } else {\n this.setState({ iconDataURI });\n }\n }\n\n /**\n * check if icon is a registry url\n * @param {String} src\n */\n isRegistryURL(src = '') {\n const [type] = src.split('://');\n return type !== 'http' && type !== 'https' && !src.startsWith('data:image/svg+xml;base64');\n }\n\n /*\n * Color the icon:\n * parse svg elements from the dataURI, change color style of svg, and change fill/stroke attribute/style of each svg basic shapes\n * in the svg element to currentColor. At the end, convert the modified svg back to dataURI string.\n *\n * Limitation:\n * if the svg is created with multiple pathes with different fill attributes, this method would\n * convert all pathes' fill attribute to the color prop. It may change the view of the svg icon.\n *\n * @method colorIcon\n * @params {DataURI} dataURI\n * @params {String} color e.g. 'red' || '#ffffff'\n */\n colorIcon(dataURI, color) {\n fetch(dataURI)\n .then(response => response.text())\n .then(text => {\n const parser = new DOMParser();\n const xmlDoc = parser.parseFromString(text, 'text/xml');\n const svg = xmlDoc.getElementsByTagName('svg')[0];\n const children = svg.querySelectorAll('*');\n svg.style.color = color;\n // eslint-disable-next-line no-restricted-syntax\n for (const child of children) {\n if (RemoteIcon.BASIC_SHAPES.includes(child.tagName)) {\n const fillAttr = child.getAttribute('fill');\n const fillStyle = (child as SVGElement).style?.fill;\n const strokeAttr = child.getAttribute('stroke');\n const strokeStyle = (child as SVGElement).style?.stroke;\n if (\n shouldChangeFill({\n fillAttr,\n fillStyle,\n strokeAttr,\n strokeStyle,\n })\n ) {\n (child as SVGElement).style.fill = '';\n child.setAttribute('fill', 'currentColor');\n }\n\n if (\n shouldChangeStroke({\n fillAttr,\n fillStyle,\n strokeAttr,\n strokeStyle,\n })\n ) {\n (child as SVGElement).style.stroke = '';\n child.setAttribute('stroke', 'currentColor');\n }\n }\n }\n const s = xmlserializer.serializeToString(svg);\n const svgStr = b64EncodeUnicode(s);\n const iconDataURI = `data:image/svg+xml;base64,${svgStr}`;\n this.setState({ iconDataURI });\n })\n .catch(() => {\n // eslint-disable-next-line no-console\n console.error(_('The icon cannot be colored properly.'));\n });\n }\n\n render() {\n const { iconDataURI } = this.state;\n const { alt = _('Remote Icon'), width = 100, height = 100, opacity = 1.0, onIconClick } = this.props;\n if (!iconDataURI) {\n return null;\n }\n return (\n <IconContainer width={width} height={height} onClick={onIconClick}>\n <ColoredIcon\n src={iconDataURI}\n alt={alt}\n width={width}\n height={height}\n opacity={opacity}\n referrerPolicy=\"no-referrer\"\n />\n </IconContainer>\n );\n }\n}\n\nexport default RemoteIcon;\n", "\nimport * as defaultImport from \"react\";\nexport * from \"react\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"styled-components\";\nexport * from \"styled-components\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"xmlserializer\";\nexport * from \"xmlserializer\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"@splunk/ui-utils/i18n\";\nexport * from \"@splunk/ui-utils/i18n\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"@splunk/visualization-context/IconContext\";\nexport * from \"@splunk/visualization-context/IconContext\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"lodash/isNumber\";\nexport * from \"lodash/isNumber\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "import isNumber from 'lodash/isNumber';\n\n/**\n * convert number to px\n * @param {*} number\n */\nexport const toPx = (number, defaultNumber = 0) =>\n isNumber(number) ? `${number}px` : number || toPx(defaultNumber);\n\n/**\n * generate width/height css properties\n * @param {*} param0\n */\nexport const toDimension = ({ width, height }) => {\n let css = '';\n if (width) {\n css = `width: ${toPx(width)};`;\n }\n if (height) {\n // only add a linebreak if width was also set\n css = `${css}${width ? '\\n' : ''}height: ${toPx(height)};`;\n }\n return css;\n};\n\n/**\n * generate margin css property\n */\nexport const arrayToCSSProp = (prop, vals = [0, 0, 0, 0]) => {\n if (Array.isArray(vals)) {\n return `\n ${prop}: ${toPx(vals[0])} ${toPx(vals[1])} ${toPx(vals[2])} ${toPx(vals[3])};\n `;\n }\n\n return `${prop}: ${toPx(vals)};`;\n};\n\n/**\n * generate margin css property\n */\nexport const toMargin = (margins = [0, 0, 0, 0]) => arrayToCSSProp('margin', margins);\n\n/**\n * generate padding css property\n */\nexport const toPadding = (paddings = [0, 0, 0, 0]) => arrayToCSSProp('padding', paddings);\n", "/**\n * check if an icon is considered as remote icon\n * @param {*} icon\n */\nexport const isRemoteIcon = (icon = '') => icon.indexOf('://') > -1;\n\n/**\n * check if an icon is a dataURI\n * @param {*} icon\n */\nexport const isDataURI = (icon = '') => icon.startsWith('data:image/svg+xml;base64');\n\n/*\n * check whether need update fill for svg children elements\n * @params {Object} style\n * @params {String} style.fillAttr <path fill=\"red\" .../>\n * @params {String} style.fillStyle. <path style=\"fill: red;\" />\n * @params {String} style.strokeAttr. <path stroke=\"red\" .../>\n * @params {String} style.strokeStyle <path style=\"stroke: red;\" .../>\n * @returns {Boolean} true means need\n * remove fill style and change the fill attribute <path fill=\"currentColor\" />\n */\nexport const shouldChangeFill = ({ fillAttr, fillStyle, strokeAttr, strokeStyle }) => {\n const noneFillAttr = !!fillAttr && (fillAttr === 'none' || fillAttr === 'transparent');\n const noneFillStyle = !!fillStyle && (fillStyle === 'none' || fillStyle === 'transparent');\n const noFillHasStroke = !fillAttr && !fillStyle && (!!strokeAttr || !!strokeStyle);\n return !(noneFillAttr || noneFillStyle || noFillHasStroke);\n};\n\n/*\n * check whether need update stroke for svg children elements\n * @params {Object} style\n * @params {String} style.fillAttr <path fill=\"red\" .../>\n * @params {String} style.fillStyle. <path style=\"fill: red;\" />\n * @params {String} style.strokeAttr. <path stroke=\"red\" .../>\n * @params {String} style.strokeStyle <path style=\"stroke: red;\" .../>\n * @returns {Boolean} true means need\n * remove stroke style and change the stroke attribute <path stroke=\"currentColor\" />\n */\nexport const shouldChangeStroke = ({ fillAttr, fillStyle, strokeAttr, strokeStyle }) => {\n const noneStrokeAttr = !!strokeAttr && (strokeAttr === 'none' || strokeAttr === 'transparent');\n const noneStrokeStyle = !!strokeStyle && (strokeStyle === 'none' || strokeStyle === 'transparent');\n const hasFill = !!fillAttr || !!fillStyle;\n const noStroke = !strokeAttr && !strokeStyle;\n return !(noneStrokeAttr || noneStrokeStyle || hasFill || noStroke);\n};\n\n/*\n * base64 encoding\n * @param {String} str\n * @return {Base64} string using based-64 encoding\n */\nexport const b64EncodeUnicode = str =>\n // first we use encodeURIComponent to get percent-encoded UTF-8,\n // then we convert the percent encodings into raw bytes which\n // can be fed into btoa.\n btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (match, p1) => String.fromCharCode(`0x${p1}`)));\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AACA,oBAA+B;AAC/B,0BAAc;AACd,IAAO,gBAAS,aAAa,gBAA8B,wBAAU;;;ACHrE;AAAA;AAAA;AAAA;AACA,IAAAA,iBAA+B;AAC/B,sCAAc;AACd,IAAO,4BAAS,aAAaA,iBAA8B,yBAAUA;;;ACHrE;AAAA;AAAA;AAAA;AACA,IAAAC,iBAA+B;AAC/B,kCAAc;AACd,IAAO,wBAAS,aAAaA,iBAA8B,yBAAUA;;;ACHrE;AA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AA,YACf;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACJ,CAAC,GACH;AACE,YAAC,MAAqB,MAAM,SAAS;AACrC,kBAAM,aAAa,UAAU,cAAc;AAAA,UAC/C;AAAA,QACJ;AAAA,MACJ;AACA,YAAM,IAAkB,wCAAkB,GAAG;AAC7C,YAAM,SAAS,iBAAiB,CAAC;AACjC,YAAM,cAAc,6BAA6B,MAAM;AACvD,WAAK,SAAS,EAAE,YAAY,CAAC;AAAA,IACjC,CAAC,EACA,MAAM,MAAM;AAET,cAAQ,UAAM,gBAAE,sCAAsC,CAAC;AAAA,IAC3D,CAAC;AAAA,EACT;AAAA,EAEA,SAAS;AACL,UAAM,EAAE,YAAY,IAAI,KAAK;AAC7B,UAAM,EAAE,UAAM,gBAAE,aAAa,GAAG,QAAQ,KAAK,SAAS,KAAK,UAAU,GAAK,YAAY,IAAI,KAAK;AAC/F,QAAI,CAAC,aAAa;AACd,aAAO;AAAA,IACX;AACA,WACI,4CAAC,iBAAc,OAAc,QAAgB,SAAS,eAClD;AAAA,MAAC;AAAA;AAAA,QACG,KAAK;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,gBAAe;AAAA;AAAA,IACnB,CACJ;AAAA,EAER;AACJ;AAnJM,YACc,cAA2B;AADzC,YAGc,eAAe,CAAC,QAAQ,QAAQ,UAAU,WAAW,QAAQ,YAAY,SAAS;AAHtG,IAAM,aAAN;AAqJA,IAAO,qBAAQ;",
|
|
6
|
+
"names": ["defaultImport", "defaultImport", "defaultImport", "defaultImport", "defaultImport"]
|
|
7
7
|
}
|
package/RemoteImage.js
CHANGED
|
@@ -7,7 +7,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
7
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
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
10
|
var __export = (target, all) => {
|
|
12
11
|
for (var name in all)
|
|
13
12
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -30,7 +29,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
29
|
mod
|
|
31
30
|
));
|
|
32
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
34
32
|
var __async = (__this, __arguments, generator) => {
|
|
35
33
|
return new Promise((resolve, reject) => {
|
|
36
34
|
var fulfilled = (value) => {
|
|
@@ -52,7 +50,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
52
50
|
});
|
|
53
51
|
};
|
|
54
52
|
|
|
55
|
-
// src/RemoteImage.
|
|
53
|
+
// src/RemoteImage.tsx
|
|
56
54
|
var RemoteImage_exports = {};
|
|
57
55
|
__export(RemoteImage_exports, {
|
|
58
56
|
default: () => RemoteImage_default,
|
|
@@ -69,59 +67,50 @@ var defaultImport = __toESM(require("react"));
|
|
|
69
67
|
__reExport(react_exports, require("react"));
|
|
70
68
|
var react_default = "default" in defaultImport ? defaultImport.default : defaultImport;
|
|
71
69
|
|
|
72
|
-
// esm-externals:prop-types
|
|
73
|
-
var prop_types_exports = {};
|
|
74
|
-
__export(prop_types_exports, {
|
|
75
|
-
default: () => prop_types_default
|
|
76
|
-
});
|
|
77
|
-
var defaultImport2 = __toESM(require("prop-types"));
|
|
78
|
-
__reExport(prop_types_exports, require("prop-types"));
|
|
79
|
-
var prop_types_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;
|
|
80
|
-
|
|
81
70
|
// esm-externals:styled-components
|
|
82
71
|
var styled_components_exports = {};
|
|
83
72
|
__export(styled_components_exports, {
|
|
84
73
|
default: () => styled_components_default
|
|
85
74
|
});
|
|
86
|
-
var
|
|
75
|
+
var defaultImport2 = __toESM(require("styled-components"));
|
|
87
76
|
__reExport(styled_components_exports, require("styled-components"));
|
|
88
|
-
var styled_components_default = "default" in
|
|
77
|
+
var styled_components_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;
|
|
89
78
|
|
|
90
|
-
// esm-externals:lodash
|
|
91
|
-
var
|
|
92
|
-
__export(
|
|
93
|
-
default: () =>
|
|
79
|
+
// esm-externals:lodash
|
|
80
|
+
var lodash_exports = {};
|
|
81
|
+
__export(lodash_exports, {
|
|
82
|
+
default: () => lodash_default
|
|
94
83
|
});
|
|
95
|
-
var
|
|
96
|
-
__reExport(
|
|
97
|
-
var
|
|
84
|
+
var defaultImport3 = __toESM(require("lodash"));
|
|
85
|
+
__reExport(lodash_exports, require("lodash"));
|
|
86
|
+
var lodash_default = "default" in defaultImport3 ? defaultImport3.default : defaultImport3;
|
|
98
87
|
|
|
99
88
|
// esm-externals:@splunk/ui-utils/i18n
|
|
100
89
|
var i18n_exports = {};
|
|
101
90
|
__export(i18n_exports, {
|
|
102
91
|
default: () => i18n_default
|
|
103
92
|
});
|
|
104
|
-
var
|
|
93
|
+
var defaultImport4 = __toESM(require("@splunk/ui-utils/i18n"));
|
|
105
94
|
__reExport(i18n_exports, require("@splunk/ui-utils/i18n"));
|
|
106
|
-
var i18n_default = "default" in
|
|
95
|
+
var i18n_default = "default" in defaultImport4 ? defaultImport4.default : defaultImport4;
|
|
107
96
|
|
|
108
97
|
// esm-externals:@splunk/visualization-context/ImageContext
|
|
109
98
|
var ImageContext_exports = {};
|
|
110
99
|
__export(ImageContext_exports, {
|
|
111
100
|
default: () => ImageContext_default
|
|
112
101
|
});
|
|
113
|
-
var
|
|
102
|
+
var defaultImport5 = __toESM(require("@splunk/visualization-context/ImageContext"));
|
|
114
103
|
__reExport(ImageContext_exports, require("@splunk/visualization-context/ImageContext"));
|
|
115
|
-
var ImageContext_default = "default" in
|
|
104
|
+
var ImageContext_default = "default" in defaultImport5 ? defaultImport5.default : defaultImport5;
|
|
116
105
|
|
|
117
106
|
// esm-externals:lodash/isNumber
|
|
118
107
|
var isNumber_exports = {};
|
|
119
108
|
__export(isNumber_exports, {
|
|
120
109
|
default: () => isNumber_default
|
|
121
110
|
});
|
|
122
|
-
var
|
|
111
|
+
var defaultImport6 = __toESM(require("lodash/isNumber"));
|
|
123
112
|
__reExport(isNumber_exports, require("lodash/isNumber"));
|
|
124
|
-
var isNumber_default = "default" in
|
|
113
|
+
var isNumber_default = "default" in defaultImport6 ? defaultImport6.default : defaultImport6;
|
|
125
114
|
|
|
126
115
|
// src/style.js
|
|
127
116
|
var toPx = (number, defaultNumber = 0) => isNumber_default(number) ? `${number}px` : number || toPx(defaultNumber);
|
|
@@ -136,7 +125,7 @@ var toDimension = ({ width, height }) => {
|
|
|
136
125
|
return css;
|
|
137
126
|
};
|
|
138
127
|
|
|
139
|
-
// src/RemoteImage.
|
|
128
|
+
// src/RemoteImage.tsx
|
|
140
129
|
var isRemoteImage = (src = "") => {
|
|
141
130
|
const [type] = src.split("://");
|
|
142
131
|
return src.indexOf("://") > -1 && type !== "http" && type !== "https";
|
|
@@ -150,7 +139,7 @@ var toImageDimensions = (props) => {
|
|
|
150
139
|
height: auto;
|
|
151
140
|
`;
|
|
152
141
|
}
|
|
153
|
-
return toDimension(
|
|
142
|
+
return toDimension((0, lodash_exports.pick)(props, ["width", "height"]));
|
|
154
143
|
};
|
|
155
144
|
var Image = styled_components_default.img`
|
|
156
145
|
display: block;
|
|
@@ -159,7 +148,10 @@ var Image = styled_components_default.img`
|
|
|
159
148
|
var RemoteImage = class extends react_exports.PureComponent {
|
|
160
149
|
constructor(props) {
|
|
161
150
|
super(props);
|
|
162
|
-
this.state = {
|
|
151
|
+
this.state = {
|
|
152
|
+
imageDataURI: null,
|
|
153
|
+
preserveAspectRatio: Boolean(props.preserveAspectRatio)
|
|
154
|
+
};
|
|
163
155
|
}
|
|
164
156
|
componentDidMount() {
|
|
165
157
|
this.getImage(this.props.imageURL);
|
|
@@ -169,7 +161,9 @@ var RemoteImage = class extends react_exports.PureComponent {
|
|
|
169
161
|
this.getImage(this.props.imageURL);
|
|
170
162
|
}
|
|
171
163
|
if (prevProps.preserveAspectRatio !== this.props.preserveAspectRatio) {
|
|
172
|
-
this.setState({
|
|
164
|
+
this.setState({
|
|
165
|
+
preserveAspectRatio: this.props.preserveAspectRatio
|
|
166
|
+
});
|
|
173
167
|
}
|
|
174
168
|
}
|
|
175
169
|
getImage(imageURL) {
|
|
@@ -191,7 +185,7 @@ var RemoteImage = class extends react_exports.PureComponent {
|
|
|
191
185
|
if (!imageDataURI) {
|
|
192
186
|
return null;
|
|
193
187
|
}
|
|
194
|
-
return /* @__PURE__ */
|
|
188
|
+
return /* @__PURE__ */ react_exports.createElement(
|
|
195
189
|
Image,
|
|
196
190
|
{
|
|
197
191
|
src: imageDataURI,
|
|
@@ -206,16 +200,6 @@ var RemoteImage = class extends react_exports.PureComponent {
|
|
|
206
200
|
);
|
|
207
201
|
}
|
|
208
202
|
};
|
|
209
|
-
|
|
210
|
-
__publicField(RemoteImage, "propTypes", {
|
|
211
|
-
imageURL: prop_types_default.string,
|
|
212
|
-
width: prop_types_default.oneOfType([prop_types_default.string, prop_types_default.number]),
|
|
213
|
-
height: prop_types_default.oneOfType([prop_types_default.string, prop_types_default.number]),
|
|
214
|
-
preserveAspectRatio: prop_types_default.bool,
|
|
215
|
-
title: prop_types_default.string
|
|
216
|
-
});
|
|
217
|
-
__publicField(RemoteImage, "defaultProps", {
|
|
218
|
-
preserveAspectRatio: false
|
|
219
|
-
});
|
|
203
|
+
RemoteImage.contextType = ImageContext_default;
|
|
220
204
|
var RemoteImage_default = RemoteImage;
|
|
221
205
|
//# sourceMappingURL=RemoteImage.js.map
|
package/RemoteImage.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["src/RemoteImage.
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["defaultImport", "defaultImport", "defaultImport", "defaultImport", "defaultImport"
|
|
3
|
+
"sources": ["src/RemoteImage.tsx", "esm-externals:react", "esm-externals:styled-components", "esm-externals:lodash", "esm-externals:@splunk/ui-utils/i18n", "esm-externals:@splunk/visualization-context/ImageContext", "esm-externals:lodash/isNumber", "src/style.js"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport styled from 'styled-components';\nimport { pick } from 'lodash';\nimport { _ } from '@splunk/ui-utils/i18n';\nimport ImageContext from '@splunk/visualization-context/ImageContext';\nimport { toDimension } from './style';\n\n/**\n * check if an image is considered as remote image\n * @param {*} src\n */\nexport const isRemoteImage = (src = '') => {\n const [type] = src.split('://');\n return src.indexOf('://') > -1 && type !== 'http' && type !== 'https';\n};\n\ninterface RemoteImageProps {\n imageURL: string;\n width: number;\n height: number;\n preserveAspectRatio: boolean;\n title: string;\n}\n\ninterface RemoteImageState {\n preserveAspectRatio: boolean;\n imageDataURI: string | null;\n}\n\ninterface ImageProps {\n shouldPreserveAspectRatio: boolean;\n width: number;\n height: number;\n}\n\nconst toImageDimensions = props => {\n if (props.shouldPreserveAspectRatio) {\n return `\n max-width: 100%;\n max-height: 100%;\n width: auto;\n height: auto;\n `;\n }\n return toDimension(pick(props, ['width', 'height']));\n};\n\nconst Image = styled.img<ImageProps>`\n display: block;\n ${props => toImageDimensions(props)};\n`;\n\nclass RemoteImage extends React.PureComponent<RemoteImageProps, RemoteImageState> {\n static readonly contextType: ImageContext = ImageContext;\n\n constructor(props) {\n super(props);\n this.state = {\n imageDataURI: null,\n preserveAspectRatio: Boolean(props.preserveAspectRatio),\n };\n }\n\n componentDidMount() {\n this.getImage(this.props.imageURL);\n }\n\n componentDidUpdate(prevProps) {\n if (prevProps.imageURL !== this.props.imageURL) {\n this.getImage(this.props.imageURL);\n }\n if (prevProps.preserveAspectRatio !== this.props.preserveAspectRatio) {\n // eslint-disable-next-line react/no-did-update-set-state\n this.setState({\n preserveAspectRatio: this.props.preserveAspectRatio,\n });\n }\n }\n\n async getImage(imageURL) {\n const imageRegistry: ImageContext = this.context;\n if (imageRegistry) {\n try {\n const image = await imageRegistry.getByURL(imageURL);\n this.setState({ imageDataURI: image.dataURI });\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n }\n }\n }\n\n render() {\n const { imageDataURI } = this.state;\n const { width, height, title } = this.props;\n\n if (!imageDataURI) {\n return null;\n }\n return (\n <Image\n src={imageDataURI}\n shouldPreserveAspectRatio={this.state.preserveAspectRatio}\n width={width}\n height={height}\n alt={_(title)}\n onError={e => {\n (e.target as HTMLImageElement).alt = _('Image not found');\n }}\n />\n );\n }\n}\n\nexport default RemoteImage;\n", "\nimport * as defaultImport from \"react\";\nexport * from \"react\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"styled-components\";\nexport * from \"styled-components\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"lodash\";\nexport * from \"lodash\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"@splunk/ui-utils/i18n\";\nexport * from \"@splunk/ui-utils/i18n\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"@splunk/visualization-context/ImageContext\";\nexport * from \"@splunk/visualization-context/ImageContext\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"lodash/isNumber\";\nexport * from \"lodash/isNumber\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "import isNumber from 'lodash/isNumber';\n\n/**\n * convert number to px\n * @param {*} number\n */\nexport const toPx = (number, defaultNumber = 0) =>\n isNumber(number) ? `${number}px` : number || toPx(defaultNumber);\n\n/**\n * generate width/height css properties\n * @param {*} param0\n */\nexport const toDimension = ({ width, height }) => {\n let css = '';\n if (width) {\n css = `width: ${toPx(width)};`;\n }\n if (height) {\n // only add a linebreak if width was also set\n css = `${css}${width ? '\\n' : ''}height: ${toPx(height)};`;\n }\n return css;\n};\n\n/**\n * generate margin css property\n */\nexport const arrayToCSSProp = (prop, vals = [0, 0, 0, 0]) => {\n if (Array.isArray(vals)) {\n return `\n ${prop}: ${toPx(vals[0])} ${toPx(vals[1])} ${toPx(vals[2])} ${toPx(vals[3])};\n `;\n }\n\n return `${prop}: ${toPx(vals)};`;\n};\n\n/**\n * generate margin css property\n */\nexport const toMargin = (margins = [0, 0, 0, 0]) => arrayToCSSProp('margin', margins);\n\n/**\n * generate padding css property\n */\nexport const toPadding = (paddings = [0, 0, 0, 0]) => arrayToCSSProp('padding', paddings);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AACA,oBAA+B;AAC/B,0BAAc;AACd,IAAO,gBAAS,aAAa,gBAA8B,wBAAU;;;ACHrE;AAAA;AAAA;AAAA;AACA,IAAAA,iBAA+B;AAC/B,sCAAc;AACd,IAAO,4BAAS,aAAaA,iBAA8B,yBAAUA;;;ACHrE;AAAA;AAAA;AAAA;AACA,IAAAC,iBAA+B;AAC/B,2BAAc;AACd,IAAO,iBAAS,aAAaA,iBAA8B,yBAAUA;;;ACHrE;AAAA;AAAA;AAAA;AACA,IAAAC,iBAA+B;AAC/B,yBAAc;AACd,IAAO,eAAS,aAAaA,iBAA8B,yBAAUA;;;ACHrE;AAAA;AAAA;AAAA;AACA,IAAAC,iBAA+B;AAC/B,iCAAc;AACd,IAAO,uBAAS,aAAaA,iBAA8B,yBAAUA;;;ACHrE;AAAA;AAAA;AAAA;AACA,IAAAC,iBAA+B;AAC/B,6BAAc;AACd,IAAO,mBAAS,aAAaA,iBAA8B,yBAAUA;;;ACG9D,IAAM,OAAO,CAAC,QAAQ,gBAAgB,M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A,EAEM,SAAS,UAAU;AAAA;AACrB,YAAM,gBAA8B,KAAK;AACzC,UAAI,eAAe;AACf,YAAI;AACA,gBAAM,QAAQ,MAAM,cAAc,SAAS,QAAQ;AACnD,eAAK,SAAS,EAAE,cAAc,MAAM,QAAQ,CAAC;AAAA,QACjD,SAAS,OAAO;AAEZ,kBAAQ,MAAM,KAAK;AAAA,QACvB;AAAA,MACJ;AAAA,IACJ;AAAA;AAAA,EAEA,SAAS;AACL,UAAM,EAAE,aAAa,IAAI,KAAK;AAC9B,UAAM,EAAE,OAAO,QAAQ,MAAM,IAAI,KAAK;AAEtC,QAAI,CAAC,cAAc;AACf,aAAO;AAAA,IACX;AACA,WACI;AAAA,MAAC;AAAA;AAAA,QACG,KAAK;AAAA,QACL,2BAA2B,KAAK,MAAM;AAAA,QACtC;AAAA,QACA;AAAA,QACA,SAAK,gBAAE,KAAK;AAAA,QACZ,SAAS,OAAK;AACV,UAAC,EAAE,OAA4B,UAAM,gBAAE,iBAAiB;AAAA,QAC5D;AAAA;AAAA,IACJ;AAAA,EAER;AACJ;AA5DM,YACc,cAA4B;AA6DhD,IAAO,sBAAQ;",
|
|
6
|
+
"names": ["defaultImport", "defaultImport", "defaultImport", "defaultImport", "defaultImport"]
|
|
7
7
|
}
|
package/SanitizeProps.js
CHANGED
|
@@ -113,6 +113,7 @@ var propsKeyValidators = {
|
|
|
113
113
|
nodeHighlightColor: colorUtils_exports.isColor,
|
|
114
114
|
linkColor: colorUtils_exports.isColor,
|
|
115
115
|
nodeTextColor: colorUtils_exports.isColor,
|
|
116
|
+
nodeValueColor: colorUtils_exports.isColor,
|
|
116
117
|
nodeTextHighlightColor: colorUtils_exports.isColor,
|
|
117
118
|
trellisBackgroundColor: colorUtils_exports.isColor
|
|
118
119
|
};
|
package/SanitizeProps.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["src/SanitizeProps.tsx", "esm-externals:react", "esm-externals:lodash", "esm-externals:@splunk/visualization-encoding/utils/colorUtils"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable no-param-reassign */\nimport * as React from 'react';\nimport { isPlainObject } from 'lodash';\nimport { isColor } from './colorUtils';\n\nconst propsKeyValidators = {\n backgroundColor: isColor,\n deltaColor: isColor, // SV react-visualizations & dashboard-visualizations\n trendColor: isColor, // SV visualizations\n fontColor: isColor,\n fillColor: isColor,\n gaugeColor: isColor,\n majorColor: isColor,\n radialBackgroundColor: isColor,\n radialStrokeColor: isColor,\n sparklineFillColor: isColor,\n sparklineStrokeColor: isColor,\n strokeColor: isColor,\n strokeHighlightColor: isColor,\n headerBackgroundColor: isColor,\n rowBackgroundColorOdd: isColor,\n rowBackgroundColorEven: isColor,\n headerTextColor: isColor,\n rowTextColorOdd: isColor,\n rowTextColorEven: isColor,\n color: isColor,\n textColor: isColor,\n defaultFontColor: isColor,\n defaultBlockFontColor: isColor,\n sparklineAreaColor: isColor,\n iconColor: isColor,\n areaColor: isColor,\n nodeColor: isColor,\n nodeHighlightColor: isColor,\n linkColor: isColor,\n nodeTextColor: isColor,\n nodeTextHighlightColor: isColor,\n trellisBackgroundColor: isColor,\n};\n\n/**\n * Validates if a given key value pair are valid\n * based on a set of predefined rules.\n *\n * @param {string} key\n * @param {string} value\n * @returns {boolean}\n */\nfunction isValidProperty(key: string, value: string): boolean {\n const { hasOwnProperty } = Object.prototype;\n return hasOwnProperty.call(propsKeyValidators, key) ? propsKeyValidators[key](value) : true;\n}\n\n/**\n * Validates every property in the key and return\n * only valid keys\n *\n * @export\n * @template T\n * @param {T} props\n * @returns {Partial<T>}\n */\nexport function sanitize<T extends Record<string, any>>(props: T): Partial<T> {\n return Object.keys(props).reduce((accum, key) => {\n if (key === 'options' && isPlainObject(props.options)) {\n accum[key] = sanitize(props.options);\n } else if (isValidProperty(key, props[key])) {\n accum[key] = props[key];\n }\n return accum;\n }, {});\n}\n\n/**\n * Helper HOC which will sanitize invalid props\n *\n * @export\n * @param {React.ComponentType} WrappedComponent\n * @returns {React.ComponentType}\n */\nexport function withSanitizedProps<T>(\n WrappedComponent: React.ComponentType<T>\n): React.ComponentType<Partial<T>> {\n const Wrapper = (props: T) => {\n const sanitizedProps = sanitize(props);\n return <WrappedComponent {...(sanitizedProps as T)} />;\n };\n return Wrapper;\n}\n", "\nimport * as defaultImport from \"react\";\nexport * from \"react\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"lodash\";\nexport * from \"lodash\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"@splunk/visualization-encoding/utils/colorUtils\";\nexport * from \"@splunk/visualization-encoding/utils/colorUtils\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AACA,oBAA+B;AAC/B,0BAAc;AACd,IAAO,gBAAS,aAAa,gBAA8B,wBAAU;;;ACHrE;AAAA;AAAA;AAAA;AACA,IAAAA,iBAA+B;AAC/B,2BAAc;AACd,IAAO,iBAAS,aAAaA,iBAA8B,yBAAUA;;;ACHrE;AAAA;AAAA;AAAA;AACA,IAAAC,iBAA+B;AAC/B,+BAAc;AACd,IAAO,qBAAS,aAAaA,iBAA8B,yBAAUA;;;AHErE,IAAM,qBAAqB;AAAA,EACvB,iBAAiB;AAAA,EACjB,YAAY;AAAA;AAAA,EACZ,YAAY;AAAA;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,uBAAuB;AAAA,EACvB,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB,sBAAsB;AAAA,EACtB,aAAa;AAAA,EACb,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,uBAAuB;AAAA,EACvB,wBAAwB;AAAA,EACxB,iBAAiB;AAAA,EACjB,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,OAAO;AAAA,EACP,WAAW;AAAA,EACX,kBAAkB;AAAA,EAClB,uBAAuB;AAAA,EACvB,oBAAoB;AAAA,EACpB,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,oBAAoB;AAAA,EACpB,WAAW;AAAA,EACX,eAAe;AAAA,EACf,wBAAwB;AAAA,EACxB,wBAAwB;AAC5B;AAUA,SAAS,gBAAgB,KAAa,OAAwB;AAC1D,QAAM,EAAE,eAAe,IAAI,OAAO;AAClC,SAAO,eAAe,KAAK,oBAAoB,GAAG,IAAI,mBAAmB,GAAG,EAAE,KAAK,IAAI;AAC3F;AAWO,SAAS,SAAwC,OAAsB;AAC1E,SAAO,OAAO,KAAK,KAAK,EAAE,OAAO,CAAC,OAAO,QAAQ;AAC7C,QAAI,QAAQ,iBAAa,8BAAc,MAAM,OAAO,GAAG;AACnD,YAAM,GAAG,IAAI,SAAS,MAAM,OAAO;AAAA,IACvC,WAAW,gBAAgB,KAAK,MAAM,GAAG,CAAC,GAAG;AACzC,YAAM,GAAG,IAAI,MAAM,GAAG;AAAA,IAC1B;AACA,WAAO;AAAA,EACX,GAAG,CAAC,CAAC;AACT;AASO,SAAS,mBACZ,kBAC+B;AAC/B,QAAM,UAAU,CAAC,UAAa;AAC1B,UAAM,iBAAiB,SAAS,KAAK;AACrC,WAAO,4CAAC,qCAAsB,eAAsB;AAAA,EACxD;AACA,SAAO;AACX;",
|
|
4
|
+
"sourcesContent": ["/* eslint-disable no-param-reassign */\nimport * as React from 'react';\nimport { isPlainObject } from 'lodash';\nimport { isColor } from './colorUtils';\n\nconst propsKeyValidators = {\n backgroundColor: isColor,\n deltaColor: isColor, // SV react-visualizations & dashboard-visualizations\n trendColor: isColor, // SV visualizations\n fontColor: isColor,\n fillColor: isColor,\n gaugeColor: isColor,\n majorColor: isColor,\n radialBackgroundColor: isColor,\n radialStrokeColor: isColor,\n sparklineFillColor: isColor,\n sparklineStrokeColor: isColor,\n strokeColor: isColor,\n strokeHighlightColor: isColor,\n headerBackgroundColor: isColor,\n rowBackgroundColorOdd: isColor,\n rowBackgroundColorEven: isColor,\n headerTextColor: isColor,\n rowTextColorOdd: isColor,\n rowTextColorEven: isColor,\n color: isColor,\n textColor: isColor,\n defaultFontColor: isColor,\n defaultBlockFontColor: isColor,\n sparklineAreaColor: isColor,\n iconColor: isColor,\n areaColor: isColor,\n nodeColor: isColor,\n nodeHighlightColor: isColor,\n linkColor: isColor,\n nodeTextColor: isColor,\n nodeValueColor: isColor,\n nodeTextHighlightColor: isColor,\n trellisBackgroundColor: isColor,\n};\n\n/**\n * Validates if a given key value pair are valid\n * based on a set of predefined rules.\n *\n * @param {string} key\n * @param {string} value\n * @returns {boolean}\n */\nfunction isValidProperty(key: string, value: string): boolean {\n const { hasOwnProperty } = Object.prototype;\n return hasOwnProperty.call(propsKeyValidators, key) ? propsKeyValidators[key](value) : true;\n}\n\n/**\n * Validates every property in the key and return\n * only valid keys\n *\n * @export\n * @template T\n * @param {T} props\n * @returns {Partial<T>}\n */\nexport function sanitize<T extends Record<string, any>>(props: T): Partial<T> {\n return Object.keys(props).reduce((accum, key) => {\n if (key === 'options' && isPlainObject(props.options)) {\n accum[key] = sanitize(props.options);\n } else if (isValidProperty(key, props[key])) {\n accum[key] = props[key];\n }\n return accum;\n }, {});\n}\n\n/**\n * Helper HOC which will sanitize invalid props\n *\n * @export\n * @param {React.ComponentType} WrappedComponent\n * @returns {React.ComponentType}\n */\nexport function withSanitizedProps<T>(\n WrappedComponent: React.ComponentType<T>\n): React.ComponentType<Partial<T>> {\n const Wrapper = (props: T) => {\n const sanitizedProps = sanitize(props);\n return <WrappedComponent {...(sanitizedProps as T)} />;\n };\n return Wrapper;\n}\n", "\nimport * as defaultImport from \"react\";\nexport * from \"react\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"lodash\";\nexport * from \"lodash\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"@splunk/visualization-encoding/utils/colorUtils\";\nexport * from \"@splunk/visualization-encoding/utils/colorUtils\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AACA,oBAA+B;AAC/B,0BAAc;AACd,IAAO,gBAAS,aAAa,gBAA8B,wBAAU;;;ACHrE;AAAA;AAAA;AAAA;AACA,IAAAA,iBAA+B;AAC/B,2BAAc;AACd,IAAO,iBAAS,aAAaA,iBAA8B,yBAAUA;;;ACHrE;AAAA;AAAA;AAAA;AACA,IAAAC,iBAA+B;AAC/B,+BAAc;AACd,IAAO,qBAAS,aAAaA,iBAA8B,yBAAUA;;;AHErE,IAAM,qBAAqB;AAAA,EACvB,iBAAiB;AAAA,EACjB,YAAY;AAAA;AAAA,EACZ,YAAY;AAAA;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,uBAAuB;AAAA,EACvB,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB,sBAAsB;AAAA,EACtB,aAAa;AAAA,EACb,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,uBAAuB;AAAA,EACvB,wBAAwB;AAAA,EACxB,iBAAiB;AAAA,EACjB,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,OAAO;AAAA,EACP,WAAW;AAAA,EACX,kBAAkB;AAAA,EAClB,uBAAuB;AAAA,EACvB,oBAAoB;AAAA,EACpB,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,oBAAoB;AAAA,EACpB,WAAW;AAAA,EACX,eAAe;AAAA,EACf,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