@blocklet/ui-react 2.1.27 → 2.1.30

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.
@@ -11,7 +11,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
12
  var _styledComponents = _interopRequireDefault(require("styled-components"));
13
13
 
14
- var _useTheme = _interopRequireDefault(require("@mui/styles/useTheme"));
14
+ var _styles = require("@mui/material/styles");
15
15
 
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
17
 
@@ -37,7 +37,7 @@ function Brand(_ref) {
37
37
  } = _ref,
38
38
  rest = _objectWithoutProperties(_ref, _excluded);
39
39
 
40
- const theme = (0, _useTheme.default)();
40
+ const theme = (0, _styles.useTheme)();
41
41
 
42
42
  if (!name && !logo && !description) {
43
43
  return null;
@@ -7,7 +7,7 @@ exports.default = void 0;
7
7
 
8
8
  var _styledComponents = _interopRequireDefault(require("styled-components"));
9
9
 
10
- var _useTheme = _interopRequireDefault(require("@mui/styles/useTheme"));
10
+ var _styles = require("@mui/material/styles");
11
11
 
12
12
  var _Box = _interopRequireDefault(require("@mui/material/Box"));
13
13
 
@@ -56,7 +56,7 @@ function Footer(_ref) {
56
56
  } = _ref,
57
57
  rest = _objectWithoutProperties(_ref, _excluded);
58
58
 
59
- const theme = (0, _useTheme.default)();
59
+ const theme = (0, _styles.useTheme)();
60
60
  const blocklet = Object.assign({}, window.blocklet, meta);
61
61
 
62
62
  if (!blocklet.appName) {
@@ -11,7 +11,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
12
  var _styledComponents = _interopRequireDefault(require("styled-components"));
13
13
 
14
- var _useTheme = _interopRequireDefault(require("@mui/styles/useTheme"));
14
+ var _styles = require("@mui/material/styles");
15
15
 
16
16
  var _clsx = _interopRequireDefault(require("clsx"));
17
17
 
@@ -42,7 +42,7 @@ function Links(_ref) {
42
42
  } = _ref,
43
43
  rest = _objectWithoutProperties(_ref, _excluded);
44
44
 
45
- const theme = (0, _useTheme.default)();
45
+ const theme = (0, _styles.useTheme)();
46
46
  const [activeIndex, setActiveIndex] = (0, _react.useState)(-1);
47
47
 
48
48
  if (!(links !== null && links !== void 0 && links.length)) {
package/lib/Footer/row.js CHANGED
@@ -9,7 +9,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
 
10
10
  var _styledComponents = _interopRequireDefault(require("styled-components"));
11
11
 
12
- var _useTheme = _interopRequireDefault(require("@mui/styles/useTheme"));
12
+ var _styles = require("@mui/material/styles");
13
13
 
14
14
  var _clsx = _interopRequireDefault(require("clsx"));
15
15
 
@@ -36,7 +36,7 @@ function Row(_ref) {
36
36
  } = _ref,
37
37
  rest = _objectWithoutProperties(_ref, _excluded);
38
38
 
39
- const theme = (0, _useTheme.default)();
39
+ const theme = (0, _styles.useTheme)();
40
40
 
41
41
  if (!children) {
42
42
  return null;
@@ -9,7 +9,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
 
10
10
  var _styledComponents = _interopRequireDefault(require("styled-components"));
11
11
 
12
- var _useTheme = _interopRequireDefault(require("@mui/styles/useTheme"));
12
+ var _styles = require("@mui/material/styles");
13
13
 
14
14
  var _Icon = _interopRequireDefault(require("../Icon"));
15
15
 
@@ -35,7 +35,7 @@ function SocialMedia(_ref) {
35
35
  } = _ref,
36
36
  rest = _objectWithoutProperties(_ref, _excluded);
37
37
 
38
- const theme = (0, _useTheme.default)();
38
+ const theme = (0, _styles.useTheme)();
39
39
 
40
40
  if (!(items !== null && items !== void 0 && items.length)) {
41
41
  return null;
package/lib/utils.js CHANGED
@@ -56,7 +56,7 @@ const matchPath = path => {
56
56
 
57
57
  const pathname = ensureTrailingSlash(window.location.pathname);
58
58
  const normalizedPath = ensureTrailingSlash(new URL(path, window.location.origin).pathname);
59
- return normalizedPath.startsWith(pathname);
59
+ return pathname.startsWith(normalizedPath);
60
60
  };
61
61
  /**
62
62
  * 从一组 paths 中, 找到匹配当前 location 的 path, 返回序号
@@ -74,13 +74,13 @@ const matchPaths = function matchPaths() {
74
74
 
75
75
  if (!(matched !== null && matched !== void 0 && matched.length)) {
76
76
  return -1;
77
- } // 多个 path 都匹配时, 取一个最短的 path
77
+ } // 多个 path 都匹配时, 取一个最具体 (最长的) path
78
78
 
79
79
 
80
- const shortest = matched.slice(1).reduce((prev, cur) => {
81
- return prev.path.length <= cur.path.length ? prev : cur;
80
+ const mostSpecific = matched.slice(1).reduce((prev, cur) => {
81
+ return prev.path.length >= cur.path.length ? prev : cur;
82
82
  }, matched[0]);
83
- return shortest.index;
83
+ return mostSpecific.index;
84
84
  };
85
85
 
86
86
  exports.matchPaths = matchPaths;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/ui-react",
3
- "version": "2.1.27",
3
+ "version": "2.1.30",
4
4
  "description": "Some useful front-end web components that can be used in Blocklets.",
5
5
  "keywords": [
6
6
  "react",
@@ -34,8 +34,8 @@
34
34
  "url": "https://github.com/ArcBlock/ux/issues"
35
35
  },
36
36
  "dependencies": {
37
- "@arcblock/did-connect": "^2.1.27",
38
- "@arcblock/ux": "^2.1.27",
37
+ "@arcblock/did-connect": "^2.1.30",
38
+ "@arcblock/ux": "^2.1.30",
39
39
  "@iconify/iconify": "^2.2.1",
40
40
  "@mui/material": "^5.6.4",
41
41
  "core-js": "^3.6.4",
@@ -57,5 +57,5 @@
57
57
  "eslint-plugin-react-hooks": "^4.2.0",
58
58
  "jest": "^24.1.0"
59
59
  },
60
- "gitHead": "a5f51b0432dbdfe806276bdb10b68df19575687e"
60
+ "gitHead": "16c9e4b3d8664ef14440b248bdf34b46fc8396d1"
61
61
  }
@@ -1,7 +1,7 @@
1
1
  import { isValidElement } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import styled from 'styled-components';
4
- import useTheme from '@mui/styles/useTheme';
4
+ import { useTheme } from '@mui/material/styles';
5
5
 
6
6
  export default function Brand({ name, logo, description, ...rest }) {
7
7
  const theme = useTheme();
@@ -1,5 +1,5 @@
1
1
  import styled from 'styled-components';
2
- import useTheme from '@mui/styles/useTheme';
2
+ import { useTheme } from '@mui/material/styles';
3
3
  import Box from '@mui/material/Box';
4
4
  import Container from '@mui/material/Container';
5
5
  import { withErrorBoundary } from 'react-error-boundary';
@@ -2,7 +2,7 @@
2
2
  import { useState } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import styled from 'styled-components';
5
- import useTheme from '@mui/styles/useTheme';
5
+ import { useTheme } from '@mui/material/styles';
6
6
  import clsx from 'clsx';
7
7
 
8
8
  /**
package/src/Footer/row.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import styled from 'styled-components';
3
- import useTheme from '@mui/styles/useTheme';
3
+ import { useTheme } from '@mui/material/styles';
4
4
  import clsx from 'clsx';
5
5
 
6
6
  export default function Row({ children, autoCenter, ...rest }) {
@@ -1,6 +1,6 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import styled from 'styled-components';
3
- import useTheme from '@mui/styles/useTheme';
3
+ import { useTheme } from '@mui/material/styles';
4
4
  import Icon from '../Icon';
5
5
 
6
6
  export default function SocialMedia({ items, ...rest }) {
package/src/utils.js CHANGED
@@ -32,7 +32,7 @@ export const matchPath = (path) => {
32
32
  const ensureTrailingSlash = (str) => (str.endsWith('/') ? str : `${str}/`);
33
33
  const pathname = ensureTrailingSlash(window.location.pathname);
34
34
  const normalizedPath = ensureTrailingSlash(new URL(path, window.location.origin).pathname);
35
- return normalizedPath.startsWith(pathname);
35
+ return pathname.startsWith(normalizedPath);
36
36
  };
37
37
 
38
38
  /**
@@ -43,9 +43,9 @@ export const matchPaths = (paths = []) => {
43
43
  if (!matched?.length) {
44
44
  return -1;
45
45
  }
46
- // 多个 path 都匹配时, 取一个最短的 path
47
- const shortest = matched.slice(1).reduce((prev, cur) => {
48
- return prev.path.length <= cur.path.length ? prev : cur;
46
+ // 多个 path 都匹配时, 取一个最具体 (最长的) path
47
+ const mostSpecific = matched.slice(1).reduce((prev, cur) => {
48
+ return prev.path.length >= cur.path.length ? prev : cur;
49
49
  }, matched[0]);
50
- return shortest.index;
50
+ return mostSpecific.index;
51
51
  };