@arcblock/ux 2.9.52 → 2.9.54

Sign up to get free protection for your applications and to get access to all the features.
@@ -45,7 +45,8 @@ export default function Confirm({
45
45
  if (['backdropClick', 'escapeKeyDown'].includes(reason)) {
46
46
  return;
47
47
  }
48
- onCancel();
48
+ e.stopPropagation();
49
+ onCancel(e, reason);
49
50
  });
50
51
  return /*#__PURE__*/_jsx(Dialog, {
51
52
  title: title,
@@ -69,12 +70,18 @@ export default function Confirm({
69
70
  },
70
71
  actions: /*#__PURE__*/_jsxs(_Fragment, {
71
72
  children: [showCancelButton && /*#__PURE__*/_jsx(Button, {
72
- onClick: e => onCancel(e, 'closeButton'),
73
+ onClick: e => {
74
+ e.stopPropagation();
75
+ onCancel(e, 'closeButton');
76
+ },
73
77
  color: "primary",
74
78
  ...cancelButton.props,
75
79
  children: cancelButton.text
76
80
  }), /*#__PURE__*/_jsx(Button, {
77
- onClick: () => onConfirm(),
81
+ onClick: e => {
82
+ e.stopPropagation();
83
+ onConfirm(e);
84
+ },
78
85
  color: "primary",
79
86
  autoFocus: true,
80
87
  ...confirmButton.props,
@@ -44,14 +44,14 @@ const ConfirmHolder = /*#__PURE__*/forwardRef((props, ref) => {
44
44
  reset();
45
45
  }, 300);
46
46
  });
47
- const onCancel = useMemoizedFn(() => {
47
+ const onCancel = useMemoizedFn((e, reason) => {
48
48
  close();
49
- state?.onCancel();
49
+ state?.onCancel(e, reason);
50
50
  }, []);
51
- const onConfirm = useMemoizedFn(async () => {
51
+ const onConfirm = useMemoizedFn(async e => {
52
52
  state.loading = true;
53
53
  try {
54
- await state?.onConfirm(close);
54
+ await state?.onConfirm(close, e);
55
55
  } finally {
56
56
  state.loading = false;
57
57
  }
@@ -7,7 +7,7 @@ import { styled } from '../../Theme';
7
7
  import { NavLink } from './external-link';
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
9
  import { jsxs as _jsxs } from "react/jsx-runtime";
10
- function renderGroup(item) {
10
+ function renderGroup(item, index) {
11
11
  return /*#__PURE__*/_jsxs("li", {
12
12
  className: "layout-sidebar-group",
13
13
  children: [/*#__PURE__*/_jsx("span", {
@@ -16,11 +16,11 @@ function renderGroup(item) {
16
16
  }), /*#__PURE__*/_jsx("ul", {
17
17
  children: item.children.map(renderItem)
18
18
  })]
19
- }, `group-${item.title}`);
19
+ }, `group-${item.title}-${index}`);
20
20
  }
21
- function renderItem(item) {
21
+ function renderItem(item, index) {
22
22
  if (item.children?.length) {
23
- return renderGroup(item);
23
+ return renderGroup(item, index);
24
24
  }
25
25
  const {
26
26
  url,
@@ -50,7 +50,7 @@ function renderItem(item) {
50
50
  children: title
51
51
  })]
52
52
  })
53
- }, url);
53
+ }, `${url}-${index}`);
54
54
  }
55
55
  function Sidebar({
56
56
  links,
@@ -132,7 +132,7 @@ export default function SessionBlocklet({
132
132
  textAlign: 'center',
133
133
  lineHeight: 'normal'
134
134
  },
135
- children: item.title?.zh || item.title
135
+ children: item.title?.[locale] || item.title
136
136
  })]
137
137
  })
138
138
  }, item.id))
@@ -57,7 +57,8 @@ function Confirm(_ref) {
57
57
  if (['backdropClick', 'escapeKeyDown'].includes(reason)) {
58
58
  return;
59
59
  }
60
- onCancel();
60
+ e.stopPropagation();
61
+ onCancel(e, reason);
61
62
  });
