@blocklet/list 0.8.19 → 0.8.22
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/base.js +37 -49
- package/lib/components/aside.js +53 -0
- package/lib/components/{filter-author.js → filter/custom-chip.js} +21 -28
- package/lib/components/filter/group.js +53 -0
- package/lib/components/filter/icon.js +93 -0
- package/lib/components/filter/index.js +31 -0
- package/lib/components/list/list.js +2 -3
- package/lib/components/search.js +1 -1
- package/lib/contexts/filter.js +5 -5
- package/lib/libs/utils.js +13 -2
- package/package.json +3 -3
- package/src/base.js +65 -78
- package/src/components/aside.js +36 -0
- package/src/components/filter/custom-chip.js +33 -0
- package/src/components/filter/group.js +64 -0
- package/src/components/filter/icon.js +69 -0
- package/src/components/filter/index.js +5 -0
- package/src/components/list/list.js +8 -3
- package/src/components/search.js +3 -11
- package/src/contexts/filter.js +9 -15
- package/src/libs/utils.js +4 -0
- package/lib/components/aside/aside.js +0 -64
- package/lib/components/aside/category-link-list.js +0 -78
- package/lib/components/aside/index.js +0 -13
- package/lib/components/category-select.js +0 -55
- package/src/components/aside/aside.js +0 -90
- package/src/components/aside/category-link-list.js +0 -53
- package/src/components/aside/index.js +0 -3
- package/src/components/category-select.js +0 -43
- package/src/components/filter-author.js +0 -38
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _aside = _interopRequireDefault(require("./aside"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
var _default = _aside.default;
|
|
13
|
-
exports.default = _default;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
var _material = require("@mui/material");
|
|
11
|
-
|
|
12
|
-
var _filter = require("../contexts/filter");
|
|
13
|
-
|
|
14
|
-
var _customSelect = _interopRequireDefault(require("./custom-select"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* 小屏幕下的分类选择器
|
|
20
|
-
* @returns
|
|
21
|
-
*/
|
|
22
|
-
const CategorySelect = () => {
|
|
23
|
-
var _categoryList$find;
|
|
24
|
-
|
|
25
|
-
const {
|
|
26
|
-
categoryList,
|
|
27
|
-
selectedCategory,
|
|
28
|
-
handleCategory,
|
|
29
|
-
t,
|
|
30
|
-
locale
|
|
31
|
-
} = (0, _filter.useFilterContext)();
|
|
32
|
-
|
|
33
|
-
const itemRender = item => {
|
|
34
|
-
return /*#__PURE__*/_react.default.createElement(_material.MenuItem, {
|
|
35
|
-
className: ['my-select__option', selectedCategory !== null && selectedCategory !== void 0 && selectedCategory.includes(item.name) ? 'my-select__option--active' : ''].join(' '),
|
|
36
|
-
key: item._id,
|
|
37
|
-
value: item.name,
|
|
38
|
-
onClick: () => handleCategory(item.name)
|
|
39
|
-
}, item.locales[locale]);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
return /*#__PURE__*/_react.default.createElement(_customSelect.default, {
|
|
43
|
-
value: selectedCategory || 'all',
|
|
44
|
-
options: categoryList,
|
|
45
|
-
title: ((_categoryList$find = categoryList.find(i => i.name === selectedCategory)) === null || _categoryList$find === void 0 ? void 0 : _categoryList$find.locales[locale]) || t('category.all'),
|
|
46
|
-
itemRender: itemRender,
|
|
47
|
-
prepend: /*#__PURE__*/_react.default.createElement(_material.MenuItem, {
|
|
48
|
-
value: "all",
|
|
49
|
-
onClick: () => handleCategory('all')
|
|
50
|
-
}, t('category.all'))
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
var _default = CategorySelect;
|
|
55
|
-
exports.default = _default;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Box, List, Checkbox, FormControlLabel } from '@mui/material';
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
|
|
5
|
-
import { useFilterContext } from '../../contexts/filter';
|
|
6
|
-
import { getPrices } from '../../libs/utils';
|
|
7
|
-
import Search from '../search';
|
|
8
|
-
import CategoryLinkList from './category-link-list';
|
|
9
|
-
|
|
10
|
-
const Aside = () => {
|
|
11
|
-
const { filters, handlePrice, t } = useFilterContext();
|
|
12
|
-
return (
|
|
13
|
-
<StyledAside>
|
|
14
|
-
<Search placeholder={t('common.searchStore')} />
|
|
15
|
-
<Box marginTop="24px">
|
|
16
|
-
{getPrices(t).map((item) => (
|
|
17
|
-
<FormControlLabel
|
|
18
|
-
className="payments"
|
|
19
|
-
key={item.value}
|
|
20
|
-
control={
|
|
21
|
-
<Checkbox
|
|
22
|
-
onClick={() => {
|
|
23
|
-
handlePrice(item.value);
|
|
24
|
-
}}
|
|
25
|
-
size="small"
|
|
26
|
-
checked={item.value === filters.price}
|
|
27
|
-
/>
|
|
28
|
-
}
|
|
29
|
-
label={item.name}
|
|
30
|
-
/>
|
|
31
|
-
))}
|
|
32
|
-
</Box>
|
|
33
|
-
<List component="nav" color="primary">
|
|
34
|
-
{/* 分割线 */}
|
|
35
|
-
<div style={{ border: '1px solid #dadce0', margin: '16px 16px' }} />
|
|
36
|
-
<CategoryLinkList />
|
|
37
|
-
</List>
|
|
38
|
-
</StyledAside>
|
|
39
|
-
);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const StyledAside = styled.aside`
|
|
43
|
-
width: 220px;
|
|
44
|
-
margin-right: 20px;
|
|
45
|
-
background-color: ${(props) => props.theme.palette.grey[50]};
|
|
46
|
-
height: 100%;
|
|
47
|
-
padding: 15px 0px;
|
|
48
|
-
border-radius: 8px;
|
|
49
|
-
.MuiListItemText-root {
|
|
50
|
-
width: 100%;
|
|
51
|
-
overflow: hidden;
|
|
52
|
-
white-space: nowrap;
|
|
53
|
-
text-overflow: ellipsis;
|
|
54
|
-
}
|
|
55
|
-
.payments {
|
|
56
|
-
display: flex;
|
|
57
|
-
padding: 0 16px;
|
|
58
|
-
.MuiFormControlLabel-label {
|
|
59
|
-
color: #5f6368;
|
|
60
|
-
font-size: 1rem;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
.MuiListItem-root {
|
|
64
|
-
text-transform: capitalize;
|
|
65
|
-
.category > span {
|
|
66
|
-
font-weight: ${(props) => props.theme.typography.fontWeightBold};
|
|
67
|
-
}
|
|
68
|
-
> :not(.category) {
|
|
69
|
-
.MuiListItemText-primary {
|
|
70
|
-
color: #5f6368;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
&.Mui-selected {
|
|
74
|
-
background-color: ${(props) => props.theme.palette.primary.main}!important;
|
|
75
|
-
border-radius: 4px;
|
|
76
|
-
.MuiListItemText-primary {
|
|
77
|
-
color: #fff !important;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
@media (max-width: ${(props) => props.theme.breakpoints.values.md}px) {
|
|
82
|
-
.MuiListItemText-primary {
|
|
83
|
-
font-size: 16px;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
`;
|
|
87
|
-
|
|
88
|
-
Aside.propTypes = {};
|
|
89
|
-
Aside.defaultProps = {};
|
|
90
|
-
export default Aside;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ListItem, ListItemText, Link } from '@mui/material';
|
|
3
|
-
import joinUrl from 'url-join';
|
|
4
|
-
|
|
5
|
-
import { useFilterContext } from '../../contexts/filter';
|
|
6
|
-
import { urlStringify } from '../../libs/utils';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 宽屏幕下的分类列表
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
const CategoryLinkList = () => {
|
|
13
|
-
const { categoryList, selectedCategory, filters, baseUrl, handleCategory, t, locale } = useFilterContext();
|
|
14
|
-
|
|
15
|
-
const handleClick = (e, name) => {
|
|
16
|
-
handleCategory(name);
|
|
17
|
-
e.preventDefault();
|
|
18
|
-
return false;
|
|
19
|
-
};
|
|
20
|
-
const content = (
|
|
21
|
-
<div style={{ marginRight: '16px' }}>
|
|
22
|
-
<ListItem selected={!selectedCategory} button onClick={(e) => handleClick(e, 'all')}>
|
|
23
|
-
<ListItemText primary={t('category.all')} />
|
|
24
|
-
</ListItem>
|
|
25
|
-
{categoryList.map((item) => (
|
|
26
|
-
<ListItem
|
|
27
|
-
key={item._id}
|
|
28
|
-
title={item.locales[locale]}
|
|
29
|
-
component={Link}
|
|
30
|
-
to={`${joinUrl(baseUrl, '/search')}?${urlStringify({
|
|
31
|
-
...filters,
|
|
32
|
-
category: item.name,
|
|
33
|
-
})}`}
|
|
34
|
-
onClick={(e) => handleClick(e, item.name)}
|
|
35
|
-
button
|
|
36
|
-
selected={item.name === selectedCategory}>
|
|
37
|
-
<ListItemText primary={item.locales[locale]} />
|
|
38
|
-
</ListItem>
|
|
39
|
-
))}
|
|
40
|
-
</div>
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<>
|
|
45
|
-
<ListItem>
|
|
46
|
-
<ListItemText className="category" primary={t('common.category')} />
|
|
47
|
-
</ListItem>
|
|
48
|
-
{content}
|
|
49
|
-
</>
|
|
50
|
-
);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export default CategoryLinkList;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { MenuItem } from '@mui/material';
|
|
3
|
-
|
|
4
|
-
import { useFilterContext } from '../contexts/filter';
|
|
5
|
-
import CustomSelect from './custom-select';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 小屏幕下的分类选择器
|
|
9
|
-
* @returns
|
|
10
|
-
*/
|
|
11
|
-
const CategorySelect = () => {
|
|
12
|
-
const { categoryList, selectedCategory, handleCategory, t, locale } = useFilterContext();
|
|
13
|
-
|
|
14
|
-
const itemRender = (item) => {
|
|
15
|
-
return (
|
|
16
|
-
<MenuItem
|
|
17
|
-
className={['my-select__option', selectedCategory?.includes(item.name) ? 'my-select__option--active' : ''].join(
|
|
18
|
-
' '
|
|
19
|
-
)}
|
|
20
|
-
key={item._id}
|
|
21
|
-
value={item.name}
|
|
22
|
-
onClick={() => handleCategory(item.name)}>
|
|
23
|
-
{item.locales[locale]}
|
|
24
|
-
</MenuItem>
|
|
25
|
-
);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<CustomSelect
|
|
30
|
-
value={selectedCategory || 'all'}
|
|
31
|
-
options={categoryList}
|
|
32
|
-
title={categoryList.find((i) => i.name === selectedCategory)?.locales[locale] || t('category.all')}
|
|
33
|
-
itemRender={itemRender}
|
|
34
|
-
prepend={
|
|
35
|
-
<MenuItem value="all" onClick={() => handleCategory('all')}>
|
|
36
|
-
{t('category.all')}
|
|
37
|
-
</MenuItem>
|
|
38
|
-
}
|
|
39
|
-
/>
|
|
40
|
-
);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export default CategorySelect;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
import { Chip } from '@mui/material';
|
|
5
|
-
import FaceIcon from '@mui/icons-material/Face';
|
|
6
|
-
|
|
7
|
-
import { useFilterContext } from '../contexts/filter';
|
|
8
|
-
|
|
9
|
-
const StyleDiv = styled.div`
|
|
10
|
-
.MuiChip-root {
|
|
11
|
-
border-radius: 4px;
|
|
12
|
-
height: initial;
|
|
13
|
-
text-transform: capitalize;
|
|
14
|
-
}
|
|
15
|
-
`;
|
|
16
|
-
const FilterAuthor = ({ user, deleteUserTag, ...containerProps }) => {
|
|
17
|
-
const { t } = useFilterContext();
|
|
18
|
-
if (!user) return null;
|
|
19
|
-
return (
|
|
20
|
-
<StyleDiv {...containerProps}>
|
|
21
|
-
<Chip
|
|
22
|
-
icon={<FaceIcon />}
|
|
23
|
-
label={t('blocklet.owner', { name: user })}
|
|
24
|
-
onDelete={() => {
|
|
25
|
-
deleteUserTag();
|
|
26
|
-
}}
|
|
27
|
-
/>
|
|
28
|
-
</StyleDiv>
|
|
29
|
-
);
|
|
30
|
-
};
|
|
31
|
-
FilterAuthor.propTypes = {
|
|
32
|
-
user: PropTypes.string.isRequired,
|
|
33
|
-
deleteUserTag: PropTypes.func,
|
|
34
|
-
};
|
|
35
|
-
FilterAuthor.defaultProps = {
|
|
36
|
-
deleteUserTag: () => {},
|
|
37
|
-
};
|
|
38
|
-
export default FilterAuthor;
|