@arcblock/ux 2.5.39 → 2.5.41

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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = Datatable;
6
+ exports.default = DataTable;
7
7
  exports.getDurableData = void 0;
8
8
 
9
9
  var _react = require("react");
@@ -56,10 +56,61 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
56
56
 
57
57
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
58
58
 
59
- function Datatable(_ref) {
60
- let props = Object.assign({}, _ref);
59
+ /**
60
+ * @typedef {{
61
+ * icon: import('react').ReactElement,
62
+ * title: string,
63
+ * }} DataTableCustomButton
64
+ */
65
+
66
+ /**
67
+ * @typedef {{
68
+ * name: string,
69
+ * label: string,
70
+ * width?: number,
71
+ * options?: {
72
+ * filter?: boolean,
73
+ * sort?: boolean,
74
+ * customBodyRender?: (value: any) => import('react').ReactElement,
75
+ * customBodyRenderLite?: (index: number) => import('react').ReactElement
76
+ * } & import('mui-datatables').MUIDataTableColumnOptions
77
+ * } & import('mui-datatables').MUIDataTableColumnDef} DataTableColumn
78
+ */
79
+
80
+ /**
81
+ * @typedef {Pick<import('mui-datatables').MUIDataTableState, 'count' | 'page' | 'rowsPerPage' | 'searchText' | 'sortOrder' | 'filterList'>} DataTableState
82
+ */
83
+
84
+ /**
85
+ * @typedef {{
86
+ * data: Array<object | number[] | string[]>,
87
+ * columns: Array<DataTableColumn>,
88
+ * locale?: string,
89
+ * options?: import('mui-datatables').MUIDataTableOptions,
90
+ * style?: import('react').CSSProperties,
91
+ * customButtons?: Array<DataTableCustomButton>,
92
+ * onChange?: (state: DataTableState, action: string) => void | Promise<void>,
93
+ * loading?: boolean,
94
+ * disabled?: boolean,
95
+ * stripped?: boolean,
96
+ * verticalKeyWidth?: number | string,
97
+ * hideTableHeader?: boolean,
98
+ * components?: import('react').ReactElement,
99
+ * emptyNode?: import('react').ReactElement,
100
+ * durable?: string,
101
+ * durableKeys?: 'page' | 'rowsPerPage' | 'searchText' | 'sortOrder'
102
+ * } & import('mui-datatables').MUIDataTableProps} DataTableProps
103
+ */
104
+
105
+ /**
106
+ * @description
107
+ * @export
108
+ * @param {DataTableProps} props
109
+ * @return {import('react').ReactComponentElement}
110
+ */
111
+ function DataTable(props) {
61
112
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_DatatableContext.DatatableProvider, {
62
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ReDatatable, _objectSpread({}, props))
113
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ReDataTable, _objectSpread({}, props))
63
114
  });
64
115
  }
65
116
 
