dtable-ui-component 4.3.10-alpha3 → 4.3.10-alpha5
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.
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
min-height: 160px;
|
|
15
15
|
max-height: 200px;
|
|
16
16
|
margin: 10px 0;
|
|
17
|
-
padding: 0 10px;
|
|
18
17
|
overflow: auto;
|
|
19
18
|
}
|
|
20
19
|
|
|
@@ -23,7 +22,7 @@
|
|
|
23
22
|
align-items: center;
|
|
24
23
|
justify-content: space-between;
|
|
25
24
|
height: 30px;
|
|
26
|
-
padding
|
|
25
|
+
padding: 0 10px;
|
|
27
26
|
font-size: 14px;
|
|
28
27
|
cursor: pointer;
|
|
29
28
|
}
|
|
@@ -45,3 +44,22 @@
|
|
|
45
44
|
font-size: 12px;
|
|
46
45
|
color: #798d99;
|
|
47
46
|
}
|
|
47
|
+
|
|
48
|
+
.dtable-ui-collaborator-editor .dtable-ui-collaborator-editor-container-no-btn {
|
|
49
|
+
min-height: 40px;
|
|
50
|
+
padding: 0.375rem 0.75rem;
|
|
51
|
+
border: 1px solid rgba(0, 40, 100, 0.12);
|
|
52
|
+
border-radius: 3px;
|
|
53
|
+
transition: border-color .15s ease-in-out;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.dtable-ui-collaborator-editor .dtable-ui-collaborator-editor-container-no-btn .collaborators-container {
|
|
57
|
+
min-height: 26px;
|
|
58
|
+
display: flex;
|
|
59
|
+
align-items: center;
|
|
60
|
+
flex-wrap: wrap;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.dtable-ui-collaborator-editor .dtable-ui-collaborator-editor-container-no-btn .collaborators-container .collaborator-item {
|
|
64
|
+
margin: 2px 10px 2px 0;
|
|
65
|
+
}
|
|
@@ -9,7 +9,7 @@ import './index.css';
|
|
|
9
9
|
class CollaboratorEditor extends React.Component {
|
|
10
10
|
constructor(props) {
|
|
11
11
|
super(props);
|
|
12
|
-
this.
|
|
12
|
+
this.onDocumentClick = e => {
|
|
13
13
|
if (this.editorContainer !== e.target && !this.editorContainer.contains(e.target)) {
|
|
14
14
|
this.onClosePopover();
|
|
15
15
|
}
|
|
@@ -56,19 +56,29 @@ class CollaboratorEditor extends React.Component {
|
|
|
56
56
|
this.props.onCommit(updated);
|
|
57
57
|
};
|
|
58
58
|
this.onCollaboratorItemToggle = collaborator => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
if (this.props.isMultilple) {
|
|
60
|
+
let newValue = this.state.newValue.slice();
|
|
61
|
+
let collaboratorIndex = newValue.findIndex(collaboratorEmail => collaboratorEmail === collaborator.email);
|
|
62
|
+
if (collaboratorIndex !== -1) {
|
|
63
|
+
newValue.splice(collaboratorIndex, 1);
|
|
64
|
+
} else {
|
|
65
|
+
newValue.push(collaborator.email);
|
|
66
|
+
}
|
|
67
|
+
this.setState({
|
|
68
|
+
newValue
|
|
69
|
+
}, () => {
|
|
70
|
+
this.onCommit(newValue);
|
|
71
|
+
});
|
|
63
72
|
} else {
|
|
64
|
-
newValue.
|
|
73
|
+
const collaboratorIndex = this.state.newValue.findIndex(collaboratorEmail => collaboratorEmail === collaborator.email);
|
|
74
|
+
const newValue = collaboratorIndex === -1 ? [collaborator.email] : [];
|
|
75
|
+
this.setState({
|
|
76
|
+
newValue
|
|
77
|
+
}, () => {
|
|
78
|
+
this.onCommit(newValue);
|
|
79
|
+
this.onClosePopover();
|
|
80
|
+
});
|
|
65
81
|
}
|
|
66
|
-
this.setState({
|
|
67
|
-
newValue
|
|
68
|
-
}, () => {
|
|
69
|
-
this.onCommit(newValue);
|
|
70
|
-
this.onClosePopover();
|
|
71
|
-
});
|
|
72
82
|
};
|
|
73
83
|
this.onDeleteCollaborator = collaborator => {
|
|
74
84
|
let newValue = this.state.newValue.slice();
|
|
@@ -110,8 +120,11 @@ class CollaboratorEditor extends React.Component {
|
|
|
110
120
|
};
|
|
111
121
|
this.onClickContainer = e => {
|
|
112
122
|
e.stopPropagation();
|
|
113
|
-
if (!this.props.isShowEditButton) {
|
|
114
|
-
this.
|
|
123
|
+
if (!this.props.isShowEditButton && !this.state.isPopoverShow) {
|
|
124
|
+
this.setState({
|
|
125
|
+
isPopoverShow: true,
|
|
126
|
+
popoverPosition: this.caculatePopoverPosition()
|
|
127
|
+
});
|
|
115
128
|
}
|
|
116
129
|
};
|
|
117
130
|
this.setEditorContainerRef = editorContainer => {
|
|
@@ -127,10 +140,10 @@ class CollaboratorEditor extends React.Component {
|
|
|
127
140
|
};
|
|
128
141
|
}
|
|
129
142
|
componentDidMount() {
|
|
130
|
-
document.addEventListener('click', this.
|
|
143
|
+
document.addEventListener('click', this.onDocumentClick);
|
|
131
144
|
}
|
|
132
145
|
componentWillUnmount() {
|
|
133
|
-
document.removeEventListener('click', this.
|
|
146
|
+
document.removeEventListener('click', this.onDocumentClick);
|
|
134
147
|
}
|
|
135
148
|
render() {
|
|
136
149
|
let {
|
|
@@ -149,13 +162,13 @@ class CollaboratorEditor extends React.Component {
|
|
|
149
162
|
className: "dtable-ui-collaborator-editor"
|
|
150
163
|
}, /*#__PURE__*/React.createElement("div", {
|
|
151
164
|
ref: this.setEditorRef,
|
|
152
|
-
className: "dtable-ui-collaborator-editor-container",
|
|
165
|
+
className: "dtable-ui-collaborator-editor-container ".concat(isShowEditButton ? '' : 'dtable-ui-collaborator-editor-container-no-btn'),
|
|
153
166
|
onClick: this.onClickContainer
|
|
154
167
|
}, isShowEditButton && /*#__PURE__*/React.createElement(EditEditorButton, {
|
|
155
168
|
text: getLocale('Add_a_collaborator'),
|
|
156
169
|
onClick: this.togglePopover
|
|
157
170
|
}), selectedCollaborators.length > 0 && /*#__PURE__*/React.createElement("div", {
|
|
158
|
-
className: "collaborators-container mt-2
|
|
171
|
+
className: "collaborators-container ".concat(isShowEditButton ? 'mt-2' : '')
|
|
159
172
|
}, selectedCollaborators.map(collaborator => {
|
|
160
173
|
return /*#__PURE__*/React.createElement(CollaboratorItem, {
|
|
161
174
|
key: collaborator.email,
|
|
@@ -184,6 +197,7 @@ class CollaboratorEditor extends React.Component {
|
|
|
184
197
|
}
|
|
185
198
|
}
|
|
186
199
|
CollaboratorEditor.defaultProps = {
|
|
200
|
+
isMultilple: true,
|
|
187
201
|
isShowEditButton: true,
|
|
188
202
|
isReadOnly: false,
|
|
189
203
|
value: []
|