"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.HeadingDecorator = exports.HeadingBase = exports.Heading = exports["default"] = void 0;

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

var _Pure = _interopRequireDefault(require("@enact/ui/internal/Pure"));

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

var _compose = _interopRequireDefault(require("ramda/src/compose"));

var _defaultProps = _interopRequireDefault(require("recompose/defaultProps"));

var _setPropTypes = _interopRequireDefault(require("recompose/setPropTypes"));

var _Heading = _interopRequireDefault(require("@enact/ui/Heading"));

var _Marquee = require("../Marquee");

var _Skinnable = _interopRequireDefault(require("../Skinnable"));

var _HeadingModule = _interopRequireDefault(require("./Heading.module.css"));

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

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

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

/**
 * A labeled Heading component.
 *
 * This component is most often not used directly but may be composed within another component as it
 * is within [Heading]{@link agate/Heading.Heading}.
 *
 * @class HeadingBase
 * @memberof agate/Heading
 * @extends ui/Heading.Heading
 * @ui
 * @public
 */
var HeadingBase = (0, _kind["default"])({
  name: 'Heading',
  propTypes:
  /** @lends agate/Heading.HeadingBase.prototype */
  {
    /**
     * Set a custom color to be used by the Heading when `size` is "title".
     * Defaults to the current accent color if none is specified.
     *
     * @type {String}
     * @public
     */
    color: _propTypes["default"].string,
    css: _propTypes["default"].object,

    /**
     * Adds a horizontal-rule (line) under the component
     *
     * @type {Boolean}
     * @public
     */
    showLine: _propTypes["default"].bool,

    /**
     * The size of the spacing around the Heading.
     *
     * Allowed values include:
     * * `'auto'` - Value is based on the `size` prop for automatic usage.
     * * `'title'` - Specifically assign the `'title'` spacing.
     * * `'large'` - Specifically assign the `'large'` spacing.
     * * `'medium'` - Specifically assign the `'medium'` spacing.
     * * `'small'` - Specifically assign the `'small'` spacing.
     * * `'none'` - No spacing at all. Neighboring elements will directly touch the Heading.
     *
     * @type {('auto'|'title'|'large'|'medium'|'small'|'none')}
     * @default 'auto'
     * @public
     */
    spacing: _propTypes["default"].oneOf(['auto', 'title', 'large', 'medium', 'small', 'none'])
  },
  defaultProps: {
    spacing: 'auto'
  },
  styles: {
    css: _HeadingModule["default"],
    className: 'heading',
    publicClassNames: true
  },
  computed: {
    className: function className(_ref) {
      var showLine = _ref.showLine,
          styler = _ref.styler;
      return styler.append({
        showLine: showLine
      });
    },
    style: function style(_ref2) {
      var color = _ref2.color,
          _style = _ref2.style;
      return _objectSpread(_objectSpread({}, _style), {}, {
        '--agate-heading-accent': color
      });
    }
  },
  render: function render(_ref3) {
    var css = _ref3.css,
        rest = _objectWithoutProperties(_ref3, ["css"]);

    delete rest.color;
    delete rest.showLine;
    return _Heading["default"].inline(_objectSpread({
      css: css
    }, rest));
  }
});
/**
 * Applies Agate specific behaviors to [HeadingBase]{@link agate/Heading.HeadingBase}.
 *
 * @hoc
 * @memberof agate/Heading
 * @mixes agate/Marquee.MarqueeDecorator
 * @mixes agate/Skinnable.Skinnable
 * @public
 */

exports.HeadingBase = HeadingBase;
var HeadingDecorator = (0, _compose["default"])((0, _setPropTypes["default"])({
  marqueeOn: _propTypes["default"].oneOf(['hover', 'render'])
}), (0, _defaultProps["default"])({
  marqueeOn: 'render'
}), _Pure["default"], _Marquee.MarqueeDecorator, _Skinnable["default"]);
/**
 * A labeled Heading component, ready to use in Agate applications.
 *
 * `Heading` may be used as a header to group related components.
 *
 * Usage:
 * ```
 * <Heading
 *   spacing="medium"
 * >
 *   Related Settings
 * </Heading>
 * <CheckboxItem>A Setting</CheckboxItem>
 * <CheckboxItem>A Second Setting</CheckboxItem>
 * ```
 *
 * @class Heading
 * @memberof agate/Heading
 * @extends agate/Heading.HeadingBase
 * @mixes agate/Heading.HeadingDecorator
 * @ui
 * @public
 */

exports.HeadingDecorator = HeadingDecorator;
var Heading = HeadingDecorator(HeadingBase);
/**
 * Marquee animation trigger.
 *
 * Allowed values include:
 * * `'hover'` - Marquee begins when the pointer enters the component
 * * `'render'` - Marquee begins when the component is rendered
 *
 * @name marqueeOn
 * @type {('hover'|'render')}
 * @default 'render'
 * @memberof agate/Heading.Heading.prototype
 * @see {@link agate/Marquee.Marquee}
 * @public
 */

exports.Heading = Heading;
var _default = Heading;
exports["default"] = _default;