@arcblock/ux 2.6.8 → 2.7.0

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.
Files changed (164) hide show
  1. package/babel.config.es.js +12 -0
  2. package/es/ActionButton/index.js +99 -0
  3. package/es/ActivityIndicator/index.js +180 -0
  4. package/es/Address/compact-text.js +105 -0
  5. package/es/Address/did-address.js +211 -0
  6. package/es/Address/index.js +23 -0
  7. package/es/Address/responsive-did-address.js +88 -0
  8. package/es/Alert/index.js +134 -0
  9. package/es/AnimationWaiter/default-animation.json +1 -0
  10. package/es/AnimationWaiter/index.js +239 -0
  11. package/es/Async/index.js +38 -0
  12. package/es/Avatar/did-motif.js +64 -0
  13. package/es/Avatar/etherscan-blockies.js +83 -0
  14. package/es/Avatar/index.js +176 -0
  15. package/es/Badge/index.js +98 -0
  16. package/es/Blocklet/blocklet.js +298 -0
  17. package/es/Blocklet/index.js +4 -0
  18. package/es/Blocklet/utils.js +52 -0
  19. package/es/BlockletNFT/index.js +412 -0
  20. package/es/Button/index.js +8 -0
  21. package/es/Button/wrap.js +140 -0
  22. package/es/ButtonGroup/index.js +6 -0
  23. package/es/CardSelector/index.js +131 -0
  24. package/es/Center/index.js +41 -0
  25. package/es/ClickToCopy/copy-button.js +72 -0
  26. package/es/ClickToCopy/hook.js +39 -0
  27. package/es/ClickToCopy/index.js +93 -0
  28. package/es/CodeBlock/LightBox.js +85 -0
  29. package/es/CodeBlock/index.js +226 -0
  30. package/es/Colors/index.js +2 -0
  31. package/es/Colors/themes/default.js +78 -0
  32. package/es/ContactForm/index.js +230 -0
  33. package/es/CookieConsent/index.js +113 -0
  34. package/es/CountDown/index.js +178 -0
  35. package/es/DID/index.js +105 -0
  36. package/es/Datatable/CustomToolbar.js +396 -0
  37. package/es/Datatable/DatatableContext.js +34 -0
  38. package/es/Datatable/TableSearch.js +165 -0
  39. package/es/Datatable/index.js +627 -0
  40. package/es/Datatable/utils.js +132 -0
  41. package/es/Dialog/confirm.js +90 -0
  42. package/es/Dialog/dialog.js +192 -0
  43. package/es/Dialog/index.js +3 -0
  44. package/es/DidLogo/index.js +31 -0
  45. package/es/DriftBot/index.js +70 -0
  46. package/es/Earth/countries.json +8057 -0
  47. package/es/Earth/index.js +521 -0
  48. package/es/Earth/util.js +51 -0
  49. package/es/Empty/index.js +64 -0
  50. package/es/ErrorBoundary/fallback.js +73 -0
  51. package/es/ErrorBoundary/index.js +1 -0
  52. package/es/Footer/index.js +172 -0
  53. package/es/Header/auto-hidden.js +35 -0
  54. package/es/Header/header.js +211 -0
  55. package/es/Header/index.js +2 -0
  56. package/es/Header/responsive-header.js +111 -0
  57. package/es/Icon/image.js +65 -0
  58. package/es/Icon/index.js +84 -0
  59. package/es/Img/index.js +217 -0
  60. package/es/InfoRow/index.js +87 -0
  61. package/es/Layout/dashboard/external-link.js +58 -0
  62. package/es/Layout/dashboard/full-page.js +53 -0
  63. package/es/Layout/dashboard/index.js +275 -0
  64. package/es/Layout/dashboard/sidebar.js +209 -0
  65. package/es/Layout/dashboard-legacy/header.js +174 -0
  66. package/es/Layout/dashboard-legacy/index.js +149 -0
  67. package/es/Layout/dashboard-legacy/sidebar.js +129 -0
  68. package/es/Layout/index.js +335 -0
  69. package/es/Locale/browser-lang.js +52 -0
  70. package/es/Locale/context.js +114 -0
  71. package/es/Locale/languages.js +60 -0
  72. package/es/Locale/selector.js +180 -0
  73. package/es/Locale/util.js +13 -0
  74. package/es/Logo/images/logo-dark-text.svg +3 -0
  75. package/es/Logo/images/logo-dark-top.svg +6 -0
  76. package/es/Logo/images/logo-light-text.svg +3 -0
  77. package/es/Logo/images/logo-light-top.svg +6 -0
  78. package/es/Logo/index.js +136 -0
  79. package/es/Metric/index.js +132 -0
  80. package/es/NFTDisplay/README.md +59 -0
  81. package/es/NFTDisplay/aspect-ratio-container.js +39 -0
  82. package/es/NFTDisplay/broken.js +18 -0
  83. package/es/NFTDisplay/demo/data/asset-state-display-url.json +7 -0
  84. package/es/NFTDisplay/demo/data/asset-state-gzipped-svg-1-1.json +10 -0
  85. package/es/NFTDisplay/demo/data/asset-state-gzipped-svg-374-130.json +10 -0
  86. package/es/NFTDisplay/demo/data/asset-state-gzipped-svg-with-foreign-object.json +20 -0
  87. package/es/NFTDisplay/demo/data/asset-state-svg.json +29 -0
  88. package/es/NFTDisplay/demo/data/asset-state-url.json +10 -0
  89. package/es/NFTDisplay/index.js +323 -0
  90. package/es/NFTDisplay/loading.js +18 -0
  91. package/es/NFTDisplay/svg-embedder/img.js +45 -0
  92. package/es/NFTDisplay/svg-embedder/inline-svg.js +39 -0
  93. package/es/NavMenu/index.js +2 -0
  94. package/es/NavMenu/nav-menu.js +286 -0
  95. package/es/NavMenu/style.js +176 -0
  96. package/es/PageScroller/index.js +286 -0
  97. package/es/PageScroller/story/FifthComponent.js +9 -0
  98. package/es/PageScroller/story/FirstComponent.js +9 -0
  99. package/es/PageScroller/story/FourthComponent.js +12 -0
  100. package/es/PageScroller/story/FullPage.js +47 -0
  101. package/es/PageScroller/story/PageContain.js +59 -0
  102. package/es/PageScroller/story/SecondComponent.js +9 -0
  103. package/es/PageScroller/story/ThirdComponent.js +9 -0
  104. package/es/PageScroller/story/index.css +115 -0
  105. package/es/PageScroller/usePrevValue.js +9 -0
  106. package/es/PricingTable/PricingPlan.js +124 -0
  107. package/es/PricingTable/index.js +53 -0
  108. package/es/QRCode/index.js +72 -0
  109. package/es/RelativeTime/index.js +98 -0
  110. package/es/Result/common.js +140 -0
  111. package/es/Result/demo/fixtures/result-image-404.svg +1 -0
  112. package/es/Result/index.js +33 -0
  113. package/es/Result/result.js +59 -0
  114. package/es/Result/translations.js +54 -0
  115. package/es/Screenshot/BaseScreenshot/index.js +91 -0
  116. package/es/Screenshot/BaseScreenshot/shells/Macbook.js +51 -0
  117. package/es/Screenshot/BaseScreenshot/shells/Phone.js +36 -0
  118. package/es/Screenshot/demo/images/bg-00.jpg +0 -0
  119. package/es/Screenshot/demo/images/bg-01.jpg +0 -0
  120. package/es/Screenshot/demo/images/bg-02.jpg +0 -0
  121. package/es/Screenshot/demo/images/bg-03.jpg +0 -0
  122. package/es/Screenshot/demo/images/bg-04.jpg +0 -0
  123. package/es/Screenshot/demo/images/bg-05.jpg +0 -0
  124. package/es/Screenshot/demo/images/bg-06.jpg +0 -0
  125. package/es/Screenshot/demo/images/bg-07.jpg +0 -0
  126. package/es/Screenshot/demo/images/bg-08.jpg +0 -0
  127. package/es/Screenshot/demo/images/bg-09.jpg +0 -0
  128. package/es/Screenshot/devices.css +1366 -0
  129. package/es/Screenshot/index.js +299 -0
  130. package/es/SessionManager/federated-login-detecter.js +166 -0
  131. package/es/SessionManager/index.js +468 -0
  132. package/es/SessionManager/user-popper.js +132 -0
  133. package/es/Sparkline/index.js +193 -0
  134. package/es/Spinner/index.js +28 -0
  135. package/es/SplitButton/index.js +144 -0
  136. package/es/Switch/index.js +96 -0
  137. package/es/Tabs/index.js +48 -0
  138. package/es/Tag/index.js +108 -0
  139. package/es/TextCollapse/index.js +92 -0
  140. package/es/Theme/index.js +16 -0
  141. package/es/Theme/theme-provider.js +39 -0
  142. package/es/Theme/theme.js +133 -0
  143. package/es/Toast/index.js +95 -0
  144. package/es/Util/deprecate.js +28 -0
  145. package/es/Util/index.js +298 -0
  146. package/es/Util/wallet.js +32 -0
  147. package/es/Video/index.js +89 -0
  148. package/es/Wallet/Action.js +119 -0
  149. package/es/Wallet/Download.js +331 -0
  150. package/es/Wallet/Open.js +45 -0
  151. package/es/Wallet/images/abtwallet.png +0 -0
  152. package/es/Wallet/images/android_download.svg +23 -0
  153. package/es/Wallet/images/app-store.svg +20 -0
  154. package/es/Wallet/images/google-play.svg +70 -0
  155. package/es/WebWalletSWKeeper/index.js +115 -0
  156. package/es/WechatPrompt/images/android.png +0 -0
  157. package/es/WechatPrompt/images/ios.png +0 -0
  158. package/es/WechatPrompt/index.js +88 -0
  159. package/es/index.js +38 -0
  160. package/es/withTheme/index.js +69 -0
  161. package/es/withTracker/README.md +34 -0
  162. package/es/withTracker/error_boundary.js +34 -0
  163. package/es/withTracker/index.js +56 -0
  164. package/package.json +272 -5
