import React, { useRef } from 'react';
import { Spin, Drawer } from '@whalecloud/fdx';
import Editor from "@monaco-editor/react";
export default (function (props) {
  var drawVisible = props.drawVisible,
      onClose = props.onClose,
      value = props.value,
      title = props.title,
      _props$language = props.language,
      language = _props$language === void 0 ? 'json' : _props$language; // const [isEditorReady, setIsEditorReady] = useState(false);

  var valueGetter = useRef();

  function handleEditorDidMount(_valueGetter) {
    //setIsEditorReady(true);
    valueGetter.current = _valueGetter;
  } // function handleShowValue() {
  //     alert(valueGetter.current());
  // }


  var onDrawerCLose = function onDrawerCLose() {
    var code = valueGetter.current();
    onClose(code);
  };

  return /*#__PURE__*/React.createElement(Drawer, {
    title: title || 'Code Editor',
    placement: "right",
    closable: false,
    width: 720,
    onClose: onDrawerCLose,
    visible: drawVisible
  }, /*#__PURE__*/React.createElement(Editor, {
    height: "90vh" // By default, it fully fits with its parent
    ,
    theme: "dark",
    language: language,
    loading: /*#__PURE__*/React.createElement(Spin, null),
    value: value,
    editorDidMount: handleEditorDidMount
  }));
});
//# sourceMappingURL=CodeDrawer.js.map