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