"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _balloon = _interopRequireDefault(require("@alifd/next/lib/balloon"));
var _radio = _interopRequireDefault(require("@alifd/next/lib/radio"));
var React = _interopRequireWildcard(require("react"));
var _icon = _interopRequireDefault(require("../icon"));
require("./index.less");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
var RadioGroup = _radio["default"].Group;
var _default = exports["default"] = function _default(props) {
  var dataList = props.dataList,
    styleKey = props.styleKey,
    onStyleChange = props.onStyleChange,
    styleData = props.styleData;
  var value = styleData[styleKey];
  var onRadioChange = function onRadioChange(key, val) {
    onStyleChange([{
      styleKey: key,
      value: val
    }]);
  };
  var onRadioItemClick = function onRadioItemClick(key, val, value) {
    if (value == val) {
      onStyleChange([{
        styleKey: key,
        value: null
      }]);
    }
  };
  return /*#__PURE__*/React.createElement("div", {
    className: "radiogroup-style"
  }, /*#__PURE__*/React.createElement(RadioGroup, {
    value: value,
    shape: "button",
    onChange: function onChange(val) {
      return onRadioChange(styleKey, val);
    },
    "aria-labelledby": "groupId"
  }, dataList && dataList.map(function (item) {
    return /*#__PURE__*/React.createElement(_balloon["default"], {
      trigger: /*#__PURE__*/React.createElement(_radio["default"], {
        id: item.value,
        value: item.value,
        onClick: function onClick(e) {
          onRadioItemClick(styleKey, e.currentTarget.id, value);
        }
      }, item.icon ? /*#__PURE__*/React.createElement(_icon["default"], {
        type: item.icon,
        size: "small"
      }) : item.title),
      triggerType: "hover",
      closable: false,
      align: "t"
    }, item.tips);
  })));
};