@@ -89,7 +140,7 @@ const fixCellProp = (tempObj, cellProps) => {
89
140
  */
90
141
 
91
142
 
92
- function ReDatatable(_ref2) {
143
+ function ReDataTable(_ref) {
93
144
  let {
94
145
  data: originData,
95
146
  columns: originColumns,
@@ -108,8 +159,8 @@ function ReDatatable(_ref2) {
108
159
  emptyNode,
109
160
  durable,
110
161
  durableKeys
111
- } = _ref2,
112
- rest = _objectWithoutProperties(_ref2, _excluded);
162
+ } = _ref,
163
+ rest = _objectWithoutProperties(_ref, _excluded);
113
164
 
114
165
  const oldState = (0, _react.useRef)(null);
115
166
  const {
@@ -372,7 +423,7 @@ function ReDatatable(_ref2) {
372
423
  });
373
424
  }
374
425
 
375
- ReDatatable.propTypes = {
426
+ ReDataTable.propTypes = {
376
427
  data: _propTypes.default.array.isRequired,
377
428
  columns: _propTypes.default.array.isRequired,
378
429
  options: _propTypes.default.object,
@@ -390,7 +441,7 @@ ReDatatable.propTypes = {
390
441
  durable: _propTypes.default.string,
391
442
  durableKeys: _propTypes.default.array
392
443
  };
393
- ReDatatable.defaultProps = {
444
+ ReDataTable.defaultProps = {
394
445
  options: {},
395
446
  style: {},
396
447
  locale: 'en',
@@ -105,7 +105,7 @@ const getSourceProvider = user => {
105
105
  };
106
106
 
107
107
  function SessionManager(_ref) {
108
- var _session$user, _session$user$avatar, _session$user3, _session$user4;
108
+ var _session$user, _session$user$avatar, _session$user3, _session$user4, _session$user5;
109
109
 
110
110
  let {
111
111
  session,
@@ -228,7 +228,9 @@ function SessionManager(_ref) {
228
228
  args[_key] = arguments[_key];
229
229
  }
230
230
 
231
- logoutOAuth(session, ...args).then(() => {
231
+ logoutOAuth({
232
+ session
233
+ }, ...args).then(() => {
232
234
  onLogout(...args);
233
235
  }).catch(err => {
234
236
  console.error(err);
@@ -355,9 +357,21 @@ function SessionManager(_ref) {
355
357
  size: "small"
356
358
  })
357
359
  })]
358
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Address.default, {
359
- responsive: false,
360
- children: walletDid || session.user.email
360
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
361
+ className: "session-manager-id-list",
362
+ children: [walletDid && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
363
+ className: "session-manager-id-item",
364
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Address.default, {
365
+ responsive: false,
366
+ children: walletDid
367
+ })
368
+ }), (session === null || session === void 0 ? void 0 : (_session$user5 = session.user) === null || _session$user5 === void 0 ? void 0 : _session$user5.email) && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
369
+ className: "session-manager-id-item",
370
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Address.default, {
371
+ responsive: false,
372
+ children: session.user.email
373
+ })
374
+ })]
361
375
  })]
