dtable-ui-component 7.0.13-beta.1 → 7.0.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.
@@ -27,7 +27,7 @@
27
27
  font-size: .875rem;
28
28
  line-height: 1.6;
29
29
  width: 100%;
30
- padding: .375rem 1rem;
30
+ padding: 6px 40px 6px 12px;
31
31
  border-top-left-radius: 4px;
32
32
  border-top-right-radius: 4px;
33
33
  }
@@ -60,7 +60,7 @@
60
60
  min-width: 20px;
61
61
  pointer-events: auto;
62
62
  color: var(--bs-icon-color);
63
- right: 13px;
63
+ right: 6px;
64
64
  top: 6px;
65
65
  z-index: 1;
66
66
  height: 20px;
@@ -14,32 +14,41 @@ var _jsxRuntime = require("react/jsx-runtime");
14
14
  class DTableCustomizeSearchInput extends _react.Component {
15
15
  constructor(props) {
16
16
  super(props);
17
- this.onCompositionStart = () => {
18
- this.isInputtingChinese = true;
17
+ this.handleCompositionStart = () => {
18
+ this.isComposing = true;
19
19
  };
20
- this.onChange = e => {
21
- this.timer && clearTimeout(this.timer);
20
+ this.clearChangeTimer = () => {
21
+ if (this.timer === null) return;
22
+ clearTimeout(this.timer);
23
+ this.timer = null;
24
+ };
25
+ this.scheduleSearchChange = searchValue => {
22
26
  const _this$props = this.props,
23
27
  onChange = _this$props.onChange,
24
28
  _this$props$wait = _this$props.wait,
25
29
  wait = _this$props$wait === void 0 ? 100 : _this$props$wait;
26
- let text = e.target.value;
30
+ this.timer = setTimeout(() => {
31
+ this.timer = null;
32
+ onChange(searchValue.trim());
33
+ }, wait);
34
+ };
35
+ this.handleInputChange = event => {
36
+ const searchValue = event.target.value || '';
37
+ this.clearChangeTimer();
27
38
  this.setState({
28
- searchValue: text || ''
29
- }, () => {
30
- if (this.isInputtingChinese) return;
31
- this.timer = setTimeout(() => {
32
- onChange && onChange(this.state.searchValue.trim());
33
- }, wait);
39
+ searchValue
34
40
  });
41
+ if (this.isComposing) return;
42
+ this.scheduleSearchChange(searchValue);
35
43
  };
36
- this.onCompositionEnd = e => {
37
- this.isInputtingChinese = false;
38
- this.onChange(e);
44
+ this.handleCompositionEnd = event => {
45
+ this.isComposing = false;
46
+ this.handleInputChange(event);
39
47
  };
40
- this.clearSearch = e => {
41
- e && e.stopPropagation && e.stopPropagation();
48
+ this.clearSearch = event => {
49
+ event && event.stopPropagation && event.stopPropagation();
42
50
  const clearValue = this.props.clearValue;
51
+ this.clearChangeTimer();
43
52
  this.setState({
44
53
  searchValue: ''
45
54
  }, () => {
@@ -65,14 +74,14 @@ class DTableCustomizeSearchInput extends _react.Component {
65
74
  onClick: this.clearSearch,
66
75
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DTableIcon.default, {
67
76
  symbol: "close",
68
- color: "var(--bs-icon-secondary-color)"
77
+ color: "var(--bs-icon-color)"
69
78
  })
70
79
  });
71
80
  };
72
81
  this.state = {
73
82
  searchValue: props.value || ''
74
83
  };
75
- this.isInputtingChinese = false;
84
+ this.isComposing = false;
76
85
  this.timer = null;
77
86
  this.inputRef = null;
78
87
  }
@@ -85,14 +94,14 @@ class DTableCustomizeSearchInput extends _react.Component {
85
94
  }
86
95
  UNSAFE_componentWillReceiveProps(nextProps) {
87
96
  if (nextProps.value !== this.props.value) {
97
+ this.clearChangeTimer();
88
98
  this.setState({
89
99
  searchValue: nextProps.value
90
100
  });
91
101
  }
92
102
  }
93
103
  componentWillUnmount() {
94
- this.timer && clearTimeout(this.timer);
95
- this.timer = null;
104
+ this.clearChangeTimer();
96
105
  this.inputRef = null;
97
106
  }
98
107
  render() {
@@ -104,24 +113,19 @@ class DTableCustomizeSearchInput extends _react.Component {
104
113
  _this$props3$disabled = _this$props3.disabled,
105
114
  disabled = _this$props3$disabled === void 0 ? false : _this$props3$disabled,
106
115
  _this$props3$style = _this$props3.style,
107
- style = _this$props3$style === void 0 ? {} : _this$props3$style,
108
- isClearable = _this$props3.isClearable,
109
- _this$props3$isMultip = _this$props3.isMultiple,
110
- isMultiple = _this$props3$isMultip === void 0 ? false : _this$props3$isMultip;
116
+ style = _this$props3$style === void 0 ? {} : _this$props3$style;
111
117
  const searchValue = this.state.searchValue;
112
- const inputWidth = isClearable && searchValue && !isMultiple ? 'calc(100% - 40px)' : '100%';
113
- style.width = inputWidth;
114
118
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
115
119
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
116
120
  type: "text",
117
121
  name: "search-input",
118
122
  value: searchValue,
119
123
  className: (0, _classnames.default)('select-search-control', className),
120
- onChange: this.onChange,
124
+ onChange: this.handleInputChange,
121
125
  autoFocus: autoFocus,
122
126
  placeholder: placeholder,
123
- onCompositionStart: this.onCompositionStart,
124
- onCompositionEnd: this.onCompositionEnd,
127
+ onCompositionStart: this.handleCompositionStart,
128
+ onCompositionEnd: this.handleCompositionEnd,
125
129
  onKeyDown: onKeyDown,
126
130
  disabled: disabled,
127
131
  style: style,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "7.0.13-beta.1",
3
+ "version": "7.0.13",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "5.0.9",