dtable-ui-component 4.3.12 → 4.4.0-alpha2
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", {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
3
|
import { Popover } from 'reactstrap';
|
|
4
|
+
import { searchCollaborators } from 'dtable-utils';
|
|
4
5
|
import SelectOptionGroup from '../SelectOptionGroup';
|
|
5
|
-
import { searchCollaborators } from './utils';
|
|
6
6
|
import './index.css';
|
|
7
7
|
class CollaboratorSelect extends Component {
|
|
8
8
|
constructor(props) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dtable-ui-component",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0-alpha2",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@seafile/react-image-lightbox": "2.0.5",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"classnames": "^2.3.2",
|
|
12
12
|
"dayjs": "1.10.7",
|
|
13
13
|
"deepmerge": "^2.1.0",
|
|
14
|
-
"dtable-utils": "
|
|
14
|
+
"dtable-utils": "4.4.0",
|
|
15
15
|
"hast-util-sanitize": "^1.1.2",
|
|
16
16
|
"hast-util-to-html": "3.1.0",
|
|
17
17
|
"is-hotkey": "0.2.0",
|
|
@@ -118,6 +118,9 @@
|
|
|
118
118
|
"file-loader": "4.3.0",
|
|
119
119
|
"fs-extra": "^8.1.0",
|
|
120
120
|
"html-webpack-plugin": "4.0.0-beta.11",
|
|
121
|
+
"i18next": "22.4.9",
|
|
122
|
+
"i18next-browser-languagedetector": "7.0.1",
|
|
123
|
+
"i18next-xhr-backend": "3.2.2",
|
|
121
124
|
"identity-obj-proxy": "3.0.0",
|
|
122
125
|
"jest": "24.9.0",
|
|
123
126
|
"jest-environment-jsdom-fourteen": "1.0.1",
|
|
@@ -133,6 +136,7 @@
|
|
|
133
136
|
"postcss-safe-parser": "4.0.1",
|
|
134
137
|
"react-dev-utils": "^12.0.1",
|
|
135
138
|
"react-element-to-jsx-string": "^14.3.1",
|
|
139
|
+
"react-i18next": "12.1.4",
|
|
136
140
|
"resolve": "1.15.0",
|
|
137
141
|
"resolve-url-loader": "3.1.5",
|
|
138
142
|
"sass-loader": "8.0.2",
|
|
@@ -142,10 +146,6 @@
|
|
|
142
146
|
"ts-pnp": "1.1.5",
|
|
143
147
|
"url-loader": "2.3.0",
|
|
144
148
|
"webpack": "4.41.5",
|
|
145
|
-
"i18next": "22.4.9",
|
|
146
|
-
"i18next-browser-languagedetector": "7.0.1",
|
|
147
|
-
"i18next-xhr-backend": "3.2.2",
|
|
148
|
-
"react-i18next": "12.1.4",
|
|
149
149
|
"webpack-dev-server": "3.11.3",
|
|
150
150
|
"webpack-manifest-plugin": "2.2.0",
|
|
151
151
|
"workbox-webpack-plugin": "4.3.1"
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export const searchCollaborators = (collaborators, searchValue) => {
|
|
2
|
-
const validSearchValue = searchValue ? searchValue.trim().toLowerCase() : '';
|
|
3
|
-
const validCollaborators = Array.isArray(collaborators) && collaborators.length > 0 ? collaborators : [];
|
|
4
|
-
if (!validSearchValue) return validCollaborators;
|
|
5
|
-
return validCollaborators.filter(collaborator => {
|
|
6
|
-
const {
|
|
7
|
-
name,
|
|
8
|
-
name_pinyin = ''
|
|
9
|
-
} = collaborator;
|
|
10
|
-
if (name.toString().toLowerCase().indexOf(validSearchValue) > -1) return true;
|
|
11
|
-
if (!name_pinyin) return false;
|
|
12
|
-
const validNamePinyin = name_pinyin.toString().toLowerCase();
|
|
13
|
-
const validSearchPinyinValue = validSearchValue.replace(/ |'/g, '');
|
|
14
|
-
|
|
15
|
-
// complete
|
|
16
|
-
if (validNamePinyin.indexOf(validSearchPinyinValue) > -1) return true;
|
|
17
|
-
if (validNamePinyin.replace(/'/g, '').indexOf(validSearchPinyinValue) > -1) return true;
|
|
18
|
-
const validNamePinyinList = validNamePinyin.split('\'');
|
|
19
|
-
// acronym
|
|
20
|
-
const namePinyinAcronym = validNamePinyinList.map(item => item && item.trim() ? item.trim().slice(0, 1) : '');
|
|
21
|
-
if (namePinyinAcronym.join('').indexOf(validSearchPinyinValue) > -1) return true;
|
|
22
|
-
return false;
|
|
23
|
-
});
|
|
24
|
-
};
|