@@ -0,0 +1,172 @@
1
+ /* eslint-disable react/no-unused-prop-types */
2
+ import PropTypes from 'prop-types';
3
+ import Typography from '@mui/material/Typography';
4
+ import MuiContainer from '@mui/material/Container';
5
+ import Box from '@mui/material/Box';
6
+ import { mergeProps } from '../Util';
7
+ import Logo from '../Logo';
8
+ import { styled } from '../Theme';
9
+ import { jsxs as _jsxs } from "react/jsx-runtime";
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ export default function Footer(props) {
12
+ const newProps = mergeProps(props, Footer, ['dark', 'style']);
13
+ const {
14
+ className,
15
+ copyStart,
16
+ style,
17
+ brand,
18
+ dark,
19
+ addon
20
+ } = newProps;
21
+ const endYearString = `${new Date().getFullYear()}`;
22
+ const copyStartString = `${copyStart}`;
23
+ const copyYear = endYearString === copyStartString ? endYearString : `${copyStartString}-${endYearString}`;
24
+ return /*#__PURE__*/_jsxs(Container, {
25
+ className: className,
26
+ style: style,
27
+ dark: dark,
28
+ children: [/*#__PURE__*/_jsx(MuiContainer, {
29
+ maxWidth: false,
30
+ children: /*#__PURE__*/_jsxs(Typography, {
31
+ component: "div",
32
+ className: "footer",
33
+ children: [/*#__PURE__*/_jsxs(Typography, {
34
+ component: "p",
35
+ className: "footer-item",
36
+ children: [/*#__PURE__*/_jsxs("span", {
37
+ className: "footer-copy",
38
+ children: ["Copyright \xA9 ", copyYear, " "]
39
+ }), /*#__PURE__*/_jsx("span", {
40
+ className: "footer-brand",
41
+ children: brand
42
+ })]
43
+ }), addon && /*#__PURE__*/_jsx(Typography, {
44
+ component: "div",
45
+ className: "footer-item",
46
+ sx: {
47
+ order: {
48
+ xs: '-1',
49
+ md: 'initial'
50
+ },
51
+ ml: {
52
+ xs: 0,
53
+ md: 'auto'
54
+ },
55
+ width: {
56
+ xs: '100%',
57
+ md: 'auto'
58
+ }
59
+ },
60
+ children: addon
61
+ }), /*#__PURE__*/_jsxs(Typography, {
62
+ component: "p",
63
+ className: "footer-item",
64
+ style: {
65
+ justifyContent: 'flex-end',
66
+ flexShrink: 0
67
+ },
68
+ children: ["Powered by", /*#__PURE__*/_jsx(Logo, {
69
+ mode: dark ? 'light' : 'dark',
70
+ layout: "horizontal",
71
+ className: "logo-container"
72
+ })]
73
+ })]
74
+ })
75
+ }), /*#__PURE__*/_jsx(Box, {
76
+ position: "absolute",
77
+ right: 16,
78
+ bottom: 0,
79
+ fontSize: 12,
80
+ sx: {
81
+ color: 'transparent',
82
+ '::selection': {
83
+ background: '#000',
84
+ color: '#fff'
85
+ }
86
+ },
87
+ children: window?.blocklet?.version
88
+ })]
89
+ });
90
+ }
91
+ Footer.propTypes = {
92
+ dark: PropTypes.bool,
93
+ className: PropTypes.string,
94
+ copyStart: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
95
+ brand: PropTypes.string,
96
+ style: PropTypes.object,
97
+ addon: PropTypes.node
98
+ };
99
+ Footer.defaultProps = {
100
+ dark: false,
101
+ brand: 'ArcBlock, Inc.',
102
+ copyStart: '2017',
103
+ className: '',
104
+ style: {},
105
+ addon: null
106
+ };
107
+ const Container = styled('div', {
108
+ shouldForwardProp: prop => prop !== 'dark'
109
+ })`
110
+ position: relative;
111
+ margin-top: 64px;
112
+ padding: 24px 0 32px;
113
+ border-top: 1px solid ${props => props.dark ? props.theme.palette.grey[900] : '#dee2e7'};
114
+ box-sizing: border-box;
115
+ width: 100%;
116
+
117
+ @media (max-width: 540px) {
118
+ padding: 8px 0;
119
+ }
120
+
121
+ .footer {
122
+ display: flex;
123
+ align-items: center;
124
+ justify-content: space-between;
125
+ flex-wrap: wrap;
126
+
127
+ .footer-item {
128
+ color: ${({
129
+ theme,
130
+ dark
131
+ }) => dark ? theme.palette.grey[500] : theme.palette.grey[900]};
132
+ display: flex;
133
+ align-items: center;
134
+ flex-wrap: wrap;
135
+ font-size: 0.9rem;
136
+ }
137
+
138
+ .footer-brand {
139
+ margin-left: 8px;
140
+ margin-right: 8px;
141
+ }
142
+
143
+ .logo-container {
144
+ margin-left: 24px;
145
+ width: 90px;
146
+ opacity: 0.5;
147
+ }
148
+
149
+ @media (max-width: 540px) {
150
+ .footer-item {
151
+ font-size: 0.7rem;
152
+ }
153
+
154
+ .logo-container {
155
+ margin: 0 0 0 16px;
156
+ width: 70px;
157
+ height: 40px;
158
+ }
159
+ }
160
+
161
+ @media (max-width: 380px) {
162
+ .footer-item {
163
+ font-size: 0.65rem;
164
+ }
165
+
166
+ .logo-container {
167
+ margin: 0 0 0 8px;
168
+ height: 24px;
169
+ }
170
+ }
171
+ }
172
+ `;
@@ -0,0 +1,35 @@
1
+ import PropTypes from 'prop-types';
2
+ import Box from '@mui/material/Box';
3
+ import { styled } from '../Theme';
4
+
5
+ /**
6
+ * 一个容器组件, 当子元素 width 超出该容器时自动隐藏子元素, 必须设置明确的 height 值
7
+ */
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ function AutoHidden({
10
+ height,
11
+ ...rest
12
+ }) {
13
+ return /*#__PURE__*/_jsx(Root, {
14
+ height: height,
15
+ ...rest
16
+ });
17
+ }
18
+ AutoHidden.propTypes = {
19
+ height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired
20
+ };
21
+ const Root = styled(Box)`
22
+ overflow: hidden;
23
+ &:before {
24
+ content: '';
25
+ display: inline-block;
26
+ width: 1px;
27
+ height: 100%;
28
+ float: left;
29
+ }
30
+ > * {
31
+ float: left;
32
+ white-space: nowrap;
33
+ }
34
+ `;
35
+ export default AutoHidden;
@@ -0,0 +1,211 @@
1
+ import PropTypes from 'prop-types';
2
+ import Box from '@mui/material/Box';
3
+ import Container from '@mui/material/Container';
4
+ import AutoHidden from './auto-hidden';
5
+ import { styled } from '../Theme';
6
+
7
+ /**
8
+ * Header 组件
9
+ * TODO: Layout/dashboard 可以复用此处的 header
10
+ */
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ import { jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { Fragment as _Fragment } from "react/jsx-runtime";
14
+ function Header({
15
+ logo,
16
+ brand,
17
+ brandAddon,
18
+ description,
19
+ children,
20
+ addons,
21
+ prepend,
22
+ align,
23
+ maxWidth,
24
+ homeLink,
25
+ ...rest
26
+ }) {
27
+ const renderBrand = () => {
28
+ const brandContent = /*#__PURE__*/_jsxs(_Fragment, {
29
+ children: [logo && /*#__PURE__*/_jsx("div", {
30
+ className: "header-logo",
31
+ children: logo
32
+ }), brand && /*#__PURE__*/_jsx(AutoHidden, {
33
+ height: 44,
34
+ sx: {
35
+ flexShrink: {
36
+ xs: 1
37
+ }
38
+ },
39
+ children: /*#__PURE__*/_jsxs("div", {
40
+ className: "header-brand",
41
+ children: [/*#__PURE__*/_jsx("div", {
42
+ className: "header-brand-title",
43
+ children: /*#__PURE__*/_jsx("h2", {
44
+ children: brand
45
+ })
46
+ }), /*#__PURE__*/_jsx("div", {
47
+ className: "header-brand-desc",
48
+ children: description
49
+ })]
50
+ })
51
+ })]
52
+ });
53
+ if (typeof homeLink === 'function') {
54
+ return homeLink(brandContent);
55
+ }
56
+ return /*#__PURE__*/_jsx("a", {
57
+ href: homeLink,
58
+ children: brandContent
59
+ });
60
+ };
61
+ return /*#__PURE__*/_jsx(Root, {
62
+ ...rest,
63
+ children: /*#__PURE__*/_jsxs(Container, {
64
+ maxWidth: maxWidth,
65
+ className: "header-container",
66
+ children: [prepend, /*#__PURE__*/_jsx("div", {
67
+ className: "header-brand-wrapper",
68
+ children: renderBrand()
69
+ }), /*#__PURE__*/_jsx("div", {
70
+ className: "header-brand-addon",
71
+ children: brandAddon
72
+ }), align === 'right' && /*#__PURE__*/_jsx(Box, {
73
+ flexGrow: 1
74
+ }), children, align === 'left' && /*#__PURE__*/_jsx(Box, {
75
+ flexGrow: 1
76
+ }), /*#__PURE__*/_jsx("div", {
77
+ className: "header-addons",
78
+ children: addons
79
+ })]
80
+ })
81
+ });
82
+ }
83
+ Header.propTypes = {
84
+ // logo img/svg, 可以包裹一个 a 标签
85
+ logo: PropTypes.node,
86
+ // 相当于 Title, 可以包裹一个 a 标签
87
+ brand: PropTypes.node,
88
+ // brand 右侧的内容区域, 可显示一个 badge 或 tag
89
+ brandAddon: PropTypes.node,
90
+ // brand 下方的描述
91
+ description: PropTypes.node,
92
+ children: PropTypes.node,
93
+ // 右侧区域, 可以放置 icons/actions/login 等
94
+ addons: PropTypes.node,
95
+ // logo 左侧内容
96
+ prepend: PropTypes.node,
97
+ align: PropTypes.oneOf(['left', 'right']),
98
+ maxWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl', false])]),
99
+ homeLink: PropTypes.oneOfType([PropTypes.string, PropTypes.func])
100
+ };
101
+ Header.defaultProps = {
102
+ logo: null,
103
+ brand: null,
104
+ brandAddon: null,
105
+ description: null,
106
+ children: null,
107
+ addons: null,
108
+ prepend: null,
109
+ align: 'left',
110
+ maxWidth: undefined,
111
+ homeLink: '/'
112
+ };
113
+ const Root = styled('div')`
114
+ position: relative;
115
+ z-index: ${props => props.theme.zIndex.appBar};
116
+ font-size: 14px;
117
+ background: ${props => props.theme.palette.common.white};
118
+ .header-container {
119
+ display: flex;
120
+ align-items: center;
121
+ height: 64px;
122
+ }
123
+
124
+ .header-brand-wrapper {
125
+ flex-shrink: 1;
126
+ min-width: 0;
127
+ > a {
128
+ display: flex;
129
+ align-items: center;
130
+ height: 100%;
131
+ line-height: 1;
132
+ color: inherit;
133
+ text-decoration: none;
134
+ }
135
+ }
136
+ .header-brand-wrapper .header-logo {
137
+ display: inline-flex;
138
+ position: relative;
139
+ height: 44px;
140
+ margin-right: 16px;
141
+ img,
142
+ svg {
143
+ width: auto;
144
+ height: 100%;
145
+ max-height: 100%;
146
+ }
147
+ }
148
+ .header-brand {
149
+ display: flex;
150
+ flex-direction: column;
151
+ justify-content: center;
152
+ height: 44px;
153
+ margin-right: 16px;
154
+ line-height: 1;
155
+ a {
156
+ color: inherit;
157
+ text-decoration: none;
158
+ }
159
+ .header-brand-title {
160
+ display: flex;
161
+ align-items: center;
162
+ h2 {
163
+ margin: 0;
164
+ font-size: 16px;
165
+ }
166
+ }
167
+ .header-brand-desc {
168
+ margin-top: 4px;
169
+ color: #9397a1;
170
+ }
171
+ }
172
+ .header-brand-addon {
173
+ margin-right: 16px;
174
+ }
175
+ .header-addons {
176
+ display: flex;
177
+ align-items: center;
178
+ }
179
+ ${props => props.theme.breakpoints.down('lg')} {
180
+ .header-brand {
181
+ margin-right: 12px;
182
+ .header-brand-title {
183
+ h2 {
184
+ font-size: 14px;
185
+ }
186
+ }
187
+ }
188
+ .header-brand-addon {
189
+ display: none;
190
+ }
191
+ }
192
+ ${props => props.theme.breakpoints.down('md')} {
193
+ .header-menu {
194
+ display: inline-block;
195
+ }
196
+ .header-logo {
197
+ height: 32px;
198
+ }
199
+ .header-brand {
200
+ .header-brand-title {
201
+ h2 {
202
+ font-size: 13px;
203
+ }
204
+ }
205
+ .header-brand-desc {
206
+ font-size: 12px;
207
+ }
208
+ }
209
+ }
210
+ `;
211
+ export default Header;
@@ -0,0 +1,2 @@
1
+ export { default as Header } from './header';
2
+ export { default as ResponsiveHeader } from './responsive-header';
@@ -0,0 +1,111 @@
1
+ import { useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import MenuIcon from '@mui/icons-material/Menu';
4
+ import CloseIcon from '@mui/icons-material/Close';
5
+ import Button from '@mui/material/IconButton';
6
+ import Container from '@mui/material/Container';
7
+ import useMediaQuery from '@mui/material/useMediaQuery';
8
+ import Drawer from '@mui/material/Drawer';
9
+ import Header from './header';
10
+ import { styled, useTheme } from '../Theme';
11
+
12
+ /**
13
+ * ResponsiveHeader
14
+ * - 窄屏下显示 burge menu
15
+ * - 窄屏下将 children 区域显示到 menu 中
16
+ *
17
+ * 注意: 暂时不要通过 display: none 隐藏 logo, https://blog.patw.me/archives/1820/inline-svg-same-id-and-display-none-issue/
18
+ */
19
+ import { jsx as _jsx } from "react/jsx-runtime";
20
+ import { jsxs as _jsxs } from "react/jsx-runtime";
21
+ function ResponsiveHeader({
22
+ menu,
23
+ prepend,
24
+ children,
25
+ ...rest
26
+ }) {
27
+ const theme = useTheme();
28
+ const isMobile = useMediaQuery(theme.breakpoints.down('md'));
29
+ const [drawerOpen, setDrawerOpen] = useState(false);
30
+ const _children = typeof children === 'function' ? children({
31
+ isMobile,
32
+ closeMenu: () => setDrawerOpen(false)
33
+ }) : children;
34
+ // 如果 children 没有值, 则使用普通的 Header 组件渲染 (此时并没有什么内容需要在 menu 中显示)
35
+ if (!children) {
36
+ return /*#__PURE__*/_jsx(Header, {
37
+ prepend: prepend,
38
+ ...rest
39
+ });
40
+ }
41
+ return /*#__PURE__*/_jsxs(Root, {
42
+ prepend: prepend || /*#__PURE__*/_jsx(Button, {
43
+ sx: {
44
+ color: theme.palette.grey[500]
45
+ },
46
+ edge: "start",
47
+ className: "header-menu",
48
+ "aria-label": "header menu button",
49
+ onClick: () => setDrawerOpen(!drawerOpen),
50
+ children: drawerOpen ? /*#__PURE__*/_jsx(CloseIcon, {}) : /*#__PURE__*/_jsx(MenuIcon, {})
51
+ }),
52
+ ...rest,
53
+ children: [!isMobile && _children, isMobile && /*#__PURE__*/_jsx(Drawer, {
54
+ open: drawerOpen,
55
+ onClose: () => setDrawerOpen(false),
56
+ ModalProps: {
57
+ disablePortal: false,
58
+ keepMounted: true,
59
+ BackdropComponent: null
60
+ },
61
+ anchor: "top",
62
+ sx: {
63
+ top: 64,
64
+ zIndex: theme.zIndex.appBar - 1
65
+ },
66
+ PaperProps: {
67
+ style: {
68
+ top: 64,
69
+ bottom: 0,
70
+ boxShadow: 'none'
71
+ }
72
+ },
73
+ children: /*#__PURE__*/_jsx(MenuPanel, {
74
+ children: _children
75
+ })
76
+ })]
77
+ });
78
+ }
79
+ ResponsiveHeader.propTypes = {
80
+ ...Header.PropTypes,
81
+ // 如果是 function, 则
82
+ // - 会传入一个 isMobile 参数, isMobile 为 true 时, 表示 children 会显示在 menu 中, 可以根据 isMobile 参数调整要渲染的内容, 比如如果 isMobile 为 true 则使用 inline 模式的 NavMenu (适用于移动端)
83
+ // - 会传入一个 closeMenu 参数, 可以关闭 menu
84
+ children: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
85
+ };
86
+ ResponsiveHeader.defaultProps = {
87
+ ...Header.defaultProps
88
+ };
89
+ const Root = styled(Header)`
90
+ .header-menu {
91
+ display: none;
92
+ }
93
+ ${props => props.theme.breakpoints.down('md')} {
94
+ .header-menu {
95
+ display: flex;
96
+ margin-right: 12px;
97
+ }
98
+ }
99
+ `;
100
+ const MenuPanel = styled(Container)`
101
+ padding-top: 8px;
102
+ padding-bottom: 16px;
103
+ .navmenu {
104
+ margin: 0 -16px;
105
+ .navmenu-root > .navmenu-item,
106
+ .navmenu-root > .navmenu-sub {
107
+ border: 0;
108
+ }
109
+ }
110
+ `;
111
+ export default ResponsiveHeader;
@@ -0,0 +1,65 @@
1
+ import PropTypes from 'prop-types';
2
+ import Img from '../Img';
3
+ import { styled } from '../Theme';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { jsxs as _jsxs } from "react/jsx-runtime";
6
+ export default function ImageIcon({
7
+ name,
8
+ size,
9
+ alt,
10
+ color,
11
+ style,
12
+ prefix,
13
+ showBadge,
14
+ ...rest
15
+ }) {
16
+ const src = `${prefix}/${name}-${color.replace(/^#/, '')}.png`;
17
+ return /*#__PURE__*/_jsxs(Div, {
18
+ style: {
19
+ width: size,
20
+ height: size
21
+ },
22
+ children: [/*#__PURE__*/_jsx(Img, {
23
+ width: size,
24
+ height: size,
25
+ alt: alt || name,
26
+ src: src,
27
+ style: Object.assign({
28
+ width: size
29
+ }, style),
30
+ ...rest
31
+ }), showBadge && /*#__PURE__*/_jsx("i", {
32
+ className: "badge-point"
33
+ })]
34
+ });
35
+ }
36
+ ImageIcon.propTypes = {
37
+ name: PropTypes.string.isRequired,
38
+ size: PropTypes.number,
39
+ color: PropTypes.string,
40
+ alt: PropTypes.string,
41
+ style: PropTypes.object,
42
+ prefix: PropTypes.string,
43
+ showBadge: PropTypes.bool
44
+ };
45
+ ImageIcon.defaultProps = {
46
+ size: 36,
47
+ color: '#000000',
48
+ alt: '',
49
+ style: {},
50
+ prefix: '/images',
51
+ showBadge: false
52
+ };
53
+ const Div = styled('div')`
54
+ position: relative;
55
+ .badge-point {
56
+ position: absolute;
57
+ width: 10px;
58
+ height: 10px;
59
+ border-radius: 10px;
60
+ background-color: #fe4e44;
61
+ right: -2px;
62
+ top: 0;
63
+ box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.3), 0px 0px 20px rgba(0, 0, 0, 0.1);
64
+ }
65
+ `;
@@ -0,0 +1,84 @@
1
+ import { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import colors from '../Colors';
4
+ import { styled } from '../Theme';
5
+ import { withDeprecated } from '../Util/deprecate';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const variants = {
8
+ light: 'fal',
9
+ regular: 'far',
10
+ solid: 'fas'
11
+ };
12
+
13
+ // eslint-disable-next-line react/prop-types
14
+ function Icon({
15
+ name,
16
+ color,
17
+ size,
18
+ variant,
19
+ rounded,
20
+ style,
21
+ className,
22
+ forwardedRef,
23
+ ...rest
24
+ }) {
25
+ const content = /*#__PURE__*/_jsx("i", {
26
+ ref: forwardedRef,
27
+ className: `${variants[variant]} fa-${name} ${rounded ? '' : className}`,
28
+ style: Object.assign({
29
+ color,
30
+ fontSize: `${size}px`
31
+ }, style || {})
32
+ });
33
+ if (rounded) {
34
+ return /*#__PURE__*/_jsx(Span, {
35
+ ref: forwardedRef,
36
+ size: size,
37
+ color: color,
38
+ className: className,
39
+ ...rest,
40
+ children: content
41
+ });
42
+ }
43
+ return content;
44
+ }
45
+ Icon.propTypes = {
46
+ name: PropTypes.string.isRequired,
47
+ className: PropTypes.string,
48
+ color: PropTypes.string,
49
+ rounded: PropTypes.bool,
50
+ variant: PropTypes.string,
51
+ size: PropTypes.number,
52
+ style: PropTypes.object
53
+ };
54
+ Icon.defaultProps = {
55
+ rounded: false,
56
+ variant: 'light',
57
+ color: colors.grey[900],
58
+ className: '',
59
+ size: 24,
60
+ style: {}
61
+ };
62
+ const Span = styled('span')`
63
+ width: ${props => props.size * 2}px;
64
+ height: ${props => props.size * 2}px;
65
+ border-radius: 50%;
66
+ border: 1px solid ${props => props.color};
67
+ display: flex;
68
+ justify-content: center;
69
+ align-items: center;
70
+
71
+ .fa,
72
+ .fas,
73
+ .fal,
74
+ .far {
75
+ line-height: ${props => props.size}px;
76
+ }
77
+ `;
78
+ export default withDeprecated( /*#__PURE__*/forwardRef((props, ref) => /*#__PURE__*/_jsx(Icon, {
79
+ ...props,
80
+ forwardedRef: ref
81
+ })), {
82
+ name: 'Icon',
83
+ alternative: 'SVG icons'
84
+ });