@arcblock/ux 2.9.13 → 2.9.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. package/es/Address/did-address.js +18 -13
  2. package/es/Colors/themes/default.js +0 -1
  3. package/es/Colors/themes/temp.js +10 -1
  4. package/es/ContactForm/index.js +2 -2
  5. package/es/DID/index.js +0 -1
  6. package/es/Dialog/confirm.js +1 -99
  7. package/es/Dialog/dialog.js +4 -7
  8. package/es/Dialog/index.js +1 -1
  9. package/es/Dialog/use-confirm.js +105 -0
  10. package/es/Locale/util.js +10 -5
  11. package/es/NFTDisplay/index.js +0 -1
  12. package/es/Passport/index.js +2 -0
  13. package/es/Passport/passport.js +103 -0
  14. package/es/SessionUser/components/logged-in.js +1 -1
  15. package/es/SessionUser/components/user-info.js +1 -1
  16. package/es/SessionUser/index.js +2 -2
  17. package/es/Tabs/index.js +88 -2
  18. package/es/Util/passport.js +62 -0
  19. package/lib/ActionButton/index.js +6 -7
  20. package/lib/ActivityIndicator/index.js +4 -4
  21. package/lib/Address/compact-text.js +6 -6
  22. package/lib/Address/did-address.js +25 -21
  23. package/lib/Address/index.js +4 -4
  24. package/lib/Address/responsive-did-address.js +4 -4
  25. package/lib/Alert/index.js +5 -6
  26. package/lib/AnimationWaiter/index.js +4 -4
  27. package/lib/Async/index.js +6 -6
  28. package/lib/Avatar/did-motif.js +5 -6
  29. package/lib/Avatar/etherscan-blockies.js +2 -3
  30. package/lib/Avatar/index.js +4 -4
  31. package/lib/Badge/index.js +5 -6
  32. package/lib/Blocklet/blocklet.js +4 -4
  33. package/lib/Blocklet/index.js +3 -4
  34. package/lib/Blocklet/utils.js +3 -5
  35. package/lib/BlockletContext/index.js +1 -2
  36. package/lib/BlockletNFT/index.js +4 -4
  37. package/lib/Button/index.js +1 -2
  38. package/lib/Button/wrap.js +4 -4
  39. package/lib/ButtonGroup/index.js +1 -2
  40. package/lib/ClickToCopy/copy-button.js +4 -4
  41. package/lib/ClickToCopy/index.js +6 -6
  42. package/lib/CodeBlock/LightBox.js +1 -2
  43. package/lib/CodeBlock/index.js +4 -4
  44. package/lib/Colors/themes/default.js +1 -2
  45. package/lib/Colors/themes/temp.js +11 -3
  46. package/lib/ContactForm/index.js +2 -2
  47. package/lib/CookieConsent/index.js +6 -6
  48. package/lib/CountDown/index.js +4 -4
  49. package/lib/DID/index.js +7 -9
  50. package/lib/Datatable/CustomToolbar.js +2 -2
  51. package/lib/Datatable/index.js +49 -49
  52. package/lib/Datatable/utils.js +2 -3
  53. package/lib/Dialog/confirm.js +5 -113
  54. package/lib/Dialog/dialog.js +14 -18
  55. package/lib/Dialog/index.js +3 -4
  56. package/lib/Dialog/use-confirm.js +126 -0
  57. package/lib/Earth/index.js +7 -8
  58. package/lib/Empty/index.js +5 -6
  59. package/lib/Header/auto-hidden.js +5 -6
  60. package/lib/Header/header.js +5 -6
  61. package/lib/Header/responsive-header.js +5 -6
  62. package/lib/Icon/image.js +4 -4
  63. package/lib/Icon/index.js +6 -7
  64. package/lib/Img/index.js +5 -6
  65. package/lib/InfoRow/index.js +5 -6
  66. package/lib/Layout/dashboard/external-link.js +4 -4
  67. package/lib/Layout/dashboard/full-page.js +5 -6
  68. package/lib/Layout/dashboard/index.js +4 -4
  69. package/lib/Layout/dashboard/sidebar.js +5 -6
  70. package/lib/Layout/dashboard-legacy/header.js +4 -4
  71. package/lib/Layout/dashboard-legacy/index.js +4 -4
  72. package/lib/Layout/dashboard-legacy/sidebar.js +4 -4
  73. package/lib/Layout/index.js +4 -4
  74. package/lib/Locale/browser-lang.js +1 -2
  75. package/lib/Locale/context.js +6 -8
  76. package/lib/Locale/languages.js +7 -9
  77. package/lib/Locale/selector.js +4 -4
  78. package/lib/Locale/util.js +12 -11
  79. package/lib/Logo/index.js +4 -4
  80. package/lib/NFTDisplay/aspect-ratio-container.js +5 -6
  81. package/lib/NFTDisplay/broken.js +4 -4
  82. package/lib/NFTDisplay/index.js +5 -7
  83. package/lib/NFTDisplay/svg-embedder/img.js +5 -6
  84. package/lib/NFTDisplay/svg-embedder/inline-svg.js +5 -6
  85. package/lib/NavMenu/nav-menu.js +5 -6
  86. package/lib/NavMenu/style.js +2 -4
  87. package/lib/PageScroller/index.js +6 -7
  88. package/lib/Passport/index.js +9 -0
  89. package/lib/Passport/passport.js +116 -0
  90. package/lib/PoweredByArcBlock/index.js +4 -4
  91. package/lib/PricingTable/PricingPlan.js +1 -2
  92. package/lib/PricingTable/index.js +1 -2
  93. package/lib/QRCode/index.js +5 -6
  94. package/lib/RelativeTime/index.js +4 -4
  95. package/lib/Result/common.js +4 -4
  96. package/lib/Result/index.js +7 -8
  97. package/lib/Result/result.js +5 -6
  98. package/lib/Result/translations.js +2 -3
  99. package/lib/Screenshot/BaseScreenshot/index.js +5 -6
  100. package/lib/Screenshot/BaseScreenshot/shells/Macbook.js +10 -15
  101. package/lib/Screenshot/BaseScreenshot/shells/Phone.js +10 -15
  102. package/lib/Screenshot/index.js +5 -6
  103. package/lib/SessionBlocklet/index.js +4 -4
  104. package/lib/SessionManager/index.js +1 -2
  105. package/lib/SessionUser/components/logged-in.js +5 -5
  106. package/lib/SessionUser/components/session-user-item.js +5 -6
  107. package/lib/SessionUser/components/session-user-switch.js +4 -4
  108. package/lib/SessionUser/components/user-info.js +1 -1
  109. package/lib/SessionUser/index.js +2 -2
  110. package/lib/SessionUser/libs/translation.js +2 -3
  111. package/lib/Spinner/index.js +13 -14
  112. package/lib/SplitButton/index.js +4 -4
  113. package/lib/Switch/index.js +5 -6
  114. package/lib/Tabs/index.js +98 -11
  115. package/lib/Tag/index.js +5 -6
  116. package/lib/TextCollapse/index.js +5 -6
  117. package/lib/Theme/index.js +6 -7
  118. package/lib/Theme/theme.js +6 -8
  119. package/lib/Toast/index.js +12 -13
  120. package/lib/Typography/index.js +4 -4
  121. package/lib/Util/constant.js +10 -20
  122. package/lib/Util/deprecate.js +4 -4
  123. package/lib/Util/index.js +2 -4
  124. package/lib/Util/passport.js +72 -0
  125. package/lib/Util/wallet.js +1 -2
  126. package/lib/Video/index.js +4 -4
  127. package/lib/Wallet/Action.js +4 -4
  128. package/lib/Wallet/Download.js +4 -4
  129. package/lib/WebWalletSWKeeper/index.js +5 -6
  130. package/lib/withTheme/index.js +5 -6
  131. package/lib/withTracker/error_boundary.js +2 -2
  132. package/lib/withTracker/index.js +8 -9
  133. package/package.json +9 -4
  134. package/src/Address/did-address.jsx +15 -12
  135. package/src/Colors/themes/temp.js +9 -0
  136. package/src/Dialog/confirm.jsx +94 -0
  137. package/src/Dialog/{dialog.js → dialog.jsx} +14 -7
  138. package/src/Dialog/index.js +1 -1
  139. package/src/Dialog/use-confirm.jsx +114 -0
  140. package/src/Locale/util.js +12 -5
  141. package/src/Passport/index.jsx +3 -0
  142. package/src/Passport/passport.jsx +99 -0
  143. package/src/SessionUser/components/logged-in.jsx +1 -1
  144. package/src/SessionUser/components/user-info.jsx +1 -1
  145. package/src/SessionUser/index.jsx +1 -1
  146. package/src/Tabs/index.jsx +124 -0
  147. package/src/Util/passport.js +75 -0
  148. package/src/Dialog/confirm.js +0 -201
  149. package/src/Tabs/index.js +0 -45
