import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
import React, { useState } from "react";
import { ReactComponent as LinkIcon } from "@svgr/webpack!../../../../../assets/icons/style-settings-link.svg";
import { ReactComponent as LinkBrokenIcon } from "@svgr/webpack!../../../../../assets/icons/style-settings-link-broken.svg";
import "./index.module.less";

var LinkButton = function LinkButton(props) {
  var onChange = props.onChange,
      _props$defaultValue = props.defaultValue,
      defaultValue = _props$defaultValue === void 0 ? true : _props$defaultValue;

  var _useState = useState(defaultValue),
      _useState2 = _slicedToArray(_useState, 2),
      linkState = _useState2[0],
      setLinkState = _useState2[1];

  var linkClick = function linkClick() {
    setLinkState(!linkState);
    if (onChange) onChange(!linkState);
  };

  return /*#__PURE__*/React.createElement(React.Fragment, null, !linkState && /*#__PURE__*/React.createElement(LinkIcon, {
    className: "formbuild-style-linkIcon",
    onClick: linkClick
  }), linkState && /*#__PURE__*/React.createElement(LinkBrokenIcon, {
    className: "formbuild-style-linkIcon",
    onClick: linkClick
  }));
};

export default LinkButton;
//# sourceMappingURL=index.js.map