@blocklet/ui-react 2.2.3 → 2.4.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.
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = require("react");
9
+
10
+ var _reactRouterDom = require("react-router-dom");
11
+
12
+ var _context = require("@arcblock/ux/lib/Locale/context");
13
+
14
+ var _dashboard = _interopRequireDefault(require("@arcblock/ux/lib/Layout/dashboard"));
15
+
16
+ var _Address = _interopRequireDefault(require("@arcblock/did-connect/lib/Address"));
17
+
18
+ var _Avatar = _interopRequireDefault(require("@arcblock/did-connect/lib/Avatar"));
19
+
20
+ var _types = require("../types");
21
+
22
+ var _blocklets = require("../blocklets");
23
+
24
+ var _jsxRuntime = require("react/jsx-runtime");
25
+
26
+ const _excluded = ["meta"];
27
+
28
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
+
30
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
31
+
32
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
33
+
34
+ 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; }
35
+
36
+ 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; }
37
+
38
+ 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; }
39
+
40
+ /**
41
+ * 专门用于 (composable) blocklet 的 Dashboard 组件, 解析 blocklet meta 中 section 为 dashboard 的 navigation 数据, 渲染一个 UX Dashboard
42
+ */
43
+ function Dashboard(_ref) {
44
+ var _formattedBlocklet$na;
45
+
46
+ let {
47
+ meta
48
+ } = _ref,
49
+ rest = _objectWithoutProperties(_ref, _excluded);
50
+
51
+ const {
52
+ locale
53
+ } = (0, _context.useLocaleContext)() || {};
54
+ const blocklet = Object.assign({}, window.blocklet, meta);
55
+ const formattedBlocklet = (0, _react.useMemo)(() => {
56
+ try {
57
+ return (0, _blocklets.formatBlockletInfo)(blocklet);
58
+ } catch (e) {
59
+ console.error('Failed to format blocklet info', e, blocklet);
60
+ return blocklet;
61
+ }
62
+ }, [blocklet]);
63
+
64
+ if (!blocklet.appName) {
65
+ return null;
66
+ }
67
+
68
+ const {
69
+ did,
70
+ appLogo,
71
+ appName
72
+ } = formattedBlocklet;
73
+ let localizedNav = (0, _blocklets.getLocalizedNavigation)(formattedBlocklet === null || formattedBlocklet === void 0 ? void 0 : (_formattedBlocklet$na = formattedBlocklet.navigation) === null || _formattedBlocklet$na === void 0 ? void 0 : _formattedBlocklet$na.dashboard, locale) || [];
74
+ localizedNav = localizedNav.map(item => _objectSpread(_objectSpread({}, item), {}, {
75
+ url: item.link,
76
+ label: item.title,
77
+ icon: item.icon ? /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
78
+ className: "iconify",
79
+ "data-icon": item.icon
80
+ }) : null
81
+ }));
82
+ const allLinks = [...(rest.links || []), localizedNav]; // https://github.com/ArcBlock/ux/issues/755#issuecomment-1208692620
83
+
84
+ allLinks.flat().forEach(item => {
85
+ item.external = true;
86
+ });
87
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_dashboard.default, _objectSpread(_objectSpread({
88
+ title: appName,
89
+ fullWidth: true,
90
+ sidebarWidth: 128,
91
+ legacy: false
92
+ }, rest), {}, {
93
+ headerProps: _objectSpread({
94
+ brand: appName,
95
+ description: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Address.default, {
96
+ compact: true,
97
+ responsive: false,
98
+ copyable: false,
99
+ prepend: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Avatar.default, {
100
+ did: did,
101
+ size: 16,
102
+ style: {
103
+ marginRight: 4
104
+ }
105
+ }),
106
+ children: did
107
+ }),
108
+ logo: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Link, {
109
+ to: _blocklets.publicPath,
110
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
111
+ src: appLogo,
112
+ alt: "logo"
113
+ })
114
+ })
115
+ }, rest.headerProps),
116
+ links: allLinks
117
+ }));
118
+ }
119
+
120
+ Dashboard.propTypes = {
121
+ meta: _types.blockletMetaProps
122
+ };
123
+ Dashboard.defaultProps = {
124
+ meta: {}
125
+ };
126
+ var _default = Dashboard;
127
+ exports.default = _default;
@@ -9,16 +9,20 @@ var _react = require("react");
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
- var _styledComponents = _interopRequireDefault(require("styled-components"));
12
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
13
13
 
