"use strict";

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

var _jsxRuntime = require("react/jsx-runtime");

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

var _Changeable = _interopRequireDefault(require("@enact/ui/Changeable"));

var _Layout = require("@enact/ui/Layout");

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

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

var _DatePicker = _interopRequireDefault(require("../DatePicker"));

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

var _TimePicker = _interopRequireDefault(require("../TimePicker"));

var _DateTimePickerModule = _interopRequireDefault(require("./DateTimePicker.module.css"));

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

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

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

/**
 * A date/time Picker component.
 *
 * @class DateTimePickerBase
 * @memberof agate/DateTimePicker
 * @ui
 * @public
 */
var DateTimePickerBase = (0, _kind["default"])({
  name: 'DateTimePickerBase',
  propTypes:
  /** @lends agate/DateTimePicker.DateTimePickerBase.prototype */
  {
    /**
     * The "aria-label" for the day picker.
     *
     * If not specified, the "aria-label" for the day picker will be
     * a combination of the current value and 'day change a value with up down button'.
     *
     * @type {String}
     * @public
     */
    dayAriaLabel: _propTypes["default"].string,

    /**
     * Disables the `DateTimePicker`.
     *
     * @type {Boolean}
     * @public
     */
    disabled: _propTypes["default"].bool,

    /**
     * The "aria-label" for the hour picker
     *
     * If not specified, the "aria-label" for the hour picker will be
     * a combination of the current value and 'hour change a value with up down button'.
     *
     * @type {String}
     * @public
     */
    hourAriaLabel: _propTypes["default"].string,

    /**
     * The "aria-label" for the meridiem picker.
     *
     * If not specified, the "aria-label" for the meridiem picker will be
     * a combination of the current value and 'change a value with up down button'.
     *
     * @type {String}
     * @public
     */
    meridiemAriaLabel: _propTypes["default"].string,

    /**
     * The "aria-label" for the minute picker.
     *
     * If not specified, the "aria-label" for the minute picker will be
     * a combination of the current value and 'minute change a value with up down button'.
     *
     * @type {String}
     * @public
     */
    minuteAriaLabel: _propTypes["default"].string,

    /**
     * The "aria-label" for the month picker.
     *
     * If not specified, the "aria-label" for the month picker will be
     * a combination of the current value and 'month change a value with up down button'.
     *
     * @type {String}
     * @public
     */
    monthAriaLabel: _propTypes["default"].string,

    /**
     * Handler for `onChange` events
     *
     * @type {Function}
     * @public
     */
    onChange: _propTypes["default"].func,

    /**
     * Called when the component is removed when it had focus.
     *
     * @type {Function}
     * @param {Object} event
     * @public
     */
    onSpotlightDisappear: _propTypes["default"].func,

    /**
     * Disables 5-way spotlight from navigating into the component.
     *
     * @type {Boolean}
     * @public
     */
    spotlightDisabled: _propTypes["default"].bool,

    /**
     * The value of the DateTimePicker.
     *
     * @type {Date}
     * @public
     */
    value: _propTypes["default"].instanceOf(Date),

    /**
     * The "aria-label" for the year picker.
     *
     * If not specified, the "aria-label" for the year picker will be
     * a combination of the current value and 'year change a value with up down button'.
     *
     * @type {String}
     * @public
     */
    yearAriaLabel: _propTypes["default"].string
  },
  styles: {
    css: _DateTimePickerModule["default"],
    className: 'dateTimePicker'
  },
  render: function render(_ref) {
    var dayAriaLabel = _ref.dayAriaLabel,
        disabled = _ref.disabled,
        hourAriaLabel = _ref.hourAriaLabel,
        meridiemAriaLabel = _ref.meridiemAriaLabel,
        minuteAriaLabel = _ref.minuteAriaLabel,
        monthAriaLabel = _ref.monthAriaLabel,
        onChange = _ref.onChange,
        onSpotlightDisappear = _ref.onSpotlightDisappear,
        spotlightDisabled = _ref.spotlightDisabled,
        value = _ref.value,
        yearAriaLabel = _ref.yearAriaLabel,
        rest = _objectWithoutProperties(_ref, ["dayAriaLabel", "disabled", "hourAriaLabel", "meridiemAriaLabel", "minuteAriaLabel", "monthAriaLabel", "onChange", "onSpotlightDisappear", "spotlightDisabled", "value", "yearAriaLabel"]);

    return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Layout.Row, _objectSpread(_objectSpread({}, rest), {}, {
      className: _DateTimePickerModule["default"].dateTimePicker,
      align: "center center",
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Layout.Row, {
        align: "center center",
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TimePicker["default"], _objectSpread(_objectSpread({}, rest), {}, {
          css: _DateTimePickerModule["default"],
          disabled: disabled,
          hourAriaLabel: hourAriaLabel,
          meridiemAriaLabel: meridiemAriaLabel,
          minuteAriaLabel: minuteAriaLabel,
          onChange: onChange,
          onSpotlightDisappear: onSpotlightDisappear,
          spotlightDisabled: spotlightDisabled,
          value: value
        }))
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Layout.Row, {
        align: "center center",
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DatePicker["default"], _objectSpread(_objectSpread({}, rest), {}, {
          css: _DateTimePickerModule["default"],
          dayAriaLabel: dayAriaLabel,
          disabled: disabled,
          monthAriaLabel: monthAriaLabel,
          onChange: onChange,
          onSpotlightDisappear: onSpotlightDisappear,
          spotlightDisabled: spotlightDisabled,
          value: value,
          yearAriaLabel: yearAriaLabel
        }))
      })]
    }));
  }
});
/**
 * Applies Agate specific behaviors to [DateTimePickerBase]{@link agate/DateTimePicker.DateTimePickerBase} components.
 *
 * @hoc
 * @memberof agate/DateTimePicker
 * @mixes agate/Skinnable.Skinnable
 * @mixes ui/Changeable.Changeable
 * @public
 */

exports.DateTimePickerBase = DateTimePickerBase;
var DateTimePickerDecorator = (0, _compose["default"])(_Skinnable["default"], _Changeable["default"]);
/**
 * An Agate themed date/time Picker component.
 *
 * @class DateTimePicker
 * @memberof agate/DateTimePicker
 * @extends agate/DateTimePicker.DateTimePickerBase
 * @mixes agate/DateTimePicker.DateTimePickerDecorator
 * @ui
 * @public
 */

var DateTimePicker = DateTimePickerDecorator(DateTimePickerBase);
exports.DateTimePicker = DateTimePicker;
var _default = DateTimePicker;
exports["default"] = _default;