@blocklet/list 0.8.35 → 0.8.38

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.
@@ -43,6 +43,7 @@ function FilterChip(_ref) {
43
43
  if (!label) return null;
44
44
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyleDiv, _objectSpread(_objectSpread({}, containerProps), {}, {
45
45
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Chip, {
46
+ "data-cy": "filter-tag",
46
47
  icon: icon,
47
48
  label: label,
48
49
  onDelete: onDelete
@@ -109,10 +109,11 @@ function FilterProvider(_ref) {
109
109
  const selectedCategory = finalFilters.category;
110
110
  const hasDeveloperFilter = !!finalFilters.developer;
111
111
  const categoryState = (0, _react.useMemo)(() => {
112
+ // 当按作者过滤时,需要从所有blocklets中找出属于作者的分类
112
113
  return !hasDeveloperFilter ? {
113
114
  data: allCategories
114
- } : (0, _utils.getCategories)(allBlocklets, finalFilters.developer);
115
- }, [hasDeveloperFilter, allCategories]);
115
+ } : (0, _utils.getCategoriesByAuthor)(allBlocklets, finalFilters.developer);
116
+ }, [hasDeveloperFilter, allCategories, allBlocklets]);
116
117
  const blockletList = (0, _react.useMemo)(() => {
117
118
  var _finalFilters$keyword;
118
119
 
package/lib/libs/utils.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.urlStringify = exports.replaceTranslate = exports.removeUndefined = exports.isMobileScreen = exports.getStoreDetail = exports.getSortOptions = exports.getPrices = exports.getCategoryOptions = exports.getCategories = exports.formatLogoPath = exports.formatError = exports.filterBlockletByPrice = void 0;
6
+ exports.urlStringify = exports.replaceTranslate = exports.removeUndefined = exports.isMobileScreen = exports.getStoreDetail = exports.getSortOptions = exports.getPrices = exports.getCategoryOptions = exports.getCategoriesByAuthor = exports.formatLogoPath = exports.formatError = exports.filterBlockletByPrice = void 0;
7
7
 
8
8
  var _urlJoin = _interopRequireDefault(require("url-join"));
9
9
 
@@ -59,7 +59,7 @@ const getCategoryOptions = function getCategoryOptions() {
59
59
  }));
60
60
  };
61
61
  /**
62
- * 从开发者所属 blocklets 中的得到 Categories
62
+ * blocklets 中的得到属于作者的 Categories
63
63
  * @param {*} list
64
64
  * @param {*} developerDid
65
65
  * @returns
@@ -68,7 +68,7 @@ const getCategoryOptions = function getCategoryOptions() {
68
68
 
69
69
  exports.getCategoryOptions = getCategoryOptions;
70
70
 
71
- const getCategories = function getCategories() {
71
+ const getCategoriesByAuthor = function getCategoriesByAuthor() {
72
72
  let list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
73
73
  let developerDid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
74
74
  const filterList = list.filter(item => developerDid ? item.owner.did === developerDid : true);
@@ -87,7 +87,7 @@ const getCategories = function getCategories() {
87
87
  */
88
88
 
89
89
 
90
- exports.getCategories = getCategories;
90
+ exports.getCategoriesByAuthor = getCategoriesByAuthor;
91
91
 
92
92
  const filterBlockletByPrice = function filterBlockletByPrice() {
93
93
  let list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/list",
3
- "version": "0.8.35",
3
+ "version": "0.8.38",
4
4
  "description": "Common ux components of blocklet",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -38,7 +38,7 @@
38
38
  "react": ">=18.1.0"
39
39
  },
40
40
  "dependencies": {
41
- "@arcblock/ux": "^2.1.21",
41
+ "@arcblock/ux": "^2.1.30",
42
42
  "@emotion/react": "^11.9.0",
43
43
  "@emotion/styled": "^11.8.1",
44
44
  "@mui/icons-material": "^5.6.2",
@@ -64,5 +64,5 @@
64
64
  "eslint": "^8.16.0",
65
65
  "prettier": "^2.6.2"
66
66
  },
67
- "gitHead": "f6a52e3c84e6eb4cd5625f688a55d7da1b477740"
67
+ "gitHead": "f08730b178cc3694c813b585941d1e9846120103"
68
68
  }
@@ -15,7 +15,7 @@ function FilterChip({ label, icon, onDelete, ...containerProps }) {
15
15
  if (!label) return null;
16
16
  return (
17
17
  <StyleDiv {...containerProps}>
18
- <Chip icon={icon} label={label} onDelete={onDelete} />
18
+ <Chip data-cy="filter-tag" icon={icon} label={label} onDelete={onDelete} />
19
19
  </StyleDiv>
20
20
  );
21
21
  }
@@ -5,7 +5,7 @@ import orderBy from 'lodash/orderBy';
5
5
  import axios from 'axios';
6
6
  import isArray from 'lodash/isArray';
7
7
  import {
8
- getCategories,
8
+ getCategoriesByAuthor,
9
9
  filterBlockletByPrice,
10
10
  replaceTranslate,
11
11
  getPrices,
@@ -59,8 +59,9 @@ function FilterProvider({ filters, children, endpoint, locale, blockletRender, o
59
59
  const selectedCategory = finalFilters.category;
60
60
  const hasDeveloperFilter = !!finalFilters.developer;
61
61
  const categoryState = useMemo(() => {
62
- return !hasDeveloperFilter ? { data: allCategories } : getCategories(allBlocklets, finalFilters.developer);
63
- }, [hasDeveloperFilter, allCategories]);
62
+ // 当按作者过滤时,需要从所有blocklets中找出属于作者的分类
63
+ return !hasDeveloperFilter ? { data: allCategories } : getCategoriesByAuthor(allBlocklets, finalFilters.developer);
64
+ }, [hasDeveloperFilter, allCategories, allBlocklets]);
64
65
 
65
66
  const blockletList = useMemo(() => {
66
67
  const sortByName = (x) => x?.title?.toLocaleLowerCase() || x?.name?.toLocaleLowerCase(); // 按名称排序
package/src/libs/utils.js CHANGED
@@ -39,12 +39,12 @@ const getCategoryOptions = (list = [], locale = 'en') => {
39
39
  return list.map((item) => ({ name: item.locales[locale], value: item.name }));
40
40
  };
41
41
  /**
42
- * 从开发者所属 blocklets 中的得到 Categories
42
+ * blocklets 中的得到属于作者的 Categories
43
43
  * @param {*} list
44
44
  * @param {*} developerDid
45
45
  * @returns
46
46
  */
47
- const getCategories = (list = [], developerDid = null) => {
47
+ const getCategoriesByAuthor = (list = [], developerDid = null) => {
48
48
  const filterList = list.filter((item) => (developerDid ? item.owner.did === developerDid : true));
49
49
  const Categories = filterList.map((item) => item.category);
50
50
  const res = new Map();
@@ -113,7 +113,7 @@ const isMobileScreen = () => {
113
113
  export {
114
114
  getSortOptions,
115
115
  getPrices,
116
- getCategories,
116
+ getCategoriesByAuthor,
117
117
  filterBlockletByPrice,
118
118
  getStoreDetail,
119
119
  formatLogoPath,