14
14
  var _styles = require("@mui/material/styles");
15
15
 
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
17
 
18
+ var _templateObject;
19
+
18
20
  const _excluded = ["name", "logo", "description"];
19
21
 
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
23
 
24
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
25
+
22
26
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
23
27
 
24
28
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -75,7 +79,4 @@ Brand.defaultProps = {
75
79
  description: ''
76
80
  };
77
81
 
78
- const Root = _styledComponents.default.div.withConfig({
79
- displayName: "brand__Root",
80
- componentId: "sc-6z2c3k-0"
81
- })(["display:flex;flex-direction:column;font-size:14px;a{text-decoration:none;color:inherit;}> div:first-child{display:flex;align-items:center;}.footer-brand-logo{display:flex;align-items:center;margin-right:16px;line-height:1;img,svg{width:auto;height:44px;max-height:44px;}}.footer-brand-name{font-size:16px;font-weight:bold;}.footer-brand-desc{margin-top:16px;}", "{width:auto;}", "{.footer-brand-logo{img,svg{height:32px;max-height:32px;}}}"], props => props.$theme.breakpoints.down('sm'), props => props.$theme.breakpoints.down('md'));
82
+ const Root = _styled.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n font-size: 14px;\n a {\n text-decoration: none;\n color: inherit;\n }\n > div:first-child {\n display: flex;\n align-items: center;\n }\n .footer-brand-logo {\n display: flex;\n align-items: center;\n margin-right: 16px;\n line-height: 1;\n img,\n svg {\n width: auto;\n height: 44px;\n max-height: 44px;\n }\n }\n .footer-brand-name {\n font-size: 16px;\n font-weight: bold;\n }\n .footer-brand-desc {\n margin-top: 16px;\n }\n\n ", " {\n width: auto;\n }\n\n ", " {\n .footer-brand-logo {\n img,\n svg {\n height: 32px;\n max-height: 32px;\n }\n }\n }\n"])), props => props.$theme.breakpoints.down('sm'), props => props.$theme.breakpoints.down('md'));
@@ -7,14 +7,18 @@ exports.default = Copyright;
7
7
 
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
 
10
- var _styledComponents = _interopRequireDefault(require("styled-components"));
10
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
11
11
 
12
12
  var _jsxRuntime = require("react/jsx-runtime");
13
13
 
14
+ var _templateObject;
15
+
14
16
  const _excluded = ["owner", "year"];
15
17
 
16
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
19
 
20
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
21
+
18
22
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
19
23
 
20
24
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -46,7 +50,4 @@ Copyright.defaultProps = {
46
50
  year: "".concat(new Date().getFullYear())
47
51
  };
48
52
 
