import React from 'react';
import { Wrapper, ColorWrapper } from './colorSelector2.styles';
import { Tooltip } from 'antd';

const Color = ({
  color,
  label,
  selected,
  onClick
}) => /*#__PURE__*/React.createElement(Tooltip, {
  placement: "top",
  title: label
}, /*#__PURE__*/React.createElement(ColorWrapper, {
  selected: selected,
  color: color,
  onClick: onClick
}, /*#__PURE__*/React.createElement("div", null)));

const ColorSelector = ({
  options,
  value,
  onChange
}) => {
  if (!options || options.length === 0) return null;
  return /*#__PURE__*/React.createElement(Wrapper, null, options.map(({
    label,
    value: val,
    color
  }, i) => /*#__PURE__*/React.createElement(Color, {
    key: i,
    color: color,
    label: label,
    selected: val === value,
    onClick: () => {
      onChange(val);
    }
  })));
};

export default ColorSelector;