'use strict';

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

var vue = require('vue');
require('../../../utils/index.cjs');
var index = require('../../date-picker/src/generatePicker/index.cjs');
require('../../date-picker/index.cjs');
var FormItemContext = require('../../form/src/FormItemContext.cjs');
var props = require('./props.cjs');
var props$1 = require('../../date-picker/src/generatePicker/props.cjs');
var log = require('../../../utils/log.cjs');
var omit = require('../../../utils/lang/omit.cjs');

function createTimePicker(generateConfig) {
  const DatePicker = index.default(generateConfig, {
    ...props.commonTimePickerProps(),
    order: {
      type: Boolean,
      default: true
    }
  });
  const {
    TimePicker: InternalTimePicker,
    RangePicker: InternalRangePicker
  } = DatePicker;
  const TimePicker = /* @__PURE__ */ vue.defineComponent({
    name: "ATimePicker",
    inheritAttrs: false,
    props: {
      ...props$1.commonProps(),
      ...props$1.datePickerProps(),
      ...props.commonTimePickerProps(),
      addon: {
        type: Function
      }
    },
    slots: Object,
    setup(p, {
      slots,
      expose,
      emit,
      attrs
    }) {
      const props = p;
      const formItemContext = FormItemContext.useInjectFormItemContext();
      log.devWarning(!(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, {
          ...attrs,
          ...omit.omit(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$1.commonProps(),
      ...props$1.rangePickerProps(),
      ...props.commonTimePickerProps(),
      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, {
          ...attrs,
          ...omit.omit(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;
//# sourceMappingURL=TimePicker.cjs.map
