"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.SwitchItemBase = exports.SwitchItem = exports.default = void 0;

var _kind = _interopRequireDefault(require("@enact/core/kind"));

var _ComponentOverride = _interopRequireDefault(require("@enact/ui/ComponentOverride"));

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

var _propTypes = _interopRequireDefault(require("prop-types"));

var _Switch = _interopRequireDefault(require("../Switch"));

var _ToggleItem = _interopRequireDefault(require("../ToggleItem"));

var _SwitchItem = _interopRequireDefault(require("./SwitchItem.less"));

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); }

/**
 * Renders an item with a [Switch]{@link moonstone/Switch}.
 *
 * @class SwitchItem
 * @memberof moonstone/SwitchItem
 * @extends moonstone/ToggleItem.ToggleItem
 * @ui
 * @public
 */
var SwitchItemBase = (0, _kind.default)({
  name: 'SwitchItem',
  propTypes:
  /** @lends moonstone/SwitchItem.SwitchItem.prototype */
  {
    /**
     * Customizes the component by mapping the supplied collection of CSS class names to the
     * corresponding internal Elements and states of this component.
     *
     * The following classes are supported:
     *
     * * `switchItem` - The root class name
     *
     * @type {Object}
     * @public
     */
    css: _propTypes.default.object,

    /**
     * Customize the component used as the switch.
     *
     * @type {Element|Function}
     * @default {@link moonstone/Switch.Switch}
     * @private
     */
    iconComponent: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.func])
  },
  defaultProps: {
    iconComponent: _Switch.default
  },
  styles: {
    css: _SwitchItem.default,
    className: 'switchItem',
    publicClassNames: ['switchItem']
  },
  computed: {
    iconComponent: function iconComponent(_ref) {
      var css = _ref.css,
          _iconComponent = _ref.iconComponent;
      return _react.default.createElement(_ComponentOverride.default, {
        component: _iconComponent,
        className: css.switch
      });
    }
  },
  render: function render(props) {
    return _react.default.createElement(_ToggleItem.default, _extends({
      "data-webos-voice-intent": "SetToggleItem"
    }, props, {
      css: props.css,
      iconPosition: "after"
    }));
  }
});
exports.SwitchItemBase = exports.SwitchItem = SwitchItemBase;
var _default = SwitchItemBase;
exports.default = _default;