49
- const Root = _styledComponents.default.p.withConfig({
50
- displayName: "copyright__Root",
51
- componentId: "sc-g2r3zf-0"
52
- })(["margin:0;font-size:13px;"]);
53
+ const Root = _styled.default.p(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n margin: 0;\n font-size: 13px;\n"])));
@@ -7,7 +7,7 @@ exports.default = void 0;
7
7
 
8
8
  var _react = require("react");
9
9
 
10
- var _styledComponents = _interopRequireDefault(require("styled-components"));
10
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
11
11
 
12
12
  var _styles = require("@mui/material/styles");
13
13
 
@@ -27,10 +27,14 @@ var _types = require("../types");
27
27
 
28
28
  var _jsxRuntime = require("react/jsx-runtime");
29
29
 
30
+ var _templateObject;
31
+
30
32
  const _excluded = ["meta"];
31
33
 
32
34
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
35
 
36
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
37
+
34
38
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
35
39
 
36
40
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -111,10 +115,7 @@ Footer.propTypes = {
111
115
  Footer.defaultProps = {
112
116
  meta: {}
113
117
  };
114
- const StyledInternalFooter = (0, _styledComponents.default)(_internalFooter.default).withConfig({
115
- displayName: "Footer__StyledInternalFooter",
116
- componentId: "sc-1iwl1nd-0"
117
- })(["border-top:1px solid #eee;color:", ";", " font-family:Lato,Avenir,-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';"], props => props.$theme.palette.grey[600], _ref2 => {
118
+ const StyledInternalFooter = (0, _styled.default)(_internalFooter.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n border-top: 1px solid #eee;\n color: ", ";\n ", "\n font-family: Lato, Avenir, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif,\n 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';\n"])), props => props.$theme.palette.grey[600], _ref2 => {
118
119
  let {
119
120
  $bgcolor
120
121
  } = _ref2;
@@ -9,16 +9,20 @@ var _react = require("react");
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
- var _styledComponents = _interopRequireDefault(require("styled-components"));
12
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
13
13
 
14
14
  var _Container = _interopRequireDefault(require("@mui/material/Container"));
15
15
 
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
17
 
18
+ var _templateObject;
19
+
18
20
  const _excluded = ["elements"];
19
21
 
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
23
 
24
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
25
+
22
26
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
23
27
 
24
28
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -59,10 +63,7 @@ PlainLayout.propTypes = {
59
63
  }).isRequired
60
64
  };
61
65
 
62
- const Root = _styledComponents.default.div.withConfig({
63
- displayName: "plain__Root",
64
- componentId: "sc-qoddfp-0"
65
- })(["padding:24px 0;border-top:1px solid #eee;.plain-layout-container{display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:8px;}"]);
66
+ const Root = _styled.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 24px 0;\n border-top: 1px solid #eee;\n .plain-layout-container {\n display: flex;\n justify-content: space-between;\n align-items: center;\n flex-wrap: wrap;\n gap: 8px;\n }\n"])));
66
67
 
67
68
  var _default = PlainLayout;
68
69
  exports.default = _default;
@@ -7,7 +7,7 @@ exports.default = Row;
7
7
 
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
 
10
- var _styledComponents = _interopRequireDefault(require("styled-components"));
10
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
11
11
 
12
12
  var _styles = require("@mui/material/styles");
13
13
 
@@ -15,10 +15,14 @@ var _clsx = _interopRequireDefault(require("clsx"));
15
15
 
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
17
 
18
+ var _templateObject;
19
+
18
20
  const _excluded = ["children", "autoCenter"];
19
21
 
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
23
 
24
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
25
+
22
26
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
23
27
 
24
28
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -60,7 +64,4 @@ Row.defaultProps = {
60
64
  autoCenter: false
61
65
  };
62
66
 
63
- const RowRoot = _styledComponents.default.div.withConfig({
64
- displayName: "row__RowRoot",
65
- componentId: "sc-1b3lw4c-0"
66
- })(["display:flex;justify-content:space-between;& + &{margin-top:24px;}&.footer-row-auto-center > *:only-child{margin:0 auto;}", "{align-items:stretch;flex-direction:column;gap:16px;> *{flex:1 0 100%;}&.footer-row-auto-center > *{margin:0 auto;}}"], props => props.$theme.breakpoints.down('md'));
67
+ const RowRoot = _styled.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n justify-content: space-between;\n & + & {\n margin-top: 24px;\n }\n &.footer-row-auto-center > *:only-child {\n margin: 0 auto;\n }\n\n ", " {\n align-items: stretch;\n flex-direction: column;\n gap: 16px;\n > * {\n flex: 1 0 100%;\n }\n &.footer-row-auto-center > * {\n margin: 0 auto;\n }\n }\n"])), props => props.$theme.breakpoints.down('md'));
@@ -7,7 +7,7 @@ exports.default = void 0;
7
7
 
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
 
10
- var _styledComponents = _interopRequireDefault(require("styled-components"));
10
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
11
11
 
12
12
  var _Box = _interopRequireDefault(require("@mui/material/Box"));
13
13
 
@@ -17,10 +17,14 @@ var _row = _interopRequireDefault(require("./row"));
17
17
 
18
18
  var _jsxRuntime = require("react/jsx-runtime");
19
19
 
20
+ var _templateObject;
21
+
20
22
  const _excluded = ["elements"];
21
23
 
22
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
25
 
26
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
27
+
24
28
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
29
 
26
30
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -75,10 +79,7 @@ Footer.propTypes = {
75
79
  }).isRequired
76
80
  };
77
81
 
78
- const Root = _styledComponents.default.div.withConfig({
79
- displayName: "standard__Root",
80
- componentId: "sc-13y30cb-0"
81
- })(["padding:48px 0;"]);
82
+ const Root = _styled.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 48px 0;\n"])));
82
83
 
83
84
  var _default = Footer;
84
85
  exports.default = _default;
@@ -9,7 +9,7 @@ var _react = require("react");
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
- var _styledComponents = _interopRequireDefault(require("styled-components"));
12
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
13
13
 
14
14
  var _styles = require("@mui/material/styles");
15
15
 
@@ -17,10 +17,14 @@ var _clsx = _interopRequireDefault(require("clsx"));
17
17
 
18
18
  var _jsxRuntime = require("react/jsx-runtime");
19
19
 
20
+ var _templateObject;
21
+
20
22
  const _excluded = ["links", "flowLayout"];
21
23
 
22
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
25
 
26
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
27
+
24
28
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
29
 
26
30
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -133,7 +137,4 @@ Links.defaultProps = {
133
137
  flowLayout: false
134
138
  };
135
139
 
136
- const Root = _styledComponents.default.div.withConfig({
137
- displayName: "links__Root",
138
- componentId: "sc-19wysi2-0"
139
- })(["overflow:hidden;color:", ";.footer-links-inner{display:flex;justify-content:space-between;margin:0 -8px;}.footer-links-group,.footer-links-sub{display:flex;flex-direction:column;}.footer-links-item{display:inline-block;padding:0 8px;font-size:14px;line-height:1.6;}.footer-links-group + .footer-links-group{margin-left:128px;}&.footer-links--grouped{.footer-links-group{> .footer-links-item{font-weight:bold;}.footer-links-sub{margin-top:8px;}}}a{color:inherit;text-decoration:none;&:hover{text-decoration:underline;}}&.footer-links--flow{display:inline-flex;.footer-links-inner{justify-content:center;flex-wrap:wrap;margin:0 -8px;.footer-links-item{padding:0 8px;}}}", "{.footer-links-group + .footer-links-group{margin-left:56px;}}", "{.footer-links-group + .footer-links-group{margin-left:40px;}}", "{.footer-links-inner{flex-direction:column;margin:0;}.footer-links-sub{display:none;}.footer-links-group{padding:12px 0;border-top:1px solid ", ";}.footer-links-group + .footer-links-group{margin-left:0;}.footer-links-group--active{.footer-links-sub{display:flex;flex-direction:row;flex-wrap:wrap;.footer-links-item{flex:0 0 50%;}}}.footer-links-item{padding:0;font-size:13px;}&.footer-links--grouped{.footer-links-group{> .footer-links-item{font-size:14px;}}}&.footer-links--flow{.footer-links-inner{flex-direction:row;}}}"], props => props.$theme.palette.grey[600], props => props.$theme.breakpoints.down('lg'), props => props.$theme.breakpoints.down('lg'), props => props.$theme.breakpoints.down('sm'), props => props.$theme.palette.grey[200]);
140
+ const Root = _styled.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n overflow: hidden;\n color: ", ";\n .footer-links-inner {\n display: flex;\n justify-content: space-between;\n margin: 0 -8px;\n }\n .footer-links-group,\n .footer-links-sub {\n display: flex;\n flex-direction: column;\n }\n .footer-links-item {\n display: inline-block;\n padding: 0 8px;\n font-size: 14px;\n line-height: 1.6;\n }\n .footer-links-group + .footer-links-group {\n margin-left: 128px;\n }\n &.footer-links--grouped {\n .footer-links-group {\n > .footer-links-item {\n font-weight: bold;\n }\n .footer-links-sub {\n margin-top: 8px;\n }\n }\n }\n a {\n color: inherit;\n text-decoration: none;\n &:hover {\n text-decoration: underline;\n }\n }\n\n &.footer-links--flow {\n display: inline-flex;\n .footer-links-inner {\n justify-content: center;\n flex-wrap: wrap;\n margin: 0 -8px;\n .footer-links-item {\n padding: 0 8px;\n }\n }\n }\n\n ", " {\n .footer-links-group + .footer-links-group {\n margin-left: 56px;\n }\n }\n\n ", " {\n .footer-links-group + .footer-links-group {\n margin-left: 40px;\n }\n }\n\n ", " {\n .footer-links-inner {\n flex-direction: column;\n margin: 0;\n }\n .footer-links-sub {\n display: none;\n }\n .footer-links-group {\n padding: 12px 0;\n border-top: 1px solid ", ";\n }\n .footer-links-group + .footer-links-group {\n margin-left: 0;\n }\n .footer-links-group--active {\n .footer-links-sub {\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n .footer-links-item {\n flex: 0 0 50%;\n }\n }\n }\n .footer-links-item {\n padding: 0;\n font-size: 13px;\n }\n &.footer-links--grouped {\n .footer-links-group {\n > .footer-links-item {\n font-size: 14px;\n }\n }\n }\n\n &.footer-links--flow {\n .footer-links-inner {\n flex-direction: row;\n }\n }\n }\n"])), props => props.$theme.palette.grey[600], props => props.$theme.breakpoints.down('lg'), props => props.$theme.breakpoints.down('lg'), props => props.$theme.breakpoints.down('sm'), props => props.$theme.palette.grey[200]);
@@ -7,7 +7,7 @@ exports.default = SocialMedia;
7
7
 
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
 
10
- var _styledComponents = _interopRequireDefault(require("styled-components"));
10
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
11
11
 
12
12
  var _styles = require("@mui/material/styles");
13
13
 
@@ -15,10 +15,14 @@ var _Icon = _interopRequireDefault(require("../Icon"));
15
15
 
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
17
 
18
+ var _templateObject;
19
+
18
20
  const _excluded = ["items"];
19
21
 
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
23
 
24
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
25
+
22
26
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
23
27
 
24
28
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -77,7 +81,4 @@ SocialMedia.defaultProps = {
77
81
  items: null
78
82
  };
79
83
 
80
- const Root = _styledComponents.default.div.withConfig({
81
- displayName: "social-media__Root",
82
- componentId: "sc-w4ariy-0"
83
- })(["display:inline-flex;align-items:center;a + a{margin-left:12px;}"]);
84
+ const Root = _styled.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n align-items: center;\n a + a {\n margin-left: 12px;\n }\n"])));
@@ -11,7 +11,7 @@ var _jsxRuntime = require("react/jsx-runtime");
11
11
 
12
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
13
 
14
- var _styledComponents = _interopRequireDefault(require("styled-components"));
14
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
15
15
 
16
16
  var _styles = require("@mui/material/styles");
17
17
 
@@ -45,10 +45,14 @@ var _utils = require("../utils");
45
45
 
46
46
  var _blocklets = require("../blocklets");
47
47
 
48
+ var _templateObject;
49
+
48
50
  const _excluded = ["meta", "addons", "sessionManagerProps", "homeLink"];
49
51
 
50
52
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
51
53
 
54
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
55
+
52
56
  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; }
