import React from 'react'; import { Icon, Tooltip } from 'UI'; import cn from 'classnames'; import {IconNames} from "UI/SVG"; import styles from './segmentSelection.module.css'; type Entry = { value: string, name: string, disabled?: boolean, icon?: IconNames }; interface Props { className?: string; name: string; value: T; list: T[]; onSelect: (_: null, data: { name: string, value: T['value']}) => void; small?: boolean; extraSmall?: boolean; primary?: boolean; size?: 'normal' | 'small' | 'extraSmall'; icons?: boolean; disabled?: boolean; disabledMessage?: string; outline?: boolean; } class SegmentSelection extends React.Component> { setActiveItem = (item: T) => { this.props.onSelect(null, { name: this.props.name, value: item.value }); }; render() { const { className, list, small = false, extraSmall = false, primary = false, size = 'normal', icons = false, disabled = false, disabledMessage = 'Not Allowed', outline, } = this.props; return (
{list.map((item, i) => (
!item.disabled && this.setActiveItem(item)} > {item.icon && ( )}
{item.name}
))}
); } } export default SegmentSelection;