@arcblock/ux 2.1.39 → 2.1.42
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.
- package/lib/Datatable/TableSearch.js +1 -1
- package/lib/Datatable/index.js +67 -31
- package/lib/Header/header.js +1 -1
- package/lib/NavMenu/style.js +1 -1
- package/package.json +4 -4
- package/src/Datatable/TableSearch.js +1 -1
- package/src/Datatable/index.js +57 -24
- package/src/Header/header.js +1 -1
- package/src/NavMenu/style.js +1 -1
|
@@ -43,7 +43,7 @@ function TableSearch(_ref) {
|
|
|
43
43
|
searchPlaceholder,
|
|
44
44
|
searchAlwaysOpen
|
|
45
45
|
} = options;
|
|
46
|
-
const [inputExpand, setInputExpand] = (0, _react.useState)(searchOpen || false);
|
|
46
|
+
const [inputExpand, setInputExpand] = (0, _react.useState)(!!searchText || searchOpen || false);
|
|
47
47
|
const [innerSearchText, setInnerSearchText] = (0, _react.useState)('');
|
|
48
48
|
const inputTimer = (0, _react.useRef)(null);
|
|
49
49
|
const {
|
package/lib/Datatable/index.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = Datatable;
|
|
7
|
+
exports.getDurableData = void 0;
|
|
7
8
|
|
|
8
9
|
var _react = require("react");
|
|
9
10
|
|
|
@@ -31,7 +32,7 @@ var _DatatableContext = require("./DatatableContext");
|
|
|
31
32
|
|
|
32
33
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
33
34
|
|
|
34
|
-
const _excluded = ["data", "columns", "locale", "options", "style", "customButtons", "onChange", "loading", "disabled", "stripped", "verticalKeyWidth", "hideTableHeader", "components", "emptyNode"];
|
|
35
|
+
const _excluded = ["data", "columns", "locale", "options", "style", "customButtons", "onChange", "loading", "disabled", "stripped", "verticalKeyWidth", "hideTableHeader", "components", "emptyNode", "durable", "durableKeys"];
|
|
35
36
|
|
|
36
37
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
37
38
|
|
|
@@ -80,7 +81,9 @@ function ReDatatable(_ref2) {
|
|
|
80
81
|
verticalKeyWidth,
|
|
81
82
|
hideTableHeader,
|
|
82
83
|
components,
|
|
83
|
-
emptyNode
|
|
84
|
+
emptyNode,
|
|
85
|
+
durable,
|
|
86
|
+
durableKeys
|
|
84
87
|
} = _ref2,
|
|
85
88
|
rest = _objectWithoutProperties(_ref2, _excluded);
|
|
86
89
|
|
|
@@ -284,43 +287,55 @@ function ReDatatable(_ref2) {
|
|
|
284
287
|
}
|
|
285
288
|
|
|
286
289
|
(0, _react.useEffect)(() => setFilterLabel(textLabels.filter.title), [textLabels.filter.title]);
|
|
290
|
+
const durableData = getDurableData(durable);
|
|
287
291
|
|
|
288
|
-
const opts = _objectSpread({
|
|
292
|
+
const opts = _objectSpread(_objectSpread(_objectSpread({
|
|
289
293
|
selectableRows: 'none',
|
|
290
294
|
textLabels,
|
|
291
295
|
rowsPerPage: 10,
|
|
292
296
|
rowsPerPageOptions: [10, 20, 50]
|
|
293
|
-
}, options)
|
|
297
|
+
}, durableData), options), {}, {
|
|
298
|
+
// Wrap the more friendly onChange callback by listening to onTableChange,
|
|
299
|
+
// which will only be triggered when the table key state changes
|
|
300
|
+
onTableChange: (action, tableState) => {
|
|
301
|
+
if (action === 'propsUpdate') {
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
294
304
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
305
|
+
const state = {
|
|
306
|
+
count: tableState.count,
|
|
307
|
+
page: tableState.page,
|
|
308
|
+
rowsPerPage: tableState.rowsPerPage,
|
|
309
|
+
searchText: tableState.searchText,
|
|
310
|
+
sortOrder: tableState.sortOrder,
|
|
311
|
+
//
|
|
312
|
+
filterList: tableState.filterList
|
|
313
|
+
};
|
|
304
314
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
315
|
+
if (durable) {
|
|
316
|
+
const needSaveState = {};
|
|
317
|
+
durableKeys.forEach(key => {
|
|
318
|
+
needSaveState[key] = state[key];
|
|
319
|
+
});
|
|
320
|
+
localStorage.setItem("datatable-durable-".concat(durable), JSON.stringify(needSaveState));
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const stateStr = JSON.stringify(state);
|
|
324
|
+
|
|
325
|
+
if (stateStr === oldState.current) {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
oldState.current = stateStr;
|
|
319
330
|
|
|
320
|
-
|
|
331
|
+
if (onChange) {
|
|
321
332
|
onChange(state, action);
|
|
322
333
|
}
|
|
323
|
-
}
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
if (onChange) {
|
|
338
|
+
opts.serverSide = true;
|
|
324
339
|
}
|
|
325
340
|
|
|
326
341
|
const props = _objectSpread(_objectSpread({
|
|
@@ -361,7 +376,9 @@ ReDatatable.propTypes = {
|
|
|
361
376
|
verticalKeyWidth: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
362
377
|
hideTableHeader: _propTypes.default.bool,
|
|
363
378
|
components: _propTypes.default.object,
|
|
364
|
-
emptyNode: _propTypes.default.node
|
|
379
|
+
emptyNode: _propTypes.default.node,
|
|
380
|
+
durable: _propTypes.default.string,
|
|
381
|
+
durableKeys: _propTypes.default.array
|
|
365
382
|
};
|
|
366
383
|
ReDatatable.defaultProps = {
|
|
367
384
|
options: {},
|
|
@@ -375,8 +392,27 @@ ReDatatable.defaultProps = {
|
|
|
375
392
|
verticalKeyWidth: '',
|
|
376
393
|
hideTableHeader: false,
|
|
377
394
|
components: {},
|
|
378
|
-
emptyNode: ''
|
|
395
|
+
emptyNode: '',
|
|
396
|
+
durable: '',
|
|
397
|
+
durableKeys: ['page', 'rowsPerPage', 'searchText', 'sortOrder']
|
|
379
398
|
};
|
|
399
|
+
|
|
400
|
+
const getDurableData = key => {
|
|
401
|
+
const durableKey = "datatable-durable-".concat(key);
|
|
402
|
+
let localData = localStorage[durableKey];
|
|
403
|
+
|
|
404
|
+
if (localData) {
|
|
405
|
+
try {
|
|
406
|
+
localData = JSON.parse(localData);
|
|
407
|
+
} catch (err) {
|
|
408
|
+
console.error("parse durable data error (key:".concat(key, ") => "), err);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
return localData || {};
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
exports.getDurableData = getDurableData;
|
|
380
416
|
const alignCss = (0, _styledComponents.css)([".MuiTableCell-head{[class*='MUIDataTableHeadCell-toolButton']{width:100%;> [class*='MUIDataTableHeadCell-sortAction']{width:100%;}}&.pc-align-center{text-align:center;[class*='MUIDataTableHeadCell-toolButton'] > [class*='MUIDataTableHeadCell-sortAction']{justify-content:center;}}&.pc-align-right{text-align:right;[class*='MUIDataTableHeadCell-toolButton']{margin-right:0;padding-right:0;& > [class*='MUIDataTableHeadCell-sortAction']{justify-content:flex-end;}}}}.MuiTableCell-body{&.pc-align-center{text-align:center;}&.pc-align-right{text-align:right;}}"]);
|
|
381
417
|
|
|
382
418
|
const TableContainer = _styledComponents.default.div.withConfig({
|
package/lib/Header/header.js
CHANGED
|
@@ -98,7 +98,7 @@ Header.propTypes = {
|
|
|
98
98
|
// brand 右侧的内容区域, 可显示一个 badge 或 tag
|
|
99
99
|
brandAddon: _propTypes.default.node,
|
|
100
100
|
// brand 下方的描述
|
|
101
|
-
description: _propTypes.default.
|
|
101
|
+
description: _propTypes.default.node,
|
|
102
102
|
children: _propTypes.default.node,
|
|
103
103
|
// 右侧区域, 可以放置 icons/actions/login 等
|
|
104
104
|
addons: _propTypes.default.node,
|
package/lib/NavMenu/style.js
CHANGED
|
@@ -12,7 +12,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
12
12
|
const NavMenuBase = _styledComponents.default.nav.withConfig({
|
|
13
13
|
displayName: "style__NavMenuBase",
|
|
14
14
|
componentId: "sc-2g7isz-0"
|
|
15
|
-
})(["background-color:", ";font-size:
|
|
15
|
+
})(["background-color:", ";font-size:16px;ul{list-style:none;margin:0;padding:0;}.navmenu-item,.navmenu-sub{display:flex;align-items:center;}a{color:inherit;}.navmenu-item,.navmenu-sub{color:", ";}.navmenu-item--active,.navmenu-item:hover,.navmenu-sub--opened{color:", ";}.navmenu-item{position:relative;cursor:pointer;transition:color 0.2s ease-in-out;a{text-decoration:none;white-space:nowrap;}a::before{position:absolute;top:0;right:0;bottom:0;left:0;background-color:transparent;content:'';}}.navmenu-sub{position:relative;cursor:pointer;}.navmenu-item-icon,.navmenu-sub-icon,.navmenu-sub-expand-icon{display:flex;line-height:1;}.navmenu-item-icon,.navmenu-sub-icon{margin-right:4px;}.navmenu-item-icon > *,.navmenu-sub-icon > *{width:auto;height:22px;max-height:22px;font-size:1.5em;}.navmenu-sub-expand-icon{margin-left:8px;> *{width:0.8em;height:0.8em;transition:transform 0.2s ease-in-out;}}"], props => props.$bgColor, props => props.$textColor, props => props.$activeTextColor);
|
|
16
16
|
|
|
17
17
|
const HorizontalStyle = (0, _styledComponents.default)(NavMenuBase).withConfig({
|
|
18
18
|
displayName: "style__HorizontalStyle",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/ux",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.42",
|
|
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": "
|
|
55
|
+
"gitHead": "077fc503a95b41c9fe5d8dab0bc8d50300105e46",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@arcblock/icons": "^2.1.
|
|
58
|
-
"@arcblock/react-hooks": "^2.1.
|
|
57
|
+
"@arcblock/icons": "^2.1.42",
|
|
58
|
+
"@arcblock/react-hooks": "^2.1.42",
|
|
59
59
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
60
60
|
"@emotion/react": "^11.9.0",
|
|
61
61
|
"@emotion/styled": "^11.8.1",
|
|
@@ -11,7 +11,7 @@ import { useDatatableContext } from './DatatableContext';
|
|
|
11
11
|
|
|
12
12
|
export default function TableSearch({ search, options, searchText, searchTextUpdate, searchClose, onSearchOpen }) {
|
|
13
13
|
const { searchOpen, searchPlaceholder, searchAlwaysOpen } = options;
|
|
14
|
-
const [inputExpand, setInputExpand] = useState(searchOpen || false);
|
|
14
|
+
const [inputExpand, setInputExpand] = useState(!!searchText || searchOpen || false);
|
|
15
15
|
const [innerSearchText, setInnerSearchText] = useState('');
|
|
16
16
|
const inputTimer = useRef(null);
|
|
17
17
|
const { loading } = useDatatableContext();
|
package/src/Datatable/index.js
CHANGED
|
@@ -42,6 +42,8 @@ function ReDatatable({
|
|
|
42
42
|
hideTableHeader,
|
|
43
43
|
components,
|
|
44
44
|
emptyNode,
|
|
45
|
+
durable,
|
|
46
|
+
durableKeys,
|
|
45
47
|
...rest
|
|
46
48
|
}) {
|
|
47
49
|
const oldState = useRef(null);
|
|
@@ -216,39 +218,53 @@ function ReDatatable({
|
|
|
216
218
|
|
|
217
219
|
useEffect(() => setFilterLabel(textLabels.filter.title), [textLabels.filter.title]);
|
|
218
220
|
|
|
221
|
+
const durableData = getDurableData(durable);
|
|
222
|
+
|
|
219
223
|
const opts = {
|
|
220
224
|
selectableRows: 'none',
|
|
221
225
|
textLabels,
|
|
222
226
|
rowsPerPage: 10,
|
|
223
227
|
rowsPerPageOptions: [10, 20, 50],
|
|
228
|
+
...durableData,
|
|
224
229
|
...options,
|
|
230
|
+
// Wrap the more friendly onChange callback by listening to onTableChange,
|
|
231
|
+
// which will only be triggered when the table key state changes
|
|
232
|
+
onTableChange: (action, tableState) => {
|
|
233
|
+
if (action === 'propsUpdate') {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
const state = {
|
|
237
|
+
count: tableState.count,
|
|
238
|
+
page: tableState.page,
|
|
239
|
+
rowsPerPage: tableState.rowsPerPage,
|
|
240
|
+
searchText: tableState.searchText,
|
|
241
|
+
sortOrder: tableState.sortOrder, //
|
|
242
|
+
filterList: tableState.filterList,
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
if (durable) {
|
|
246
|
+
const needSaveState = {};
|
|
247
|
+
|
|
248
|
+
durableKeys.forEach((key) => {
|
|
249
|
+
needSaveState[key] = state[key];
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
localStorage.setItem(`datatable-durable-${durable}`, JSON.stringify(needSaveState));
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const stateStr = JSON.stringify(state);
|
|
256
|
+
if (stateStr === oldState.current) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
oldState.current = stateStr;
|
|
260
|
+
if (onChange) {
|
|
261
|
+
onChange(state, action);
|
|
262
|
+
}
|
|
263
|
+
},
|
|
225
264
|
};
|
|
226
265
|
|
|
227
266
|
if (onChange) {
|
|
228
|
-
|
|
229
|
-
serverSide: true,
|
|
230
|
-
// Wrap the more friendly onChange callback by listening to onTableChange,
|
|
231
|
-
// which will only be triggered when the table key state changes
|
|
232
|
-
onTableChange: (action, tableState) => {
|
|
233
|
-
if (action === 'propsUpdate') {
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
const state = {
|
|
237
|
-
count: tableState.count,
|
|
238
|
-
page: tableState.page,
|
|
239
|
-
rowsPerPage: tableState.rowsPerPage,
|
|
240
|
-
searchText: tableState.searchText,
|
|
241
|
-
sortOrder: tableState.sortOrder, //
|
|
242
|
-
filterList: tableState.filterList,
|
|
243
|
-
};
|
|
244
|
-
const stateStr = JSON.stringify(state);
|
|
245
|
-
if (stateStr === oldState.current) {
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
oldState.current = stateStr;
|
|
249
|
-
onChange(state, action);
|
|
250
|
-
},
|
|
251
|
-
});
|
|
267
|
+
opts.serverSide = true;
|
|
252
268
|
}
|
|
253
269
|
|
|
254
270
|
const props = {
|
|
@@ -290,6 +306,8 @@ ReDatatable.propTypes = {
|
|
|
290
306
|
hideTableHeader: PropTypes.bool,
|
|
291
307
|
components: PropTypes.object,
|
|
292
308
|
emptyNode: PropTypes.node,
|
|
309
|
+
durable: PropTypes.string,
|
|
310
|
+
durableKeys: PropTypes.array,
|
|
293
311
|
};
|
|
294
312
|
|
|
295
313
|
ReDatatable.defaultProps = {
|
|
@@ -305,6 +323,21 @@ ReDatatable.defaultProps = {
|
|
|
305
323
|
hideTableHeader: false,
|
|
306
324
|
components: {},
|
|
307
325
|
emptyNode: '',
|
|
326
|
+
durable: '',
|
|
327
|
+
durableKeys: ['page', 'rowsPerPage', 'searchText', 'sortOrder'],
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
export const getDurableData = (key) => {
|
|
331
|
+
const durableKey = `datatable-durable-${key}`;
|
|
332
|
+
let localData = localStorage[durableKey];
|
|
333
|
+
if (localData) {
|
|
334
|
+
try {
|
|
335
|
+
localData = JSON.parse(localData);
|
|
336
|
+
} catch (err) {
|
|
337
|
+
console.error(`parse durable data error (key:${key}) => `, err);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return localData || {};
|
|
308
341
|
};
|
|
309
342
|
|
|
310
343
|
const alignCss = css`
|
package/src/Header/header.js
CHANGED
|
@@ -41,7 +41,7 @@ Header.propTypes = {
|
|
|
41
41
|
// brand 右侧的内容区域, 可显示一个 badge 或 tag
|
|
42
42
|
brandAddon: PropTypes.node,
|
|
43
43
|
// brand 下方的描述
|
|
44
|
-
description: PropTypes.
|
|
44
|
+
description: PropTypes.node,
|
|
45
45
|
children: PropTypes.node,
|
|
46
46
|
// 右侧区域, 可以放置 icons/actions/login 等
|
|
47
47
|
addons: PropTypes.node,
|