62
63
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_dialog.default, _objectSpread(_objectSpread({
63
64
  title: title,
@@ -81,12 +82,18 @@ function Confirm(_ref) {
81
82
  },
82
83
  actions: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
83
84
  children: [showCancelButton && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, _objectSpread(_objectSpread({
84
- onClick: e => onCancel(e, 'closeButton'),
85
+ onClick: e => {
86
+ e.stopPropagation();
87
+ onCancel(e, 'closeButton');
88
+ },
85
89
  color: "primary"
86
90
  }, cancelButton.props), {}, {
87
91
  children: cancelButton.text
88
92
  })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, _objectSpread(_objectSpread({
89
- onClick: () => onConfirm(),
93
+ onClick: e => {
94
+ e.stopPropagation();
95
+ onConfirm(e);
96
+ },
90
97
  color: "primary",
91
98
  autoFocus: true
92
99
  }, confirmButton.props), {}, {
@@ -58,14 +58,14 @@ const ConfirmHolder = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
58
58
  reset();
59
59
  }, 300);
60
60
  });
61
- const onCancel = (0, _ahooks.useMemoizedFn)(() => {
61
+ const onCancel = (0, _ahooks.useMemoizedFn)((e, reason) => {
62
62
  close();
63
- state === null || state === void 0 ? void 0 : state.onCancel();
63
+ state === null || state === void 0 ? void 0 : state.onCancel(e, reason);
64
64
  }, []);
65
- const onConfirm = (0, _ahooks.useMemoizedFn)(async () => {
65
+ const onConfirm = (0, _ahooks.useMemoizedFn)(async e => {
66
66
  state.loading = true;
67
67
  try {
68
- await (state === null || state === void 0 ? void 0 : state.onConfirm(close));
68
+ await (state === null || state === void 0 ? void 0 : state.onConfirm(close, e));
69
69
  } finally {
70
70
  state.loading = false;
71
71
  }
@@ -23,7 +23,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
23
23
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
24
24
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
25
25
  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; }
26
- function renderGroup(item) {
26
+ function renderGroup(item, index) {
27
27
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("li", {
28
28
  className: "layout-sidebar-group",
29
29
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
@@ -32,12 +32,12 @@ function renderGroup(item) {
32
32
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("ul", {
33
33
  children: item.children.map(renderItem)
34
34
  })]
35
- }, "group-".concat(item.title));
35
+ }, "group-".concat(item.title, "-").concat(index));
36
36
  }
37
- function renderItem(item) {
37
+ function renderItem(item, index) {
38
38
  var _item$children;
39
39
  if ((_item$children = item.children) !== null && _item$children !== void 0 && _item$children.length) {
40
- return renderGroup(item);
40
+ return renderGroup(item, index);
41
41
  }
42
42
  const {
43
43
  url,
@@ -70,7 +70,7 @@ function renderItem(item) {
70
70
  children: title
71
71
  })]
72
72
  })
73
- }, url);
73
+ }, "".concat(url, "-").concat(index));
74
74
  }
75
75
  function Sidebar(_ref2) {
76
76
  let {
@@ -148,7 +148,7 @@ function SessionBlocklet(_ref) {
148
148
  textAlign: 'center',
149
149
  lineHeight: 'normal'
150
150
  },
151
- children: ((_item$title = item.title) === null || _item$title === void 0 ? void 0 : _item$title.zh) || item.title
151
+ children: ((_item$title = item.title) === null || _item$title === void 0 ? void 0 : _item$title[locale]) || item.title
152
152
  })]
153
153
  })
154
154
  }, item.id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.9.52",
3
+ "version": "2.9.54",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -358,12 +358,12 @@
358
358
  "@mui/material": "^5.15.0",
359
359
  "react": ">=18.2.0"
360
360
  },
