dtable-statistic 4.3.11 → 4.3.13

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.
@@ -46,12 +46,6 @@ Object.defineProperty(exports, "SeaTableRadio", {
46
46
  return _seatableRadio.default;
47
47
  }
48
48
  });
49
- Object.defineProperty(exports, "Select", {
50
- enumerable: true,
51
- get: function () {
52
- return _select.default;
53
- }
54
- });
55
49
  Object.defineProperty(exports, "toaster", {
56
50
  enumerable: true,
57
51
  get: function () {
@@ -65,5 +59,4 @@ var _loading = _interopRequireDefault(require("./loading"));
65
59
  var _modalPortal = _interopRequireDefault(require("./modal-portal"));
66
60
  var _newTableDialog = _interopRequireDefault(require("./dialog/new-table-dialog"));
67
61
  var _seatableRadio = _interopRequireDefault(require("./seatable-radio"));
68
- var _select = _interopRequireDefault(require("./select"));
69
62
  var _toast = _interopRequireDefault(require("./toast"));
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
10
- var _index = require("../../../index");
10
+ var _DTableCustomizeSelect = _interopRequireDefault(require("dtable-ui-component/lib/DTableCustomizeSelect"));
11
11
  var _numberInput = _interopRequireDefault(require("./number-input"));
12
12
  var _colorRules = require("../../../../constants/color-rules");
13
13
  const INPUT_CMP_TYPE_MAP = {
@@ -124,7 +124,7 @@ class Filter extends _react.default.Component {
124
124
  case 1:
125
125
  {
126
126
  const selectedConjunction = conjunctionOptions.find(option => option.value === filterConjunction);
127
- return /*#__PURE__*/_react.default.createElement(_index.Select, {
127
+ return /*#__PURE__*/_react.default.createElement(_DTableCustomizeSelect.default, {
128
128
  value: selectedConjunction,
129
129
  options: conjunctionOptions,
130
130
  onSelectOption: this.onSelectConjunction
@@ -203,13 +203,13 @@ class Filter extends _react.default.Component {
203
203
  className: "filter-container"
204
204
  }, /*#__PURE__*/_react.default.createElement("div", {
205
205
  className: "filter-column"
206
- }, /*#__PURE__*/_react.default.createElement(_index.Select, {
206
+ }, /*#__PURE__*/_react.default.createElement(_DTableCustomizeSelect.default, {
207
207
  value: selectedFilterType,
208
208
  options: filterTypeOptions,
209
209
  onSelectOption: this.onSelectFilterBy
210
210
  })), /*#__PURE__*/_react.default.createElement("div", {
211
211
  className: "filter-predicate ml-2"
212
- }, /*#__PURE__*/_react.default.createElement(_index.Select, {
212
+ }, /*#__PURE__*/_react.default.createElement(_DTableCustomizeSelect.default, {
213
213
  value: selectedPredicate,
214
214
  options: this.predicateOptions,
215
215
  onSelectOption: this.onSelectPredicate
@@ -208,7 +208,3 @@
208
208
  border-color: rgba(0, 40, 100, 0.12);
209
209
  box-shadow: unset;
210
210
  }
211
-
212
- .statistic-color-rule-filters .dtable-select .selected-option {
213
- background-color: transparent;
214
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-statistic",
3
- "version": "4.3.11",
3
+ "version": "4.3.13",
4
4
  "description": "statistics",
5
5
  "main": "dist/dtable-statistic.js",
6
6
  "author": "seafile",
@@ -10,7 +10,7 @@
10
10
  "@antv/g2": "4.1.46",
11
11
  "@antv/util": "3.3.2",
12
12
  "@seafile/seafile-calendar": "0.0.24",
13
- "comlink": "^4.3.1",
13
+ "comlink": "^4.4.1",
14
14
  "dayjs": "1.10.7",
15
15
  "glamor": "^2.20.40",
16
16
  "html2canvas": "^1.4.1",
@@ -57,7 +57,7 @@
57
57
  "css-minimizer-webpack-plugin": "^3.2.0",
58
58
  "dotenv": "^10.0.0",
59
59
  "dotenv-expand": "^5.1.0",
60
- "dtable-ui-component": "4.3.3",
60
+ "dtable-ui-component": "4.3.7",
61
61
  "dtable-utils": "4.3.5",
62
62
  "dtable-web-api": "4.3.5",
63
63
  "dtable-store": "4.3.6",
@@ -1,9 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _select = _interopRequireDefault(require("./select"));
9
- var _default = exports.default = _select.default;
@@ -1,104 +0,0 @@
1
- .option-group {
2
- position: absolute;
3
- left: 0;
4
- min-height: 60px;
5
- max-height: 300px;
6
- min-width: 100%;
7
- max-width: 15rem;
8
- padding: .5rem 0;
9
- box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
10
- background: #fff;
11
- border: 1px solid rgba(0, 40, 100, 0.12);
12
- border-radius: 3px;
13
- z-index: 10001;
14
- }
15
-
16
- .option-group .option-group-search {
17
- width: 100%;
18
- padding: 0 10px 6px 10px;
19
- min-width: 170px;
20
- }
21
-
22
- .option-group-search .form-control {
23
- height: 31px;
24
- }
25
-
26
- .option-group .none-search-result {
27
- height: 100px;
28
- width: 100%;
29
- padding: 10px;
30
- opacity: .5;
31
- }
32
-
33
- .option-group .option-group-content {
34
- max-height: 252px;
35
- overflow-y: auto;
36
- }
37
-
38
- .option {
39
- display: block;
40
- width: 100%;
41
- line-height: 24px;
42
- padding: .25rem 10px;
43
- clear: both;
44
- font-weight: 400;
45
- color: #212529;
46
- text-align: inherit;
47
- background-color: transparent;
48
- border: 0;
49
- overflow: hidden;
50
- text-overflow: ellipsis;
51
- white-space: nowrap;
52
- }
53
-
54
- .option.option-active {
55
- background-color: #20a0ff;
56
- color: #fff;
57
- cursor: pointer;
58
- }
59
-
60
- .option:hover .header-icon .dtable-font,
61
- .option.option-active .select-option-name {
62
- color: #fff;
63
- }
64
-
65
- .option.option-active .header-icon .dtable-font {
66
- color: #fff;
67
- }
68
-
69
- .option:not(.option-active):hover .header-icon .dtable-font {
70
- color: #aaa;
71
- }
72
-
73
- .option .select-option-name .single-select-option {
74
- margin: 0 0 0 12px;
75
- }
76
-
77
- .option .select-option-name .multiple-select-option {
78
- margin: 0;
79
- }
80
-
81
- .option-group-selector-single-select .select-option-name,
82
- .option-group-selector-multiple-select .multiple-option-name {
83
- display: flex;
84
- align-items: center;
85
- justify-content: space-between;
86
- }
87
-
88
- .option-group-selector-multiple-select .multiple-check-icon {
89
- display: inline-flex;
90
- width: 20px;
91
- text-align: center;
92
- }
93
-
94
- .option-group-selector-multiple-select .multiple-check-icon .dtable-icon-check-mark {
95
- font-size: 12px;
96
- color: #798d99;
97
- }
98
-
99
- .option-group-selector-single-select .option:hover,
100
- .option-group-selector-single-select .option.option-active,
101
- .option-group-selector-multiple-select .option:hover,
102
- .option-group-selector-multiple-select .option.option-active {
103
- background-color: #f7f7f7;
104
- }
@@ -1,215 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _react = _interopRequireWildcard(require("react"));
10
- var _dtableSearchInput = _interopRequireDefault(require("../dtable-search-input"));
11
- var _option = _interopRequireDefault(require("./option"));
12
- var _constants = require("../../constants");
13
- require("./option-group.css");
14
- const OPTION_HEIGHT = 32;
15
- class OptGroup extends _react.Component {
16
- constructor(props) {
17
- super(props);
18
- this.resetMenuStyle = () => {
19
- const {
20
- isInModal,
21
- position
22
- } = this.props;
23
- const {
24
- top,
25
- height
26
- } = this.optionGroupRef.getBoundingClientRect();
27
- if (isInModal) {
28
- if (position.y + position.height + height > window.innerHeight) {
29
- this.optionGroupRef.style.top = position.y - height + 'px';
30
- }
31
- this.optionGroupRef.style.opacity = 1;
32
- } else {
33
- if (height + top > window.innerHeight) {
34
- const borderWidth = 2;
35
- this.optionGroupRef.style.top = -1 * (height + borderWidth) + 'px';
36
- }
37
- }
38
- };
39
- this.onHotKey = event => {
40
- const keyCode = event.keyCode;
41
- if (keyCode === _constants.KeyCodes.UpArrow) {
42
- this.onPressUp();
43
- } else if (keyCode === _constants.KeyCodes.DownArrow) {
44
- this.onPressDown();
45
- } else if (keyCode === _constants.KeyCodes.Enter) {
46
- let option = this.filterOptions && this.filterOptions[this.state.activeIndex];
47
- if (option) {
48
- this.props.onSelectOption(option.value);
49
- if (!this.props.supportMultipleSelect) {
50
- this.props.closeSelect();
51
- }
52
- }
53
- } else if (keyCode === _constants.KeyCodes.Tab || keyCode === _constants.KeyCodes.Escape) {
54
- this.props.closeSelect();
55
- window.app.eventBus.dispatch(_constants.CommonEventTypes.OPEN_SELECT, false);
56
- }
57
- };
58
- this.onPressUp = () => {
59
- if (this.state.activeIndex > 0) {
60
- this.setState({
61
- activeIndex: this.state.activeIndex - 1
62
- }, () => {
63
- this.scrollContent();
64
- });
65
- }
66
- };
67
- this.onPressDown = () => {
68
- if (this.filterOptions && this.state.activeIndex < this.filterOptions.length - 1) {
69
- this.setState({
70
- activeIndex: this.state.activeIndex + 1
71
- }, () => {
72
- this.scrollContent();
73
- });
74
- }
75
- };
76
- this.scrollContent = () => {
77
- const {
78
- offsetHeight,
79
- scrollTop
80
- } = this.optionGroupContentRef;
81
- this.setState({
82
- disableHover: true
83
- });
84
- this.timer = setTimeout(() => {
85
- this.setState({
86
- disableHover: false
87
- });
88
- }, 500);
89
- if (this.state.activeIndex * OPTION_HEIGHT === 0) {
90
- this.optionGroupContentRef.scrollTop = 0;
91
- return;
92
- }
93
- if (this.state.activeIndex * OPTION_HEIGHT < scrollTop) {
94
- this.optionGroupContentRef.scrollTop = scrollTop - OPTION_HEIGHT;
95
- } else if (this.state.activeIndex * OPTION_HEIGHT > offsetHeight + scrollTop) {
96
- this.optionGroupContentRef.scrollTop = scrollTop + OPTION_HEIGHT;
97
- }
98
- };
99
- this.changeIndex = index => {
100
- this.setState({
101
- activeIndex: index
102
- });
103
- };
104
- this.onChangeSearch = searchVal => {
105
- let value = searchVal || '';
106
- if (value !== this.state.searchVal) {
107
- this.setState({
108
- searchVal: value,
109
- activeIndex: -1
110
- });
111
- }
112
- };
113
- this.renderOptGroup = searchVal => {
114
- let {
115
- noOptionsPlaceholder,
116
- onSelectOption
117
- } = this.props;
118
- this.filterOptions = this.props.getFilterOptions(searchVal);
119
- if (this.filterOptions.length === 0) {
120
- return /*#__PURE__*/_react.default.createElement("div", {
121
- className: "none-search-result"
122
- }, noOptionsPlaceholder);
123
- }
124
- return this.filterOptions.map((opt, i) => {
125
- let key = opt.value.column ? opt.value.column.key : i;
126
- let isActive = this.state.activeIndex === i;
127
- return /*#__PURE__*/_react.default.createElement(_option.default, {
128
- key: key,
129
- index: i,
130
- isActive: isActive,
131
- value: opt.value,
132
- onSelectOption: onSelectOption,
133
- changeIndex: this.changeIndex,
134
- supportMultipleSelect: this.props.supportMultipleSelect,
135
- disableHover: this.state.disableHover
136
- }, opt.label);
137
- });
138
- };
139
- this.state = {
140
- searchVal: '',
141
- activeIndex: -1,
142
- disableHover: false
143
- };
144
- this.filterOptions = null;
145
- this.timer = null;
146
- }
147
- componentDidMount() {
148
- window.addEventListener('keydown', this.onHotKey);
149
- // Make sure child component is rendered, so current component can be stretched out, then get the correct size
150
- setTimeout(() => {
151
- this.resetMenuStyle();
152
- }, 1);
153
- }
154
- componentWillUnmount() {
155
- this.filterOptions = null;
156
- this.timer && clearTimeout(this.timer);
157
- window.removeEventListener('keydown', this.onHotKey);
158
- }
159
- render() {
160
- const {
161
- searchable,
162
- searchPlaceholder,
163
- top,
164
- left,
165
- minWidth,
166
- value,
167
- isShowSelected,
168
- isInModal,
169
- position,
170
- className
171
- } = this.props;
172
- let {
173
- searchVal
174
- } = this.state;
175
- let style = {
176
- top: top || 0,
177
- left: left || 0
178
- };
179
- if (minWidth) {
180
- style = {
181
- top: top || 0,
182
- left: left || 0,
183
- minWidth
184
- };
185
- }
186
- if (isInModal) {
187
- style = {
188
- position: 'fixed',
189
- left: position.x,
190
- top: position.y + position.height,
191
- minWidth: position.width,
192
- opacity: 0
193
- };
194
- }
195
- return /*#__PURE__*/_react.default.createElement("div", {
196
- className: "option-group ".concat(isShowSelected ? 'pt-0' : '', " ").concat(className ? 'option-group-' + className : ''),
197
- ref: ref => this.optionGroupRef = ref,
198
- style: style
199
- }, isShowSelected && /*#__PURE__*/_react.default.createElement("div", {
200
- className: "editor-list-delete mb-2",
201
- onClick: e => e.stopPropagation()
202
- }, value.label || ''), searchable && /*#__PURE__*/_react.default.createElement("div", {
203
- className: "option-group-search"
204
- }, /*#__PURE__*/_react.default.createElement(_dtableSearchInput.default, {
205
- className: "option-search-control",
206
- placeholder: searchPlaceholder,
207
- onChange: this.onChangeSearch,
208
- autoFocus: true
209
- })), /*#__PURE__*/_react.default.createElement("div", {
210
- className: "option-group-content",
211
- ref: ref => this.optionGroupContentRef = ref
212
- }, this.renderOptGroup(searchVal)));
213
- }
214
- }
215
- var _default = exports.default = OptGroup;
@@ -1,45 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _react = _interopRequireWildcard(require("react"));
10
- var _classnames = _interopRequireDefault(require("classnames"));
11
- class Option extends _react.Component {
12
- constructor() {
13
- super(...arguments);
14
- this.onSelectOption = (value, event) => {
15
- if (this.props.supportMultipleSelect) {
16
- event.stopPropagation();
17
- }
18
- this.props.onSelectOption(value, event);
19
- };
20
- this.onMouseEnter = () => {
21
- if (!this.props.disableHover) {
22
- this.props.changeIndex(this.props.index);
23
- }
24
- };
25
- this.onMouseLeave = () => {
26
- if (!this.props.disableHover) {
27
- this.props.changeIndex(-1);
28
- }
29
- };
30
- }
31
- render() {
32
- const {
33
- isActive
34
- } = this.props;
35
- return /*#__PURE__*/_react.default.createElement("div", {
36
- className: (0, _classnames.default)('option', {
37
- 'option-active': isActive
38
- }),
39
- onClick: this.onSelectOption.bind(this, this.props.value),
40
- onMouseEnter: this.onMouseEnter,
41
- onMouseLeave: this.onMouseLeave
42
- }, this.props.children);
43
- }
44
- }
45
- var _default = exports.default = Option;
@@ -1,211 +0,0 @@
1
- .dtable-select {
2
- position: relative;
3
- }
4
-
5
- .dtable-select.custom-select {
6
- display: flex;
7
- padding: 0 10px;
8
- border-radius: 3px;
9
- align-items: center;
10
- justify-content: space-between;
11
- max-width: 900px;
12
- user-select: none;
13
- -webkit-user-select: none;
14
- -moz-user-select: none;
15
- -o-user-select: none;
16
- -ms-user-select: none;
17
- text-align: left;
18
- }
19
-
20
- .dtable-select.custom-select:focus,
21
- .dtable-select.custom-select.focus {
22
- border-color: #1991eb !important;
23
- box-shadow: 0 0 0 2px rgba(70, 127, 207, 0.25);
24
- }
25
-
26
- .dtable-select.custom-select.disabled:focus,
27
- .dtable-select.custom-select.focus.disabled,
28
- .dtable-select.custom-select.disabled:hover {
29
- border-color: rgba(0, 40, 100, 0.12) !important;
30
- box-shadow: unset;
31
- cursor: default;
32
- }
33
-
34
- .dtable-select.custom-select:hover {
35
- cursor: pointer;
36
- border-color: rgb(179, 179, 179);
37
- }
38
-
39
- .dtable-select .select-option-name {
40
- color: #212529;
41
- }
42
-
43
- .dtable-select .dtable-icon-drop-down {
44
- display: inline-block;
45
- font-size: 12px;
46
- color: #949494;
47
- transform: scale(.8) translateY(2px);
48
- transition: all .1s;
49
- }
50
-
51
- .dtable-select .dtable-icon-drop-down:hover {
52
- color: #000;
53
- }
54
-
55
- .dtable-select .selected-option {
56
- display: flex;
57
- flex: 1;
58
- overflow: hidden;
59
- flex-wrap: nowrap;
60
- align-items: center;
61
- justify-content: space-between;
62
- background: #fff;
63
- }
64
-
65
- .dtable-select.selector-collaborator .option-group .option-group-content {
66
- padding: 10px;
67
- }
68
-
69
- .dtable-select.selector-collaborator .option {
70
- padding: 5px 0 5px 10px !important;
71
- line-height: 20px;
72
- }
73
-
74
- .dtable-select .selected-option-show {
75
- overflow: hidden;
76
- text-overflow: ellipsis;
77
- white-space: nowrap;
78
- }
79
-
80
- .dtable-select .select-placeholder {
81
- line-height: 1;
82
- font-size: 14px;
83
- color: #949494;
84
- white-space: nowrap;
85
- }
86
-
87
- /* collaborator select */
88
- .collaborator-select-popover.dtable-select {
89
- position: unset;
90
- }
91
-
92
- .collaborator-select-popover .collaborator-avatar {
93
- width: 16px;
94
- height: 16px;
95
- transform: translateY(-1px);
96
- }
97
-
98
- .collaborator-select-popover .option-group {
99
- position: absolute;
100
- left: 0px;
101
- min-height: 60px;
102
- max-height: unset;
103
- min-width: 100%;
104
- max-width: 15rem;
105
- padding: 0.5rem 0;
106
- box-shadow: 0 1px 2px 0 rgb(0 0 0 / 5%);
107
- background: #fff;
108
- border: 1px solid rgba(0,40,100,.12);
109
- border-radius: 3px;
110
- z-index: 10001;
111
- }
112
-
113
- .collaborator-select-popover .option-group .option-group-search {
114
- width: 100%;
115
- padding: 0 10px;
116
- min-width: 170px;
117
- }
118
-
119
- .collaborator-select-popover .option-group-search .form-control {
120
- height: 31px;
121
- }
122
-
123
- .collaborator-select-popover .option-group .none-search-result {
124
- height: 100px;
125
- width: 100%;
126
- padding: 10px;
127
- opacity: .5;
128
- }
129
-
130
- .collaborator-select-popover .option-group .option-group-content {
131
- max-height: 252px;
132
- overflow-y: auto;
133
- padding: 10px;
134
- }
135
-
136
- .collaborator-select-popover .selected-option-show {
137
- width: calc(100% - 20px);
138
- height: 20px;
139
- }
140
-
141
- .collaborator-select-popover .selected-option {
142
- width: auto;
143
- overflow-x: auto;
144
- }
145
-
146
- .collaborator-select-popover .dtable-icon-drop-down {
147
- margin-left: .5rem;
148
- }
149
-
150
- .collaborator-select-popover .option-collaborator {
151
- display: flex;
152
- }
153
-
154
- .collaborator-select-popover .collaborator-container {
155
- flex: 1 1;
156
- }
157
-
158
- .collaborator-select-popover .editor-list-delete .collaborator-container {
159
- flex: 1 1;
160
- display: inline;
161
- }
162
-
163
- .collaborator-select-popover .multiple-check-icon {
164
- display: inline-flex;
165
- width: 20px;
166
- text-align: center;
167
- }
168
-
169
- .collaborator-select-popover .collaborator-check-icon .dtable-icon-check-mark,
170
- .collaborator-select-popover .multiple-check-icon .dtable-icon-check-mark {
171
- font-size: 12px;
172
- color: #798d99;
173
- }
174
-
175
- .collaborator-select-popover.dtable-select .option-active,
176
- .collaborator-select-popover.dtable-select .option:hover {
177
- color: #212529;
178
- background-color: #f7f7f7;
179
- }
180
-
181
- .collaborator-select-popover.dtable-select .option.option-active .select-option-name {
182
- color: #212529;
183
- }
184
-
185
- .collaborator-select .option-group-content .collaborator,
186
- .collaborator-select-popover .option-group .option-group-content .collaborator {
187
- background: none;
188
- }
189
-
190
- .collaborator-select-popover .collaborator-avatar-container {
191
- width: 16px;
192
- }
193
-
194
- .collaborator-select-popover .option-group-content .remove-container {
195
- display: none;
196
- }
197
-
198
- .collaborator-select-popover .collaborator-container {
199
- display: flex;
200
- justify-content: space-between;
201
- }
202
-
203
- .collaborator-container .collaborator-name {
204
- margin-left: 5px;
205
- max-width: 200px;
206
- color: #212529;
207
- }
208
-
209
- .collaborator-select .option-group {
210
- max-height: fit-content;
211
- }
@@ -1,150 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _react = _interopRequireWildcard(require("react"));
10
- var _classnames = _interopRequireDefault(require("classnames"));
11
- var _modalPortal = _interopRequireDefault(require("../modal-portal"));
12
- var _optionGroup = _interopRequireDefault(require("./option-group"));
13
- var _constants = require("../../constants");
14
- require("./select.css");
15
- class Select extends _react.Component {
16
- constructor(props) {
17
- super(props);
18
- this.onSelectToggle = event => {
19
- event.preventDefault();
20
- /*
21
- if select is showing, click events do not need to be monitored by other click events,
22
- so it can be closed when other select is clicked.
23
- */
24
- if (this.state.isShowSelectOptions) event.nativeEvent.stopImmediatePropagation();
25
- let eventClassName = event.target.className;
26
- if (this.props.isLocked || eventClassName.indexOf('option-search-control') > -1 || eventClassName === 'option-group-search') return;
27
- //Prevent closing by pressing the spacebar in the search input
28
- if (event.target.value === '') return;
29
- this.setState({
30
- isShowSelectOptions: !this.state.isShowSelectOptions
31
- });
32
- window.app.eventBus.dispatch(_constants.CommonEventTypes.OPEN_SELECT, !this.state.isShowSelectOptions);
33
- };
34
- this.onMousedown = event => {
35
- if (this.props.isShowSelected && event.target.className.includes('icon-fork-number')) {
36
- return;
37
- }
38
- if (!this.selector.contains(event.target)) {
39
- this.closeSelect();
40
- }
41
- };
42
- this.closeSelect = () => {
43
- this.setState({
44
- isShowSelectOptions: false
45
- });
46
- };
47
- this.getSelectedOptionTop = () => {
48
- if (!this.selector) return 38;
49
- const {
50
- height
51
- } = this.selector.getBoundingClientRect();
52
- return height;
53
- };
54
- this.getFilterOptions = searchValue => {
55
- const {
56
- options,
57
- searchable
58
- } = this.props;
59
- if (!searchable) return options || [];
60
- const validSearchVal = searchValue.trim().toLowerCase();
61
- if (!validSearchVal) return options || [];
62
- return options.filter(option => {
63
- const {
64
- value,
65
- name
66
- } = option;
67
- if (typeof name === 'string') {
68
- return name.toLowerCase().indexOf(validSearchVal) > -1;
69
- }
70
- if (typeof value === 'object') {
71
- if (value.column) {
72
- return value.column.name.toLowerCase().indexOf(validSearchVal) > -1;
73
- }
74
- if (value.name) {
75
- return value.name.toLowerCase().indexOf(validSearchVal) > -1;
76
- }
77
- return value.columnOption && value.columnOption.name.toLowerCase().indexOf(validSearchVal) > -1;
78
- }
79
- return false;
80
- });
81
- };
82
- this.state = {
83
- isShowSelectOptions: false
84
- };
85
- }
86
- componentDidMount() {
87
- document.addEventListener('mousedown', this.onMousedown);
88
- }
89
- componentWillUnmount() {
90
- document.removeEventListener('mousedown', this.onMousedown);
91
- }
92
- render() {
93
- let {
94
- className,
95
- value,
96
- options,
97
- placeholder,
98
- searchable,
99
- searchPlaceholder,
100
- noOptionsPlaceholder,
101
- isLocked,
102
- isInModal
103
- } = this.props;
104
- return /*#__PURE__*/_react.default.createElement("div", {
105
- ref: node => this.selector = node,
106
- className: (0, _classnames.default)('dtable-select custom-select', {
107
- 'focus': this.state.isShowSelectOptions
108
- }, {
109
- 'disabled': isLocked
110
- }, className),
111
- onClick: this.onSelectToggle
112
- }, /*#__PURE__*/_react.default.createElement("div", {
113
- className: "selected-option"
114
- }, value.label ? /*#__PURE__*/_react.default.createElement("span", {
115
- className: "selected-option-show"
116
- }, value.label) : /*#__PURE__*/_react.default.createElement("span", {
117
- className: "select-placeholder"
118
- }, placeholder), !isLocked && /*#__PURE__*/_react.default.createElement("i", {
119
- className: "dtable-font dtable-icon-drop-down"
120
- })), this.state.isShowSelectOptions && !isInModal && /*#__PURE__*/_react.default.createElement(_optionGroup.default, {
121
- value: value,
122
- isShowSelected: this.props.isShowSelected,
123
- top: this.getSelectedOptionTop(),
124
- options: options,
125
- onSelectOption: this.props.onSelectOption,
126
- searchable: searchable,
127
- searchPlaceholder: searchPlaceholder,
128
- noOptionsPlaceholder: noOptionsPlaceholder,
129
- closeSelect: this.closeSelect,
130
- getFilterOptions: this.getFilterOptions,
131
- supportMultipleSelect: this.props.supportMultipleSelect
132
- }), this.state.isShowSelectOptions && isInModal && /*#__PURE__*/_react.default.createElement(_modalPortal.default, null, /*#__PURE__*/_react.default.createElement(_optionGroup.default, {
133
- className: className,
134
- value: value,
135
- isShowSelected: this.props.isShowSelected,
136
- position: this.selector.getBoundingClientRect(),
137
- isInModal: isInModal,
138
- top: this.getSelectedOptionTop(),
139
- options: options,
140
- onSelectOption: this.props.onSelectOption,
141
- searchable: searchable,
142
- searchPlaceholder: searchPlaceholder,
143
- noOptionsPlaceholder: noOptionsPlaceholder,
144
- closeSelect: this.closeSelect,
145
- getFilterOptions: this.getFilterOptions,
146
- supportMultipleSelect: this.props.supportMultipleSelect
147
- })));
148
- }
149
- }
150
- var _default = exports.default = Select;