@arcblock/ux 2.1.21 → 2.1.24

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.
@@ -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 = _interopRequireDefault(require("styled-components"));
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 = columnMeta => {
113
- let cellProps = {}; // Complementing width while inheriting old setCellHeaderProps
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(columnMeta) || {};
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[key]);
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",
@@ -155,7 +155,7 @@ Dashboard.defaultProps = {
155
155
  const Wrapper = _styledComponents.default.div.withConfig({
156
156
  displayName: "dashboard__Wrapper",
157
157
  componentId: "sc-arvc7q-0"
158
- })(["&.dashboard{display:flex;flex-direction:column;height:100vh;}.dashboard-body{overflow:hidden;flex:1;}.dashboard-sidebar{box-sizing:border-box;flex:0 0 auto;width:104px;padding:0 24px;&:hover{overflow-y:auto;}}.dashboard-main{display:flex;flex-direction:column;overflow:auto;flex:1;}.dashboard-content{flex:1;}.dashboard-footer{padding-left:30px;}"]);
158
+ })(["&.dashboard{display:flex;flex-direction:column;height:100vh;}.dashboard-body{overflow:hidden;flex:1;}.dashboard-sidebar{box-sizing:border-box;flex:0 0 auto;width:104px;&:hover{overflow-y:auto;}}.dashboard-main{display:flex;flex-direction:column;overflow:auto;flex:1;}.dashboard-content{flex:1;}.dashboard-footer{padding-left:30px;}"]);
159
159
 
160
160
  const StyledUxHeader = (0, _styledComponents.default)(_Header.ResponsiveHeader).withConfig({
161
161
  displayName: "dashboard__StyledUxHeader",
@@ -83,7 +83,7 @@ const gradient = 'linear-gradient(32deg, rgba(144, 255, 230, 0.1), rgba(144, 255
83
83
  const Root = _styledComponents.default.div.withConfig({
84
84
  displayName: "sidebar__Root",
85
85
  componentId: "sc-gaosgy-0"
86
- })(["display:flex;flex-direction:column;ul{list-style:none;margin:0;padding:0;}.layout-sidebar-link{display:flex;flex-direction:column;align-items:center;padding:16px 0;color:", ";text-decoration:none;&:hover,&.layout-sidebar-link--active{color:", ";background:", ";border-left-color:", ";}}.layout-sidebar-icon{display:inline-block;width:32px;height:32px;> img,> svg{width:32px;height:32px;}}.layout-sidebar-badge{position:relative;&:after{content:'';position:absolute;width:10px;height:10px;border-radius:10px;background-color:#fe4e44;right:-2px;top:0;box-shadow:0px 1px 4px rgba(0,0,0,0.3),0px 0px 20px rgba(0,0,0,0.1);}}.layout-sidebar-link-text{margin-top:8px;font-size:12px;font-weight:500;text-align:center;text-transform:capitalize;letter-spacing:normal;}"], props => props.theme.palette.text.secondary, props => props.theme.palette.primary.main, gradient, _colors.teal.A700);
86
+ })(["display:flex;flex-direction:column;ul{list-style:none;margin:0;padding:0;}.layout-sidebar-link{display:flex;flex-direction:column;align-items:center;padding:22px 24px;color:", ";text-decoration:none;&:hover,&.layout-sidebar-link--active{color:", ";background:", ";border-left-color:", ";}}.layout-sidebar-icon{display:inline-block;width:32px;height:32px;> img,> svg{width:32px;height:32px;}}.layout-sidebar-badge{position:relative;&:after{content:'';position:absolute;width:10px;height:10px;border-radius:10px;background-color:#fe4e44;right:-2px;top:0;box-shadow:0px 1px 4px rgba(0,0,0,0.3),0px 0px 20px rgba(0,0,0,0.1);}}.layout-sidebar-link-text{margin-top:8px;font-size:12px;font-weight:500;text-align:center;text-transform:capitalize;letter-spacing:normal;}"], props => props.theme.palette.text.secondary, props => props.theme.palette.primary.main, gradient, _colors.teal.A700);
87
87
 
88
88
  var _default = Sidebar;
89
89
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.1.21",
3
+ "version": "2.1.24",
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": "ee49a5560e16fa5791cef6ab0cc5930c4f1c2cf5",
55
+ "gitHead": "d299e6578893a3b09be4d0e4421bd2c9cd45eb71",
56
56
  "dependencies": {
57
- "@arcblock/icons": "^2.1.21",
58
- "@arcblock/react-hooks": "^2.1.21",
57
+ "@arcblock/icons": "^2.1.24",
58
+ "@arcblock/react-hooks": "^2.1.24",
59
59
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
60
60
  "@emotion/react": "^11.9.0",
61
61
  "@emotion/styled": "^11.8.1",
@@ -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
- tempObj.options.setCellHeaderProps = (columnMeta) => {
71
- let cellProps = {};
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 = setCellHeaderProps(columnMeta) || {};
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[key]);
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 {
@@ -104,7 +104,6 @@ const Wrapper = styled.div`
104
104
  box-sizing: border-box;
105
105
  flex: 0 0 auto;
106
106
  width: 104px;
107
- padding: 0 24px;
108
107
  &:hover {
109
108
  overflow-y: auto;
110
109
  }
@@ -51,7 +51,7 @@ const Root = styled.div`
51
51
  display: flex;
52
52
  flex-direction: column;
53
53
  align-items: center;
54
- padding: 16px 0;
54
+ padding: 22px 24px;
55
55
  color: ${(props) => props.theme.palette.text.secondary};
56
56
  text-decoration: none;
57
57