361
- "gitHead": "362391bd55f3b943e59f16dfaaded615c64ecb93",
361
+ "gitHead": "497c6bb83ad04937b3ba6a182e79383889a4562e",
362
362
  "dependencies": {
363
363
  "@arcblock/did-motif": "^1.1.13",
364
- "@arcblock/icons": "^2.9.52",
365
- "@arcblock/nft-display": "^2.9.52",
366
- "@arcblock/react-hooks": "^2.9.52",
364
+ "@arcblock/icons": "^2.9.54",
365
+ "@arcblock/nft-display": "^2.9.54",
366
+ "@arcblock/react-hooks": "^2.9.54",
367
367
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
368
368
  "@emotion/react": "^11.10.4",
369
369
  "@emotion/styled": "^11.10.4",
@@ -47,7 +47,8 @@ export default function Confirm({
47
47
  if (['backdropClick', 'escapeKeyDown'].includes(reason)) {
48
48
  return;
49
49
  }
50
- onCancel();
50
+ e.stopPropagation();
51
+ onCancel(e, reason);
51
52
  });
52
53
 
53
54
  return (
@@ -72,11 +73,24 @@ export default function Confirm({
72
73
  actions={
73
74
  <>
74
75
  {showCancelButton && (
75
- <Button onClick={(e) => onCancel(e, 'closeButton')} color="primary" {...cancelButton.props}>
76
+ <Button
77
+ onClick={(e) => {
78
+ e.stopPropagation();
79
+ onCancel(e, 'closeButton');
80
+ }}
81
+ color="primary"
82
+ {...cancelButton.props}>
76
83
  {cancelButton.text}
77
84
  </Button>
78
85
  )}
79
- <Button onClick={() => onConfirm()} color="primary" autoFocus {...confirmButton.props}>
86
+ <Button
87
+ onClick={(e) => {
88
+ e.stopPropagation();
89
+ onConfirm(e);
90
+ }}
91
+ color="primary"
92
+ autoFocus
93
+ {...confirmButton.props}>
80
94
  {confirmButton.text}
81
95
  </Button>
82
96
  </>
@@ -46,14 +46,14 @@ const ConfirmHolder = forwardRef((props, ref) => {
46
46
  reset();
47
47
  }, 300);
48
48
  });
49
- const onCancel = useMemoizedFn(() => {
49
+ const onCancel = useMemoizedFn((e, reason) => {
50
50
  close();
51
- state?.onCancel();
51
+ state?.onCancel(e, reason);
52
52
  }, []);
53
- const onConfirm = useMemoizedFn(async () => {
53
+ const onConfirm = useMemoizedFn(async (e) => {
54
54
  state.loading = true;
55
55
  try {
56
- await state?.onConfirm(close);
56
+ await state?.onConfirm(close, e);
57
57
  } finally {
58
58
  state.loading = false;
59
59
  }
@@ -6,23 +6,23 @@ import clsx from 'clsx';
6
6
  import { styled } from '../../Theme';
7
7
  import { NavLink } from './external-link';
8
8
 
9
- function renderGroup(item) {
9
+ function renderGroup(item, index) {
10
10
  return (
11
- <li key={`group-${item.title}`} className="layout-sidebar-group">
11
+ <li key={`group-${item.title}-${index}`} className="layout-sidebar-group">
12
12
  <span className="layout-sidebar-group-title">{item.title}</span>
13
13
  <ul>{item.children.map(renderItem)}</ul>
14
14
  </li>
15
15
  );
16
16
  }
17
17
 
18
- function renderItem(item) {
18
+ function renderItem(item, index) {
19
19
  if (item.children?.length) {
20
- return renderGroup(item);
20
+ return renderGroup(item, index);
21
21
  }
22
22
  const { url, icon, title, showBadge, external, active } = item;
23
23
  // external = true 时 link active 状态由传入 links 的调用方决定 (适用于 blocklet ui dashboard 的情况)
24
24
  return (
25
- <li key={url} className="layout-sidebar-item">
25
+ <li key={`${url}-${index}`} className="layout-sidebar-item">
26
26
  <NavLink
27
27
  external={external}
28
28
  to={url}
@@ -136,7 +136,7 @@ export default function SessionBlocklet({ session, locale, size }) {
136
136
  textAlign: 'center',
137
137
  lineHeight: 'normal',
138
138
  }}>
139
- {item.title?.zh || item.title}
139
+ {item.title?.[locale] || item.title}
140
140
  </Typography>
141
141
  </ListItemButton>
142
142
  </ListItem>