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.
Files changed (120) 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.js +92 -103
  15. package/lib/DTablePopover/index.js +52 -71
  16. package/lib/DTablePopover/utils.js +1 -1
  17. package/lib/DTableRadio/index.js +9 -7
  18. package/lib/DTableSearchInput/index.js +89 -99
  19. package/lib/DTableSearchInput/utils.js +2 -2
  20. package/lib/DTableSelect/dtable-select-label.js +5 -3
  21. package/lib/DTableSelect/index.js +50 -64
  22. package/lib/DTableSelect/utils.js +36 -41
  23. package/lib/DTableSwitch/index.js +7 -5
  24. package/lib/DateEditor/index.js +88 -94
  25. package/lib/DateEditor/mb-date-editor-popover/index.js +136 -134
  26. package/lib/DateEditor/pc-date-editor-popover.js +70 -77
  27. package/lib/DateFormatter/index.js +15 -28
  28. package/lib/DepartmentSingleSelectFormatter/index.js +9 -9
  29. package/lib/DigitalSignFormatter/index.js +55 -65
  30. package/lib/DigitalSignFormatter/utils.js +9 -8
  31. package/lib/DurationFormatter/index.js +14 -27
  32. package/lib/EditEditorButton/index.js +10 -22
  33. package/lib/EmailFormatter/index.js +11 -24
  34. package/lib/FieldDisplaySetting/field-item.js +18 -20
  35. package/lib/FieldDisplaySetting/index.js +41 -43
  36. package/lib/FileEditor/index.js +18 -29
  37. package/lib/FileFormatter/index.js +29 -43
  38. package/lib/FileItemFormatter/index.js +17 -32
  39. package/lib/FileItemFormatter/utils.js +5 -5
  40. package/lib/FileUploader/index.js +20 -33
  41. package/lib/FormulaFormatter/cell-value-validator.js +23 -8
  42. package/lib/FormulaFormatter/index.js +77 -83
  43. package/lib/FormulaFormatter/utils.js +27 -21
  44. package/lib/GeolocationFormatter/index.js +19 -32
  45. package/lib/HtmlLongTextFormatter/index.js +43 -52
  46. package/lib/HtmlLongTextFormatter/markdown2html.js +2 -2
  47. package/lib/HtmlLongTextFormatter/unified/index.js +1 -1
  48. package/lib/HtmlLongTextFormatter/vfile/core.js +10 -10
  49. package/lib/ImageFormatter/images-lazy-load.js +71 -79
  50. package/lib/ImageFormatter/index.js +86 -97
  51. package/lib/ImageFormatter/utils.js +1 -1
  52. package/lib/ImagePreviewerLightbox/index.js +20 -18
  53. package/lib/ImagePreviewerLightbox/utils.js +3 -3
  54. package/lib/LastModifierFormatter/index.js +24 -40
  55. package/lib/LinkEditor/index.js +163 -167
  56. package/lib/LinkEditor/link-editor-option.js +41 -56
  57. package/lib/LinkEditor/mb-link-editor-popover/index.js +90 -99
  58. package/lib/LinkEditor/pc-link-editor-popover/index.js +63 -71
  59. package/lib/LinkFormatter/index.js +75 -77
  60. package/lib/LongTextFormatter/index.js +5 -3
  61. package/lib/MBEditorHeader/index.js +25 -38
  62. package/lib/MTimeFormatter/index.js +17 -32
  63. package/lib/ModalPortal/index.js +15 -32
  64. package/lib/MultipleSelectEditor/index.js +118 -136
  65. package/lib/MultipleSelectFormatter/index.js +24 -40
  66. package/lib/NotificationPopover/index.js +68 -95
  67. package/lib/NumberEditor/index.js +75 -82
  68. package/lib/NumberFormatter/index.js +15 -28
  69. package/lib/RateFormatter/index.js +29 -45
  70. package/lib/RoleStatusEditor/index.js +20 -22
  71. package/lib/RowExpandEmailFormatter/index.js +24 -37
  72. package/lib/RowExpandFileFormatter/index.js +28 -42
  73. package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +66 -82
  74. package/lib/RowExpandFormatter/index.js +92 -96
  75. package/lib/RowExpandFormulaFormatter/index.js +85 -91
  76. package/lib/RowExpandImageFormatter/index.js +65 -82
  77. package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +71 -84
  78. package/lib/RowExpandImageFormatter/utils.js +1 -1
  79. package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +54 -68
  80. package/lib/RowExpandLinkFormatter/index.js +131 -137
  81. package/lib/RowExpandLinkFormatter/utils.js +23 -17
  82. package/lib/RowExpandLinkFormatter/value-display-utils.js +9 -7
  83. package/lib/RowExpandRateFormatter/index.js +27 -42
  84. package/lib/RowExpandUrlFormatter/index.js +27 -40
  85. package/lib/SelectItem/index.js +17 -33
  86. package/lib/SelectOptionGroup/index.js +141 -159
  87. package/lib/SelectOptionGroup/option.js +24 -40
  88. package/lib/SimpleLongTextFormatter/index.js +55 -67
  89. package/lib/SimpleLongTextFormatter/normalize-long-text-value.js +23 -22
  90. package/lib/SimpleLongTextFormatter/widgets/LongTextPreview.js +42 -57
  91. package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +31 -46
  92. package/lib/SingleSelectEditor/index.js +108 -119
  93. package/lib/SingleSelectFormatter/index.js +21 -37
  94. package/lib/TextEditor/index.js +45 -51
  95. package/lib/TextFormatter/index.js +17 -32
  96. package/lib/UrlFormatter/index.js +11 -24
  97. package/lib/cellFormatterFactory/index.js +8 -17
  98. package/lib/common/ClickOutside.js +22 -43
  99. package/lib/common/delete-tip.js +40 -65
  100. package/lib/common/modal-portal.js +15 -33
  101. package/lib/constants/index.js +5 -5
  102. package/lib/data/dtable-value.js +4 -4
  103. package/lib/formatterConfig/base-formatter-config.js +24 -3
  104. package/lib/formatterConfig/index.js +5 -4
  105. package/lib/lang/index.js +6 -6
  106. package/lib/locals/de.js +1 -1
  107. package/lib/locals/en.js +1 -1
  108. package/lib/locals/fr.js +1 -1
  109. package/lib/locals/zh-CN.js +1 -1
  110. package/lib/select-editor/mb-select-editor-popover/index.js +126 -137
  111. package/lib/select-editor/pc-select-editor-popover/index.js +75 -83
  112. package/lib/select-editor/select-editor-option.js +41 -56
  113. package/lib/toaster/alert.js +73 -88
  114. package/lib/toaster/index.js +1 -1
  115. package/lib/toaster/toast.js +75 -102
  116. package/lib/toaster/toastManager.js +55 -91
  117. package/lib/toaster/toaster.js +58 -57
  118. package/lib/utils/editor-utils.js +17 -19
  119. package/lib/utils/utils.js +14 -14
  120. 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
