@arcblock/ux 2.1.22 → 2.1.23
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/index.js +39 -7
- package/package.json +4 -4
- package/src/Datatable/index.js +107 -6
package/lib/Datatable/index.js
CHANGED
|
@@ -11,12 +11,14 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
11
11
|
|
|
12
12
|
var _muiDatatables = _interopRequireWildcard(require("mui-datatables"));
|
|
13
13
|
|
|
14
|
-
var _styledComponents =
|
|
14
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
15
15
|
|
|
16
16
|
var _isObject = _interopRequireDefault(require("lodash/isObject"));
|
|
17
17
|
|
|
18
18
|
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
19
19
|
|
|
20
|
+
var _get = _interopRequireDefault(require("lodash/get"));
|
|
21
|
+
|
|
20
22
|
var _Empty = _interopRequireDefault(require("../Empty"));
|
|
21
23
|
|
|
22
24
|
var _CustomToolbar = _interopRequireDefault(require("./CustomToolbar"));
|
|
@@ -106,14 +108,17 @@ function ReDatatable(_ref2) {
|
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
const {
|
|
109
|
-
setCellHeaderProps
|
|
111
|
+
setCellHeaderProps,
|
|
112
|
+
setCellProps
|
|
110
113
|
} = tempObj.options;
|
|
111
114
|
|
|
112
|
-
tempObj.options.setCellHeaderProps =
|
|
113
|
-
let cellProps = {
|
|
115
|
+
tempObj.options.setCellHeaderProps = function () {
|
|
116
|
+
let cellProps = {
|
|
117
|
+
className: ''
|
|
118
|
+
}; // Complementing width while inheriting old setCellHeaderProps
|
|
114
119
|
|
|
115
120
|
if (setCellHeaderProps && !setCellHeaderProps.__innerFunc) {
|
|
116
|
-
cellProps = setCellHeaderProps(
|
|
121
|
+
cellProps = _objectSpread(_objectSpread({}, cellProps), setCellHeaderProps(...arguments) || {});
|
|
117
122
|
}
|
|
118
123
|
|
|
119
124
|
if (loading || disabled) {
|
|
@@ -126,17 +131,42 @@ function ReDatatable(_ref2) {
|
|
|
126
131
|
cellProps.width = tempObj.width;
|
|
127
132
|
}
|
|
128
133
|
|
|
134
|
+
if (tempObj.align) {
|
|
135
|
+
cellProps.className = "pc-align-".concat(tempObj.align);
|
|
136
|
+
}
|
|
137
|
+
|
|
129
138
|
return cellProps;
|
|
130
139
|
}; // Prevent memory xie caused by recursive forwarding of setCellHeaderProps functions
|
|
131
140
|
|
|
132
141
|
|
|
133
142
|
tempObj.options.setCellHeaderProps.__innerFunc = 1;
|
|
143
|
+
|
|
144
|
+
if (tempObj.align || tempObj.style) {
|
|
145
|
+
tempObj.options.setCellProps = function () {
|
|
146
|
+
let cellProps = {
|
|
147
|
+
className: ''
|
|
148
|
+
}; // Complementing width while inheriting old setCellHeaderProps
|
|
149
|
+
|
|
150
|
+
if (setCellProps && !setCellProps.__innerFunc) {
|
|
151
|
+
cellProps = _objectSpread(_objectSpread({}, cellProps), setCellProps(...arguments) || {});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (tempObj.align) {
|
|
155
|
+
cellProps.className = "pc-align-".concat(tempObj.align);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return cellProps;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
tempObj.options.setCellProps.__innerFunc = 1;
|
|
162
|
+
}
|
|
163
|
+
|
|
134
164
|
return tempObj;
|
|
135
165
|
}); // Fixing object-type structures
|
|
136
166
|
|
|
137
167
|
const data = originData.map(e => {
|
|
138
168
|
if (!Array.isArray(e) && (0, _isObject.default)(e)) {
|
|
139
|
-
return keys.map(key => e
|
|
169
|
+
return keys.map(key => (0, _get.default)(e, key));
|
|
140
170
|
}
|
|
141
171
|
|
|
142
172
|
return e;
|
|
@@ -303,10 +333,12 @@ function ReDatatable(_ref2) {
|
|
|
303
333
|
});
|
|
304
334
|
}
|
|
305
335
|
|
|
336
|
+
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:right;}}}}.MuiTableCell-body{&.pc-align-center{text-align:center;}&.pc-align-right{text-align:right;}}"]);
|
|
337
|
+
|
|
306
338
|
const TableContainer = _styledComponents.default.div.withConfig({
|
|
307
339
|
displayName: "Datatable__TableContainer",
|
|
308
340
|
componentId: "sc-1ju12vq-0"
|
|
309
|
-
})(["height:100%;> .MuiPaper-root{display:flex;flex-direction:column;height:100%;box-shadow:none;}", "{[class*='MUIDataTableBody-emptyTitle']{padding-left:16px;width:200%;margin-left:-100%;text-align:center;}}&.datatable-stripped{.MuiTableBody-root{tr:nth-of-type(odd){background-color:", ";}}}"], props => props.theme.breakpoints.down('md'), props => props.theme.palette.action.hover);
|
|
341
|
+
})(["height:100%;> .MuiPaper-root{display:flex;flex-direction:column;height:100%;box-shadow:none;}", "{[class*='MUIDataTableBody-emptyTitle']{padding-left:16px;width:200%;margin-left:-100%;text-align:center;}[class*='MUIDataTableBodyCell-simpleCell']{[class*='MUIDataTableBody-emptyTitle']{padding-left:16px;width:100%;margin-left:0;text-align:center;}}}", "{[class*='responsiveSimple']{td.MuiTableCell-body{display:flex;padding-right:0;> div{width:auto;flex:1;&:first-child{flex:0;padding-right:16px;}}}}}", "{", "}", "{[class*='responsiveSimple']{", "}}&.datatable-stripped{.MuiTableBody-root{tr:nth-of-type(odd){background-color:", ";}}}"], props => props.theme.breakpoints.down('md'), props => props.theme.breakpoints.down('sm'), props => props.theme.breakpoints.up('md'), alignCss, props => props.theme.breakpoints.up('sm'), alignCss, props => props.theme.palette.action.hover);
|
|
310
342
|
|
|
311
343
|
const FilterLine = _styledComponents.default.div.withConfig({
|
|
312
344
|
displayName: "Datatable__FilterLine",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/ux",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.23",
|
|
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": "bce078a75dc904ab3bc86ff4d537f00e6503a3c1",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@arcblock/icons": "^2.1.
|
|
58
|
-
"@arcblock/react-hooks": "^2.1.
|
|
57
|
+
"@arcblock/icons": "^2.1.23",
|
|
58
|
+
"@arcblock/react-hooks": "^2.1.23",
|
|
59
59
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
60
60
|
"@emotion/react": "^11.9.0",
|
|
61
61
|
"@emotion/styled": "^11.8.1",
|
package/src/Datatable/index.js
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
import { useEffect, useRef } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import MUIDataTable, { TableFilterList, TableFooter } from 'mui-datatables';
|
|
5
|
-
import styled from 'styled-components';
|
|
5
|
+
import styled, { css } from 'styled-components';
|
|
6
6
|
import isObject from 'lodash/isObject';
|
|
7
7
|
import cloneDeep from 'lodash/cloneDeep';
|
|
8
|
+
import get from 'lodash/get';
|
|
8
9
|
import Empty from '../Empty';
|
|
9
10
|
import CustomToolbar from './CustomToolbar';
|
|
10
11
|
import { DatatableProvide, useDatatableContext } from './DatatableContext';
|
|
@@ -66,13 +67,19 @@ function ReDatatable({
|
|
|
66
67
|
tempObj.options = {};
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
const { setCellHeaderProps } = tempObj.options;
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
const { setCellHeaderProps, setCellProps } = tempObj.options;
|
|
71
|
+
|
|
72
|
+
tempObj.options.setCellHeaderProps = (...args) => {
|
|
73
|
+
let cellProps = {
|
|
74
|
+
className: '',
|
|
75
|
+
};
|
|
72
76
|
|
|
73
77
|
// Complementing width while inheriting old setCellHeaderProps
|
|
74
78
|
if (setCellHeaderProps && !setCellHeaderProps.__innerFunc) {
|
|
75
|
-
cellProps =
|
|
79
|
+
cellProps = {
|
|
80
|
+
...cellProps,
|
|
81
|
+
...(setCellHeaderProps(...args) || {}),
|
|
82
|
+
};
|
|
76
83
|
}
|
|
77
84
|
|
|
78
85
|
if (loading || disabled) {
|
|
@@ -83,19 +90,46 @@ function ReDatatable({
|
|
|
83
90
|
cellProps.width = tempObj.width;
|
|
84
91
|
}
|
|
85
92
|
|
|
93
|
+
if (tempObj.align) {
|
|
94
|
+
cellProps.className = `pc-align-${tempObj.align}`;
|
|
95
|
+
}
|
|
96
|
+
|
|
86
97
|
return cellProps;
|
|
87
98
|
};
|
|
88
99
|
|
|
89
100
|
// Prevent memory xie caused by recursive forwarding of setCellHeaderProps functions
|
|
90
101
|
tempObj.options.setCellHeaderProps.__innerFunc = 1;
|
|
91
102
|
|
|
103
|
+
if (tempObj.align || tempObj.style) {
|
|
104
|
+
tempObj.options.setCellProps = (...args) => {
|
|
105
|
+
let cellProps = {
|
|
106
|
+
className: '',
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// Complementing width while inheriting old setCellHeaderProps
|
|
110
|
+
if (setCellProps && !setCellProps.__innerFunc) {
|
|
111
|
+
cellProps = {
|
|
112
|
+
...cellProps,
|
|
113
|
+
...(setCellProps(...args) || {}),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (tempObj.align) {
|
|
118
|
+
cellProps.className = `pc-align-${tempObj.align}`;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return cellProps;
|
|
122
|
+
};
|
|
123
|
+
tempObj.options.setCellProps.__innerFunc = 1;
|
|
124
|
+
}
|
|
125
|
+
|
|
92
126
|
return tempObj;
|
|
93
127
|
});
|
|
94
128
|
|
|
95
129
|
// Fixing object-type structures
|
|
96
130
|
const data = originData.map((e) => {
|
|
97
131
|
if (!Array.isArray(e) && isObject(e)) {
|
|
98
|
-
return keys.map((key) => e
|
|
132
|
+
return keys.map((key) => get(e, key));
|
|
99
133
|
}
|
|
100
134
|
return e;
|
|
101
135
|
});
|
|
@@ -229,6 +263,41 @@ function ReDatatable({
|
|
|
229
263
|
);
|
|
230
264
|
}
|
|
231
265
|
|
|
266
|
+
const alignCss = css`
|
|
267
|
+
.MuiTableCell-head {
|
|
268
|
+
[class*='MUIDataTableHeadCell-toolButton'] {
|
|
269
|
+
width: 100%;
|
|
270
|
+
> [class*='MUIDataTableHeadCell-sortAction'] {
|
|
271
|
+
width: 100%;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
&.pc-align-center {
|
|
275
|
+
text-align: center;
|
|
276
|
+
[class*='MUIDataTableHeadCell-toolButton'] > [class*='MUIDataTableHeadCell-sortAction'] {
|
|
277
|
+
justify-content: center;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
&.pc-align-right {
|
|
281
|
+
text-align: right;
|
|
282
|
+
[class*='MUIDataTableHeadCell-toolButton'] {
|
|
283
|
+
margin-right: 0;
|
|
284
|
+
padding-right: 0;
|
|
285
|
+
& > [class*='MUIDataTableHeadCell-sortAction'] {
|
|
286
|
+
justify-content: right;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
.MuiTableCell-body {
|
|
292
|
+
&.pc-align-center {
|
|
293
|
+
text-align: center;
|
|
294
|
+
}
|
|
295
|
+
&.pc-align-right {
|
|
296
|
+
text-align: right;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
`;
|
|
300
|
+
|
|
232
301
|
const TableContainer = styled.div`
|
|
233
302
|
height: 100%;
|
|
234
303
|
> .MuiPaper-root {
|
|
@@ -244,6 +313,38 @@ const TableContainer = styled.div`
|
|
|
244
313
|
margin-left: -100%;
|
|
245
314
|
text-align: center;
|
|
246
315
|
}
|
|
316
|
+
[class*='MUIDataTableBodyCell-simpleCell'] {
|
|
317
|
+
[class*='MUIDataTableBody-emptyTitle'] {
|
|
318
|
+
padding-left: 16px;
|
|
319
|
+
width: 100%;
|
|
320
|
+
margin-left: 0;
|
|
321
|
+
text-align: center;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
${(props) => props.theme.breakpoints.down('sm')} {
|
|
326
|
+
[class*='responsiveSimple'] {
|
|
327
|
+
td.MuiTableCell-body {
|
|
328
|
+
display: flex;
|
|
329
|
+
padding-right: 0;
|
|
330
|
+
> div {
|
|
331
|
+
width: auto;
|
|
332
|
+
flex: 1;
|
|
333
|
+
&:first-child {
|
|
334
|
+
flex: 0;
|
|
335
|
+
padding-right: 16px;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
${(props) => props.theme.breakpoints.up('md')} {
|
|
342
|
+
${alignCss}
|
|
343
|
+
}
|
|
344
|
+
${(props) => props.theme.breakpoints.up('sm')} {
|
|
345
|
+
[class*='responsiveSimple'] {
|
|
346
|
+
${alignCss}
|
|
347
|
+
}
|
|
247
348
|
}
|
|
248
349
|
&.datatable-stripped {
|
|
249
350
|
.MuiTableBody-root {
|