var _excluded = ["disabled", "checked", "onChange", "children"];
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import React, { forwardRef, useRef, useImperativeHandle } from 'react';

// 按钮选择
var Item = /*#__PURE__*/forwardRef(function (_ref, ref) {
  var _ref$disabled = _ref.disabled,
    disabled = _ref$disabled === void 0 ? false : _ref$disabled,
    _ref$checked = _ref.checked,
    checked = _ref$checked === void 0 ? false : _ref$checked,
    onChange = _ref.onChange,
    children = _ref.children,
    props = _objectWithoutProperties(_ref, _excluded);
  // 节点
  var rootRef = useRef(null);
  var inputRef = useRef(null);
  useImperativeHandle(ref, function () {
    return {
      rootDOM: rootRef.current,
      inputDOM: inputRef.current,
      getRootDOM: function getRootDOM() {
        return rootRef.current;
      },
      getInputDOM: function getInputDOM() {
        return inputRef.current;
      }
    };
  });

  // 点击回调
  function handleClick(e) {
    if (disabled) return;
    if (onChange) onChange(e.currentTarget.getAttribute('data-checked') !== 'true');
  }
  return /*#__PURE__*/React.createElement("div", _extends({}, props, {
    onClick: handleClick,
    disabled: disabled,
    "data-checked": checked,
    className: "selector-item",
    ref: rootRef
  }), /*#__PURE__*/React.createElement("div", {
    className: "selector-item-name"
  }, children), /*#__PURE__*/React.createElement("div", {
    className: "selector-item-checked-mark"
  }, /*#__PURE__*/React.createElement("i", {
    className: "selector-item-checked-mark-icon"
  })));
});
export default Item;