@splunk/visualizations-shared 28.0.0 → 28.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +5 -0
- package/Downloader.d.ts +25 -0
- package/Downloader.js +16 -15
- package/Downloader.js.map +2 -2
- package/FileDownloader.d.ts +32 -0
- package/FileDownloader.js.map +2 -2
- package/FileDownloader.test.d.ts +1 -0
- package/JSONSchemaUtils.d.ts +9 -0
- package/Message.d.ts +9 -0
- package/Message.js +10 -41
- package/Message.js.map +4 -4
- package/RemoteIcon.d.ts +35 -0
- package/RemoteIcon.js +23 -46
- package/RemoteIcon.js.map +4 -4
- package/RemoteImage.d.ts +27 -0
- package/RemoteImage.js +21 -42
- package/RemoteImage.js.map +4 -4
- package/SanitizeProps.d.ts +19 -0
- package/SizeAwareWrapper.d.ts +23 -0
- package/SizeAwareWrapper.js +16 -29
- package/SizeAwareWrapper.js.map +3 -3
- package/VisualizationDocPage.d.ts +32 -0
- package/VisualizationDocPage.js +34 -88
- package/VisualizationDocPage.js.map +4 -4
- package/colorUtils.d.ts +1 -0
- package/configUtils.d.ts +2 -0
- package/dataSourceUtils.d.ts +27 -0
- package/hocUtils.d.ts +1 -0
- package/iconUtils.d.ts +15 -0
- package/mapUtils.d.ts +2 -0
- package/package.json +15 -15
- package/previewVizMessage.d.ts +2 -0
- package/schemaUtils.d.ts +1 -0
- package/style.d.ts +5 -0
- package/trellisUtils.d.ts +21 -0
- package/tsconfig.json +9 -8
- package/SizeAwareWrapperDeprecated.js +0 -145
- package/SizeAwareWrapperDeprecated.js.map +0 -7
package/RemoteIcon.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["src/RemoteIcon.
|
|
4
|
-
"sourcesContent": ["/* eslint-disable class-methods-use-this */\nimport React, { PureComponent } from 'react';\nimport T from 'prop-types';\nimport styled from 'styled-components';\nimport xmlserializer from 'xmlserializer';\nimport { _ } from '@splunk/ui-utils/i18n';\nimport IconContext from '@splunk/visualization-context/IconContext';\nimport { toDimension } from './style';\nimport { shouldChangeFill, shouldChangeStroke, b64EncodeUnicode } from './iconUtils';\n\nconst IconContainer = styled.div`\n ${props => toDimension({ width: props.width, height: props.height })};\n margin: auto;\n cursor: ${props => (props.onClick ? 'pointer' : 'inherit')};\n`;\nconst ColoredIcon = styled.img`\n ${props => toDimension({ width: props.width, height: props.height })};\n opacity: ${props => props.opacity || 1.0};\n`;\n\nclass RemoteIcon extends PureComponent {\n static contextType = IconContext;\n\n static propTypes = {\n iconURL: T.string,\n color: T.string,\n width: T.number,\n height: T.number,\n opacity: T.number,\n onIconClick: T.func,\n };\n\n static defaultProps = {\n width: 100,\n height: 100,\n opacity: 1.0,\n };\n\n static BASIC_SHAPES = ['path', 'rect', 'circle', 'ellipse', 'line', 'polyline', 'polygon'];\n\n constructor(props) {\n super(props);\n this.state = { iconDataURI: null };\n }\n\n // eslint-disable-next-line camelcase\n UNSAFE_componentWillMount() {\n this.getIcon(this.props.iconURL, this.props.color);\n }\n\n componentDidUpdate(prevProps) {\n if (prevProps.iconURL !== this.props.iconURL || prevProps.color !== this.props.color) {\n this.getIcon(this.props.iconURL, this.props.color);\n }\n }\n\n /**\n * Check if the iconURL is a registry URL/dataURI/direct URL and fetch from the registry when required\n * @param {String} iconURL\n * @param {String} color\n */\n async getIcon(iconURL, color) {\n const getIconDataURI = async () => {\n if (this.isRegistryURL(iconURL)) {\n const iconRegistry = this.context;\n if (iconRegistry) {\n try {\n const icon = await iconRegistry.getByURL(iconURL);\n return icon.dataURI;\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(_(error));\n }\n }\n } else {\n return iconURL;\n }\n return null;\n };\n\n const iconDataURI = await getIconDataURI();\n\n if (color) {\n this.colorIcon(iconDataURI, color);\n } else {\n this.setState({ iconDataURI });\n }\n }\n\n /**\n * check if icon is a registry url\n * @param {String} src\n */\n isRegistryURL(src = '') {\n const [type] = src.split('://');\n return type !== 'http' && type !== 'https' && !src.startsWith('data:image/svg+xml;base64');\n }\n\n /*\n * Color the icon:\n * parse svg elements from the dataURI, change color style of svg, and change fill/stroke attribute/style of each svg basic shapes\n * in the svg element to currentColor. At the end, convert the modified svg back to dataURI string.\n *\n * Limitation:\n * if the svg is created with multiple pathes with different fill attributes, this method would\n * convert all pathes' fill attribute to the color prop. It may change the view of the svg icon.\n *\n * @method colorIcon\n * @params {DataURI} dataURI\n * @params {String} color e.g. 'red' || '#ffffff'\n */\n colorIcon(dataURI, color) {\n fetch(dataURI)\n .then(response => response.text())\n .then(text => {\n const parser = new DOMParser();\n const xmlDoc = parser.parseFromString(text, 'text/xml');\n const svg = xmlDoc.getElementsByTagName('svg')[0];\n const children = svg.querySelectorAll('*');\n svg.style.color = color;\n\n // Todo: need move this to IconRegistry after figure out the jest issue with XMLSerializer\n for (let i = 0; i < children.length; i += 1) {\n const child = children[i];\n\n if (RemoteIcon.BASIC_SHAPES.includes(child.tagName)) {\n const fillAttr = child.getAttribute('fill');\n const fillStyle = child.style && child.style.fill;\n const strokeAttr = child.getAttribute('stroke');\n const strokeStyle = child.style && child.style.stroke;\n\n if (\n shouldChangeFill({\n fillAttr,\n fillStyle,\n strokeAttr,\n strokeStyle,\n })\n ) {\n child.style.fill = '';\n child.setAttribute('fill', 'currentColor');\n }\n\n if (\n shouldChangeStroke({\n fillAttr,\n fillStyle,\n strokeAttr,\n strokeStyle,\n })\n ) {\n child.style.stroke = '';\n child.setAttribute('stroke', 'currentColor');\n }\n }\n }\n\n const svgStr = b64EncodeUnicode(xmlserializer.serializeToString(svg));\n const iconDataURI = `data:image/svg+xml;base64,${svgStr}`;\n this.setState({ iconDataURI });\n })\n .catch(() => {\n // eslint-disable-next-line no-console\n console.error(_('The icon cannot be colored properly.'));\n });\n }\n\n render() {\n const { iconDataURI } = this.state;\n const { width, height, opacity, onIconClick } = this.props;\n\n if (!iconDataURI) {\n return null;\n }\n return (\n <IconContainer width={width} height={height} onClick={onIconClick}>\n <ColoredIcon\n src={iconDataURI}\n alt=\"Remote Icon\"\n width={width}\n height={height}\n opacity={opacity}\n referrerPolicy=\"no-referrer\"\n />\n </IconContainer>\n );\n }\n}\n\nexport default RemoteIcon;\n", "\nimport * as defaultImport from \"react\";\nexport * from \"react\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"prop-types\";\nexport * from \"prop-types\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"styled-components\";\nexport * from \"styled-components\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"xmlserializer\";\nexport * from \"xmlserializer\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"@splunk/ui-utils/i18n\";\nexport * from \"@splunk/ui-utils/i18n\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"@splunk/visualization-context/IconContext\";\nexport * from \"@splunk/visualization-context/IconContext\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"lodash/isNumber\";\nexport * from \"lodash/isNumber\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "import isNumber from 'lodash/isNumber';\n\n/**\n * convert number to px\n * @param {*} number\n */\nexport const toPx = (number, defaultNumber = 0) =>\n isNumber(number) ? `${number}px` : number || toPx(defaultNumber);\n\n/**\n * generate width/height css properties\n * @param {*} param0\n */\nexport const toDimension = ({ width, height }) => {\n let css = '';\n if (width) {\n css = `width: ${toPx(width)};`;\n }\n if (height) {\n // only add a linebreak if width was also set\n css = `${css}${width ? '\\n' : ''}height: ${toPx(height)};`;\n }\n return css;\n};\n\n/**\n * generate margin css property\n */\nexport const arrayToCSSProp = (prop, vals = [0, 0, 0, 0]) => {\n if (Array.isArray(vals)) {\n return `\n ${prop}: ${toPx(vals[0])} ${toPx(vals[1])} ${toPx(vals[2])} ${toPx(vals[3])};\n `;\n }\n\n return `${prop}: ${toPx(vals)};`;\n};\n\n/**\n * generate margin css property\n */\nexport const toMargin = (margins = [0, 0, 0, 0]) => arrayToCSSProp('margin', margins);\n\n/**\n * generate padding css property\n */\nexport const toPadding = (paddings = [0, 0, 0, 0]) => arrayToCSSProp('padding', paddings);\n", "/**\n * check if an icon is considered as remote icon\n * @param {*} icon\n */\nexport const isRemoteIcon = (icon = '') => icon.indexOf('://') > -1;\n\n/**\n * check if an icon is a dataURI\n * @param {*} icon\n */\nexport const isDataURI = (icon = '') => icon.startsWith('data:image/svg+xml;base64');\n\n/*\n * check whether need update fill for svg children elements\n * @params {Object} style\n * @params {String} style.fillAttr <path fill=\"red\" .../>\n * @params {String} style.fillStyle. <path style=\"fill: red;\" />\n * @params {String} style.strokeAttr. <path stroke=\"red\" .../>\n * @params {String} style.strokeStyle <path style=\"stroke: red;\" .../>\n * @returns {Boolean} true means need\n * remove fill style and change the fill attribute <path fill=\"currentColor\" />\n */\nexport const shouldChangeFill = ({ fillAttr, fillStyle, strokeAttr, strokeStyle }) => {\n const noneFillAttr = !!fillAttr && (fillAttr === 'none' || fillAttr === 'transparent');\n const noneFillStyle = !!fillStyle && (fillStyle === 'none' || fillStyle === 'transparent');\n const noFillHasStroke = !fillAttr && !fillStyle && (!!strokeAttr || !!strokeStyle);\n return !(noneFillAttr || noneFillStyle || noFillHasStroke);\n};\n\n/*\n * check whether need update stroke for svg children elements\n * @params {Object} style\n * @params {String} style.fillAttr <path fill=\"red\" .../>\n * @params {String} style.fillStyle. <path style=\"fill: red;\" />\n * @params {String} style.strokeAttr. <path stroke=\"red\" .../>\n * @params {String} style.strokeStyle <path style=\"stroke: red;\" .../>\n * @returns {Boolean} true means need\n * remove stroke style and change the stroke attribute <path stroke=\"currentColor\" />\n */\nexport const shouldChangeStroke = ({ fillAttr, fillStyle, strokeAttr, strokeStyle }) => {\n const noneStrokeAttr = !!strokeAttr && (strokeAttr === 'none' || strokeAttr === 'transparent');\n const noneStrokeStyle = !!strokeStyle && (strokeStyle === 'none' || strokeStyle === 'transparent');\n const hasFill = !!fillAttr || !!fillStyle;\n const noStroke = !strokeAttr && !strokeStyle;\n return !(noneStrokeAttr || noneStrokeStyle || hasFill || noStroke);\n};\n\n/*\n * base64 encoding\n * @param {String} str\n * @return {Base64} string using based-64 encoding\n */\nexport const b64EncodeUnicode = str =>\n // first we use encodeURIComponent to get percent-encoded UTF-8,\n // then we convert the percent encodings into raw bytes which\n // can be fed into btoa.\n btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (match, p1) => String.fromCharCode(`0x${p1}`)));\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["defaultImport", "defaultImport", "defaultImport", "defaultImport", "defaultImport"
|
|
3
|
+
"sources": ["src/RemoteIcon.tsx", "esm-externals:react", "esm-externals:styled-components", "esm-externals:xmlserializer", "esm-externals:@splunk/ui-utils/i18n", "esm-externals:@splunk/visualization-context/IconContext", "esm-externals:lodash/isNumber", "src/style.js", "src/iconUtils.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable class-methods-use-this */\nimport * as React from 'react';\nimport styled from 'styled-components';\nimport * as xmlserializer from 'xmlserializer';\nimport { _ } from '@splunk/ui-utils/i18n';\nimport IconContext from '@splunk/visualization-context/IconContext';\nimport { toDimension } from './style';\nimport { shouldChangeFill, shouldChangeStroke, b64EncodeUnicode } from './iconUtils';\n\ninterface RemoteIconProps {\n alt?: string;\n iconURL?: string;\n color?: string;\n width?: number | string;\n height?: number | string;\n opacity?: number;\n onIconClick?: (event: React.MouseEvent<HTMLDivElement>) => void;\n}\n\ninterface RemoteIconState {\n iconDataURI: string | null;\n}\n\nconst IconContainer = styled.div<RemoteIconProps>`\n ${props => toDimension({ width: props.width, height: props.height })};\n margin: auto;\n cursor: ${props => (props.onClick ? 'pointer' : 'inherit')};\n`;\n\nconst ColoredIcon = styled.img<RemoteIconProps>`\n ${props => toDimension({ width: props.width, height: props.height })};\n opacity: ${props => props.opacity || 1.0};\n`;\n\nclass RemoteIcon extends React.PureComponent<RemoteIconProps, RemoteIconState> {\n static readonly contextType: IconContext = IconContext;\n\n static readonly BASIC_SHAPES = ['path', 'rect', 'circle', 'ellipse', 'line', 'polyline', 'polygon'];\n\n constructor(props: RemoteIconProps) {\n super(props);\n this.state = { iconDataURI: null };\n }\n\n // eslint-disable-next-line camelcase\n UNSAFE_componentWillMount() {\n this.getIcon(this.props.iconURL, this.props.color);\n }\n\n componentDidUpdate(prevProps) {\n if (prevProps.iconURL !== this.props.iconURL || prevProps.color !== this.props.color) {\n this.getIcon(this.props.iconURL, this.props.color);\n }\n }\n\n /**\n * Check if the iconURL is a registry URL/dataURI/direct URL and fetch from the registry when required\n * @param {String} iconURL\n * @param {String} color\n */\n async getIcon(iconURL, color) {\n const getIconDataURI = async () => {\n if (this.isRegistryURL(iconURL)) {\n const iconRegistry: IconContext = this.context;\n if (iconRegistry) {\n try {\n const icon = (await iconRegistry.getByURL(iconURL)) as any;\n return icon.dataURI;\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(_(error));\n }\n }\n } else {\n return iconURL;\n }\n return null;\n };\n\n const iconDataURI = await getIconDataURI();\n\n if (color) {\n this.colorIcon(iconDataURI, color);\n } else {\n this.setState({ iconDataURI });\n }\n }\n\n /**\n * check if icon is a registry url\n * @param {String} src\n */\n isRegistryURL(src = '') {\n const [type] = src.split('://');\n return type !== 'http' && type !== 'https' && !src.startsWith('data:image/svg+xml;base64');\n }\n\n /*\n * Color the icon:\n * parse svg elements from the dataURI, change color style of svg, and change fill/stroke attribute/style of each svg basic shapes\n * in the svg element to currentColor. At the end, convert the modified svg back to dataURI string.\n *\n * Limitation:\n * if the svg is created with multiple pathes with different fill attributes, this method would\n * convert all pathes' fill attribute to the color prop. It may change the view of the svg icon.\n *\n * @method colorIcon\n * @params {DataURI} dataURI\n * @params {String} color e.g. 'red' || '#ffffff'\n */\n colorIcon(dataURI, color) {\n fetch(dataURI)\n .then(response => response.text())\n .then(text => {\n const parser = new DOMParser();\n const xmlDoc = parser.parseFromString(text, 'text/xml');\n const svg = xmlDoc.getElementsByTagName('svg')[0];\n const children = svg.querySelectorAll('*');\n svg.style.color = color;\n // eslint-disable-next-line no-restricted-syntax\n for (const child of children) {\n if (RemoteIcon.BASIC_SHAPES.includes(child.tagName)) {\n const fillAttr = child.getAttribute('fill');\n const fillStyle = (child as SVGElement).style?.fill;\n const strokeAttr = child.getAttribute('stroke');\n const strokeStyle = (child as SVGElement).style?.stroke;\n if (\n shouldChangeFill({\n fillAttr,\n fillStyle,\n strokeAttr,\n strokeStyle,\n })\n ) {\n (child as SVGElement).style.fill = '';\n child.setAttribute('fill', 'currentColor');\n }\n\n if (\n shouldChangeStroke({\n fillAttr,\n fillStyle,\n strokeAttr,\n strokeStyle,\n })\n ) {\n (child as SVGElement).style.stroke = '';\n child.setAttribute('stroke', 'currentColor');\n }\n }\n }\n const s = xmlserializer.serializeToString(svg);\n const svgStr = b64EncodeUnicode(s);\n const iconDataURI = `data:image/svg+xml;base64,${svgStr}`;\n this.setState({ iconDataURI });\n })\n .catch(() => {\n // eslint-disable-next-line no-console\n console.error(_('The icon cannot be colored properly.'));\n });\n }\n\n render() {\n const { iconDataURI } = this.state;\n const { alt = _('Remote Icon'), width = 100, height = 100, opacity = 1.0, onIconClick } = this.props;\n if (!iconDataURI) {\n return null;\n }\n return (\n <IconContainer width={width} height={height} onClick={onIconClick}>\n <ColoredIcon\n src={iconDataURI}\n alt={alt}\n width={width}\n height={height}\n opacity={opacity}\n referrerPolicy=\"no-referrer\"\n />\n </IconContainer>\n );\n }\n}\n\nexport default RemoteIcon;\n", "\nimport * as defaultImport from \"react\";\nexport * from \"react\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"styled-components\";\nexport * from \"styled-components\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"xmlserializer\";\nexport * from \"xmlserializer\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"@splunk/ui-utils/i18n\";\nexport * from \"@splunk/ui-utils/i18n\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"@splunk/visualization-context/IconContext\";\nexport * from \"@splunk/visualization-context/IconContext\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"lodash/isNumber\";\nexport * from \"lodash/isNumber\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "import isNumber from 'lodash/isNumber';\n\n/**\n * convert number to px\n * @param {*} number\n */\nexport const toPx = (number, defaultNumber = 0) =>\n isNumber(number) ? `${number}px` : number || toPx(defaultNumber);\n\n/**\n * generate width/height css properties\n * @param {*} param0\n */\nexport const toDimension = ({ width, height }) => {\n let css = '';\n if (width) {\n css = `width: ${toPx(width)};`;\n }\n if (height) {\n // only add a linebreak if width was also set\n css = `${css}${width ? '\\n' : ''}height: ${toPx(height)};`;\n }\n return css;\n};\n\n/**\n * generate margin css property\n */\nexport const arrayToCSSProp = (prop, vals = [0, 0, 0, 0]) => {\n if (Array.isArray(vals)) {\n return `\n ${prop}: ${toPx(vals[0])} ${toPx(vals[1])} ${toPx(vals[2])} ${toPx(vals[3])};\n `;\n }\n\n return `${prop}: ${toPx(vals)};`;\n};\n\n/**\n * generate margin css property\n */\nexport const toMargin = (margins = [0, 0, 0, 0]) => arrayToCSSProp('margin', margins);\n\n/**\n * generate padding css property\n */\nexport const toPadding = (paddings = [0, 0, 0, 0]) => arrayToCSSProp('padding', paddings);\n", "/**\n * check if an icon is considered as remote icon\n * @param {*} icon\n */\nexport const isRemoteIcon = (icon = '') => icon.indexOf('://') > -1;\n\n/**\n * check if an icon is a dataURI\n * @param {*} icon\n */\nexport const isDataURI = (icon = '') => icon.startsWith('data:image/svg+xml;base64');\n\n/*\n * check whether need update fill for svg children elements\n * @params {Object} style\n * @params {String} style.fillAttr <path fill=\"red\" .../>\n * @params {String} style.fillStyle. <path style=\"fill: red;\" />\n * @params {String} style.strokeAttr. <path stroke=\"red\" .../>\n * @params {String} style.strokeStyle <path style=\"stroke: red;\" .../>\n * @returns {Boolean} true means need\n * remove fill style and change the fill attribute <path fill=\"currentColor\" />\n */\nexport const shouldChangeFill = ({ fillAttr, fillStyle, strokeAttr, strokeStyle }) => {\n const noneFillAttr = !!fillAttr && (fillAttr === 'none' || fillAttr === 'transparent');\n const noneFillStyle = !!fillStyle && (fillStyle === 'none' || fillStyle === 'transparent');\n const noFillHasStroke = !fillAttr && !fillStyle && (!!strokeAttr || !!strokeStyle);\n return !(noneFillAttr || noneFillStyle || noFillHasStroke);\n};\n\n/*\n * check whether need update stroke for svg children elements\n * @params {Object} style\n * @params {String} style.fillAttr <path fill=\"red\" .../>\n * @params {String} style.fillStyle. <path style=\"fill: red;\" />\n * @params {String} style.strokeAttr. <path stroke=\"red\" .../>\n * @params {String} style.strokeStyle <path style=\"stroke: red;\" .../>\n * @returns {Boolean} true means need\n * remove stroke style and change the stroke attribute <path stroke=\"currentColor\" />\n */\nexport const shouldChangeStroke = ({ fillAttr, fillStyle, strokeAttr, strokeStyle }) => {\n const noneStrokeAttr = !!strokeAttr && (strokeAttr === 'none' || strokeAttr === 'transparent');\n const noneStrokeStyle = !!strokeStyle && (strokeStyle === 'none' || strokeStyle === 'transparent');\n const hasFill = !!fillAttr || !!fillStyle;\n const noStroke = !strokeAttr && !strokeStyle;\n return !(noneStrokeAttr || noneStrokeStyle || hasFill || noStroke);\n};\n\n/*\n * base64 encoding\n * @param {String} str\n * @return {Base64} string using based-64 encoding\n */\nexport const b64EncodeUnicode = str =>\n // first we use encodeURIComponent to get percent-encoded UTF-8,\n // then we convert the percent encodings into raw bytes which\n // can be fed into btoa.\n btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (match, p1) => String.fromCharCode(`0x${p1}`)));\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;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Q,QAAQ,UAAU,WAAW,QAAQ,YAAY,SAAS;AAHtG,IAAM,aAAN;AAqJA,IAAO,qBAAQ;",
|
|
6
|
+
"names": ["defaultImport", "defaultImport", "defaultImport", "defaultImport", "defaultImport"]
|
|
7
7
|
}
|
package/RemoteImage.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import ImageContext from '@splunk/visualization-context/ImageContext';
|
|
3
|
+
/**
|
|
4
|
+
* check if an image is considered as remote image
|
|
5
|
+
* @param {*} src
|
|
6
|
+
*/
|
|
7
|
+
export declare const isRemoteImage: (src?: string) => boolean;
|
|
8
|
+
interface RemoteImageProps {
|
|
9
|
+
imageURL: string;
|
|
10
|
+
width?: number | string;
|
|
11
|
+
height?: number | string;
|
|
12
|
+
preserveAspectRatio: boolean;
|
|
13
|
+
title: string;
|
|
14
|
+
}
|
|
15
|
+
interface RemoteImageState {
|
|
16
|
+
preserveAspectRatio: boolean;
|
|
17
|
+
imageDataURI: string | null;
|
|
18
|
+
}
|
|
19
|
+
declare class RemoteImage extends React.PureComponent<RemoteImageProps, RemoteImageState> {
|
|
20
|
+
static readonly contextType: ImageContext;
|
|
21
|
+
constructor(props: any);
|
|
22
|
+
componentDidMount(): void;
|
|
23
|
+
componentDidUpdate(prevProps: any): void;
|
|
24
|
+
getImage(imageURL: any): Promise<void>;
|
|
25
|
+
render(): React.JSX.Element;
|
|
26
|
+
}
|
|
27
|
+
export default RemoteImage;
|
package/RemoteImage.js
CHANGED
|
@@ -7,7 +7,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
7
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
10
|
var __export = (target, all) => {
|
|
12
11
|
for (var name in all)
|
|
13
12
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -30,7 +29,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
29
|
mod
|
|
31
30
|
));
|
|
32
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
34
32
|
var __async = (__this, __arguments, generator) => {
|
|
35
33
|
return new Promise((resolve, reject) => {
|
|
36
34
|
var fulfilled = (value) => {
|
|
@@ -52,7 +50,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
52
50
|
});
|
|
53
51
|
};
|
|
54
52
|
|
|
55
|
-
// src/RemoteImage.
|
|
53
|
+
// src/RemoteImage.tsx
|
|
56
54
|
var RemoteImage_exports = {};
|
|
57
55
|
__export(RemoteImage_exports, {
|
|
58
56
|
default: () => RemoteImage_default,
|
|
@@ -69,59 +67,50 @@ var defaultImport = __toESM(require("react"));
|
|
|
69
67
|
__reExport(react_exports, require("react"));
|
|
70
68
|
var react_default = "default" in defaultImport ? defaultImport.default : defaultImport;
|
|
71
69
|
|
|
72
|
-
// esm-externals:prop-types
|
|
73
|
-
var prop_types_exports = {};
|
|
74
|
-
__export(prop_types_exports, {
|
|
75
|
-
default: () => prop_types_default
|
|
76
|
-
});
|
|
77
|
-
var defaultImport2 = __toESM(require("prop-types"));
|
|
78
|
-
__reExport(prop_types_exports, require("prop-types"));
|
|
79
|
-
var prop_types_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;
|
|
80
|
-
|
|
81
70
|
// esm-externals:styled-components
|
|
82
71
|
var styled_components_exports = {};
|
|
83
72
|
__export(styled_components_exports, {
|
|
84
73
|
default: () => styled_components_default
|
|
85
74
|
});
|
|
86
|
-
var
|
|
75
|
+
var defaultImport2 = __toESM(require("styled-components"));
|
|
87
76
|
__reExport(styled_components_exports, require("styled-components"));
|
|
88
|
-
var styled_components_default = "default" in
|
|
77
|
+
var styled_components_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;
|
|
89
78
|
|
|
90
|
-
// esm-externals:lodash
|
|
91
|
-
var
|
|
92
|
-
__export(
|
|
93
|
-
default: () =>
|
|
79
|
+
// esm-externals:lodash
|
|
80
|
+
var lodash_exports = {};
|
|
81
|
+
__export(lodash_exports, {
|
|
82
|
+
default: () => lodash_default
|
|
94
83
|
});
|
|
95
|
-
var
|
|
96
|
-
__reExport(
|
|
97
|
-
var
|
|
84
|
+
var defaultImport3 = __toESM(require("lodash"));
|
|
85
|
+
__reExport(lodash_exports, require("lodash"));
|
|
86
|
+
var lodash_default = "default" in defaultImport3 ? defaultImport3.default : defaultImport3;
|
|
98
87
|
|
|
99
88
|
// esm-externals:@splunk/ui-utils/i18n
|
|
100
89
|
var i18n_exports = {};
|
|
101
90
|
__export(i18n_exports, {
|
|
102
91
|
default: () => i18n_default
|
|
103
92
|
});
|
|
104
|
-
var
|
|
93
|
+
var defaultImport4 = __toESM(require("@splunk/ui-utils/i18n"));
|
|
105
94
|
__reExport(i18n_exports, require("@splunk/ui-utils/i18n"));
|
|
106
|
-
var i18n_default = "default" in
|
|
95
|
+
var i18n_default = "default" in defaultImport4 ? defaultImport4.default : defaultImport4;
|
|
107
96
|
|
|
108
97
|
// esm-externals:@splunk/visualization-context/ImageContext
|
|
109
98
|
var ImageContext_exports = {};
|
|
110
99
|
__export(ImageContext_exports, {
|
|
111
100
|
default: () => ImageContext_default
|
|
112
101
|
});
|
|
113
|
-
var
|
|
102
|
+
var defaultImport5 = __toESM(require("@splunk/visualization-context/ImageContext"));
|
|
114
103
|
__reExport(ImageContext_exports, require("@splunk/visualization-context/ImageContext"));
|
|
115
|
-
var ImageContext_default = "default" in
|
|
104
|
+
var ImageContext_default = "default" in defaultImport5 ? defaultImport5.default : defaultImport5;
|
|
116
105
|
|
|
117
106
|
// esm-externals:lodash/isNumber
|
|
118
107
|
var isNumber_exports = {};
|
|
119
108
|
__export(isNumber_exports, {
|
|
120
109
|
default: () => isNumber_default
|
|
121
110
|
});
|
|
122
|
-
var
|
|
111
|
+
var defaultImport6 = __toESM(require("lodash/isNumber"));
|
|
123
112
|
__reExport(isNumber_exports, require("lodash/isNumber"));
|
|
124
|
-
var isNumber_default = "default" in
|
|
113
|
+
var isNumber_default = "default" in defaultImport6 ? defaultImport6.default : defaultImport6;
|
|
125
114
|
|
|
126
115
|
// src/style.js
|
|
127
116
|
var toPx = (number, defaultNumber = 0) => isNumber_default(number) ? `${number}px` : number || toPx(defaultNumber);
|
|
@@ -136,7 +125,7 @@ var toDimension = ({ width, height }) => {
|
|
|
136
125
|
return css;
|
|
137
126
|
};
|
|
138
127
|
|
|
139
|
-
// src/RemoteImage.
|
|
128
|
+
// src/RemoteImage.tsx
|
|
140
129
|
var isRemoteImage = (src = "") => {
|
|
141
130
|
const [type] = src.split("://");
|
|
142
131
|
return src.indexOf("://") > -1 && type !== "http" && type !== "https";
|
|
@@ -150,7 +139,7 @@ var toImageDimensions = (props) => {
|
|
|
150
139
|
height: auto;
|
|
151
140
|
`;
|
|
152
141
|
}
|
|
153
|
-
return toDimension(
|
|
142
|
+
return toDimension((0, lodash_exports.pick)(props, ["width", "height"]));
|
|
154
143
|
};
|
|
155
144
|
var Image = styled_components_default.img`
|
|
156
145
|
display: block;
|
|
@@ -161,7 +150,7 @@ var RemoteImage = class extends react_exports.PureComponent {
|
|
|
161
150
|
super(props);
|
|
162
151
|
this.state = {
|
|
163
152
|
imageDataURI: null,
|
|
164
|
-
preserveAspectRatio: props.preserveAspectRatio
|
|
153
|
+
preserveAspectRatio: Boolean(props.preserveAspectRatio)
|
|
165
154
|
};
|
|
166
155
|
}
|
|
167
156
|
componentDidMount() {
|
|
@@ -196,7 +185,7 @@ var RemoteImage = class extends react_exports.PureComponent {
|
|
|
196
185
|
if (!imageDataURI) {
|
|
197
186
|
return null;
|
|
198
187
|
}
|
|
199
|
-
return /* @__PURE__ */
|
|
188
|
+
return /* @__PURE__ */ react_exports.createElement(
|
|
200
189
|
Image,
|
|
201
190
|
{
|
|
202
191
|
src: imageDataURI,
|
|
@@ -211,16 +200,6 @@ var RemoteImage = class extends react_exports.PureComponent {
|
|
|
211
200
|
);
|
|
212
201
|
}
|
|
213
202
|
};
|
|
214
|
-
|
|
215
|
-
__publicField(RemoteImage, "propTypes", {
|
|
216
|
-
imageURL: prop_types_default.string,
|
|
217
|
-
width: prop_types_default.oneOfType([prop_types_default.string, prop_types_default.number]),
|
|
218
|
-
height: prop_types_default.oneOfType([prop_types_default.string, prop_types_default.number]),
|
|
219
|
-
preserveAspectRatio: prop_types_default.bool,
|
|
220
|
-
title: prop_types_default.string
|
|
221
|
-
});
|
|
222
|
-
__publicField(RemoteImage, "defaultProps", {
|
|
223
|
-
preserveAspectRatio: false
|
|
224
|
-
});
|
|
203
|
+
RemoteImage.contextType = ImageContext_default;
|
|
225
204
|
var RemoteImage_default = RemoteImage;
|
|
226
205
|
//# sourceMappingURL=RemoteImage.js.map
|
package/RemoteImage.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["src/RemoteImage.
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["defaultImport", "defaultImport", "defaultImport", "defaultImport", "defaultImport"
|
|
3
|
+
"sources": ["src/RemoteImage.tsx", "esm-externals:react", "esm-externals:styled-components", "esm-externals:lodash", "esm-externals:@splunk/ui-utils/i18n", "esm-externals:@splunk/visualization-context/ImageContext", "esm-externals:lodash/isNumber", "src/style.js"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport styled from 'styled-components';\nimport { pick } from 'lodash';\nimport { _ } from '@splunk/ui-utils/i18n';\nimport ImageContext from '@splunk/visualization-context/ImageContext';\nimport { toDimension } from './style';\n\n/**\n * check if an image is considered as remote image\n * @param {*} src\n */\nexport const isRemoteImage = (src = '') => {\n const [type] = src.split('://');\n return src.indexOf('://') > -1 && type !== 'http' && type !== 'https';\n};\n\ninterface RemoteImageProps {\n imageURL: string;\n width?: number | string;\n height?: number | string;\n preserveAspectRatio: boolean;\n title: string;\n}\n\ninterface RemoteImageState {\n preserveAspectRatio: boolean;\n imageDataURI: string | null;\n}\n\ninterface ImageProps {\n shouldPreserveAspectRatio: boolean;\n width: number | string;\n height: number | string;\n}\n\nconst toImageDimensions = props => {\n if (props.shouldPreserveAspectRatio) {\n return `\n max-width: 100%;\n max-height: 100%;\n width: auto;\n height: auto;\n `;\n }\n return toDimension(pick(props, ['width', 'height']));\n};\n\nconst Image = styled.img<ImageProps>`\n display: block;\n ${props => toImageDimensions(props)};\n`;\n\nclass RemoteImage extends React.PureComponent<RemoteImageProps, RemoteImageState> {\n static readonly contextType: ImageContext = ImageContext;\n\n constructor(props) {\n super(props);\n this.state = {\n imageDataURI: null,\n preserveAspectRatio: Boolean(props.preserveAspectRatio),\n };\n }\n\n componentDidMount() {\n this.getImage(this.props.imageURL);\n }\n\n componentDidUpdate(prevProps) {\n if (prevProps.imageURL !== this.props.imageURL) {\n this.getImage(this.props.imageURL);\n }\n if (prevProps.preserveAspectRatio !== this.props.preserveAspectRatio) {\n // eslint-disable-next-line react/no-did-update-set-state\n this.setState({\n preserveAspectRatio: this.props.preserveAspectRatio,\n });\n }\n }\n\n async getImage(imageURL) {\n const imageRegistry: ImageContext = this.context;\n if (imageRegistry) {\n try {\n const image = await imageRegistry.getByURL(imageURL);\n this.setState({ imageDataURI: image.dataURI });\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n }\n }\n }\n\n render() {\n const { imageDataURI } = this.state;\n const { width, height, title } = this.props;\n\n if (!imageDataURI) {\n return null;\n }\n return (\n <Image\n src={imageDataURI}\n shouldPreserveAspectRatio={this.state.preserveAspectRatio}\n width={width}\n height={height}\n alt={_(title)}\n onError={e => {\n (e.target as HTMLImageElement).alt = _('Image not found');\n }}\n />\n );\n }\n}\n\nexport default RemoteImage;\n", "\nimport * as defaultImport from \"react\";\nexport * from \"react\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"styled-components\";\nexport * from \"styled-components\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"lodash\";\nexport * from \"lodash\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"@splunk/ui-utils/i18n\";\nexport * from \"@splunk/ui-utils/i18n\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"@splunk/visualization-context/ImageContext\";\nexport * from \"@splunk/visualization-context/ImageContext\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"lodash/isNumber\";\nexport * from \"lodash/isNumber\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "import isNumber from 'lodash/isNumber';\n\n/**\n * convert number to px\n * @param {*} number\n */\nexport const toPx = (number, defaultNumber = 0) =>\n isNumber(number) ? `${number}px` : number || toPx(defaultNumber);\n\n/**\n * generate width/height css properties\n * @param {*} param0\n */\nexport const toDimension = ({ width, height }) => {\n let css = '';\n if (width) {\n css = `width: ${toPx(width)};`;\n }\n if (height) {\n // only add a linebreak if width was also set\n css = `${css}${width ? '\\n' : ''}height: ${toPx(height)};`;\n }\n return css;\n};\n\n/**\n * generate margin css property\n */\nexport const arrayToCSSProp = (prop, vals = [0, 0, 0, 0]) => {\n if (Array.isArray(vals)) {\n return `\n ${prop}: ${toPx(vals[0])} ${toPx(vals[1])} ${toPx(vals[2])} ${toPx(vals[3])};\n `;\n }\n\n return `${prop}: ${toPx(vals)};`;\n};\n\n/**\n * generate margin css property\n */\nexport const toMargin = (margins = [0, 0, 0, 0]) => arrayToCSSProp('margin', margins);\n\n/**\n * generate padding css property\n */\nexport const toPadding = (paddings = [0, 0, 0, 0]) =>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ACI;AAAA,MAAC;AAAA;AAAA,QACG,KAAK;AAAA,QACL,2BAA2B,KAAK,MAAM;AAAA,QACtC;AAAA,QACA;AAAA,QACA,SAAK,gBAAE,KAAK;AAAA,QACZ,SAAS,OAAK;AACV,UAAC,EAAE,OAA4B,UAAM,gBAAE,iBAAiB;AAAA,QAC5D;AAAA;AAAA,IACJ;AAAA,EAER;AACJ;AA5DM,YACc,cAA4B;AA6DhD,IAAO,sBAAQ;",
|
|
6
|
+
"names": ["defaultImport", "defaultImport", "defaultImport", "defaultImport", "defaultImport"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Validates every property in the key and return
|
|
4
|
+
* only valid keys
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @template T
|
|
8
|
+
* @param {T} props
|
|
9
|
+
* @returns {Partial<T>}
|
|
10
|
+
*/
|
|
11
|
+
export declare function sanitize<T extends Record<string, any>>(props: T): Partial<T>;
|
|
12
|
+
/**
|
|
13
|
+
* Helper HOC which will sanitize invalid props
|
|
14
|
+
*
|
|
15
|
+
* @export
|
|
16
|
+
* @param {React.ComponentType} WrappedComponent
|
|
17
|
+
* @returns {React.ComponentType}
|
|
18
|
+
*/
|
|
19
|
+
export declare function withSanitizedProps<T>(WrappedComponent: React.ComponentType<T>): React.ComponentType<Partial<T>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface SizeAwareWrapperProps {
|
|
3
|
+
onResize: (width: number, height: number) => void;
|
|
4
|
+
width?: number | string;
|
|
5
|
+
height?: number | string;
|
|
6
|
+
}
|
|
7
|
+
declare class SizeAwareWrapper extends React.PureComponent<SizeAwareWrapperProps, null> {
|
|
8
|
+
ro: ResizeObserver | {
|
|
9
|
+
observe(): void;
|
|
10
|
+
unobserve(): void;
|
|
11
|
+
};
|
|
12
|
+
el: HTMLDivElement;
|
|
13
|
+
componentDidMount(): void;
|
|
14
|
+
componentWillUnmount(): void;
|
|
15
|
+
getElement: () => HTMLElement;
|
|
16
|
+
getResizeObserver(): ResizeObserver | {
|
|
17
|
+
observe(): void;
|
|
18
|
+
unobserve(): void;
|
|
19
|
+
};
|
|
20
|
+
handleResize: (entries: any) => void;
|
|
21
|
+
render(): React.JSX.Element;
|
|
22
|
+
}
|
|
23
|
+
export default SizeAwareWrapper;
|
package/SizeAwareWrapper.js
CHANGED
|
@@ -7,7 +7,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
7
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
10
|
var __export = (target, all) => {
|
|
12
11
|
for (var name in all)
|
|
13
12
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -30,9 +29,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
29
|
mod
|
|
31
30
|
));
|
|
32
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
34
32
|
|
|
35
|
-
// src/SizeAwareWrapper.
|
|
33
|
+
// src/SizeAwareWrapper.tsx
|
|
36
34
|
var SizeAwareWrapper_exports = {};
|
|
37
35
|
__export(SizeAwareWrapper_exports, {
|
|
38
36
|
default: () => SizeAwareWrapper_default
|
|
@@ -48,16 +46,16 @@ var defaultImport = __toESM(require("react"));
|
|
|
48
46
|
__reExport(react_exports, require("react"));
|
|
49
47
|
var react_default = "default" in defaultImport ? defaultImport.default : defaultImport;
|
|
50
48
|
|
|
51
|
-
// esm-externals:
|
|
52
|
-
var
|
|
53
|
-
__export(
|
|
54
|
-
default: () =>
|
|
49
|
+
// esm-externals:lodash
|
|
50
|
+
var lodash_exports = {};
|
|
51
|
+
__export(lodash_exports, {
|
|
52
|
+
default: () => lodash_default
|
|
55
53
|
});
|
|
56
|
-
var defaultImport2 = __toESM(require("
|
|
57
|
-
__reExport(
|
|
58
|
-
var
|
|
54
|
+
var defaultImport2 = __toESM(require("lodash"));
|
|
55
|
+
__reExport(lodash_exports, require("lodash"));
|
|
56
|
+
var lodash_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;
|
|
59
57
|
|
|
60
|
-
// src/SizeAwareWrapper.
|
|
58
|
+
// src/SizeAwareWrapper.tsx
|
|
61
59
|
var styles = {
|
|
62
60
|
position: "absolute",
|
|
63
61
|
width: 0,
|
|
@@ -68,16 +66,17 @@ var styles = {
|
|
|
68
66
|
var SizeAwareWrapper = class extends react_exports.PureComponent {
|
|
69
67
|
constructor() {
|
|
70
68
|
super(...arguments);
|
|
71
|
-
|
|
69
|
+
this.getElement = () => {
|
|
72
70
|
const parentElement = this.el && this.el.parentElement;
|
|
73
71
|
return parentElement;
|
|
74
|
-
}
|
|
75
|
-
|
|
72
|
+
};
|
|
73
|
+
this.handleResize = (entries) => {
|
|
74
|
+
const { onResize = lodash_exports.noop } = this.props;
|
|
76
75
|
entries.forEach((entry) => {
|
|
77
76
|
const { width, height } = entry.contentRect;
|
|
78
|
-
|
|
77
|
+
onResize(width, height);
|
|
79
78
|
});
|
|
80
|
-
}
|
|
79
|
+
};
|
|
81
80
|
}
|
|
82
81
|
componentDidMount() {
|
|
83
82
|
const resizableElement = this.getElement();
|
|
@@ -104,7 +103,7 @@ var SizeAwareWrapper = class extends react_exports.PureComponent {
|
|
|
104
103
|
return new ResizeObserver(this.handleResize);
|
|
105
104
|
}
|
|
106
105
|
render() {
|
|
107
|
-
return /* @__PURE__ */
|
|
106
|
+
return /* @__PURE__ */ react_exports.createElement(
|
|
108
107
|
"div",
|
|
109
108
|
{
|
|
110
109
|
key: "resize-detector",
|
|
@@ -116,17 +115,5 @@ var SizeAwareWrapper = class extends react_exports.PureComponent {
|
|
|
116
115
|
);
|
|
117
116
|
}
|
|
118
117
|
};
|
|
119
|
-
SizeAwareWrapper.propTypes = {
|
|
120
|
-
onResize: prop_types_default.func
|
|
121
|
-
// This was to use width and height as props and then check to see if the values have changed inside the handleResize function
|
|
122
|
-
// Some components need a double render to 'settle' and are using this so no check is needed.
|
|
123
|
-
// However until that is fixed unit tests rely on these props so keeping as optional.
|
|
124
|
-
// width: T.arrayOf(T.number, T.string),
|
|
125
|
-
// height: T.arrayOf(T.number, T.string),
|
|
126
|
-
};
|
|
127
|
-
SizeAwareWrapper.defaultProps = {
|
|
128
|
-
onResize: () => {
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
118
|
var SizeAwareWrapper_default = SizeAwareWrapper;
|
|
132
119
|
//# sourceMappingURL=SizeAwareWrapper.js.map
|
package/SizeAwareWrapper.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["src/SizeAwareWrapper.
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "
|
|
3
|
+
"sources": ["src/SizeAwareWrapper.tsx", "esm-externals:react", "esm-externals:lodash"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport { noop } from 'lodash';\n\nconst styles: React.CSSProperties = {\n position: 'absolute',\n width: 0,\n height: 0,\n visibility: 'hidden',\n display: 'none',\n};\n\ninterface SizeAwareWrapperProps {\n onResize: (width: number, height: number) => void;\n // This was to use width and height as props and then check to see if the values have changed inside the handleResize function\n // Some components need a double render to 'settle' and are using this so no check is needed.\n // However until that is fixed unit tests rely on these props so keeping as optional.\n // eslint-disable-next-line\n width?: number | string;\n // eslint-disable-next-line\n height?: number | string;\n}\n\nclass SizeAwareWrapper extends React.PureComponent<SizeAwareWrapperProps, null> {\n ro: ResizeObserver | { observe(): void; unobserve(): void };\n\n el: HTMLDivElement;\n\n componentDidMount() {\n const resizableElement = this.getElement();\n if (resizableElement) {\n this.ro = this.getResizeObserver();\n this.ro.observe(resizableElement);\n }\n }\n\n componentWillUnmount() {\n const resizableElement = this.getElement();\n if (resizableElement && this.ro) {\n this.ro.unobserve(resizableElement);\n }\n }\n\n getElement = () => {\n const parentElement = this.el && this.el.parentElement;\n return parentElement;\n };\n\n getResizeObserver() {\n if (typeof ResizeObserver !== 'function') {\n return {\n observe() {},\n unobserve() {},\n };\n }\n return new ResizeObserver(this.handleResize);\n }\n\n handleResize = entries => {\n const { onResize = noop } = this.props;\n entries.forEach(entry => {\n const { width, height } = entry.contentRect;\n onResize(width, height);\n });\n };\n\n render() {\n return (\n <div\n key=\"resize-detector\"\n style={styles}\n ref={el => {\n this.el = el;\n }}\n />\n );\n }\n}\n\nexport default SizeAwareWrapper;\n", "\nimport * as defaultImport from \"react\";\nexport * from \"react\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"lodash\";\nexport * from \"lodash\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AACA,oBAA+B;AAC/B,0BAAc;AACd,IAAO,gBAAS,aAAa,gBAA8B,wBAAU;;;ACHrE;AAAA;AAAA;AAAA;AACA,IAAAA,iBAA+B;AAC/B,2BAAc;AACd,IAAO,iBAAS,aAAaA,iBAA8B,yBAAUA;;;AFArE,IAAM,SAA8B;AAAA,EAChC,UAAU;AAAA,EACV,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,SAAS;AACb;AAaA,IAAM,mBAAN,cAAqC,4BAA2C;AAAA,EAAhF;AAAA;AAoBI,sBAAa,MAAM;AACf,YAAM,gBAAgB,KAAK,MAAM,KAAK,GAAG;AACzC,aAAO;AAAA,IACX;AAYA,wBAAe,aAAW;AACtB,YAAM,EAAE,WAAW,oBAAK,IAAI,KAAK;AACjC,cAAQ,QAAQ,WAAS;AACrB,cAAM,EAAE,OAAO,OAAO,IAAI,MAAM;AAChC,iBAAS,OAAO,MAAM;AAAA,MAC1B,CAAC;AAAA,IACL;AAAA;AAAA,EApCA,oBAAoB;AAChB,UAAM,mBAAmB,KAAK,WAAW;AACzC,QAAI,kBAAkB;AAClB,WAAK,KAAK,KAAK,kBAAkB;AACjC,WAAK,GAAG,QAAQ,gBAAgB;AAAA,IACpC;AAAA,EACJ;AAAA,EAEA,uBAAuB;AACnB,UAAM,mBAAmB,KAAK,WAAW;AACzC,QAAI,oBAAoB,KAAK,IAAI;AAC7B,WAAK,GAAG,UAAU,gBAAgB;AAAA,IACtC;AAAA,EACJ;AAAA,EAOA,oBAAoB;AAChB,QAAI,OAAO,mBAAmB,YAAY;AACtC,aAAO;AAAA,QACH,UAAU;AAAA,QAAC;AAAA,QACX,YAAY;AAAA,QAAC;AAAA,MACjB;AAAA,IACJ;AACA,WAAO,IAAI,eAAe,KAAK,YAAY;AAAA,EAC/C;AAAA,EAUA,SAAS;AACL,WACI;AAAA,MAAC;AAAA;AAAA,QACG,KAAI;AAAA,QACJ,OAAO;AAAA,QACP,KAAK,QAAM;AACP,eAAK,KAAK;AAAA,QACd;AAAA;AAAA,IACJ;AAAA,EAER;AACJ;AAEA,IAAO,2BAAQ;",
|
|
6
6
|
"names": ["defaultImport"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface ComponentPageProps {
|
|
3
|
+
createComponentURL: (componentName: string) => string;
|
|
4
|
+
dependsOnSplunk: boolean;
|
|
5
|
+
status: string;
|
|
6
|
+
description: string;
|
|
7
|
+
overviewSection: React.ReactNode;
|
|
8
|
+
conceptsSection: React.ReactNode;
|
|
9
|
+
examplesSection: React.ReactNode;
|
|
10
|
+
optionSection: React.ReactNode;
|
|
11
|
+
encodingSection: React.ReactNode;
|
|
12
|
+
eventSection: React.ReactNode;
|
|
13
|
+
themeSection: React.ReactNode;
|
|
14
|
+
headerOffset: number;
|
|
15
|
+
sourceURL: string;
|
|
16
|
+
title: string;
|
|
17
|
+
}
|
|
18
|
+
interface ComponentPageState {
|
|
19
|
+
activeSection: string;
|
|
20
|
+
}
|
|
21
|
+
declare class ComponentPage extends React.Component<ComponentPageProps, ComponentPageState> {
|
|
22
|
+
static currentSection: string;
|
|
23
|
+
bodyEl: any;
|
|
24
|
+
constructor(args: any);
|
|
25
|
+
handleBodyMount: (el: any) => void;
|
|
26
|
+
handleSectionChange: (e: any, { selectedTabId }: {
|
|
27
|
+
selectedTabId: any;
|
|
28
|
+
}) => void;
|
|
29
|
+
renderBody(): React.ReactNode;
|
|
30
|
+
render(): React.JSX.Element;
|
|
31
|
+
}
|
|
32
|
+
export default ComponentPage;
|