/* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ import React from 'react'; import { i18n } from '@kbn/i18n'; import { EuiFormRow, EuiButtonGroup, EuiSwitch, EuiSwitchEvent } from '@elastic/eui'; import { Position } from '@elastic/charts'; import { ToolbarPopover } from '../shared_components'; export interface LegendSettingsPopoverProps { /** * Determines the legend display options */ legendOptions: Array<{ id: string; value: 'auto' | 'show' | 'hide' | 'default'; label: string }>; /** * Determines the legend mode */ mode: 'default' | 'show' | 'hide' | 'auto'; /** * Callback on display option change */ onDisplayChange: (id: string) => void; /** * Sets the legend position */ position?: Position; /** * Callback on position option change */ onPositionChange: (id: string) => void; /** * If true, nested legend switch is rendered */ renderNestedLegendSwitch?: boolean; /** * nested legend switch status */ nestedLegend?: boolean; /** * Callback on nested switch status change */ onNestedLegendChange?: (event: EuiSwitchEvent) => void; } const toggleButtonsIcons = [ { id: Position.Bottom, label: i18n.translate('xpack.lens.shared.legendPositionBottom', { defaultMessage: 'Bottom', }), iconType: 'arrowDown', }, { id: Position.Left, label: i18n.translate('xpack.lens.shared.legendPositionLeft', { defaultMessage: 'Left', }), iconType: 'arrowLeft', }, { id: Position.Right, label: i18n.translate('xpack.lens.shared.legendPositionRight', { defaultMessage: 'Right', }), iconType: 'arrowRight', }, { id: Position.Top, label: i18n.translate('xpack.lens.shared.legendPositionTop', { defaultMessage: 'Top', }), iconType: 'arrowUp', }, ]; export const LegendSettingsPopover: React.FunctionComponent = ({ legendOptions, mode, onDisplayChange, position, onPositionChange, renderNestedLegendSwitch, nestedLegend, onNestedLegendChange = () => {}, }) => { return ( value === mode)!.id} onChange={onDisplayChange} /> {renderNestedLegendSwitch && ( )} ); };