import { css } from '@emotion/css'; import React, { ChangeEvent, FC } from 'react'; import { useToggle } from 'react-use'; import { GrafanaTheme2 } from '@grafana/data'; import { Stack } from '@grafana/experimental'; import { Button, Icon, InlineField, TextArea, useStyles2 } from '@grafana/ui'; import { ExpressionQuery } from '../types'; interface Props { labelWidth: number; query: ExpressionQuery; onChange: (query: ExpressionQuery) => void; onRunQuery: () => void; } const mathPlaceholder = 'Math operations on one or more queries. You reference the query by ${refId} ie. $A, $B, $C etc\n' + 'The sum of two scalar values: $A + $B > 10'; export const Math: FC = ({ labelWidth, onChange, query, onRunQuery }) => { const [showHelp, toggleShowHelp] = useToggle(false); const onExpressionChange = (event: ChangeEvent) => { onChange({ ...query, expression: event.target.value }); }; const styles = useStyles2((theme) => getStyles(theme, showHelp)); const executeQuery = () => { if (query.expression) { onRunQuery(); } }; return ( <>