@arcblock/ux 2.10.53 → 2.10.55

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.
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { forwardRef, useImperativeHandle, useRef, useState } from 'react';
2
+ import { forwardRef, isValidElement, useImperativeHandle, useRef, useState } from 'react';
3
3
  import { useMemoizedFn, useReactive } from 'ahooks';
4
4
  import noop from 'lodash/noop';
5
5
  import Confirm from './confirm';
@@ -10,8 +10,11 @@ const ConfirmHolder = /*#__PURE__*/forwardRef((props, ref) => {
10
10
  const [content, setContent] = useState('');
11
11
  const state = useReactive({
12
12
  show: false,
13
+ title: '',
14
+ content: '',
13
15
  onConfirm: noop,
14
16
  onCancel: noop,
17
+ // 其他属性
15
18
  loading: false,
16
19
  showCancelButton: true,
17
20
  showCloseButton: true,
@@ -21,8 +24,20 @@ const ConfirmHolder = /*#__PURE__*/forwardRef((props, ref) => {
21
24
  cancelButtonProps: {}
22
25
  });
23
26
  const open = useMemoizedFn((params = {}) => {
24
- setTitle(params.title);
25
- setContent(params.content);
27
+ if (/*#__PURE__*/isValidElement(params.title)) {
28
+ setTitle(params.title);
29
+ state.title = '';
30
+ } else {
31
+ setTitle('');
32
+ state.title = params.title;
33
+ }
34
+ if (/*#__PURE__*/isValidElement(params.content)) {
35
+ setContent(params.content);
36
+ state.content = '';
37
+ } else {
38
+ setContent('');
39
+ state.content = params.content;
40
+ }
26
41
  state.onConfirm = params.onConfirm || noop;
27
42
  state.onCancel = params.onCancel || noop;
28
43
  state.showCloseButton = params.showCloseButton ?? true;
@@ -37,6 +52,8 @@ const ConfirmHolder = /*#__PURE__*/forwardRef((props, ref) => {
37
52
  const reset = useMemoizedFn(() => {
38
53
  setTitle('');
39
54
  setContent('');
55
+ state.title = '';
56
+ state.content = '';
40
57
  state.onConfirm = noop;
41
58
  state.onCancel = noop;
42
59
  state.confirmButtonText = 'Confirm';
@@ -51,8 +68,24 @@ const ConfirmHolder = /*#__PURE__*/forwardRef((props, ref) => {
51
68
  }, 300);
52
69
  });
53
70
  const update = useMemoizedFn(params => {
54
- if (params.title) setTitle(params.title);
55
- if (params.content) setContent(params.content);
71
+ if (params.title) {
72
+ if (/*#__PURE__*/isValidElement(params.title)) {
73
+ setTitle(params.title);
74
+ state.title = '';
75
+ } else {
76
+ setTitle('');
77
+ state.title = params.title;
78
+ }
79
+ }
80
+ if (params.content) {
81
+ if (/*#__PURE__*/isValidElement(params.content)) {
82
+ setContent(params.content);
83
+ state.content = '';
84
+ } else {
85
+ setContent('');
86
+ state.content = params.content;
87
+ }
88
+ }
56
89
  });
57
90
  const onCancel = useMemoizedFn((e, reason) => {
58
91
  close();
@@ -73,10 +106,12 @@ const ConfirmHolder = /*#__PURE__*/forwardRef((props, ref) => {
73
106
  update
74
107
  };
75
108
  }, [open, close, update]);
109
+ const realTitle = title || state.title;
110
+ const realContent = content || state.content;
76
111
  return /*#__PURE__*/_jsx(Confirm, {
77
112
  ...props,
78
113
  open: state.show,
79
- title: title,
114
+ title: realTitle,
80
115
  onConfirm: onConfirm,
81
116
  onCancel: onCancel,
82
117
  confirmButton: {
@@ -98,7 +133,7 @@ const ConfirmHolder = /*#__PURE__*/forwardRef((props, ref) => {
98
133
  ...state.cancelButtonProps
99
134
  }
100
135
  },
101
- children: content
136
+ children: realContent instanceof Function ? realContent() : realContent
102
137
  });
103
138
  });
104
139
  export default function useConfirm(props = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.10.53",
3
+ "version": "2.10.55",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -64,12 +64,12 @@
64
64
  "react": ">=18.2.0",
65
65
  "react-router-dom": ">=6.22.3"
66
66
  },
67
- "gitHead": "a78ffedb0502bf9605989a9494d85dcfe6d1e2d1",
67
+ "gitHead": "dd999d6523d493edc49846772cb6ec23416fba74",
68
68
  "dependencies": {
69
69
  "@arcblock/did-motif": "^1.1.13",
70
- "@arcblock/icons": "^2.10.53",
71
- "@arcblock/nft-display": "^2.10.53",
72
- "@arcblock/react-hooks": "^2.10.53",
70
+ "@arcblock/icons": "^2.10.55",
71
+ "@arcblock/nft-display": "^2.10.55",
72
+ "@arcblock/react-hooks": "^2.10.55",
73
73
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
74
74
  "@fontsource/inter": "^5.0.16",
75
75
  "@fontsource/ubuntu-mono": "^5.0.18",
@@ -1,4 +1,4 @@
1
- import { forwardRef, useImperativeHandle, useRef, useState } from 'react';
1
+ import { forwardRef, isValidElement, useImperativeHandle, useRef, useState } from 'react';
2
2
  import { useMemoizedFn, useReactive } from 'ahooks';
3
3
  import noop from 'lodash/noop';
4
4
 
@@ -11,8 +11,11 @@ const ConfirmHolder = forwardRef((props, ref) => {
11
11
  const [content, setContent] = useState('');
12
12
  const state = useReactive({
13
13
  show: false,
14
+ title: '',
15
+ content: '',
14
16
  onConfirm: noop,
15
17
  onCancel: noop,
18
+ // 其他属性
16
19
  loading: false,
17
20
  showCancelButton: true,
18
21
  showCloseButton: true,
@@ -22,8 +25,20 @@ const ConfirmHolder = forwardRef((props, ref) => {
22
25
  cancelButtonProps: {},
23
26
  });
24
27
  const open = useMemoizedFn((params = {}) => {
25
- setTitle(params.title);
26
- setContent(params.content);
28
+ if (isValidElement(params.title)) {
29
+ setTitle(params.title);
30
+ state.title = '';
31
+ } else {
32
+ setTitle('');
33
+ state.title = params.title;
34
+ }
35
+ if (isValidElement(params.content)) {
36
+ setContent(params.content);
37
+ state.content = '';
38
+ } else {
39
+ setContent('');
40
+ state.content = params.content;
41
+ }
27
42
  state.onConfirm = params.onConfirm || noop;
28
43
  state.onCancel = params.onCancel || noop;
29
44
  state.showCloseButton = params.showCloseButton ?? true;
@@ -39,6 +54,8 @@ const ConfirmHolder = forwardRef((props, ref) => {
39
54
  const reset = useMemoizedFn(() => {
40
55
  setTitle('');
41
56
  setContent('');
57
+ state.title = '';
58
+ state.content = '';
42
59
  state.onConfirm = noop;
43
60
  state.onCancel = noop;
44
61
  state.confirmButtonText = 'Confirm';
@@ -53,8 +70,24 @@ const ConfirmHolder = forwardRef((props, ref) => {
53
70
  }, 300);
54
71
  });
55
72
  const update = useMemoizedFn((params) => {
56
- if (params.title) setTitle(params.title);
57
- if (params.content) setContent(params.content);
73
+ if (params.title) {
74
+ if (isValidElement(params.title)) {
75
+ setTitle(params.title);
76
+ state.title = '';
77
+ } else {
78
+ setTitle('');
79
+ state.title = params.title;
80
+ }
81
+ }
82
+ if (params.content) {
83
+ if (isValidElement(params.content)) {
84
+ setContent(params.content);
85
+ state.content = '';
86
+ } else {
87
+ setContent('');
88
+ state.content = params.content;
89
+ }
90
+ }
58
91
  });
59
92
  const onCancel = useMemoizedFn((e, reason) => {
60
93
  close();
@@ -76,11 +109,14 @@ const ConfirmHolder = forwardRef((props, ref) => {
76
109
  };
77
110
  }, [open, close, update]);
78
111
 
112
+ const realTitle = title || state.title;
113
+ const realContent = content || state.content;
114
+
79
115
  return (
80
116
  <Confirm
81
117
  {...props}
82
118
  open={state.show}
83
- title={title}
119
+ title={realTitle}
84
120
  onConfirm={onConfirm}
85
121
  onCancel={onCancel}
86
122
  confirmButton={{
@@ -102,7 +138,7 @@ const ConfirmHolder = forwardRef((props, ref) => {
102
138
  ...state.cancelButtonProps,
103
139
  },
104
140
  }}>
105
- {content}
141
+ {realContent instanceof Function ? realContent() : realContent}
106
142
  </Confirm>
107
143
  );
108
144
  });