dtable-ui-component 4.3.6 → 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.css +22 -59
- package/lib/DTableCustomizeSelect/index.js +99 -95
- 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.css +103 -0
- package/lib/SelectOptionGroup/index.js +157 -135
- package/lib/SelectOptionGroup/option.js +31 -38
- 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 +28 -0
- 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,82 +1,76 @@
|
|
|
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 classnames from 'classnames';
|
|
7
3
|
import { Popover } from 'reactstrap';
|
|
8
4
|
import SelectOptionGroup from '../SelectOptionGroup';
|
|
9
5
|
import { searchCollaborators } from './utils';
|
|
10
6
|
import './index.css';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _this;
|
|
16
|
-
_classCallCheck(this, CollaboratorSelect);
|
|
17
|
-
_this = _super.call(this, props);
|
|
18
|
-
_this.onSelectToggle = function (event) {
|
|
7
|
+
class CollaboratorSelect extends Component {
|
|
8
|
+
constructor(props) {
|
|
9
|
+
super(props);
|
|
10
|
+
this.onSelectToggle = event => {
|
|
19
11
|
event.preventDefault();
|
|
20
12
|
/*
|
|
21
13
|
if select is showing, click events do not need to be monitored by other click events,
|
|
22
14
|
so it can be closed when other select is clicked.
|
|
23
15
|
*/
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
if (
|
|
16
|
+
if (this.state.isShowSelectOptions) event.nativeEvent.stopImmediatePropagation();
|
|
17
|
+
let eventClassName = event.target.className;
|
|
18
|
+
if (this.props.isLocked || eventClassName.indexOf('option-search-control') > -1 || eventClassName === 'option-group-search') return;
|
|
27
19
|
//Prevent closing by pressing the spacebar in the search input
|
|
28
20
|
if (event.target.value === '') return;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
isShowSelectOptions: !
|
|
21
|
+
this.selectedOptionWidth = this.selectedOptionRef.clientWidth;
|
|
22
|
+
this.setState({
|
|
23
|
+
isShowSelectOptions: !this.state.isShowSelectOptions
|
|
32
24
|
});
|
|
33
25
|
};
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
this.onMousedown = event => {
|
|
27
|
+
const name = event.target.className;
|
|
36
28
|
if (name === 'select-placeholder' || name.includes('icon-fork-number')) {
|
|
37
29
|
return;
|
|
38
30
|
}
|
|
39
|
-
if (!
|
|
40
|
-
|
|
31
|
+
if (!this.selector.contains(event.target)) {
|
|
32
|
+
this.closeSelect();
|
|
41
33
|
}
|
|
42
34
|
};
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
this.closeSelect = () => {
|
|
36
|
+
this.setState({
|
|
45
37
|
isShowSelectOptions: false
|
|
46
38
|
});
|
|
47
39
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
options
|
|
51
|
-
searchable
|
|
40
|
+
this.getFilterOptions = searchValue => {
|
|
41
|
+
const {
|
|
42
|
+
options,
|
|
43
|
+
searchable
|
|
44
|
+
} = this.props;
|
|
52
45
|
if (!searchable) return options || [];
|
|
53
46
|
return searchCollaborators(options, searchValue);
|
|
54
47
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
value
|
|
58
|
-
options
|
|
59
|
-
searchable
|
|
60
|
-
searchPlaceholder
|
|
61
|
-
noOptionsPlaceholder
|
|
62
|
-
top
|
|
63
|
-
left
|
|
64
|
-
isUsePopover
|
|
48
|
+
this.renderOptionGroup = () => {
|
|
49
|
+
const {
|
|
50
|
+
value,
|
|
51
|
+
options,
|
|
52
|
+
searchable,
|
|
53
|
+
searchPlaceholder,
|
|
54
|
+
noOptionsPlaceholder,
|
|
55
|
+
top,
|
|
56
|
+
left,
|
|
57
|
+
isUsePopover
|
|
58
|
+
} = this.props;
|
|
65
59
|
if (!isUsePopover) {
|
|
66
60
|
return /*#__PURE__*/React.createElement(SelectOptionGroup, {
|
|
67
61
|
value: value,
|
|
68
62
|
top: top,
|
|
69
63
|
left: left,
|
|
70
|
-
minWidth:
|
|
64
|
+
minWidth: this.btnWidth + 8 // 8px is padding
|
|
71
65
|
,
|
|
72
66
|
options: options,
|
|
73
|
-
onSelectOption:
|
|
67
|
+
onSelectOption: this.props.onSelectOption,
|
|
74
68
|
searchable: searchable,
|
|
75
69
|
searchPlaceholder: searchPlaceholder,
|
|
76
70
|
noOptionsPlaceholder: noOptionsPlaceholder,
|
|
77
|
-
closeSelect:
|
|
78
|
-
getFilterOptions:
|
|
79
|
-
supportMultipleSelect:
|
|
71
|
+
closeSelect: this.closeSelect,
|
|
72
|
+
getFilterOptions: this.getFilterOptions,
|
|
73
|
+
supportMultipleSelect: this.props.supportMultipleSelect,
|
|
80
74
|
stopClickEvent: true,
|
|
81
75
|
isShowSelected: true
|
|
82
76
|
});
|
|
@@ -84,7 +78,7 @@ var CollaboratorSelect = /*#__PURE__*/function (_Component) {
|
|
|
84
78
|
return /*#__PURE__*/React.createElement(Popover, {
|
|
85
79
|
placement: "bottom",
|
|
86
80
|
isOpen: true,
|
|
87
|
-
target:
|
|
81
|
+
target: this.id,
|
|
88
82
|
fade: false,
|
|
89
83
|
hideArrow: true,
|
|
90
84
|
className: "dtable-customize-collaborator-select dtable-select"
|
|
@@ -92,73 +86,60 @@ var CollaboratorSelect = /*#__PURE__*/function (_Component) {
|
|
|
92
86
|
value: value,
|
|
93
87
|
top: top,
|
|
94
88
|
left: left,
|
|
95
|
-
minWidth:
|
|
89
|
+
minWidth: this.btnWidth + 8 // 8px is padding
|
|
96
90
|
,
|
|
97
91
|
options: options,
|
|
98
|
-
onSelectOption:
|
|
92
|
+
onSelectOption: this.props.onSelectOption,
|
|
99
93
|
searchable: searchable,
|
|
100
94
|
searchPlaceholder: searchPlaceholder,
|
|
101
95
|
noOptionsPlaceholder: noOptionsPlaceholder,
|
|
102
|
-
closeSelect:
|
|
103
|
-
getFilterOptions:
|
|
104
|
-
supportMultipleSelect:
|
|
96
|
+
closeSelect: this.closeSelect,
|
|
97
|
+
getFilterOptions: this.getFilterOptions,
|
|
98
|
+
supportMultipleSelect: this.props.supportMultipleSelect,
|
|
105
99
|
stopClickEvent: true,
|
|
106
100
|
isShowSelected: true
|
|
107
101
|
}));
|
|
108
102
|
};
|
|
109
|
-
|
|
103
|
+
this.state = {
|
|
110
104
|
isShowSelectOptions: false
|
|
111
105
|
};
|
|
112
|
-
|
|
113
|
-
return _this;
|
|
106
|
+
this.id = 'collaborator-select-' + Math.trunc(Math.random() * 10000);
|
|
114
107
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
}, value.label ? /*#__PURE__*/React.createElement("span", {
|
|
152
|
-
className: "selected-option-show"
|
|
153
|
-
}, value.label) : /*#__PURE__*/React.createElement("span", {
|
|
154
|
-
className: "select-placeholder"
|
|
155
|
-
}, placeholder), !isLocked && /*#__PURE__*/React.createElement("i", {
|
|
156
|
-
className: "dtable-font dtable-icon-drop-down"
|
|
157
|
-
})), this.state.isShowSelectOptions && this.renderOptionGroup());
|
|
158
|
-
}
|
|
159
|
-
}]);
|
|
160
|
-
return CollaboratorSelect;
|
|
161
|
-
}(Component);
|
|
108
|
+
componentDidMount() {
|
|
109
|
+
document.addEventListener('mousedown', this.onMousedown);
|
|
110
|
+
this.btnWidth = this.selector.clientWidth;
|
|
111
|
+
}
|
|
112
|
+
componentWillUnmount() {
|
|
113
|
+
document.removeEventListener('mousedown', this.onMousedown);
|
|
114
|
+
}
|
|
115
|
+
render() {
|
|
116
|
+
let {
|
|
117
|
+
className,
|
|
118
|
+
value,
|
|
119
|
+
placeholder,
|
|
120
|
+
isLocked
|
|
121
|
+
} = this.props;
|
|
122
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
123
|
+
ref: node => this.selector = node,
|
|
124
|
+
className: classnames('dtable-select custom-select collaborator-select', {
|
|
125
|
+
'focus': this.state.isShowSelectOptions
|
|
126
|
+
}, {
|
|
127
|
+
'disabled': isLocked
|
|
128
|
+
}, className),
|
|
129
|
+
id: this.id,
|
|
130
|
+
onClick: this.onSelectToggle
|
|
131
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
132
|
+
className: "selected-option",
|
|
133
|
+
ref: node => this.selectedOptionRef = node
|
|
134
|
+
}, value.label ? /*#__PURE__*/React.createElement("span", {
|
|
135
|
+
className: "selected-option-show"
|
|
136
|
+
}, value.label) : /*#__PURE__*/React.createElement("span", {
|
|
137
|
+
className: "select-placeholder"
|
|
138
|
+
}, placeholder), !isLocked && /*#__PURE__*/React.createElement("i", {
|
|
139
|
+
className: "dtable-font dtable-icon-drop-down"
|
|
140
|
+
})), this.state.isShowSelectOptions && this.renderOptionGroup());
|
|
141
|
+
}
|
|
142
|
+
}
|
|
162
143
|
CollaboratorSelect.defaultProps = {
|
|
163
144
|
top: -3,
|
|
164
145
|
left: -3
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export const searchCollaborators = (collaborators, searchValue) => {
|
|
2
|
+
const validSearchValue = searchValue ? searchValue.trim().toLowerCase() : '';
|
|
3
|
+
const validCollaborators = Array.isArray(collaborators) && collaborators.length > 0 ? collaborators : [];
|
|
4
4
|
if (!validSearchValue) return validCollaborators;
|
|
5
|
-
return validCollaborators.filter(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
name_pinyin =
|
|
5
|
+
return validCollaborators.filter(collaborator => {
|
|
6
|
+
const {
|
|
7
|
+
name,
|
|
8
|
+
name_pinyin = ''
|
|
9
|
+
} = collaborator;
|
|
9
10
|
if (name.toString().toLowerCase().indexOf(validSearchValue) > -1) return true;
|
|
10
11
|
if (!name_pinyin) return false;
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
const validNamePinyin = name_pinyin.toString().toLowerCase();
|
|
13
|
+
const validSearchPinyinValue = validSearchValue.replace(/ |'/g, '');
|
|
13
14
|
|
|
14
15
|
// complete
|
|
15
16
|
if (validNamePinyin.indexOf(validSearchPinyinValue) > -1) return true;
|
|
16
17
|
if (validNamePinyin.replace(/'/g, '').indexOf(validSearchPinyinValue) > -1) return true;
|
|
17
|
-
|
|
18
|
+
const validNamePinyinList = validNamePinyin.split('\'');
|
|
18
19
|
// acronym
|
|
19
|
-
|
|
20
|
-
return item && item.trim() ? item.trim().slice(0, 1) : '';
|
|
21
|
-
});
|
|
20
|
+
const namePinyinAcronym = validNamePinyinList.map(item => item && item.trim() ? item.trim().slice(0, 1) : '');
|
|
22
21
|
if (namePinyinAcronym.join('').indexOf(validSearchPinyinValue) > -1) return true;
|
|
23
22
|
return false;
|
|
24
23
|
});
|
|
@@ -36,16 +36,12 @@
|
|
|
36
36
|
border-color: rgb(179, 179, 179);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
.dtable-select .select-option-name {
|
|
40
|
-
color: #212529;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
39
|
.dtable-select .dtable-icon-drop-down {
|
|
44
40
|
display: inline-block;
|
|
45
41
|
font-size: 12px;
|
|
46
|
-
color: #
|
|
47
|
-
transform: scale(.8) translateY(2px);
|
|
48
|
-
transition: all .1s;
|
|
42
|
+
color: #999;
|
|
43
|
+
transform: scale(0.8) translateY(2px);
|
|
44
|
+
transition: all 0.1s;
|
|
49
45
|
}
|
|
50
46
|
|
|
51
47
|
.dtable-select .dtable-icon-drop-down:hover {
|
|
@@ -62,67 +58,34 @@
|
|
|
62
58
|
background: #fff;
|
|
63
59
|
}
|
|
64
60
|
|
|
65
|
-
.dtable-select .option-group
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
min-height: 60px;
|
|
69
|
-
max-height: 300px;
|
|
70
|
-
min-width: 100%;
|
|
71
|
-
max-width: 15rem;
|
|
72
|
-
padding: .5rem 0;
|
|
73
|
-
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
|
74
|
-
background: #fff;
|
|
75
|
-
border: 1px solid rgba(0, 40, 100, 0.12);
|
|
76
|
-
border-radius: 3px;
|
|
77
|
-
z-index: 10001;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.dtable-select .option-group .option-group-search {
|
|
81
|
-
width: 100%;
|
|
82
|
-
padding: 0 10px 6px 10px;
|
|
83
|
-
min-width: 170px;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.dtable-select .option-group-search .form-control {
|
|
87
|
-
height: 31px;
|
|
61
|
+
.dtable-select.selector-collaborator .option-group .option-group-content,
|
|
62
|
+
.dtable-select.selector-group .option-group .option-group-content {
|
|
63
|
+
padding: 10px;
|
|
88
64
|
}
|
|
89
65
|
|
|
90
|
-
.dtable-select .option-group .
|
|
91
|
-
|
|
92
|
-
width: 100%;
|
|
93
|
-
padding: 10px;
|
|
94
|
-
opacity: .5;
|
|
66
|
+
.dtable-select.custom-select.selector-collaborator .option-group .option-group-content {
|
|
67
|
+
padding: 10px 0;
|
|
95
68
|
}
|
|
96
69
|
|
|
97
|
-
.dtable-select
|
|
98
|
-
|
|
99
|
-
|
|
70
|
+
.dtable-select.custom-select.selector-collaborator .option {
|
|
71
|
+
padding: 5px 0 5px 10px !important;
|
|
72
|
+
line-height: 20px;
|
|
100
73
|
}
|
|
101
74
|
|
|
102
|
-
.dtable-select .option {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
padding: .25rem 10px;
|
|
107
|
-
clear: both;
|
|
108
|
-
font-weight: 400;
|
|
109
|
-
color: #212529;
|
|
110
|
-
text-align: inherit;
|
|
111
|
-
background-color: transparent;
|
|
112
|
-
border: 0;
|
|
113
|
-
overflow: hidden;
|
|
114
|
-
text-overflow: ellipsis;
|
|
115
|
-
white-space: nowrap;
|
|
75
|
+
.dtable-select.selector-group .option {
|
|
76
|
+
height: 30px;
|
|
77
|
+
display: flex;
|
|
78
|
+
align-items: center;
|
|
116
79
|
}
|
|
117
80
|
|
|
118
|
-
.dtable-select .option
|
|
119
|
-
|
|
120
|
-
color: #fff;
|
|
121
|
-
cursor: pointer;
|
|
81
|
+
.dtable-select.selector-group .select-group-option {
|
|
82
|
+
justify-content: space-between;
|
|
122
83
|
}
|
|
123
84
|
|
|
124
|
-
.dtable-select
|
|
125
|
-
|
|
85
|
+
.dtable-select.selector-group .selected-option .selected-group {
|
|
86
|
+
padding: 0 2px;
|
|
87
|
+
background: #eceff4;
|
|
88
|
+
border-radius: 3px;
|
|
126
89
|
}
|
|
127
90
|
|
|
128
91
|
.dtable-select .selected-option-show {
|
|
@@ -134,6 +97,6 @@
|
|
|
134
97
|
.dtable-select .select-placeholder {
|
|
135
98
|
line-height: 1;
|
|
136
99
|
font-size: 14px;
|
|
137
|
-
color: #
|
|
100
|
+
color: #999;
|
|
138
101
|
white-space: nowrap;
|
|
139
102
|
}
|
|
@@ -1,132 +1,136 @@
|
|
|
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 SelectOptionGroup from '../SelectOptionGroup';
|
|
7
3
|
import classnames from 'classnames';
|
|
4
|
+
import ModalPortal from '../common/modal-portal';
|
|
8
5
|
import './index.css';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var _this;
|
|
14
|
-
_classCallCheck(this, DTableCustomizeSelect);
|
|
15
|
-
_this = _super.call(this, props);
|
|
16
|
-
_this.onSelectToggle = function (event) {
|
|
6
|
+
class DTableCustomizeSelect extends Component {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super(props);
|
|
9
|
+
this.onSelectToggle = event => {
|
|
17
10
|
event.preventDefault();
|
|
18
11
|
/*
|
|
19
12
|
if select is showing, click events do not need to be monitored by other click events,
|
|
20
13
|
so it can be closed when other select is clicked.
|
|
21
14
|
*/
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
if (
|
|
15
|
+
if (this.state.isShowSelectOptions) event.stopPropagation();
|
|
16
|
+
let eventClassName = event.target.className;
|
|
17
|
+
if (this.props.isLocked || eventClassName.indexOf('option-search-control') > -1 || eventClassName === 'option-group-search') return;
|
|
25
18
|
//Prevent closing by pressing the spacebar in the search input
|
|
26
19
|
if (event.target.value === '') return;
|
|
27
|
-
|
|
28
|
-
isShowSelectOptions: !
|
|
20
|
+
this.setState({
|
|
21
|
+
isShowSelectOptions: !this.state.isShowSelectOptions
|
|
29
22
|
});
|
|
30
23
|
};
|
|
31
|
-
|
|
32
|
-
if (
|
|
24
|
+
this.onClick = event => {
|
|
25
|
+
if (this.props.isShowSelected && event.target.className.includes('icon-fork-number')) {
|
|
33
26
|
return;
|
|
34
27
|
}
|
|
35
|
-
if (!
|
|
36
|
-
|
|
28
|
+
if (!this.selector.contains(event.target)) {
|
|
29
|
+
this.closeSelect();
|
|
37
30
|
}
|
|
38
31
|
};
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
this.closeSelect = () => {
|
|
33
|
+
this.setState({
|
|
41
34
|
isShowSelectOptions: false
|
|
42
35
|
});
|
|
43
36
|
};
|
|
44
|
-
|
|
45
|
-
if (!
|
|
46
|
-
|
|
47
|
-
height
|
|
37
|
+
this.getSelectedOptionTop = () => {
|
|
38
|
+
if (!this.selector) return 38;
|
|
39
|
+
const {
|
|
40
|
+
height
|
|
41
|
+
} = this.selector.getBoundingClientRect();
|
|
48
42
|
return height;
|
|
49
43
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
options
|
|
53
|
-
searchable
|
|
44
|
+
this.getFilterOptions = searchValue => {
|
|
45
|
+
const {
|
|
46
|
+
options,
|
|
47
|
+
searchable
|
|
48
|
+
} = this.props;
|
|
54
49
|
if (!searchable) return options || [];
|
|
55
|
-
|
|
50
|
+
const validSearchVal = searchValue.trim().toLowerCase();
|
|
56
51
|
if (!validSearchVal) return options || [];
|
|
57
|
-
return options.filter(
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
return options.filter(option => {
|
|
53
|
+
const {
|
|
54
|
+
value,
|
|
55
|
+
name
|
|
56
|
+
} = option;
|
|
60
57
|
if (typeof name === 'string') {
|
|
61
58
|
return name.toLowerCase().indexOf(validSearchVal) > -1;
|
|
62
59
|
}
|
|
63
60
|
if (typeof value === 'object') {
|
|
61
|
+
if (value.column) {
|
|
62
|
+
return value.column.name.toLowerCase().indexOf(validSearchVal) > -1;
|
|
63
|
+
}
|
|
64
|
+
if (value.name) {
|
|
65
|
+
return value.name.toLowerCase().indexOf(validSearchVal) > -1;
|
|
66
|
+
}
|
|
64
67
|
return value.columnOption && value.columnOption.name.toLowerCase().indexOf(validSearchVal) > -1;
|
|
65
68
|
}
|
|
66
69
|
return false;
|
|
67
70
|
});
|
|
68
71
|
};
|
|
69
|
-
|
|
72
|
+
this.state = {
|
|
70
73
|
isShowSelectOptions: false
|
|
71
74
|
};
|
|
72
|
-
return _this;
|
|
73
75
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
76
|
+
render() {
|
|
77
|
+
let {
|
|
78
|
+
className,
|
|
79
|
+
value,
|
|
80
|
+
options,
|
|
81
|
+
placeholder,
|
|
82
|
+
searchable,
|
|
83
|
+
searchPlaceholder,
|
|
84
|
+
noOptionsPlaceholder,
|
|
85
|
+
isLocked,
|
|
86
|
+
isInModal
|
|
87
|
+
} = this.props;
|
|
88
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
89
|
+
ref: node => this.selector = node,
|
|
90
|
+
className: classnames('dtable-select custom-select', {
|
|
91
|
+
'focus': this.state.isShowSelectOptions
|
|
92
|
+
}, {
|
|
93
|
+
'disabled': isLocked
|
|
94
|
+
}, className),
|
|
95
|
+
onClick: this.onSelectToggle
|
|
96
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
97
|
+
className: "selected-option"
|
|
98
|
+
}, value && value.label ? /*#__PURE__*/React.createElement("span", {
|
|
99
|
+
className: "selected-option-show"
|
|
100
|
+
}, value.label) : /*#__PURE__*/React.createElement("span", {
|
|
101
|
+
className: "select-placeholder"
|
|
102
|
+
}, placeholder), !isLocked && /*#__PURE__*/React.createElement("i", {
|
|
103
|
+
className: "dtable-font dtable-icon-drop-down"
|
|
104
|
+
})), this.state.isShowSelectOptions && !isInModal && /*#__PURE__*/React.createElement(SelectOptionGroup, {
|
|
105
|
+
value: value,
|
|
106
|
+
isShowSelected: this.props.isShowSelected,
|
|
107
|
+
top: this.getSelectedOptionTop(),
|
|
108
|
+
options: options,
|
|
109
|
+
onSelectOption: this.props.onSelectOption,
|
|
110
|
+
searchable: searchable,
|
|
111
|
+
searchPlaceholder: searchPlaceholder,
|
|
112
|
+
noOptionsPlaceholder: noOptionsPlaceholder,
|
|
113
|
+
onClickOutside: this.onClick,
|
|
114
|
+
closeSelect: this.closeSelect,
|
|
115
|
+
getFilterOptions: this.getFilterOptions,
|
|
116
|
+
supportMultipleSelect: this.props.supportMultipleSelect
|
|
117
|
+
}), this.state.isShowSelectOptions && isInModal && /*#__PURE__*/React.createElement(ModalPortal, null, /*#__PURE__*/React.createElement(SelectOptionGroup, {
|
|
118
|
+
className: className,
|
|
119
|
+
value: value,
|
|
120
|
+
isShowSelected: this.props.isShowSelected,
|
|
121
|
+
position: this.selector.getBoundingClientRect(),
|
|
122
|
+
isInModal: isInModal,
|
|
123
|
+
top: this.getSelectedOptionTop(),
|
|
124
|
+
options: options,
|
|
125
|
+
onSelectOption: this.props.onSelectOption,
|
|
126
|
+
searchable: searchable,
|
|
127
|
+
searchPlaceholder: searchPlaceholder,
|
|
128
|
+
noOptionsPlaceholder: noOptionsPlaceholder,
|
|
129
|
+
onClickOutside: this.onClick,
|
|
130
|
+
closeSelect: this.closeSelect,
|
|
131
|
+
getFilterOptions: this.getFilterOptions,
|
|
132
|
+
supportMultipleSelect: this.props.supportMultipleSelect
|
|
133
|
+
})));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
132
136
|
export default DTableCustomizeSelect;
|