dtable-ui-component 4.3.10 → 4.3.11-alpha1

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.
@@ -15,7 +15,7 @@ class CTimeFormatter extends React.Component {
15
15
  containerClassName
16
16
  } = this.props;
17
17
  let classname = classnames('dtable-ui cell-formatter-container ctime-formatter', containerClassName);
18
- if (date !== '') {
18
+ if (date) {
19
19
  date = this.formatDate(date);
20
20
  }
21
21
  return /*#__PURE__*/React.createElement("div", {
@@ -14,16 +14,20 @@
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
 
20
+ .dtable-ui-collaborator-editor-popover .collaborator-list-container .search-option-null {
21
+ opacity: 0.5;
22
+ padding-left: 10px;
23
+ }
24
+
21
25
  .dtable-ui-collaborator-editor-popover .collaborator-list-container .collaborator-item-container {
22
26
  display: flex;
23
27
  align-items: center;
24
28
  justify-content: space-between;
25
29
  height: 30px;
26
- padding-left: 12px;
30
+ padding: 0 10px;
27
31
  font-size: 14px;
28
32
  cursor: pointer;
29
33
  }
@@ -45,3 +49,22 @@
45
49
  font-size: 12px;
46
50
  color: #798d99;
47
51
  }
52
+
53
+ .dtable-ui-collaborator-editor .dtable-ui-collaborator-editor-container-no-btn {
54
+ min-height: 40px;
55
+ padding: 0.375rem 0.75rem;
56
+ border: 1px solid rgba(0, 40, 100, 0.12);
57
+ border-radius: 3px;
58
+ transition: border-color .15s ease-in-out;
59
+ }
60
+
61
+ .dtable-ui-collaborator-editor .dtable-ui-collaborator-editor-container-no-btn .collaborators-container {
62
+ min-height: 26px;
63
+ display: flex;
64
+ align-items: center;
65
+ flex-wrap: wrap;
66
+ }
67
+
68
+ .dtable-ui-collaborator-editor .dtable-ui-collaborator-editor-container-no-btn .collaborators-container .collaborator-item {
69
+ margin: 2px 10px 2px 0;
70
+ }
@@ -9,7 +9,7 @@ import './index.css';
9
9
  class CollaboratorEditor extends React.Component {
10
10
  constructor(props) {
11
11
  super(props);
12
- this.onDocumentToggle = e => {
12
+ this.onMouseDown = e => {
13
13
  if (this.editorContainer !== e.target && !this.editorContainer.contains(e.target)) {
14
14
  this.onClosePopover();
15
15
  }
@@ -28,7 +28,7 @@ class CollaboratorEditor extends React.Component {
28
28
  }
29
29
  return [];
30
30
  };
31
- this.onAddOptionToggle = event => {
31
+ this.togglePopover = event => {
32
32
  event.nativeEvent.stopImmediatePropagation();
33
33
  event.stopPropagation();
34
34
  if (this.props.isReadOnly) {
@@ -67,7 +67,6 @@ class CollaboratorEditor extends React.Component {
67
67
  newValue
68
68
  }, () => {
69
69
  this.onCommit(newValue);
70
- this.onClosePopover();
71
70
  });
72
71
  };
73
72
  this.onDeleteCollaborator = collaborator => {
@@ -108,6 +107,15 @@ class CollaboratorEditor extends React.Component {
108
107
  isPopoverShow: false
109
108
  });
110
109
  };
110
+ this.onClickContainer = e => {
111
+ e.stopPropagation();
112
+ if (!this.props.isShowEditButton && !this.state.isPopoverShow) {
113
+ this.setState({
114
+ isPopoverShow: true,
115
+ popoverPosition: this.caculatePopoverPosition()
116
+ });
117
+ }
118
+ };
111
119
  this.setEditorContainerRef = editorContainer => {
112
120
  this.editorContainer = editorContainer;
113
121
  };
@@ -121,15 +129,16 @@ class CollaboratorEditor extends React.Component {
121
129
  };
122
130
  }
123
131
  componentDidMount() {
124
- document.addEventListener('click', this.onDocumentToggle);
132
+ document.addEventListener('mousedown', this.onMouseDown);
125
133
  }
126
134
  componentWillUnmount() {
127
- document.removeEventListener('click', this.onDocumentToggle);
135
+ document.removeEventListener('mousedown', this.onMouseDown);
128
136
  }
129
137
  render() {
130
138
  let {
131
139
  collaborators,
132
- isReadOnly
140
+ isReadOnly,
141
+ isShowEditButton
133
142
  } = this.props;
134
143
  let {
135
144
  isPopoverShow,
@@ -142,12 +151,13 @@ class CollaboratorEditor extends React.Component {
142
151
  className: "dtable-ui-collaborator-editor"
143
152
  }, /*#__PURE__*/React.createElement("div", {
144
153
  ref: this.setEditorRef,
145
- className: "dtable-ui-collaborator-editor-container"
146
- }, /*#__PURE__*/React.createElement(EditEditorButton, {
154
+ className: "dtable-ui-collaborator-editor-container ".concat(isShowEditButton ? '' : 'dtable-ui-collaborator-editor-container-no-btn'),
155
+ onClick: this.onClickContainer
156
+ }, isShowEditButton && /*#__PURE__*/React.createElement(EditEditorButton, {
147
157
  text: getLocale('Add_a_collaborator'),
148
- onClick: this.onAddOptionToggle
158
+ onClick: this.togglePopover
149
159
  }), selectedCollaborators.length > 0 && /*#__PURE__*/React.createElement("div", {
150
- className: "collaborators-container mt-2"
160
+ className: "collaborators-container ".concat(isShowEditButton ? 'mt-2' : '')
151
161
  }, selectedCollaborators.map(collaborator => {
152
162
  return /*#__PURE__*/React.createElement(CollaboratorItem, {
153
163
  key: collaborator.email,
@@ -176,6 +186,7 @@ class CollaboratorEditor extends React.Component {
176
186
  }
177
187
  }
178
188
  CollaboratorEditor.defaultProps = {
189
+ isShowEditButton: true,
179
190
  isReadOnly: false,
180
191
  value: []
181
192
  };
@@ -33,6 +33,10 @@ class PCCollaboratorEditorPopover extends React.Component {
33
33
  this.state = {
34
34
  searchValue: ''
35
35
  };
36
+ this.editorInputRef = React.createRef();
37
+ }
38
+ componentDidMount() {
39
+ this.editorInputRef.current.focus();
36
40
  }
37
41
  render() {
38
42
  let {
@@ -58,7 +62,8 @@ class PCCollaboratorEditorPopover extends React.Component {
58
62
  value: searchValue,
59
63
  onChange: this.onValueChanged,
60
64
  onClick: this.onInputClick,
61
- placeholder: getLocale('Find_a_collaborator')
65
+ placeholder: getLocale('Find_a_collaborator'),
66
+ ref: this.editorInputRef
62
67
  })), /*#__PURE__*/React.createElement("div", {
63
68
  className: "collaborator-list-container"
64
69
  }, collaborators.length > 0 && collaborators.map((collaborator, index) => {
@@ -4,6 +4,8 @@ import dayjs from 'dayjs';
4
4
  import { getDateDisplayString } from 'dtable-utils';
5
5
  import PCDateEditorPopover from './pc-date-editor-popover';
6
6
  import MBDateEditorPopover from './mb-date-editor-popover';
7
+ import 'dayjs/locale/zh-cn';
8
+ import 'dayjs/locale/en-gb';
7
9
  import './index.css';
8
10
  class DateEditor extends React.Component {
9
11
  constructor(props) {
@@ -33,6 +35,9 @@ class DateEditor extends React.Component {
33
35
  newValue: value
34
36
  });
35
37
  this.onCommit(value);
38
+ if (!this.state.showHourAndMinute) {
39
+ this.onClosePopover();
40
+ }
36
41
  }
37
42
  };
38
43
  this.onCommit = newValue => {
@@ -11,7 +11,7 @@ import './index.css';
11
11
  class LinkEditor extends React.Component {
12
12
  constructor(props) {
13
13
  super(props);
14
- this.onDocumentToggle = e => {
14
+ this.onMouseDown = e => {
15
15
  if (this.editorContainer !== e.target && !this.editorContainer.contains(e.target)) {
16
16
  this.onClosePopover();
17
17
  }
@@ -197,10 +197,10 @@ class LinkEditor extends React.Component {
197
197
  };
198
198
  }
199
199
  componentDidMount() {
200
- document.addEventListener('click', this.onDocumentToggle);
200
+ document.addEventListener('mousedown', this.onMouseDown);
201
201
  }
202
202
  componentWillUnmount() {
203
- document.removeEventListener('click', this.onDocumentToggle);
203
+ document.removeEventListener('mousedown', this.onMouseDown);
204
204
  }
205
205
  render() {
206
206
  let {
@@ -15,7 +15,7 @@ class MTimeFormatter extends React.Component {
15
15
  containerClassName
16
16
  } = this.props;
17
17
  let classname = classnames('dtable-ui cell-formatter-container ctime-formatter', containerClassName);
18
- if (date !== '') {
18
+ if (date) {
19
19
  date = this.formatDate(date);
20
20
  }
21
21
  return /*#__PURE__*/React.createElement("div", {
@@ -7,7 +7,7 @@ import './index.css';
7
7
  class MultipleSelectEditor extends React.Component {
8
8
  constructor(props) {
9
9
  super(props);
10
- this.onDocumentToggle = e => {
10
+ this.onMouseDown = e => {
11
11
  if (this.editorContainer !== e.target && !this.editorContainer.contains(e.target)) {
12
12
  this.onClosePopover();
13
13
  }
@@ -121,10 +121,10 @@ class MultipleSelectEditor extends React.Component {
121
121
  this.options = _column.data && (_column.data.options || []);
122
122
  }
123
123
  componentDidMount() {
124
- document.addEventListener('click', this.onDocumentToggle);
124
+ document.addEventListener('mousedown', this.onMouseDown);
125
125
  }
126
126
  componentWillUnmount() {
127
- document.removeEventListener('click', this.onDocumentToggle);
127
+ document.removeEventListener('mousedown', this.onMouseDown);
128
128
  }
129
129
  render() {
130
130
  let {
@@ -4,9 +4,9 @@ import './index.css';
4
4
  export default class NotificationPopover extends React.Component {
5
5
  constructor() {
6
6
  super(...arguments);
7
- this.handleOutsideClick = e => {
7
+ this.onMouseDown = e => {
8
8
  if (!this.notificationContainerRef.contains(e.target)) {
9
- document.removeEventListener('mousedown', this.handleOutsideClick);
9
+ document.removeEventListener('mousedown', this.onMouseDown);
10
10
  if (e.target.className === 'tool notification' || e.target.parentNode.className === 'tool notification') {
11
11
  return;
12
12
  }
@@ -28,10 +28,10 @@ export default class NotificationPopover extends React.Component {
28
28
  };
29
29
  }
30
30
  componentDidMount() {
31
- document.addEventListener('mousedown', this.handleOutsideClick);
31
+ document.addEventListener('mousedown', this.onMouseDown);
32
32
  }
33
33
  componentWillUnmount() {
34
- document.removeEventListener('mousedown', this.handleOutsideClick);
34
+ document.removeEventListener('mousedown', this.onMouseDown);
35
35
  }
36
36
  render() {
37
37
  const {
@@ -7,7 +7,7 @@ import './index.css';
7
7
  class SingleSelectEditor extends React.Component {
8
8
  constructor(props) {
9
9
  super(props);
10
- this.onDocumentToggle = e => {
10
+ this.onMouseDown = e => {
11
11
  if (this.editorContainer !== e.target && !this.editorContainer.contains(e.target)) {
12
12
  this.onClosePopover();
13
13
  }
@@ -102,10 +102,10 @@ class SingleSelectEditor extends React.Component {
102
102
  this.options = _column.data && (_column.data.options || []);
103
103
  }
104
104
  componentDidMount() {
105
- document.addEventListener('click', this.onDocumentToggle);
105
+ document.addEventListener('mousedown', this.onMouseDown);
106
106
  }
107
107
  componentWillUnmount() {
108
- document.removeEventListener('click', this.onDocumentToggle);
108
+ document.removeEventListener('mousedown', this.onMouseDown);
109
109
  }
110
110
  render() {
111
111
  let {
@@ -8,7 +8,7 @@ export default class ClickOutside extends React.Component {
8
8
  this.isClickedInside = false;
9
9
  return;
10
10
  }
11
- this.props.onClickOutside(e);
11
+ this.props.onClickOutside && this.props.onClickOutside(e);
12
12
  };
13
13
  this.handleMouseDown = () => {
14
14
  this.isClickedInside = true;
@@ -5,17 +5,17 @@ import './delete-tip.css';
5
5
  export default class DeleteTip extends React.Component {
6
6
  constructor() {
7
7
  super(...arguments);
8
- this.handleOutsideClick = e => {
8
+ this.onMouseDown = e => {
9
9
  if (this.tipContainer && !this.tipContainer.contains(e.target)) {
10
10
  this.props.toggle();
11
11
  }
12
12
  };
13
13
  }
14
14
  componentDidMount() {
15
- document.addEventListener('click', this.handleOutsideClick);
15
+ document.addEventListener('mousedown', this.onMouseDown);
16
16
  }
17
17
  componentWillUnmount() {
18
- document.removeEventListener('click', this.handleOutsideClick);
18
+ document.removeEventListener('mousedown', this.onMouseDown);
19
19
  }
20
20
  render() {
21
21
  const {
@@ -1,7 +1,7 @@
1
1
  .dtable-toast-manager {
2
2
  position: fixed;
3
3
  margin: 0 auto;
4
- max-width: 560;
4
+ max-width: 560px;
5
5
  top: 0;
6
6
  left: 0;
7
7
  right: 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "4.3.10",
3
+ "version": "4.3.11-alpha1",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "2.0.5",