@blocklet/list 0.8.30 → 0.8.33
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.
- package/lib/components/list/index.js +149 -4
- package/lib/contexts/filter.js +5 -2
- package/lib/libs/prop-types.js +3 -1
- package/package.json +3 -3
- package/src/components/list/index.js +125 -2
- package/src/contexts/filter.js +3 -1
- package/src/libs/prop-types.js +2 -0
- package/lib/components/list/list.js +0 -158
- package/src/components/list/list.js +0 -126
|
@@ -3,11 +3,156 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = BlockletList;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
|
|
10
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
+
|
|
12
|
+
var _Empty = _interopRequireDefault(require("@arcblock/ux/lib/Empty"));
|
|
13
|
+
|
|
14
|
+
var _Alert = _interopRequireDefault(require("@arcblock/ux/lib/Alert"));
|
|
15
|
+
|
|
16
|
+
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
17
|
+
|
|
18
|
+
var _Grid = _interopRequireDefault(require("@mui/material/Grid"));
|
|
19
|
+
|
|
20
|
+
var _CircularProgress = _interopRequireDefault(require("@mui/material/CircularProgress"));
|
|
21
|
+
|
|
22
|
+
var _empty = require("./empty");
|
|
23
|
+
|
|
24
|
+
var _filter = require("../../contexts/filter");
|
|
25
|
+
|
|
26
|
+
var _utils = require("../../libs/utils");
|
|
27
|
+
|
|
28
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
29
|
+
|
|
30
|
+
const _excluded = ["blocklets"];
|
|
9
31
|
|
|
10
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
33
|
|
|
12
|
-
var
|
|
13
|
-
|
|
34
|
+
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
|
+
|
|
36
|
+
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; }
|
|
37
|
+
|
|
38
|
+
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; }
|
|
39
|
+
|
|
40
|
+
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; }
|
|
41
|
+
|
|
42
|
+
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; }
|
|
43
|
+
|
|
44
|
+
function BlockletList(_ref) {
|
|
45
|
+
let {
|
|
46
|
+
blocklets
|
|
47
|
+
} = _ref,
|
|
48
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
49
|
+
|
|
50
|
+
const {
|
|
51
|
+
blockletRender,
|
|
52
|
+
errors,
|
|
53
|
+
loadings,
|
|
54
|
+
selectedCategory,
|
|
55
|
+
blockletList,
|
|
56
|
+
getCategoryLocale,
|
|
57
|
+
filters,
|
|
58
|
+
t
|
|
59
|
+
} = (0, _filter.useFilterContext)();
|
|
60
|
+
const showFilterTip = !!selectedCategory || !!filters.price;
|
|
61
|
+
|
|
62
|
+
if (errors.fetchBlockletsError) {
|
|
63
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
|
|
64
|
+
type: "error",
|
|
65
|
+
variant: "icon",
|
|
66
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
67
|
+
children: (0, _utils.formatError)(errors.fetchBlockletsError)
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (loadings.fetchBlockletsLoading) {
|
|
73
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
74
|
+
display: "flex",
|
|
75
|
+
alignItems: "center",
|
|
76
|
+
justifyContent: "center",
|
|
77
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {})
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (filters.keyword && showFilterTip && blockletList.length === 0) {
|
|
82
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(CustomEmpty, {
|
|
83
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_empty.EmptyTitle, {
|
|
84
|
+
primaryStart: t('blocklet.noBlockletPart1'),
|
|
85
|
+
primaryEnd: t('blocklet.noBlockletPart2'),
|
|
86
|
+
filter: filters.keyword
|
|
87
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_empty.NoResultsTips, {
|
|
88
|
+
keywordTip: true,
|
|
89
|
+
filterTip: true
|
|
90
|
+
})]
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (filters.keyword && blockletList.length === 0) {
|
|
95
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(CustomEmpty, {
|
|
96
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_empty.EmptyTitle, {
|
|
97
|
+
primaryStart: t('blocklet.noBlockletPart1'),
|
|
98
|
+
primaryEnd: t('blocklet.noBlockletPart2'),
|
|
99
|
+
filter: filters.keyword
|
|
100
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_empty.NoResultsTips, {
|
|
101
|
+
keywordTip: true
|
|
102
|
+
})]
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (showFilterTip && blockletList.length === 0) {
|
|
107
|
+
const categoryLocale = getCategoryLocale(selectedCategory);
|
|
108
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(CustomEmpty, {
|
|
109
|
+
children: [categoryLocale ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_empty.EmptyTitle, {
|
|
110
|
+
primaryStart: t('blocklet.noCategoryResults1'),
|
|
111
|
+
primaryEnd: t('blocklet.noCategoryResults2'),
|
|
112
|
+
filter: categoryLocale
|
|
113
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_empty.NoResults, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_empty.NoResultsTips, {
|
|
114
|
+
filterTip: true
|
|
115
|
+
})]
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (blockletList.length === 0) {
|
|
120
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(CustomEmpty, {
|
|
121
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_empty.NoResults, {})
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledGrid, _objectSpread(_objectSpread({
|
|
126
|
+
container: true
|
|
127
|
+
}, rest), {}, {
|
|
128
|
+
children: blocklets.map(blocklet => /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledGridItem, {
|
|
129
|
+
item: true,
|
|
130
|
+
lg: 4,
|
|
131
|
+
md: 6,
|
|
132
|
+
sm: 6,
|
|
133
|
+
xs: 12,
|
|
134
|
+
"data-blocklet-did": blocklet.did,
|
|
135
|
+
children: blockletRender({
|
|
136
|
+
blocklet,
|
|
137
|
+
blocklets: blockletList
|
|
138
|
+
})
|
|
139
|
+
}, blocklet.did))
|
|
140
|
+
}));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
BlockletList.propTypes = {
|
|
144
|
+
blocklets: _propTypes.default.array.isRequired
|
|
145
|
+
};
|
|
146
|
+
BlockletList.defaultProps = {};
|
|
147
|
+
const StyledGrid = (0, _styledComponents.default)(_Grid.default).withConfig({
|
|
148
|
+
displayName: "list__StyledGrid",
|
|
149
|
+
componentId: "sc-1guvpon-0"
|
|
150
|
+
})(["&.MuiGrid-root{width:auto;margin:0 -16px;}"]);
|
|
151
|
+
const StyledGridItem = (0, _styledComponents.default)(_Grid.default).withConfig({
|
|
152
|
+
displayName: "list__StyledGridItem",
|
|
153
|
+
componentId: "sc-1guvpon-1"
|
|
154
|
+
})(["@media (max-width:", "px){&.MuiGrid-item{padding-bottom:0px;}}@media (min-width:", "px){&.MuiGrid-item{margin-bottom:", ";}}"], props => props.theme.breakpoints.values.sm, props => props.theme.breakpoints.values.sm, props => props.theme.spacing(2));
|
|
155
|
+
const CustomEmpty = (0, _styledComponents.default)(_Empty.default).withConfig({
|
|
156
|
+
displayName: "list__CustomEmpty",
|
|
157
|
+
componentId: "sc-1guvpon-2"
|
|
158
|
+
})(["text-align:center;.primary{color:", ";}.tips{margin-top:", ";}"], props => props.theme.palette.primary.main, props => props.theme.spacing(1));
|
package/lib/contexts/filter.js
CHANGED
|
@@ -48,7 +48,8 @@ function FilterProvider(_ref) {
|
|
|
48
48
|
endpoint,
|
|
49
49
|
locale,
|
|
50
50
|
blockletRender,
|
|
51
|
-
onFilterChange
|
|
51
|
+
onFilterChange,
|
|
52
|
+
extraFilter
|
|
52
53
|
} = _ref;
|
|
53
54
|
|
|
54
55
|
const storeApi = _axios.default.create({
|
|
@@ -135,7 +136,9 @@ function FilterProvider(_ref) {
|
|
|
135
136
|
var _ref2, _item$description, _item$version;
|
|
136
137
|
|
|
137
138
|
return ((_ref2 = (item === null || item === void 0 ? void 0 : item.title) || (item === null || item === void 0 ? void 0 : item.name)) === null || _ref2 === void 0 ? void 0 : _ref2.toLocaleLowerCase().includes(lowerSearch)) || ((_item$description = item.description) === null || _item$description === void 0 ? void 0 : _item$description.toLocaleLowerCase().includes(lowerSearch)) || (item === null || item === void 0 ? void 0 : (_item$version = item.version) === null || _item$version === void 0 ? void 0 : _item$version.toLocaleLowerCase().includes(lowerSearch));
|
|
138
|
-
}); //
|
|
139
|
+
}); // 用户传入的过滤函数
|
|
140
|
+
|
|
141
|
+
blocklets = extraFilter(blocklets); // 排序
|
|
139
142
|
|
|
140
143
|
return (0, _orderBy.default)(blocklets, [sortMap[finalFilters.sortBy]], [finalFilters.sortDirection]);
|
|
141
144
|
}, [allBlocklets, finalFilters]);
|
package/lib/libs/prop-types.js
CHANGED
|
@@ -18,6 +18,7 @@ const propTypes = {
|
|
|
18
18
|
category: _propTypes.default.string,
|
|
19
19
|
developer: _propTypes.default.string
|
|
20
20
|
}),
|
|
21
|
+
extraFilter: _propTypes.default.func,
|
|
21
22
|
endpoint: _propTypes.default.string.isRequired,
|
|
22
23
|
blockletRender: _propTypes.default.func.isRequired,
|
|
23
24
|
onFilterChange: _propTypes.default.func,
|
|
@@ -29,6 +30,7 @@ const defaultProps = {
|
|
|
29
30
|
baseUrl: null,
|
|
30
31
|
locale: 'zh',
|
|
31
32
|
filters: {},
|
|
32
|
-
onFilterChange: () => {}
|
|
33
|
+
onFilterChange: () => {},
|
|
34
|
+
extraFilter: list => list
|
|
33
35
|
};
|
|
34
36
|
exports.defaultProps = defaultProps;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/list",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.33",
|
|
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.
|
|
41
|
+
"@arcblock/ux": "^2.1.17",
|
|
42
42
|
"@emotion/react": "^11.9.0",
|
|
43
43
|
"@emotion/styled": "^11.8.1",
|
|
44
44
|
"@mui/icons-material": "^5.6.2",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"eslint": "^8.16.0",
|
|
63
63
|
"prettier": "^2.6.2"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "5e7c02cb3dfd0edff3f8290509f754b10bbc61bc"
|
|
66
66
|
}
|
|
@@ -1,3 +1,126 @@
|
|
|
1
|
-
import
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import Empty from '@arcblock/ux/lib/Empty';
|
|
4
|
+
import Alert from '@arcblock/ux/lib/Alert';
|
|
5
|
+
import Box from '@mui/material/Box';
|
|
6
|
+
import Grid from '@mui/material/Grid';
|
|
7
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
|
2
8
|
|
|
3
|
-
|
|
9
|
+
import { NoResults, EmptyTitle, NoResultsTips } from './empty';
|
|
10
|
+
import { useFilterContext } from '../../contexts/filter';
|
|
11
|
+
import { formatError } from '../../libs/utils';
|
|
12
|
+
|
|
13
|
+
export default function BlockletList({ blocklets, ...rest }) {
|
|
14
|
+
const { blockletRender, errors, loadings, selectedCategory, blockletList, getCategoryLocale, filters, t } =
|
|
15
|
+
useFilterContext();
|
|
16
|
+
|
|
17
|
+
const showFilterTip = !!selectedCategory || !!filters.price;
|
|
18
|
+
|
|
19
|
+
if (errors.fetchBlockletsError) {
|
|
20
|
+
return (
|
|
21
|
+
<Alert type="error" variant="icon">
|
|
22
|
+
<div>{formatError(errors.fetchBlockletsError)}</div>
|
|
23
|
+
</Alert>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
if (loadings.fetchBlockletsLoading) {
|
|
27
|
+
return (
|
|
28
|
+
<Box display="flex" alignItems="center" justifyContent="center">
|
|
29
|
+
<CircularProgress />
|
|
30
|
+
</Box>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
if (filters.keyword && showFilterTip && blockletList.length === 0) {
|
|
34
|
+
return (
|
|
35
|
+
<CustomEmpty>
|
|
36
|
+
<EmptyTitle
|
|
37
|
+
primaryStart={t('blocklet.noBlockletPart1')}
|
|
38
|
+
primaryEnd={t('blocklet.noBlockletPart2')}
|
|
39
|
+
filter={filters.keyword}
|
|
40
|
+
/>
|
|
41
|
+
<NoResultsTips keywordTip filterTip />
|
|
42
|
+
</CustomEmpty>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
if (filters.keyword && blockletList.length === 0) {
|
|
46
|
+
return (
|
|
47
|
+
<CustomEmpty>
|
|
48
|
+
<EmptyTitle
|
|
49
|
+
primaryStart={t('blocklet.noBlockletPart1')}
|
|
50
|
+
primaryEnd={t('blocklet.noBlockletPart2')}
|
|
51
|
+
filter={filters.keyword}
|
|
52
|
+
/>
|
|
53
|
+
<NoResultsTips keywordTip />
|
|
54
|
+
</CustomEmpty>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
if (showFilterTip && blockletList.length === 0) {
|
|
58
|
+
const categoryLocale = getCategoryLocale(selectedCategory);
|
|
59
|
+
return (
|
|
60
|
+
<CustomEmpty>
|
|
61
|
+
{categoryLocale ? (
|
|
62
|
+
<EmptyTitle
|
|
63
|
+
primaryStart={t('blocklet.noCategoryResults1')}
|
|
64
|
+
primaryEnd={t('blocklet.noCategoryResults2')}
|
|
65
|
+
filter={categoryLocale}
|
|
66
|
+
/>
|
|
67
|
+
) : (
|
|
68
|
+
<NoResults />
|
|
69
|
+
)}
|
|
70
|
+
<NoResultsTips filterTip />
|
|
71
|
+
</CustomEmpty>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
if (blockletList.length === 0) {
|
|
75
|
+
return (
|
|
76
|
+
<CustomEmpty>
|
|
77
|
+
<NoResults />
|
|
78
|
+
</CustomEmpty>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<StyledGrid container {...rest}>
|
|
84
|
+
{blocklets.map((blocklet) => (
|
|
85
|
+
<StyledGridItem item lg={4} md={6} sm={6} xs={12} key={blocklet.did} data-blocklet-did={blocklet.did}>
|
|
86
|
+
{blockletRender({ blocklet, blocklets: blockletList })}
|
|
87
|
+
</StyledGridItem>
|
|
88
|
+
))}
|
|
89
|
+
</StyledGrid>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
BlockletList.propTypes = {
|
|
94
|
+
blocklets: PropTypes.array.isRequired,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
BlockletList.defaultProps = {};
|
|
98
|
+
|
|
99
|
+
const StyledGrid = styled(Grid)`
|
|
100
|
+
&.MuiGrid-root {
|
|
101
|
+
width: auto;
|
|
102
|
+
margin: 0 -16px;
|
|
103
|
+
}
|
|
104
|
+
`;
|
|
105
|
+
|
|
106
|
+
const StyledGridItem = styled(Grid)`
|
|
107
|
+
@media (max-width: ${(props) => props.theme.breakpoints.values.sm}px) {
|
|
108
|
+
&.MuiGrid-item {
|
|
109
|
+
padding-bottom: 0px;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
@media (min-width: ${(props) => props.theme.breakpoints.values.sm}px) {
|
|
113
|
+
&.MuiGrid-item {
|
|
114
|
+
margin-bottom: ${(props) => props.theme.spacing(2)};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
`;
|
|
118
|
+
const CustomEmpty = styled(Empty)`
|
|
119
|
+
text-align: center;
|
|
120
|
+
.primary {
|
|
121
|
+
color: ${(props) => props.theme.palette.primary.main};
|
|
122
|
+
}
|
|
123
|
+
.tips {
|
|
124
|
+
margin-top: ${(props) => props.theme.spacing(1)};
|
|
125
|
+
}
|
|
126
|
+
`;
|
package/src/contexts/filter.js
CHANGED
|
@@ -12,7 +12,7 @@ import { propTypes, defaultProps } from '../libs/prop-types';
|
|
|
12
12
|
const Filter = createContext({});
|
|
13
13
|
const { Provider, Consumer } = Filter;
|
|
14
14
|
|
|
15
|
-
function FilterProvider({ filters, children, baseUrl, endpoint, locale, blockletRender, onFilterChange }) {
|
|
15
|
+
function FilterProvider({ filters, children, baseUrl, endpoint, locale, blockletRender, onFilterChange, extraFilter }) {
|
|
16
16
|
const storeApi = axios.create({
|
|
17
17
|
baseURL: endpoint,
|
|
18
18
|
});
|
|
@@ -78,6 +78,8 @@ function FilterProvider({ filters, children, baseUrl, endpoint, locale, blocklet
|
|
|
78
78
|
item?.version?.toLocaleLowerCase().includes(lowerSearch)
|
|
79
79
|
);
|
|
80
80
|
});
|
|
81
|
+
// 用户传入的过滤函数
|
|
82
|
+
blocklets = extraFilter(blocklets);
|
|
81
83
|
// 排序
|
|
82
84
|
return orderBy(blocklets, [sortMap[finalFilters.sortBy]], [finalFilters.sortDirection]);
|
|
83
85
|
}, [allBlocklets, finalFilters]);
|
package/src/libs/prop-types.js
CHANGED
|
@@ -9,6 +9,7 @@ const propTypes = {
|
|
|
9
9
|
category: PropTypes.string,
|
|
10
10
|
developer: PropTypes.string,
|
|
11
11
|
}),
|
|
12
|
+
extraFilter: PropTypes.func,
|
|
12
13
|
endpoint: PropTypes.string.isRequired,
|
|
13
14
|
blockletRender: PropTypes.func.isRequired,
|
|
14
15
|
onFilterChange: PropTypes.func,
|
|
@@ -21,6 +22,7 @@ const defaultProps = {
|
|
|
21
22
|
locale: 'zh',
|
|
22
23
|
filters: {},
|
|
23
24
|
onFilterChange: () => {},
|
|
25
|
+
extraFilter: (list) => list,
|
|
24
26
|
};
|
|
25
27
|
|
|
26
28
|
export { propTypes, defaultProps };
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = BlockletList;
|
|
7
|
-
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
|
|
10
|
-
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
-
|
|
12
|
-
var _Empty = _interopRequireDefault(require("@arcblock/ux/lib/Empty"));
|
|
13
|
-
|
|
14
|
-
var _Alert = _interopRequireDefault(require("@arcblock/ux/lib/Alert"));
|
|
15
|
-
|
|
16
|
-
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
17
|
-
|
|
18
|
-
var _Grid = _interopRequireDefault(require("@mui/material/Grid"));
|
|
19
|
-
|
|
20
|
-
var _CircularProgress = _interopRequireDefault(require("@mui/material/CircularProgress"));
|
|
21
|
-
|
|
22
|
-
var _empty = require("./empty");
|
|
23
|
-
|
|
24
|
-
var _filter = require("../../contexts/filter");
|
|
25
|
-
|
|
26
|
-
var _utils = require("../../libs/utils");
|
|
27
|
-
|
|
28
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
29
|
-
|
|
30
|
-
const _excluded = ["blocklets"];
|
|
31
|
-
|
|
32
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
|
-
|
|
34
|
-
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
|
-
|
|
36
|
-
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; }
|
|
37
|
-
|
|
38
|
-
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; }
|
|
39
|
-
|
|
40
|
-
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; }
|
|
41
|
-
|
|
42
|
-
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; }
|
|
43
|
-
|
|
44
|
-
function BlockletList(_ref) {
|
|
45
|
-
let {
|
|
46
|
-
blocklets
|
|
47
|
-
} = _ref,
|
|
48
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
49
|
-
|
|
50
|
-
const {
|
|
51
|
-
blockletRender,
|
|
52
|
-
errors,
|
|
53
|
-
loadings,
|
|
54
|
-
selectedCategory,
|
|
55
|
-
blockletList,
|
|
56
|
-
getCategoryLocale,
|
|
57
|
-
filters,
|
|
58
|
-
t
|
|
59
|
-
} = (0, _filter.useFilterContext)();
|
|
60
|
-
const showFilterTip = !!selectedCategory || !!filters.price;
|
|
61
|
-
|
|
62
|
-
if (errors.fetchBlockletsError) {
|
|
63
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
|
|
64
|
-
type: "error",
|
|
65
|
-
variant: "icon",
|
|
66
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
67
|
-
children: (0, _utils.formatError)(errors.fetchBlockletsError)
|
|
68
|
-
})
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (loadings.fetchBlockletsLoading) {
|
|
73
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
74
|
-
display: "flex",
|
|
75
|
-
alignItems: "center",
|
|
76
|
-
justifyContent: "center",
|
|
77
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {})
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (filters.keyword && showFilterTip && blockletList.length === 0) {
|
|
82
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(CustomEmpty, {
|
|
83
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_empty.EmptyTitle, {
|
|
84
|
-
primaryStart: t('blocklet.noBlockletPart1'),
|
|
85
|
-
primaryEnd: t('blocklet.noBlockletPart2'),
|
|
86
|
-
filter: filters.keyword
|
|
87
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_empty.NoResultsTips, {
|
|
88
|
-
keywordTip: true,
|
|
89
|
-
filterTip: true
|
|
90
|
-
})]
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (filters.keyword && blockletList.length === 0) {
|
|
95
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(CustomEmpty, {
|
|
96
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_empty.EmptyTitle, {
|
|
97
|
-
primaryStart: t('blocklet.noBlockletPart1'),
|
|
98
|
-
primaryEnd: t('blocklet.noBlockletPart2'),
|
|
99
|
-
filter: filters.keyword
|
|
100
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_empty.NoResultsTips, {
|
|
101
|
-
keywordTip: true
|
|
102
|
-
})]
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (showFilterTip && blockletList.length === 0) {
|
|
107
|
-
const categoryLocale = getCategoryLocale(selectedCategory);
|
|
108
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(CustomEmpty, {
|
|
109
|
-
children: [categoryLocale ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_empty.EmptyTitle, {
|
|
110
|
-
primaryStart: t('blocklet.noCategoryResults1'),
|
|
111
|
-
primaryEnd: t('blocklet.noCategoryResults2'),
|
|
112
|
-
filter: categoryLocale
|
|
113
|
-
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_empty.NoResults, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_empty.NoResultsTips, {
|
|
114
|
-
filterTip: true
|
|
115
|
-
})]
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (blockletList.length === 0) {
|
|
120
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(CustomEmpty, {
|
|
121
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_empty.NoResults, {})
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledGrid, _objectSpread(_objectSpread({
|
|
126
|
-
container: true
|
|
127
|
-
}, rest), {}, {
|
|
128
|
-
children: blocklets.map(blocklet => /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledGridItem, {
|
|
129
|
-
item: true,
|
|
130
|
-
lg: 4,
|
|
131
|
-
md: 6,
|
|
132
|
-
sm: 6,
|
|
133
|
-
xs: 12,
|
|
134
|
-
"data-blocklet-did": blocklet.did,
|
|
135
|
-
children: blockletRender({
|
|
136
|
-
blocklet,
|
|
137
|
-
blocklets: blockletList
|
|
138
|
-
})
|
|
139
|
-
}, blocklet.did))
|
|
140
|
-
}));
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
BlockletList.propTypes = {
|
|
144
|
-
blocklets: _propTypes.default.array.isRequired
|
|
145
|
-
};
|
|
146
|
-
BlockletList.defaultProps = {};
|
|
147
|
-
const StyledGrid = (0, _styledComponents.default)(_Grid.default).withConfig({
|
|
148
|
-
displayName: "list__StyledGrid",
|
|
149
|
-
componentId: "sc-jzgpev-0"
|
|
150
|
-
})(["&.MuiGrid-root{width:auto;margin:0 -16px;}"]);
|
|
151
|
-
const StyledGridItem = (0, _styledComponents.default)(_Grid.default).withConfig({
|
|
152
|
-
displayName: "list__StyledGridItem",
|
|
153
|
-
componentId: "sc-jzgpev-1"
|
|
154
|
-
})(["@media (max-width:", "px){&.MuiGrid-item{padding-bottom:0px;}}@media (min-width:", "px){&.MuiGrid-item{margin-bottom:", ";}}"], props => props.theme.breakpoints.values.sm, props => props.theme.breakpoints.values.sm, props => props.theme.spacing(2));
|
|
155
|
-
const CustomEmpty = (0, _styledComponents.default)(_Empty.default).withConfig({
|
|
156
|
-
displayName: "list__CustomEmpty",
|
|
157
|
-
componentId: "sc-jzgpev-2"
|
|
158
|
-
})(["text-align:center;.primary{color:", ";}.tips{margin-top:", ";}"], props => props.theme.palette.primary.main, props => props.theme.spacing(1));
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
import Empty from '@arcblock/ux/lib/Empty';
|
|
4
|
-
import Alert from '@arcblock/ux/lib/Alert';
|
|
5
|
-
import Box from '@mui/material/Box';
|
|
6
|
-
import Grid from '@mui/material/Grid';
|
|
7
|
-
import CircularProgress from '@mui/material/CircularProgress';
|
|
8
|
-
|
|
9
|
-
import { NoResults, EmptyTitle, NoResultsTips } from './empty';
|
|
10
|
-
import { useFilterContext } from '../../contexts/filter';
|
|
11
|
-
import { formatError } from '../../libs/utils';
|
|
12
|
-
|
|
13
|
-
export default function BlockletList({ blocklets, ...rest }) {
|
|
14
|
-
const { blockletRender, errors, loadings, selectedCategory, blockletList, getCategoryLocale, filters, t } =
|
|
15
|
-
useFilterContext();
|
|
16
|
-
|
|
17
|
-
const showFilterTip = !!selectedCategory || !!filters.price;
|
|
18
|
-
|
|
19
|
-
if (errors.fetchBlockletsError) {
|
|
20
|
-
return (
|
|
21
|
-
<Alert type="error" variant="icon">
|
|
22
|
-
<div>{formatError(errors.fetchBlockletsError)}</div>
|
|
23
|
-
</Alert>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
if (loadings.fetchBlockletsLoading) {
|
|
27
|
-
return (
|
|
28
|
-
<Box display="flex" alignItems="center" justifyContent="center">
|
|
29
|
-
<CircularProgress />
|
|
30
|
-
</Box>
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
if (filters.keyword && showFilterTip && blockletList.length === 0) {
|
|
34
|
-
return (
|
|
35
|
-
<CustomEmpty>
|
|
36
|
-
<EmptyTitle
|
|
37
|
-
primaryStart={t('blocklet.noBlockletPart1')}
|
|
38
|
-
primaryEnd={t('blocklet.noBlockletPart2')}
|
|
39
|
-
filter={filters.keyword}
|
|
40
|
-
/>
|
|
41
|
-
<NoResultsTips keywordTip filterTip />
|
|
42
|
-
</CustomEmpty>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
if (filters.keyword && blockletList.length === 0) {
|
|
46
|
-
return (
|
|
47
|
-
<CustomEmpty>
|
|
48
|
-
<EmptyTitle
|
|
49
|
-
primaryStart={t('blocklet.noBlockletPart1')}
|
|
50
|
-
primaryEnd={t('blocklet.noBlockletPart2')}
|
|
51
|
-
filter={filters.keyword}
|
|
52
|
-
/>
|
|
53
|
-
<NoResultsTips keywordTip />
|
|
54
|
-
</CustomEmpty>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
if (showFilterTip && blockletList.length === 0) {
|
|
58
|
-
const categoryLocale = getCategoryLocale(selectedCategory);
|
|
59
|
-
return (
|
|
60
|
-
<CustomEmpty>
|
|
61
|
-
{categoryLocale ? (
|
|
62
|
-
<EmptyTitle
|
|
63
|
-
primaryStart={t('blocklet.noCategoryResults1')}
|
|
64
|
-
primaryEnd={t('blocklet.noCategoryResults2')}
|
|
65
|
-
filter={categoryLocale}
|
|
66
|
-
/>
|
|
67
|
-
) : (
|
|
68
|
-
<NoResults />
|
|
69
|
-
)}
|
|
70
|
-
<NoResultsTips filterTip />
|
|
71
|
-
</CustomEmpty>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
if (blockletList.length === 0) {
|
|
75
|
-
return (
|
|
76
|
-
<CustomEmpty>
|
|
77
|
-
<NoResults />
|
|
78
|
-
</CustomEmpty>
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<StyledGrid container {...rest}>
|
|
84
|
-
{blocklets.map((blocklet) => (
|
|
85
|
-
<StyledGridItem item lg={4} md={6} sm={6} xs={12} key={blocklet.did} data-blocklet-did={blocklet.did}>
|
|
86
|
-
{blockletRender({ blocklet, blocklets: blockletList })}
|
|
87
|
-
</StyledGridItem>
|
|
88
|
-
))}
|
|
89
|
-
</StyledGrid>
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
BlockletList.propTypes = {
|
|
94
|
-
blocklets: PropTypes.array.isRequired,
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
BlockletList.defaultProps = {};
|
|
98
|
-
|
|
99
|
-
const StyledGrid = styled(Grid)`
|
|
100
|
-
&.MuiGrid-root {
|
|
101
|
-
width: auto;
|
|
102
|
-
margin: 0 -16px;
|
|
103
|
-
}
|
|
104
|
-
`;
|
|
105
|
-
|
|
106
|
-
const StyledGridItem = styled(Grid)`
|
|
107
|
-
@media (max-width: ${(props) => props.theme.breakpoints.values.sm}px) {
|
|
108
|
-
&.MuiGrid-item {
|
|
109
|
-
padding-bottom: 0px;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
@media (min-width: ${(props) => props.theme.breakpoints.values.sm}px) {
|
|
113
|
-
&.MuiGrid-item {
|
|
114
|
-
margin-bottom: ${(props) => props.theme.spacing(2)};
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
`;
|
|
118
|
-
const CustomEmpty = styled(Empty)`
|
|
119
|
-
text-align: center;
|
|
120
|
-
.primary {
|
|
121
|
-
color: ${(props) => props.theme.palette.primary.main};
|
|
122
|
-
}
|
|
123
|
-
.tips {
|
|
124
|
-
margin-top: ${(props) => props.theme.spacing(1)};
|
|
125
|
-
}
|
|
126
|
-
`;
|