UNPKG

@patternfly/react-charts

Version:

This library provides a set of React chart components for use with the PatternFly reference implementation.

53 lines 2.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getComputedStyleValue = exports.getClassName = exports.canUseDOM = void 0; /** * Copied from exenv * * @private Not intended as public API and subject to change */ exports.canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); /** * Returns the class name that will be applied to the outermost div rendered by the chart's container * * @private Not intended as public API and subject to change */ const getClassName = (className) => { let cleanClassName; // Cleanup class name if (className) { cleanClassName = className .replace(/pf-v6-c-chart/g, '') .replace(/pf-c-chart/g, '') .replace(/\s+/g, ' ') .trim(); } return (cleanClassName === null || cleanClassName === void 0 ? void 0 : cleanClassName.length) ? `pf-v6-c-chart ${cleanClassName}` : 'pf-v6-c-chart'; }; exports.getClassName = getClassName; /** * Get computed style value -- see https://github.com/apache/echarts/issues/19743 * * Note that Victory uses the style property to apply CSS variables. However, ECharts' LineChart uses `fill` and * `stroke` attributes, which doesn't work with CSS variables. In addition, using CSS variables with Sankey * causes sever flashing during mouse hover. Therefore, we will obtain the CSS computed value from the DOM. * * @public * @beta */ const getComputedStyleValue = (token) => { var _a; let result; if (exports.canUseDOM) { result = (_a = window.getComputedStyle(document.body)) === null || _a === void 0 ? void 0 : _a.getPropertyValue(token.name); if (result === '') { result = undefined; } else if (!isNaN(result) || result === 'true' || result === 'false') { result = JSON.parse(result); } } return result !== undefined ? result : token.value; }; exports.getComputedStyleValue = getComputedStyleValue; //# sourceMappingURL=styles.js.map