@splunk/visualizations-shared 25.7.1 → 25.8.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 +5 -60
- package/Downloader.js.map +1 -1
- package/FileDownloader.js +21 -95
- package/FileDownloader.js.map +1 -1
- package/JSONSchemaUtils.js +0 -5
- package/JSONSchemaUtils.js.map +1 -1
- package/Message.js +10 -21
- package/Message.js.map +1 -1
- package/RemoteIcon.js +33 -86
- package/RemoteIcon.js.map +1 -1
- package/RemoteImage.js +8 -44
- package/RemoteImage.js.map +1 -1
- package/SanitizeProps.js +14 -39
- package/SanitizeProps.js.map +1 -1
- package/SizeAwareWrapper.js +6 -34
- package/SizeAwareWrapper.js.map +1 -1
- package/VisualizationDocPage.js +18 -64
- package/VisualizationDocPage.js.map +1 -1
- package/colorConstants.js.map +1 -1
- package/colorUtils.js +14 -27
- package/colorUtils.js.map +1 -1
- package/configUtils.js +0 -2
- package/configUtils.js.map +1 -1
- package/console.js +0 -12
- package/console.js.map +1 -1
- package/dataSourceUtils.js +1 -10
- package/dataSourceUtils.js.map +1 -1
- package/domUtils.js.map +1 -1
- package/hocUtils.js +0 -14
- package/hocUtils.js.map +1 -1
- package/i18n.js +0 -2
- package/i18n.js.map +1 -1
- package/iconUtils.js +12 -11
- package/iconUtils.js.map +1 -1
- package/mapUtils.js +0 -4
- package/mapUtils.js.map +1 -1
- package/namedColors.js +2 -2
- package/namedColors.js.map +1 -1
- package/numberUtils.js +17 -27
- package/numberUtils.js.map +1 -1
- package/package.json +5 -5
- package/previewVizMessage.js.map +1 -1
- package/propUtils.js +5 -7
- package/propUtils.js.map +1 -1
- package/schemaUtils.js +10 -10
- package/schemaUtils.js.map +1 -1
- package/simpleXMLOptions.js +2 -2
- package/simpleXMLOptions.js.map +1 -1
- package/style.js +6 -11
- package/style.js.map +1 -1
- package/testHelper.js.map +1 -1
- package/themeUtils.js +7 -8
- package/themeUtils.js.map +1 -1
- package/trellisUtils.js +18 -62
- 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","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;;QA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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 = 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","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;;;;;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C,aAAA,CAACnG,aAAa;QAACxC,KAAK,EAAEA,KAAM;QAACC,MAAM,EAAEA,MAAO;QAAC6C,OAAO,EAAE2F;MAAY,gBAC9DC,6CAAA,CAAAC,aAAA,CAAC5F,WAAW;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":""}
|
package/RemoteImage.js
CHANGED
|
@@ -273,35 +273,26 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
273
273
|
|
|
274
274
|
|
|
275
275
|
|
|
276
|
-
|
|
277
276
|
var _templateObject;
|
|
278
277
|
|
|
279
|
-
|
|
280
|
-
|
|
281
278
|
function _createSuper(Derived) {
|
|
282
279
|
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
283
|
-
|
|
284
280
|
return function _createSuperInternal() {
|
|
285
281
|
var Super = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_5___default()(Derived),
|
|
286
|
-
|
|
287
|
-
|
|
282
|
+
result;
|
|
288
283
|
if (hasNativeReflectConstruct) {
|
|
289
284
|
var NewTarget = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_5___default()(this).constructor;
|
|
290
|
-
|
|
291
285
|
result = Reflect.construct(Super, arguments, NewTarget);
|
|
292
286
|
} else {
|
|
293
287
|
result = Super.apply(this, arguments);
|
|
294
288
|
}
|
|
295
|
-
|
|
296
289
|
return _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_4___default()(this, result);
|
|
297
290
|
};
|
|
298
291
|
}
|
|
299
|
-
|
|
300
292
|
function _isNativeReflectConstruct() {
|
|
301
293
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
302
294
|
if (Reflect.construct.sham) return false;
|
|
303
295
|
if (typeof Proxy === "function") return true;
|
|
304
|
-
|
|
305
296
|
try {
|
|
306
297
|
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
307
298
|
return true;
|
|
@@ -321,39 +312,28 @@ function _isNativeReflectConstruct() {
|
|
|
321
312
|
* check if an image is considered as remote image
|
|
322
313
|
* @param {*} src
|
|
323
314
|
*/
|
|
324
|
-
|
|
325
315
|
var isRemoteImage = function isRemoteImage() {
|
|
326
316
|
var src = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
327
|
-
|
|
328
317
|
var _src$split = src.split('://'),
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
318
|
+
_src$split2 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_8___default()(_src$split, 1),
|
|
319
|
+
type = _src$split2[0];
|
|
332
320
|
return src.indexOf('://') > -1 && type !== 'http' && type !== 'https';
|
|
333
321
|
};
|
|
334
|
-
|
|
335
322
|
var toImageDimensions = function toImageDimensions(props) {
|
|
336
323
|
if (props.shouldPreserveAspectRatio) {
|
|
337
324
|
return "\n max-width: 100%;\n max-height: 100%;\n width: auto;\n height: auto;\n ";
|
|
338
325
|
}
|
|
339
|
-
|
|
340
326
|
return Object(_splunk_visualizations_shared_style__WEBPACK_IMPORTED_MODULE_16__["toDimension"])(lodash_pick__WEBPACK_IMPORTED_MODULE_13___default()(props, ['width', 'height']));
|
|
341
327
|
};
|
|
342
|
-
|
|
343
328
|
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) {
|
|
344
329
|
return toImageDimensions(props);
|
|
345
330
|
});
|
|
346
|
-
|
|
347
331
|
var RemoteImage = /*#__PURE__*/function (_PureComponent) {
|
|
348
332
|
_babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_3___default()(RemoteImage, _PureComponent);
|
|
349
|
-
|
|
350
333
|
var _super = _createSuper(RemoteImage);
|
|
351
|
-
|
|
352
334
|
function RemoteImage(props) {
|
|
353
335
|
var _this;
|
|
354
|
-
|
|
355
336
|
_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default()(this, RemoteImage);
|
|
356
|
-
|
|
357
337
|
_this = _super.call(this, props);
|
|
358
338
|
_this.state = {
|
|
359
339
|
imageDataURI: null,
|
|
@@ -361,7 +341,6 @@ var RemoteImage = /*#__PURE__*/function (_PureComponent) {
|
|
|
361
341
|
};
|
|
362
342
|
return _this;
|
|
363
343
|
}
|
|
364
|
-
|
|
365
344
|
_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default()(RemoteImage, [{
|
|
366
345
|
key: "componentDidMount",
|
|
367
346
|
value: function componentDidMount() {
|
|
@@ -373,7 +352,6 @@ var RemoteImage = /*#__PURE__*/function (_PureComponent) {
|
|
|
373
352
|
if (prevProps.imageURL !== this.props.imageURL) {
|
|
374
353
|
this.getImage(this.props.imageURL);
|
|
375
354
|
}
|
|
376
|
-
|
|
377
355
|
if (prevProps.preserveAspectRatio !== this.props.preserveAspectRatio) {
|
|
378
356
|
// eslint-disable-next-line react/no-did-update-set-state
|
|
379
357
|
this.setState({
|
|
@@ -391,16 +369,13 @@ var RemoteImage = /*#__PURE__*/function (_PureComponent) {
|
|
|
391
369
|
switch (_context.prev = _context.next) {
|
|
392
370
|
case 0:
|
|
393
371
|
imageRegistry = this.context;
|
|
394
|
-
|
|
395
372
|
if (!imageRegistry) {
|
|
396
373
|
_context.next = 12;
|
|
397
374
|
break;
|
|
398
375
|
}
|
|
399
|
-
|
|
400
376
|
_context.prev = 2;
|
|
401
377
|
_context.next = 5;
|
|
402
378
|
return imageRegistry.getByURL(imageURL);
|
|
403
|
-
|
|
404
379
|
case 5:
|
|
405
380
|
image = _context.sent;
|
|
406
381
|
this.setState({
|
|
@@ -408,13 +383,11 @@ var RemoteImage = /*#__PURE__*/function (_PureComponent) {
|
|
|
408
383
|
});
|
|
409
384
|
_context.next = 12;
|
|
410
385
|
break;
|
|
411
|
-
|
|
412
386
|
case 9:
|
|
413
387
|
_context.prev = 9;
|
|
414
|
-
_context.t0 = _context["catch"](2);
|
|
415
|
-
|
|
388
|
+
_context.t0 = _context["catch"](2);
|
|
389
|
+
// eslint-disable-next-line no-console
|
|
416
390
|
console.error(_context.t0);
|
|
417
|
-
|
|
418
391
|
case 12:
|
|
419
392
|
case "end":
|
|
420
393
|
return _context.stop();
|
|
@@ -422,11 +395,9 @@ var RemoteImage = /*#__PURE__*/function (_PureComponent) {
|
|
|
422
395
|
}
|
|
423
396
|
}, _callee, this, [[2, 9]]);
|
|
424
397
|
}));
|
|
425
|
-
|
|
426
398
|
function getImage(_x) {
|
|
427
399
|
return _getImage.apply(this, arguments);
|
|
428
400
|
}
|
|
429
|
-
|
|
430
401
|
return getImage;
|
|
431
402
|
}()
|
|
432
403
|
}, {
|
|
@@ -434,14 +405,12 @@ var RemoteImage = /*#__PURE__*/function (_PureComponent) {
|
|
|
434
405
|
value: function render() {
|
|
435
406
|
var imageDataURI = this.state.imageDataURI;
|
|
436
407
|
var _this$props = this.props,
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
408
|
+
width = _this$props.width,
|
|
409
|
+
height = _this$props.height,
|
|
410
|
+
title = _this$props.title;
|
|
441
411
|
if (!imageDataURI) {
|
|
442
412
|
return null;
|
|
443
413
|
}
|
|
444
|
-
|
|
445
414
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_10___default.a.createElement(Image, {
|
|
446
415
|
src: imageDataURI,
|
|
447
416
|
shouldPreserveAspectRatio: this.state.preserveAspectRatio,
|
|
@@ -454,12 +423,9 @@ var RemoteImage = /*#__PURE__*/function (_PureComponent) {
|
|
|
454
423
|
});
|
|
455
424
|
}
|
|
456
425
|
}]);
|
|
457
|
-
|
|
458
426
|
return RemoteImage;
|
|
459
427
|
}(react__WEBPACK_IMPORTED_MODULE_10__["PureComponent"]);
|
|
460
|
-
|
|
461
428
|
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_6___default()(RemoteImage, "contextType", _splunk_visualization_context_ImageContext__WEBPACK_IMPORTED_MODULE_15___default.a);
|
|
462
|
-
|
|
463
429
|
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_6___default()(RemoteImage, "propTypes", {
|
|
464
430
|
imageURL: prop_types__WEBPACK_IMPORTED_MODULE_11___default.a.string,
|
|
465
431
|
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]),
|
|
@@ -467,11 +433,9 @@ _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_6___default()(Rem
|
|
|
467
433
|
preserveAspectRatio: prop_types__WEBPACK_IMPORTED_MODULE_11___default.a.bool,
|
|
468
434
|
title: prop_types__WEBPACK_IMPORTED_MODULE_11___default.a.string
|
|
469
435
|
});
|
|
470
|
-
|
|
471
436
|
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_6___default()(RemoteImage, "defaultProps", {
|
|
472
437
|
preserveAspectRatio: false
|
|
473
438
|
});
|
|
474
|
-
|
|
475
439
|
/* harmony default export */ __webpack_exports__["default"] = (RemoteImage);
|
|
476
440
|
|
|
477
441
|
/***/ })
|
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","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;;;;;;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;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 = 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","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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AACrC,YAAY,EAAE;QACf,OAAO,IAAI;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":""}
|
package/SanitizeProps.js
CHANGED
|
@@ -341,32 +341,32 @@ var createTestSchema = function createTestSchema(optionsSchema) {
|
|
|
341
341
|
type: 'object',
|
|
342
342
|
properties: optionsSchema
|
|
343
343
|
};
|
|
344
|
-
};
|
|
344
|
+
};
|
|
345
345
|
|
|
346
|
-
|
|
346
|
+
// Below 2 regexs are copied from dashboard-framework/packages/dashboard-utils/src/token.jsc
|
|
347
|
+
var TOKEN_NAMESPACE_PREFIX_PATTERN = /(\w+:)?/.source;
|
|
348
|
+
// ex: token.name|suh (old-style filter chain)
|
|
347
349
|
// ex: token.name|lower|capitalize (new-style filter chain)
|
|
348
|
-
|
|
349
350
|
var TOKEN_NAME_CHARS_PATTERN = /([^$|:]+?)(\|[|\w]+)?/.source;
|
|
350
|
-
var TOKEN_PATTERN = /\$/.source + TOKEN_NAMESPACE_PREFIX_PATTERN + TOKEN_NAME_CHARS_PATTERN + /\$/.source;
|
|
351
|
+
var TOKEN_PATTERN = /\$/.source + TOKEN_NAMESPACE_PREFIX_PATTERN + TOKEN_NAME_CHARS_PATTERN + /\$/.source;
|
|
352
|
+
// rgb and rgba regexes were derived from:
|
|
351
353
|
// https://stackoverflow.com/questions/9585973/javascript-regular-expression-for-rgb-values/9586150
|
|
352
354
|
// https://github.com/regexhq/rgba-regex
|
|
353
355
|
// NOTE: this will incorrectly accept values like rgb(999,999,999), but may be overkill to specify a regex that limits values to <= 255
|
|
354
|
-
|
|
355
356
|
var rgbColorPattern = /^rgb\(\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/;
|
|
356
|
-
var rgbaColorPattern = /^rgba\(\s*(\d{1,3}%?),\s*(\d{1,3}%?),\s*(\d{1,3}%?),\s*(\d*(?:\.\d+)?)\)$/;
|
|
357
|
-
|
|
357
|
+
var rgbaColorPattern = /^rgba\(\s*(\d{1,3}%?),\s*(\d{1,3}%?),\s*(\d{1,3}%?),\s*(\d*(?:\.\d+)?)\)$/;
|
|
358
|
+
// todo: rename this to COLOR_PATTERN and replace all occurences.
|
|
358
359
|
var colorPattern = '^#[0-9a-fA-F]{6}$|transparent';
|
|
359
360
|
var colorPatternWithRGBA = "".concat(colorPattern, "|").concat(rgbColorPattern.source, "|").concat(rgbaColorPattern.source);
|
|
360
361
|
var COLOR_OR_TOKEN_PATTERN = "".concat(colorPattern, "|").concat(TOKEN_PATTERN);
|
|
361
|
-
var COLOR_OR_TOKEN_PATTERN_WITH_RGBA = "".concat(colorPatternWithRGBA, "|").concat(TOKEN_PATTERN);
|
|
362
|
-
|
|
362
|
+
var COLOR_OR_TOKEN_PATTERN_WITH_RGBA = "".concat(colorPatternWithRGBA, "|").concat(TOKEN_PATTERN);
|
|
363
|
+
// dynamic option DSL expressions always start with a >
|
|
363
364
|
var DYNAMIC_OPTIONS_DSL_PATTERN = /^>.*/.source;
|
|
364
365
|
/**
|
|
365
366
|
* Returns the regex string that matches each passed in value as well as tokens.
|
|
366
367
|
* @param {Array.<string>} values
|
|
367
368
|
* @returns {string}
|
|
368
369
|
*/
|
|
369
|
-
|
|
370
370
|
var getPattern = function getPattern(values) {
|
|
371
371
|
return values.reduce(function (accumulator, value) {
|
|
372
372
|
return "".concat(accumulator, "|^").concat(value, "$");
|
|
@@ -383,8 +383,8 @@ var getPattern = function getPattern(values) {
|
|
|
383
383
|
|
|
384
384
|
Object.defineProperty(exports, "__esModule", {
|
|
385
385
|
value: true
|
|
386
|
-
});
|
|
387
|
-
|
|
386
|
+
});
|
|
387
|
+
// Reference - https://www.w3.org/TR/css-color-4/#named-colors
|
|
388
388
|
exports.default = ['transparent', 'aliceblue', 'antiquewhite', 'aqua', 'aquamarine', 'azure', 'beige', 'bisque', 'black', 'blanchedalmond', 'blue', 'blueviolet', 'brown', 'burlywood', 'cadetblue', 'chartreuse', 'chocolate', 'coral', 'cornflowerblue', 'cornsilk', 'crimson', 'cyan', 'darkblue', 'darkcyan', 'darkgoldenrod', 'darkgray', 'darkgreen', 'darkgrey', 'darkkhaki', 'darkmagenta', 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred', 'darksalmon', 'darkseagreen', 'darkslateblue', 'darkslategray', 'darkslategrey', 'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue', 'dimgray', 'dimgrey', 'dodgerblue', 'firebrick', 'floralwhite', 'forestgreen', 'fuchsia', 'gainsboro', 'ghostwhite', 'gold', 'goldenrod', 'gray', 'green', 'greenyellow', 'grey', 'honeydew', 'hotpink', 'indianred', 'indigo', 'ivory', 'khaki', 'lavender', 'lavenderblush', 'lawngreen', 'lemonchiffon', 'lightblue', 'lightcoral', 'lightcyan', 'lightgoldenrodyellow', 'lightgray', 'lightgreen', 'lightgrey', 'lightpink', 'lightsalmon', 'lightseagreen', 'lightskyblue', 'lightslategray', 'lightslategrey', 'lightsteelblue', 'lightyellow', 'lime', 'limegreen', 'linen', 'magenta', 'maroon', 'mediumaquamarine', 'mediumblue', 'mediumorchid', 'mediumpurple', 'mediumseagreen', 'mediumslateblue', 'mediumspringgreen', 'mediumturquoise', 'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose', 'moccasin', 'navajowhite', 'navy', 'oldlace', 'olive', 'olivedrab', 'orange', 'orangered', 'orchid', 'palegoldenrod', 'palegreen', 'paleturquoise', 'palevioletred', 'papayawhip', 'peachpuff', 'peru', 'pink', 'plum', 'powderblue', 'purple', 'rebeccapurple', 'red', 'rosybrown', 'royalblue', 'saddlebrown', 'salmon', 'sandybrown', 'seagreen', 'seashell', 'sienna', 'silver', 'skyblue', 'slateblue', 'slategray', 'slategrey', 'snow', 'springgreen', 'steelblue', 'tan', 'teal', 'thistle', 'tomato', 'turquoise', 'violet', 'wheat', 'white', 'whitesmoke', 'yellow', 'yellowgreen'];
|
|
389
389
|
|
|
390
390
|
/***/ }),
|
|
@@ -399,9 +399,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
399
399
|
value: true
|
|
400
400
|
});
|
|
401
401
|
exports.sanitizeArrayOfColors = exports.isArrayOfColors = exports.isColor = void 0;
|
|
402
|
-
|
|
403
402
|
var schemaUtils_1 = __webpack_require__(22);
|
|
404
|
-
|
|
405
403
|
var namedColors_1 = __webpack_require__(23);
|
|
406
404
|
/**
|
|
407
405
|
* Validates if a given string is a valid color
|
|
@@ -409,28 +407,21 @@ var namedColors_1 = __webpack_require__(23);
|
|
|
409
407
|
* @param {string} color
|
|
410
408
|
* @returns {boolean}
|
|
411
409
|
*/
|
|
412
|
-
|
|
413
|
-
|
|
414
410
|
function isColor() {
|
|
415
411
|
var color = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
416
|
-
|
|
417
412
|
if (typeof color !== 'string') {
|
|
418
413
|
return false;
|
|
419
414
|
}
|
|
420
|
-
|
|
421
415
|
if (color.charAt(0) === '#') {
|
|
422
416
|
color = color.substring(1); // eslint-disable-line no-param-reassign
|
|
423
|
-
|
|
424
417
|
return [3, 4, 6, 8].indexOf(color.length) > -1 && !Number.isNaN(parseInt(color, 16));
|
|
425
418
|
}
|
|
426
|
-
|
|
427
419
|
var trimmedColor = color.trim();
|
|
428
|
-
|
|
429
420
|
if (schemaUtils_1.rgbColorPattern.test(trimmedColor) || schemaUtils_1.rgbaColorPattern.test(trimmedColor)) {
|
|
430
421
|
return true;
|
|
431
422
|
}
|
|
432
|
-
|
|
433
|
-
|
|
423
|
+
return namedColors_1.default.includes(color.toLowerCase());
|
|
424
|
+
// for future when we want to support rgb | hsl
|
|
434
425
|
// return /^(rgb|hsl)a?\((\d+%?(deg|rad|grad|turn)?[,\s]+){2,3}[\s\/]*[\d\.]+%?\)$/i.test(color);
|
|
435
426
|
}
|
|
436
427
|
|
|
@@ -440,11 +431,9 @@ exports.isColor = isColor;
|
|
|
440
431
|
* @param colors
|
|
441
432
|
* @returns
|
|
442
433
|
*/
|
|
443
|
-
|
|
444
434
|
var isArrayOfColors = function isArrayOfColors(colors) {
|
|
445
435
|
return Array.isArray(colors) && colors.every(isColor);
|
|
446
436
|
};
|
|
447
|
-
|
|
448
437
|
exports.isArrayOfColors = isArrayOfColors;
|
|
449
438
|
/**
|
|
450
439
|
* Sanitizes an array of colors `arr` to replace any non-color values with undefined,
|
|
@@ -454,13 +443,11 @@ exports.isArrayOfColors = isArrayOfColors;
|
|
|
454
443
|
* @param {string} fallback
|
|
455
444
|
* @returns {string[]} sanitized array any non-color values replaced with `fallback`
|
|
456
445
|
*/
|
|
457
|
-
|
|
458
446
|
var sanitizeArrayOfColors = function sanitizeArrayOfColors(arr, fallback) {
|
|
459
447
|
return arr.map(function (entry) {
|
|
460
448
|
return isColor(entry) ? entry : fallback;
|
|
461
449
|
});
|
|
462
450
|
};
|
|
463
|
-
|
|
464
451
|
exports.sanitizeArrayOfColors = sanitizeArrayOfColors;
|
|
465
452
|
|
|
466
453
|
/***/ }),
|
|
@@ -483,13 +470,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
483
470
|
});
|
|
484
471
|
exports.withSanitizedProps = exports.sanitize = void 0;
|
|
485
472
|
/* eslint-disable no-param-reassign */
|
|
486
|
-
|
|
487
473
|
var React = __webpack_require__(1);
|
|
488
|
-
|
|
489
474
|
var lodash_1 = __webpack_require__(4);
|
|
490
|
-
|
|
491
475
|
var colorUtils_1 = __webpack_require__(27);
|
|
492
|
-
|
|
493
476
|
var propsKeyValidators = {
|
|
494
477
|
backgroundColor: colorUtils_1.isColor,
|
|
495
478
|
deltaColor: colorUtils_1.isColor,
|
|
@@ -532,7 +515,6 @@ var propsKeyValidators = {
|
|
|
532
515
|
* @param {string} value
|
|
533
516
|
* @returns {boolean}
|
|
534
517
|
*/
|
|
535
|
-
|
|
536
518
|
function isValidProperty(key, value) {
|
|
537
519
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
538
520
|
return hasOwnProperty.call(propsKeyValidators, key) ? propsKeyValidators[key](value) : true;
|
|
@@ -546,8 +528,6 @@ function isValidProperty(key, value) {
|
|
|
546
528
|
* @param {T} props
|
|
547
529
|
* @returns {Partial<T>}
|
|
548
530
|
*/
|
|
549
|
-
|
|
550
|
-
|
|
551
531
|
function sanitize(props) {
|
|
552
532
|
return Object.keys(props).reduce(function (accum, key) {
|
|
553
533
|
if (key === 'options' && lodash_1.isPlainObject(props.options)) {
|
|
@@ -555,11 +535,9 @@ function sanitize(props) {
|
|
|
555
535
|
} else if (isValidProperty(key, props[key])) {
|
|
556
536
|
accum[key] = props[key];
|
|
557
537
|
}
|
|
558
|
-
|
|
559
538
|
return accum;
|
|
560
539
|
}, {});
|
|
561
540
|
}
|
|
562
|
-
|
|
563
541
|
exports.sanitize = sanitize;
|
|
564
542
|
/**
|
|
565
543
|
* Helper HOC which will sanitize invalid props
|
|
@@ -568,16 +546,13 @@ exports.sanitize = sanitize;
|
|
|
568
546
|
* @param {React.ComponentType} WrappedComponent
|
|
569
547
|
* @returns {React.ComponentType}
|
|
570
548
|
*/
|
|
571
|
-
|
|
572
549
|
function withSanitizedProps(WrappedComponent) {
|
|
573
550
|
var Wrapper = function Wrapper(props) {
|
|
574
551
|
var sanitizedProps = sanitize(props);
|
|
575
552
|
return React.createElement(WrappedComponent, Object.assign({}, sanitizedProps));
|
|
576
553
|
};
|
|
577
|
-
|
|
578
554
|
return Wrapper;
|
|
579
555
|
}
|
|
580
|
-
|
|
581
556
|
exports.withSanitizedProps = withSanitizedProps;
|
|
582
557
|
|
|
583
558
|
/***/ })
|