@blocklet/list 0.12.90 → 0.12.91
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/column-sizer.js +40 -0
- package/lib/components/list/index.js +29 -44
- package/lib/index.es.js +252 -240
- package/package.json +8 -3
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _ahooks = require("ahooks");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
function calculateColumns(size) {
|
|
12
|
+
if (!size) {
|
|
13
|
+
return 0;
|
|
14
|
+
}
|
|
15
|
+
if (size.width > 900) {
|
|
16
|
+
return 12;
|
|
17
|
+
}
|
|
18
|
+
if (size.width > 600) {
|
|
19
|
+
return 8;
|
|
20
|
+
}
|
|
21
|
+
return 4;
|
|
22
|
+
}
|
|
23
|
+
function ColumnSizer(_ref) {
|
|
24
|
+
let {
|
|
25
|
+
children
|
|
26
|
+
} = _ref;
|
|
27
|
+
const refContainer = (0, _react.useRef)(null);
|
|
28
|
+
const [dom, setDom] = (0, _react.useState)(null);
|
|
29
|
+
const size = (0, _ahooks.useSize)(dom);
|
|
30
|
+
(0, _react.useEffect)(() => {
|
|
31
|
+
if (!dom) {
|
|
32
|
+
setDom(refContainer.current);
|
|
33
|
+
}
|
|
34
|
+
}, [dom]);
|
|
35
|
+
return children(refContainer, calculateColumns(size));
|
|
36
|
+
}
|
|
37
|
+
ColumnSizer.propTypes = {
|
|
38
|
+
children: _propTypes.default.func.isRequired
|
|
39
|
+
};
|
|
40
|
+
var _default = exports.default = ColumnSizer;
|
|
@@ -4,16 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = BlockletList;
|
|
7
|
-
var _react = require("react");
|
|
8
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
8
|
var _Theme = require("@arcblock/ux/lib/Theme");
|
|
10
9
|
var _Empty = _interopRequireDefault(require("@arcblock/ux/lib/Empty"));
|
|
11
10
|
var _material = require("@mui/material");
|
|
12
11
|
var _reactInfiniteScrollHook = _interopRequireDefault(require("react-infinite-scroll-hook"));
|
|
13
12
|
var _ErrorBoundary = require("@arcblock/ux/lib/ErrorBoundary");
|
|
14
|
-
var _ahooks = require("ahooks");
|
|
15
13
|
var _empty = require("./empty");
|
|
16
14
|
var _filter = require("../../contexts/filter");
|
|
15
|
+
var _columnSizer = _interopRequireDefault(require("./column-sizer"));
|
|
17
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
17
|
var _templateObject, _templateObject2, _templateObject3;
|
|
19
18
|
const _excluded = ["blocklets"];
|
|
@@ -43,22 +42,6 @@ function BlockletList(_ref) {
|
|
|
43
42
|
loadMore,
|
|
44
43
|
endpoint
|
|
45
44
|
} = (0, _filter.useFilterContext)();
|
|
46
|
-
const refContainer = (0, _react.useRef)(null);
|
|
47
|
-
const size = (0, _ahooks.useSize)(refContainer.current);
|
|
48
|
-
|
|
49
|
-
// 根据当前容器的宽度来决定 columns,而不是屏幕宽度
|
|
50
|
-
const columns = (0, _ahooks.useCreation)(() => {
|
|
51
|
-
if (size) {
|
|
52
|
-
if (size.width > 900) {
|
|
53
|
-
return 12;
|
|
54
|
-
}
|
|
55
|
-
if (size.width > 600) {
|
|
56
|
-
return 8;
|
|
57
|
-
}
|
|
58
|
-
return 4;
|
|
59
|
-
}
|
|
60
|
-
return 0;
|
|
61
|
-
}, [size]);
|
|
62
45
|
const showFilterTip = !!selectedCategory || !!filters.price;
|
|
63
46
|
const [sentryRef] = (0, _reactInfiniteScrollHook.default)({
|
|
64
47
|
loading: loadings.fetchBlockletsLoading || loadings.loadingMore,
|
|
@@ -119,36 +102,38 @@ function BlockletList(_ref) {
|
|
|
119
102
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_empty.NoResults, {})
|
|
120
103
|
});
|
|
121
104
|
}
|
|
122
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
105
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_columnSizer.default, {
|
|
106
|
+
children: (refContainer, columns) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(StyledGrid, _objectSpread(_objectSpread({
|
|
107
|
+
container: true
|
|
108
|
+
}, rest), {}, {
|
|
109
|
+
columns: columns,
|
|
110
|
+
ref: refContainer,
|
|
111
|
+
children: [blocklets.map(blocklet => /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledGridItem, {
|
|
112
|
+
item: true,
|
|
113
|
+
xs: 4,
|
|
114
|
+
"data-blocklet-did": blocklet.did,
|
|
115
|
+
children: blockletRender({
|
|
116
|
+
blocklet,
|
|
117
|
+
blocklets
|
|
118
|
+
})
|
|
119
|
+
}, blocklet.did)), hasNextPage && /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledGridItem, {
|
|
120
|
+
item: true,
|
|
121
|
+
xs: 12,
|
|
122
|
+
ref: sentryRef,
|
|
123
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
124
|
+
height: 60,
|
|
125
|
+
display: "flex",
|
|
126
|
+
justifyContent: "center",
|
|
127
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.CircularProgress, {})
|
|
128
|
+
})
|
|
129
|
+
})]
|
|
130
|
+
}))
|
|
131
|
+
});
|
|
147
132
|
}
|
|
148
133
|
BlockletList.propTypes = {
|
|
149
134
|
blocklets: _propTypes.default.array.isRequired
|
|
150
135
|
};
|
|
151
136
|
BlockletList.defaultProps = {};
|
|
152
137
|
const StyledGrid = (0, _Theme.styled)(_material.Grid)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n opacity: ", ";\n &.MuiGrid-root {\n width: 100%;\n margin: 0 -16px;\n }\n"])), props => props.columns > 0 ? 1 : 0);
|
|
153
|
-
const StyledGridItem =
|
|
138
|
+
const StyledGridItem = (0, _Theme.styled)(_material.Grid)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n @media (max-width: ", "px) {\n &.MuiGrid-item {\n padding-bottom: 0px;\n }\n }\n @media (min-width: ", "px) {\n &.MuiGrid-item {\n margin-bottom: ", ";\n }\n }\n"])), props => props.theme.breakpoints.values.sm, props => props.theme.breakpoints.values.sm, props => props.theme.spacing(2));
|
|
154
139
|
const CustomEmpty = (0, _Theme.styled)(_Empty.default)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n text-align: center;\n .primary {\n color: ", ";\n }\n .tips {\n margin-top: ", ";\n }\n"])), props => props.theme.palette.primary.main, props => props.theme.spacing(1));
|
package/lib/index.es.js
CHANGED
|
@@ -2,38 +2,38 @@ import { jsx as t, jsxs as h, Fragment as he } from "react/jsx-runtime";
|
|
|
2
2
|
import { useTheme as fe } from "@mui/material/styles";
|
|
3
3
|
import { Global as ge, css as ye } from "@emotion/react";
|
|
4
4
|
import { styled as v } from "@arcblock/ux/lib/Theme";
|
|
5
|
-
import
|
|
6
|
-
import { Button as
|
|
7
|
-
import
|
|
8
|
-
import { ErrorBoundary as
|
|
5
|
+
import De from "@mui/icons-material/Sort";
|
|
6
|
+
import { Button as _e, CircularProgress as Q, MenuList as Ne, useMediaQuery as be, SvgIcon as Le, Popper as Me, Grow as Ae, Paper as Fe, ClickAwayListener as Oe, MenuItem as qe, Chip as Ee, Grid as we, Box as N, OutlinedInput as je, InputAdornment as ce, Typography as Ge, Hidden as pe } from "@mui/material";
|
|
7
|
+
import Ue from "@mui/icons-material/Face";
|
|
8
|
+
import { ErrorBoundary as Ke } from "react-error-boundary";
|
|
9
9
|
import { ErrorFallback as xe } from "@arcblock/ux/lib/ErrorBoundary";
|
|
10
|
-
import { createContext as
|
|
10
|
+
import { createContext as We, useMemo as q, useState as L, useCallback as J, useEffect as F, useContext as He, forwardRef as Ve, useRef as E, createElement as Qe, Fragment as Je } from "react";
|
|
11
11
|
import n from "prop-types";
|
|
12
|
-
import { useReactive as Xe, useInfiniteScroll as Ye, useRequest as Ze, useSize as et,
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
12
|
+
import { useReactive as Xe, useInfiniteScroll as Ye, useRequest as Ze, useSize as et, useDebounceFn as tt } from "ahooks";
|
|
13
|
+
import rt from "lodash/orderBy";
|
|
14
|
+
import ot from "axios";
|
|
15
|
+
import nt from "json-stable-stringify";
|
|
16
16
|
import "lodash/cloneDeep";
|
|
17
|
-
import
|
|
17
|
+
import lt from "color";
|
|
18
18
|
import ue from "flat";
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
19
|
+
import at from "@mui/icons-material/KeyboardArrowDown";
|
|
20
|
+
import it from "lodash/isEmpty";
|
|
21
|
+
import st from "@mui/icons-material/FilterAltOutlined";
|
|
22
|
+
import ct from "@arcblock/ux/lib/Dialog";
|
|
23
|
+
import pt from "@mui/material/Button";
|
|
24
|
+
import ut from "@arcblock/ux/lib/Empty";
|
|
25
|
+
import dt from "react-infinite-scroll-hook";
|
|
26
|
+
import mt from "@mui/material/Box";
|
|
27
27
|
import ke from "@mui/material/Typography";
|
|
28
|
-
import
|
|
29
|
-
import
|
|
30
|
-
import { createRoot as
|
|
31
|
-
import { autocomplete as
|
|
32
|
-
import { useHotkeys as
|
|
33
|
-
import
|
|
34
|
-
import
|
|
28
|
+
import ht from "@mui/icons-material/Search";
|
|
29
|
+
import ft from "@mui/icons-material/Close";
|
|
30
|
+
import { createRoot as gt } from "react-dom/client";
|
|
31
|
+
import { autocomplete as yt } from "@algolia/autocomplete-js";
|
|
32
|
+
import { useHotkeys as bt } from "react-hotkeys-hook";
|
|
33
|
+
import wt from "url-join";
|
|
34
|
+
import xt from "@arcblock/ux/lib/Switch";
|
|
35
35
|
import "@algolia/autocomplete-theme-classic/dist/theme.css";
|
|
36
|
-
const
|
|
36
|
+
const kt = (e) => [
|
|
37
37
|
{
|
|
38
38
|
name: e("sort.popularity"),
|
|
39
39
|
value: "popularity"
|
|
@@ -50,17 +50,17 @@ const St = (e) => [
|
|
|
50
50
|
name: e("sort.nameDescend"),
|
|
51
51
|
value: "nameDesc"
|
|
52
52
|
}
|
|
53
|
-
],
|
|
53
|
+
], St = (e) => [
|
|
54
54
|
{ name: e("blocklet.free"), value: "free" },
|
|
55
55
|
{ name: e("blocklet.payment"), value: "payment" }
|
|
56
|
-
],
|
|
56
|
+
], vt = (e = [], o = "en") => e.map((r) => ({ name: r.locales[o] || `Category.${o}`, value: r._id })), Ct = (e, o) => (
|
|
57
57
|
// eslint-disable-next-line no-prototype-builtins
|
|
58
58
|
e.replace(/{(\w*)}/g, (r, l) => o.hasOwnProperty(l) ? o[l] : "")
|
|
59
|
-
),
|
|
59
|
+
), Pt = () => window.innerWidth <= 600, Tt = (e, o) => {
|
|
60
60
|
const r = (e + o) / o;
|
|
61
61
|
return r > 1 ? r.toFixed() : 1;
|
|
62
|
-
},
|
|
63
|
-
function
|
|
62
|
+
}, Rt = (e) => lt(e).rgb().object();
|
|
63
|
+
function Bt(e, o) {
|
|
64
64
|
let r;
|
|
65
65
|
return function(...s) {
|
|
66
66
|
return r && clearTimeout(r), new Promise((c) => {
|
|
@@ -68,7 +68,7 @@ function $t(e, o) {
|
|
|
68
68
|
});
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
const
|
|
71
|
+
const $t = Bt((e) => Promise.resolve(e), 300), zt = {
|
|
72
72
|
common: {
|
|
73
73
|
searchStore: "Search the store",
|
|
74
74
|
showResources: "Show resources",
|
|
@@ -107,7 +107,7 @@ const zt = $t((e) => Promise.resolve(e), 300), It = {
|
|
|
107
107
|
autocomplete: {
|
|
108
108
|
expandResult: 'Show {number} search results for "{name}" '
|
|
109
109
|
}
|
|
110
|
-
},
|
|
110
|
+
}, It = {
|
|
111
111
|
common: {
|
|
112
112
|
searchStore: "搜索商店内应用",
|
|
113
113
|
showResources: "显示资源型应用",
|
|
@@ -147,8 +147,8 @@ const zt = $t((e) => Promise.resolve(e), 300), It = {
|
|
|
147
147
|
expandResult: "显示 {number} 条 “{name}” 的搜索结果 "
|
|
148
148
|
}
|
|
149
149
|
}, V = {
|
|
150
|
-
en: ue(
|
|
151
|
-
zh: ue(
|
|
150
|
+
en: ue(zt),
|
|
151
|
+
zh: ue(It)
|
|
152
152
|
}, Se = {
|
|
153
153
|
filters: n.shape({
|
|
154
154
|
keyword: n.string,
|
|
@@ -192,7 +192,7 @@ const zt = $t((e) => Promise.resolve(e), 300), It = {
|
|
|
192
192
|
blockletsPath: "/api/v2/blocklets.json",
|
|
193
193
|
categoriesPath: "/api/blocklets/categories",
|
|
194
194
|
cacheSize: 100
|
|
195
|
-
}, Ce =
|
|
195
|
+
}, Ce = We({}), { Provider: Dt, Consumer: $r } = Ce;
|
|
196
196
|
function X({
|
|
197
197
|
filters: e,
|
|
198
198
|
children: o,
|
|
@@ -202,27 +202,27 @@ function X({
|
|
|
202
202
|
onFilterChange: c,
|
|
203
203
|
onSearchSelect: b,
|
|
204
204
|
extraFilter: g,
|
|
205
|
-
wrapChildren:
|
|
205
|
+
wrapChildren: p,
|
|
206
206
|
baseSearch: y,
|
|
207
|
-
serverVersion:
|
|
207
|
+
serverVersion: u,
|
|
208
208
|
storeVersion: C,
|
|
209
209
|
fetchCategoryDelay: B,
|
|
210
|
-
showResourcesSwitch:
|
|
210
|
+
showResourcesSwitch: P
|
|
211
211
|
}) {
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
const
|
|
212
|
+
const k = {};
|
|
213
|
+
u && (k["x-blocklet-server-version"] = u), C && (k["x-blocklet-store-version"] = C);
|
|
214
|
+
const T = q(() => ot.create({
|
|
215
215
|
baseURL: r,
|
|
216
|
-
headers:
|
|
217
|
-
}), [r]), i =
|
|
216
|
+
headers: k
|
|
217
|
+
}), [r]), i = q(() => ({
|
|
218
218
|
sortBy: "popularity",
|
|
219
219
|
sortDirection: "desc",
|
|
220
220
|
...e
|
|
221
|
-
}), [e]),
|
|
221
|
+
}), [e]), m = i.category, S = Xe({
|
|
222
222
|
currentPage: z.currentPage,
|
|
223
|
-
pageSize:
|
|
223
|
+
pageSize: Pt() ? z.mobilePageSize : z.pageSize,
|
|
224
224
|
defaultCurrentPage: z.defaultCurrentPage
|
|
225
|
-
}), [
|
|
225
|
+
}), [w, $] = L(null), {
|
|
226
226
|
data: f = { list: [], total: 0 },
|
|
227
227
|
loading: D,
|
|
228
228
|
loadMore: G,
|
|
@@ -230,95 +230,95 @@ function X({
|
|
|
230
230
|
} = Ye(
|
|
231
231
|
async (a) => {
|
|
232
232
|
var _;
|
|
233
|
-
const
|
|
233
|
+
const d = {
|
|
234
234
|
...i,
|
|
235
235
|
sortBy: z[i.sortBy],
|
|
236
|
-
page:
|
|
236
|
+
page: Tt(((_ = a == null ? void 0 : a.list) == null ? void 0 : _.length) || 0, S.pageSize),
|
|
237
237
|
pageSize: S.pageSize
|
|
238
238
|
};
|
|
239
239
|
$(null);
|
|
240
|
-
const { data:
|
|
241
|
-
params:
|
|
240
|
+
const { data: x = {} } = await T.get(z.blockletsPath, {
|
|
241
|
+
params: d
|
|
242
242
|
});
|
|
243
|
-
return { list: (
|
|
243
|
+
return { list: (x == null ? void 0 : x.dataList) || [], total: (x == null ? void 0 : x.total) || 0 };
|
|
244
244
|
},
|
|
245
245
|
{
|
|
246
246
|
isNoMore: (a) => a ? a.list.length >= a.total : !1,
|
|
247
|
-
reloadDeps: [r,
|
|
247
|
+
reloadDeps: [r, nt(e)],
|
|
248
248
|
onError: (a) => {
|
|
249
249
|
$(a);
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
252
|
), {
|
|
253
|
-
data:
|
|
253
|
+
data: M = [],
|
|
254
254
|
error: R,
|
|
255
|
-
loading:
|
|
256
|
-
run:
|
|
255
|
+
loading: Re,
|
|
256
|
+
run: Be
|
|
257
257
|
} = Ze(
|
|
258
258
|
async () => {
|
|
259
|
-
const { data: a } = await
|
|
259
|
+
const { data: a } = await T.get(z.categoriesPath);
|
|
260
260
|
return Array.isArray(a) ? a : [];
|
|
261
261
|
},
|
|
262
262
|
{ manual: !0 }
|
|
263
|
-
), H =
|
|
264
|
-
(a,
|
|
265
|
-
const
|
|
266
|
-
return
|
|
263
|
+
), H = q(() => rt(M || [], [(d) => d.name], ["asc"]), [M]), ae = J(
|
|
264
|
+
(a, d) => {
|
|
265
|
+
const x = V[l] ? V[l][a] : V.en[a];
|
|
266
|
+
return Ct(x, d);
|
|
267
267
|
},
|
|
268
268
|
[l]
|
|
269
|
-
), ie =
|
|
269
|
+
), ie = q(() => {
|
|
270
270
|
let a = f.list || [];
|
|
271
271
|
return a = g(a), a;
|
|
272
|
-
}, [f, g]),
|
|
273
|
-
errors: { fetchBlockletsError:
|
|
274
|
-
loadings: { fetchBlockletsLoading: D, fetchCategoriesLoading:
|
|
272
|
+
}, [f, g]), $e = q(() => vt(H, l), [H, l]), ze = St(ae), Ie = {
|
|
273
|
+
errors: { fetchBlockletsError: w, fetchCategoriesError: R },
|
|
274
|
+
loadings: { fetchBlockletsLoading: D, fetchCategoriesLoading: Re, loadingMore: U },
|
|
275
275
|
endpoint: r,
|
|
276
276
|
blockletList: ie,
|
|
277
|
-
wrapChildren:
|
|
277
|
+
wrapChildren: p,
|
|
278
278
|
t: ae,
|
|
279
279
|
filters: i,
|
|
280
|
-
selectedCategory:
|
|
280
|
+
selectedCategory: m,
|
|
281
281
|
categoryList: H,
|
|
282
282
|
blockletRender: s,
|
|
283
283
|
locale: l,
|
|
284
|
-
categoryOptions:
|
|
285
|
-
priceOptions:
|
|
286
|
-
storeApi:
|
|
284
|
+
categoryOptions: $e,
|
|
285
|
+
priceOptions: ze,
|
|
286
|
+
storeApi: T,
|
|
287
287
|
baseSearch: y,
|
|
288
|
-
showResourcesSwitch:
|
|
288
|
+
showResourcesSwitch: P,
|
|
289
289
|
hasNextPage: f.list.length < f.total,
|
|
290
290
|
handleSort: (a) => {
|
|
291
|
-
const
|
|
291
|
+
const d = {
|
|
292
292
|
...i,
|
|
293
293
|
sortBy: a,
|
|
294
294
|
sortDirection: a === "nameAsc" ? "asc" : "desc"
|
|
295
295
|
};
|
|
296
|
-
c(
|
|
296
|
+
c(d);
|
|
297
297
|
},
|
|
298
298
|
handleKeyword: (a) => {
|
|
299
|
-
const
|
|
300
|
-
c(
|
|
299
|
+
const d = { ...i, keyword: a || void 0 };
|
|
300
|
+
c(d);
|
|
301
301
|
},
|
|
302
302
|
handlePrice: (a) => {
|
|
303
|
-
const
|
|
303
|
+
const d = {
|
|
304
304
|
...i,
|
|
305
305
|
price: a === i.price ? void 0 : a
|
|
306
306
|
};
|
|
307
|
-
c(
|
|
307
|
+
c(d);
|
|
308
308
|
},
|
|
309
309
|
handleCategory: (a) => {
|
|
310
|
-
let
|
|
311
|
-
(a === "all" || a === i.category) && (
|
|
312
|
-
const
|
|
313
|
-
c(
|
|
310
|
+
let d = a;
|
|
311
|
+
(a === "all" || a === i.category) && (d = void 0);
|
|
312
|
+
const x = { ...i, category: d };
|
|
313
|
+
c(x);
|
|
314
314
|
},
|
|
315
315
|
handleDeveloper: (a) => {
|
|
316
|
-
const
|
|
317
|
-
c(
|
|
316
|
+
const d = { ...i, owner: a || void 0 };
|
|
317
|
+
c(d);
|
|
318
318
|
},
|
|
319
319
|
handlePage: (a) => {
|
|
320
|
-
const
|
|
321
|
-
c(
|
|
320
|
+
const d = { ...i, currentPage: a };
|
|
321
|
+
c(d);
|
|
322
322
|
},
|
|
323
323
|
handleSwitchShowResources: () => {
|
|
324
324
|
const a = { ...i };
|
|
@@ -330,24 +330,24 @@ function X({
|
|
|
330
330
|
getCategoryLocale: (a) => {
|
|
331
331
|
if (!a)
|
|
332
332
|
return null;
|
|
333
|
-
let
|
|
334
|
-
const
|
|
335
|
-
return
|
|
333
|
+
let d = null;
|
|
334
|
+
const x = M.find((_) => _._id === a);
|
|
335
|
+
return x && (d = x.locales[l]), d;
|
|
336
336
|
},
|
|
337
337
|
get developerName() {
|
|
338
|
-
var
|
|
339
|
-
return ((
|
|
338
|
+
var d, x;
|
|
339
|
+
return ((x = (d = ie.find((_) => {
|
|
340
340
|
var se;
|
|
341
341
|
return ((se = _ == null ? void 0 : _.owner) == null ? void 0 : se.did) === i.owner;
|
|
342
|
-
})) == null ? void 0 :
|
|
342
|
+
})) == null ? void 0 : d.owner) == null ? void 0 : x.name) || "";
|
|
343
343
|
},
|
|
344
344
|
handleSearchSelect: b
|
|
345
345
|
};
|
|
346
|
-
return
|
|
346
|
+
return F(() => {
|
|
347
347
|
setTimeout(() => {
|
|
348
|
-
|
|
348
|
+
Be();
|
|
349
349
|
}, B || 0);
|
|
350
|
-
}, [r]), /* @__PURE__ */ t(
|
|
350
|
+
}, [r]), /* @__PURE__ */ t(Dt, { value: Ie, children: o });
|
|
351
351
|
}
|
|
352
352
|
X.propTypes = {
|
|
353
353
|
...Se,
|
|
@@ -355,13 +355,13 @@ X.propTypes = {
|
|
|
355
355
|
};
|
|
356
356
|
X.defaultProps = ve;
|
|
357
357
|
function I() {
|
|
358
|
-
const e =
|
|
358
|
+
const e = He(Ce);
|
|
359
359
|
return e || {};
|
|
360
360
|
}
|
|
361
|
-
const
|
|
361
|
+
const _t = v(_e)`
|
|
362
362
|
border-radius: 4px;
|
|
363
|
-
`, Y =
|
|
364
|
-
|
|
363
|
+
`, Y = Ve(({ children: e, rounded: o, loading: r, disabled: l, ...s }, c) => /* @__PURE__ */ t(
|
|
364
|
+
_t,
|
|
365
365
|
{
|
|
366
366
|
ref: c,
|
|
367
367
|
disableElevation: !0,
|
|
@@ -384,49 +384,49 @@ Y.defaultProps = {
|
|
|
384
384
|
disabled: !1
|
|
385
385
|
};
|
|
386
386
|
function Z({ title: e, value: o, icon: r, prepend: l, options: s, onChange: c, itemRender: b, ...g }) {
|
|
387
|
-
const
|
|
388
|
-
|
|
389
|
-
|
|
387
|
+
const p = E(null), y = fe(), [u, C] = L(!1), [B, P] = L(o !== null ? o : ""), k = be(y.breakpoints.down("sm"));
|
|
388
|
+
F(() => {
|
|
389
|
+
P(o !== null ? o : "");
|
|
390
390
|
}, [o]);
|
|
391
|
-
const
|
|
391
|
+
const T = J(() => {
|
|
392
392
|
C(!1);
|
|
393
393
|
}, []), i = J(() => {
|
|
394
394
|
C(!0);
|
|
395
395
|
}, []);
|
|
396
|
-
function
|
|
397
|
-
w
|
|
396
|
+
function m(w) {
|
|
397
|
+
P(w.value), c(w.value), k && T();
|
|
398
398
|
}
|
|
399
|
-
function S(
|
|
400
|
-
return
|
|
399
|
+
function S(w) {
|
|
400
|
+
return w === B;
|
|
401
401
|
}
|
|
402
402
|
return /* @__PURE__ */ h(he, { children: [
|
|
403
403
|
/* @__PURE__ */ h(
|
|
404
|
-
|
|
404
|
+
Nt,
|
|
405
405
|
{
|
|
406
|
-
ref:
|
|
406
|
+
ref: p,
|
|
407
407
|
onClick: i,
|
|
408
408
|
variant: "outlined",
|
|
409
409
|
size: "small",
|
|
410
|
-
className: ["my-select__selector",
|
|
410
|
+
className: ["my-select__selector", it(B) ? "" : "my-select__selector--active"].join(" "),
|
|
411
411
|
...g,
|
|
412
412
|
children: [
|
|
413
413
|
/* @__PURE__ */ t("div", { className: "my-select__icon", children: r }),
|
|
414
414
|
e,
|
|
415
|
-
/* @__PURE__ */ t(
|
|
415
|
+
/* @__PURE__ */ t(Le, { className: "my-select__arrowdown", component: at, fontSize: "small" })
|
|
416
416
|
]
|
|
417
417
|
}
|
|
418
418
|
),
|
|
419
|
-
/* @__PURE__ */ t(
|
|
420
|
-
|
|
419
|
+
/* @__PURE__ */ t(Me, { open: u, anchorEl: p.current, transition: !0, style: { zIndex: "9999" }, children: ({ TransitionProps: w, placement: $ }) => /* @__PURE__ */ t(
|
|
420
|
+
Ae,
|
|
421
421
|
{
|
|
422
|
-
...
|
|
422
|
+
...w,
|
|
423
423
|
style: { transformOrigin: $ === "bottom" ? "center top" : "center bottom" },
|
|
424
|
-
children: /* @__PURE__ */ t(
|
|
424
|
+
children: /* @__PURE__ */ t(Fe, { children: /* @__PURE__ */ t(Oe, { onClickAway: T, children: /* @__PURE__ */ h(Lt, { autoFocusItem: u, onMouseEnter: i, onMouseLeave: T, children: [
|
|
425
425
|
l,
|
|
426
426
|
s.map((f) => b ? b(f) : /* @__PURE__ */ t(
|
|
427
|
-
|
|
427
|
+
qe,
|
|
428
428
|
{
|
|
429
|
-
onClick: () =>
|
|
429
|
+
onClick: () => m(f),
|
|
430
430
|
className: [
|
|
431
431
|
"my-select__option",
|
|
432
432
|
S(f.value) ? "my-select__option--active" : ""
|
|
@@ -457,7 +457,7 @@ Z.defaultProps = {
|
|
|
457
457
|
onChange: () => {
|
|
458
458
|
}
|
|
459
459
|
};
|
|
460
|
-
const
|
|
460
|
+
const Nt = v(Y)`
|
|
461
461
|
border: 1px solid #f0f0f0;
|
|
462
462
|
padding: 6px 8px 6px 12px;
|
|
463
463
|
font-weight: ${(e) => e.theme.typography.fontWeightBold};
|
|
@@ -489,7 +489,7 @@ const Lt = v(Y)`
|
|
|
489
489
|
margin-right: 3px;
|
|
490
490
|
}
|
|
491
491
|
}
|
|
492
|
-
`,
|
|
492
|
+
`, Lt = v(Ne)`
|
|
493
493
|
.my-select__option__icon {
|
|
494
494
|
color: transparent;
|
|
495
495
|
font-size: 16px;
|
|
@@ -506,8 +506,8 @@ const Lt = v(Y)`
|
|
|
506
506
|
}
|
|
507
507
|
}
|
|
508
508
|
`;
|
|
509
|
-
function
|
|
510
|
-
return /* @__PURE__ */ h(
|
|
509
|
+
function O({ options: e, onChange: o, title: r, value: l }) {
|
|
510
|
+
return /* @__PURE__ */ h(Mt, { children: [
|
|
511
511
|
/* @__PURE__ */ t("div", { className: "title", children: r }),
|
|
512
512
|
/* @__PURE__ */ t("div", { className: "list", children: e.map((s) => /* @__PURE__ */ t(
|
|
513
513
|
"div",
|
|
@@ -522,7 +522,7 @@ function F({ options: e, onChange: o, title: r, value: l }) {
|
|
|
522
522
|
)) })
|
|
523
523
|
] });
|
|
524
524
|
}
|
|
525
|
-
const
|
|
525
|
+
const Mt = v("div")`
|
|
526
526
|
.title {
|
|
527
527
|
font-size: 18px;
|
|
528
528
|
font-weight: bold;
|
|
@@ -550,48 +550,48 @@ const At = v("div")`
|
|
|
550
550
|
font-weight: bold;
|
|
551
551
|
}
|
|
552
552
|
`;
|
|
553
|
-
|
|
553
|
+
O.propTypes = {
|
|
554
554
|
title: n.string.isRequired,
|
|
555
555
|
options: n.array.isRequired,
|
|
556
556
|
onChange: n.func.isRequired,
|
|
557
557
|
value: n.oneOfType([n.string, n.number])
|
|
558
558
|
};
|
|
559
|
-
|
|
559
|
+
O.defaultProps = {
|
|
560
560
|
value: null
|
|
561
561
|
};
|
|
562
562
|
function ee() {
|
|
563
|
-
const { selectedCategory: e, handleCategory: o, t: r, handlePrice: l, filters: s, categoryOptions: c, priceOptions: b } = I(), [g,
|
|
564
|
-
|
|
563
|
+
const { selectedCategory: e, handleCategory: o, t: r, handlePrice: l, filters: s, categoryOptions: c, priceOptions: b } = I(), [g, p] = L(!1), y = (u, C) => {
|
|
564
|
+
u === "category" && o(C), u === "price" && l(C), p(!1);
|
|
565
565
|
};
|
|
566
|
-
return /* @__PURE__ */ h(
|
|
567
|
-
/* @__PURE__ */ t(
|
|
568
|
-
/* @__PURE__ */ h(
|
|
566
|
+
return /* @__PURE__ */ h(At, { children: [
|
|
567
|
+
/* @__PURE__ */ t(pt, { variant: "outlined", className: "filter-button", onClick: () => p(!0), children: /* @__PURE__ */ t(st, { className: "filter-icon", fontSize: "small" }) }),
|
|
568
|
+
/* @__PURE__ */ h(ct, { fullWidth: !0, title: "", open: g, onClose: () => p(!1), children: [
|
|
569
569
|
/* @__PURE__ */ t(
|
|
570
|
-
|
|
570
|
+
O,
|
|
571
571
|
{
|
|
572
572
|
title: r("common.price"),
|
|
573
573
|
options: b,
|
|
574
574
|
value: s.price,
|
|
575
|
-
onChange: (
|
|
576
|
-
y("price",
|
|
575
|
+
onChange: (u) => {
|
|
576
|
+
y("price", u);
|
|
577
577
|
}
|
|
578
578
|
}
|
|
579
579
|
),
|
|
580
580
|
c.length > 0 && /* @__PURE__ */ t("div", { style: { marginTop: "16px" }, children: /* @__PURE__ */ t(
|
|
581
|
-
|
|
581
|
+
O,
|
|
582
582
|
{
|
|
583
583
|
title: r("common.category"),
|
|
584
584
|
options: c,
|
|
585
585
|
value: e,
|
|
586
|
-
onChange: (
|
|
587
|
-
y("category",
|
|
586
|
+
onChange: (u) => {
|
|
587
|
+
y("category", u);
|
|
588
588
|
}
|
|
589
589
|
}
|
|
590
590
|
) })
|
|
591
591
|
] })
|
|
592
592
|
] });
|
|
593
593
|
}
|
|
594
|
-
const
|
|
594
|
+
const At = v("div")`
|
|
595
595
|
.filter-button {
|
|
596
596
|
margin-right: 16px;
|
|
597
597
|
border-color: rgb(240, 240, 240);
|
|
@@ -605,7 +605,7 @@ const Ft = v("div")`
|
|
|
605
605
|
`;
|
|
606
606
|
ee.propTypes = {};
|
|
607
607
|
ee.defaultProps = {};
|
|
608
|
-
const
|
|
608
|
+
const Ft = v("div")`
|
|
609
609
|
.MuiChip-root {
|
|
610
610
|
border-radius: 4px;
|
|
611
611
|
height: initial;
|
|
@@ -614,15 +614,15 @@ const Ot = v("div")`
|
|
|
614
614
|
padding: 4px 0;
|
|
615
615
|
}
|
|
616
616
|
`;
|
|
617
|
-
function
|
|
618
|
-
return e ? /* @__PURE__ */ t(
|
|
617
|
+
function A({ label: e, icon: o, onDelete: r, ...l }) {
|
|
618
|
+
return e ? /* @__PURE__ */ t(Ft, { ...l, children: /* @__PURE__ */ t(Ee, { color: "primary", "data-cy": "filter-tag", icon: o, label: e, onDelete: r }) }) : null;
|
|
619
619
|
}
|
|
620
|
-
|
|
620
|
+
A.propTypes = {
|
|
621
621
|
label: n.string,
|
|
622
622
|
onDelete: n.func,
|
|
623
623
|
icon: n.element
|
|
624
624
|
};
|
|
625
|
-
|
|
625
|
+
A.defaultProps = {
|
|
626
626
|
onDelete: null,
|
|
627
627
|
icon: null,
|
|
628
628
|
label: null
|
|
@@ -631,20 +631,20 @@ function de() {
|
|
|
631
631
|
const { t: e } = I();
|
|
632
632
|
return /* @__PURE__ */ t(ke, { style: { textAlign: "center" }, variant: "subtitle2", children: e("blocklet.noResults") });
|
|
633
633
|
}
|
|
634
|
-
function
|
|
634
|
+
function j({ filterTip: e, keywordTip: o }) {
|
|
635
635
|
const { t: r, locale: l } = I(), s = () => l === "zh" ? "、" : " , ";
|
|
636
|
-
return /* @__PURE__ */ h(
|
|
636
|
+
return /* @__PURE__ */ h(mt, { className: "tips", children: [
|
|
637
637
|
/* @__PURE__ */ t("span", { style: { marginRight: "16px" }, children: r("blocklet.emptyTip") }),
|
|
638
638
|
e && /* @__PURE__ */ t("span", { children: r("blocklet.filterTip") }),
|
|
639
639
|
e && o && s(),
|
|
640
640
|
o && /* @__PURE__ */ t("span", { children: r("blocklet.keywordTip") })
|
|
641
641
|
] });
|
|
642
642
|
}
|
|
643
|
-
|
|
643
|
+
j.propTypes = {
|
|
644
644
|
filterTip: n.bool,
|
|
645
645
|
keywordTip: n.bool
|
|
646
646
|
};
|
|
647
|
-
|
|
647
|
+
j.defaultProps = {
|
|
648
648
|
filterTip: !1,
|
|
649
649
|
keywordTip: !1
|
|
650
650
|
};
|
|
@@ -667,6 +667,18 @@ W.propTypes = {
|
|
|
667
667
|
primaryEnd: n.string.isRequired,
|
|
668
668
|
filter: n.string.isRequired
|
|
669
669
|
};
|
|
670
|
+
function Ot(e) {
|
|
671
|
+
return e ? e.width > 900 ? 12 : e.width > 600 ? 8 : 4 : 0;
|
|
672
|
+
}
|
|
673
|
+
function Pe({ children: e }) {
|
|
674
|
+
const o = E(null), [r, l] = L(null), s = et(r);
|
|
675
|
+
return F(() => {
|
|
676
|
+
r || l(o.current);
|
|
677
|
+
}, [r]), e(o, Ot(s));
|
|
678
|
+
}
|
|
679
|
+
Pe.propTypes = {
|
|
680
|
+
children: n.func.isRequired
|
|
681
|
+
};
|
|
670
682
|
function te({ blocklets: e, ...o }) {
|
|
671
683
|
const {
|
|
672
684
|
blockletRender: r,
|
|
@@ -675,14 +687,14 @@ function te({ blocklets: e, ...o }) {
|
|
|
675
687
|
selectedCategory: c,
|
|
676
688
|
getCategoryLocale: b,
|
|
677
689
|
filters: g,
|
|
678
|
-
t:
|
|
690
|
+
t: p,
|
|
679
691
|
hasNextPage: y,
|
|
680
|
-
loadMore:
|
|
692
|
+
loadMore: u,
|
|
681
693
|
endpoint: C
|
|
682
|
-
} = I(), B =
|
|
694
|
+
} = I(), B = !!c || !!g.price, [P] = dt({
|
|
683
695
|
loading: s.fetchBlockletsLoading || s.loadingMore,
|
|
684
696
|
hasNextPage: y,
|
|
685
|
-
onLoadMore:
|
|
697
|
+
onLoadMore: u
|
|
686
698
|
});
|
|
687
699
|
if (l.fetchBlockletsError)
|
|
688
700
|
return /* @__PURE__ */ t(
|
|
@@ -693,60 +705,60 @@ function te({ blocklets: e, ...o }) {
|
|
|
693
705
|
);
|
|
694
706
|
if (s.fetchBlockletsLoading)
|
|
695
707
|
return /* @__PURE__ */ t(N, { height: 60, display: "flex", alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ t(Q, {}) });
|
|
696
|
-
if (g.keyword &&
|
|
708
|
+
if (g.keyword && B && e.length === 0)
|
|
697
709
|
return /* @__PURE__ */ h(K, { children: [
|
|
698
710
|
/* @__PURE__ */ t(
|
|
699
711
|
W,
|
|
700
712
|
{
|
|
701
|
-
primaryStart:
|
|
702
|
-
primaryEnd:
|
|
713
|
+
primaryStart: p("blocklet.noBlockletPart1"),
|
|
714
|
+
primaryEnd: p("blocklet.noBlockletPart2"),
|
|
703
715
|
filter: g.keyword
|
|
704
716
|
}
|
|
705
717
|
),
|
|
706
|
-
/* @__PURE__ */ t(
|
|
718
|
+
/* @__PURE__ */ t(j, { keywordTip: !0, filterTip: !0 })
|
|
707
719
|
] });
|
|
708
720
|
if (g.keyword && e.length === 0)
|
|
709
721
|
return /* @__PURE__ */ h(K, { children: [
|
|
710
722
|
/* @__PURE__ */ t(
|
|
711
723
|
W,
|
|
712
724
|
{
|
|
713
|
-
primaryStart:
|
|
714
|
-
primaryEnd:
|
|
725
|
+
primaryStart: p("blocklet.noBlockletPart1"),
|
|
726
|
+
primaryEnd: p("blocklet.noBlockletPart2"),
|
|
715
727
|
filter: g.keyword
|
|
716
728
|
}
|
|
717
729
|
),
|
|
718
|
-
/* @__PURE__ */ t(
|
|
730
|
+
/* @__PURE__ */ t(j, { keywordTip: !0 })
|
|
719
731
|
] });
|
|
720
|
-
if (
|
|
721
|
-
const
|
|
732
|
+
if (B && e.length === 0) {
|
|
733
|
+
const k = b(c);
|
|
722
734
|
return /* @__PURE__ */ h(K, { children: [
|
|
723
|
-
|
|
735
|
+
k ? /* @__PURE__ */ t(
|
|
724
736
|
W,
|
|
725
737
|
{
|
|
726
|
-
primaryStart:
|
|
727
|
-
primaryEnd:
|
|
728
|
-
filter:
|
|
738
|
+
primaryStart: p("blocklet.noCategoryResults1"),
|
|
739
|
+
primaryEnd: p("blocklet.noCategoryResults2"),
|
|
740
|
+
filter: k
|
|
729
741
|
}
|
|
730
742
|
) : /* @__PURE__ */ t(de, {}),
|
|
731
|
-
/* @__PURE__ */ t(
|
|
743
|
+
/* @__PURE__ */ t(j, { filterTip: !0 })
|
|
732
744
|
] });
|
|
733
745
|
}
|
|
734
|
-
return e.length === 0 ? /* @__PURE__ */ t(K, { children: /* @__PURE__ */ t(de, {}) }) : /* @__PURE__ */ h(
|
|
735
|
-
e.map((
|
|
736
|
-
y && /* @__PURE__ */ t(me, { item: !0, xs: 12, ref:
|
|
737
|
-
] });
|
|
746
|
+
return e.length === 0 ? /* @__PURE__ */ t(K, { children: /* @__PURE__ */ t(de, {}) }) : /* @__PURE__ */ t(Pe, { children: (k, T) => /* @__PURE__ */ h(qt, { container: !0, ...o, columns: T, ref: k, children: [
|
|
747
|
+
e.map((i) => /* @__PURE__ */ t(me, { item: !0, xs: 4, "data-blocklet-did": i.did, children: r({ blocklet: i, blocklets: e }) }, i.did)),
|
|
748
|
+
y && /* @__PURE__ */ t(me, { item: !0, xs: 12, ref: P, children: /* @__PURE__ */ t(N, { height: 60, display: "flex", justifyContent: "center", children: /* @__PURE__ */ t(Q, {}) }) })
|
|
749
|
+
] }) });
|
|
738
750
|
}
|
|
739
751
|
te.propTypes = {
|
|
740
752
|
blocklets: n.array.isRequired
|
|
741
753
|
};
|
|
742
754
|
te.defaultProps = {};
|
|
743
|
-
const
|
|
755
|
+
const qt = v(we)`
|
|
744
756
|
opacity: ${(e) => e.columns > 0 ? 1 : 0};
|
|
745
757
|
&.MuiGrid-root {
|
|
746
758
|
width: 100%;
|
|
747
759
|
margin: 0 -16px;
|
|
748
760
|
}
|
|
749
|
-
`, me =
|
|
761
|
+
`, me = v(we)`
|
|
750
762
|
@media (max-width: ${(e) => e.theme.breakpoints.values.sm}px) {
|
|
751
763
|
&.MuiGrid-item {
|
|
752
764
|
padding-bottom: 0px;
|
|
@@ -757,7 +769,7 @@ const Et = v(we)`
|
|
|
757
769
|
margin-bottom: ${(e) => e.theme.spacing(2)};
|
|
758
770
|
}
|
|
759
771
|
}
|
|
760
|
-
|
|
772
|
+
`, K = v(ut)`
|
|
761
773
|
text-align: center;
|
|
762
774
|
.primary {
|
|
763
775
|
color: ${(e) => e.theme.palette.primary.main};
|
|
@@ -768,10 +780,10 @@ const Et = v(we)`
|
|
|
768
780
|
`;
|
|
769
781
|
function re() {
|
|
770
782
|
const { selectedCategory: e, handleCategory: o, t: r, handlePrice: l, filters: s, categoryOptions: c, priceOptions: b } = I();
|
|
771
|
-
return /* @__PURE__ */ h(
|
|
772
|
-
/* @__PURE__ */ t("div", { children: /* @__PURE__ */ t(
|
|
783
|
+
return /* @__PURE__ */ h(Et, { children: [
|
|
784
|
+
/* @__PURE__ */ t("div", { children: /* @__PURE__ */ t(O, { title: r("common.price"), options: b, value: s.price, onChange: l }) }),
|
|
773
785
|
c.length > 0 && /* @__PURE__ */ t("div", { style: { marginTop: "16px" }, children: /* @__PURE__ */ t(
|
|
774
|
-
|
|
786
|
+
O,
|
|
775
787
|
{
|
|
776
788
|
title: r("common.category"),
|
|
777
789
|
options: c,
|
|
@@ -781,7 +793,7 @@ function re() {
|
|
|
781
793
|
) })
|
|
782
794
|
] });
|
|
783
795
|
}
|
|
784
|
-
const
|
|
796
|
+
const Et = v("aside")`
|
|
785
797
|
width: 220px;
|
|
786
798
|
margin-right: ${(e) => e.theme.spacing(2)};
|
|
787
799
|
height: 100%;
|
|
@@ -793,13 +805,13 @@ const qt = v("aside")`
|
|
|
793
805
|
re.propTypes = {};
|
|
794
806
|
re.defaultProps = {};
|
|
795
807
|
function oe({ placeholder: e, ...o }) {
|
|
796
|
-
const { filters: r, handleKeyword: l } = I(), [s, c] =
|
|
797
|
-
const { value:
|
|
798
|
-
c(
|
|
799
|
-
},
|
|
808
|
+
const { filters: r, handleKeyword: l } = I(), [s, c] = L(r.keyword || ""), b = tt(l, { wait: 300 }), g = (y) => {
|
|
809
|
+
const { value: u } = y.target;
|
|
810
|
+
c(u), b.run(u);
|
|
811
|
+
}, p = () => {
|
|
800
812
|
c(""), l();
|
|
801
813
|
};
|
|
802
|
-
return
|
|
814
|
+
return F(() => {
|
|
803
815
|
c(r.keyword || "");
|
|
804
816
|
}, [r.keyword]), /* @__PURE__ */ t(
|
|
805
817
|
jt,
|
|
@@ -813,7 +825,7 @@ function oe({ placeholder: e, ...o }) {
|
|
|
813
825
|
value: s,
|
|
814
826
|
title: e,
|
|
815
827
|
"data-cy": "search",
|
|
816
|
-
endAdornment: s && /* @__PURE__ */ t(ce, { position: "end", children: /* @__PURE__ */ t(Ut, { "data-cy": "search-delete", onClick:
|
|
828
|
+
endAdornment: s && /* @__PURE__ */ t(ce, { position: "end", children: /* @__PURE__ */ t(Ut, { "data-cy": "search-delete", onClick: p }) }),
|
|
817
829
|
...o
|
|
818
830
|
}
|
|
819
831
|
);
|
|
@@ -824,7 +836,7 @@ oe.propTypes = {
|
|
|
824
836
|
oe.defaultProps = {
|
|
825
837
|
placeholder: "Type to search..."
|
|
826
838
|
};
|
|
827
|
-
const jt = v(
|
|
839
|
+
const jt = v(je)`
|
|
828
840
|
background-color: ${(e) => e.theme.palette.grey[50]};
|
|
829
841
|
font-size: 14px;
|
|
830
842
|
border-radius: 6px;
|
|
@@ -841,49 +853,49 @@ const jt = v(qe)`
|
|
|
841
853
|
color: transparent;
|
|
842
854
|
}
|
|
843
855
|
}
|
|
844
|
-
`, Gt = v(
|
|
856
|
+
`, Gt = v(ht)`
|
|
845
857
|
color: ${(e) => e.theme.palette.grey[500]};
|
|
846
858
|
font-size: 28px;
|
|
847
859
|
@media (max-width: ${(e) => e.theme.breakpoints.values.md}px) {
|
|
848
860
|
font-size: 24px;
|
|
849
861
|
}
|
|
850
|
-
`, Ut = v(
|
|
862
|
+
`, Ut = v(ft)`
|
|
851
863
|
color: ${(e) => e.theme.palette.grey[500]};
|
|
852
864
|
font-size: 16px;
|
|
853
865
|
cursor: pointer;
|
|
854
866
|
`;
|
|
855
867
|
function ne({ onSelect: e, wrapChildren: o }) {
|
|
856
|
-
const r = E(null), l = E(null), s = E(null), { storeApi: c, blockletRender: b, filters: g, endpoint:
|
|
857
|
-
const { data:
|
|
858
|
-
return S.length > 0 && S.unshift({ type: "more-result", total:
|
|
868
|
+
const r = E(null), l = E(null), s = E(null), { storeApi: c, blockletRender: b, filters: g, endpoint: p, handleKeyword: y, t: u } = I(), C = async (i) => {
|
|
869
|
+
const { data: m } = await c.get(z.blockletsPath, { params: i }), S = m.dataList || [];
|
|
870
|
+
return S.length > 0 && S.unshift({ type: "more-result", total: m.total || 0 }), S;
|
|
859
871
|
}, B = (i) => {
|
|
860
872
|
y(i.state.query), i.setIsOpen(!1);
|
|
861
|
-
},
|
|
873
|
+
}, P = () => {
|
|
862
874
|
r.current && setTimeout(() => {
|
|
863
875
|
const i = r.current.querySelector("input.bl-autocomplete-input");
|
|
864
876
|
i && i.focus();
|
|
865
877
|
});
|
|
866
|
-
},
|
|
867
|
-
i.setIsOpen(!1),
|
|
868
|
-
},
|
|
869
|
-
i.query !==
|
|
878
|
+
}, k = (i) => {
|
|
879
|
+
i.setIsOpen(!1), P();
|
|
880
|
+
}, T = ({ prevState: i, state: m }) => {
|
|
881
|
+
i.query !== m.query && (m.query || y());
|
|
870
882
|
};
|
|
871
|
-
return
|
|
883
|
+
return bt(
|
|
872
884
|
"ctrl + k, command + k",
|
|
873
|
-
(i) => (i.stopPropagation(), i.preventDefault(),
|
|
885
|
+
(i) => (i.stopPropagation(), i.preventDefault(), P(), !1),
|
|
874
886
|
{ enableOnTags: ["INPUT"] }
|
|
875
|
-
),
|
|
876
|
-
|
|
877
|
-
}, [
|
|
887
|
+
), F(() => {
|
|
888
|
+
P();
|
|
889
|
+
}, [p]), F(() => {
|
|
878
890
|
if (!r.current)
|
|
879
891
|
return;
|
|
880
|
-
const i =
|
|
892
|
+
const i = yt({
|
|
881
893
|
container: r.current,
|
|
882
894
|
renderer: { createElement: Qe, Fragment: Je, render: () => {
|
|
883
895
|
} },
|
|
884
|
-
render({ children:
|
|
885
|
-
var
|
|
886
|
-
(!l.current || s.current !== S) && (s.current = S, (
|
|
896
|
+
render({ children: m }, S) {
|
|
897
|
+
var w;
|
|
898
|
+
(!l.current || s.current !== S) && (s.current = S, (w = l.current) == null || w.unmount(), l.current = gt(S)), l.current.render(o(m));
|
|
887
899
|
},
|
|
888
900
|
autoFocus: !0,
|
|
889
901
|
openOnFocus: !1,
|
|
@@ -897,31 +909,31 @@ function ne({ onSelect: e, wrapChildren: o }) {
|
|
|
897
909
|
detachedContainer: "bl-autocomplete-detached-container"
|
|
898
910
|
},
|
|
899
911
|
translations: {
|
|
900
|
-
clearButtonTitle:
|
|
901
|
-
detachedCancelButtonText:
|
|
902
|
-
submitButtonTitle:
|
|
903
|
-
detachedSearchButtonTitle:
|
|
912
|
+
clearButtonTitle: u("common.clear"),
|
|
913
|
+
detachedCancelButtonText: u("common.cancel"),
|
|
914
|
+
submitButtonTitle: u("common.search"),
|
|
915
|
+
detachedSearchButtonTitle: u("common.search")
|
|
904
916
|
},
|
|
905
|
-
placeholder:
|
|
917
|
+
placeholder: u("common.searchStore"),
|
|
906
918
|
initialState: {
|
|
907
919
|
query: g.keyword
|
|
908
920
|
},
|
|
909
|
-
onStateChange(
|
|
910
|
-
|
|
921
|
+
onStateChange(m) {
|
|
922
|
+
T(m);
|
|
911
923
|
},
|
|
912
924
|
onSubmit: B,
|
|
913
|
-
onReset(
|
|
914
|
-
|
|
925
|
+
onReset(m) {
|
|
926
|
+
k(m);
|
|
915
927
|
},
|
|
916
|
-
getSources({ query:
|
|
928
|
+
getSources({ query: m, state: S, ...w }) {
|
|
917
929
|
const $ = {
|
|
918
930
|
...g,
|
|
919
931
|
sortBy: z[g.sortBy],
|
|
920
932
|
page: 1,
|
|
921
933
|
pageSize: 10,
|
|
922
|
-
keyword:
|
|
934
|
+
keyword: m
|
|
923
935
|
};
|
|
924
|
-
return
|
|
936
|
+
return $t([
|
|
925
937
|
{
|
|
926
938
|
sourceId: "blocklets",
|
|
927
939
|
getItems() {
|
|
@@ -929,22 +941,22 @@ function ne({ onSelect: e, wrapChildren: o }) {
|
|
|
929
941
|
},
|
|
930
942
|
// 选中后填充 搜索框中值
|
|
931
943
|
getItemInputValue({ item: f }) {
|
|
932
|
-
return f.type === "more-result" ?
|
|
944
|
+
return f.type === "more-result" ? m : f.title;
|
|
933
945
|
},
|
|
934
946
|
// 选中或者点击自动完成列表中的 item 时触发
|
|
935
947
|
onSelect({ event: f, item: D }) {
|
|
936
|
-
return D.type === "more-result" ? (
|
|
948
|
+
return D.type === "more-result" ? (w.setIsOpen(!1), y(m)) : f.type === "keydown" ? y(D.title) : e({
|
|
937
949
|
blocklet: D,
|
|
938
|
-
detailUrl:
|
|
939
|
-
storeUrl:
|
|
950
|
+
detailUrl: wt(p, `/blocklets/${D.did}`),
|
|
951
|
+
storeUrl: p
|
|
940
952
|
});
|
|
941
953
|
},
|
|
942
954
|
templates: {
|
|
943
955
|
item({ item: f }) {
|
|
944
|
-
return f.type === "more-result" ? /* @__PURE__ */ t("div", { children:
|
|
956
|
+
return f.type === "more-result" ? /* @__PURE__ */ t("div", { children: u("autocomplete.expandResult", { name: m, number: f.total.toLocaleString() }) }) : b({ blocklet: f, autocompleteSetters: w });
|
|
945
957
|
},
|
|
946
958
|
noResults() {
|
|
947
|
-
return
|
|
959
|
+
return u("blocklet.noResults");
|
|
948
960
|
}
|
|
949
961
|
}
|
|
950
962
|
}
|
|
@@ -982,12 +994,12 @@ function le({ t: e }) {
|
|
|
982
994
|
o.showResources = !o.showResources, r();
|
|
983
995
|
};
|
|
984
996
|
return /* @__PURE__ */ t(
|
|
985
|
-
|
|
997
|
+
xt,
|
|
986
998
|
{
|
|
987
999
|
checked: o.showResources,
|
|
988
1000
|
onChange: l,
|
|
989
1001
|
labelProps: {
|
|
990
|
-
label: /* @__PURE__ */ t(
|
|
1002
|
+
label: /* @__PURE__ */ t(Ge, { marginLeft: "8px", fontSize: "small", children: /* @__PURE__ */ t("span", { children: e("common.showResources") }) })
|
|
991
1003
|
}
|
|
992
1004
|
}
|
|
993
1005
|
);
|
|
@@ -997,7 +1009,7 @@ le.propTypes = {
|
|
|
997
1009
|
};
|
|
998
1010
|
le.defaultProps = {};
|
|
999
1011
|
function Kt() {
|
|
1000
|
-
var G, U,
|
|
1012
|
+
var G, U, M;
|
|
1001
1013
|
const {
|
|
1002
1014
|
handleDeveloper: e,
|
|
1003
1015
|
blockletList: o,
|
|
@@ -1007,13 +1019,13 @@ function Kt() {
|
|
|
1007
1019
|
handleCategory: c,
|
|
1008
1020
|
handlePrice: b,
|
|
1009
1021
|
handleSearchSelect: g,
|
|
1010
|
-
t:
|
|
1022
|
+
t: p,
|
|
1011
1023
|
getCategoryLocale: y,
|
|
1012
|
-
priceOptions:
|
|
1024
|
+
priceOptions: u,
|
|
1013
1025
|
wrapChildren: C,
|
|
1014
1026
|
showResourcesSwitch: B,
|
|
1015
|
-
baseSearch:
|
|
1016
|
-
} = I(),
|
|
1027
|
+
baseSearch: P
|
|
1028
|
+
} = I(), k = kt(p), T = ((G = k.find((R) => R.value === r.sortBy)) == null ? void 0 : G.name) || p("sort.sort"), i = y(r.category), { resourceType: m } = r || {}, S = (U = u.find((R) => R.value === r.price)) == null ? void 0 : U.name, [w, $] = L(!1), f = be((R) => R.breakpoints.down("md")), D = !P || w || f || ((M = r == null ? void 0 : r.keyword) == null ? void 0 : M.length);
|
|
1017
1029
|
return /* @__PURE__ */ h(N, { display: "flex", alignItems: "flex-start", height: "100%", children: [
|
|
1018
1030
|
/* @__PURE__ */ t(pe, { mdDown: !0, children: /* @__PURE__ */ t(re, {}) }),
|
|
1019
1031
|
/* @__PURE__ */ h(Wt, { children: [
|
|
@@ -1033,19 +1045,19 @@ function Kt() {
|
|
|
1033
1045
|
onBlur: () => {
|
|
1034
1046
|
$(!1);
|
|
1035
1047
|
},
|
|
1036
|
-
children:
|
|
1048
|
+
children: P ? /* @__PURE__ */ t(oe, { className: "bl-search-container", placeholder: p("common.searchStore") }) : /* @__PURE__ */ t(ne, { onSelect: g, wrapChildren: C })
|
|
1037
1049
|
}
|
|
1038
1050
|
),
|
|
1039
1051
|
/* @__PURE__ */ h(N, { mt: 0, ml: "16px", className: "filter-container", display: "flex", alignItems: "center", children: [
|
|
1040
|
-
!f && B && /* @__PURE__ */ t(N, { ml: 1, mr: 1, children: /* @__PURE__ */ t(le, { t:
|
|
1052
|
+
!f && B && /* @__PURE__ */ t(N, { ml: 1, mr: 1, children: /* @__PURE__ */ t(le, { t: p }) }),
|
|
1041
1053
|
/* @__PURE__ */ t(pe, { mdUp: !0, children: /* @__PURE__ */ t(ee, {}) }),
|
|
1042
1054
|
/* @__PURE__ */ t(
|
|
1043
1055
|
Z,
|
|
1044
1056
|
{
|
|
1045
1057
|
value: r.sortBy,
|
|
1046
|
-
options:
|
|
1047
|
-
title:
|
|
1048
|
-
icon: /* @__PURE__ */ t(
|
|
1058
|
+
options: k,
|
|
1059
|
+
title: T,
|
|
1060
|
+
icon: /* @__PURE__ */ t(De, {}),
|
|
1049
1061
|
onChange: (R) => {
|
|
1050
1062
|
s(R);
|
|
1051
1063
|
}
|
|
@@ -1055,17 +1067,17 @@ function Kt() {
|
|
|
1055
1067
|
] }),
|
|
1056
1068
|
/* @__PURE__ */ h(N, { display: "flex", flexWrap: "wrap", alignItems: "center", mb: "16px", children: [
|
|
1057
1069
|
/* @__PURE__ */ t(
|
|
1058
|
-
|
|
1070
|
+
A,
|
|
1059
1071
|
{
|
|
1060
1072
|
label: l,
|
|
1061
|
-
icon: /* @__PURE__ */ t(
|
|
1073
|
+
icon: /* @__PURE__ */ t(Ue, {}),
|
|
1062
1074
|
onDelete: () => {
|
|
1063
1075
|
e(null);
|
|
1064
1076
|
}
|
|
1065
1077
|
}
|
|
1066
1078
|
),
|
|
1067
1079
|
/* @__PURE__ */ t(
|
|
1068
|
-
|
|
1080
|
+
A,
|
|
1069
1081
|
{
|
|
1070
1082
|
label: i,
|
|
1071
1083
|
onDelete: () => {
|
|
@@ -1074,7 +1086,7 @@ function Kt() {
|
|
|
1074
1086
|
}
|
|
1075
1087
|
),
|
|
1076
1088
|
/* @__PURE__ */ t(
|
|
1077
|
-
|
|
1089
|
+
A,
|
|
1078
1090
|
{
|
|
1079
1091
|
label: S,
|
|
1080
1092
|
onDelete: () => {
|
|
@@ -1082,10 +1094,10 @@ function Kt() {
|
|
|
1082
1094
|
}
|
|
1083
1095
|
}
|
|
1084
1096
|
),
|
|
1085
|
-
|
|
1097
|
+
m && /* @__PURE__ */ t(A, { label: `${p("common.resourceType")}: ${m}` })
|
|
1086
1098
|
] })
|
|
1087
1099
|
] }),
|
|
1088
|
-
/* @__PURE__ */ t(
|
|
1100
|
+
/* @__PURE__ */ t(Ke, { FallbackComponent: xe, children: /* @__PURE__ */ t("div", { style: { position: "relative", flex: 1, overflow: "auto" }, children: /* @__PURE__ */ t(te, { blocklets: o }) }) })
|
|
1089
1101
|
] })
|
|
1090
1102
|
] });
|
|
1091
1103
|
}
|
|
@@ -1139,8 +1151,8 @@ const Wt = v("main")`
|
|
|
1139
1151
|
z-index: 9;
|
|
1140
1152
|
background-color: white;
|
|
1141
1153
|
`;
|
|
1142
|
-
function
|
|
1143
|
-
const o = fe(), r =
|
|
1154
|
+
function Te(e) {
|
|
1155
|
+
const o = fe(), r = Rt(o.palette.primary.main), l = {
|
|
1144
1156
|
autocomplete: ye`
|
|
1145
1157
|
:root {
|
|
1146
1158
|
--aa-detached-media-query: (max-width: ${o.breakpoints.values.md}px) !important;
|
|
@@ -1184,8 +1196,8 @@ function Pe(e) {
|
|
|
1184
1196
|
/* @__PURE__ */ t(Kt, {})
|
|
1185
1197
|
] });
|
|
1186
1198
|
}
|
|
1187
|
-
|
|
1188
|
-
|
|
1199
|
+
Te.propTypes = Se;
|
|
1200
|
+
Te.defaultProps = ve;
|
|
1189
1201
|
export {
|
|
1190
|
-
|
|
1202
|
+
Te as default
|
|
1191
1203
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/list",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.91",
|
|
4
4
|
"description": "Common ux components of blocklet",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -43,7 +43,11 @@
|
|
|
43
43
|
"url": "https://github.com/blocklet/blocklet-store/issues"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@arcblock/did-connect": ">=2.
|
|
46
|
+
"@arcblock/did-connect": ">=2.9.77",
|
|
47
|
+
"@arcblock/icons": ">=2.9.77",
|
|
48
|
+
"@arcblock/nft-display": ">=2.9.77",
|
|
49
|
+
"@arcblock/ux": ">=2.9.77",
|
|
50
|
+
"@blocklet/ui-react": ">=2.9.77",
|
|
47
51
|
"@mui/material": ">=5.6.4",
|
|
48
52
|
"@mui/styles": ">=5.6.2",
|
|
49
53
|
"react": ">=18.1.0",
|
|
@@ -53,6 +57,7 @@
|
|
|
53
57
|
"@algolia/autocomplete-js": "^1.17.0",
|
|
54
58
|
"@algolia/autocomplete-theme-classic": "^1.17.0",
|
|
55
59
|
"@arcblock/ux": "^2.9.79",
|
|
60
|
+
"@blocklet/util": "0.12.91",
|
|
56
61
|
"@emotion/react": "^11.10.0",
|
|
57
62
|
"@emotion/styled": "^11.10.0",
|
|
58
63
|
"@mui/icons-material": "^5.15.12",
|
|
@@ -83,5 +88,5 @@
|
|
|
83
88
|
"prettier": "^2.7.1",
|
|
84
89
|
"vite": "^5.2.6"
|
|
85
90
|
},
|
|
86
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "960c4679590e2f9a2a70e2848631934f02deba8a"
|
|
87
92
|
}
|