362
376
  }), Array.isArray(menu) && menu.map((menuItem, index) => {
363
377
  const {
@@ -508,7 +522,7 @@ SessionManager.defaultProps = {
508
522
  dark: false,
509
523
  size: 24
510
524
  };
511
- const StyledPopper = (0, _Theme.styled)(_material.Popper)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n z-index: ", ";\n .MuiList-root {\n width: 280px;\n }\n .session-manager-user {\n font-size: 12px;\n flex-direction: column;\n align-items: flex-start;\n padding: 24px 24px 10px;\n }\n .session-manager-user-name {\n font-size: 20px;\n color: ", ";\n font-weight: bold;\n margin-bottom: 10px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n }\n .session-manager-menu-item {\n padding: 18.5px 24px;\n color: #777;\n font-size: 16px;\n &:hover {\n background-color: #fbfbfb;\n }\n }\n .session-manager-menu-icon {\n color: #999;\n margin-right: 16px;\n }\n"])), _ref3 => {
525
+ const StyledPopper = (0, _Theme.styled)(_material.Popper)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n z-index: ", ";\n .MuiList-root {\n width: 280px;\n }\n .session-manager-user {\n font-size: 12px;\n flex-direction: column;\n align-items: flex-start;\n padding: 24px 24px 10px;\n }\n .session-manager-user-name {\n font-size: 20px;\n color: ", ";\n font-weight: bold;\n margin-bottom: 10px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n }\n .session-manager-id-item {\n position: relative;\n padding-left: 8px;\n /* HACK: \u5F53\u524D\u5143\u7D20\u65E2\u662F\u7B2C\u4E00\u4E2A\uFF0C\u4E5F\u662F\u6700\u540E\u4E00\u4E2A\uFF0C\u5373\u53EA\u6709\u4E00\u4E2A\u540C\u7EA7\u5143\u7D20 */\n &:first-of-type:last-of-type {\n padding-left: 0;\n &:before,\n &:after {\n content: unset;\n }\n }\n &:before {\n position: absolute;\n content: '';\n left: 0px;\n top: 50%;\n width: 6px;\n height: 1px;\n background-color: #aeaeae;\n }\n &:not(:last-of-type):after {\n position: absolute;\n content: '';\n left: 0px;\n top: 50%;\n height: 100%;\n width: 1px;\n background-color: #aeaeae;\n }\n }\n .session-manager-menu-item {\n padding: 18.5px 24px;\n color: #777;\n font-size: 16px;\n &:hover {\n background-color: #fbfbfb;\n }\n }\n .session-manager-menu-icon {\n color: #999;\n margin-right: 16px;\n }\n"])), _ref3 => {
512
526
  let {
513
527
  theme
514
528
  } = _ref3;
@@ -144,5 +144,5 @@ SplitButton.defaultProps = {
144
144
  menuButtonProps: {}
145
145
  };
146
146
  SplitButton.Item = _MenuItem.default;
147
- const StyledButtonGroup = (0, _Theme.styled)(_ButtonGroup.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n > .MuiButtonBase-root:last-child {\n min-width: 2em;\n padding-left: 0;\n padding-right: 0;\n }\n"])));
147
+ const StyledButtonGroup = (0, _Theme.styled)(_ButtonGroup.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n > .MuiButtonBase-root:last-of-type {\n min-width: 2em;\n padding-left: 0;\n padding-right: 0;\n }\n"])));
148
148
  const StyledPopper = (0, _Theme.styled)(_Popper.default)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n z-index: ", ";\n .MuiList-root {\n padding: 4px 0;\n }\n .MuiListItem-root {\n padding-top: 4px;\n padding-bottom: 4px;\n }\n"])), props => props.theme.zIndex.tooltip);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.5.39",
3
+ "version": "2.5.41",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -45,11 +45,11 @@
45
45
  "peerDependencies": {
46
46
  "react": ">=18.1.0"
47
47
  },
48
- "gitHead": "04d1c08b749669f4c109c74459d51df49bf361a0",
48
+ "gitHead": "28cc23a804e4a687a1dc60acc5171b025446cbd5",
49
49
  "dependencies": {
50
50
  "@arcblock/did-motif": "^1.1.10",
51
- "@arcblock/icons": "^2.5.39",
52
- "@arcblock/react-hooks": "^2.5.39",
51
+ "@arcblock/icons": "^2.5.41",
52
+ "@arcblock/react-hooks": "^2.5.41",
53
53
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
54
54
  "@emotion/react": "^11.10.4",
55
55
  "@emotion/styled": "^11.10.4",
@@ -10,14 +10,66 @@ import clsx from 'clsx';
10
10
  import CircularProgress from '@mui/material/CircularProgress';
11
11
  import Empty from '../Empty';
12
12
  import CustomToolbar from './CustomToolbar';
13
- import { DatatableProvider, useDatatableContext } from './DatatableContext';
13
+ import { DatatableProvider as DataTableProvider, useDatatableContext } from './DatatableContext';
14
14
  import { styled } from '../Theme';
15
15
 
16
- export default function Datatable({ ...props }) {
16
+ /**
17
+ * @typedef {{
18
+ * icon: import('react').ReactElement,
19
+ * title: string,
20
+ * }} DataTableCustomButton
21
+ */
22
+
23
+ /**
24
+ * @typedef {{
25
+ * name: string,
26
+ * label: string,
27
+ * width?: number,
28
+ * options?: {
29
+ * filter?: boolean,
30
+ * sort?: boolean,
31
+ * customBodyRender?: (value: any) => import('react').ReactElement,
32
+ * customBodyRenderLite?: (index: number) => import('react').ReactElement
33
+ * } & import('mui-datatables').MUIDataTableColumnOptions
34
+ * } & import('mui-datatables').MUIDataTableColumnDef} DataTableColumn
35
+ */
36
+
37
+ /**
38
+ * @typedef {Pick<import('mui-datatables').MUIDataTableState, 'count' | 'page' | 'rowsPerPage' | 'searchText' | 'sortOrder' | 'filterList'>} DataTableState
39
+ */
40
+
41
+ /**
42
+ * @typedef {{
43
+ * data: Array<object | number[] | string[]>,
44
+ * columns: Array<DataTableColumn>,
45
+ * locale?: string,
46
+ * options?: import('mui-datatables').MUIDataTableOptions,
47
+ * style?: import('react').CSSProperties,
48
+ * customButtons?: Array<DataTableCustomButton>,
49
+ * onChange?: (state: DataTableState, action: string) => void | Promise<void>,
50
+ * loading?: boolean,
51
+ * disabled?: boolean,
52
+ * stripped?: boolean,
53
+ * verticalKeyWidth?: number | string,
54
+ * hideTableHeader?: boolean,
55
+ * components?: import('react').ReactElement,
56
+ * emptyNode?: import('react').ReactElement,
57
+ * durable?: string,
58
+ * durableKeys?: 'page' | 'rowsPerPage' | 'searchText' | 'sortOrder'
59
+ * } & import('mui-datatables').MUIDataTableProps} DataTableProps
60
+ */
61
+
62
+ /**
63
+ * @description
64
+ * @export
65
+ * @param {DataTableProps} props
66
+ * @return {import('react').ReactComponentElement}
67
+ */
68
+ export default function DataTable(props) {
17
69
  return (
18
- <DatatableProvider>
19
- <ReDatatable {...props} />
20
- </DatatableProvider>
70
+ <DataTableProvider>
71
+ <ReDataTable {...props} />
72
+ </DataTableProvider>
21
73
  );
22
74
  }
23
75
 
@@ -46,7 +98,7 @@ const fixCellProp = (tempObj, cellProps) => {
46
98
  * @param {Boolean} props.loading For dynamic data, usually used with onChange
47
99
  * @returns
48
100
  */
49
- function ReDatatable({
101
+ function ReDataTable({
50
102
  data: originData,
51
103
  columns: originColumns,
52
104
  locale,
@@ -298,7 +350,7 @@ function ReDatatable({
298
350
  );
299
351
  }
300
352
 
301
- ReDatatable.propTypes = {
353
+ ReDataTable.propTypes = {
302
354
  data: PropTypes.array.isRequired,
303
355
  columns: PropTypes.array.isRequired,
304
356
  options: PropTypes.object,
@@ -317,7 +369,7 @@ ReDatatable.propTypes = {
317
369
  durableKeys: PropTypes.array,
318
370
  };
319
371
 
320
- ReDatatable.defaultProps = {
372
+ ReDataTable.defaultProps = {
321
373
  options: {},
322
374
  style: {},
323
375
  locale: 'en',
@@ -143,7 +143,7 @@ function SessionManager({
143
143
  }
144
144
  function _onLogout() {
145
145
  session.logout((...args) => {
146
- logoutOAuth(session, ...args)
146
+ logoutOAuth({ session }, ...args)
147
147
  .then(() => {
148
148
  onLogout(...args);
149
149
  })
@@ -255,7 +255,18 @@ function SessionManager({
255
255
  />
256
256
  )}
257
257
  </div>
258
- <DidAddress responsive={false}>{walletDid || session.user.email}</DidAddress>
258
+ <div className="session-manager-id-list">
259
+ {walletDid && (
260
+ <div className="session-manager-id-item">
261
+ <DidAddress responsive={false}>{walletDid}</DidAddress>
262
+ </div>
263
+ )}
264
+ {session?.user?.email && (
265
+ <div className="session-manager-id-item">
266
+ <DidAddress responsive={false}>{session.user.email}</DidAddress>
267
+ </div>
268
+ )}
269
+ </div>
259
270
  </div>
260
271
  {Array.isArray(menu) &&
261
272
  menu.map((menuItem, index) => {
@@ -442,6 +453,36 @@ const StyledPopper = styled(Popper)`
442
453
  align-items: center;
443
454
  justify-content: space-between;
444
455
  }
456
+ .session-manager-id-item {
457
+ position: relative;
458
+ padding-left: 8px;
459
+ /* HACK: 当前元素既是第一个,也是最后一个,即只有一个同级元素 */
460
+ &:first-of-type:last-of-type {
461
+ padding-left: 0;
462
+ &:before,
463
+ &:after {
464
+ content: unset;
465
+ }
466
+ }
467
+ &:before {
468
+ position: absolute;
469
+ content: '';
470
+ left: 0px;
471
+ top: 50%;
472
+ width: 6px;
473
+ height: 1px;
474
+ background-color: #aeaeae;
475
+ }
476
+ &:not(:last-of-type):after {
477
+ position: absolute;
478
+ content: '';
479
+ left: 0px;
480
+ top: 50%;
481
+ height: 100%;
482
+ width: 1px;
483
+ background-color: #aeaeae;
484
+ }
485
+ }
445
486
  .session-manager-menu-item {
446
487
  padding: 18.5px 24px;
447
488
  color: #777;
@@ -88,7 +88,7 @@ SplitButton.defaultProps = {
88
88
  SplitButton.Item = MenuItem;
89
89
 
90
90
  const StyledButtonGroup = styled(ButtonGroup)`
91
- > .MuiButtonBase-root:last-child {
91
+ > .MuiButtonBase-root:last-of-type {
92
92
  min-width: 2em;
93
93
  padding-left: 0;
94
94
  padding-right: 0;