'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var index = require('../date-picker/generatePicker/index.js');
var props = require('../date-picker/generatePicker/props.js');
var devWarning = require('../vc-util/devWarning.js');
var FormItemContext = require('../form/FormItemContext.js');
var omit = require('../_util/omit.js');
var type = require('../_util/type.js');

const timePickerProps = () => ({
  format: String,
  showNow: type.booleanType(),
  showHour: type.booleanType(),
  showMinute: type.booleanType(),
  showSecond: type.booleanType(),
  use12Hours: type.booleanType(),
  hourStep: Number,
  minuteStep: Number,
  secondStep: Number,
  hideDisabledOptions: type.booleanType(),
  popupClassName: String,
  status: type.stringType()
});
function createTimePicker(generateConfig) {
  const DatePicker = index.default(generateConfig, {
    ...timePickerProps(),
    order: {
      type: Boolean,
      default: true
    }
  });
  const {
    TimePicker: InternalTimePicker,
    RangePicker: InternalRangePicker
  } = DatePicker;
  const TimePicker = /* @__PURE__ */ vue.defineComponent({
    name: "ATimePicker",
    inheritAttrs: false,
    props: {
      ...props.commonProps(),
      ...props.datePickerProps(),
      ...timePickerProps(),
      addon: {
        type: Function
      }
    },
    slots: Object,
    setup(p, {
      slots,
      expose,
      emit,
      attrs
    }) {
      const props = p;
      const formItemContext = FormItemContext.useInjectFormItemContext();
      devWarning.default(!(slots.addon || props.addon), "TimePicker", "`addon` is deprecated. Please use `v-slot:renderExtraFooter` instead.");
      const pickerRef = vue.ref();
      expose({
        focus: () => {
          var _a;
          (_a = pickerRef.value) == null ? void 0 : _a.focus();
        },
        blur: () => {
          var _a;
          (_a = pickerRef.value) == null ? void 0 : _a.blur();
        }
      });
      const onChange = (value, dateString) => {
        emit("update:value", value);
        emit("change", value, dateString);
        formItemContext.onFieldChange();
      };
      const onOpenChange = (open) => {
        emit("update:open", open);
        emit("openChange", open);
      };
      const onFocus = (e) => {
        emit("focus", e);
      };
      const onBlur = (e) => {
        emit("blur", e);
        formItemContext.onFieldBlur();
      };
      const onOk = (value) => {
        emit("ok", value);
      };
      return () => {
        const {
          id = formItemContext.id.value
        } = props;
        return vue.createVNode(InternalTimePicker, vue.mergeProps(attrs, omit.default(props, ["onUpdate:value", "onUpdate:open"]), {
          "id": id,
          "dropdownClassName": props.popupClassName,
          "mode": void 0,
          "ref": pickerRef,
          "renderExtraFooter": props.addon || slots.addon || props.renderExtraFooter || slots.renderExtraFooter,
          "onChange": onChange,
          "onOpenChange": onOpenChange,
          "onFocus": onFocus,
          "onBlur": onBlur,
          "onOk": onOk
        }), slots);
      };
    }
  });
  const TimeRangePicker = /* @__PURE__ */ vue.defineComponent({
    name: "ATimeRangePicker",
    inheritAttrs: false,
    props: {
      ...props.commonProps(),
      ...props.rangePickerProps(),
      ...timePickerProps(),
      order: {
        type: Boolean,
        default: true
      }
    },
    slots: Object,
    setup(p, {
      slots,
      expose,
      emit,
      attrs
    }) {
      const props = p;
      const pickerRef = vue.ref();
      const formItemContext = FormItemContext.useInjectFormItemContext();
      expose({
        focus: () => {
          var _a;
          (_a = pickerRef.value) == null ? void 0 : _a.focus();
        },
        blur: () => {
          var _a;
          (_a = pickerRef.value) == null ? void 0 : _a.blur();
        }
      });
      const onChange = (values, dateStrings) => {
        emit("update:value", values);
        emit("change", values, dateStrings);
        formItemContext.onFieldChange();
      };
      const onOpenChange = (open) => {
        emit("update:open", open);
        emit("openChange", open);
      };
      const onFocus = (e) => {
        emit("focus", e);
      };
      const onBlur = (e) => {
        emit("blur", e);
        formItemContext.onFieldBlur();
      };
      const onPanelChange = (values, modes) => {
        emit("panelChange", values, modes);
      };
      const onOk = (values) => {
        emit("ok", values);
      };
      const onCalendarChange = (values, dateStrings, info) => {
        emit("calendarChange", values, dateStrings, info);
      };
      return () => {
        const {
          id = formItemContext.id.value
        } = props;
        return vue.createVNode(InternalRangePicker, vue.mergeProps(attrs, omit.default(props, ["onUpdate:open", "onUpdate:value"]), {
          "id": id,
          "dropdownClassName": props.popupClassName,
          "picker": "time",
          "mode": void 0,
          "ref": pickerRef,
          "onChange": onChange,
          "onOpenChange": onOpenChange,
          "onFocus": onFocus,
          "onBlur": onBlur,
          "onPanelChange": onPanelChange,
          "onOk": onOk,
          "onCalendarChange": onCalendarChange
        }), slots);
      };
    }
  });
  return {
    TimePicker,
    TimeRangePicker
  };
}

exports.default = createTimePicker;
exports.timePickerProps = timePickerProps;
//# sourceMappingURL=time-picker.js.map