+ }
@@ -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
- var OPTION_HEIGHT = 32;
12
- var SelectOptionGroup = /*#__PURE__*/function (_Component) {
13
- _inherits(SelectOptionGroup, _Component);
14
- var _super = _createSuper(SelectOptionGroup);
15
- function SelectOptionGroup(props) {
16
- var _this;
17
- _classCallCheck(this, SelectOptionGroup);
18
- _this = _super.call(this, props);
19
- _this.resetMenuStyle = function () {
20
- var _this$props = _this.props,
21
- isInModal = _this$props.isInModal,
22
- position = _this$props.position;
23
- var _this$optionGroupRef$ = _this.optionGroupRef.getBoundingClientRect(),
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
- _this.optionGroupRef.style.top = position.y - height + 'px';
22
+ this.optionGroupRef.style.top = position.y - height + 'px';
29
23
  }
30
- _this.optionGroupRef.style.opacity = 1;
24
+ this.optionGroupRef.style.opacity = 1;
31
25
  } else {
32
26
  if (height + top > window.innerHeight) {
33
- var borderWidth = 2;
34
- _this.optionGroupRef.style.top = -1 * (height + borderWidth) + 'px';
27
+ const borderWidth = 2;
28
+ this.optionGroupRef.style.top = -1 * (height + borderWidth) + 'px';
35
29
  }
36
30
  }
37
31
  };
