import _Switch from "@alifd/next/es/switch";
import React, { useState } from 'react';
var CommonSwitch = function CommonSwitch(_ref) {
  var value = _ref.value,
    defaultValue = _ref.defaultValue,
    isDisabled = _ref.isDisabled,
    onChange = _ref.onChange;
  React.useEffect(function () {
    setValue(value);
  }, [value]);
  var _useState = useState(value ? value : defaultValue),
    inputValue = _useState[0],
    setValue = _useState[1];
  var onInputChange = function onInputChange(value) {
    onChange && onChange(value);
    setValue(value);
  };
  return /*#__PURE__*/React.createElement(_Switch, {
    autoWidth: true,
    checked: inputValue,
    checkedChildren: "\u662F",
    unCheckedChildren: "\u5426",
    disabled: isDisabled,
    onChange: function onChange(e) {
      return onInputChange(e);
    }
  });
};
CommonSwitch.displayName = 'CommonSwitch';
export default CommonSwitch;