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