38
- _this.onHotKey = function (event) {
39
- var keyCode = event.keyCode;
32
+ this.onHotKey = event => {
33
+ const keyCode = event.keyCode;
40
34
  if (keyCode === KeyCodes.UpArrow) {
41
- _this.onPressUp();
35
+ this.onPressUp();
42
36
  } else if (keyCode === KeyCodes.DownArrow) {
43
- _this.onPressDown();
37
+ this.onPressDown();
44
38
  } else if (keyCode === KeyCodes.Enter) {
45
- var option = _this.filterOptions && _this.filterOptions[_this.state.activeIndex];
39
+ let option = this.filterOptions && this.filterOptions[this.state.activeIndex];
46
40
  if (option) {
47
- _this.props.onSelectOption(option.value);
48
- if (!_this.props.supportMultipleSelect) {
49
- _this.props.closeSelect();
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
- _this.props.closeSelect();
47
+ this.props.closeSelect();
54
48
  }
55
49
  };
56
- _this.onPressUp = function () {
57
- if (_this.state.activeIndex > 0) {
58
- _this.setState({
59
- activeIndex: _this.state.activeIndex - 1
60
- }, function () {
61
- _this.scrollContent();
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
- _this.onPressDown = function () {
66
- if (_this.filterOptions && _this.state.activeIndex < _this.filterOptions.length - 1) {
67
- _this.setState({
68
- activeIndex: _this.state.activeIndex + 1
69
- }, function () {
70
- _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();
71
65
  });
72
66
  }
73
67
  };
74
- _this.scrollContent = function () {
75
- var _this$optionGroupCont = _this.optionGroupContentRef,
76
- offsetHeight = _this$optionGroupCont.offsetHeight,
77
- scrollTop = _this$optionGroupCont.scrollTop;
78
- _this.setState({
68
+ this.scrollContent = () => {
69
+ const {
70
+ offsetHeight,
71
+ scrollTop
72
+ } = this.optionGroupContentRef;
73
+ this.setState({
79
74
  disableHover: true
80
75
  });
81
- _this.timer = setTimeout(function () {
82
- _this.setState({
76
+ this.timer = setTimeout(() => {
77
+ this.setState({
83
78
  disableHover: false
84
79
  });
85
80
  }, 500);
86
- if (_this.state.activeIndex * OPTION_HEIGHT === 0) {
87
- _this.optionGroupContentRef.scrollTop = 0;
81
+ if (this.state.activeIndex * OPTION_HEIGHT === 0) {
82
+ this.optionGroupContentRef.scrollTop = 0;
88
83
  return;
89
84
  }
90
- if (_this.state.activeIndex * OPTION_HEIGHT < scrollTop) {
91
- _this.optionGroupContentRef.scrollTop = scrollTop - OPTION_HEIGHT;
92
- } else if (_this.state.activeIndex * OPTION_HEIGHT > offsetHeight + scrollTop) {
93
- _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;
94
89
  }
95
90
  };
96
- _this.changeIndex = function (index) {
97
- _this.setState({
91
+ this.changeIndex = index => {
92
+ this.setState({
98
93
  activeIndex: index
99
94
  });
100
95
  };
101
- _this.onChangeSearch = function (searchVal) {
102
- var value = searchVal || '';
103
- if (value !== _this.state.searchVal) {
104
- _this.setState({
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
- _this.renderOptGroup = function (searchVal) {
111
- var _this$props2 = _this.props,
112
- noOptionsPlaceholder = _this$props2.noOptionsPlaceholder,
113
- onSelectOption = _this$props2.onSelectOption,
114
- isInModal = _this$props2.isInModal;
115
- _this.filterOptions = _this.props.getFilterOptions(searchVal);
116
- if (_this.filterOptions.length === 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) {
117
113
  return /*#__PURE__*/React.createElement("div", {
118
114
  className: "none-search-result"
119
115
  }, noOptionsPlaceholder);
120
116
  }
121
- return _this.filterOptions.map(function (opt, i) {
122
- var key = opt.value.column ? opt.value.column.key : i;
123
- 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;
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: _this.changeIndex,
132
- supportMultipleSelect: _this.props.supportMultipleSelect,
133
- disableHover: _this.state.disableHover
127
+ changeIndex: this.changeIndex,
128
+ supportMultipleSelect: this.props.supportMultipleSelect,
129
+ disableHover: this.state.disableHover
134
130
  }, opt.label);
135
131
  });
136
132
  };
137
- _this.state = {
133
+ this.state = {
138
134
  searchVal: '',
139
135
  activeIndex: -1,
140
136
  disableHover: false
141
137
  };
142
- _this.filterOptions = null;
143
- _this.timer = null;
144
- return _this;
138
+ this.filterOptions = null;
139
+ this.timer = null;
145
140
  }
146
- _createClass(SelectOptionGroup, [{
147
- key: "componentDidMount",
148
- value: function componentDidMount() {
149
- var _this2 = this;
150
- window.addEventListener('keydown', this.onHotKey);
151
- setTimeout(function () {
152
- _this2.resetMenuStyle();
153
- }, 1);
154
- }
155
- }, {
156
- key: "componentWillUnmount",
157
- value: function componentWillUnmount() {
158
- this.filterOptions = null;
159
- this.timer && clearTimeout(this.timer);
160
- window.removeEventListener('keydown', this.onHotKey);
161
- }
162
- }, {
163
- key: "render",
164
- value: function render() {
165
- var _this3 = this;
166
- var _this$props3 = this.props,
167
- searchable = _this$props3.searchable,
168
- searchPlaceholder = _this$props3.searchPlaceholder,
169
- top = _this$props3.top,
170
- left = _this$props3.left,
171
- minWidth = _this$props3.minWidth,
172
- value = _this$props3.value,
173
- isShowSelected = _this$props3.isShowSelected,
174
- isInModal = _this$props3.isInModal,
175
- position = _this$props3.position,
176
- className = _this$props3.className;
177
- var searchVal = this.state.searchVal;
178
- var style = {
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
- return SelectOptionGroup;
227
- }(Component);
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
- 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
- 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
- _this.props.onSelectOption(value, event);
9
+ this.props.onSelectOption(value, event);
21
10
  };
22
- _this.onMouseEnter = function () {
23
- if (!_this.props.disableHover) {
24
- _this.props.changeIndex(_this.props.index);
11
+ this.onMouseEnter = () => {
12
+ if (!this.props.disableHover) {
13
+ this.props.changeIndex(this.props.index);
25
14
  }
26
15
  };
27
- _this.onMouseLeave = function () {
28
- if (!_this.props.disableHover) {
29
- _this.props.changeIndex(-1);
16
+ this.onMouseLeave = () => {
17
+ if (!this.props.disableHover) {
18
+ this.props.changeIndex(-1);
30
19
  }
31
20
  };
32
- _this.onMouseDown = function (event) {
33
- if (_this.props.isInModal) {
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
- _createClass(Option, [{
42
- key: "render",
43
- value: function render() {
44
- return /*#__PURE__*/React.createElement("div", {
45
- className: this.props.isActive ? 'option option-active' : 'option',
46
- onClick: this.onSelectOption.bind(this, this.props.value),
47
- onMouseDown: this.onMouseDown,
48
- onMouseEnter: this.onMouseEnter,
49
- onMouseLeave: this.onMouseLeave
50
- }, this.props.children);
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;