@blocklet/list 0.12.87 → 0.12.89

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