dtable-ui-component 4.3.7 → 4.3.8
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.
- package/lib/AutoNumberFormatter/index.js +11 -24
- package/lib/ButtonFormatter/index.js +29 -45
- package/lib/CTimeFormatter/index.js +17 -32
- package/lib/CheckboxEditor/index.js +42 -49
- package/lib/CheckboxFormatter/index.js +17 -30
- package/lib/CollaboratorEditor/index.js +118 -135
- package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.js +90 -99
- package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +61 -69
- package/lib/CollaboratorFormatter/index.js +26 -42
- package/lib/CollaboratorItem/index.js +31 -44
- package/lib/CreatorFormatter/index.js +24 -40
- package/lib/DTableCustomizeCollaboratorSelect/index.js +80 -99
- package/lib/DTableCustomizeCollaboratorSelect/utils.js +12 -13
- package/lib/DTableCustomizeSelect/index.js +92 -103
- package/lib/DTablePopover/index.js +52 -71
- package/lib/DTablePopover/utils.js +1 -1
- package/lib/DTableRadio/index.js +9 -7
- package/lib/DTableSearchInput/index.js +89 -99
- package/lib/DTableSearchInput/utils.js +2 -2
- package/lib/DTableSelect/dtable-select-label.js +5 -3
- package/lib/DTableSelect/index.js +50 -64
- package/lib/DTableSelect/utils.js +36 -41
- package/lib/DTableSwitch/index.js +7 -5
- package/lib/DateEditor/index.js +88 -94
- package/lib/DateEditor/mb-date-editor-popover/index.js +136 -134
- package/lib/DateEditor/pc-date-editor-popover.js +70 -77
- package/lib/DateFormatter/index.js +15 -28
- package/lib/DepartmentSingleSelectFormatter/index.js +9 -9
- package/lib/DigitalSignFormatter/index.js +55 -65
- package/lib/DigitalSignFormatter/utils.js +9 -8
- package/lib/DurationFormatter/index.js +14 -27
- package/lib/EditEditorButton/index.js +10 -22
- package/lib/EmailFormatter/index.js +11 -24
- package/lib/FieldDisplaySetting/field-item.js +18 -20
- package/lib/FieldDisplaySetting/index.js +41 -43
- package/lib/FileEditor/index.js +18 -29
- package/lib/FileFormatter/index.js +29 -43
- package/lib/FileItemFormatter/index.js +17 -32
- package/lib/FileItemFormatter/utils.js +5 -5
- package/lib/FileUploader/index.js +20 -33
- package/lib/FormulaFormatter/cell-value-validator.js +23 -8
- package/lib/FormulaFormatter/index.js +77 -83
- package/lib/FormulaFormatter/utils.js +27 -21
- package/lib/GeolocationFormatter/index.js +19 -32
- package/lib/HtmlLongTextFormatter/index.js +43 -52
- package/lib/HtmlLongTextFormatter/markdown2html.js +2 -2
- package/lib/HtmlLongTextFormatter/unified/index.js +1 -1
- package/lib/HtmlLongTextFormatter/vfile/core.js +10 -10
- package/lib/ImageFormatter/images-lazy-load.js +71 -79
- package/lib/ImageFormatter/index.js +86 -97
- package/lib/ImageFormatter/utils.js +1 -1
- package/lib/ImagePreviewerLightbox/index.js +20 -18
- package/lib/ImagePreviewerLightbox/utils.js +3 -3
- package/lib/LastModifierFormatter/index.js +24 -40
- package/lib/LinkEditor/index.js +163 -167
- package/lib/LinkEditor/link-editor-option.js +41 -56
- package/lib/LinkEditor/mb-link-editor-popover/index.js +90 -99
- package/lib/LinkEditor/pc-link-editor-popover/index.js +63 -71
- package/lib/LinkFormatter/index.js +75 -77
- package/lib/LongTextFormatter/index.js +5 -3
- package/lib/MBEditorHeader/index.js +25 -38
- package/lib/MTimeFormatter/index.js +17 -32
- package/lib/ModalPortal/index.js +15 -32
- package/lib/MultipleSelectEditor/index.js +118 -136
- package/lib/MultipleSelectFormatter/index.js +24 -40
- package/lib/NotificationPopover/index.js +68 -95
- package/lib/NumberEditor/index.js +75 -82
- package/lib/NumberFormatter/index.js +15 -28
- package/lib/RateFormatter/index.js +29 -45
- package/lib/RoleStatusEditor/index.js +20 -22
- package/lib/RowExpandEmailFormatter/index.js +24 -37
- package/lib/RowExpandFileFormatter/index.js +28 -42
- package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +66 -82
- package/lib/RowExpandFormatter/index.js +92 -96
- package/lib/RowExpandFormulaFormatter/index.js +85 -91
- package/lib/RowExpandImageFormatter/index.js +65 -82
- package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +71 -84
- package/lib/RowExpandImageFormatter/utils.js +1 -1
- package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +54 -68
- package/lib/RowExpandLinkFormatter/index.js +131 -137
- package/lib/RowExpandLinkFormatter/utils.js +23 -17
- package/lib/RowExpandLinkFormatter/value-display-utils.js +9 -7
- package/lib/RowExpandRateFormatter/index.js +27 -42
- package/lib/RowExpandUrlFormatter/index.js +27 -40
- package/lib/SelectItem/index.js +17 -33
- package/lib/SelectOptionGroup/index.js +141 -159
- package/lib/SelectOptionGroup/option.js +24 -40
- package/lib/SimpleLongTextFormatter/index.js +55 -67
- package/lib/SimpleLongTextFormatter/normalize-long-text-value.js +23 -22
- package/lib/SimpleLongTextFormatter/widgets/LongTextPreview.js +42 -57
- package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +31 -46
- package/lib/SingleSelectEditor/index.js +108 -119
- package/lib/SingleSelectFormatter/index.js +21 -37
- package/lib/TextEditor/index.js +45 -51
- package/lib/TextFormatter/index.js +17 -32
- package/lib/UrlFormatter/index.js +11 -24
- package/lib/cellFormatterFactory/index.js +8 -17
- package/lib/common/ClickOutside.js +22 -43
- package/lib/common/delete-tip.js +40 -65
- package/lib/common/modal-portal.js +15 -33
- package/lib/constants/index.js +5 -5
- package/lib/data/dtable-value.js +4 -4
- package/lib/formatterConfig/base-formatter-config.js +24 -3
- package/lib/formatterConfig/index.js +5 -4
- package/lib/lang/index.js +6 -6
- package/lib/locals/de.js +1 -1
- package/lib/locals/en.js +1 -1
- package/lib/locals/fr.js +1 -1
- package/lib/locals/zh-CN.js +1 -1
- package/lib/select-editor/mb-select-editor-popover/index.js +126 -137
- package/lib/select-editor/pc-select-editor-popover/index.js +75 -83
- package/lib/select-editor/select-editor-option.js +41 -56
- package/lib/toaster/alert.js +73 -88
- package/lib/toaster/index.js +1 -1
- package/lib/toaster/toast.js +75 -102
- package/lib/toaster/toastManager.js +55 -91
- package/lib/toaster/toaster.js +58 -57
- package/lib/utils/editor-utils.js +17 -19
- package/lib/utils/utils.js +14 -14
- package/package.json +4 -4
|
@@ -1,57 +1,44 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
1
|
import React from 'react';
|
|
6
2
|
import classnames from 'classnames';
|
|
7
3
|
import toaster from '../toaster';
|
|
8
4
|
import { isValidUrl, getTrimmedString } from '../utils/editor-utils';
|
|
9
5
|
import './index.css';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
20
|
-
_this.onOpenUrlLink = function () {
|
|
21
|
-
var value = _this.props.value;
|
|
22
|
-
var url = getTrimmedString(value);
|
|
23
|
-
var validUrl = isValidUrl(url) ? url : "http://".concat(url);
|
|
6
|
+
class UrlFormatter extends React.Component {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.onOpenUrlLink = () => {
|
|
10
|
+
const {
|
|
11
|
+
value
|
|
12
|
+
} = this.props;
|
|
13
|
+
const url = getTrimmedString(value);
|
|
14
|
+
const validUrl = isValidUrl(url) ? url : "http://".concat(url);
|
|
24
15
|
try {
|
|
25
|
-
|
|
16
|
+
let a = document.createElement('a');
|
|
26
17
|
document.body.appendChild(a);
|
|
27
18
|
a.href = validUrl;
|
|
28
19
|
a.target = '_blank';
|
|
29
20
|
a.rel = 'noopener noreferrer';
|
|
30
21
|
a.click();
|
|
31
22
|
document.body.removeChild(a);
|
|
32
|
-
} catch
|
|
23
|
+
} catch {
|
|
33
24
|
toaster.danger('The url is invalid');
|
|
34
25
|
}
|
|
35
26
|
};
|
|
36
|
-
return _this;
|
|
37
27
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}]);
|
|
55
|
-
return UrlFormatter;
|
|
56
|
-
}(React.Component);
|
|
28
|
+
render() {
|
|
29
|
+
const {
|
|
30
|
+
containerClassName,
|
|
31
|
+
value
|
|
32
|
+
} = this.props;
|
|
33
|
+
let classname = classnames('dtable-ui cell-formatter-container url-formatter', containerClassName);
|
|
34
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
35
|
+
className: classname
|
|
36
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
37
|
+
className: "url-formatter-value text-truncate"
|
|
38
|
+
}, value), getTrimmedString(value) && /*#__PURE__*/React.createElement("span", {
|
|
39
|
+
className: "dtable-font dtable-icon-url row-expand-jump-link",
|
|
40
|
+
onClick: this.onOpenUrlLink
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
57
44
|
export default UrlFormatter;
|
package/lib/SelectItem/index.js
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
1
|
import React from 'react';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _this;
|
|
11
|
-
_classCallCheck(this, SelectItem);
|
|
12
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
13
|
-
args[_key] = arguments[_key];
|
|
14
|
-
}
|
|
15
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
16
|
-
_this.getStyle = function (option, fontSize) {
|
|
2
|
+
export default class SelectItem extends React.PureComponent {
|
|
3
|
+
constructor() {
|
|
4
|
+
super(...arguments);
|
|
5
|
+
this.getStyle = (option, fontSize) => {
|
|
17
6
|
return {
|
|
18
7
|
display: 'inline-block',
|
|
19
8
|
padding: '0px 10px',
|
|
@@ -28,22 +17,17 @@ var SelectItem = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
28
17
|
color: option.textColor || null
|
|
29
18
|
};
|
|
30
19
|
};
|
|
31
|
-
return _this;
|
|
32
20
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}]);
|
|
47
|
-
return SelectItem;
|
|
48
|
-
}(React.PureComponent);
|
|
49
|
-
export { SelectItem as default };
|
|
21
|
+
render() {
|
|
22
|
+
let {
|
|
23
|
+
option,
|
|
24
|
+
fontSize
|
|
25
|
+
} = this.props;
|
|
26
|
+
const style = this.getStyle(option, fontSize);
|
|
27
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
28
|
+
className: "dtable-ui select-item text-truncate",
|
|
29
|
+
style: style,
|
|
30
|
+
title: option.name
|
|
31
|
+
}, option.name);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,126 +1,122 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
1
|
import React, { Component } from 'react';
|
|
6
2
|
import Option from './option';
|
|
7
3
|
import DTableSearchInput from '../DTableSearchInput';
|
|
8
4
|
import KeyCodes from './KeyCodes';
|
|
9
5
|
import ClickOutside from '../common/ClickOutside';
|
|
10
6
|
import './index.css';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
top = _this$optionGroupRef$.top,
|
|
25
|
-
height = _this$optionGroupRef$.height;
|
|
7
|
+
const OPTION_HEIGHT = 32;
|
|
8
|
+
class SelectOptionGroup extends Component {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
this.resetMenuStyle = () => {
|
|
12
|
+
const {
|
|
13
|
+
isInModal,
|
|
14
|
+
position
|
|
15
|
+
} = this.props;
|
|
16
|
+
const {
|
|
17
|
+
top,
|
|
18
|
+
height
|
|
19
|
+
} = this.optionGroupRef.getBoundingClientRect();
|
|
26
20
|
if (isInModal) {
|
|
27
21
|
if (position.y + position.height + height > window.innerHeight) {
|
|
28
|
-
|
|
22
|
+
this.optionGroupRef.style.top = position.y - height + 'px';
|
|
29
23
|
}
|
|
30
|
-
|
|
24
|
+
this.optionGroupRef.style.opacity = 1;
|
|
31
25
|
} else {
|
|
32
26
|
if (height + top > window.innerHeight) {
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
const borderWidth = 2;
|
|
28
|
+
this.optionGroupRef.style.top = -1 * (height + borderWidth) + 'px';
|
|
35
29
|
}
|
|
36
30
|
}
|
|
37
31
|
};
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
this.onHotKey = event => {
|
|
33
|
+
const keyCode = event.keyCode;
|
|
40
34
|
if (keyCode === KeyCodes.UpArrow) {
|
|
41
|
-
|
|
35
|
+
this.onPressUp();
|
|
42
36
|
} else if (keyCode === KeyCodes.DownArrow) {
|
|
43
|
-
|
|
37
|
+
this.onPressDown();
|
|
44
38
|
} else if (keyCode === KeyCodes.Enter) {
|
|
45
|
-
|
|
39
|
+
let option = this.filterOptions && this.filterOptions[this.state.activeIndex];
|
|
46
40
|
if (option) {
|
|
47
|
-
|
|
48
|
-
if (!
|
|
49
|
-
|
|
41
|
+
this.props.onSelectOption(option.value);
|
|
42
|
+
if (!this.props.supportMultipleSelect) {
|
|
43
|
+
this.props.closeSelect();
|
|
50
44
|
}
|
|
51
45
|
}
|
|
52
46
|
} else if (keyCode === KeyCodes.Tab || keyCode === KeyCodes.Escape) {
|
|
53
|
-
|
|
47
|
+
this.props.closeSelect();
|
|
54
48
|
}
|
|
55
49
|
};
|
|
56
|
-
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
activeIndex:
|
|
60
|
-
},
|
|
61
|
-
|
|
50
|
+
this.onPressUp = () => {
|
|
51
|
+
if (this.state.activeIndex > 0) {
|
|
52
|
+
this.setState({
|
|
53
|
+
activeIndex: this.state.activeIndex - 1
|
|
54
|
+
}, () => {
|
|
55
|
+
this.scrollContent();
|
|
62
56
|
});
|
|
63
57
|
}
|
|
64
58
|
};
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
activeIndex:
|
|
69
|
-
},
|
|
70
|
-
|
|
59
|
+
this.onPressDown = () => {
|
|
60
|
+
if (this.filterOptions && this.state.activeIndex < this.filterOptions.length - 1) {
|
|
61
|
+
this.setState({
|
|
62
|
+
activeIndex: this.state.activeIndex + 1
|
|
63
|
+
}, () => {
|
|
64
|
+
this.scrollContent();
|
|
71
65
|
});
|
|
72
66
|
}
|
|
73
67
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
offsetHeight
|
|
77
|
-
scrollTop
|
|
78
|
-
|
|
68
|
+
this.scrollContent = () => {
|
|
69
|
+
const {
|
|
70
|
+
offsetHeight,
|
|
71
|
+
scrollTop
|
|
72
|
+
} = this.optionGroupContentRef;
|
|
73
|
+
this.setState({
|
|
79
74
|
disableHover: true
|
|
80
75
|
});
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
this.timer = setTimeout(() => {
|
|
77
|
+
this.setState({
|
|
83
78
|
disableHover: false
|
|
84
79
|
});
|
|
85
80
|
}, 500);
|
|
86
|
-
if (
|
|
87
|
-
|
|
81
|
+
if (this.state.activeIndex * OPTION_HEIGHT === 0) {
|
|
82
|
+
this.optionGroupContentRef.scrollTop = 0;
|
|
88
83
|
return;
|
|
89
84
|
}
|
|
90
|
-
if (
|
|
91
|
-
|
|
92
|
-
} else if (
|
|
93
|
-
|
|
85
|
+
if (this.state.activeIndex * OPTION_HEIGHT < scrollTop) {
|
|
86
|
+
this.optionGroupContentRef.scrollTop = scrollTop - OPTION_HEIGHT;
|
|
87
|
+
} else if (this.state.activeIndex * OPTION_HEIGHT > offsetHeight + scrollTop) {
|
|
88
|
+
this.optionGroupContentRef.scrollTop = scrollTop + OPTION_HEIGHT;
|
|
94
89
|
}
|
|
95
90
|
};
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
this.changeIndex = index => {
|
|
92
|
+
this.setState({
|
|
98
93
|
activeIndex: index
|
|
99
94
|
});
|
|
100
95
|
};
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (value !==
|
|
104
|
-
|
|
96
|
+
this.onChangeSearch = searchVal => {
|
|
97
|
+
let value = searchVal || '';
|
|
98
|
+
if (value !== this.state.searchVal) {
|
|
99
|
+
this.setState({
|
|
105
100
|
searchVal: value,
|
|
106
101
|
activeIndex: -1
|
|
107
102
|
});
|
|
108
103
|
}
|
|
109
104
|
};
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
noOptionsPlaceholder
|
|
113
|
-
onSelectOption
|
|
114
|
-
isInModal
|
|
115
|
-
|
|
116
|
-
|
|
105
|
+
this.renderOptGroup = searchVal => {
|
|
106
|
+
let {
|
|
107
|
+
noOptionsPlaceholder,
|
|
108
|
+
onSelectOption,
|
|
109
|
+
isInModal
|
|
110
|
+
} = this.props;
|
|
111
|
+
this.filterOptions = this.props.getFilterOptions(searchVal);
|
|
112
|
+
if (this.filterOptions.length === 0) {
|
|
117
113
|
return /*#__PURE__*/React.createElement("div", {
|
|
118
114
|
className: "none-search-result"
|
|
119
115
|
}, noOptionsPlaceholder);
|
|
120
116
|
}
|
|
121
|
-
return
|
|
122
|
-
|
|
123
|
-
|
|
117
|
+
return this.filterOptions.map((opt, i) => {
|
|
118
|
+
let key = opt.value.column ? opt.value.column.key : i;
|
|
119
|
+
let isActive = this.state.activeIndex === i;
|
|
124
120
|
return /*#__PURE__*/React.createElement(Option, {
|
|
125
121
|
key: key,
|
|
126
122
|
index: i,
|
|
@@ -128,101 +124,87 @@ var SelectOptionGroup = /*#__PURE__*/function (_Component) {
|
|
|
128
124
|
isInModal: isInModal,
|
|
129
125
|
value: opt.value,
|
|
130
126
|
onSelectOption: onSelectOption,
|
|
131
|
-
changeIndex:
|
|
132
|
-
supportMultipleSelect:
|
|
133
|
-
disableHover:
|
|
127
|
+
changeIndex: this.changeIndex,
|
|
128
|
+
supportMultipleSelect: this.props.supportMultipleSelect,
|
|
129
|
+
disableHover: this.state.disableHover
|
|
134
130
|
}, opt.label);
|
|
135
131
|
});
|
|
136
132
|
};
|
|
137
|
-
|
|
133
|
+
this.state = {
|
|
138
134
|
searchVal: '',
|
|
139
135
|
activeIndex: -1,
|
|
140
136
|
disableHover: false
|
|
141
137
|
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return _this;
|
|
138
|
+
this.filterOptions = null;
|
|
139
|
+
this.timer = null;
|
|
145
140
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
141
|
+
componentDidMount() {
|
|
142
|
+
window.addEventListener('keydown', this.onHotKey);
|
|
143
|
+
setTimeout(() => {
|
|
144
|
+
this.resetMenuStyle();
|
|
145
|
+
}, 1);
|
|
146
|
+
}
|
|
147
|
+
componentWillUnmount() {
|
|
148
|
+
this.filterOptions = null;
|
|
149
|
+
this.timer && clearTimeout(this.timer);
|
|
150
|
+
window.removeEventListener('keydown', this.onHotKey);
|
|
151
|
+
}
|
|
152
|
+
render() {
|
|
153
|
+
const {
|
|
154
|
+
searchable,
|
|
155
|
+
searchPlaceholder,
|
|
156
|
+
top,
|
|
157
|
+
left,
|
|
158
|
+
minWidth,
|
|
159
|
+
value,
|
|
160
|
+
isShowSelected,
|
|
161
|
+
isInModal,
|
|
162
|
+
position,
|
|
163
|
+
className
|
|
164
|
+
} = this.props;
|
|
165
|
+
let {
|
|
166
|
+
searchVal
|
|
167
|
+
} = this.state;
|
|
168
|
+
let style = {
|
|
169
|
+
top: top || 0,
|
|
170
|
+
left: left || 0
|
|
171
|
+
};
|
|
172
|
+
if (minWidth) {
|
|
173
|
+
style = {
|
|
179
174
|
top: top || 0,
|
|
180
|
-
left: left || 0
|
|
175
|
+
left: left || 0,
|
|
176
|
+
minWidth
|
|
181
177
|
};
|
|
182
|
-
if (minWidth) {
|
|
183
|
-
style = {
|
|
184
|
-
top: top || 0,
|
|
185
|
-
left: left || 0,
|
|
186
|
-
minWidth: minWidth
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
if (isInModal) {
|
|
190
|
-
style = {
|
|
191
|
-
position: 'fixed',
|
|
192
|
-
left: position.x,
|
|
193
|
-
top: position.y + position.height,
|
|
194
|
-
minWidth: position.width,
|
|
195
|
-
opacity: 0
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
return /*#__PURE__*/React.createElement(ClickOutside, {
|
|
199
|
-
onClickOutside: this.props.onClickOutside
|
|
200
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
201
|
-
className: "option-group ".concat(isShowSelected ? 'pt-0' : '', " ").concat(className ? 'option-group-' + className : ''),
|
|
202
|
-
ref: function ref(_ref2) {
|
|
203
|
-
return _this3.optionGroupRef = _ref2;
|
|
204
|
-
},
|
|
205
|
-
style: style
|
|
206
|
-
}, isShowSelected && /*#__PURE__*/React.createElement("div", {
|
|
207
|
-
className: "editor-list-delete mb-2",
|
|
208
|
-
onClick: function onClick(e) {
|
|
209
|
-
return e.stopPropagation();
|
|
210
|
-
}
|
|
211
|
-
}, value.label || ''), searchable && /*#__PURE__*/React.createElement("div", {
|
|
212
|
-
className: "option-group-search"
|
|
213
|
-
}, /*#__PURE__*/React.createElement(DTableSearchInput, {
|
|
214
|
-
className: "option-search-control",
|
|
215
|
-
placeholder: searchPlaceholder,
|
|
216
|
-
onChange: this.onChangeSearch,
|
|
217
|
-
autoFocus: true
|
|
218
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
219
|
-
className: "option-group-content",
|
|
220
|
-
ref: function ref(_ref) {
|
|
221
|
-
return _this3.optionGroupContentRef = _ref;
|
|
222
|
-
}
|
|
223
|
-
}, this.renderOptGroup(searchVal))));
|
|
224
178
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
179
|
+
if (isInModal) {
|
|
180
|
+
style = {
|
|
181
|
+
position: 'fixed',
|
|
182
|
+
left: position.x,
|
|
183
|
+
top: position.y + position.height,
|
|
184
|
+
minWidth: position.width,
|
|
185
|
+
opacity: 0
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
return /*#__PURE__*/React.createElement(ClickOutside, {
|
|
189
|
+
onClickOutside: this.props.onClickOutside
|
|
190
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
191
|
+
className: "option-group ".concat(isShowSelected ? 'pt-0' : '', " ").concat(className ? 'option-group-' + className : ''),
|
|
192
|
+
ref: ref => this.optionGroupRef = ref,
|
|
193
|
+
style: style
|
|
194
|
+
}, isShowSelected && /*#__PURE__*/React.createElement("div", {
|
|
195
|
+
className: "editor-list-delete mb-2",
|
|
196
|
+
onClick: e => e.stopPropagation()
|
|
197
|
+
}, value.label || ''), searchable && /*#__PURE__*/React.createElement("div", {
|
|
198
|
+
className: "option-group-search"
|
|
199
|
+
}, /*#__PURE__*/React.createElement(DTableSearchInput, {
|
|
200
|
+
className: "option-search-control",
|
|
201
|
+
placeholder: searchPlaceholder,
|
|
202
|
+
onChange: this.onChangeSearch,
|
|
203
|
+
autoFocus: true
|
|
204
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
205
|
+
className: "option-group-content",
|
|
206
|
+
ref: ref => this.optionGroupContentRef = ref
|
|
207
|
+
}, this.renderOptGroup(searchVal))));
|
|
208
|
+
}
|
|
209
|
+
}
|
|
228
210
|
export default SelectOptionGroup;
|
|
@@ -1,55 +1,39 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
1
|
import React, { Component } from 'react';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
_classCallCheck(this, Option);
|
|
12
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
13
|
-
args[_key] = arguments[_key];
|
|
14
|
-
}
|
|
15
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
16
|
-
_this.onSelectOption = function (value, event) {
|
|
17
|
-
if (_this.props.supportMultipleSelect) {
|
|
2
|
+
class Option extends Component {
|
|
3
|
+
constructor() {
|
|
4
|
+
super(...arguments);
|
|
5
|
+
this.onSelectOption = (value, event) => {
|
|
6
|
+
if (this.props.supportMultipleSelect) {
|
|
18
7
|
event.stopPropagation();
|
|
19
8
|
}
|
|
20
|
-
|
|
9
|
+
this.props.onSelectOption(value, event);
|
|
21
10
|
};
|
|
22
|
-
|
|
23
|
-
if (!
|
|
24
|
-
|
|
11
|
+
this.onMouseEnter = () => {
|
|
12
|
+
if (!this.props.disableHover) {
|
|
13
|
+
this.props.changeIndex(this.props.index);
|
|
25
14
|
}
|
|
26
15
|
};
|
|
27
|
-
|
|
28
|
-
if (!
|
|
29
|
-
|
|
16
|
+
this.onMouseLeave = () => {
|
|
17
|
+
if (!this.props.disableHover) {
|
|
18
|
+
this.props.changeIndex(-1);
|
|
30
19
|
}
|
|
31
20
|
};
|
|
32
|
-
|
|
33
|
-
if (
|
|
21
|
+
this.onMouseDown = event => {
|
|
22
|
+
if (this.props.isInModal) {
|
|
34
23
|
// prevent close modal via select option
|
|
35
24
|
event.stopPropagation();
|
|
36
25
|
event.nativeEvent.stopImmediatePropagation();
|
|
37
26
|
}
|
|
38
27
|
};
|
|
39
|
-
return _this;
|
|
40
28
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
}]);
|
|
53
|
-
return Option;
|
|
54
|
-
}(Component);
|
|
29
|
+
render() {
|
|
30
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
31
|
+
className: this.props.isActive ? 'option option-active' : 'option',
|
|
32
|
+
onClick: this.onSelectOption.bind(this, this.props.value),
|
|
33
|
+
onMouseDown: this.onMouseDown,
|
|
34
|
+
onMouseEnter: this.onMouseEnter,
|
|
35
|
+
onMouseLeave: this.onMouseLeave
|
|
36
|
+
}, this.props.children);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
55
39
|
export default Option;
|