"use strict";

exports.__esModule = true;
exports["default"] = void 0;

var _react = _interopRequireDefault(require("react"));

var _excluded = ["readOnly", "disabled", "checked", "onAttribute", "offAttribute", "onClick"];

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _extends() { _extends = Object.assign || 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 _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; }

// 开关控件
function OnOff(_ref) {
  var readOnly = _ref.readOnly,
      disabled = _ref.disabled,
      checked = _ref.checked,
      _ref$onAttribute = _ref.onAttribute,
      onAttribute = _ref$onAttribute === void 0 ? {} : _ref$onAttribute,
      _ref$offAttribute = _ref.offAttribute,
      offAttribute = _ref$offAttribute === void 0 ? {} : _ref$offAttribute,
      _onClick = _ref.onClick,
      others = _objectWithoutPropertiesLoose(_ref, _excluded);

  return /*#__PURE__*/_react["default"].createElement("div", _extends({}, others, {
    className: "onoff" + (others.className ? ' ' + others.className : '') + (onAttribute.caption && offAttribute.caption ? '' : ' notext') + (checked ? ' active' : ''),
    "data-on": onAttribute.caption || '',
    "data-off": offAttribute.caption || '',
    "data-readonly": readOnly,
    "data-disabled": disabled,
    onClick: function onClick(e) {
      if (_onClick) _onClick(e, checked);
    }
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "onoff-handle"
  }));
}

var _default = OnOff;
exports["default"] = _default;
module.exports = exports.default;