@formant/ava-react
Version:
React components of AVA.
53 lines • 3.61 kB
JavaScript
var _excluded = ["spec", "pluginManager", "size", "theme"],
_excluded2 = ["onClickParagraph", "onMouseEnterParagraph", "onMouseLeaveParagraph"];
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import React from 'react';
import { NTV_PREFIX_CLS } from "../constants";
import { Headline as StyledHeadline } from "../styled";
import { Phrases } from "../phrases";
import { classnames as cx } from "../../utils";
import { presetPluginManager } from "../chore/plugin";
import { AlertCircle } from 'lucide-react';
import { Alert, AlertDescription, AlertTitle, AlertTitleRow } from "../../InsightCard/Title/customStyled";
export function Headline(_ref) {
var spec = _ref.spec,
_ref$pluginManager = _ref.pluginManager,
pluginManager = _ref$pluginManager === void 0 ? presetPluginManager : _ref$pluginManager,
_ref$size = _ref.size,
size = _ref$size === void 0 ? 'normal' : _ref$size,
_ref$theme = _ref.theme,
theme = _ref$theme === void 0 ? 'dark' : _ref$theme,
events = _objectWithoutProperties(_ref, _excluded);
var _ref2 = events || {},
onClickParagraph = _ref2.onClickParagraph,
onMouseEnterParagraph = _ref2.onMouseEnterParagraph,
onMouseLeaveParagraph = _ref2.onMouseLeaveParagraph,
phraseEvents = _objectWithoutProperties(_ref2, _excluded2);
var themeStyles = {
size: size,
theme: theme
};
var onClick = function onClick() {
onClickParagraph === null || onClickParagraph === void 0 || onClickParagraph(spec);
};
var onMouseEnter = function onMouseEnter() {
onMouseEnterParagraph === null || onMouseEnterParagraph === void 0 || onMouseEnterParagraph(spec);
};
var onMouseLeave = function onMouseLeave() {
onMouseLeaveParagraph === null || onMouseLeaveParagraph === void 0 || onMouseLeaveParagraph(spec);
};
return /*#__PURE__*/React.createElement(Alert, null, /*#__PURE__*/React.createElement(AlertTitleRow, null, /*#__PURE__*/React.createElement(AlertCircle, {
size: 16
}), /*#__PURE__*/React.createElement(AlertTitle, null, "Time Series Outlier Detected")), /*#__PURE__*/React.createElement(AlertDescription, null, /*#__PURE__*/React.createElement(StyledHeadline, _extends({
onClick: onClick,
onMouseEnter: onMouseEnter,
onMouseLeave: onMouseLeave,
className: cx("".concat(NTV_PREFIX_CLS, "-headline"), spec.className),
style: spec.styles
}, themeStyles), /*#__PURE__*/React.createElement(Phrases, _extends({
spec: spec.phrases,
pluginManager: pluginManager
}, themeStyles, phraseEvents)))));
}