@arcblock/ux 2.1.7 → 2.1.10
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/CustomToolbar.js +38 -18
- package/lib/Datatable/DatatableContext.js +47 -0
- package/lib/Datatable/TableSearch.js +4 -6
- package/lib/Datatable/index.js +190 -37
- package/lib/Footer/index.js +2 -2
- package/lib/Header/header.js +6 -10
- package/lib/Layout/dashboard/header.js +1 -1
- package/lib/Layout/dashboard/index.js +1 -1
- package/lib/NavMenu/style.js +2 -2
- package/package.json +4 -4
- package/src/Datatable/CustomToolbar.js +108 -73
- package/src/Datatable/DatatableContext.js +32 -0
- package/src/Datatable/TableSearch.js +10 -7
- package/src/Datatable/index.js +200 -31
- package/src/Footer/index.js +2 -2
- package/src/Header/header.js +3 -21
- package/src/Layout/dashboard/header.js +1 -1
- package/src/Layout/dashboard/index.js +1 -1
- package/src/NavMenu/style.js +21 -24
|
@@ -43,10 +43,14 @@ var _useMediaQuery = _interopRequireDefault(require("@mui/material/useMediaQuery
|
|
|
43
43
|
|
|
44
44
|
var _styles = require("@mui/material/styles");
|
|
45
45
|
|
|
46
|
+
var _LinearProgress = _interopRequireDefault(require("@mui/material/LinearProgress"));
|
|
47
|
+
|
|
46
48
|
var _utils = require("./utils");
|
|
47
49
|
|
|
48
50
|
var _TableSearch = _interopRequireDefault(require("./TableSearch"));
|
|
49
51
|
|
|
52
|
+
var _DatatableContext = require("./DatatableContext");
|
|
53
|
+
|
|
50
54
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
51
55
|
|
|
52
56
|
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); }
|
|
@@ -63,6 +67,12 @@ function CustomToolbar(props) {
|
|
|
63
67
|
const moreBtn = (0, _react.useRef)(null);
|
|
64
68
|
const isMobile = useMobile();
|
|
65
69
|
const toolbarId = (0, _react.useRef)(Math.random().toString(32).slice(2));
|
|
70
|
+
const [searchOpened, setSearchOpened] = (0, _react.useState)(false);
|
|
71
|
+
const {
|
|
72
|
+
customButtons,
|
|
73
|
+
loading,
|
|
74
|
+
disabled
|
|
75
|
+
} = (0, _DatatableContext.useDatatableContext)();
|
|
66
76
|
const {
|
|
67
77
|
data,
|
|
68
78
|
options,
|
|
@@ -78,9 +88,9 @@ function CustomToolbar(props) {
|
|
|
78
88
|
title,
|
|
79
89
|
searchText,
|
|
80
90
|
searchTextUpdate,
|
|
81
|
-
searchClose
|
|
82
|
-
customButtons
|
|
91
|
+
searchClose
|
|
83
92
|
} = props;
|
|
93
|
+
const customToolbarEle = options.customToolbar ? options.customToolbar(props) : '';
|
|
84
94
|
const {
|
|
85
95
|
search,
|
|
86
96
|
downloadCsv,
|
|
@@ -92,6 +102,11 @@ function CustomToolbar(props) {
|
|
|
92
102
|
const hidePrint = options.print === false || options.print === 'false';
|
|
93
103
|
const TableFilterComponent = components.TableFilter || _muiDatatables.TableFilter;
|
|
94
104
|
const TableViewColComponent = components.TableViewCol || _muiDatatables.TableViewCol;
|
|
105
|
+
(0, _react.useEffect)(() => {
|
|
106
|
+
if (loading || disabled) {
|
|
107
|
+
setAllPopsEl({});
|
|
108
|
+
}
|
|
109
|
+
}, [loading, disabled]);
|
|
95
110
|
|
|
96
111
|
const printArea = func => {
|
|
97
112
|
return /*#__PURE__*/_react.default.createElement(_reactToPrint.default, {
|
|
@@ -101,7 +116,7 @@ function CustomToolbar(props) {
|
|
|
101
116
|
|
|
102
117
|
const getPopId = key => "toolbar-pop-".concat(toolbarId.current, "-").concat(key);
|
|
103
118
|
|
|
104
|
-
const defaultButtons = [];
|
|
119
|
+
const defaultButtons = []; // download/viewColumns/filter button behaviours, rendered using custom button logic
|
|
105
120
|
|
|
106
121
|
if (!(options.download === false || options.download === 'false')) {
|
|
107
122
|
defaultButtons.push({
|
|
@@ -156,7 +171,9 @@ function CustomToolbar(props) {
|
|
|
156
171
|
|
|
157
172
|
const showMore = [!hidePrint, ...defaultButtons, ...customButtons].filter(e => !!e).length > 1 && isMobile;
|
|
158
173
|
const allPops = [];
|
|
159
|
-
const [allPopsEl, setAllPopsEl] = (0, _react.useState)({});
|
|
174
|
+
const [allPopsEl, setAllPopsEl] = (0, _react.useState)({}); // Large screens show the toolbar buttons directly, small screens show the drop-down menu style buttons
|
|
175
|
+
// The right-hand button of the form toolbar in desktop mode
|
|
176
|
+
|
|
160
177
|
const toolbarButtons = [...defaultButtons, ...customButtons].map((e, index) => {
|
|
161
178
|
if ( /*#__PURE__*/(0, _react.isValidElement)(e)) {
|
|
162
179
|
return e;
|
|
@@ -168,7 +185,7 @@ function CustomToolbar(props) {
|
|
|
168
185
|
const {
|
|
169
186
|
Icon,
|
|
170
187
|
popRender
|
|
171
|
-
} = e;
|
|
188
|
+
} = e; // When popRender is present, clicking the button will bubble up the content returned by the popRender
|
|
172
189
|
|
|
173
190
|
if (popRender) {
|
|
174
191
|
allPops.push( /*#__PURE__*/_react.default.createElement(_Popover.default, {
|
|
@@ -198,6 +215,7 @@ function CustomToolbar(props) {
|
|
|
198
215
|
}
|
|
199
216
|
|
|
200
217
|
if (popRender) {
|
|
218
|
+
// On the large screen, the bubble is positioned at the corresponding button
|
|
201
219
|
setAllPopsEl({
|
|
202
220
|
[popId]: document.getElementById("btn-".concat(popId))
|
|
203
221
|
});
|
|
@@ -207,7 +225,8 @@ function CustomToolbar(props) {
|
|
|
207
225
|
}
|
|
208
226
|
|
|
209
227
|
return e;
|
|
210
|
-
});
|
|
228
|
+
}); // The toolbar menu in the mobile to replace toolbarButtons
|
|
229
|
+
|
|
211
230
|
const menuItems = [...defaultButtons, ...customButtons].map((e, index) => {
|
|
212
231
|
const popId = getPopId(index);
|
|
213
232
|
let content;
|
|
@@ -233,6 +252,7 @@ function CustomToolbar(props) {
|
|
|
233
252
|
}
|
|
234
253
|
|
|
235
254
|
if (e.popRender) {
|
|
255
|
+
// On the small screen, the bubbles are positioned at the three dot buttons
|
|
236
256
|
setAllPopsEl({
|
|
237
257
|
[popId]: moreBtn.current
|
|
238
258
|
});
|
|
@@ -241,20 +261,18 @@ function CustomToolbar(props) {
|
|
|
241
261
|
}, content);
|
|
242
262
|
});
|
|
243
263
|
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(Container, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
244
|
-
className: "custom-toobar-title"
|
|
264
|
+
className: "custom-toobar-title ".concat(isMobile && searchOpened && /*#__PURE__*/(0, _react.isValidElement)(title) ? 'toobar-title-hidden' : '')
|
|
245
265
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
246
266
|
className: "custom-toobar-title-inner"
|
|
247
267
|
}, /*#__PURE__*/_react.default.createElement("span", null, title))), /*#__PURE__*/_react.default.createElement("div", {
|
|
248
|
-
className: "custom-toobar-
|
|
249
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
250
|
-
className: "custom-toobar-btns"
|
|
268
|
+
className: "custom-toobar-btns ".concat(loading || disabled ? 'toobar-btns-disabled' : '')
|
|
251
269
|
}, !hideSearch && /*#__PURE__*/_react.default.createElement(_TableSearch.default, {
|
|
252
270
|
search: search,
|
|
253
271
|
options: options,
|
|
254
272
|
searchText: searchText,
|
|
255
273
|
searchTextUpdate: searchTextUpdate,
|
|
256
274
|
searchClose: searchClose,
|
|
257
|
-
|
|
275
|
+
onSearchOpen: setSearchOpened
|
|
258
276
|
}), !showMore && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !hidePrint && printArea(_ref => {
|
|
259
277
|
let {
|
|
260
278
|
handlePrint
|
|
@@ -271,8 +289,11 @@ function CustomToolbar(props) {
|
|
|
271
289
|
ref: moreBtn,
|
|
272
290
|
"aria-haspopup": "true",
|
|
273
291
|
"aria-expanded": menuIconEl ? 'true' : undefined,
|
|
274
|
-
onClick: event => setMenuIconEl(event.currentTarget)
|
|
275
|
-
|
|
292
|
+
onClick: event => setMenuIconEl(event.currentTarget),
|
|
293
|
+
style: {
|
|
294
|
+
flexShrink: 0
|
|
295
|
+
}
|
|
296
|
+
}, /*#__PURE__*/_react.default.createElement(_MoreVert.default, null))), customToolbarEle), /*#__PURE__*/_react.default.createElement(_Menu.default, {
|
|
276
297
|
anchorEl: menuIconEl,
|
|
277
298
|
open: !!menuIconEl,
|
|
278
299
|
onClose: () => setMenuIconEl(null),
|
|
@@ -293,7 +314,7 @@ function CustomToolbar(props) {
|
|
|
293
314
|
})), /*#__PURE__*/_react.default.createElement(_ListItemText.default, null, print));
|
|
294
315
|
}), menuItems), allPops.map((e, index) => /*#__PURE__*/_react.default.createElement("div", {
|
|
295
316
|
key: getPopId(index)
|
|
296
|
-
}, e)));
|
|
317
|
+
}, e)), loading && /*#__PURE__*/_react.default.createElement(_LinearProgress.default, null));
|
|
297
318
|
}
|
|
298
319
|
|
|
299
320
|
CustomToolbar.propTypes = {
|
|
@@ -308,12 +329,11 @@ CustomToolbar.propTypes = {
|
|
|
308
329
|
updateFilterByType: _propTypes.default.func.isRequired,
|
|
309
330
|
toggleViewColumn: _propTypes.default.func.isRequired,
|
|
310
331
|
updateColumns: _propTypes.default.func.isRequired,
|
|
311
|
-
title: _propTypes.default.
|
|
332
|
+
title: _propTypes.default.any,
|
|
312
333
|
searchText: _propTypes.default.any,
|
|
313
334
|
searchTextUpdate: _propTypes.default.func.isRequired,
|
|
314
335
|
searchClose: _propTypes.default.func.isRequired,
|
|
315
|
-
tableRef: _propTypes.default.func.isRequired
|
|
316
|
-
customButtons: _propTypes.default.array.isRequired
|
|
336
|
+
tableRef: _propTypes.default.func.isRequired
|
|
317
337
|
};
|
|
318
338
|
CustomToolbar.defaultProps = {
|
|
319
339
|
data: [],
|
|
@@ -327,4 +347,4 @@ CustomToolbar.defaultProps = {
|
|
|
327
347
|
const Container = _styledComponents.default.div.withConfig({
|
|
328
348
|
displayName: "CustomToolbar__Container",
|
|
329
349
|
componentId: "sc-cvz3dp-0"
|
|
330
|
-
})(["display:flex;align-items:center;height:56px;.custom-toobar
|
|
350
|
+
})(["display:flex;align-items:center;height:56px;.custom-toobar-title{position:relative;flex:1;font-size:18px;font-weight:800;height:56px;transition:all ease 0.3s;&-inner{line-height:56px;width:100%;height:56px;position:absolute;left:0;top:0;span{display:inline-block;max-width:100%;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;}}}.custom-toobar-btns{display:flex;justify-content:center;align-items:center;&.toobar-btns-disabled{position:relative;opacity:0.5;&:after{position:absolute;display:block;z-index:2;width:100%;height:100%;left:0;top:0;content:'';cursor:not-allowed;}}}.toobar-title-hidden{opacity:0;cursor:none;}"]);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DatatableProvide = void 0;
|
|
7
|
+
exports.useDatatableContext = useDatatableContext;
|
|
8
|
+
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
|
|
11
|
+
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); }
|
|
12
|
+
|
|
13
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
|
+
|
|
15
|
+
const DatatableContext = /*#__PURE__*/(0, _react.createContext)({});
|
|
16
|
+
const {
|
|
17
|
+
Provider
|
|
18
|
+
} = DatatableContext; // eslint-disable-next-line react/prop-types
|
|
19
|
+
|
|
20
|
+
const DatatableProvide = _ref => {
|
|
21
|
+
let {
|
|
22
|
+
children
|
|
23
|
+
} = _ref;
|
|
24
|
+
const [customButtons, setCustomButtons] = (0, _react.useState)([]);
|
|
25
|
+
const [loading, setLoading] = (0, _react.useState)(false);
|
|
26
|
+
const [disabled, setDisabled] = (0, _react.useState)(false);
|
|
27
|
+
const [filterLabel, setFilterLabel] = (0, _react.useState)('Filter');
|
|
28
|
+
const value = {
|
|
29
|
+
customButtons,
|
|
30
|
+
setCustomButtons,
|
|
31
|
+
filterLabel,
|
|
32
|
+
setFilterLabel,
|
|
33
|
+
loading,
|
|
34
|
+
setLoading,
|
|
35
|
+
disabled,
|
|
36
|
+
setDisabled
|
|
37
|
+
};
|
|
38
|
+
return /*#__PURE__*/_react.default.createElement(Provider, {
|
|
39
|
+
value: value
|
|
40
|
+
}, children);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
exports.DatatableProvide = DatatableProvide;
|
|
44
|
+
|
|
45
|
+
function useDatatableContext() {
|
|
46
|
+
return (0, _react.useContext)(DatatableContext);
|
|
47
|
+
}
|
|
@@ -34,7 +34,6 @@ function TableSearch(_ref) {
|
|
|
34
34
|
searchText,
|
|
35
35
|
searchTextUpdate,
|
|
36
36
|
searchClose,
|
|
37
|
-
isMobile,
|
|
38
37
|
onSearchOpen
|
|
39
38
|
} = _ref;
|
|
40
39
|
const [inputMode, setInputMode] = (0, _react.useState)(false);
|
|
@@ -55,7 +54,7 @@ function TableSearch(_ref) {
|
|
|
55
54
|
};
|
|
56
55
|
|
|
57
56
|
return /*#__PURE__*/_react.default.createElement(Container, null, inputMode ? /*#__PURE__*/_react.default.createElement("div", {
|
|
58
|
-
className: "toolbar-search-icon-placeholder
|
|
57
|
+
className: "toolbar-search-icon-placeholder"
|
|
59
58
|
}, /*#__PURE__*/_react.default.createElement(_Search.default, null)) : /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
|
|
60
59
|
title: search,
|
|
61
60
|
disableFocusListener: true
|
|
@@ -65,7 +64,7 @@ function TableSearch(_ref) {
|
|
|
65
64
|
disabled: options.search === 'disabled',
|
|
66
65
|
onClick: clickSearchIcon
|
|
67
66
|
}, /*#__PURE__*/_react.default.createElement(_Search.default, null))), /*#__PURE__*/_react.default.createElement("div", {
|
|
68
|
-
className: "toolbar-search-area ".concat(inputMode ? 'toolbar-btn-show' : ''
|
|
67
|
+
className: "toolbar-search-area ".concat(inputMode ? 'toolbar-btn-show' : '')
|
|
69
68
|
}, inputMode && /*#__PURE__*/_react.default.createElement(_TextField.default, {
|
|
70
69
|
variant: "standard",
|
|
71
70
|
spacing: 2,
|
|
@@ -85,8 +84,7 @@ TableSearch.propTypes = {
|
|
|
85
84
|
onSearchOpen: _propTypes.default.func,
|
|
86
85
|
options: _propTypes.default.object.isRequired,
|
|
87
86
|
searchTextUpdate: _propTypes.default.func.isRequired,
|
|
88
|
-
searchClose: _propTypes.default.func.isRequired
|
|
89
|
-
isMobile: _propTypes.default.bool.isRequired
|
|
87
|
+
searchClose: _propTypes.default.func.isRequired
|
|
90
88
|
};
|
|
91
89
|
TableSearch.defaultProps = {
|
|
92
90
|
search: '',
|
|
@@ -97,4 +95,4 @@ TableSearch.defaultProps = {
|
|
|
97
95
|
const Container = _styledComponents.default.div.withConfig({
|
|
98
96
|
displayName: "TableSearch__Container",
|
|
99
97
|
componentId: "sc-43ylue-0"
|
|
100
|
-
})(["display:flex;align-items:center;.toolbar-search-area{width:0;transition:all ease 0.3s;overflow:hidden;.MuiFormControl-root{width:inherit;margin:0 12px;}&.toolbar-btn-show{width:260px;padding-left:8px
|
|
98
|
+
})(["display:flex;align-items:center;.toolbar-search-area{width:0;transition:all ease 0.3s;overflow:hidden;.MuiFormControl-root{width:inherit;margin:0 12px;}&.toolbar-btn-show{width:260px;padding-left:8px;", "{width:200px;}", "{width:180px;}&.small-textfield{width:200px;}}}.toolbar-search-close{width:0;transition:all ease 0.3s;overflow:hidden;&.toolbar-btn-show{width:40px;}}.toolbar-search-icon-placeholder{display:flex;justify-content:center;align-items:center;width:40px;height:40px;}"], props => props.theme.breakpoints.down('md'), props => props.theme.breakpoints.down('sm'));
|
package/lib/Datatable/index.js
CHANGED
|
@@ -13,9 +13,15 @@ var _muiDatatables = _interopRequireWildcard(require("mui-datatables"));
|
|
|
13
13
|
|
|
14
14
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
15
15
|
|
|
16
|
+
var _isObject = _interopRequireDefault(require("lodash/isObject"));
|
|
17
|
+
|
|
18
|
+
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
19
|
+
|
|
16
20
|
var _CustomToolbar = _interopRequireDefault(require("./CustomToolbar"));
|
|
17
21
|
|
|
18
|
-
|
|
22
|
+
var _DatatableContext = require("./DatatableContext");
|
|
23
|
+
|
|
24
|
+
const _excluded = ["data", "columns", "locale", "options", "style", "customButtons", "onChange", "loading", "disabled"];
|
|
19
25
|
|
|
20
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
27
|
|
|
@@ -33,37 +39,104 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
33
39
|
|
|
34
40
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return '';
|
|
48
|
-
};
|
|
42
|
+
function Datatable(_ref) {
|
|
43
|
+
let props = Object.assign({}, _ref);
|
|
44
|
+
return /*#__PURE__*/_react.default.createElement(_DatatableContext.DatatableProvide, null, /*#__PURE__*/_react.default.createElement(ReDatatable, props));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @param {Object} props.options The options of mui-datatable,detail see https://github.com/gregnb/mui-datatables/tree/b8d2eee6af4589d254b40918e5d7e70b1ee4baca
|
|
48
|
+
* @param {Array} props.customButtons Custom buttons for toolbar
|
|
49
|
+
* @param {Function} props.onChange When onChange is present, serverSide mode is activated by default https://github.com/gregnb/mui-datatables/tree/b8d2eee6af4589d254b40918e5d7e70b1ee4baca#remote-data
|
|
50
|
+
* @param {Boolean} props.loading For dynamic data, usually used with onChange
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
49
53
|
|
|
50
|
-
WrapFilterList.propTypes = {
|
|
51
|
-
filterList: _propTypes.default.array
|
|
52
|
-
};
|
|
53
|
-
WrapFilterList.defaultProps = {
|
|
54
|
-
filterList: []
|
|
55
|
-
};
|
|
56
54
|
|
|
57
|
-
function
|
|
55
|
+
function ReDatatable(_ref2) {
|
|
58
56
|
let {
|
|
57
|
+
data: originData,
|
|
58
|
+
columns: originColumns,
|
|
59
59
|
locale,
|
|
60
60
|
options,
|
|
61
61
|
style,
|
|
62
|
-
customButtons
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
customButtons,
|
|
63
|
+
onChange,
|
|
64
|
+
loading,
|
|
65
|
+
disabled
|
|
66
|
+
} = _ref2,
|
|
67
|
+
rest = _objectWithoutProperties(_ref2, _excluded);
|
|
65
68
|
|
|
66
69
|
const container = (0, _react.useRef)(null);
|
|
70
|
+
const oldState = (0, _react.useRef)(null);
|
|
71
|
+
const {
|
|
72
|
+
setCustomButtons,
|
|
73
|
+
setFilterLabel,
|
|
74
|
+
setLoading,
|
|
75
|
+
setDisabled
|
|
76
|
+
} = (0, _DatatableContext.useDatatableContext)();
|
|
77
|
+
const disabledCellStyle = {
|
|
78
|
+
cursor: 'not-allowed',
|
|
79
|
+
pointerEvents: 'none'
|
|
80
|
+
};
|
|
81
|
+
const keys = []; // Convert Columns fields to object sets to support the width function
|
|
82
|
+
|
|
83
|
+
const columns = originColumns.map(e => {
|
|
84
|
+
let tempObj;
|
|
85
|
+
|
|
86
|
+
if (!(0, _isObject.default)(e)) {
|
|
87
|
+
tempObj = {
|
|
88
|
+
label: e,
|
|
89
|
+
name: e
|
|
90
|
+
};
|
|
91
|
+
} else {
|
|
92
|
+
tempObj = (0, _cloneDeep.default)(e);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
keys.push(tempObj.name);
|
|
96
|
+
|
|
97
|
+
if (!tempObj.options) {
|
|
98
|
+
tempObj.options = {};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const {
|
|
102
|
+
setCellHeaderProps
|
|
103
|
+
} = tempObj.options;
|
|
104
|
+
|
|
105
|
+
tempObj.options.setCellHeaderProps = columnMeta => {
|
|
106
|
+
let cellProps = {}; // Complementing width while inheriting old setCellHeaderProps
|
|
107
|
+
|
|
108
|
+
if (setCellHeaderProps && !setCellHeaderProps.__innerFunc) {
|
|
109
|
+
cellProps = setCellHeaderProps(columnMeta) || {};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (loading || disabled) {
|
|
113
|
+
cellProps = _objectSpread(_objectSpread({}, cellProps), {}, {
|
|
114
|
+
style: disabledCellStyle
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (tempObj.width) {
|
|
119
|
+
cellProps.width = tempObj.width;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return cellProps;
|
|
123
|
+
}; // Prevent memory xie caused by recursive forwarding of setCellHeaderProps functions
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
tempObj.options.setCellHeaderProps.__innerFunc = 1;
|
|
127
|
+
return tempObj;
|
|
128
|
+
}); // Fixing object-type structures
|
|
129
|
+
|
|
130
|
+
const data = originData.map(e => {
|
|
131
|
+
if (!Array.isArray(e) && (0, _isObject.default)(e)) {
|
|
132
|
+
return keys.map(key => e[key]);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return e;
|
|
136
|
+
});
|
|
137
|
+
(0, _react.useEffect)(() => setCustomButtons(customButtons || []), [customButtons]);
|
|
138
|
+
(0, _react.useEffect)(() => setLoading(loading), [loading]);
|
|
139
|
+
(0, _react.useEffect)(() => setDisabled(disabled), [disabled]);
|
|
67
140
|
let textLabels = {
|
|
68
141
|
body: {
|
|
69
142
|
noMatch: 'Sorry, no matching records found',
|
|
@@ -136,42 +209,83 @@ function Datatable(_ref) {
|
|
|
136
209
|
};
|
|
137
210
|
}
|
|
138
211
|
|
|
212
|
+
(0, _react.useEffect)(() => setFilterLabel(textLabels.filter.title), [textLabels.filter.title]);
|
|
213
|
+
|
|
139
214
|
const opts = _objectSpread({
|
|
140
215
|
selectableRows: 'none',
|
|
141
|
-
textLabels
|
|
216
|
+
textLabels,
|
|
217
|
+
rowsPerPage: 10,
|
|
218
|
+
rowsPerPageOptions: [10, 20, 50]
|
|
142
219
|
}, options);
|
|
143
220
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
221
|
+
if (onChange) {
|
|
222
|
+
Object.assign(opts, {
|
|
223
|
+
serverSide: true,
|
|
224
|
+
// Wrap the more friendly onChange callback by listening to onTableChange,
|
|
225
|
+
// which will only be triggered when the table key state changes
|
|
226
|
+
onTableChange: (action, tableState) => {
|
|
227
|
+
if (action === 'propsUpdate') {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const state = {
|
|
232
|
+
count: tableState.count,
|
|
233
|
+
page: tableState.page,
|
|
234
|
+
rowsPerPage: tableState.rowsPerPage,
|
|
235
|
+
searchText: tableState.searchText,
|
|
236
|
+
sortOrder: tableState.sortOrder,
|
|
237
|
+
//
|
|
238
|
+
filterList: tableState.filterList
|
|
239
|
+
};
|
|
240
|
+
const stateStr = JSON.stringify(state);
|
|
241
|
+
|
|
242
|
+
if (stateStr === oldState.current) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
oldState.current = stateStr;
|
|
247
|
+
onChange(state, action);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
}
|
|
149
251
|
|
|
150
252
|
const props = _objectSpread(_objectSpread({
|
|
151
253
|
options: opts
|
|
152
254
|
}, rest), {}, {
|
|
153
255
|
components: {
|
|
154
|
-
TableToolbar:
|
|
256
|
+
TableToolbar: _CustomToolbar.default,
|
|
257
|
+
TableFooter: WrapTableFooter,
|
|
155
258
|
TableFilterList: WrapFilterList
|
|
156
259
|
}
|
|
157
260
|
});
|
|
158
261
|
|
|
159
|
-
|
|
262
|
+
ReDatatable.propTypes = {
|
|
263
|
+
data: _propTypes.default.array.isRequired,
|
|
264
|
+
columns: _propTypes.default.array.isRequired,
|
|
160
265
|
options: _propTypes.default.object,
|
|
161
266
|
style: _propTypes.default.object,
|
|
162
267
|
locale: _propTypes.default.string,
|
|
163
|
-
|
|
268
|
+
loading: _propTypes.default.bool,
|
|
269
|
+
disabled: _propTypes.default.bool,
|
|
270
|
+
customButtons: _propTypes.default.array,
|
|
271
|
+
onChange: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.string])
|
|
164
272
|
};
|
|
165
|
-
|
|
273
|
+
ReDatatable.defaultProps = {
|
|
166
274
|
options: {},
|
|
167
275
|
style: {},
|
|
168
276
|
locale: 'en',
|
|
169
|
-
|
|
277
|
+
loading: false,
|
|
278
|
+
disabled: false,
|
|
279
|
+
customButtons: [],
|
|
280
|
+
onChange: ''
|
|
170
281
|
};
|
|
171
282
|
return /*#__PURE__*/_react.default.createElement(TableContainer, {
|
|
172
283
|
ref: container,
|
|
173
284
|
style: style
|
|
174
|
-
}, /*#__PURE__*/_react.default.createElement(_muiDatatables.default,
|
|
285
|
+
}, /*#__PURE__*/_react.default.createElement(_muiDatatables.default, Object.assign({
|
|
286
|
+
data: data,
|
|
287
|
+
columns: columns
|
|
288
|
+
}, props)));
|
|
175
289
|
}
|
|
176
290
|
|
|
177
291
|
const TableContainer = _styledComponents.default.div.withConfig({
|
|
@@ -182,4 +296,43 @@ const TableContainer = _styledComponents.default.div.withConfig({
|
|
|
182
296
|
const FilterLine = _styledComponents.default.div.withConfig({
|
|
183
297
|
displayName: "Datatable__FilterLine",
|
|
184
298
|
componentId: "sc-1ju12vq-1"
|
|
185
|
-
})(["display:flex;align-items:center;.toolbar-filter-content{margin-bottom:8px;}.toolbar-filter-title{font-weight:700;font-size:14px;}"]);
|
|
299
|
+
})(["display:flex;align-items:center;.toolbar-filter-content{margin-bottom:8px;}.toolbar-filter-title{font-weight:700;font-size:14px;}"]);
|
|
300
|
+
|
|
301
|
+
const WrapFilterList = props => {
|
|
302
|
+
const {
|
|
303
|
+
filterLabel
|
|
304
|
+
} = (0, _DatatableContext.useDatatableContext)();
|
|
305
|
+
const hasFilter = !!props.filterList.filter(e => e.length).length;
|
|
306
|
+
|
|
307
|
+
if (hasFilter) {
|
|
308
|
+
return /*#__PURE__*/_react.default.createElement(FilterLine, null, hasFilter && /*#__PURE__*/_react.default.createElement("div", {
|
|
309
|
+
className: "toolbar-filter-title"
|
|
310
|
+
}, filterLabel), /*#__PURE__*/_react.default.createElement("div", {
|
|
311
|
+
className: "toolbar-filter-content"
|
|
312
|
+
}, /*#__PURE__*/_react.default.createElement(_muiDatatables.TableFilterList, props)));
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return '';
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
WrapFilterList.propTypes = {
|
|
319
|
+
filterList: _propTypes.default.array
|
|
320
|
+
};
|
|
321
|
+
WrapFilterList.defaultProps = {
|
|
322
|
+
filterList: []
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
const WrapTableFooter = props => {
|
|
326
|
+
const {
|
|
327
|
+
loading,
|
|
328
|
+
disabled
|
|
329
|
+
} = (0, _DatatableContext.useDatatableContext)();
|
|
330
|
+
return /*#__PURE__*/_react.default.createElement(FooterContainer, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
331
|
+
className: "datatable-footer ".concat(loading || disabled ? 'datatable-footer-disabled' : '')
|
|
332
|
+
}, /*#__PURE__*/_react.default.createElement(_muiDatatables.TableFooter, props)));
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
const FooterContainer = _styledComponents.default.div.withConfig({
|
|
336
|
+
displayName: "Datatable__FooterContainer",
|
|
337
|
+
componentId: "sc-1ju12vq-2"
|
|
338
|
+
})(["display:flex;align-items:center;.datatable-footer{position:relative;margin-left:auto;&.datatable-footer-disabled{position:relative;.MuiTablePagination-root{opacity:0.6;}&:after{position:absolute;display:block;z-index:2;width:100%;height:100%;left:0;top:0;content:'';cursor:not-allowed;}}}"]);
|
package/lib/Footer/index.js
CHANGED
|
@@ -43,7 +43,7 @@ function Footer(props) {
|
|
|
43
43
|
className: "footer-item"
|
|
44
44
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
45
45
|
className: "footer-copy"
|
|
46
|
-
}, "\xA9
|
|
46
|
+
}, "Copyright \xA9 ", copyYear, " "), /*#__PURE__*/_react.default.createElement("span", {
|
|
47
47
|
className: "footer-brand"
|
|
48
48
|
}, brand)), /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
49
49
|
component: "p",
|
|
@@ -68,7 +68,7 @@ Footer.propTypes = {
|
|
|
68
68
|
};
|
|
69
69
|
Footer.defaultProps = {
|
|
70
70
|
dark: false,
|
|
71
|
-
brand: 'ArcBlock Inc.',
|
|
71
|
+
brand: 'ArcBlock, Inc.',
|
|
72
72
|
copyStart: '2017',
|
|
73
73
|
className: '',
|
|
74
74
|
style: {}
|
package/lib/Header/header.js
CHANGED
|
@@ -17,7 +17,7 @@ var _Container = _interopRequireDefault(require("@mui/material/Container"));
|
|
|
17
17
|
|
|
18
18
|
var _useTheme = _interopRequireDefault(require("@mui/styles/useTheme"));
|
|
19
19
|
|
|
20
|
-
const _excluded = ["logo", "brand", "brandAddon", "description", "children", "addons", "prepend"
|
|
20
|
+
const _excluded = ["logo", "brand", "brandAddon", "description", "children", "addons", "prepend"];
|
|
21
21
|
|
|
22
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
23
|
|
|
@@ -37,15 +37,14 @@ function Header(_ref) {
|
|
|
37
37
|
description,
|
|
38
38
|
children,
|
|
39
39
|
addons,
|
|
40
|
-
prepend
|
|
41
|
-
containerComponent: ContainerComponent
|
|
40
|
+
prepend
|
|
42
41
|
} = _ref,
|
|
43
42
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
44
43
|
|
|
45
44
|
const theme = (0, _useTheme.default)();
|
|
46
45
|
return /*#__PURE__*/_react.default.createElement(Root, Object.assign({}, rest, {
|
|
47
46
|
$theme: theme
|
|
48
|
-
}), /*#__PURE__*/_react.default.createElement(
|
|
47
|
+
}), /*#__PURE__*/_react.default.createElement(_Container.default, {
|
|
49
48
|
className: "header-container"
|
|
50
49
|
}, prepend, logo && /*#__PURE__*/_react.default.createElement("div", {
|
|
51
50
|
className: "header-logo"
|
|
@@ -76,9 +75,7 @@ Header.propTypes = {
|
|
|
76
75
|
// 右侧区域, 可以放置 icons/actions/login 等
|
|
77
76
|
addons: _propTypes.default.node,
|
|
78
77
|
// logo 左侧内容
|
|
79
|
-
prepend: _propTypes.default.node
|
|
80
|
-
// 默认使用 mui 的 Container, 如果不想限制 header 内容区域的宽度, 可以设置为 div
|
|
81
|
-
containerComponent: _propTypes.default.elementType
|
|
78
|
+
prepend: _propTypes.default.node
|
|
82
79
|
};
|
|
83
80
|
Header.defaultProps = {
|
|
84
81
|
logo: null,
|
|
@@ -87,14 +84,13 @@ Header.defaultProps = {
|
|
|
87
84
|
description: null,
|
|
88
85
|
children: null,
|
|
89
86
|
addons: null,
|
|
90
|
-
prepend: null
|
|
91
|
-
containerComponent: _Container.default
|
|
87
|
+
prepend: null
|
|
92
88
|
};
|
|
93
89
|
|
|
94
90
|
const Root = _styledComponents.default.div.withConfig({
|
|
95
91
|
displayName: "header__Root",
|
|
96
92
|
componentId: "sc-15qnwg1-0"
|
|
97
|
-
})(["position:relative;z-index:", ";font-size:14px;background:", ";.header-container{display:flex;align-items:center;height:64px;
|
|
93
|
+
})(["position:relative;z-index:", ";font-size:14px;background:", ";.header-container{display:flex;align-items:center;height:64px;}.header-logo{display:inline-flex;justify-content:center;position:relative;height:40px;margin-right:16px;img,svg{width:auto;height:100%;}> a{height:100%;line-height:1;}> a::before{position:absolute;top:0;right:0;bottom:0;left:0;background-color:transparent;content:'';}}.header-brand{display:flex;flex-direction:column;flex-shrink:0;margin-right:16px;.header-brand-title{display:flex;align-items:center;h2{font-size:16px;}.header-brand-addon{margin-left:8px;}}.header-brand-desc{color:#9397a1;}}.header-addons{display:flex;align-items:center;}", "{.header-brand{margin-right:12px;.header-brand-title{h2{font-size:14px;}}}}", "{.header-container{height:56px;}.header-menu{display:inline-block;}.header-logo{height:32px;}.header-brand{display:none;}}"], props => props.$theme.zIndex.drawer + 1, props => props.$theme.palette.common.white, props => props.$theme.breakpoints.down('lg'), props => props.$theme.breakpoints.down('md'));
|
|
98
94
|
|
|
99
95
|
var _default = Header;
|
|
100
96
|
exports.default = _default;
|
|
@@ -108,7 +108,7 @@ Header.propTypes = {
|
|
|
108
108
|
onToggleMenu: _propTypes.default.func.isRequired,
|
|
109
109
|
brand: _propTypes.default.string.isRequired,
|
|
110
110
|
brandAddon: _propTypes.default.object,
|
|
111
|
-
description: _propTypes.default.
|
|
111
|
+
description: _propTypes.default.any.isRequired,
|
|
112
112
|
children: _propTypes.default.any,
|
|
113
113
|
addons: _propTypes.default.any,
|
|
114
114
|
homeUrl: _propTypes.default.string,
|
|
@@ -131,7 +131,7 @@ Dashboard.propTypes = {
|
|
|
131
131
|
links: _propTypes.default.array.isRequired,
|
|
132
132
|
images: _propTypes.default.object.isRequired,
|
|
133
133
|
brandAddon: _propTypes.default.object,
|
|
134
|
-
description: _propTypes.default.
|
|
134
|
+
description: _propTypes.default.any.isRequired,
|
|
135
135
|
headerAddon: _propTypes.default.any,
|
|
136
136
|
prefix: _propTypes.default.string,
|
|
137
137
|
// 兼容旧版的设置,新版使用 fullWidth 进行设置
|
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
|
-
})(["
|
|
15
|
+
})(["background-color:", ";font-size:14px;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 > *{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",
|
|
@@ -24,5 +24,5 @@ exports.HorizontalStyle = HorizontalStyle;
|
|
|
24
24
|
const InlineStyle = (0, _styledComponents.default)(NavMenuBase).withConfig({
|
|
25
25
|
displayName: "style__InlineStyle",
|
|
26
26
|
componentId: "sc-2g7isz-2"
|
|
27
|
-
})([".navmenu-root{display:flex;flex-direction:column;align-items:stretch;}.navmenu-item,.navmenu-sub{padding:0 16px;}.navmenu-root > .navmenu-item,.navmenu-root > .navmenu-sub{
|
|
27
|
+
})([".navmenu-root{display:flex;flex-direction:column;align-items:stretch;}.navmenu-item,.navmenu-sub{padding:0 16px;}& .navmenu-sub{flex-wrap:wrap;}.navmenu-root > .navmenu-item,.navmenu-root > .navmenu-sub{line-height:48px;border-bottom:1px solid #eee;}.navmenu-item-icon,.navmenu-sub-icon{width:32px;margin:0;}.navmenu-sub-expand-icon{margin-left:auto;}.navmenu-sub-container{display:none;flex:1 0 100%;margin:0 -16px;padding-bottom:8px;.navmenu-item,.navmenu-sub{line-height:32px;}}.navmenu-sub-list{padding-left:16px;.navmenu-item,.navmenu-sub{padding-left:32px;font-size:13px;}}.navmenu-root > .navmenu-sub{&.navmenu-sub--opened{background:#eee;}}.navmenu-sub--opened > .navmenu-sub-container{display:block;}"]);
|
|
28
28
|
exports.InlineStyle = InlineStyle;
|