import React, { ReactNode } from 'react'; import { QueryPreviewTabs, TabOption } from '../types.js'; import { renderTabPanelButtonId } from '../utils/a11y.js'; import { emptyArray } from '../utils/object.js'; export interface QueryPreviewHeaderProps { tabs: ReadonlyArray< TabOption >; onTabChange: (tab: QueryPreviewTabs) => void; selectedTab: QueryPreviewTabs; renderTabLabel?: (tab: QueryPreviewHeaderProps['tabs'][number]) => ReactNode; } export class QueryPreviewHeader extends React.Component { handleTabClick = (tab: QueryPreviewHeaderProps['tabs'][number]): void => { if (this.props.selectedTab !== tab.value) { this.props.onTabChange(tab.value); } }; render(): ReactNode { const { tabs, selectedTab, renderTabLabel } = this.props; return (
({ flex: '0 0 30px', padding: '5px 4px', alignItems: 'center', borderBottomWidth: '1px', borderBottomStyle: 'solid', backgroundColor: theme.HEADER_BACKGROUND_COLOR, borderBottomColor: theme.HEADER_BORDER_COLOR, })} >
*': { flex: '0 1 auto', }, }} > {tabs.map((tab) => ( ))}
); } static defaultProps = { tabs: emptyArray, }; }