import _TimePicker from "@alifd/next/es/time-picker2";
import React, { useState } from 'react';
//时间控件

var CommonTimePicker = function CommonTimePicker(_ref) {
  var value = _ref.value,
    placeholder = _ref.placeholder,
    defaultValue = _ref.defaultValue,
    isDisabled = _ref.isDisabled,
    _ref$isPreview = _ref.isPreview,
    isPreview = _ref$isPreview === void 0 ? false : _ref$isPreview,
    _ref$outputFormat = _ref.outputFormat,
    outputFormat = _ref$outputFormat === void 0 ? "HH:mm:ss" : _ref$outputFormat,
    onChange = _ref.onChange;
  React.useEffect(function () {
    setValue(value);
  }, [value]);
  var _useState = useState(value),
    inputValue = _useState[0],
    setValue = _useState[1];
  var onTimeChange = function onTimeChange(value) {
    var time = value === null || value === void 0 ? void 0 : value.format(outputFormat);
    onChange && onChange(time);
    setValue(time);
  };
  return /*#__PURE__*/React.createElement(_TimePicker, {
    placeholder: placeholder,
    hasClear: true,
    format: outputFormat,
    value: inputValue,
    defaultValue: defaultValue,
    disabled: isDisabled,
    onChange: function onChange(e) {
      return onTimeChange(e);
    }
  });
};
CommonTimePicker.displayName = 'CommonTimePicker';
export default CommonTimePicker;