@blocklet/list 0.9.8 → 0.9.11
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 +1 -3
- package/lib/components/autocomplete/index.js +11 -22
- package/lib/index.js +2 -2
- package/package.json +4 -4
- package/src/base.js +3 -5
- package/src/components/autocomplete/index.js +10 -23
- package/src/index.js +5 -5
package/lib/base.js
CHANGED
|
@@ -128,9 +128,7 @@ function ListBase() {
|
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
const StyledMin = _styled.default.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 .search-container {\n flex: 2;\n margin-left: 0px;\n }\n\n .filter-container {\n flex: 1;\n display: flex;\n justify-content: flex-end;\n }\n @media (max-width: ", "px) {\n .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 =>
|
|
132
|
-
return props.theme.spacing(2);
|
|
133
|
-
}, props => props.theme.breakpoints.values.md, props => props.theme.spacing(2), props => props.theme.breakpoints.values.md);
|
|
131
|
+
const StyledMin = _styled.default.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 flex: 2;\n margin-left: 0px;\n }\n\n .filter-container {\n flex: 1;\n display: flex;\n justify-content: flex-end;\n }\n @media (max-width: ", "px) {\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);
|
|
134
132
|
|
|
135
133
|
const FilterContainer = _styled.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: sticky;\n top: 0;\n z-index: 9;\n background-color: white;\n"])));
|
|
136
134
|
|
|
@@ -19,12 +19,12 @@ var _urlJoin = _interopRequireDefault(require("url-join"));
|
|
|
19
19
|
|
|
20
20
|
var _constant = _interopRequireDefault(require("../../libs/constant"));
|
|
21
21
|
|
|
22
|
+
var _utils = require("../../libs/utils");
|
|
23
|
+
|
|
22
24
|
var _filter = require("../../contexts/filter");
|
|
23
25
|
|
|
24
26
|
var _item = _interopRequireDefault(require("./item"));
|
|
25
27
|
|
|
26
|
-
require("@algolia/autocomplete-theme-classic");
|
|
27
|
-
|
|
28
28
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
29
29
|
|
|
30
30
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -35,8 +35,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
35
35
|
|
|
36
36
|
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; }
|
|
37
37
|
|
|
38
|
-
const cachePool = new Map();
|
|
39
|
-
|
|
40
38
|
function Autocomplete() {
|
|
41
39
|
const containerRef = (0, _react.useRef)(null);
|
|
42
40
|
const panelRootRef = (0, _react.useRef)(null);
|
|
@@ -50,22 +48,11 @@ function Autocomplete() {
|
|
|
50
48
|
} = (0, _filter.useFilterContext)();
|
|
51
49
|
const muiTheme = (0, _styles.useTheme)();
|
|
52
50
|
const getResults = (0, _react.useCallback)(async params => {
|
|
53
|
-
const key = JSON.stringify(params);
|
|
54
|
-
const target = cachePool.get(key);
|
|
55
|
-
if (target) return target.data;
|
|
56
51
|
const {
|
|
57
52
|
data
|
|
58
53
|
} = await storeApi.get(_constant.default.blockletsPath, {
|
|
59
54
|
params
|
|
60
55
|
});
|
|
61
|
-
|
|
62
|
-
if (cachePool.size > _constant.default.cacheSize) {
|
|
63
|
-
cachePool.clear();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
cachePool.set(key, {
|
|
67
|
-
data: data.dataList
|
|
68
|
-
});
|
|
69
56
|
return data.dataList || [];
|
|
70
57
|
}, [storeApi]);
|
|
71
58
|
|
|
@@ -109,9 +96,11 @@ function Autocomplete() {
|
|
|
109
96
|
},
|
|
110
97
|
|
|
111
98
|
classNames: {
|
|
112
|
-
panel: '
|
|
113
|
-
label: '
|
|
114
|
-
form: '
|
|
99
|
+
panel: 'bl-autocomplete-panel',
|
|
100
|
+
label: 'bl-autocomplete-label',
|
|
101
|
+
form: 'bl-autocomplete-form',
|
|
102
|
+
input: 'bl-autocomplete-input',
|
|
103
|
+
clearButton: 'bl-autocomplete-clear'
|
|
115
104
|
},
|
|
116
105
|
placeholder: t('common.searchStore'),
|
|
117
106
|
initialState: {
|
|
@@ -132,7 +121,7 @@ function Autocomplete() {
|
|
|
132
121
|
keyword: query
|
|
133
122
|
});
|
|
134
123
|
|
|
135
|
-
return [{
|
|
124
|
+
return (0, _utils.debounced)([{
|
|
136
125
|
sourceId: 'blocklets',
|
|
137
126
|
|
|
138
127
|
getItems() {
|
|
@@ -180,11 +169,11 @@ function Autocomplete() {
|
|
|
180
169
|
},
|
|
181
170
|
|
|
182
171
|
noResults() {
|
|
183
|
-
return '
|
|
172
|
+
return t('blocklet.noResults');
|
|
184
173
|
}
|
|
185
174
|
|
|
186
175
|
}
|
|
187
|
-
}];
|
|
176
|
+
}]);
|
|
188
177
|
}
|
|
189
178
|
|
|
190
179
|
});
|
|
@@ -193,7 +182,7 @@ function Autocomplete() {
|
|
|
193
182
|
};
|
|
194
183
|
}, [endpoint, filters, getResults, muiTheme, onReset, onSubmit, t]);
|
|
195
184
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
196
|
-
className: "search-container",
|
|
185
|
+
className: "bl-search-container",
|
|
197
186
|
ref: containerRef
|
|
198
187
|
});
|
|
199
188
|
}
|
package/lib/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var _propTypes = require("./libs/prop-types");
|
|
|
17
17
|
|
|
18
18
|
var _utils = require("./libs/utils");
|
|
19
19
|
|
|
20
|
-
require("@algolia/autocomplete-theme-classic");
|
|
20
|
+
require("@algolia/autocomplete-theme-classic/dist/theme.css");
|
|
21
21
|
|
|
22
22
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
23
|
|
|
@@ -37,7 +37,7 @@ function BlockletList(props) {
|
|
|
37
37
|
const muiTheme = (0, _styles.useTheme)();
|
|
38
38
|
const primaryColor = (0, _utils.toColorRgb)(muiTheme.palette.primary.main);
|
|
39
39
|
const globalStyles = {
|
|
40
|
-
autocomplete: theme => (0, _react.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n :root {\n --aa-detached-media-query: (max-width: ", "px) !important;\n --aa-detached-modal-media-query: (min-width: ", "px) !important;\n --aa-detached-modal-max-width: ", "px !important;\n --aa-selected-color-rgb: ", ", ", ", ", " !important;\n --aa-primary-color-rgb: ", ", ", ", ", " !important;\n --aa-input-background-color-rgb: 250, 250, 250 !important;\n }\n .
|
|
40
|
+
autocomplete: theme => (0, _react.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n :root {\n --aa-detached-media-query: (max-width: ", "px) !important;\n --aa-detached-modal-media-query: (min-width: ", "px) !important;\n --aa-detached-modal-max-width: ", "px !important;\n --aa-selected-color-rgb: ", ", ", ", ", " !important;\n --aa-primary-color-rgb: ", ", ", ", ", " !important;\n --aa-input-background-color-rgb: 250, 250, 250 !important;\n }\n .bl-autocomplete-panel {\n z-index: ", " !important;\n }\n .bl-autocomplete-label {\n .aa-SubmitIcon {\n color: ", " !important;\n }\n }\n .bl-autocomplete-form {\n border: none !important;\n &:focus-within {\n box-shadow: none !important;\n }\n }\n .aa-DetachedSearchButton {\n border: none !important;\n &:focus-within {\n box-shadow: none !important;\n }\n .aa-SubmitIcon {\n color: ", " !important;\n }\n }\n "])), theme.breakpoints.values.md, theme.breakpoints.values.md, theme.breakpoints.values.md, primaryColor.r, primaryColor.g, primaryColor.b, primaryColor.r, primaryColor.g, primaryColor.b, theme.zIndex.modal + 1, theme.palette.grey[500], theme.palette.grey[500])
|
|
41
41
|
};
|
|
42
42
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_filter.FilterProvider, _objectSpread(_objectSpread({}, props), {}, {
|
|
43
43
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Global, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/list",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.11",
|
|
4
4
|
"description": "Common ux components of blocklet",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@algolia/autocomplete-js": "^1.7.1",
|
|
44
44
|
"@algolia/autocomplete-theme-classic": "^1.7.1",
|
|
45
|
-
"@arcblock/ux": "^2.4.
|
|
45
|
+
"@arcblock/ux": "^2.4.6",
|
|
46
46
|
"@emotion/react": "^11.10.0",
|
|
47
47
|
"@emotion/styled": "^11.10.0",
|
|
48
48
|
"@mui/icons-material": "^5.8.4",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"@babel/preset-react": "^7.18.6",
|
|
66
66
|
"@emotion/babel-plugin": "^11.10.0",
|
|
67
67
|
"babel-plugin-inline-react-svg": "^2.0.1",
|
|
68
|
-
"eslint": "^8.
|
|
68
|
+
"eslint": "^8.22.0",
|
|
69
69
|
"prettier": "^2.7.1"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "816aadb1ee96d04ab7a0752d8c41a2da5238d333"
|
|
72
72
|
}
|
package/src/base.js
CHANGED
|
@@ -96,14 +96,12 @@ const StyledMin = styled.main`
|
|
|
96
96
|
height: 100%;
|
|
97
97
|
.filter-bar {
|
|
98
98
|
justify-content: space-between;
|
|
99
|
-
margin-bottom: ${(props) =>
|
|
100
|
-
return props.theme.spacing(2);
|
|
101
|
-
}};
|
|
99
|
+
margin-bottom: ${(props) => props.theme.spacing(2)};
|
|
102
100
|
}
|
|
103
101
|
.sort-button {
|
|
104
102
|
white-space: nowrap;
|
|
105
103
|
}
|
|
106
|
-
.search-container {
|
|
104
|
+
.bl-search-container {
|
|
107
105
|
flex: 2;
|
|
108
106
|
margin-left: 0px;
|
|
109
107
|
}
|
|
@@ -114,7 +112,7 @@ const StyledMin = styled.main`
|
|
|
114
112
|
justify-content: flex-end;
|
|
115
113
|
}
|
|
116
114
|
@media (max-width: ${(props) => props.theme.breakpoints.values.md}px) {
|
|
117
|
-
.search-container {
|
|
115
|
+
.bl-search-container {
|
|
118
116
|
width: 100%;
|
|
119
117
|
margin-bottom: ${(props) => props.theme.spacing(2)};
|
|
120
118
|
}
|
|
@@ -7,13 +7,10 @@ import { ThemeProvider as MuiThemeProvider, useTheme } from '@mui/material/style
|
|
|
7
7
|
import joinUrl from 'url-join';
|
|
8
8
|
|
|
9
9
|
import constant from '../../libs/constant';
|
|
10
|
+
import { debounced } from '../../libs/utils';
|
|
10
11
|
import { useFilterContext } from '../../contexts/filter';
|
|
11
12
|
import Blocklet from './item';
|
|
12
13
|
|
|
13
|
-
import '@algolia/autocomplete-theme-classic';
|
|
14
|
-
|
|
15
|
-
const cachePool = new Map();
|
|
16
|
-
|
|
17
14
|
export default function Autocomplete() {
|
|
18
15
|
const containerRef = useRef(null);
|
|
19
16
|
const panelRootRef = useRef(null);
|
|
@@ -23,20 +20,8 @@ export default function Autocomplete() {
|
|
|
23
20
|
|
|
24
21
|
const getResults = useCallback(
|
|
25
22
|
async (params) => {
|
|
26
|
-
const key = JSON.stringify(params);
|
|
27
|
-
const target = cachePool.get(key);
|
|
28
|
-
|
|
29
|
-
if (target) return target.data;
|
|
30
|
-
|
|
31
23
|
const { data } = await storeApi.get(constant.blockletsPath, { params });
|
|
32
24
|
|
|
33
|
-
if (cachePool.size > constant.cacheSize) {
|
|
34
|
-
cachePool.clear();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
cachePool.set(key, {
|
|
38
|
-
data: data.dataList,
|
|
39
|
-
});
|
|
40
25
|
return data.dataList || [];
|
|
41
26
|
},
|
|
42
27
|
[storeApi]
|
|
@@ -74,9 +59,11 @@ export default function Autocomplete() {
|
|
|
74
59
|
panelRootRef.current.render(children);
|
|
75
60
|
},
|
|
76
61
|
classNames: {
|
|
77
|
-
panel: '
|
|
78
|
-
label: '
|
|
79
|
-
form: '
|
|
62
|
+
panel: 'bl-autocomplete-panel',
|
|
63
|
+
label: 'bl-autocomplete-label',
|
|
64
|
+
form: 'bl-autocomplete-form',
|
|
65
|
+
input: 'bl-autocomplete-input',
|
|
66
|
+
clearButton: 'bl-autocomplete-clear',
|
|
80
67
|
},
|
|
81
68
|
placeholder: t('common.searchStore'),
|
|
82
69
|
initialState: {
|
|
@@ -92,7 +79,7 @@ export default function Autocomplete() {
|
|
|
92
79
|
pageSize: 10,
|
|
93
80
|
keyword: query,
|
|
94
81
|
};
|
|
95
|
-
return [
|
|
82
|
+
return debounced([
|
|
96
83
|
{
|
|
97
84
|
sourceId: 'blocklets',
|
|
98
85
|
getItems() {
|
|
@@ -127,11 +114,11 @@ export default function Autocomplete() {
|
|
|
127
114
|
);
|
|
128
115
|
},
|
|
129
116
|
noResults() {
|
|
130
|
-
return '
|
|
117
|
+
return t('blocklet.noResults');
|
|
131
118
|
},
|
|
132
119
|
},
|
|
133
120
|
},
|
|
134
|
-
];
|
|
121
|
+
]);
|
|
135
122
|
},
|
|
136
123
|
});
|
|
137
124
|
|
|
@@ -140,5 +127,5 @@ export default function Autocomplete() {
|
|
|
140
127
|
};
|
|
141
128
|
}, [endpoint, filters, getResults, muiTheme, onReset, onSubmit, t]);
|
|
142
129
|
|
|
143
|
-
return <div className="search-container" ref={containerRef} />;
|
|
130
|
+
return <div className="bl-search-container" ref={containerRef} />;
|
|
144
131
|
}
|
package/src/index.js
CHANGED
|
@@ -4,8 +4,8 @@ import SelectBase from './base';
|
|
|
4
4
|
import { FilterProvider } from './contexts/filter';
|
|
5
5
|
import { propTypes, defaultProps } from './libs/prop-types';
|
|
6
6
|
import { toColorRgb } from './libs/utils';
|
|
7
|
-
|
|
8
|
-
import '@algolia/autocomplete-theme-classic';
|
|
7
|
+
// 不知道为什么引入 theme.min.css 话,blocklet-store 打包就会报错
|
|
8
|
+
import '@algolia/autocomplete-theme-classic/dist/theme.css';
|
|
9
9
|
|
|
10
10
|
export default function BlockletList(props) {
|
|
11
11
|
const muiTheme = useTheme();
|
|
@@ -21,15 +21,15 @@ export default function BlockletList(props) {
|
|
|
21
21
|
--aa-primary-color-rgb: ${primaryColor.r}, ${primaryColor.g}, ${primaryColor.b} !important;
|
|
22
22
|
--aa-input-background-color-rgb: 250, 250, 250 !important;
|
|
23
23
|
}
|
|
24
|
-
.
|
|
24
|
+
.bl-autocomplete-panel {
|
|
25
25
|
z-index: ${theme.zIndex.modal + 1} !important;
|
|
26
26
|
}
|
|
27
|
-
.
|
|
27
|
+
.bl-autocomplete-label {
|
|
28
28
|
.aa-SubmitIcon {
|
|
29
29
|
color: ${theme.palette.grey[500]} !important;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
.
|
|
32
|
+
.bl-autocomplete-form {
|
|
33
33
|
border: none !important;
|
|
34
34
|
&:focus-within {
|
|
35
35
|
box-shadow: none !important;
|