@blocklet/list 0.12.86 → 0.12.88
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/assets/locale.js +2 -0
- package/lib/base.js +40 -9
- package/lib/components/base-search.js +1 -1
- package/lib/components/show-resources-switch.js +43 -0
- package/lib/contexts/filter.js +7 -1
- package/lib/index.es.js +503 -452
- package/package.json +2 -2
package/lib/assets/locale.js
CHANGED
|
@@ -9,6 +9,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
9
9
|
const en = {
|
|
10
10
|
common: {
|
|
11
11
|
searchStore: 'Search the store',
|
|
12
|
+
showResources: 'Show resources',
|
|
12
13
|
price: 'Price',
|
|
13
14
|
category: 'Category',
|
|
14
15
|
resourceType: 'Resource Type',
|
|
@@ -48,6 +49,7 @@ const en = {
|
|
|
48
49
|
const zh = {
|
|
49
50
|
common: {
|
|
50
51
|
searchStore: '搜索商店内应用',
|
|
52
|
+
showResources: '显示资源型应用',
|
|
51
53
|
price: '价格',
|
|
52
54
|
category: '类别',
|
|
53
55
|
resourceType: '资源类型',
|
package/lib/base.js
CHANGED
|
@@ -10,6 +10,7 @@ var _material = require("@mui/material");
|
|
|
10
10
|
var _Face = _interopRequireDefault(require("@mui/icons-material/Face"));
|
|
11
11
|
var _reactErrorBoundary = require("react-error-boundary");
|
|
12
12
|
var _ErrorBoundary = require("@arcblock/ux/lib/ErrorBoundary");
|
|
13
|
+
var _react = require("react");
|
|
13
14
|
var _filter = require("./contexts/filter");
|
|
14
15
|
var _customSelect = _interopRequireDefault(require("./components/custom-select"));
|
|
15
16
|
var _filter2 = require("./components/filter");
|
|
@@ -18,12 +19,13 @@ var _list = _interopRequireDefault(require("./components/list"));
|
|
|
18
19
|
var _aside = _interopRequireDefault(require("./components/aside"));
|
|
19
20
|
var _baseSearch = _interopRequireDefault(require("./components/base-search"));
|
|
20
21
|
var _autocomplete = _interopRequireDefault(require("./components/autocomplete"));
|
|
22
|
+
var _showResourcesSwitch = _interopRequireDefault(require("./components/show-resources-switch"));
|
|
21
23
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
24
|
var _templateObject, _templateObject2;
|
|
23
25
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
26
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
25
27
|
function ListBase() {
|
|
26
|
-
var _sortOptions$find, _priceOptions$find;
|
|
28
|
+
var _sortOptions$find, _priceOptions$find, _filters$keyword;
|
|
27
29
|
const {
|
|
28
30
|
handleDeveloper,
|
|
29
31
|
blockletList,
|
|
@@ -37,6 +39,7 @@ function ListBase() {
|
|
|
37
39
|
getCategoryLocale,
|
|
38
40
|
priceOptions,
|
|
39
41
|
wrapChildren,
|
|
42
|
+
showResourcesSwitch,
|
|
40
43
|
baseSearch
|
|
41
44
|
} = (0, _filter.useFilterContext)();
|
|
42
45
|
const sortOptions = (0, _utils.getSortOptions)(t);
|
|
@@ -46,6 +49,9 @@ function ListBase() {
|
|
|
46
49
|
resourceType
|
|
47
50
|
} = filters || {};
|
|
48
51
|
const priceLocale = (_priceOptions$find = priceOptions.find(price => price.value === filters.price)) === null || _priceOptions$find === void 0 ? void 0 : _priceOptions$find.name;
|
|
52
|
+
const [searchFocused, setSearchFocused] = (0, _react.useState)(false);
|
|
53
|
+
const isMobile = (0, _material.useMediaQuery)(theme => theme.breakpoints.down('md'));
|
|
54
|
+
const showFullSearch = !baseSearch || searchFocused || isMobile || (filters === null || filters === void 0 || (_filters$keyword = filters.keyword) === null || _filters$keyword === void 0 ? void 0 : _filters$keyword.length);
|
|
49
55
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
50
56
|
display: "flex",
|
|
51
57
|
alignItems: "flex-start",
|
|
@@ -59,17 +65,42 @@ function ListBase() {
|
|
|
59
65
|
className: "filter-bar",
|
|
60
66
|
display: "flex",
|
|
61
67
|
alignItems: "center",
|
|
62
|
-
children: [
|
|
63
|
-
className: "
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("form", {
|
|
69
|
+
className: "search-form",
|
|
70
|
+
style: showFullSearch ? {
|
|
71
|
+
flex: 1,
|
|
72
|
+
width: '100%'
|
|
73
|
+
} : {},
|
|
74
|
+
onSubmit: e => {
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
e.stopPropagation();
|
|
77
|
+
},
|
|
78
|
+
onFocus: () => {
|
|
79
|
+
setSearchFocused(true);
|
|
80
|
+
},
|
|
81
|
+
onBlur: () => {
|
|
82
|
+
setSearchFocused(false);
|
|
83
|
+
},
|
|
84
|
+
children: baseSearch ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_baseSearch.default, {
|
|
85
|
+
className: "bl-search-container",
|
|
86
|
+
placeholder: t('common.searchStore')
|
|
87
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_autocomplete.default, {
|
|
88
|
+
onSelect: handleSearchSelect,
|
|
89
|
+
wrapChildren: wrapChildren
|
|
90
|
+
})
|
|
68
91
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
69
92
|
mt: 0,
|
|
70
93
|
ml: "16px",
|
|
71
94
|
className: "filter-container",
|
|
72
|
-
|
|
95
|
+
display: "flex",
|
|
96
|
+
alignItems: "center",
|
|
97
|
+
children: [!isMobile && showResourcesSwitch && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
98
|
+
ml: 1,
|
|
99
|
+
mr: 1,
|
|
100
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_showResourcesSwitch.default, {
|
|
101
|
+
t: t
|
|
102
|
+
})
|
|
103
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Hidden, {
|
|
73
104
|
mdUp: true,
|
|
74
105
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_filter2.FilterIcon, {})
|
|
75
106
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_customSelect.default, {
|
|
@@ -123,6 +154,6 @@ function ListBase() {
|
|
|
123
154
|
})]
|
|
124
155
|
});
|
|
125
156
|
}
|
|
126
|
-
const StyledMin = (0, _Theme.styled)('main')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n flex: 1;\n width: 100%;\n height: 100%;\n .filter-bar {\n justify-content: space-between;\n margin-bottom: ", ";\n }\n .sort-button {\n white-space: nowrap;\n }\n .bl-search-container {\n
|
|
157
|
+
const StyledMin = (0, _Theme.styled)('main')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n flex: 1;\n width: 100%;\n height: 100%;\n .filter-bar {\n justify-content: space-between;\n margin-bottom: ", ";\n }\n .sort-button {\n white-space: nowrap;\n }\n .bl-search-container {\n margin-left: 0px;\n }\n .filter-container {\n display: flex;\n justify-content: flex-end;\n }\n @media (max-width: ", "px) {\n .search-form {\n flex: 1;\n }\n .bl-search-container {\n width: 100%;\n margin-bottom: ", ";\n }\n .filter-container {\n margin-left: 0;\n display: flex;\n justify-content: flex-start;\n }\n .filter-bar {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n }\n }\n @media (max-width: ", "px) {\n .sort-button {\n font-size: 12px;\n }\n }\n"])), props => props.theme.spacing(2), props => props.theme.breakpoints.values.md, props => props.theme.spacing(2), props => props.theme.breakpoints.values.md);
|
|
127
158
|
const FilterContainer = (0, _Theme.styled)('div')(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: sticky;\n top: 0;\n z-index: 9;\n background-color: white;\n"])));
|
|
128
159
|
var _default = exports.default = ListBase;
|
|
@@ -79,7 +79,7 @@ BaseSearch.propTypes = {
|
|
|
79
79
|
BaseSearch.defaultProps = {
|
|
80
80
|
placeholder: 'Type to search...'
|
|
81
81
|
};
|
|
82
|
-
const StyledSearch = (0, _Theme.styled)(_material.OutlinedInput)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: ", ";\n font-size: 14px;\n border-radius: 6px;\n .MuiInputBase-input {\n padding: 8px 0 8px 10px;\n }\n .MuiOutlinedInput-notchedOutline {\n border: none;\n }\n .Mui-focused {\n background-color: #f6f6f6;\n .MuiInputBase-input::placeholder {\n color: transparent;\n }\n }\n"])), props => props.theme.palette.grey[50]);
|
|
82
|
+
const StyledSearch = (0, _Theme.styled)(_material.OutlinedInput)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: ", ";\n font-size: 14px;\n border-radius: 6px;\n width: 100%;\n .MuiInputBase-input {\n padding: 8px 0 8px 10px;\n }\n .MuiOutlinedInput-notchedOutline {\n border: none;\n }\n .Mui-focused {\n background-color: #f6f6f6;\n .MuiInputBase-input::placeholder {\n color: transparent;\n }\n }\n"])), props => props.theme.palette.grey[50]);
|
|
83
83
|
const StyledSearchIcon = (0, _Theme.styled)(_Search.default)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n color: ", ";\n font-size: 28px;\n @media (max-width: ", "px) {\n font-size: 24px;\n }\n"])), props => props.theme.palette.grey[500], props => props.theme.breakpoints.values.md);
|
|
84
84
|
const StyledCloseIcon = (0, _Theme.styled)(_Close.default)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n color: ", ";\n font-size: 16px;\n cursor: pointer;\n"])), props => props.theme.palette.grey[500]);
|
|
85
85
|
var _default = exports.default = BaseSearch;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _Switch = _interopRequireDefault(require("@arcblock/ux/lib/Switch"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _material = require("@mui/material");
|
|
10
|
+
var _filter = require("../contexts/filter");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
function ShowResourcesSwitch(_ref) {
|
|
14
|
+
let {
|
|
15
|
+
t
|
|
16
|
+
} = _ref;
|
|
17
|
+
const {
|
|
18
|
+
filters,
|
|
19
|
+
handleSwitchShowResources
|
|
20
|
+
} = (0, _filter.useFilterContext)();
|
|
21
|
+
const handleChange = () => {
|
|
22
|
+
filters.showResources = !filters.showResources;
|
|
23
|
+
handleSwitchShowResources();
|
|
24
|
+
};
|
|
25
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Switch.default, {
|
|
26
|
+
checked: filters.showResources,
|
|
27
|
+
onChange: handleChange,
|
|
28
|
+
labelProps: {
|
|
29
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
30
|
+
marginLeft: "8px",
|
|
31
|
+
fontSize: "small",
|
|
32
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
33
|
+
children: t('common.showResources')
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
ShowResourcesSwitch.propTypes = {
|
|
40
|
+
t: _propTypes.default.func.isRequired
|
|
41
|
+
};
|
|
42
|
+
ShowResourcesSwitch.defaultProps = {};
|
|
43
|
+
var _default = exports.default = ShowResourcesSwitch;
|
package/lib/contexts/filter.js
CHANGED
|
@@ -43,7 +43,8 @@ function FilterProvider(_ref) {
|
|
|
43
43
|
baseSearch,
|
|
44
44
|
serverVersion,
|
|
45
45
|
storeVersion,
|
|
46
|
-
fetchCategoryDelay
|
|
46
|
+
fetchCategoryDelay,
|
|
47
|
+
showResourcesSwitch
|
|
47
48
|
} = _ref;
|
|
48
49
|
const requestHeaders = {};
|
|
49
50
|
if (serverVersion) {
|
|
@@ -158,6 +159,7 @@ function FilterProvider(_ref) {
|
|
|
158
159
|
priceOptions,
|
|
159
160
|
storeApi,
|
|
160
161
|
baseSearch,
|
|
162
|
+
showResourcesSwitch,
|
|
161
163
|
hasNextPage: blockletsState.list.length < blockletsState.total,
|
|
162
164
|
handleSort: sort => {
|
|
163
165
|
const changeData = _objectSpread(_objectSpread({}, finalFilters), {}, {
|
|
@@ -200,6 +202,10 @@ function FilterProvider(_ref) {
|
|
|
200
202
|
});
|
|
201
203
|
onFilterChange(changeData);
|
|
202
204
|
},
|
|
205
|
+
handleSwitchShowResources: () => {
|
|
206
|
+
const changeData = _objectSpread({}, finalFilters);
|
|
207
|
+
onFilterChange(changeData);
|
|
208
|
+
},
|
|
203
209
|
loadMore: () => {
|
|
204
210
|
_loadMore();
|
|
205
211
|
},
|