@splunk/visualizations-shared 25.13.1 → 26.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/Downloader.js +66 -11
- package/Downloader.js.map +1 -1
- package/FileDownloader.js +105 -31
- package/FileDownloader.js.map +1 -1
- package/JSONSchemaUtils.js +13 -8
- package/JSONSchemaUtils.js.map +1 -1
- package/Message.js +23 -12
- package/Message.js.map +1 -1
- package/RemoteIcon.js +93 -41
- package/RemoteIcon.js.map +1 -1
- package/RemoteImage.js +51 -16
- package/RemoteImage.js.map +1 -1
- package/SanitizeProps.js +50 -25
- package/SanitizeProps.js.map +1 -1
- package/SizeAwareWrapper.js +47 -19
- package/SizeAwareWrapper.js.map +1 -1
- package/VisualizationDocPage.js +72 -26
- package/VisualizationDocPage.js.map +1 -1
- package/colorConstants.js +2 -2
- package/colorConstants.js.map +1 -1
- package/colorUtils.js +27 -14
- package/colorUtils.js.map +1 -1
- package/configUtils.js +4 -2
- package/configUtils.js.map +1 -1
- package/console.js +14 -2
- package/console.js.map +1 -1
- package/dataSourceUtils.js +12 -3
- package/dataSourceUtils.js.map +1 -1
- package/domUtils.js +2 -2
- package/domUtils.js.map +1 -1
- package/hocUtils.js +29 -15
- package/hocUtils.js.map +1 -1
- package/i18n.js +4 -2
- package/i18n.js.map +1 -1
- package/iconUtils.js +11 -12
- package/iconUtils.js.map +1 -1
- package/mapUtils.js +4 -0
- package/mapUtils.js.map +1 -1
- package/namedColors.js +2 -2
- package/namedColors.js.map +1 -1
- package/numberUtils.js +31 -21
- package/numberUtils.js.map +1 -1
- package/package.json +12 -14
- package/previewVizMessage.js +2 -2
- package/previewVizMessage.js.map +1 -1
- package/propUtils.js +77 -12
- package/propUtils.js.map +1 -1
- package/schemaUtils.js +10 -10
- package/schemaUtils.js.map +1 -1
- package/simpleXMLOptions.js +6 -6
- package/simpleXMLOptions.js.map +1 -1
- package/style.js +11 -6
- package/style.js.map +1 -1
- package/testHelper.js +2 -2
- package/testHelper.js.map +1 -1
- package/themeUtils.js +14 -13
- package/themeUtils.js.map +1 -1
- package/trellisUtils.js +77 -33
- package/trellisUtils.js.map +1 -1
package/RemoteIcon.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"prop-types\"","webpack:///external \"react\"","webpack:///external \"@babel/runtime/helpers/defineProperty\"","webpack:///external \"@babel/runtime/helpers/getPrototypeOf\"","webpack:///external \"@babel/runtime/helpers/classCallCheck\"","webpack:///external \"@babel/runtime/helpers/createClass\"","webpack:///external \"@splunk/ui-utils/i18n\"","webpack:///external \"@babel/runtime/helpers/inherits\"","webpack:///external \"@babel/runtime/helpers/possibleConstructorReturn\"","webpack:///external \"@babel/runtime/regenerator\"","webpack:///external \"@babel/runtime/helpers/slicedToArray\"","webpack:///external \"@babel/runtime/helpers/taggedTemplateLiteral\"","webpack:///external \"styled-components\"","webpack:///./src/style.js","webpack:///external \"lodash/isNumber\"","webpack:///external \"@babel/runtime/helpers/asyncToGenerator\"","webpack:///./src/iconUtils.js","webpack:///external \"xmlserializer\"","webpack:///external \"@splunk/visualization-context/IconContext\"","webpack:///./src/RemoteIcon.jsx"],"names":["toPx","number","defaultNumber","arguments","length","undefined","isNumber","concat","toDimension","_ref","width","height","css","arrayToCSSProp","prop","vals","Array","isArray","toMargin","margins","toPadding","paddings","isRemoteIcon","icon","indexOf","isDataURI","startsWith","shouldChangeFill","fillAttr","fillStyle","strokeAttr","strokeStyle","noneFillAttr","noneFillStyle","noFillHasStroke","shouldChangeStroke","_ref2","noneStrokeAttr","noneStrokeStyle","hasFill","noStroke","b64EncodeUnicode","str","btoa","encodeURIComponent","replace","match","p1","String","fromCharCode","IconContainer","styled","div","_templateObject","_taggedTemplateLiteral","props","onClick","ColoredIcon","img","_templateObject2","opacity","RemoteIcon","_PureComponent","_inherits","_super","_createSuper","_this","_classCallCheck","call","state","iconDataURI","_createClass","key","value","UNSAFE_componentWillMount","getIcon","iconURL","color","componentDidUpdate","prevProps","_getIcon","_asyncToGenerator","_regeneratorRuntime","mark","_callee2","_this2","getIconDataURI","wrap","_callee2$","_context2","prev","next","_callee","iconRegistry","_callee$","_context","isRegistryURL","context","getByURL","sent","abrupt","dataURI","t0","console","error","_","stop","apply","colorIcon","setState","_x","_x2","src","_src$split","split","_src$split2","_slicedToArray","type","_this3","fetch","then","response","text","parser","DOMParser","xmlDoc","parseFromString","svg","getElementsByTagName","children","querySelectorAll","style","i","child","BASIC_SHAPES","includes","tagName","getAttribute","fill","stroke","setAttribute","svgStr","xmlserializer","serializeToString","catch","render","_this$props","onIconClick","React","createElement","alt","referrerPolicy","PureComponent","_defineProperty","IconContext","T","string","func"],"mappings":";;;;;;;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;AClFA,uC;;;;;;ACAA,kC;;;;;;ACAA,kE;;;;;;ACAA,kE;;;;;;;ACAA,kE;;;;;;ACAA,+D;;;;;;ACAA,kD;;;;;;ACAA,4D;;;;;;ACAA,6E;;;;;;ACAA,uD;;;;;;ACAA,iE;;;;;;ACAA,yE;;;;;;ACAA,8C;;;;;;;;;ACAA;AAAA;AAAA;AAAA;AAAA;A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;QACRuD,GAAG,EAAE1C,WAAY;QACjBgF,GAAG,EAAC,aAAa;QACjB5I,KAAK,EAAEA,KAAM;QACbC,MAAM,EAAEA,MAAO;QACfiD,OAAO,EAAEA,OAAQ;QACjB2F,cAAc,EAAC;MAAa,EAC9B,CACU;IAExB;EAAC;EAAA,OAAA1F,UAAA;AAAA,EAxJoB2F,oDAAa;AAAAC,4EAAA,CAAhC5F,UAAU,iBACS6F,iFAAW;AAAAD,4EAAA,CAD9B5F,UAAU,eAGO;EACfe,OAAO,EAAE+E,kDAAC,CAACC,MAAM;EACjB/E,KAAK,EAAE8E,kDAAC,CAACC,MAAM;EACflJ,KAAK,EAAEiJ,kDAAC,CAAC1J,MAAM;EACfU,MAAM,EAAEgJ,kDAAC,CAAC1J,MAAM;EAChB2D,OAAO,EAAE+F,kDAAC,CAAC1J,MAAM;EACjBkJ,WAAW,EAAEQ,kDAAC,CAACE;AACnB,CAAC;AAAAJ,4EAAA,CAVC5F,UAAU,kBAYU;EAClBnD,KAAK,EAAE,GAAG;EACVC,MAAM,EAAE,GAAG;EACXiD,OAAO,EAAE;AACb,CAAC;AAAA6F,4EAAA,CAhBC5F,UAAU,kBAkBU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,CAAC;AAyI/EA,yEAAU,E","file":"RemoteIcon.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 47);\n","module.exports = require(\"prop-types\");","module.exports = require(\"react\");","module.exports = require(\"@babel/runtime/helpers/defineProperty\");","module.exports = require(\"@babel/runtime/helpers/getPrototypeOf\");","module.exports = require(\"@babel/runtime/helpers/classCallCheck\");","module.exports = require(\"@babel/runtime/helpers/createClass\");","module.exports = require(\"@splunk/ui-utils/i18n\");","module.exports = require(\"@babel/runtime/helpers/inherits\");","module.exports = require(\"@babel/runtime/helpers/possibleConstructorReturn\");","module.exports = require(\"@babel/runtime/regenerator\");","module.exports = require(\"@babel/runtime/helpers/slicedToArray\");","module.exports = require(\"@babel/runtime/helpers/taggedTemplateLiteral\");","module.exports = require(\"styled-components\");","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","module.exports = require(\"lodash/isNumber\");","module.exports = require(\"@babel/runtime/helpers/asyncToGenerator\");","/**\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","module.exports = require(\"xmlserializer\");","module.exports = require(\"@splunk/visualization-context/IconContext\");","/* 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"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"prop-types\"","webpack:///external \"react\"","webpack:///external \"@babel/runtime/helpers/defineProperty\"","webpack:///external \"@babel/runtime/helpers/getPrototypeOf\"","webpack:///external \"@babel/runtime/helpers/classCallCheck\"","webpack:///external \"@babel/runtime/helpers/createClass\"","webpack:///external \"@splunk/ui-utils/i18n\"","webpack:///external \"@babel/runtime/helpers/inherits\"","webpack:///external \"@babel/runtime/helpers/possibleConstructorReturn\"","webpack:///external \"@babel/runtime/regenerator\"","webpack:///external \"@babel/runtime/helpers/slicedToArray\"","webpack:///external \"@babel/runtime/helpers/taggedTemplateLiteral\"","webpack:///external \"styled-components\"","webpack:///./src/style.js","webpack:///external \"lodash/isNumber\"","webpack:///external \"@babel/runtime/helpers/asyncToGenerator\"","webpack:///./src/iconUtils.js","webpack:///external \"xmlserializer\"","webpack:///external \"@splunk/visualization-context/IconContext\"","webpack:///./src/RemoteIcon.jsx"],"names":["toPx","defaultNumber","isNumber","number","toDimension","width","height","css","arrayToCSSProp","vals","Array","toMargin","margins","toPadding","paddings","isRemoteIcon","icon","isDataURI","shouldChangeFill","fillAttr","fillStyle","strokeAttr","strokeStyle","noneFillAttr","noneFillStyle","noFillHasStroke","shouldChangeStroke","noneStrokeAttr","noneStrokeStyle","hasFill","noStroke","b64EncodeUnicode","btoa","String","IconContainer","styled","props","ColoredIcon","RemoteIcon","iconDataURI","prevProps","getIconDataURI","iconRegistry","console","_","src","type","fetch","response","parser","xmlDoc","svg","children","i","child","svgStr","xmlserializer","opacity","onIconClick","PureComponent","IconContext","iconURL","T","color","func"],"mappings":";;;;;;;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;AClFA,uC;;;;;;ACAA,kC;;;;;;;ACAA,kE;;;;;;ACAA,kE;;;;;;ACAA,kE;;;;;;ACAA,+D;;;;;;ACAA,kD;;;;;;ACAA,4D;;;;;;ACAA,6E;;;;;;ACAA,uD;;;;;;ACAA,iE;;;;;;ACAA,yE;;;;;;ACAA,8C;;;;;;;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA;AACA;AACA;AACA;;AACO,IAAMA,IAAI,GAAG,SAAPA,IAAO;AAAA,MAASC,aAAT;AAAA,SAChBC,sDAAQ,CAARA,MAAQ,CAARA,6BAAmCC,MAAM,IAAIH,IAAI,CADjC,aACiC,CADjC;AAAb;AAGP;AACA;AACA;AACA;;AACO,IAAMI,WAAW,GAAG,SAAdA,WAAc,OAAuB;AAAA,MAApBC,KAAoB,QAApBA,KAAoB;AAAA,MAAbC,MAAa,QAAbA,MAAa;A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,qDAAa,CAAbA,kBAAhC,GAAgCA,CAAD,CAA/B;AACA,YAAMjB,WAAW,uCAAjB,MAAiB,CAAjB;;AACA,cAAI,CAAJ,SAAc;AAAEA,qBAAW,EAAXA;AAAF,SAAd;AAjCRQ,eAmCW,YAAM;AACT;AACAJ,eAAO,CAAPA,MAAcC,gEAAC,CAAfD,sCAAe,CAAfA;AArCRI;AAuCH;;;WAED,kBAAS;AAAA,UACGR,WADH,GACmB,KADnB,KACmB,CADnB;AAAA,wBAE2C,KAF3C;AAAA,UAEGlC,KAFH;AAAA,UAEUC,MAFV;AAAA,UAEkBmD,OAFlB;AAAA,UAE2BC,WAF3B;;AAIL,UAAI,CAAJ,aAAkB;AACd;AACH;;AACD,0BACI;AAAe,aAAK,EAApB;AAA6B,cAAM,EAAnC;AAA6C,eAAO,EAAEA;AAAtD,sBACI;AACI,WAAG,EADP;AAEI,WAAG,EAFP;AAGI,aAAK,EAHT;AAII,cAAM,EAJV;AAKI,eAAO,EALX;AAMI,sBAAc,EAAC;AANnB,QADJ,CADJ;AAYH;;;;EAxJoBC,oD;;6EAAnBrB,U,iBACmBsB,iF;;6EADnBtB,U,eAGiB;AACfuB,SAAO,EAAEC,kDAAC,CADK;AAEfC,OAAK,EAAED,kDAAC,CAFO;AAGfzD,OAAK,EAAEyD,kDAAC,CAHO;AAIfxD,QAAM,EAAEwD,kDAAC,CAJM;AAKfL,SAAO,EAAEK,kDAAC,CALK;AAMfJ,aAAW,EAAEI,kDAAC,CAACE;AANA,C;;6EAHjB1B,U,kBAYoB;AAClBjC,OAAK,EADa;AAElBC,QAAM,EAFY;AAGlBmD,SAAO,EAAE;AAHS,C;;6EAZpBnB,U,kBAkBoB,oE;;AAyI1B,2E","file":"RemoteIcon.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 46);\n","module.exports = require(\"prop-types\");","module.exports = require(\"react\");","module.exports = require(\"@babel/runtime/helpers/defineProperty\");","module.exports = require(\"@babel/runtime/helpers/getPrototypeOf\");","module.exports = require(\"@babel/runtime/helpers/classCallCheck\");","module.exports = require(\"@babel/runtime/helpers/createClass\");","module.exports = require(\"@splunk/ui-utils/i18n\");","module.exports = require(\"@babel/runtime/helpers/inherits\");","module.exports = require(\"@babel/runtime/helpers/possibleConstructorReturn\");","module.exports = require(\"@babel/runtime/regenerator\");","module.exports = require(\"@babel/runtime/helpers/slicedToArray\");","module.exports = require(\"@babel/runtime/helpers/taggedTemplateLiteral\");","module.exports = require(\"styled-components\");","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","module.exports = require(\"lodash/isNumber\");","module.exports = require(\"@babel/runtime/helpers/asyncToGenerator\");","/**\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","module.exports = require(\"xmlserializer\");","module.exports = require(\"@splunk/visualization-context/IconContext\");","/* 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"],"sourceRoot":""}
|
package/RemoteImage.js
CHANGED
|
@@ -87,7 +87,7 @@ module.exports =
|
|
|
87
87
|
/******/
|
|
88
88
|
/******/
|
|
89
89
|
/******/ // Load entry module and return exports
|
|
90
|
-
/******/ return __webpack_require__(__webpack_require__.s =
|
|
90
|
+
/******/ return __webpack_require__(__webpack_require__.s = 47);
|
|
91
91
|
/******/ })
|
|
92
92
|
/************************************************************************/
|
|
93
93
|
/******/ ([
|
|
@@ -103,19 +103,19 @@ module.exports = require("prop-types");
|
|
|
103
103
|
module.exports = require("react");
|
|
104
104
|
|
|
105
105
|
/***/ }),
|
|
106
|
-
/* 2
|
|
106
|
+
/* 2 */,
|
|
107
|
+
/* 3 */
|
|
107
108
|
/***/ (function(module, exports) {
|
|
108
109
|
|
|
109
110
|
module.exports = require("@babel/runtime/helpers/defineProperty");
|
|
110
111
|
|
|
111
112
|
/***/ }),
|
|
112
|
-
/*
|
|
113
|
+
/* 4 */
|
|
113
114
|
/***/ (function(module, exports) {
|
|
114
115
|
|
|
115
116
|
module.exports = require("@babel/runtime/helpers/getPrototypeOf");
|
|
116
117
|
|
|
117
118
|
/***/ }),
|
|
118
|
-
/* 4 */,
|
|
119
119
|
/* 5 */
|
|
120
120
|
/***/ (function(module, exports) {
|
|
121
121
|
|
|
@@ -223,8 +223,7 @@ module.exports = require("@splunk/visualizations-shared/style");
|
|
|
223
223
|
/* 44 */,
|
|
224
224
|
/* 45 */,
|
|
225
225
|
/* 46 */,
|
|
226
|
-
/* 47
|
|
227
|
-
/* 48 */
|
|
226
|
+
/* 47 */
|
|
228
227
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
229
228
|
|
|
230
229
|
"use strict";
|
|
@@ -240,9 +239,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
240
239
|
/* harmony import */ var _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_3__);
|
|
241
240
|
/* harmony import */ var _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9);
|
|
242
241
|
/* harmony import */ var _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_4__);
|
|
243
|
-
/* harmony import */ var _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
|
|
242
|
+
/* harmony import */ var _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(4);
|
|
244
243
|
/* harmony import */ var _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_5__);
|
|
245
|
-
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(
|
|
244
|
+
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(3);
|
|
246
245
|
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_6__);
|
|
247
246
|
/* harmony import */ var _babel_runtime_helpers_taggedTemplateLiteral__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(12);
|
|
248
247
|
/* harmony import */ var _babel_runtime_helpers_taggedTemplateLiteral__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_taggedTemplateLiteral__WEBPACK_IMPORTED_MODULE_7__);
|
|
@@ -273,26 +272,35 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
273
272
|
|
|
274
273
|
|
|
275
274
|
|
|
275
|
+
|
|
276
276
|
var _templateObject;
|
|
277
277
|
|
|
278
|
+
|
|
279
|
+
|
|
278
280
|
function _createSuper(Derived) {
|
|
279
281
|
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
282
|
+
|
|
280
283
|
return function _createSuperInternal() {
|
|
281
284
|
var Super = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_5___default()(Derived),
|
|
282
|
-
|
|
285
|
+
result;
|
|
286
|
+
|
|
283
287
|
if (hasNativeReflectConstruct) {
|
|
284
288
|
var NewTarget = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_5___default()(this).constructor;
|
|
289
|
+
|
|
285
290
|
result = Reflect.construct(Super, arguments, NewTarget);
|
|
286
291
|
} else {
|
|
287
292
|
result = Super.apply(this, arguments);
|
|
288
293
|
}
|
|
294
|
+
|
|
289
295
|
return _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_4___default()(this, result);
|
|
290
296
|
};
|
|
291
297
|
}
|
|
298
|
+
|
|
292
299
|
function _isNativeReflectConstruct() {
|
|
293
300
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
294
301
|
if (Reflect.construct.sham) return false;
|
|
295
302
|
if (typeof Proxy === "function") return true;
|
|
303
|
+
|
|
296
304
|
try {
|
|
297
305
|
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
298
306
|
return true;
|
|
@@ -312,28 +320,39 @@ function _isNativeReflectConstruct() {
|
|
|
312
320
|
* check if an image is considered as remote image
|
|
313
321
|
* @param {*} src
|
|
314
322
|
*/
|
|
323
|
+
|
|
315
324
|
var isRemoteImage = function isRemoteImage() {
|
|
316
325
|
var src = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
326
|
+
|
|
317
327
|
var _src$split = src.split('://'),
|
|
318
|
-
|
|
319
|
-
|
|
328
|
+
_src$split2 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_8___default()(_src$split, 1),
|
|
329
|
+
type = _src$split2[0];
|
|
330
|
+
|
|
320
331
|
return src.indexOf('://') > -1 && type !== 'http' && type !== 'https';
|
|
321
332
|
};
|
|
333
|
+
|
|
322
334
|
var toImageDimensions = function toImageDimensions(props) {
|
|
323
335
|
if (props.shouldPreserveAspectRatio) {
|
|
324
336
|
return "\n max-width: 100%;\n max-height: 100%;\n width: auto;\n height: auto;\n ";
|
|
325
337
|
}
|
|
338
|
+
|
|
326
339
|
return Object(_splunk_visualizations_shared_style__WEBPACK_IMPORTED_MODULE_16__["toDimension"])(lodash_pick__WEBPACK_IMPORTED_MODULE_13___default()(props, ['width', 'height']));
|
|
327
340
|
};
|
|
341
|
+
|
|
328
342
|
var Image = styled_components__WEBPACK_IMPORTED_MODULE_12___default.a.img(_templateObject || (_templateObject = _babel_runtime_helpers_taggedTemplateLiteral__WEBPACK_IMPORTED_MODULE_7___default()(["\n display: block;\n ", ";\n"])), function (props) {
|
|
329
343
|
return toImageDimensions(props);
|
|
330
344
|
});
|
|
345
|
+
|
|
331
346
|
var RemoteImage = /*#__PURE__*/function (_PureComponent) {
|
|
332
347
|
_babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_3___default()(RemoteImage, _PureComponent);
|
|
348
|
+
|
|
333
349
|
var _super = _createSuper(RemoteImage);
|
|
350
|
+
|
|
334
351
|
function RemoteImage(props) {
|
|
335
352
|
var _this;
|
|
353
|
+
|
|
336
354
|
_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default()(this, RemoteImage);
|
|
355
|
+
|
|
337
356
|
_this = _super.call(this, props);
|
|
338
357
|
_this.state = {
|
|
339
358
|
imageDataURI: null,
|
|
@@ -341,6 +360,7 @@ var RemoteImage = /*#__PURE__*/function (_PureComponent) {
|
|
|
341
360
|
};
|
|
342
361
|
return _this;
|
|
343
362
|
}
|
|
363
|
+
|
|
344
364
|
_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default()(RemoteImage, [{
|
|
345
365
|
key: "componentDidMount",
|
|
346
366
|
value: function componentDidMount() {
|
|
@@ -352,6 +372,7 @@ var RemoteImage = /*#__PURE__*/function (_PureComponent) {
|
|
|
352
372
|
if (prevProps.imageURL !== this.props.imageURL) {
|
|
353
373
|
this.getImage(this.props.imageURL);
|
|
354
374
|
}
|
|
375
|
+
|
|
355
376
|
if (prevProps.preserveAspectRatio !== this.props.preserveAspectRatio) {
|
|
356
377
|
// eslint-disable-next-line react/no-did-update-set-state
|
|
357
378
|
this.setState({
|
|
@@ -369,13 +390,16 @@ var RemoteImage = /*#__PURE__*/function (_PureComponent) {
|
|
|
369
390
|
switch (_context.prev = _context.next) {
|
|
370
391
|
case 0:
|
|
371
392
|
imageRegistry = this.context;
|
|
393
|
+
|
|
372
394
|
if (!imageRegistry) {
|
|
373
395
|
_context.next = 12;
|
|
374
396
|
break;
|
|
375
397
|
}
|
|
398
|
+
|
|
376
399
|
_context.prev = 2;
|
|
377
400
|
_context.next = 5;
|
|
378
401
|
return imageRegistry.getByURL(imageURL);
|
|
402
|
+
|
|
379
403
|
case 5:
|
|
380
404
|
image = _context.sent;
|
|
381
405
|
this.setState({
|
|
@@ -383,11 +407,13 @@ var RemoteImage = /*#__PURE__*/function (_PureComponent) {
|
|
|
383
407
|
});
|
|
384
408
|
_context.next = 12;
|
|
385
409
|
break;
|
|
410
|
+
|
|
386
411
|
case 9:
|
|
387
412
|
_context.prev = 9;
|
|
388
|
-
_context.t0 = _context["catch"](2);
|
|
389
|
-
|
|
413
|
+
_context.t0 = _context["catch"](2); // eslint-disable-next-line no-console
|
|
414
|
+
|
|
390
415
|
console.error(_context.t0);
|
|
416
|
+
|
|
391
417
|
case 12:
|
|
392
418
|
case "end":
|
|
393
419
|
return _context.stop();
|
|
@@ -395,9 +421,11 @@ var RemoteImage = /*#__PURE__*/function (_PureComponent) {
|
|
|
395
421
|
}
|
|
396
422
|
}, _callee, this, [[2, 9]]);
|
|
397
423
|
}));
|
|
424
|
+
|
|
398
425
|
function getImage(_x) {
|
|
399
426
|
return _getImage.apply(this, arguments);
|
|
400
427
|
}
|
|
428
|
+
|
|
401
429
|
return getImage;
|
|
402
430
|
}()
|
|
403
431
|
}, {
|
|
@@ -405,12 +433,14 @@ var RemoteImage = /*#__PURE__*/function (_PureComponent) {
|
|
|
405
433
|
value: function render() {
|
|
406
434
|
var imageDataURI = this.state.imageDataURI;
|
|
407
435
|
var _this$props = this.props,
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
436
|
+
width = _this$props.width,
|
|
437
|
+
height = _this$props.height,
|
|
438
|
+
title = _this$props.title;
|
|
439
|
+
|
|
411
440
|
if (!imageDataURI) {
|
|
412
441
|
return null;
|
|
413
442
|
}
|
|
443
|
+
|
|
414
444
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_10___default.a.createElement(Image, {
|
|
415
445
|
src: imageDataURI,
|
|
416
446
|
shouldPreserveAspectRatio: this.state.preserveAspectRatio,
|
|
@@ -423,9 +453,12 @@ var RemoteImage = /*#__PURE__*/function (_PureComponent) {
|
|
|
423
453
|
});
|
|
424
454
|
}
|
|
425
455
|
}]);
|
|
456
|
+
|
|
426
457
|
return RemoteImage;
|
|
427
458
|
}(react__WEBPACK_IMPORTED_MODULE_10__["PureComponent"]);
|
|
459
|
+
|
|
428
460
|
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_6___default()(RemoteImage, "contextType", _splunk_visualization_context_ImageContext__WEBPACK_IMPORTED_MODULE_15___default.a);
|
|
461
|
+
|
|
429
462
|
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_6___default()(RemoteImage, "propTypes", {
|
|
430
463
|
imageURL: prop_types__WEBPACK_IMPORTED_MODULE_11___default.a.string,
|
|
431
464
|
width: prop_types__WEBPACK_IMPORTED_MODULE_11___default.a.oneOfType([prop_types__WEBPACK_IMPORTED_MODULE_11___default.a.string, prop_types__WEBPACK_IMPORTED_MODULE_11___default.a.number]),
|
|
@@ -433,9 +466,11 @@ _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_6___default()(Rem
|
|
|
433
466
|
preserveAspectRatio: prop_types__WEBPACK_IMPORTED_MODULE_11___default.a.bool,
|
|
434
467
|
title: prop_types__WEBPACK_IMPORTED_MODULE_11___default.a.string
|
|
435
468
|
});
|
|
469
|
+
|
|
436
470
|
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_6___default()(RemoteImage, "defaultProps", {
|
|
437
471
|
preserveAspectRatio: false
|
|
438
472
|
});
|
|
473
|
+
|
|
439
474
|
/* harmony default export */ __webpack_exports__["default"] = (RemoteImage);
|
|
440
475
|
|
|
441
476
|
/***/ })
|
package/RemoteImage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"prop-types\"","webpack:///external \"react\"","webpack:///external \"@babel/runtime/helpers/defineProperty\"","webpack:///external \"@babel/runtime/helpers/getPrototypeOf\"","webpack:///external \"@babel/runtime/helpers/classCallCheck\"","webpack:///external \"@babel/runtime/helpers/createClass\"","webpack:///external \"@splunk/ui-utils/i18n\"","webpack:///external \"@babel/runtime/helpers/inherits\"","webpack:///external \"@babel/runtime/helpers/possibleConstructorReturn\"","webpack:///external \"@babel/runtime/regenerator\"","webpack:///external \"@babel/runtime/helpers/slicedToArray\"","webpack:///external \"@babel/runtime/helpers/taggedTemplateLiteral\"","webpack:///external \"styled-components\"","webpack:///external \"@babel/runtime/helpers/asyncToGenerator\"","webpack:///external \"lodash/pick\"","webpack:///external \"@splunk/visualization-context/ImageContext\"","webpack:///external \"@splunk/visualizations-shared/style\"","webpack:///./src/RemoteImage.jsx"],"names":["isRemoteImage","src","arguments","length","undefined","_src$split","split","_src$split2","_slicedToArray","type","indexOf","toImageDimensions","props","shouldPreserveAspectRatio","toDimension","pick","Image","styled","img","_templateObject","_taggedTemplateLiteral","RemoteImage","_PureComponent","_inherits","_super","_createSuper","_this","_classCallCheck","call","state","imageDataURI","preserveAspectRatio","_createClass","key","value","componentDidMount","getImage","imageURL","componentDidUpdate","prevProps","setState","_getImage","_asyncToGenerator","_regeneratorRuntime","mark","_callee","imageRegistry","image","wrap","_callee$","_context","prev","next","context","getByURL","sent","dataURI","t0","console","error","stop","_x","apply","render","_this$props","width","height","title","React","createElement","alt","_","onError","e","target","PureComponent","_defineProperty","ImageContext","T","string","oneOfType","number","bool"],"mappings":";;;;;;;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH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I;MACf;MACA,oBACIsC,6CAAA,CAAAC,aAAA,CAACrD,KAAK;QACFf,GAAG,EAAE6B,YAAa;QAClBjB,yBAAyB,EAAE,IAAI,CAACgB,KAAK,CAACE,mBAAoB;QAC1DkC,KAAK,EAAEA,KAAM;QACbC,MAAM,EAAEA,MAAO;QACfI,GAAG,EAAEC,gEAAC,CAACJ,KAAK,CAAE;QACdK,OAAO,EAAE,SAAAA,QAAAC,CAAC,EAAI;UACVA,CAAC,CAACC,MAAM,CAACJ,GAAG,GAAGC,gEAAC,CAAC,iBAAiB,CAAC;QACvC;MAAE,EACJ;IAEV;EAAC;EAAA,OAAAlD,WAAA;AAAA,EAlEqBsD,oDAAa;AAAAC,4EAAA,CAAjCvD,WAAW,iBACQwD,kFAAY;AAAAD,4EAAA,CAD/BvD,WAAW,eAGM;EACfgB,QAAQ,EAAEyC,kDAAC,CAACC,MAAM;EAClBd,KAAK,EAAEa,kDAAC,CAACE,SAAS,CAAC,CAACF,kDAAC,CAACC,MAAM,EAAED,kDAAC,CAACG,MAAM,CAAC,CAAC;EACxCf,MAAM,EAAEY,kDAAC,CAACE,SAAS,CAAC,CAACF,kDAAC,CAACC,MAAM,EAAED,kDAAC,CAACG,MAAM,CAAC,CAAC;EACzClD,mBAAmB,EAAE+C,kDAAC,CAACI,IAAI;EAC3Bf,KAAK,EAAEW,kDAAC,CAACC;AACb,CAAC;AAAAH,4EAAA,CATCvD,WAAW,kBAWS;EAClBU,mBAAmB,EAAE;AACzB,CAAC;AAwDUV,0EAAW,E","file":"RemoteImage.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 48);\n","module.exports = require(\"prop-types\");","module.exports = require(\"react\");","module.exports = require(\"@babel/runtime/helpers/defineProperty\");","module.exports = require(\"@babel/runtime/helpers/getPrototypeOf\");","module.exports = require(\"@babel/runtime/helpers/classCallCheck\");","module.exports = require(\"@babel/runtime/helpers/createClass\");","module.exports = require(\"@splunk/ui-utils/i18n\");","module.exports = require(\"@babel/runtime/helpers/inherits\");","module.exports = require(\"@babel/runtime/helpers/possibleConstructorReturn\");","module.exports = require(\"@babel/runtime/regenerator\");","module.exports = require(\"@babel/runtime/helpers/slicedToArray\");","module.exports = require(\"@babel/runtime/helpers/taggedTemplateLiteral\");","module.exports = require(\"styled-components\");","module.exports = require(\"@babel/runtime/helpers/asyncToGenerator\");","module.exports = require(\"lodash/pick\");","module.exports = require(\"@splunk/visualization-context/ImageContext\");","module.exports = require(\"@splunk/visualizations-shared/style\");","import React, { PureComponent } from 'react';\nimport T from 'prop-types';\nimport styled from 'styled-components';\nimport pick from 'lodash/pick';\nimport { _ } from '@splunk/ui-utils/i18n';\nimport ImageContext from '@splunk/visualization-context/ImageContext';\nimport { toDimension } from '@splunk/visualizations-shared/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\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`\n display: block;\n ${props => toImageDimensions(props)};\n`;\n\nclass RemoteImage extends PureComponent {\n static contextType = ImageContext;\n\n static propTypes = {\n imageURL: T.string,\n width: T.oneOfType([T.string, T.number]),\n height: T.oneOfType([T.string, T.number]),\n preserveAspectRatio: T.bool,\n title: T.string,\n };\n\n static defaultProps = {\n preserveAspectRatio: false,\n };\n\n constructor(props) {\n super(props);\n this.state = { imageDataURI: null, preserveAspectRatio: props.preserveAspectRatio };\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({ preserveAspectRatio: this.props.preserveAspectRatio });\n }\n }\n\n async getImage(imageURL) {\n const imageRegistry = 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.alt = _('Image not found');\n }}\n />\n );\n }\n}\n\nexport default RemoteImage;\n"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"prop-types\"","webpack:///external \"react\"","webpack:///external \"@babel/runtime/helpers/defineProperty\"","webpack:///external \"@babel/runtime/helpers/getPrototypeOf\"","webpack:///external \"@babel/runtime/helpers/classCallCheck\"","webpack:///external \"@babel/runtime/helpers/createClass\"","webpack:///external \"@splunk/ui-utils/i18n\"","webpack:///external \"@babel/runtime/helpers/inherits\"","webpack:///external \"@babel/runtime/helpers/possibleConstructorReturn\"","webpack:///external \"@babel/runtime/regenerator\"","webpack:///external \"@babel/runtime/helpers/slicedToArray\"","webpack:///external \"@babel/runtime/helpers/taggedTemplateLiteral\"","webpack:///external \"styled-components\"","webpack:///external \"@babel/runtime/helpers/asyncToGenerator\"","webpack:///external \"lodash/pick\"","webpack:///external \"@splunk/visualization-context/ImageContext\"","webpack:///external \"@splunk/visualizations-shared/style\"","webpack:///./src/RemoteImage.jsx"],"names":["isRemoteImage","src","type","toImageDimensions","props","toDimension","pick","Image","styled","RemoteImage","imageDataURI","preserveAspectRatio","prevProps","imageRegistry","image","dataURI","console","width","height","title","_","e","PureComponent","ImageContext","imageURL","T","string"],"mappings":";;;;;;;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;AClFA,uC;;;;;;ACAA,kC;;;;;;;ACAA,kE;;;;;;ACAA,kE;;;;;;ACAA,kE;;;;;;ACAA,+D;;;;;;ACAA,kD;;;;;;ACAA,4D;;;;;;ACAA,6E;;;;;;ACAA,uD;;;;;;ACAA,iE;;;;;;ACAA,yE;;;;;;ACAA,8C;;;;;;;;;;;;ACAA,oE;;;;;;;;;;;;;;;;;ACAA,wC;;;;;;ACAA,uE;;;;;;ACAA,gE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;A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;AAAA;AAAA,oDAOY;;AACAC,uBAAO,CAAPA;;AARZ;AAAA;AAAA;AAAA;AAAA;AAAA;;;;;;;;;;;WAaA,kBAAS;AAAA,UACGN,YADH,GACoB,KADpB,KACoB,CADpB;AAAA,wBAE4B,KAF5B;AAAA,UAEGO,KAFH;AAAA,UAEUC,MAFV;AAAA,UAEkBC,KAFlB;;AAIL,UAAI,CAAJ,cAAmB;AACf;AACH;;AACD,0BACI;AACI,WAAG,EADP;AAEI,iCAAyB,EAAE,WAF/B;AAGI,aAAK,EAHT;AAII,cAAM,EAJV;AAKI,WAAG,EAAEC,gEAAC,CALV,KAKU,CALV;AAMI,eAAO,EAAE,oBAAK;AACVC,WAAC,CAADA,aAAeD,gEAAC,CAAhBC,iBAAgB,CAAhBA;AACH;AARL,QADJ;AAYH;;;;EAlEqBC,oD;;6EAApBb,W,iBACmBc,kF;;6EADnBd,W,eAGiB;AACfe,UAAQ,EAAEC,kDAAC,CADI;AAEfR,OAAK,EAAEQ,kDAAC,CAADA,UAAY,CAACA,kDAAC,CAAF,QAAWA,kDAAC,CAFhB,MAEI,CAAZA,CAFQ;AAGfP,QAAM,EAAEO,kDAAC,CAADA,UAAY,CAACA,kDAAC,CAAF,QAAWA,kDAAC,CAHjB,MAGK,CAAZA,CAHO;AAIfd,qBAAmB,EAAEc,kDAAC,CAJP;AAKfN,OAAK,EAAEM,kDAAC,CAACC;AALM,C;;6EAHjBjB,W,kBAWoB;AAClBE,qBAAmB,EAAE;AADH,C;;AA0D1B,4E","file":"RemoteImage.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 47);\n","module.exports = require(\"prop-types\");","module.exports = require(\"react\");","module.exports = require(\"@babel/runtime/helpers/defineProperty\");","module.exports = require(\"@babel/runtime/helpers/getPrototypeOf\");","module.exports = require(\"@babel/runtime/helpers/classCallCheck\");","module.exports = require(\"@babel/runtime/helpers/createClass\");","module.exports = require(\"@splunk/ui-utils/i18n\");","module.exports = require(\"@babel/runtime/helpers/inherits\");","module.exports = require(\"@babel/runtime/helpers/possibleConstructorReturn\");","module.exports = require(\"@babel/runtime/regenerator\");","module.exports = require(\"@babel/runtime/helpers/slicedToArray\");","module.exports = require(\"@babel/runtime/helpers/taggedTemplateLiteral\");","module.exports = require(\"styled-components\");","module.exports = require(\"@babel/runtime/helpers/asyncToGenerator\");","module.exports = require(\"lodash/pick\");","module.exports = require(\"@splunk/visualization-context/ImageContext\");","module.exports = require(\"@splunk/visualizations-shared/style\");","import React, { PureComponent } from 'react';\nimport T from 'prop-types';\nimport styled from 'styled-components';\nimport pick from 'lodash/pick';\nimport { _ } from '@splunk/ui-utils/i18n';\nimport ImageContext from '@splunk/visualization-context/ImageContext';\nimport { toDimension } from '@splunk/visualizations-shared/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\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`\n display: block;\n ${props => toImageDimensions(props)};\n`;\n\nclass RemoteImage extends PureComponent {\n static contextType = ImageContext;\n\n static propTypes = {\n imageURL: T.string,\n width: T.oneOfType([T.string, T.number]),\n height: T.oneOfType([T.string, T.number]),\n preserveAspectRatio: T.bool,\n title: T.string,\n };\n\n static defaultProps = {\n preserveAspectRatio: false,\n };\n\n constructor(props) {\n super(props);\n this.state = { imageDataURI: null, preserveAspectRatio: props.preserveAspectRatio };\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({ preserveAspectRatio: this.props.preserveAspectRatio });\n }\n }\n\n async getImage(imageURL) {\n const imageRegistry = 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.alt = _('Image not found');\n }}\n />\n );\n }\n}\n\nexport default RemoteImage;\n"],"sourceRoot":""}
|