@yuntijs/ui 1.0.0-beta.115 → 1.0.0-beta.116

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,6 +41,7 @@ export interface IGeneralManacoEditorProps {
41
41
  }
42
42
  export interface ISingleMonacoEditorProps extends IGeneralManacoEditorProps {
43
43
  onChange?: (input: string, event: IEditor.IModelContentChangedEvent) => void;
44
+ onBlur?: (input: string, event: any) => void;
44
45
  supportFullScreen?: boolean;
45
46
  onFullScreenChange?: (isFullScreen: boolean) => void;
46
47
  }
@@ -12,6 +12,7 @@ function noop() {}
12
12
  var SingleMonacoEditor = function SingleMonacoEditor(props) {
13
13
  var _props$options;
14
14
  var onChange = props.onChange,
15
+ onBlur = props.onBlur,
15
16
  enableOutline = props.enableOutline,
16
17
  width = props.width,
17
18
  height = props.height,
@@ -19,6 +20,7 @@ var SingleMonacoEditor = function SingleMonacoEditor(props) {
19
20
  supportFullScreen = props.supportFullScreen,
20
21
  onFullScreenChange = props.onFullScreenChange;
21
22
  var onChangeRef = useRef(onChange);
23
+ var onBlurRef = useRef(onBlur);
22
24
  var _useEditor = useEditor('single', props),
23
25
  isEditorReady = _useEditor.isEditorReady,
24
26
  focused = _useEditor.focused,
@@ -28,6 +30,7 @@ var SingleMonacoEditor = function SingleMonacoEditor(props) {
28
30
  editorRef = _useEditor.editorRef,
29
31
  valueRef = _useEditor.valueRef;
30
32
  var subscriptionRef = useRef();
33
+ var subscriptionBlurRef = useRef();
31
34
  var _useFullScreen = useFullScreen(editorRef === null || editorRef === void 0 ? void 0 : editorRef.current),
32
35
  isFullScreen = _useFullScreen.isFullScreen,
33
36
  fullScreen = _useFullScreen.fullScreen;
@@ -51,9 +54,12 @@ var SingleMonacoEditor = function SingleMonacoEditor(props) {
51
54
  useEffect(function () {
52
55
  onChangeRef.current = onChange;
53
56
  }, [onChange]);
57
+ useEffect(function () {
58
+ onBlurRef.current = onBlur;
59
+ }, [onBlur]);
54
60
  useEffect(function () {
55
61
  if (isEditorReady) {
56
- var _subscriptionRef$curr;
62
+ var _subscriptionRef$curr, _subscriptionBlurRef$;
57
63
  var editorInstance = editorRef.current;
58
64
  (_subscriptionRef$curr = subscriptionRef.current) === null || _subscriptionRef$curr === void 0 || _subscriptionRef$curr.dispose();
59
65
  subscriptionRef.current = editorInstance === null || editorInstance === void 0 ? void 0 : editorInstance.onDidChangeModelContent(function (event) {
@@ -64,14 +70,21 @@ var SingleMonacoEditor = function SingleMonacoEditor(props) {
64
70
  (_onChangeRef$current = onChangeRef.current) === null || _onChangeRef$current === void 0 || _onChangeRef$current.call(onChangeRef, editorValue, event);
65
71
  }
66
72
  });
73
+ (_subscriptionBlurRef$ = subscriptionBlurRef.current) === null || _subscriptionBlurRef$ === void 0 || _subscriptionBlurRef$.dispose();
74
+ subscriptionBlurRef.current = editorInstance === null || editorInstance === void 0 ? void 0 : editorInstance.onDidBlurEditorText(function (event) {
75
+ var _editorInstance$getMo2, _onBlurRef$current;
76
+ var editorValue = editorInstance === null || editorInstance === void 0 || (_editorInstance$getMo2 = editorInstance.getModel()) === null || _editorInstance$getMo2 === void 0 ? void 0 : _editorInstance$getMo2.getValue();
77
+ (_onBlurRef$current = onBlurRef.current) === null || _onBlurRef$current === void 0 || _onBlurRef$current.call(onBlurRef, editorValue, event);
78
+ });
67
79
  }
68
80
  }, [editorRef, isEditorReady, subscriptionRef, valueRef]);
69
81
  useEffect(function () {
70
82
  return function () {
71
- var _subscriptionRef$curr2, _editorInstance$getMo2, _editorRef$current;
83
+ var _subscriptionRef$curr2, _subscriptionBlurRef$2, _editorInstance$getMo3, _editorRef$current;
72
84
  var editorInstance = editorRef.current;
73
85
  (_subscriptionRef$curr2 = subscriptionRef.current) === null || _subscriptionRef$curr2 === void 0 || _subscriptionRef$curr2.dispose();
74
- editorInstance === null || editorInstance === void 0 || (_editorInstance$getMo2 = editorInstance.getModel()) === null || _editorInstance$getMo2 === void 0 || _editorInstance$getMo2.dispose();
86
+ (_subscriptionBlurRef$2 = subscriptionBlurRef.current) === null || _subscriptionBlurRef$2 === void 0 || _subscriptionBlurRef$2.dispose();
87
+ editorInstance === null || editorInstance === void 0 || (_editorInstance$getMo3 = editorInstance.getModel()) === null || _editorInstance$getMo3 === void 0 || _editorInstance$getMo3.dispose();
75
88
  // eslint-disable-next-line react-hooks/exhaustive-deps
76
89
  (_editorRef$current = editorRef.current) === null || _editorRef$current === void 0 || _editorRef$current.dispose();
77
90
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuntijs/ui",
3
- "version": "1.0.0-beta.115",
3
+ "version": "1.0.0-beta.116",
4
4
  "description": "☁️ Yunti UI - an open-source UI component library for building Cloud Native web apps",
5
5
  "keywords": [
6
6
  "yuntijs",