dtable-ui-component 4.4.1 → 4.4.2
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { Fragment } from 'react';
|
|
2
2
|
import MediaQuery from 'react-responsive';
|
|
3
3
|
import { getLocale } from '../lang';
|
|
4
|
+
import ModalPortal from '../common/modal-portal';
|
|
4
5
|
import CollaboratorItem from '../CollaboratorItem';
|
|
5
6
|
import EditEditorButton from '../EditEditorButton';
|
|
6
7
|
import PCCollaboratorEditorPopover from './pc-collaborator-editor-popover';
|
|
@@ -10,6 +11,11 @@ class CollaboratorEditor extends React.Component {
|
|
|
10
11
|
constructor(props) {
|
|
11
12
|
super(props);
|
|
12
13
|
this.onMouseDown = e => {
|
|
14
|
+
if (this.state.isPopoverShow && this.editorPopoverRef) {
|
|
15
|
+
if (this.editorPopoverRef === e.target || this.editorPopoverRef.contains(e.target)) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
13
19
|
if (this.editorContainer !== e.target && !this.editorContainer.contains(e.target)) {
|
|
14
20
|
this.onClosePopover();
|
|
15
21
|
}
|
|
@@ -82,6 +88,17 @@ class CollaboratorEditor extends React.Component {
|
|
|
82
88
|
}
|
|
83
89
|
};
|
|
84
90
|
this.caculatePopoverPosition = () => {
|
|
91
|
+
if (this.props.isInModel) {
|
|
92
|
+
const {
|
|
93
|
+
top,
|
|
94
|
+
left
|
|
95
|
+
} = this.editor.getBoundingClientRect();
|
|
96
|
+
return {
|
|
97
|
+
top: top + 40,
|
|
98
|
+
left,
|
|
99
|
+
zIndex: 1051
|
|
100
|
+
};
|
|
101
|
+
}
|
|
85
102
|
const POPOVER_MAX_HEIGHT = 200;
|
|
86
103
|
let innerHeight = window.innerHeight;
|
|
87
104
|
let {
|
|
@@ -122,6 +139,9 @@ class CollaboratorEditor extends React.Component {
|
|
|
122
139
|
this.setEditorRef = editor => {
|
|
123
140
|
this.editor = editor;
|
|
124
141
|
};
|
|
142
|
+
this.setPopoverRef = ref => {
|
|
143
|
+
this.editorPopoverRef = ref;
|
|
144
|
+
};
|
|
125
145
|
this.state = {
|
|
126
146
|
newValue: Array.isArray(props.value) ? props.value : [],
|
|
127
147
|
isPopoverShow: false,
|
|
@@ -167,13 +187,14 @@ class CollaboratorEditor extends React.Component {
|
|
|
167
187
|
});
|
|
168
188
|
}))), isPopoverShow && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(MediaQuery, {
|
|
169
189
|
query: '(min-width: 768px)'
|
|
170
|
-
}, /*#__PURE__*/React.createElement(PCCollaboratorEditorPopover, {
|
|
190
|
+
}, /*#__PURE__*/React.createElement(ModalPortal, null, /*#__PURE__*/React.createElement(PCCollaboratorEditorPopover, {
|
|
171
191
|
popoverPosition: popoverPosition,
|
|
172
192
|
isReadOnly: this.props.isReadOnly,
|
|
173
193
|
selectedCollaborators: selectedCollaborators,
|
|
174
194
|
collaborators: collaborators,
|
|
175
|
-
onCollaboratorItemToggle: this.onCollaboratorItemToggle
|
|
176
|
-
|
|
195
|
+
onCollaboratorItemToggle: this.onCollaboratorItemToggle,
|
|
196
|
+
setPopoverRef: this.setPopoverRef
|
|
197
|
+
}))), /*#__PURE__*/React.createElement(MediaQuery, {
|
|
177
198
|
query: '(max-width: 767.8px)'
|
|
178
199
|
}, /*#__PURE__*/React.createElement(MBCollaboratorEditorPopover, {
|
|
179
200
|
isReadOnly: this.props.isReadOnly,
|
|
@@ -188,6 +209,7 @@ class CollaboratorEditor extends React.Component {
|
|
|
188
209
|
CollaboratorEditor.defaultProps = {
|
|
189
210
|
isShowEditButton: true,
|
|
190
211
|
isReadOnly: false,
|
|
191
|
-
value: []
|
|
212
|
+
value: [],
|
|
213
|
+
isInModel: false
|
|
192
214
|
};
|
|
193
215
|
export default CollaboratorEditor;
|
|
@@ -54,7 +54,8 @@ class PCCollaboratorEditorPopover extends React.Component {
|
|
|
54
54
|
});
|
|
55
55
|
return /*#__PURE__*/React.createElement("div", {
|
|
56
56
|
className: "dtable-ui-editor-popover dtable-ui-collaborator-editor-popover",
|
|
57
|
-
style: popoverStyle
|
|
57
|
+
style: popoverStyle,
|
|
58
|
+
ref: this.props.setPopoverRef
|
|
58
59
|
}, /*#__PURE__*/React.createElement("div", {
|
|
59
60
|
className: "collaborator-search-container"
|
|
60
61
|
}, /*#__PURE__*/React.createElement("input", {
|