@blocklet/list 0.12.48 → 0.12.50
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 +4 -2
- package/lib/base.js +5 -0
- package/lib/components/filter/custom-chip.js +1 -1
- package/lib/contexts/filter.js +6 -2
- package/lib/index.es.js +358 -349
- package/lib/libs/prop-types.js +7 -3
- package/package.json +2 -2
package/lib/index.es.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { jsx as t, jsxs as h, Fragment as
|
|
1
|
+
import { jsx as t, jsxs as h, Fragment as Pe } from "react/jsx-runtime";
|
|
2
2
|
import { useTheme as pe } from "@mui/material/styles";
|
|
3
|
-
import { css as
|
|
3
|
+
import { css as Te, Global as Be } from "@emotion/react";
|
|
4
4
|
import { styled as C } from "@arcblock/ux/lib/Theme";
|
|
5
5
|
import $e from "@mui/icons-material/Sort";
|
|
6
|
-
import { Button as
|
|
7
|
-
import
|
|
8
|
-
import { ErrorBoundary as
|
|
9
|
-
import { ErrorFallback as
|
|
10
|
-
import { createContext as
|
|
11
|
-
import
|
|
12
|
-
import { useReactive as
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
6
|
+
import { Button as Re, CircularProgress as W, MenuList as ze, useMediaQuery as Ie, SvgIcon as _e, Popper as De, Grow as Ne, Paper as Ae, ClickAwayListener as Le, MenuItem as Me, Chip as Oe, Grid as ue, Box as D, OutlinedInput as Fe, InputAdornment as le, Hidden as ae } from "@mui/material";
|
|
7
|
+
import Ee from "@mui/icons-material/Face";
|
|
8
|
+
import { ErrorBoundary as qe } from "react-error-boundary";
|
|
9
|
+
import { ErrorFallback as de } from "@arcblock/ux/lib/ErrorBoundary";
|
|
10
|
+
import { createContext as je, useMemo as L, useState as F, useCallback as H, useEffect as E, useContext as Ge, forwardRef as Ue, useRef as M, memo as Ke, createElement as We, Fragment as He } from "react";
|
|
11
|
+
import o from "prop-types";
|
|
12
|
+
import { useReactive as Ve, useInfiniteScroll as Qe, useRequest as Je, useSize as Xe, useCreation as Ye, useDebounceFn as Ze } from "ahooks";
|
|
13
|
+
import et from "lodash/orderBy";
|
|
14
|
+
import tt from "axios";
|
|
15
|
+
import rt from "json-stable-stringify";
|
|
16
16
|
import "lodash/cloneDeep";
|
|
17
|
-
import
|
|
17
|
+
import ot from "color";
|
|
18
18
|
import ie from "flat";
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
19
|
+
import nt from "@mui/icons-material/KeyboardArrowDown";
|
|
20
|
+
import lt from "lodash/isEmpty";
|
|
21
|
+
import at from "@mui/icons-material/FilterAltOutlined";
|
|
22
|
+
import it from "@arcblock/ux/lib/Dialog";
|
|
23
|
+
import st from "@mui/material/Button";
|
|
24
|
+
import ct from "@arcblock/ux/lib/Empty";
|
|
25
|
+
import pt from "react-infinite-scroll-hook";
|
|
26
|
+
import ut from "@mui/material/Box";
|
|
27
27
|
import me from "@mui/material/Typography";
|
|
28
28
|
import dt from "@mui/icons-material/Search";
|
|
29
|
-
import
|
|
30
|
-
import { createRoot as
|
|
31
|
-
import { autocomplete as
|
|
32
|
-
import { useHotkeys as
|
|
33
|
-
import
|
|
29
|
+
import mt from "@mui/icons-material/Close";
|
|
30
|
+
import { createRoot as ft } from "react-dom/client";
|
|
31
|
+
import { autocomplete as ht } from "@algolia/autocomplete-js";
|
|
32
|
+
import { useHotkeys as gt } from "react-hotkeys-hook";
|
|
33
|
+
import yt from "url-join";
|
|
34
34
|
import "@algolia/autocomplete-theme-classic/dist/theme.css";
|
|
35
|
-
const
|
|
35
|
+
const bt = (e) => [
|
|
36
36
|
{
|
|
37
37
|
name: e("sort.popularity"),
|
|
38
38
|
value: "popularity"
|
|
@@ -49,29 +49,30 @@ const yt = (e) => [
|
|
|
49
49
|
name: e("sort.nameDescend"),
|
|
50
50
|
value: "nameDesc"
|
|
51
51
|
}
|
|
52
|
-
],
|
|
52
|
+
], xt = (e) => [
|
|
53
53
|
{ name: e("blocklet.free"), value: "free" },
|
|
54
54
|
{ name: e("blocklet.payment"), value: "payment" }
|
|
55
|
-
],
|
|
55
|
+
], kt = (e = [], n = "en") => e.map((r) => ({ name: r.locales[n] || `Category.${n}`, value: r._id })), wt = (e, n) => (
|
|
56
56
|
// eslint-disable-next-line no-prototype-builtins
|
|
57
|
-
e.replace(/{(\w*)}/g, (r, l) =>
|
|
58
|
-
),
|
|
59
|
-
const r = (e +
|
|
57
|
+
e.replace(/{(\w*)}/g, (r, l) => n.hasOwnProperty(l) ? n[l] : "")
|
|
58
|
+
), vt = () => window.innerWidth <= 600, St = (e, n) => {
|
|
59
|
+
const r = (e + n) / n;
|
|
60
60
|
return r > 1 ? r.toFixed() : 1;
|
|
61
|
-
},
|
|
62
|
-
function
|
|
61
|
+
}, Ct = (e) => ot(e).rgb().object();
|
|
62
|
+
function Pt(e, n) {
|
|
63
63
|
let r;
|
|
64
64
|
return function(...i) {
|
|
65
65
|
return r && clearTimeout(r), new Promise((c) => {
|
|
66
|
-
r = setTimeout(() => c(e(...i)),
|
|
66
|
+
r = setTimeout(() => c(e(...i)), n);
|
|
67
67
|
});
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
|
-
const
|
|
70
|
+
const Tt = Pt((e) => Promise.resolve(e), 300), Bt = {
|
|
71
71
|
common: {
|
|
72
72
|
searchStore: "Search the store",
|
|
73
73
|
price: "Price",
|
|
74
|
-
category: "Category"
|
|
74
|
+
category: "Category",
|
|
75
|
+
resourceType: "Resource Type"
|
|
75
76
|
},
|
|
76
77
|
sort: {
|
|
77
78
|
sort: "Sort",
|
|
@@ -105,7 +106,8 @@ const Pt = Ct((e) => Promise.resolve(e), 300), Bt = {
|
|
|
105
106
|
common: {
|
|
106
107
|
searchStore: "搜索商店内应用",
|
|
107
108
|
price: "价格",
|
|
108
|
-
category: "类别"
|
|
109
|
+
category: "类别",
|
|
110
|
+
resourceType: "资源类型"
|
|
109
111
|
},
|
|
110
112
|
sort: {
|
|
111
113
|
sort: "排序",
|
|
@@ -139,22 +141,25 @@ const Pt = Ct((e) => Promise.resolve(e), 300), Bt = {
|
|
|
139
141
|
en: ie(Bt),
|
|
140
142
|
zh: ie($t)
|
|
141
143
|
}, fe = {
|
|
142
|
-
filters:
|
|
143
|
-
keyword:
|
|
144
|
-
sortBy:
|
|
145
|
-
sortDirection:
|
|
146
|
-
price:
|
|
147
|
-
category:
|
|
148
|
-
developer:
|
|
144
|
+
filters: o.shape({
|
|
145
|
+
keyword: o.string,
|
|
146
|
+
sortBy: o.string,
|
|
147
|
+
sortDirection: o.string,
|
|
148
|
+
price: o.string,
|
|
149
|
+
category: o.string,
|
|
150
|
+
developer: o.string,
|
|
151
|
+
resourceType: o.string
|
|
149
152
|
}),
|
|
150
|
-
wrapChildren:
|
|
151
|
-
extraFilter:
|
|
152
|
-
endpoint:
|
|
153
|
-
blockletRender:
|
|
154
|
-
onFilterChange:
|
|
155
|
-
onSearchSelect:
|
|
156
|
-
locale:
|
|
157
|
-
baseSearch:
|
|
153
|
+
wrapChildren: o.func,
|
|
154
|
+
extraFilter: o.func,
|
|
155
|
+
endpoint: o.string.isRequired,
|
|
156
|
+
blockletRender: o.func.isRequired,
|
|
157
|
+
onFilterChange: o.func,
|
|
158
|
+
onSearchSelect: o.func,
|
|
159
|
+
locale: o.oneOf(["zh", "en"]),
|
|
160
|
+
baseSearch: o.bool,
|
|
161
|
+
// sometimes blocklet list can be rendered only before the category is fetched
|
|
162
|
+
fetchCategoryDelay: o.number
|
|
158
163
|
}, he = {
|
|
159
164
|
locale: "zh",
|
|
160
165
|
filters: {},
|
|
@@ -165,8 +170,9 @@ const Pt = Ct((e) => Promise.resolve(e), 300), Bt = {
|
|
|
165
170
|
},
|
|
166
171
|
wrapChildren: (e) => e,
|
|
167
172
|
extraFilter: (e) => e,
|
|
168
|
-
baseSearch: !1
|
|
169
|
-
|
|
173
|
+
baseSearch: !1,
|
|
174
|
+
fetchCategoryDelay: 0
|
|
175
|
+
}, R = {
|
|
170
176
|
nameAsc: "title",
|
|
171
177
|
nameDesc: "title",
|
|
172
178
|
popularity: "stats.downloads",
|
|
@@ -177,163 +183,166 @@ const Pt = Ct((e) => Promise.resolve(e), 300), Bt = {
|
|
|
177
183
|
blockletsPath: "/api/v2/blocklets.json",
|
|
178
184
|
categoriesPath: "/api/blocklets/categories",
|
|
179
185
|
cacheSize: 100
|
|
180
|
-
}, ge =
|
|
186
|
+
}, ge = je({}), { Provider: Rt, Consumer: Cr } = ge;
|
|
181
187
|
function V({
|
|
182
188
|
filters: e,
|
|
183
|
-
children:
|
|
189
|
+
children: n,
|
|
184
190
|
endpoint: r,
|
|
185
191
|
locale: l,
|
|
186
192
|
blockletRender: i,
|
|
187
193
|
onFilterChange: c,
|
|
188
194
|
onSearchSelect: k,
|
|
189
195
|
extraFilter: g,
|
|
190
|
-
wrapChildren:
|
|
191
|
-
baseSearch:
|
|
192
|
-
serverVersion:
|
|
193
|
-
storeVersion: P
|
|
196
|
+
wrapChildren: p,
|
|
197
|
+
baseSearch: y,
|
|
198
|
+
serverVersion: f,
|
|
199
|
+
storeVersion: P,
|
|
200
|
+
fetchCategoryDelay: B
|
|
194
201
|
}) {
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
const
|
|
202
|
+
const b = {};
|
|
203
|
+
f && (b["x-blocklet-server-version"] = f), P && (b["x-blocklet-store-version"] = P);
|
|
204
|
+
const $ = L(() => tt.create({
|
|
198
205
|
baseURL: r,
|
|
199
|
-
headers:
|
|
200
|
-
}), [r]),
|
|
201
|
-
currentPage:
|
|
202
|
-
pageSize:
|
|
203
|
-
defaultCurrentPage:
|
|
204
|
-
}), [
|
|
205
|
-
data:
|
|
206
|
-
loading:
|
|
207
|
-
loadMore:
|
|
208
|
-
loadingMore:
|
|
209
|
-
} =
|
|
206
|
+
headers: b
|
|
207
|
+
}), [r]), d = L(() => ({ sortBy: "popularity", sortDirection: "desc", ...e }), [e]), u = d.category, s = Ve({
|
|
208
|
+
currentPage: R.currentPage,
|
|
209
|
+
pageSize: vt() ? R.mobilePageSize : R.pageSize,
|
|
210
|
+
defaultCurrentPage: R.defaultCurrentPage
|
|
211
|
+
}), [S, x] = F(null), {
|
|
212
|
+
data: T = { list: [], total: 0 },
|
|
213
|
+
loading: w,
|
|
214
|
+
loadMore: _,
|
|
215
|
+
loadingMore: be
|
|
216
|
+
} = Qe(
|
|
210
217
|
async (a) => {
|
|
211
|
-
var
|
|
212
|
-
const
|
|
213
|
-
...
|
|
214
|
-
sortBy:
|
|
215
|
-
page:
|
|
216
|
-
pageSize:
|
|
218
|
+
var z;
|
|
219
|
+
const m = {
|
|
220
|
+
...d,
|
|
221
|
+
sortBy: R[d.sortBy],
|
|
222
|
+
page: St(((z = a == null ? void 0 : a.list) == null ? void 0 : z.length) || 0, s.pageSize),
|
|
223
|
+
pageSize: s.pageSize
|
|
217
224
|
};
|
|
218
|
-
|
|
219
|
-
const { data:
|
|
220
|
-
params:
|
|
225
|
+
x(null);
|
|
226
|
+
const { data: v = {} } = await $.get(R.blockletsPath, {
|
|
227
|
+
params: m
|
|
221
228
|
});
|
|
222
|
-
return { list: (
|
|
229
|
+
return { list: (v == null ? void 0 : v.dataList) || [], total: (v == null ? void 0 : v.total) || 0 };
|
|
223
230
|
},
|
|
224
231
|
{
|
|
225
232
|
isNoMore: (a) => a ? a.list.length >= a.total : !1,
|
|
226
|
-
reloadDeps: [r,
|
|
233
|
+
reloadDeps: [r, rt(e)],
|
|
227
234
|
onError: (a) => {
|
|
228
|
-
|
|
235
|
+
x(a);
|
|
229
236
|
}
|
|
230
237
|
}
|
|
231
238
|
), {
|
|
232
239
|
data: G = [],
|
|
233
|
-
error:
|
|
234
|
-
loading:
|
|
235
|
-
run:
|
|
236
|
-
} =
|
|
240
|
+
error: xe,
|
|
241
|
+
loading: ke,
|
|
242
|
+
run: we
|
|
243
|
+
} = Je(
|
|
237
244
|
async () => {
|
|
238
|
-
const { data: a } = await
|
|
245
|
+
const { data: a } = await $.get(R.categoriesPath);
|
|
239
246
|
return Array.isArray(a) ? a : [];
|
|
240
247
|
},
|
|
241
248
|
{ manual: !0 }
|
|
242
|
-
), U =
|
|
243
|
-
(a,
|
|
244
|
-
const
|
|
245
|
-
return
|
|
249
|
+
), U = L(() => et(G || [], [(m) => m.name], ["asc"]), [G]), re = H(
|
|
250
|
+
(a, m) => {
|
|
251
|
+
const v = K[l] ? K[l][a] : K.en[a];
|
|
252
|
+
return wt(v, m);
|
|
246
253
|
},
|
|
247
254
|
[l]
|
|
248
|
-
), oe =
|
|
249
|
-
let a =
|
|
255
|
+
), oe = L(() => {
|
|
256
|
+
let a = T.list || [];
|
|
250
257
|
return a = g(a), a;
|
|
251
|
-
}, [
|
|
252
|
-
errors: { fetchBlockletsError:
|
|
253
|
-
loadings: { fetchBlockletsLoading:
|
|
258
|
+
}, [T, g]), ve = L(() => kt(U, l), [U, l]), Se = xt(re), Ce = {
|
|
259
|
+
errors: { fetchBlockletsError: S, fetchCategoriesError: xe },
|
|
260
|
+
loadings: { fetchBlockletsLoading: w, fetchCategoriesLoading: ke, loadingMore: be },
|
|
254
261
|
endpoint: r,
|
|
255
262
|
blockletList: oe,
|
|
256
|
-
wrapChildren:
|
|
263
|
+
wrapChildren: p,
|
|
257
264
|
t: re,
|
|
258
|
-
filters:
|
|
259
|
-
selectedCategory:
|
|
265
|
+
filters: d,
|
|
266
|
+
selectedCategory: u,
|
|
260
267
|
categoryList: U,
|
|
261
268
|
blockletRender: i,
|
|
262
269
|
locale: l,
|
|
263
|
-
categoryOptions:
|
|
264
|
-
priceOptions:
|
|
265
|
-
storeApi:
|
|
266
|
-
baseSearch:
|
|
267
|
-
hasNextPage:
|
|
270
|
+
categoryOptions: ve,
|
|
271
|
+
priceOptions: Se,
|
|
272
|
+
storeApi: $,
|
|
273
|
+
baseSearch: y,
|
|
274
|
+
hasNextPage: T.list.length < T.total,
|
|
268
275
|
handleSort: (a) => {
|
|
269
|
-
const
|
|
270
|
-
...
|
|
276
|
+
const m = {
|
|
277
|
+
...d,
|
|
271
278
|
sortBy: a,
|
|
272
279
|
sortDirection: a === "nameAsc" ? "asc" : "desc"
|
|
273
280
|
};
|
|
274
|
-
c(
|
|
281
|
+
c(m);
|
|
275
282
|
},
|
|
276
283
|
handleKeyword: (a) => {
|
|
277
|
-
const
|
|
278
|
-
c(
|
|
284
|
+
const m = { ...d, keyword: a || void 0 };
|
|
285
|
+
c(m);
|
|
279
286
|
},
|
|
280
287
|
handlePrice: (a) => {
|
|
281
|
-
const
|
|
282
|
-
...
|
|
283
|
-
price: a ===
|
|
288
|
+
const m = {
|
|
289
|
+
...d,
|
|
290
|
+
price: a === d.price ? void 0 : a
|
|
284
291
|
};
|
|
285
|
-
c(
|
|
292
|
+
c(m);
|
|
286
293
|
},
|
|
287
294
|
handleCategory: (a) => {
|
|
288
|
-
let
|
|
289
|
-
(a === "all" || a ===
|
|
290
|
-
const
|
|
291
|
-
c(
|
|
295
|
+
let m = a;
|
|
296
|
+
(a === "all" || a === d.category) && (m = void 0);
|
|
297
|
+
const v = { ...d, category: m };
|
|
298
|
+
c(v);
|
|
292
299
|
},
|
|
293
300
|
handleDeveloper: (a) => {
|
|
294
|
-
const
|
|
295
|
-
c(
|
|
301
|
+
const m = { ...d, owner: a || void 0 };
|
|
302
|
+
c(m);
|
|
296
303
|
},
|
|
297
304
|
handlePage: (a) => {
|
|
298
|
-
const
|
|
299
|
-
c(
|
|
305
|
+
const m = { ...d, currentPage: a };
|
|
306
|
+
c(m);
|
|
300
307
|
},
|
|
301
308
|
loadMore: () => {
|
|
302
|
-
|
|
309
|
+
_();
|
|
303
310
|
},
|
|
304
311
|
getCategoryLocale: (a) => {
|
|
305
312
|
if (!a)
|
|
306
313
|
return null;
|
|
307
|
-
let
|
|
308
|
-
const
|
|
309
|
-
return
|
|
314
|
+
let m = null;
|
|
315
|
+
const v = G.find((z) => z._id === a);
|
|
316
|
+
return v && (m = v.locales[l]), m;
|
|
310
317
|
},
|
|
311
318
|
get developerName() {
|
|
312
|
-
var
|
|
313
|
-
return ((
|
|
319
|
+
var m, v;
|
|
320
|
+
return ((v = (m = oe.find((z) => {
|
|
314
321
|
var ne;
|
|
315
|
-
return ((ne =
|
|
316
|
-
})) == null ? void 0 :
|
|
322
|
+
return ((ne = z == null ? void 0 : z.owner) == null ? void 0 : ne.did) === d.owner;
|
|
323
|
+
})) == null ? void 0 : m.owner) == null ? void 0 : v.name) || "";
|
|
317
324
|
},
|
|
318
325
|
handleSearchSelect: k
|
|
319
326
|
};
|
|
320
327
|
return E(() => {
|
|
321
|
-
|
|
322
|
-
|
|
328
|
+
setTimeout(() => {
|
|
329
|
+
we();
|
|
330
|
+
}, B || 0);
|
|
331
|
+
}, [r]), /* @__PURE__ */ t(Rt, { value: Ce, children: n });
|
|
323
332
|
}
|
|
324
333
|
V.propTypes = {
|
|
325
334
|
...fe,
|
|
326
|
-
children:
|
|
335
|
+
children: o.any.isRequired
|
|
327
336
|
};
|
|
328
337
|
V.defaultProps = he;
|
|
329
|
-
function
|
|
330
|
-
const e =
|
|
338
|
+
function I() {
|
|
339
|
+
const e = Ge(ge);
|
|
331
340
|
return e || {};
|
|
332
341
|
}
|
|
333
|
-
const
|
|
342
|
+
const zt = C(Re)`
|
|
334
343
|
border-radius: 4px;
|
|
335
|
-
`, Q =
|
|
336
|
-
|
|
344
|
+
`, Q = Ue(({ children: e, rounded: n, loading: r, disabled: l, ...i }, c) => /* @__PURE__ */ t(
|
|
345
|
+
zt,
|
|
337
346
|
{
|
|
338
347
|
ref: c,
|
|
339
348
|
disableElevation: !0,
|
|
@@ -344,10 +353,10 @@ const Rt = C(Te)`
|
|
|
344
353
|
}
|
|
345
354
|
));
|
|
346
355
|
Q.propTypes = {
|
|
347
|
-
children:
|
|
348
|
-
rounded:
|
|
349
|
-
loading:
|
|
350
|
-
disabled:
|
|
356
|
+
children: o.any,
|
|
357
|
+
rounded: o.bool,
|
|
358
|
+
loading: o.bool,
|
|
359
|
+
disabled: o.bool
|
|
351
360
|
};
|
|
352
361
|
Q.defaultProps = {
|
|
353
362
|
children: null,
|
|
@@ -355,57 +364,57 @@ Q.defaultProps = {
|
|
|
355
364
|
loading: !1,
|
|
356
365
|
disabled: !1
|
|
357
366
|
};
|
|
358
|
-
function J({ title: e, value:
|
|
359
|
-
const
|
|
367
|
+
function J({ title: e, value: n, icon: r, prepend: l, options: i, onChange: c, itemRender: k, ...g }) {
|
|
368
|
+
const p = M(null), y = pe(), [f, P] = F(!1), [B, b] = F(n !== null ? n : ""), $ = Ie(y.breakpoints.down("sm"));
|
|
360
369
|
E(() => {
|
|
361
|
-
|
|
362
|
-
}, [
|
|
363
|
-
const
|
|
370
|
+
b(n !== null ? n : "");
|
|
371
|
+
}, [n]);
|
|
372
|
+
const d = H(() => {
|
|
364
373
|
P(!1);
|
|
365
|
-
}, []),
|
|
374
|
+
}, []), u = H(() => {
|
|
366
375
|
P(!0);
|
|
367
376
|
}, []);
|
|
368
|
-
function s(
|
|
369
|
-
x
|
|
377
|
+
function s(x) {
|
|
378
|
+
b(x.value), c(x.value), $ && d();
|
|
370
379
|
}
|
|
371
|
-
function
|
|
372
|
-
return
|
|
380
|
+
function S(x) {
|
|
381
|
+
return x === B;
|
|
373
382
|
}
|
|
374
|
-
return /* @__PURE__ */ h(
|
|
383
|
+
return /* @__PURE__ */ h(Pe, { children: [
|
|
375
384
|
/* @__PURE__ */ h(
|
|
376
|
-
|
|
385
|
+
It,
|
|
377
386
|
{
|
|
378
|
-
ref:
|
|
379
|
-
onClick:
|
|
387
|
+
ref: p,
|
|
388
|
+
onClick: u,
|
|
380
389
|
variant: "outlined",
|
|
381
390
|
size: "small",
|
|
382
|
-
className: ["my-select__selector",
|
|
391
|
+
className: ["my-select__selector", lt(B) ? "" : "my-select__selector--active"].join(" "),
|
|
383
392
|
...g,
|
|
384
393
|
children: [
|
|
385
394
|
/* @__PURE__ */ t("div", { className: "my-select__icon", children: r }),
|
|
386
395
|
e,
|
|
387
|
-
/* @__PURE__ */ t(
|
|
396
|
+
/* @__PURE__ */ t(_e, { className: "my-select__arrowdown", component: nt, fontSize: "small" })
|
|
388
397
|
]
|
|
389
398
|
}
|
|
390
399
|
),
|
|
391
|
-
/* @__PURE__ */ t(
|
|
392
|
-
|
|
400
|
+
/* @__PURE__ */ t(De, { open: f, anchorEl: p.current, transition: !0, style: { zIndex: "9999" }, children: ({ TransitionProps: x, placement: T }) => /* @__PURE__ */ t(
|
|
401
|
+
Ne,
|
|
393
402
|
{
|
|
394
|
-
...
|
|
395
|
-
style: { transformOrigin:
|
|
396
|
-
children: /* @__PURE__ */ t(
|
|
403
|
+
...x,
|
|
404
|
+
style: { transformOrigin: T === "bottom" ? "center top" : "center bottom" },
|
|
405
|
+
children: /* @__PURE__ */ t(Ae, { children: /* @__PURE__ */ t(Le, { onClickAway: d, children: /* @__PURE__ */ h(_t, { autoFocusItem: f, onMouseEnter: u, onMouseLeave: d, children: [
|
|
397
406
|
l,
|
|
398
|
-
i.map((
|
|
399
|
-
|
|
407
|
+
i.map((w) => k ? k(w) : /* @__PURE__ */ t(
|
|
408
|
+
Me,
|
|
400
409
|
{
|
|
401
|
-
onClick: () => s(
|
|
410
|
+
onClick: () => s(w),
|
|
402
411
|
className: [
|
|
403
412
|
"my-select__option",
|
|
404
|
-
w
|
|
413
|
+
S(w.value) ? "my-select__option--active" : ""
|
|
405
414
|
].join(" "),
|
|
406
|
-
children:
|
|
415
|
+
children: w.name
|
|
407
416
|
},
|
|
408
|
-
|
|
417
|
+
w.value
|
|
409
418
|
))
|
|
410
419
|
] }) }) })
|
|
411
420
|
}
|
|
@@ -413,13 +422,13 @@ function J({ title: e, value: o, icon: r, prepend: l, options: i, onChange: c, i
|
|
|
413
422
|
] });
|
|
414
423
|
}
|
|
415
424
|
J.propTypes = {
|
|
416
|
-
options:
|
|
417
|
-
value:
|
|
418
|
-
onChange:
|
|
419
|
-
itemRender:
|
|
420
|
-
title:
|
|
421
|
-
icon:
|
|
422
|
-
prepend:
|
|
425
|
+
options: o.array.isRequired,
|
|
426
|
+
value: o.oneOfType([o.string, o.number, o.array]),
|
|
427
|
+
onChange: o.func,
|
|
428
|
+
itemRender: o.func,
|
|
429
|
+
title: o.string.isRequired,
|
|
430
|
+
icon: o.any,
|
|
431
|
+
prepend: o.any
|
|
423
432
|
};
|
|
424
433
|
J.defaultProps = {
|
|
425
434
|
value: null,
|
|
@@ -429,7 +438,7 @@ J.defaultProps = {
|
|
|
429
438
|
onChange: () => {
|
|
430
439
|
}
|
|
431
440
|
};
|
|
432
|
-
const
|
|
441
|
+
const It = C(Q)`
|
|
433
442
|
border: 1px solid #f0f0f0;
|
|
434
443
|
padding: 6px 8px 6px 12px;
|
|
435
444
|
font-weight: ${(e) => e.theme.typography.fontWeightBold};
|
|
@@ -461,7 +470,7 @@ const zt = C(Q)`
|
|
|
461
470
|
margin-right: 3px;
|
|
462
471
|
}
|
|
463
472
|
}
|
|
464
|
-
`,
|
|
473
|
+
`, _t = C(ze)`
|
|
465
474
|
.my-select__option__icon {
|
|
466
475
|
color: transparent;
|
|
467
476
|
font-size: 16px;
|
|
@@ -478,8 +487,8 @@ const zt = C(Q)`
|
|
|
478
487
|
}
|
|
479
488
|
}
|
|
480
489
|
`;
|
|
481
|
-
function
|
|
482
|
-
return /* @__PURE__ */ h(
|
|
490
|
+
function A({ options: e, onChange: n, title: r, value: l }) {
|
|
491
|
+
return /* @__PURE__ */ h(Dt, { children: [
|
|
483
492
|
/* @__PURE__ */ t("div", { className: "title", children: r }),
|
|
484
493
|
/* @__PURE__ */ t("div", { className: "list", children: e.map((i) => /* @__PURE__ */ t(
|
|
485
494
|
"div",
|
|
@@ -487,14 +496,14 @@ function D({ options: e, onChange: o, title: r, value: l }) {
|
|
|
487
496
|
title: i.name,
|
|
488
497
|
"data-cy": "filter",
|
|
489
498
|
className: l === i.value ? "select item" : "item",
|
|
490
|
-
onClick: () =>
|
|
499
|
+
onClick: () => n(i.value),
|
|
491
500
|
children: i.name
|
|
492
501
|
},
|
|
493
502
|
i.value
|
|
494
503
|
)) })
|
|
495
504
|
] });
|
|
496
505
|
}
|
|
497
|
-
const
|
|
506
|
+
const Dt = C("div")`
|
|
498
507
|
.title {
|
|
499
508
|
font-size: 18px;
|
|
500
509
|
font-weight: bold;
|
|
@@ -522,48 +531,48 @@ const _t = C("div")`
|
|
|
522
531
|
font-weight: bold;
|
|
523
532
|
}
|
|
524
533
|
`;
|
|
525
|
-
|
|
526
|
-
title:
|
|
527
|
-
options:
|
|
528
|
-
onChange:
|
|
529
|
-
value:
|
|
534
|
+
A.propTypes = {
|
|
535
|
+
title: o.string.isRequired,
|
|
536
|
+
options: o.array.isRequired,
|
|
537
|
+
onChange: o.func.isRequired,
|
|
538
|
+
value: o.oneOfType([o.string, o.number])
|
|
530
539
|
};
|
|
531
|
-
|
|
540
|
+
A.defaultProps = {
|
|
532
541
|
value: null
|
|
533
542
|
};
|
|
534
543
|
function X() {
|
|
535
|
-
const { selectedCategory: e, handleCategory:
|
|
536
|
-
|
|
544
|
+
const { selectedCategory: e, handleCategory: n, t: r, handlePrice: l, filters: i, categoryOptions: c, priceOptions: k } = I(), [g, p] = F(!1), y = (f, P) => {
|
|
545
|
+
f === "category" && n(P), f === "price" && l(P), p(!1);
|
|
537
546
|
};
|
|
538
|
-
return /* @__PURE__ */ h(
|
|
539
|
-
/* @__PURE__ */ t(
|
|
540
|
-
/* @__PURE__ */ h(
|
|
547
|
+
return /* @__PURE__ */ h(Nt, { children: [
|
|
548
|
+
/* @__PURE__ */ t(st, { variant: "outlined", className: "filter-button", onClick: () => p(!0), children: /* @__PURE__ */ t(at, { className: "filter-icon", fontSize: "small" }) }),
|
|
549
|
+
/* @__PURE__ */ h(it, { fullWidth: !0, title: "", open: g, onClose: () => p(!1), children: [
|
|
541
550
|
/* @__PURE__ */ t(
|
|
542
|
-
|
|
551
|
+
A,
|
|
543
552
|
{
|
|
544
553
|
title: r("common.price"),
|
|
545
554
|
options: k,
|
|
546
555
|
value: i.price,
|
|
547
|
-
onChange: (
|
|
548
|
-
|
|
556
|
+
onChange: (f) => {
|
|
557
|
+
y("price", f);
|
|
549
558
|
}
|
|
550
559
|
}
|
|
551
560
|
),
|
|
552
561
|
c.length > 0 && /* @__PURE__ */ t("div", { style: { marginTop: "16px" }, children: /* @__PURE__ */ t(
|
|
553
|
-
|
|
562
|
+
A,
|
|
554
563
|
{
|
|
555
564
|
title: r("common.category"),
|
|
556
565
|
options: c,
|
|
557
566
|
value: e,
|
|
558
|
-
onChange: (
|
|
559
|
-
|
|
567
|
+
onChange: (f) => {
|
|
568
|
+
y("category", f);
|
|
560
569
|
}
|
|
561
570
|
}
|
|
562
571
|
) })
|
|
563
572
|
] })
|
|
564
573
|
] });
|
|
565
574
|
}
|
|
566
|
-
const
|
|
575
|
+
const Nt = C("div")`
|
|
567
576
|
.filter-button {
|
|
568
577
|
margin-right: 16px;
|
|
569
578
|
border-color: rgb(240, 240, 240);
|
|
@@ -577,7 +586,7 @@ const Dt = C("div")`
|
|
|
577
586
|
`;
|
|
578
587
|
X.propTypes = {};
|
|
579
588
|
X.defaultProps = {};
|
|
580
|
-
const
|
|
589
|
+
const At = C("div")`
|
|
581
590
|
.MuiChip-root {
|
|
582
591
|
border-radius: 4px;
|
|
583
592
|
height: initial;
|
|
@@ -586,42 +595,41 @@ const Nt = C("div")`
|
|
|
586
595
|
padding: 4px 0;
|
|
587
596
|
}
|
|
588
597
|
`;
|
|
589
|
-
function
|
|
590
|
-
return e ? /* @__PURE__ */ t(
|
|
598
|
+
function N({ label: e, icon: n, onDelete: r, ...l }) {
|
|
599
|
+
return e ? /* @__PURE__ */ t(At, { ...l, children: /* @__PURE__ */ t(Oe, { color: "primary", "data-cy": "filter-tag", icon: n, label: e, onDelete: r }) }) : null;
|
|
591
600
|
}
|
|
592
|
-
|
|
593
|
-
label:
|
|
594
|
-
onDelete:
|
|
595
|
-
icon:
|
|
601
|
+
N.propTypes = {
|
|
602
|
+
label: o.string,
|
|
603
|
+
onDelete: o.func,
|
|
604
|
+
icon: o.element
|
|
596
605
|
};
|
|
597
|
-
|
|
598
|
-
onDelete:
|
|
599
|
-
},
|
|
606
|
+
N.defaultProps = {
|
|
607
|
+
onDelete: null,
|
|
600
608
|
icon: null,
|
|
601
609
|
label: null
|
|
602
610
|
};
|
|
603
611
|
function se() {
|
|
604
|
-
const { t: e } =
|
|
612
|
+
const { t: e } = I();
|
|
605
613
|
return /* @__PURE__ */ t(me, { style: { textAlign: "center" }, variant: "subtitle2", children: e("blocklet.noResults") });
|
|
606
614
|
}
|
|
607
|
-
function O({ filterTip: e, keywordTip:
|
|
608
|
-
const { t: r, locale: l } =
|
|
609
|
-
return /* @__PURE__ */ h(
|
|
615
|
+
function O({ filterTip: e, keywordTip: n }) {
|
|
616
|
+
const { t: r, locale: l } = I(), i = () => l === "zh" ? "、" : " , ";
|
|
617
|
+
return /* @__PURE__ */ h(ut, { className: "tips", children: [
|
|
610
618
|
/* @__PURE__ */ t("span", { style: { marginRight: "16px" }, children: r("blocklet.emptyTip") }),
|
|
611
619
|
e && /* @__PURE__ */ t("span", { children: r("blocklet.filterTip") }),
|
|
612
|
-
e &&
|
|
613
|
-
|
|
620
|
+
e && n && i(),
|
|
621
|
+
n && /* @__PURE__ */ t("span", { children: r("blocklet.keywordTip") })
|
|
614
622
|
] });
|
|
615
623
|
}
|
|
616
624
|
O.propTypes = {
|
|
617
|
-
filterTip:
|
|
618
|
-
keywordTip:
|
|
625
|
+
filterTip: o.bool,
|
|
626
|
+
keywordTip: o.bool
|
|
619
627
|
};
|
|
620
628
|
O.defaultProps = {
|
|
621
629
|
filterTip: !1,
|
|
622
630
|
keywordTip: !1
|
|
623
631
|
};
|
|
624
|
-
function j({ primaryStart: e, primaryEnd:
|
|
632
|
+
function j({ primaryStart: e, primaryEnd: n, filter: r }) {
|
|
625
633
|
return /* @__PURE__ */ h(me, { variant: "subtitle2", children: [
|
|
626
634
|
/* @__PURE__ */ t("span", { children: e }),
|
|
627
635
|
/* @__PURE__ */ h("span", { className: "primary", children: [
|
|
@@ -630,17 +638,17 @@ function j({ primaryStart: e, primaryEnd: o, filter: r }) {
|
|
|
630
638
|
" "
|
|
631
639
|
] }),
|
|
632
640
|
/* @__PURE__ */ h("span", { children: [
|
|
633
|
-
|
|
641
|
+
n,
|
|
634
642
|
" "
|
|
635
643
|
] })
|
|
636
644
|
] });
|
|
637
645
|
}
|
|
638
646
|
j.propTypes = {
|
|
639
|
-
primaryStart:
|
|
640
|
-
primaryEnd:
|
|
641
|
-
filter:
|
|
647
|
+
primaryStart: o.string.isRequired,
|
|
648
|
+
primaryEnd: o.string.isRequired,
|
|
649
|
+
filter: o.string.isRequired
|
|
642
650
|
};
|
|
643
|
-
function Y({ blocklets: e, ...
|
|
651
|
+
function Y({ blocklets: e, ...n }) {
|
|
644
652
|
const {
|
|
645
653
|
blockletRender: r,
|
|
646
654
|
errors: l,
|
|
@@ -648,31 +656,31 @@ function Y({ blocklets: e, ...o }) {
|
|
|
648
656
|
selectedCategory: c,
|
|
649
657
|
getCategoryLocale: k,
|
|
650
658
|
filters: g,
|
|
651
|
-
t:
|
|
652
|
-
hasNextPage:
|
|
653
|
-
loadMore:
|
|
659
|
+
t: p,
|
|
660
|
+
hasNextPage: y,
|
|
661
|
+
loadMore: f,
|
|
654
662
|
endpoint: P
|
|
655
|
-
} =
|
|
663
|
+
} = I(), B = M(null), b = Xe(B.current), $ = Ye(() => b ? b.width > 900 ? 12 : b.width > 600 ? 8 : 4 : 0, [b]), d = !!c || !!g.price, [u] = pt({
|
|
656
664
|
loading: i.fetchBlockletsLoading || i.loadingMore,
|
|
657
|
-
hasNextPage:
|
|
658
|
-
onLoadMore:
|
|
665
|
+
hasNextPage: y,
|
|
666
|
+
onLoadMore: f
|
|
659
667
|
});
|
|
660
668
|
if (l.fetchBlockletsError)
|
|
661
669
|
return /* @__PURE__ */ t(
|
|
662
|
-
|
|
670
|
+
de,
|
|
663
671
|
{
|
|
664
672
|
error: new Error(`Failed to fetch blocklets from ${P}: ${l.fetchBlockletsError.message}`)
|
|
665
673
|
}
|
|
666
674
|
);
|
|
667
675
|
if (i.fetchBlockletsLoading)
|
|
668
|
-
return /* @__PURE__ */ t(
|
|
669
|
-
if (g.keyword &&
|
|
676
|
+
return /* @__PURE__ */ t(D, { height: 60, display: "flex", alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ t(W, {}) });
|
|
677
|
+
if (g.keyword && d && e.length === 0)
|
|
670
678
|
return /* @__PURE__ */ h(q, { children: [
|
|
671
679
|
/* @__PURE__ */ t(
|
|
672
680
|
j,
|
|
673
681
|
{
|
|
674
|
-
primaryStart:
|
|
675
|
-
primaryEnd:
|
|
682
|
+
primaryStart: p("blocklet.noBlockletPart1"),
|
|
683
|
+
primaryEnd: p("blocklet.noBlockletPart2"),
|
|
676
684
|
filter: g.keyword
|
|
677
685
|
}
|
|
678
686
|
),
|
|
@@ -683,43 +691,43 @@ function Y({ blocklets: e, ...o }) {
|
|
|
683
691
|
/* @__PURE__ */ t(
|
|
684
692
|
j,
|
|
685
693
|
{
|
|
686
|
-
primaryStart:
|
|
687
|
-
primaryEnd:
|
|
694
|
+
primaryStart: p("blocklet.noBlockletPart1"),
|
|
695
|
+
primaryEnd: p("blocklet.noBlockletPart2"),
|
|
688
696
|
filter: g.keyword
|
|
689
697
|
}
|
|
690
698
|
),
|
|
691
699
|
/* @__PURE__ */ t(O, { keywordTip: !0 })
|
|
692
700
|
] });
|
|
693
|
-
if (
|
|
701
|
+
if (d && e.length === 0) {
|
|
694
702
|
const s = k(c);
|
|
695
703
|
return /* @__PURE__ */ h(q, { children: [
|
|
696
704
|
s ? /* @__PURE__ */ t(
|
|
697
705
|
j,
|
|
698
706
|
{
|
|
699
|
-
primaryStart:
|
|
700
|
-
primaryEnd:
|
|
707
|
+
primaryStart: p("blocklet.noCategoryResults1"),
|
|
708
|
+
primaryEnd: p("blocklet.noCategoryResults2"),
|
|
701
709
|
filter: s
|
|
702
710
|
}
|
|
703
711
|
) : /* @__PURE__ */ t(se, {}),
|
|
704
712
|
/* @__PURE__ */ t(O, { filterTip: !0 })
|
|
705
713
|
] });
|
|
706
714
|
}
|
|
707
|
-
return e.length === 0 ? /* @__PURE__ */ t(q, { children: /* @__PURE__ */ t(se, {}) }) : /* @__PURE__ */ h(
|
|
715
|
+
return e.length === 0 ? /* @__PURE__ */ t(q, { children: /* @__PURE__ */ t(se, {}) }) : /* @__PURE__ */ h(Lt, { container: !0, ...n, columns: $, ref: B, children: [
|
|
708
716
|
e.map((s) => /* @__PURE__ */ t(ce, { item: !0, xs: 4, "data-blocklet-did": s.did, children: r({ blocklet: s, blocklets: e }) }, s.did)),
|
|
709
|
-
|
|
717
|
+
y && /* @__PURE__ */ t(ce, { item: !0, xs: 12, ref: u, children: /* @__PURE__ */ t(D, { height: 60, display: "flex", justifyContent: "center", children: /* @__PURE__ */ t(W, {}) }) })
|
|
710
718
|
] });
|
|
711
719
|
}
|
|
712
720
|
Y.propTypes = {
|
|
713
|
-
blocklets:
|
|
721
|
+
blocklets: o.array.isRequired
|
|
714
722
|
};
|
|
715
723
|
Y.defaultProps = {};
|
|
716
|
-
const
|
|
724
|
+
const Lt = C(ue)`
|
|
717
725
|
opacity: ${(e) => e.columns > 0 ? 1 : 0};
|
|
718
726
|
&.MuiGrid-root {
|
|
719
727
|
width: 100%;
|
|
720
728
|
margin: 0 -16px;
|
|
721
729
|
}
|
|
722
|
-
`, ce =
|
|
730
|
+
`, ce = Ke(C(ue)`
|
|
723
731
|
@media (max-width: ${(e) => e.theme.breakpoints.values.sm}px) {
|
|
724
732
|
&.MuiGrid-item {
|
|
725
733
|
padding-bottom: 0px;
|
|
@@ -730,7 +738,7 @@ const At = C(de)`
|
|
|
730
738
|
margin-bottom: ${(e) => e.theme.spacing(2)};
|
|
731
739
|
}
|
|
732
740
|
}
|
|
733
|
-
`), q = C(
|
|
741
|
+
`), q = C(ct)`
|
|
734
742
|
text-align: center;
|
|
735
743
|
.primary {
|
|
736
744
|
color: ${(e) => e.theme.palette.primary.main};
|
|
@@ -740,21 +748,21 @@ const At = C(de)`
|
|
|
740
748
|
}
|
|
741
749
|
`;
|
|
742
750
|
function Z() {
|
|
743
|
-
const { selectedCategory: e, handleCategory:
|
|
744
|
-
return /* @__PURE__ */ h(
|
|
745
|
-
/* @__PURE__ */ t("div", { children: /* @__PURE__ */ t(
|
|
751
|
+
const { selectedCategory: e, handleCategory: n, t: r, handlePrice: l, filters: i, categoryOptions: c, priceOptions: k } = I();
|
|
752
|
+
return /* @__PURE__ */ h(Mt, { children: [
|
|
753
|
+
/* @__PURE__ */ t("div", { children: /* @__PURE__ */ t(A, { title: r("common.price"), options: k, value: i.price, onChange: l }) }),
|
|
746
754
|
c.length > 0 && /* @__PURE__ */ t("div", { style: { marginTop: "16px" }, children: /* @__PURE__ */ t(
|
|
747
|
-
|
|
755
|
+
A,
|
|
748
756
|
{
|
|
749
757
|
title: r("common.category"),
|
|
750
758
|
options: c,
|
|
751
759
|
value: e,
|
|
752
|
-
onChange:
|
|
760
|
+
onChange: n
|
|
753
761
|
}
|
|
754
762
|
) })
|
|
755
763
|
] });
|
|
756
764
|
}
|
|
757
|
-
const
|
|
765
|
+
const Mt = C("aside")`
|
|
758
766
|
width: 220px;
|
|
759
767
|
margin-right: ${(e) => e.theme.spacing(2)};
|
|
760
768
|
height: 100%;
|
|
@@ -765,39 +773,39 @@ const Lt = C("aside")`
|
|
|
765
773
|
`;
|
|
766
774
|
Z.propTypes = {};
|
|
767
775
|
Z.defaultProps = {};
|
|
768
|
-
function ee({ placeholder: e, ...
|
|
769
|
-
const { filters: r, handleKeyword: l } =
|
|
770
|
-
const { value:
|
|
771
|
-
c(
|
|
772
|
-
},
|
|
776
|
+
function ee({ placeholder: e, ...n }) {
|
|
777
|
+
const { filters: r, handleKeyword: l } = I(), [i, c] = F(r.keyword || ""), k = Ze(l, { wait: 300 }), g = (y) => {
|
|
778
|
+
const { value: f } = y.target;
|
|
779
|
+
c(f), k.run(f);
|
|
780
|
+
}, p = () => {
|
|
773
781
|
c(""), l();
|
|
774
782
|
};
|
|
775
783
|
return E(() => {
|
|
776
784
|
c(r.keyword || "");
|
|
777
785
|
}, [r.keyword]), /* @__PURE__ */ t(
|
|
778
|
-
|
|
786
|
+
Ot,
|
|
779
787
|
{
|
|
780
788
|
inputProps: {
|
|
781
789
|
"data-cy": "search-blocklet"
|
|
782
790
|
},
|
|
783
|
-
startAdornment: /* @__PURE__ */ t(le, { position: "start", children: /* @__PURE__ */ t(
|
|
791
|
+
startAdornment: /* @__PURE__ */ t(le, { position: "start", children: /* @__PURE__ */ t(Ft, {}) }),
|
|
784
792
|
onChange: g,
|
|
785
793
|
placeholder: e,
|
|
786
794
|
value: i,
|
|
787
795
|
title: e,
|
|
788
796
|
"data-cy": "search",
|
|
789
|
-
endAdornment: i && /* @__PURE__ */ t(le, { position: "end", children: /* @__PURE__ */ t(
|
|
790
|
-
...
|
|
797
|
+
endAdornment: i && /* @__PURE__ */ t(le, { position: "end", children: /* @__PURE__ */ t(Et, { "data-cy": "search-delete", onClick: p }) }),
|
|
798
|
+
...n
|
|
791
799
|
}
|
|
792
800
|
);
|
|
793
801
|
}
|
|
794
802
|
ee.propTypes = {
|
|
795
|
-
placeholder:
|
|
803
|
+
placeholder: o.string
|
|
796
804
|
};
|
|
797
805
|
ee.defaultProps = {
|
|
798
806
|
placeholder: "Type to search..."
|
|
799
807
|
};
|
|
800
|
-
const
|
|
808
|
+
const Ot = C(Fe)`
|
|
801
809
|
background-color: ${(e) => e.theme.palette.grey[50]};
|
|
802
810
|
font-size: 14px;
|
|
803
811
|
border-radius: 6px;
|
|
@@ -813,49 +821,49 @@ const Mt = C(Oe)`
|
|
|
813
821
|
color: transparent;
|
|
814
822
|
}
|
|
815
823
|
}
|
|
816
|
-
`,
|
|
824
|
+
`, Ft = C(dt)`
|
|
817
825
|
color: ${(e) => e.theme.palette.grey[500]};
|
|
818
826
|
font-size: 28px;
|
|
819
827
|
@media (max-width: ${(e) => e.theme.breakpoints.values.md}px) {
|
|
820
828
|
font-size: 24px;
|
|
821
829
|
}
|
|
822
|
-
`,
|
|
830
|
+
`, Et = C(mt)`
|
|
823
831
|
color: ${(e) => e.theme.palette.grey[500]};
|
|
824
832
|
font-size: 16px;
|
|
825
833
|
cursor: pointer;
|
|
826
834
|
`;
|
|
827
|
-
function te({ onSelect: e, wrapChildren:
|
|
828
|
-
const r =
|
|
829
|
-
const { data: s } = await c.get(
|
|
830
|
-
return
|
|
831
|
-
}, B = (
|
|
832
|
-
|
|
833
|
-
},
|
|
835
|
+
function te({ onSelect: e, wrapChildren: n }) {
|
|
836
|
+
const r = M(null), l = M(null), i = M(null), { storeApi: c, blockletRender: k, filters: g, endpoint: p, handleKeyword: y, t: f } = I(), P = async (u) => {
|
|
837
|
+
const { data: s } = await c.get(R.blockletsPath, { params: u }), S = s.dataList || [];
|
|
838
|
+
return S.length > 0 && S.unshift({ type: "more-result", total: s.total || 0 }), S;
|
|
839
|
+
}, B = (u) => {
|
|
840
|
+
y(u.state.query), u.setIsOpen(!1);
|
|
841
|
+
}, b = () => {
|
|
834
842
|
r.current && setTimeout(() => {
|
|
835
|
-
const
|
|
836
|
-
|
|
843
|
+
const u = r.current.querySelector("input.bl-autocomplete-input");
|
|
844
|
+
u && u.focus();
|
|
837
845
|
});
|
|
838
|
-
},
|
|
839
|
-
|
|
840
|
-
},
|
|
841
|
-
|
|
846
|
+
}, $ = (u) => {
|
|
847
|
+
u.setIsOpen(!1), b();
|
|
848
|
+
}, d = ({ prevState: u, state: s }) => {
|
|
849
|
+
u.query !== s.query && (s.query || y());
|
|
842
850
|
};
|
|
843
|
-
return
|
|
851
|
+
return gt(
|
|
844
852
|
"ctrl + k, command + k",
|
|
845
|
-
(
|
|
853
|
+
(u) => (u.stopPropagation(), u.preventDefault(), b(), !1),
|
|
846
854
|
{ enableOnTags: ["INPUT"] }
|
|
847
855
|
), E(() => {
|
|
848
|
-
|
|
849
|
-
}, [
|
|
856
|
+
b();
|
|
857
|
+
}, [p]), E(() => {
|
|
850
858
|
if (!r.current)
|
|
851
859
|
return;
|
|
852
|
-
const
|
|
860
|
+
const u = ht({
|
|
853
861
|
container: r.current,
|
|
854
|
-
renderer: { createElement:
|
|
862
|
+
renderer: { createElement: We, Fragment: He, render: () => {
|
|
855
863
|
} },
|
|
856
|
-
render({ children: s },
|
|
857
|
-
var
|
|
858
|
-
(!l.current || i.current !==
|
|
864
|
+
render({ children: s }, S) {
|
|
865
|
+
var x;
|
|
866
|
+
(!l.current || i.current !== S) && (i.current = S, (x = l.current) == null || x.unmount(), l.current = ft(S)), l.current.render(n(s));
|
|
859
867
|
},
|
|
860
868
|
autoFocus: !0,
|
|
861
869
|
openOnFocus: !1,
|
|
@@ -866,49 +874,49 @@ function te({ onSelect: e, wrapChildren: o }) {
|
|
|
866
874
|
input: "bl-autocomplete-input",
|
|
867
875
|
clearButton: "bl-autocomplete-clear"
|
|
868
876
|
},
|
|
869
|
-
placeholder:
|
|
877
|
+
placeholder: f("common.searchStore"),
|
|
870
878
|
initialState: {
|
|
871
879
|
query: g.keyword
|
|
872
880
|
},
|
|
873
881
|
onStateChange(s) {
|
|
874
|
-
|
|
882
|
+
d(s);
|
|
875
883
|
},
|
|
876
884
|
onSubmit: B,
|
|
877
885
|
onReset(s) {
|
|
878
|
-
|
|
886
|
+
$(s);
|
|
879
887
|
},
|
|
880
|
-
getSources({ query: s, state:
|
|
881
|
-
const
|
|
888
|
+
getSources({ query: s, state: S, ...x }) {
|
|
889
|
+
const T = {
|
|
882
890
|
...g,
|
|
883
|
-
sortBy:
|
|
891
|
+
sortBy: R[g.sortBy],
|
|
884
892
|
page: 1,
|
|
885
893
|
pageSize: 10,
|
|
886
894
|
keyword: s
|
|
887
895
|
};
|
|
888
|
-
return
|
|
896
|
+
return Tt([
|
|
889
897
|
{
|
|
890
898
|
sourceId: "blocklets",
|
|
891
899
|
getItems() {
|
|
892
|
-
return P(
|
|
900
|
+
return P(T);
|
|
893
901
|
},
|
|
894
902
|
// 选中后填充 搜索框中值
|
|
895
|
-
getItemInputValue({ item:
|
|
896
|
-
return
|
|
903
|
+
getItemInputValue({ item: w }) {
|
|
904
|
+
return w.type === "more-result" ? s : w.title;
|
|
897
905
|
},
|
|
898
906
|
// 选中或者点击自动完成列表中的 item 时触发
|
|
899
|
-
onSelect({ event:
|
|
900
|
-
return
|
|
901
|
-
blocklet:
|
|
902
|
-
detailUrl:
|
|
903
|
-
storeUrl:
|
|
907
|
+
onSelect({ event: w, item: _ }) {
|
|
908
|
+
return _.type === "more-result" ? (x.setIsOpen(!1), y(s)) : w.type === "keydown" ? y(_.title) : e({
|
|
909
|
+
blocklet: _,
|
|
910
|
+
detailUrl: yt(p, `/blocklets/${_.did}`),
|
|
911
|
+
storeUrl: p
|
|
904
912
|
});
|
|
905
913
|
},
|
|
906
914
|
templates: {
|
|
907
|
-
item({ item:
|
|
908
|
-
return
|
|
915
|
+
item({ item: w }) {
|
|
916
|
+
return w.type === "more-result" ? /* @__PURE__ */ t("div", { children: f("autocomplete.expandResult", { name: s, number: w.total.toLocaleString() }) }) : k({ blocklet: w, autocompleteSetters: x });
|
|
909
917
|
},
|
|
910
918
|
noResults() {
|
|
911
|
-
return
|
|
919
|
+
return f("blocklet.noResults");
|
|
912
920
|
}
|
|
913
921
|
}
|
|
914
922
|
}
|
|
@@ -916,92 +924,93 @@ function te({ onSelect: e, wrapChildren: o }) {
|
|
|
916
924
|
}
|
|
917
925
|
});
|
|
918
926
|
return () => {
|
|
919
|
-
|
|
927
|
+
u.destroy();
|
|
920
928
|
};
|
|
921
929
|
}, [g, k]), /* @__PURE__ */ t("div", { className: "bl-search-container", ref: r });
|
|
922
930
|
}
|
|
923
931
|
te.propTypes = {
|
|
924
|
-
onSelect:
|
|
925
|
-
wrapChildren:
|
|
932
|
+
onSelect: o.func.isRequired,
|
|
933
|
+
wrapChildren: o.func
|
|
926
934
|
};
|
|
927
935
|
te.defaultProps = {
|
|
928
936
|
wrapChildren: (e) => e
|
|
929
937
|
};
|
|
930
|
-
function
|
|
931
|
-
var
|
|
938
|
+
function qt() {
|
|
939
|
+
var S, x;
|
|
932
940
|
const {
|
|
933
941
|
handleDeveloper: e,
|
|
934
|
-
blockletList:
|
|
942
|
+
blockletList: n,
|
|
935
943
|
filters: r,
|
|
936
944
|
developerName: l,
|
|
937
945
|
handleSort: i,
|
|
938
946
|
handleCategory: c,
|
|
939
947
|
handlePrice: k,
|
|
940
948
|
handleSearchSelect: g,
|
|
941
|
-
t:
|
|
942
|
-
getCategoryLocale:
|
|
943
|
-
priceOptions:
|
|
949
|
+
t: p,
|
|
950
|
+
getCategoryLocale: y,
|
|
951
|
+
priceOptions: f,
|
|
944
952
|
wrapChildren: P,
|
|
945
953
|
baseSearch: B
|
|
946
|
-
} =
|
|
947
|
-
return /* @__PURE__ */ h(
|
|
954
|
+
} = I(), b = bt(p), $ = ((S = b.find((T) => T.value === r.sortBy)) == null ? void 0 : S.name) || p("sort.sort"), d = y(r.category), { resourceType: u } = r || {}, s = (x = f.find((T) => T.value === r.price)) == null ? void 0 : x.name;
|
|
955
|
+
return /* @__PURE__ */ h(D, { display: "flex", alignItems: "flex-start", height: "100%", children: [
|
|
948
956
|
/* @__PURE__ */ t(ae, { mdDown: !0, children: /* @__PURE__ */ t(Z, {}) }),
|
|
949
|
-
/* @__PURE__ */ h(
|
|
950
|
-
/* @__PURE__ */ h(
|
|
951
|
-
/* @__PURE__ */ h(
|
|
952
|
-
B ? /* @__PURE__ */ t(ee, { className: "bl-search-container", placeholder:
|
|
953
|
-
/* @__PURE__ */ h(
|
|
957
|
+
/* @__PURE__ */ h(jt, { children: [
|
|
958
|
+
/* @__PURE__ */ h(Gt, { children: [
|
|
959
|
+
/* @__PURE__ */ h(D, { className: "filter-bar", display: "flex", alignItems: "center", children: [
|
|
960
|
+
B ? /* @__PURE__ */ t(ee, { className: "bl-search-container", placeholder: p("common.searchStore") }) : /* @__PURE__ */ t(te, { onSelect: g, wrapChildren: P }),
|
|
961
|
+
/* @__PURE__ */ h(D, { mt: 0, ml: "16px", className: "filter-container", children: [
|
|
954
962
|
/* @__PURE__ */ t(ae, { mdUp: !0, children: /* @__PURE__ */ t(X, {}) }),
|
|
955
963
|
/* @__PURE__ */ t(
|
|
956
964
|
J,
|
|
957
965
|
{
|
|
958
966
|
value: r.sortBy,
|
|
959
|
-
options:
|
|
960
|
-
title:
|
|
967
|
+
options: b,
|
|
968
|
+
title: $,
|
|
961
969
|
icon: /* @__PURE__ */ t($e, {}),
|
|
962
|
-
onChange: (
|
|
963
|
-
i(
|
|
970
|
+
onChange: (T) => {
|
|
971
|
+
i(T);
|
|
964
972
|
}
|
|
965
973
|
}
|
|
966
974
|
)
|
|
967
975
|
] })
|
|
968
976
|
] }),
|
|
969
|
-
/* @__PURE__ */ h(
|
|
977
|
+
/* @__PURE__ */ h(D, { display: "flex", flexWrap: "wrap", alignItems: "center", mb: "16px", children: [
|
|
970
978
|
/* @__PURE__ */ t(
|
|
971
|
-
|
|
979
|
+
N,
|
|
972
980
|
{
|
|
973
981
|
label: l,
|
|
974
|
-
icon: /* @__PURE__ */ t(
|
|
982
|
+
icon: /* @__PURE__ */ t(Ee, {}),
|
|
975
983
|
onDelete: () => {
|
|
976
984
|
e(null);
|
|
977
985
|
}
|
|
978
986
|
}
|
|
979
987
|
),
|
|
980
988
|
/* @__PURE__ */ t(
|
|
981
|
-
|
|
989
|
+
N,
|
|
982
990
|
{
|
|
983
|
-
label:
|
|
991
|
+
label: d,
|
|
984
992
|
onDelete: () => {
|
|
985
993
|
c(null);
|
|
986
994
|
}
|
|
987
995
|
}
|
|
988
996
|
),
|
|
989
997
|
/* @__PURE__ */ t(
|
|
990
|
-
|
|
998
|
+
N,
|
|
991
999
|
{
|
|
992
|
-
label:
|
|
1000
|
+
label: s,
|
|
993
1001
|
onDelete: () => {
|
|
994
1002
|
k(null);
|
|
995
1003
|
}
|
|
996
1004
|
}
|
|
997
|
-
)
|
|
1005
|
+
),
|
|
1006
|
+
u && /* @__PURE__ */ t(N, { label: `${p("common.resourceType")}: ${u}` })
|
|
998
1007
|
] })
|
|
999
1008
|
] }),
|
|
1000
|
-
/* @__PURE__ */ t(
|
|
1009
|
+
/* @__PURE__ */ t(qe, { FallbackComponent: de, children: /* @__PURE__ */ t("div", { style: { position: "relative", flex: 1, overflow: "auto" }, children: /* @__PURE__ */ t(Y, { blocklets: n }) }) })
|
|
1001
1010
|
] })
|
|
1002
1011
|
] });
|
|
1003
1012
|
}
|
|
1004
|
-
const
|
|
1013
|
+
const jt = C("main")`
|
|
1005
1014
|
display: flex;
|
|
1006
1015
|
flex-direction: column;
|
|
1007
1016
|
flex: 1;
|
|
@@ -1045,29 +1054,29 @@ const qt = C("main")`
|
|
|
1045
1054
|
font-size: 12px;
|
|
1046
1055
|
}
|
|
1047
1056
|
}
|
|
1048
|
-
`,
|
|
1057
|
+
`, Gt = C("div")`
|
|
1049
1058
|
position: sticky;
|
|
1050
1059
|
top: 0;
|
|
1051
1060
|
z-index: 9;
|
|
1052
1061
|
background-color: white;
|
|
1053
1062
|
`;
|
|
1054
1063
|
function ye(e) {
|
|
1055
|
-
const
|
|
1056
|
-
autocomplete:
|
|
1064
|
+
const n = pe(), r = Ct(n.palette.primary.main), l = {
|
|
1065
|
+
autocomplete: Te`
|
|
1057
1066
|
:root {
|
|
1058
|
-
--aa-detached-media-query: (max-width: ${
|
|
1059
|
-
--aa-detached-modal-media-query: (min-width: ${
|
|
1060
|
-
--aa-detached-modal-max-width: ${
|
|
1067
|
+
--aa-detached-media-query: (max-width: ${n.breakpoints.values.md}px) !important;
|
|
1068
|
+
--aa-detached-modal-media-query: (min-width: ${n.breakpoints.values.md}px) !important;
|
|
1069
|
+
--aa-detached-modal-max-width: ${n.breakpoints.values.md}px !important;
|
|
1061
1070
|
--aa-selected-color-rgb: ${r.r}, ${r.g}, ${r.b} !important;
|
|
1062
1071
|
--aa-primary-color-rgb: ${r.r}, ${r.g}, ${r.b} !important;
|
|
1063
1072
|
--aa-input-background-color-rgb: 250, 250, 250 !important;
|
|
1064
1073
|
}
|
|
1065
1074
|
.bl-autocomplete-panel {
|
|
1066
|
-
z-index: ${
|
|
1075
|
+
z-index: ${n.zIndex.modal};
|
|
1067
1076
|
}
|
|
1068
1077
|
.bl-autocomplete-label {
|
|
1069
1078
|
.aa-SubmitIcon {
|
|
1070
|
-
color: ${
|
|
1079
|
+
color: ${n.palette.grey[500]} !important;
|
|
1071
1080
|
}
|
|
1072
1081
|
}
|
|
1073
1082
|
.bl-autocomplete-form {
|
|
@@ -1083,7 +1092,7 @@ function ye(e) {
|
|
|
1083
1092
|
box-shadow: none !important;
|
|
1084
1093
|
}
|
|
1085
1094
|
.aa-SubmitIcon {
|
|
1086
|
-
color: ${
|
|
1095
|
+
color: ${n.palette.grey[500]} !important;
|
|
1087
1096
|
}
|
|
1088
1097
|
}
|
|
1089
1098
|
.aa-Panel .arcblock-blocklet button {
|
|
@@ -1093,7 +1102,7 @@ function ye(e) {
|
|
|
1093
1102
|
};
|
|
1094
1103
|
return /* @__PURE__ */ h(V, { ...e, children: [
|
|
1095
1104
|
/* @__PURE__ */ t(Be, { styles: l.autocomplete }),
|
|
1096
|
-
/* @__PURE__ */ t(
|
|
1105
|
+
/* @__PURE__ */ t(qt, {})
|
|
1097
1106
|
] });
|
|
1098
1107
|
}
|
|
1099
1108
|
ye.propTypes = fe;
|