@@ -1,201 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import { forwardRef, useRef, useImperativeHandle } from 'react';
3
- import { useMemoizedFn, useReactive } from 'ahooks';
4
- import noop from 'lodash/noop';
5
-
6
- import Button from '../Button';
7
- import Dialog from './dialog';
8
-
9
- /**
10
- @typedef {Object} ConfirmProps
11
- @property {boolean} open
12
- @property {React.ReactNode} title
13
- @property {React.ReactNode} children
14
- @property {() => void | Promise<void>} onConfirm
15
- @property {() => void | Promise<void>} onCancel
16
- @property {boolean} [showCancelButton=true]
17
- @property {{text: string, props?: import('../Button/wrap').ButtonProps}} [confirmButton={text: 'Confirm'}]
18
- @property {{text: string, props?: import('../Button/wrap').ButtonProps}} [cancelButton={text: 'Cancel'}]
19
- @property {import('@mui/material').PaperProps} [PaperProps={}]
20
- */
21
-
22
- // 注意排在 {...rest} 之后的 props 优先级更高
23
- /**
24
- *
25
- * @param {ConfirmProps} props
26
- * @returns {import('react').ReactComponentElement}
27
- */
28
- export default function Confirm({
29
- title,
30
- children,
31
- onConfirm,
32
- onCancel,
33
- showCancelButton,
34
- confirmButton,
35
- cancelButton,
36
- PaperProps,
37
- ...rest
38
- }) {
39
- // 去除 dialog 默认的 300 最小高度
40
- PaperProps.style = Object.assign(
41
- {
42
- minHeight: 0,
43
- },
44
- PaperProps.style
45
- );
46
-
47
- return (
48
- <Dialog
49
- title={title}
50
- PaperProps={PaperProps}
51
- {...rest}
52
- onClose={() => onCancel()}
53
- actions={
54
- <>
55
- {showCancelButton && (
56
- <Button onClick={() => onCancel()} color="primary" {...cancelButton.props}>
57
- {cancelButton.text}
58
- </Button>
59
- )}
60
- <Button onClick={() => onConfirm()} color="primary" autoFocus {...confirmButton.props}>
61
- {confirmButton.text}
62
- </Button>
63
- </>
64
- }>
65
- {children}
66
- </Dialog>
67
- );
68
- }
69
-
70
- Confirm.propTypes = {
71
- title: PropTypes.node.isRequired,
72
- children: PropTypes.node.isRequired,
73
- onConfirm: PropTypes.func.isRequired,
74
- onCancel: PropTypes.func.isRequired,
75
- showCancelButton: PropTypes.bool,
76
- // 可以传入 {text: ..., props: ...}
77
- confirmButton: PropTypes.shape({
78
- text: PropTypes.string.isRequired,
79
- props: PropTypes.object,
80
- }),
81
- cancelButton: PropTypes.shape({
82
- text: PropTypes.string.isRequired,
83
- props: PropTypes.object,
84
- }),
85
- PaperProps: PropTypes.object,
86
- };
87
-
88
- Confirm.defaultProps = {
89
- showCancelButton: true,
90
- confirmButton: {
91
- text: 'Confirm',
92
- },
93
- cancelButton: {
94
- text: 'Cancel',
95
- },
96
- PaperProps: {},
97
- };
98
-
99
- const ConfirmHolder = forwardRef((props, ref) => {
100
- const state = useReactive({
101
- show: false,
102
- title: '',
103
- content: '',
104
- onConfirm: noop,
105
- onCancel: noop,
106
- loading: false,
107
- confirmButtonText: 'Confirm',
108
- cancelButtonText: 'Cancel',
109
- });
110
- const open = useMemoizedFn((params = {}) => {
111
- state.show = true;
112
- state.title = params.title;
113
- state.content = params.content;
114
- state.onConfirm = params.onConfirm || noop;
115
- state.onCancel = params.onCancel || noop;
116
- if (params.confirmButtonText) state.confirmButtonText = params.confirmButtonText;
117
- if (params.cancelButtonText) state.cancelButtonText = params.cancelButtonText;
118
- state.loading = false;
119
- });
120
- const reset = useMemoizedFn(() => {
121
- state.title = '';
122
- state.content = '';
123
- state.onConfirm = noop;
124
- state.onCancel = noop;
125
- state.confirmButtonText = 'Confirm';
126
- state.cancelButtonText = 'Cancel';
127
- });
128
- const close = useMemoizedFn(() => {
129
- state.show = false;
130
- setTimeout(() => {
131
- reset();
132
- }, 300);
133
- });
134
- const onCancel = useMemoizedFn(() => {
135
- close();
136
- state?.onCancel();
137
- }, []);
138
- const onConfirm = useMemoizedFn(async () => {
139
- state.loading = true;
140
- try {
141
- await state?.onConfirm(close);
142
- } finally {
143
- state.loading = false;
144
- }
145
- }, []);
146
- useImperativeHandle(
147
- ref,
148
- () => {
149
- return {
150
- open,
151
- close,
152
- };
153
- },
154
- [open, close]
155
- );
156
-
157
- return (
158
- <Confirm
159
- open={state.show}
160
- title={state.title}
161
- onConfirm={onConfirm}
162
- onCancel={onCancel}
163
- confirmButton={{
164
- text: state.confirmButtonText,
165
- props: {
166
- variant: 'contained',
167
- color: 'primary',
168
- loading: state.loading,
169
- },
170
- }}
171
- cancelButton={{
172
- text: state.cancelButtonText,
173
- props: {
174
- variant: 'outlined',
175
- color: 'primary',
176
- },
177
- }}>
178
- {state.content}
179
- </Confirm>
180
- );
181
- });
182
-
183
- export function useConfirm() {
184
- const confirmRef = useRef(null);
185
-
186
- const open = useMemoizedFn((...args) => {
187
- confirmRef.current?.open(...args);
188
- });
189
- const close = useMemoizedFn((...args) => {
190
- confirmRef.current?.close(...args);
191
- });
192
- const confirmApi = {
193
- open,
194
- close,
195
- };
196
-
197
- return {
198
- confirmHolder: <ConfirmHolder ref={confirmRef} />,
199
- confirmApi,
200
- };
201
- }
package/src/Tabs/index.js DELETED
@@ -1,45 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import MuiTabs from '@mui/material/Tabs';
3
- import MuiTab from '@mui/material/Tab';
4
- import { styled } from '../Theme';
5
-
6
- const PREFIX = 'index';
7
-
8
- const classes = {
9
- tabs: `${PREFIX}-tabs`,
10
- tab: `${PREFIX}-tab`,
11
- };
12
-
13
- const StyledMuiTabs = styled(MuiTabs)(({ theme }) => ({
14
- [`& .${classes.tabs}`]: {},
15
-
16
- [`& .${classes.tab}`]: {
17
- fontSize: '0.875rem',
18
- [theme.breakpoints.up('md')]: {
19
- fontSize: '1rem',
20
- },
21
- },
22
- }));
23
-
24
- export default function Tabs({ tabs, current, onChange, ...rest }) {
25
- return (
26
- <StyledMuiTabs
27
- scrollButtons="auto"
28
- variant="scrollable"
29
- value={current}
30
- onChange={(_, newValue) => onChange(newValue)}
31
- indicatorColor="primary"
32
- {...rest}
33
- className={[classes.tabs, rest.className || ''].join(' ')}>
34
- {tabs.map((x) => (
35
- <MuiTab className={classes.tab} key={x.value} value={x.value} label={x.label} icon={x.icon || null} />
36
- ))}
37
- </StyledMuiTabs>
38
- );
39
- }
40
-
41
- Tabs.propTypes = {
42
- tabs: PropTypes.array.isRequired,
43
- current: PropTypes.string.isRequired,
44
- onChange: PropTypes.func.isRequired,
45
- };