@arcblock/ux 2.1.17 → 2.1.18

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.
@@ -37,6 +37,9 @@ function TableSearch(_ref) {
37
37
  onSearchOpen
38
38
  } = _ref;
39
39
  const [inputMode, setInputMode] = (0, _react.useState)(false);
40
+ const [innerSearchText, setInnerSearchText] = (0, _react.useState)('');
41
+ const inputTimer = (0, _react.useRef)(null);
42
+ const searchDebounceTime = options.serverSide && options.searchDebounceTime;
40
43
 
41
44
  const clickSearchIcon = () => {
42
45
  setInputMode(true);
@@ -44,7 +47,19 @@ function TableSearch(_ref) {
44
47
  };
45
48
 
46
49
  const onChange = event => {
47
- searchTextUpdate(event.currentTarget.value);
50
+ const {
51
+ value
52
+ } = event.currentTarget;
53
+
54
+ if (searchDebounceTime) {
55
+ clearTimeout(inputTimer.current);
56
+ setInnerSearchText(value);
57
+ inputTimer.current = setTimeout(() => {
58
+ searchTextUpdate(value);
59
+ }, searchDebounceTime);
60
+ } else {
61
+ searchTextUpdate(value);
62
+ }
48
63
  };
49
64
 
50
65
  const clickClose = () => {
@@ -69,7 +84,7 @@ function TableSearch(_ref) {
69
84
  variant: "standard",
70
85
  spacing: 2,
71
86
  onChange: onChange,
72
- value: searchText || '',
87
+ value: searchDebounceTime ? innerSearchText : searchText || '',
73
88
  autoFocus: true
74
89
  })), /*#__PURE__*/_react.default.createElement("div", {
75
90
  className: "toolbar-search-close ".concat(inputMode ? 'toolbar-btn-show' : '')
@@ -17,6 +17,8 @@ var _isObject = _interopRequireDefault(require("lodash/isObject"));
17
17
 
18
18
  var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
19
19
 
20
+ var _Empty = _interopRequireDefault(require("../Empty"));
21
+
20
22
  var _CustomToolbar = _interopRequireDefault(require("./CustomToolbar"));
21
23
 
22
24
  var _DatatableContext = require("./DatatableContext");
@@ -140,7 +142,7 @@ function ReDatatable(_ref2) {
140
142
  (0, _react.useEffect)(() => setDisabled(disabled), [disabled]);
141
143
  let textLabels = {
142
144
  body: {
143
- noMatch: 'Sorry, no matching records found',
145
+ noMatch: /*#__PURE__*/_react.default.createElement(_Empty.default, null, "Sorry, no matching records found"),
144
146
  toolTip: 'Sort'
145
147
  },
146
148
  pagination: {
@@ -176,7 +178,7 @@ function ReDatatable(_ref2) {
176
178
  if (locale === 'zh') {
177
179
  textLabels = {
178
180
  body: {
179
- noMatch: '对不起,没有找到匹配的记录',
181
+ noMatch: /*#__PURE__*/_react.default.createElement(_Empty.default, null, "\u5BF9\u4E0D\u8D77\uFF0C\u6CA1\u6709\u627E\u5230\u5339\u914D\u7684\u8BB0\u5F55"),
180
182
  toolTip: '排序'
181
183
  },
182
184
  pagination: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.1.17",
3
+ "version": "2.1.18",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -52,10 +52,10 @@
52
52
  "react": ">=18.1.0",
53
53
  "react-ga": "^2.7.0"
54
54
  },
55
- "gitHead": "607634595a2b72ad99cacdc02e6a0070a345368b",
55
+ "gitHead": "5724cf7868e1dcb5d96af8d100f4254546a59442",
56
56
  "dependencies": {
57
- "@arcblock/icons": "^2.1.17",
58
- "@arcblock/react-hooks": "^2.1.17",
57
+ "@arcblock/icons": "^2.1.18",
58
+ "@arcblock/react-hooks": "^2.1.18",
59
59
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
60
60
  "@emotion/react": "^11.9.0",
61
61
  "@emotion/styled": "^11.8.1",
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react';
1
+ import React, { useState, useRef } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import IconButton from '@mui/material/IconButton';
4
4
  import Tooltip from '@mui/material/Tooltip';
@@ -16,6 +16,10 @@ export default function TableSearch({
16
16
  onSearchOpen,
17
17
  }) {
18
18
  const [inputMode, setInputMode] = useState(false);
19
+ const [innerSearchText, setInnerSearchText] = useState('');
20
+ const inputTimer = useRef(null);
21
+
22
+ const searchDebounceTime = options.serverSide && options.searchDebounceTime;
19
23
 
20
24
  const clickSearchIcon = () => {
21
25
  setInputMode(true);
@@ -23,7 +27,16 @@ export default function TableSearch({
23
27
  };
24
28
 
25
29
  const onChange = event => {
26
- searchTextUpdate(event.currentTarget.value);
30
+ const { value } = event.currentTarget;
31
+ if (searchDebounceTime) {
32
+ clearTimeout(inputTimer.current);
33
+ setInnerSearchText(value);
34
+ inputTimer.current = setTimeout(() => {
35
+ searchTextUpdate(value);
36
+ }, searchDebounceTime);
37
+ } else {
38
+ searchTextUpdate(value);
39
+ }
27
40
  };
28
41
 
29
42
  const clickClose = () => {
@@ -56,7 +69,7 @@ export default function TableSearch({
56
69
  variant="standard"
57
70
  spacing={2}
58
71
  onChange={onChange}
59
- value={searchText || ''}
72
+ value={searchDebounceTime ? innerSearchText : searchText || ''}
60
73
  autoFocus
61
74
  />
62
75
  )}
@@ -4,6 +4,7 @@ import MUIDataTable, { TableFilterList, TableFooter } from 'mui-datatables';
4
4
  import styled from 'styled-components';
5
5
  import isObject from 'lodash/isObject';
6
6
  import cloneDeep from 'lodash/cloneDeep';
7
+ import Empty from '../Empty';
7
8
  import CustomToolbar from './CustomToolbar';
8
9
  import { DatatableProvide, useDatatableContext } from './DatatableContext';
9
10
 
@@ -103,7 +104,10 @@ function ReDatatable({
103
104
  useEffect(() => setDisabled(disabled), [disabled]);
104
105
 
105
106
  let textLabels = {
106
- body: { noMatch: 'Sorry, no matching records found', toolTip: 'Sort' },
107
+ body: {
108
+ noMatch: <Empty>Sorry, no matching records found</Empty>,
109
+ toolTip: 'Sort',
110
+ },
107
111
  pagination: {
108
112
  next: 'Next Page',
109
113
  previous: 'Previous Page',
@@ -125,7 +129,7 @@ function ReDatatable({
125
129
 
126
130
  if (locale === 'zh') {
127
131
  textLabels = {
128
- body: { noMatch: '对不起,没有找到匹配的记录', toolTip: '排序' },
132
+ body: { noMatch: <Empty>对不起,没有找到匹配的记录</Empty>, toolTip: '排序' },
129
133
  pagination: {
130
134
  next: '下一页',
131
135
  previous: '上一页',