@blocklet/list 0.9.19 → 0.9.20
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.
|
@@ -49,8 +49,7 @@ function Autocomplete(_ref) {
|
|
|
49
49
|
filters,
|
|
50
50
|
endpoint,
|
|
51
51
|
handleKeyword,
|
|
52
|
-
t
|
|
53
|
-
serverUrl
|
|
52
|
+
t
|
|
54
53
|
} = (0, _filter.useFilterContext)();
|
|
55
54
|
const muiTheme = (0, _styles.useTheme)();
|
|
56
55
|
const getResults = (0, _react.useCallback)(async params => {
|
|
@@ -61,15 +60,6 @@ function Autocomplete(_ref) {
|
|
|
61
60
|
});
|
|
62
61
|
return data.dataList || [];
|
|
63
62
|
}, [storeApi]);
|
|
64
|
-
const getBlockletDetail = (0, _react.useCallback)(item => {
|
|
65
|
-
let blockletDetail = (0, _urlJoin.default)(endpoint, "/blocklets/".concat(item.did));
|
|
66
|
-
|
|
67
|
-
if (serverUrl) {
|
|
68
|
-
blockletDetail = "".concat(blockletDetail, "?server-url=").concat(encodeURIComponent(serverUrl));
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return blockletDetail;
|
|
72
|
-
}, [endpoint, serverUrl]);
|
|
73
63
|
const onSubmit = (0, _react.useCallback)(e => {
|
|
74
64
|
handleKeyword(e.state.query);
|
|
75
65
|
}, [handleKeyword]);
|
|
@@ -152,7 +142,7 @@ function Autocomplete(_ref) {
|
|
|
152
142
|
} = _ref5;
|
|
153
143
|
onSelect({
|
|
154
144
|
blocklet: item,
|
|
155
|
-
detailUrl:
|
|
145
|
+
detailUrl: (0, _urlJoin.default)(endpoint, "/blocklets/".concat(item.did)),
|
|
156
146
|
storeUrl: endpoint
|
|
157
147
|
});
|
|
158
148
|
},
|
|
@@ -191,7 +181,7 @@ function Autocomplete(_ref) {
|
|
|
191
181
|
return () => {
|
|
192
182
|
search.destroy();
|
|
193
183
|
};
|
|
194
|
-
}, [endpoint, filters,
|
|
184
|
+
}, [endpoint, filters, getResults, muiTheme, onReset, onSubmit, onSelect, t]);
|
|
195
185
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
196
186
|
className: "bl-search-container",
|
|
197
187
|
ref: containerRef
|
package/lib/contexts/filter.js
CHANGED
|
@@ -51,8 +51,7 @@ function FilterProvider(_ref) {
|
|
|
51
51
|
blockletRender,
|
|
52
52
|
onFilterChange,
|
|
53
53
|
onSearchSelect,
|
|
54
|
-
extraFilter
|
|
55
|
-
serverUrl
|
|
54
|
+
extraFilter
|
|
56
55
|
} = _ref;
|
|
57
56
|
|
|
58
57
|
const storeApi = _axios.default.create({
|
|
@@ -163,7 +162,6 @@ function FilterProvider(_ref) {
|
|
|
163
162
|
categoryOptions,
|
|
164
163
|
priceOptions,
|
|
165
164
|
storeApi,
|
|
166
|
-
serverUrl,
|
|
167
165
|
hasNextPage: blockletsState.list.length < blockletsState.total,
|
|
168
166
|
handleSort: sort => {
|
|
169
167
|
const changeData = _objectSpread(_objectSpread({}, finalFilters), {}, {
|
package/lib/libs/prop-types.js
CHANGED
|
@@ -23,8 +23,7 @@ const propTypes = {
|
|
|
23
23
|
blockletRender: _propTypes.default.func.isRequired,
|
|
24
24
|
onFilterChange: _propTypes.default.func,
|
|
25
25
|
onSearchSelect: _propTypes.default.func,
|
|
26
|
-
locale: _propTypes.default.oneOf(['zh', 'en'])
|
|
27
|
-
serverUrl: _propTypes.default.string
|
|
26
|
+
locale: _propTypes.default.oneOf(['zh', 'en'])
|
|
28
27
|
};
|
|
29
28
|
exports.propTypes = propTypes;
|
|
30
29
|
const defaultProps = {
|
|
@@ -37,7 +36,6 @@ const defaultProps = {
|
|
|
37
36
|
} = _ref;
|
|
38
37
|
window.location.href = detailUrl;
|
|
39
38
|
},
|
|
40
|
-
extraFilter: list => list
|
|
41
|
-
serverUrl: null
|
|
39
|
+
extraFilter: list => list
|
|
42
40
|
};
|
|
43
41
|
exports.defaultProps = defaultProps;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/list",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.20",
|
|
4
4
|
"description": "Common ux components of blocklet",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"eslint": "^8.22.0",
|
|
69
69
|
"prettier": "^2.7.1"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "7e8a387a49a0f0164bcd39ff938372bd1d5d113d"
|
|
72
72
|
}
|
|
@@ -16,7 +16,7 @@ export default function Autocomplete({ onSelect }) {
|
|
|
16
16
|
const containerRef = useRef(null);
|
|
17
17
|
const panelRootRef = useRef(null);
|
|
18
18
|
const rootRef = useRef(null);
|
|
19
|
-
const { storeApi, filters, endpoint, handleKeyword, t
|
|
19
|
+
const { storeApi, filters, endpoint, handleKeyword, t } = useFilterContext();
|
|
20
20
|
const muiTheme = useTheme();
|
|
21
21
|
|
|
22
22
|
const getResults = useCallback(
|
|
@@ -28,17 +28,6 @@ export default function Autocomplete({ onSelect }) {
|
|
|
28
28
|
[storeApi]
|
|
29
29
|
);
|
|
30
30
|
|
|
31
|
-
const getBlockletDetail = useCallback(
|
|
32
|
-
(item) => {
|
|
33
|
-
let blockletDetail = joinUrl(endpoint, `/blocklets/${item.did}`);
|
|
34
|
-
if (serverUrl) {
|
|
35
|
-
blockletDetail = `${blockletDetail}?server-url=${encodeURIComponent(serverUrl)}`;
|
|
36
|
-
}
|
|
37
|
-
return blockletDetail;
|
|
38
|
-
},
|
|
39
|
-
[endpoint, serverUrl]
|
|
40
|
-
);
|
|
41
|
-
|
|
42
31
|
const onSubmit = useCallback(
|
|
43
32
|
(e) => {
|
|
44
33
|
handleKeyword(e.state.query);
|
|
@@ -99,7 +88,7 @@ export default function Autocomplete({ onSelect }) {
|
|
|
99
88
|
return item.title;
|
|
100
89
|
},
|
|
101
90
|
onSelect({ item }) {
|
|
102
|
-
onSelect({ blocklet: item, detailUrl:
|
|
91
|
+
onSelect({ blocklet: item, detailUrl: joinUrl(endpoint, `/blocklets/${item.did}`), storeUrl: endpoint });
|
|
103
92
|
},
|
|
104
93
|
templates: {
|
|
105
94
|
// eslint-disable-next-line react/no-unstable-nested-components
|
|
@@ -131,7 +120,7 @@ export default function Autocomplete({ onSelect }) {
|
|
|
131
120
|
return () => {
|
|
132
121
|
search.destroy();
|
|
133
122
|
};
|
|
134
|
-
}, [endpoint, filters,
|
|
123
|
+
}, [endpoint, filters, getResults, muiTheme, onReset, onSubmit, onSelect, t]);
|
|
135
124
|
|
|
136
125
|
return <div className="bl-search-container" ref={containerRef} />;
|
|
137
126
|
}
|
package/src/contexts/filter.js
CHANGED
|
@@ -20,7 +20,6 @@ function FilterProvider({
|
|
|
20
20
|
onFilterChange,
|
|
21
21
|
onSearchSelect,
|
|
22
22
|
extraFilter,
|
|
23
|
-
serverUrl,
|
|
24
23
|
}) {
|
|
25
24
|
const storeApi = axios.create({
|
|
26
25
|
baseURL: endpoint,
|
|
@@ -115,7 +114,6 @@ function FilterProvider({
|
|
|
115
114
|
categoryOptions,
|
|
116
115
|
priceOptions,
|
|
117
116
|
storeApi,
|
|
118
|
-
serverUrl,
|
|
119
117
|
hasNextPage: blockletsState.list.length < blockletsState.total,
|
|
120
118
|
handleSort: (sort) => {
|
|
121
119
|
const changeData = {
|
package/src/libs/prop-types.js
CHANGED
|
@@ -15,7 +15,6 @@ const propTypes = {
|
|
|
15
15
|
onFilterChange: PropTypes.func,
|
|
16
16
|
onSearchSelect: PropTypes.func,
|
|
17
17
|
locale: PropTypes.oneOf(['zh', 'en']),
|
|
18
|
-
serverUrl: PropTypes.string,
|
|
19
18
|
};
|
|
20
19
|
|
|
21
20
|
const defaultProps = {
|
|
@@ -26,7 +25,6 @@ const defaultProps = {
|
|
|
26
25
|
window.location.href = detailUrl;
|
|
27
26
|
},
|
|
28
27
|
extraFilter: (list) => list,
|
|
29
|
-
serverUrl: null,
|
|
30
28
|
};
|
|
31
29
|
|
|
32
30
|
export { propTypes, defaultProps };
|