53
57
 
54
58
  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; }
@@ -261,10 +265,7 @@ Header.defaultProps = {
261
265
  },
262
266
  homeLink: _blocklets.publicPath
263
267
  };
264
- const StyledUxHeader = (0, _styledComponents.default)(_Header.ResponsiveHeader).withConfig({
265
- displayName: "Header__StyledUxHeader",
266
- componentId: "sc-kcf4st-0"
267
- })(["", " font-family:Lato,Avenir,-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';.header-logo{min-width:44px;}", "{.header-logo{min-width:32px;}}.header-nav{.navmenu-sub .navmenu-item{min-width:80px;}}"], _ref3 => {
268
+ const StyledUxHeader = (0, _styled.default)(_Header.ResponsiveHeader)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", "\n font-family: Lato, Avenir, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif,\n 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';\n .header-logo {\n min-width: 44px;\n }\n ", " {\n .header-logo {\n min-width: 32px;\n }\n }\n .header-nav {\n .navmenu-sub .navmenu-item {\n min-width: 80px;\n }\n }\n .header-nav.navmenu--horizontal {\n .navmenu-root > .navmenu-sub,\n .navmenu-root > .navmenu-item {\n padding: 16px 4px;\n }\n }\n"])), _ref3 => {
268
269
  let {
269
270
  $bgcolor
270
271
  } = _ref3;
package/lib/blocklets.js CHANGED
@@ -7,7 +7,7 @@ exports.publicPath = exports.parseNavigation = exports.getLocalizedNavigation =
7
7
 
8
8
  var _utils = require("./utils");
9
9
 
10
- var _window, _window$blocklet;
10
+ var _window, _window$blocklet, _window2, _window2$blocklet;
11
11
 
12
12
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
13
13
 
@@ -15,7 +15,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
15
15
 
16
16
  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; }
17
17
 
18
- const publicPath = ((_window = window) === null || _window === void 0 ? void 0 : (_window$blocklet = _window.blocklet) === null || _window$blocklet === void 0 ? void 0 : _window$blocklet.prefix) || '/';
18
+ const publicPath = ((_window = window) === null || _window === void 0 ? void 0 : (_window$blocklet = _window.blocklet) === null || _window$blocklet === void 0 ? void 0 : _window$blocklet.groupPrefix) || ((_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$blocklet = _window2.blocklet) === null || _window2$blocklet === void 0 ? void 0 : _window2$blocklet.prefix) || '/';
19
19
  /**
20
20
  * 格式化 theme (目前仅考虑 background)
21
21
  */
@@ -90,7 +90,9 @@ const parseNavigation = navigation => {
90
90
  // 对应 footer social media
91
91
  social: [],
92
92
  // 对应 footer 底部 links
93
- bottom: []
93
+ bottom: [],
94
+ // 对应 dashboard#sidenav 导航
95
+ dashboard: []
94
96
  }; // 对 navigation 顶层元素按 section 分组
95
97
 
96
98
  navigation.forEach(item => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/ui-react",
3
- "version": "2.2.3",
3
+ "version": "2.4.0",
4
4
  "description": "Some useful front-end web components that can be used in Blocklets.",
5
5
  "keywords": [
6
6
  "react",
@@ -30,13 +30,14 @@
30
30
  "url": "https://github.com/ArcBlock/ux/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@arcblock/did-connect": "^2.2.3",
34
- "@arcblock/ux": "^2.2.3",
33
+ "@arcblock/did-connect": "^2.4.0",
34
+ "@arcblock/ux": "^2.4.0",
35
+ "@emotion/react": "^11.10.0",
36
+ "@emotion/styled": "^11.10.0",
35
37
  "@iconify/iconify": "^2.2.1",
36
- "@mui/material": "^5.9.3",
38
+ "@mui/material": "^5.10.0",
37
39
  "core-js": "^3.24.1",
38
- "react-error-boundary": "^3.1.4",
39
- "styled-components": "^5.3.5"
40
+ "react-error-boundary": "^3.1.4"
40
41
  },
41
42
  "peerDependencies": {
42
43
  "react": ">=18.1.0"
@@ -49,9 +50,8 @@
49
50
  "@babel/core": "^7.18.10",
50
51
  "@babel/preset-env": "^7.18.10",
51
52
  "@babel/preset-react": "^7.18.6",
52
- "babel-plugin-styled-components": "^1.13.3",
53
53
  "eslint-plugin-react-hooks": "^4.6.0",
54
54
  "jest": "^24.9.0"
55
55
  },
56
- "gitHead": "8fe2ac5bc92d997e2df3547237e3fa44b76c91aa"
56
+ "gitHead": "202771a046cab27fc550d31e73588075a90c75fd"
57
57
  }
@@ -0,0 +1,81 @@
1
+ import { useMemo } from 'react';
2
+ import { Link } from 'react-router-dom';
3
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
4
+ import UxDashboard from '@arcblock/ux/lib/Layout/dashboard';
5
+ import DidAddress from '@arcblock/did-connect/lib/Address';
6
+ import DidAvatar from '@arcblock/did-connect/lib/Avatar';
7
+ import { blockletMetaProps } from '../types';
8
+ import { publicPath, formatBlockletInfo, getLocalizedNavigation } from '../blocklets';
9
+
10
+ /**
11
+ * 专门用于 (composable) blocklet 的 Dashboard 组件, 解析 blocklet meta 中 section 为 dashboard 的 navigation 数据, 渲染一个 UX Dashboard
12
+ */
13
+ function Dashboard({ meta, ...rest }) {
14
+ const { locale } = useLocaleContext() || {};
15
+ const blocklet = Object.assign({}, window.blocklet, meta);
16
+ const formattedBlocklet = useMemo(() => {
17
+ try {
18
+ return formatBlockletInfo(blocklet);
19
+ } catch (e) {
20
+ console.error('Failed to format blocklet info', e, blocklet);
21
+ return blocklet;
22
+ }
23
+ }, [blocklet]);
24
+
25
+ if (!blocklet.appName) {
26
+ return null;
27
+ }
28
+
29
+ const { did, appLogo, appName } = formattedBlocklet;
30
+ let localizedNav = getLocalizedNavigation(formattedBlocklet?.navigation?.dashboard, locale) || [];
31
+ localizedNav = localizedNav.map((item) => ({
32
+ ...item,
33
+ url: item.link,
34
+ label: item.title,
35
+ icon: item.icon ? <span className="iconify" data-icon={item.icon} /> : null,
36
+ }));
37
+ const allLinks = [...(rest.links || []), localizedNav];
38
+ // https://github.com/ArcBlock/ux/issues/755#issuecomment-1208692620
39
+ allLinks.flat().forEach((item) => {
40
+ item.external = true;
41
+ });
42
+
43
+ return (
44
+ <UxDashboard
45
+ title={appName}
46
+ fullWidth
47
+ sidebarWidth={128}
48
+ legacy={false}
49
+ {...rest}
50
+ headerProps={{
51
+ brand: appName,
52
+ description: (
53
+ <DidAddress
54
+ compact
55
+ responsive={false}
56
+ copyable={false}
57
+ prepend={<DidAvatar did={did} size={16} style={{ marginRight: 4 }} />}>
58
+ {did}
59
+ </DidAddress>
60
+ ),
61
+ logo: (
62
+ <Link to={publicPath}>
63
+ <img src={appLogo} alt="logo" />
64
+ </Link>
65
+ ),
66
+ ...rest.headerProps,
67
+ }}
68
+ links={allLinks}
69
+ />
70
+ );
71
+ }
72
+
73
+ Dashboard.propTypes = {
74
+ meta: blockletMetaProps,
75
+ };
76
+
77
+ Dashboard.defaultProps = {
78
+ meta: {},
79
+ };
80
+
81
+ export default Dashboard;
@@ -1,6 +1,6 @@
1
1
  import { isValidElement } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import styled from 'styled-components';
3
+ import styled from '@emotion/styled';
4
4
  import { useTheme } from '@mui/material/styles';
5
5
 
6
6
  export default function Brand({ name, logo, description, ...rest }) {
@@ -1,5 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
- import styled from 'styled-components';
2
+ import styled from '@emotion/styled';
3
3
 
4
4
  export default function Copyright({ owner, year, ...rest }) {
5
5
  return (
@@ -1,5 +1,5 @@
1
1
  import { useMemo } from 'react';
2
- import styled from 'styled-components';
2
+ import styled from '@emotion/styled';
3
3
  import { useTheme } from '@mui/material/styles';
4
4
  import { withErrorBoundary } from 'react-error-boundary';
5
5
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
@@ -1,6 +1,6 @@
1
1
  import { cloneElement } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import styled from 'styled-components';
3
+ import styled from '@emotion/styled';
4
4
  import Container from '@mui/material/Container';
5
5
 
6
6
  /**
@@ -1,5 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
- import styled from 'styled-components';
2
+ import styled from '@emotion/styled';
3
3
  import { useTheme } from '@mui/material/styles';
4
4
  import clsx from 'clsx';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
- import styled from 'styled-components';
2
+ import styled from '@emotion/styled';
3
3
  import Box from '@mui/material/Box';
4
4
  import Container from '@mui/material/Container';
5
5
  import Row from './row';
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable react/no-array-index-key */
2
2
  import { useState } from 'react';
3
3
  import PropTypes from 'prop-types';
4
- import styled from 'styled-components';
4
+ import styled from '@emotion/styled';
5
5
  import { useTheme } from '@mui/material/styles';
6
6
  import clsx from 'clsx';
7
7
 
@@ -1,5 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
- import styled from 'styled-components';
2
+ import styled from '@emotion/styled';
3
3
  import { useTheme } from '@mui/material/styles';
4
4
  import Icon from '../Icon';
5
5
 
@@ -2,7 +2,7 @@ import { useContext, useMemo, createElement } from 'react';
2
2
  // FIXME: 直接从 react 中 import Fragment 可能会在 vite 下出错,先暂时从 react/jsx-runtime 导入 Fragment 来跳过这个问题
3
3
  import { Fragment } from 'react/jsx-runtime';
4
4
  import PropTypes from 'prop-types';
5
- import styled from 'styled-components';
5
+ import styled from '@emotion/styled';
6
6
  import { ThemeProvider } from '@mui/material/styles';
7
7
  import { withErrorBoundary } from 'react-error-boundary';
8
8
  import { ErrorFallback } from '@arcblock/ux/lib/ErrorBoundary';
@@ -200,6 +200,12 @@ const StyledUxHeader = styled(ResponsiveHeader)`
200
200
  min-width: 80px;
201
201
  }
202
202
  }
203
+ .header-nav.navmenu--horizontal {
204
+ .navmenu-root > .navmenu-sub,
205
+ .navmenu-root > .navmenu-item {
206
+ padding: 16px 4px;
207
+ }
208
+ }
203
209
  `;
204
210
 
205
211
  export default withErrorBoundary(Header, {
package/src/blocklets.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { mapRecursive } from './utils';
2
2
 
3
- export const publicPath = window?.blocklet?.prefix || '/';
3
+ export const publicPath = window?.blocklet?.groupPrefix || window?.blocklet?.prefix || '/';
4
4
 
5
5
  /**
6
6
  * 格式化 theme (目前仅考虑 background)
@@ -61,6 +61,8 @@ export const parseNavigation = (navigation) => {
61
61
  social: [],
62
62
  // 对应 footer 底部 links
63
63
  bottom: [],
64
+ // 对应 dashboard#sidenav 导航
65
+ dashboard: [],
64
66
  };
65
67
 
66
68
  // 对 navigation 顶层元素按 section 分组