@blocklet/list 0.13.39 → 0.13.40

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.
Files changed (2) hide show
  1. package/lib/index.es.js +495 -455
  2. package/package.json +3 -3
package/lib/index.es.js CHANGED
@@ -1,56 +1,56 @@
1
- import { jsx as t, jsxs as p, Fragment as F } from "react/jsx-runtime";
1
+ import { jsx as t, jsxs as m, Fragment as F } from "react/jsx-runtime";
2
2
  import { styled as D, useTheme as be } from "@arcblock/ux/lib/Theme";
3
3
  import { Global as xe, css as we } from "@emotion/react";
4
- import { ErrorFallback as K } from "@arcblock/ux/lib/ErrorBoundary";
5
- import { Button as Z, useTheme as Ge, useMediaQuery as N, Drawer as Qe, Box as S, Stack as P, FormControlLabel as ke, Checkbox as ve, Typography as T, CircularProgress as ee, Link as Xe, Grid as pe, MenuList as Ye, SvgIcon as Je, Popper as Ke, Grow as Ze, Paper as et, ClickAwayListener as tt, MenuItem as rt, OutlinedInput as ot, InputAdornment as me } from "@mui/material";
6
- import { ErrorBoundary as nt } from "react-error-boundary";
7
- import lt from "@iconify-icons/tabler/compass";
4
+ import { ErrorFallback as Z } from "@arcblock/ux/lib/ErrorBoundary";
5
+ import { Button as ee, useTheme as Qe, useMediaQuery as N, Drawer as Xe, Box as S, CircularProgress as te, MenuList as Ye, SvgIcon as Je, Popper as Ke, Grow as Ze, Paper as et, ClickAwayListener as tt, MenuItem as rt, Stack as T, FormControlLabel as ke, Checkbox as ve, Typography as I, Link as ot, Grid as pe, OutlinedInput as nt, InputAdornment as me } from "@mui/material";
6
+ import { ErrorBoundary as lt } from "react-error-boundary";
7
+ import at from "@iconify-icons/tabler/compass";
8
8
  import { Icon as Ce } from "@iconify/react";
9
9
  import Se from "@mui/icons-material/Close";
10
- import { createContext as Be, useState as q, useMemo as E, useContext as Re, useCallback as J, useEffect as j, memo as at, forwardRef as it, useRef as U, createElement as st, Fragment as ct } from "react";
10
+ import { createContext as Be, useState as q, useMemo as E, useContext as Re, useCallback as K, useEffect as j, forwardRef as it, useRef as U, memo as st, createElement as ct, Fragment as dt } from "react";
11
11
  import Pe from "axios";
12
- import dt from "lodash/orderBy";
12
+ import ut from "lodash/orderBy";
13
13
  import i from "prop-types";
14
- import { useInfiniteScroll as ut, useRequest as te, useReactive as pt, useDebounceFn as mt } from "ahooks";
15
- import ht from "lodash/omitBy";
16
- import ft from "json-stable-stringify";
14
+ import { useInfiniteScroll as pt, useRequest as re, useReactive as mt, useDebounceFn as ht } from "ahooks";
15
+ import ft from "lodash/omitBy";
16
+ import gt from "json-stable-stringify";
17
17
  import "lodash/cloneDeep";
18
- import gt from "color";
18
+ import yt from "color";
19
19
  import he from "flat";
20
+ import bt from "@mui/icons-material/KeyboardArrowDown";
21
+ import xt from "lodash/isEmpty";
20
22
  import Te from "@mui/material/Box";
21
- import yt from "@arcblock/ux/lib/Avatar";
22
- import bt from "@iconify-icons/tabler/cloud-download";
23
- import xt from "@mui/icons-material/ChevronLeft";
24
- import wt from "@mui/icons-material/ChevronRight";
25
- import kt from "react-image-gallery";
23
+ import wt from "@arcblock/ux/lib/Avatar";
24
+ import kt from "@iconify-icons/tabler/cloud-download";
25
+ import vt from "@mui/icons-material/ChevronLeft";
26
+ import Ct from "@mui/icons-material/ChevronRight";
27
+ import St from "react-image-gallery";
26
28
  import "react-image-gallery/styles/css/image-gallery.css";
27
- import vt from "@mui/icons-material/KeyboardArrowDown";
28
- import Ct from "lodash/isEmpty";
29
- import St from "@arcblock/ux/lib/Empty";
30
- import Bt from "react-infinite-scroll-hook";
29
+ import Bt from "@arcblock/ux/lib/Empty";
30
+ import Rt from "react-infinite-scroll-hook";
31
31
  import Ie from "@mui/material/Typography";
32
- import Rt from "@mui/icons-material/Menu";
33
- import { createRoot as Pt } from "react-dom/client";
34
- import { autocomplete as Tt } from "@algolia/autocomplete-js";
35
- import { useHotkeys as It } from "react-hotkeys-hook";
36
- import { joinURL as Lt } from "ufo";
37
- import zt from "@mui/icons-material/Search";
32
+ import Pt from "@mui/icons-material/Menu";
33
+ import { createRoot as Tt } from "react-dom/client";
34
+ import { autocomplete as It } from "@algolia/autocomplete-js";
35
+ import { useHotkeys as Lt } from "react-hotkeys-hook";
36
+ import { joinURL as zt } from "ufo";
37
+ import $t from "@mui/icons-material/Search";
38
38
  import "@algolia/autocomplete-theme-classic/dist/theme.css";
39
39
  const Le = Be({
40
40
  open: !1,
41
41
  toggleOpen: (e) => {
42
42
  }
43
43
  });
44
- function $t({ children: e }) {
44
+ function _t({ children: e }) {
45
45
  const [r, o] = q(!1), n = (l) => {
46
46
  o(l ?? !l);
47
47
  }, a = E(() => ({ open: r, toggleOpen: n }), [r]);
48
48
  return /* @__PURE__ */ t(Le.Provider, { value: a, children: e });
49
49
  }
50
- function re() {
50
+ function oe() {
51
51
  return Re(Le);
52
52
  }
53
- const R = {
53
+ const P = {
54
54
  nameAsc: "title",
55
55
  nameDesc: "title",
56
56
  popularity: "stats.downloads",
@@ -64,22 +64,28 @@ const R = {
64
64
  explorePath: "/api/blocklets/explore",
65
65
  exploreDidsPath: "/api/blocklets/dids",
66
66
  cacheSize: 100
67
- }, _t = (e, r, o, n) => ut(
67
+ }, At = (e, r, o, n) => pt(
68
68
  async (a) => {
69
69
  a || (o.currentPage = o.defaultCurrentPage);
70
- const { currentPage: l, pageSize: m } = o, d = { ...r, sortBy: R[r.sortBy], page: l, pageSize: m };
70
+ const { currentPage: l, pageSize: c } = o, d = {
71
+ ...r,
72
+ category: r.category === "All" ? "" : r.category,
73
+ sortBy: P[r.sortBy],
74
+ page: l,
75
+ pageSize: c
76
+ };
71
77
  n(null);
72
- const { data: s = {} } = await e.get(R.blockletsPath, { params: d });
73
- return o.currentPage++, { page: l, pageSize: m, list: (s == null ? void 0 : s.dataList) || [], total: (s == null ? void 0 : s.total) || 0 };
78
+ const { data: s = {} } = await e.get(P.blockletsPath, { params: d });
79
+ return o.currentPage++, { page: l, pageSize: c, list: (s == null ? void 0 : s.dataList) || [], total: (s == null ? void 0 : s.total) || 0 };
74
80
  },
75
81
  {
76
82
  isNoMore: (a) => a ? a.page * a.pageSize >= a.total : !1,
77
- reloadDeps: [e, ft(r)],
83
+ reloadDeps: [e, gt(r)],
78
84
  onError: n
79
85
  }
80
- ), Ft = (e) => te(
86
+ ), Ft = (e) => re(
81
87
  async () => {
82
- const { data: r } = await e.get(R.categoriesPath);
88
+ const { data: r } = await e.get(P.categoriesPath);
83
89
  return Array.isArray(r) ? r : [];
84
90
  },
85
91
  { manual: !0 }
@@ -123,7 +129,7 @@ const R = {
123
129
  showResourcesSwitch: !1,
124
130
  showCategory: !0,
125
131
  tagFilters: []
126
- }, At = (e) => [
132
+ }, _e = (e) => [
127
133
  {
128
134
  name: e("sort.popularity"),
129
135
  value: "popularity"
@@ -142,7 +148,7 @@ const R = {
142
148
  ], Et = (e = [], r = "en") => e.map((o) => ({ name: o.locales[r] || o.locales.en, value: o._id })), Mt = (e, r) => (
143
149
  // eslint-disable-next-line no-prototype-builtins
144
150
  e == null ? void 0 : e.replace(/{(\w*)}/g, (o, n) => r.hasOwnProperty(n) ? r[n] : "")
145
- ), Nt = () => window.innerWidth <= 600, Ot = (e) => gt(e).rgb().object();
151
+ ), Nt = () => window.innerWidth <= 600, Ot = (e) => yt(e).rgb().object();
146
152
  function qt(e, r) {
147
153
  let o;
148
154
  return function(...a) {
@@ -247,14 +253,14 @@ const jt = qt((e) => Promise.resolve(e), 300), Vt = {
247
253
  autocomplete: {
248
254
  expandResult: "查看 “{name}” 的所有搜索结果"
249
255
  }
250
- }, Y = {
256
+ }, J = {
251
257
  en: he(Vt),
252
258
  zh: he(Wt)
253
- }, _e = (e, r) => {
259
+ }, Ae = (e, r) => {
254
260
  const o = {};
255
261
  return e && (o["x-blocklet-server-version"] = e), r && (o["x-blocklet-store-version"] = r), o;
256
262
  }, Ut = (e) => (r, o) => {
257
- const n = Y[e] ? Y[e][r] : Y.en[r];
263
+ const n = J[e] ? J[e][r] : J.en[r];
258
264
  return Mt(n, o) || r;
259
265
  }, Fe = {
260
266
  errors: {
@@ -309,132 +315,135 @@ const jt = qt((e) => Promise.resolve(e), 300), Vt = {
309
315
  developerName: "",
310
316
  handleSearchSelect: () => {
311
317
  }
312
- }, Ae = Be(Fe), { Provider: Ht, Consumer: Hr } = Ae;
313
- function oe({
318
+ }, De = Be(Fe), { Provider: Ht, Consumer: Hr } = De;
319
+ function ne({
314
320
  filters: e,
315
321
  children: r,
316
322
  endpoint: o,
317
323
  locale: n,
318
324
  blockletRender: a,
319
325
  onFilterChange: l,
320
- onSearchSelect: m,
326
+ onSearchSelect: c,
321
327
  extraFilter: d,
322
328
  wrapChildren: s,
323
- baseSearch: k,
329
+ baseSearch: v,
324
330
  serverVersion: f,
325
- storeVersion: g,
326
- fetchCategoryDelay: c,
327
- showResourcesSwitch: x,
328
- showCategory: w,
329
- tagFilters: v
331
+ storeVersion: y,
332
+ fetchCategoryDelay: u,
333
+ showResourcesSwitch: w,
334
+ showCategory: k,
335
+ tagFilters: x
330
336
  }) {
331
- const z = _e(f, g), y = E(() => Pe.create({ baseURL: o, headers: z }), [o]), u = { sortBy: "popularity", sortDirection: "desc", ...e }, C = u.category, $ = pt({
332
- currentPage: R.currentPage,
333
- pageSize: Nt() ? R.mobilePageSize : R.pageSize,
334
- defaultCurrentPage: R.defaultCurrentPage
335
- }), [_, L] = q(null), I = _t(y, u, $, L), {
336
- data: Q = [],
337
- error: je,
338
- loading: Ve,
337
+ const $ = Ae(f, y), b = E(() => Pe.create({ baseURL: o, headers: $ }), [o]), h = { sortBy: "popularity", sortDirection: "desc", ...e }, C = h.category, _ = mt({
338
+ currentPage: P.currentPage,
339
+ pageSize: Nt() ? P.mobilePageSize : P.pageSize,
340
+ defaultCurrentPage: P.defaultCurrentPage
341
+ }), [A, z] = q(null), L = At(b, h, _, z), {
342
+ data: X = [],
343
+ error: Ve,
344
+ loading: We,
339
345
  run: se
340
- } = Ft(y), X = E(() => dt(Q, [(h) => h.name], ["asc"]), [Q]), ce = E(() => {
341
- var h;
342
- return d(((h = I.data) == null ? void 0 : h.list) || []);
343
- }, [I.data, d]), de = J(Ut(n), [n]), We = E(() => Et(X, n), [X, n]), Ue = Dt(de), He = {
344
- errors: { fetchBlockletsError: _, fetchCategoriesError: je },
346
+ } = Ft(b), Y = E(() => {
347
+ const p = ut(X, [(R) => R.name], ["asc"]), g = p.findIndex((R) => R.name === "All" || R.locales.en === "All");
348
+ return g > -1 ? [{ ...p[g], _id: "All" }, ...p.slice(0, g), ...p.slice(g + 1)] : p;
349
+ }, [X]), ce = E(() => {
350
+ var p;
351
+ return d(((p = L.data) == null ? void 0 : p.list) || []);
352
+ }, [L.data, d]), de = K(Ut(n), [n]), Ue = E(() => Et(Y, n), [Y, n]), He = Dt(de), Ge = {
353
+ errors: { fetchBlockletsError: A, fetchCategoriesError: Ve },
345
354
  loadings: {
346
- fetchBlockletsLoading: I.loading,
347
- fetchCategoriesLoading: Ve,
348
- loadingMore: I.loadingMore
355
+ fetchBlockletsLoading: L.loading,
356
+ fetchCategoriesLoading: We,
357
+ loadingMore: L.loadingMore
349
358
  },
350
359
  endpoint: o,
351
360
  blockletList: ce,
352
361
  wrapChildren: s,
353
362
  t: de,
354
- storeVersion: g,
363
+ storeVersion: y,
355
364
  serverVersion: f,
356
- filters: u,
365
+ filters: h,
357
366
  selectedCategory: C,
358
- categoryList: X,
367
+ categoryList: Y,
359
368
  blockletRender: a,
360
369
  locale: n,
361
- categoryOptions: We,
362
- priceOptions: Ue,
363
- storeApi: y,
364
- baseSearch: k,
365
- showResourcesSwitch: x,
366
- showCategory: w,
367
- tagFilters: v,
368
- hasNextPage: !I.noMore,
370
+ categoryOptions: Ue,
371
+ priceOptions: He,
372
+ storeApi: b,
373
+ baseSearch: v,
374
+ showResourcesSwitch: w,
375
+ showCategory: k,
376
+ tagFilters: x,
377
+ hasNextPage: !L.noMore,
369
378
  onFilterChange: l,
370
- cleanFilter: (h) => {
371
- const b = h ? ht(u, (A, M) => h == null ? void 0 : h.includes(M)) : {};
372
- l(b);
379
+ cleanFilter: (p) => {
380
+ const g = p ? ft(h, (R, M) => p == null ? void 0 : p.includes(M)) : {};
381
+ l(g);
373
382
  },
374
- handleSort: (h) => {
375
- const b = { ...u, sortBy: h, sortDirection: h === "nameAsc" ? "asc" : "desc" };
376
- l(b);
383
+ handleSort: (p) => {
384
+ const g = { ...h, sortBy: p, sortDirection: p === "nameAsc" ? "asc" : "desc" };
385
+ l(g);
377
386
  },
378
- handleKeyword: (h) => {
379
- const b = { ...u, keyword: h || void 0 };
380
- l(b);
387
+ handleKeyword: (p) => {
388
+ const g = { ...h, category: void 0, keyword: p || void 0 };
389
+ l(g);
381
390
  },
382
- handlePrice: (h) => {
383
- const b = { ...u, price: h === u.price ? void 0 : h };
384
- l(b);
391
+ handlePrice: (p) => {
392
+ const g = { ...h, price: p === h.price ? void 0 : p };
393
+ l(g);
385
394
  },
386
- handleCategory: (h) => {
387
- const b = h === "all" || h === u.category ? "" : h, A = { ...u, category: b };
388
- l(A);
395
+ handleCategory: (p) => {
396
+ const g = p === "all" || p === h.category ? "" : p, R = { ...h, category: g };
397
+ l(R);
389
398
  },
390
- handleDeveloper: (h) => {
391
- const b = { ...u, owner: h || void 0 };
392
- l(b);
399
+ handleDeveloper: (p) => {
400
+ const g = { ...h, owner: p || void 0 };
401
+ l(g);
393
402
  },
394
- handlePage: (h) => {
395
- const b = { ...u, currentPage: h };
396
- l(b);
403
+ handlePage: (p) => {
404
+ const g = { ...h, currentPage: p };
405
+ l(g);
397
406
  },
398
407
  handleSwitchShowResources: () => {
399
- const h = { ...u };
400
- l(h);
408
+ const p = { ...h };
409
+ l(p);
401
410
  },
402
- loadMore: I.loadMore,
403
- getCategoryLocale: (h) => {
404
- if (!h)
411
+ loadMore: L.loadMore,
412
+ getCategoryLocale: (p) => {
413
+ if (!p)
405
414
  return null;
406
- const b = Q.find((A) => A._id === h);
407
- return b ? b.locales[n] || b.locales.en : null;
415
+ const g = X.find((R) => R._id === p);
416
+ return g ? g.locales[n] || g.locales.en : null;
408
417
  },
409
418
  get developerName() {
410
- var b, A;
411
- return ((A = (b = ce.find((M) => {
419
+ var g, R;
420
+ return ((R = (g = ce.find((M) => {
412
421
  var ue;
413
- return ((ue = M == null ? void 0 : M.owner) == null ? void 0 : ue.did) === u.owner;
414
- })) == null ? void 0 : b.owner) == null ? void 0 : A.name) || "";
422
+ return ((ue = M == null ? void 0 : M.owner) == null ? void 0 : ue.did) === h.owner;
423
+ })) == null ? void 0 : g.owner) == null ? void 0 : R.name) || "";
415
424
  },
416
- handleSearchSelect: m
425
+ handleSearchSelect: c
417
426
  };
418
427
  return j(() => {
419
- setTimeout(se, c || 0);
420
- }, [o, se, c]), /* @__PURE__ */ t(Ht, { value: He, children: r });
428
+ setTimeout(se, u || 0);
429
+ }, [o, se, u]), /* @__PURE__ */ t(Ht, { value: Ge, children: r });
421
430
  }
422
- oe.propTypes = {
431
+ ne.propTypes = {
423
432
  ...ze,
424
433
  children: i.any.isRequired
425
434
  };
426
- oe.defaultProps = $e;
435
+ ne.defaultProps = $e;
427
436
  function B() {
428
- const e = Re(Ae);
437
+ const e = Re(De);
429
438
  return e || Fe;
430
439
  }
431
- function De({
440
+ function Ee({
432
441
  children: e,
433
442
  onClick: r,
434
443
  size: o = 32
435
444
  }) {
436
445
  return /* @__PURE__ */ t(
437
- Z,
446
+ ee,
438
447
  {
439
448
  onClick: r,
440
449
  variant: "outlined",
@@ -464,48 +473,214 @@ function G({
464
473
  xl: a,
465
474
  exact: l
466
475
  }) {
467
- const m = Ge(), d = N(m.breakpoints.down("sm")), s = N(m.breakpoints.between("sm", "md")), k = N(m.breakpoints.between("md", "lg")), f = N(m.breakpoints.between("lg", "xl"));
476
+ const c = Qe(), d = N(c.breakpoints.down("sm")), s = N(c.breakpoints.between("sm", "md")), v = N(c.breakpoints.between("md", "lg")), f = N(c.breakpoints.between("lg", "xl"));
468
477
  if (l)
469
- return d ? e || null : s ? r || null : k ? o || null : f ? n || null : a || null;
470
- let g = e;
471
- return d || (g = V(r, g), s) || (g = V(o, g), k) || (g = V(n, g), f) ? g : V(a, g);
478
+ return d ? e || null : s ? r || null : v ? o || null : f ? n || null : a || null;
479
+ let y = e;
480
+ return d || (y = V(r, y), s) || (y = V(o, y), v) || (y = V(n, y), f) ? y : V(a, y);
472
481
  }
473
482
  function Gt({ children: e }) {
474
- const { open: r, toggleOpen: o } = re();
483
+ const { open: r, toggleOpen: o } = oe();
475
484
  return /* @__PURE__ */ t(
476
485
  G,
477
486
  {
478
- xs: /* @__PURE__ */ t(Qe, { open: r, onClose: () => o(!1), children: e }),
487
+ xs: /* @__PURE__ */ t(Xe, { open: r, onClose: () => o(!1), children: e }),
479
488
  md: /* @__PURE__ */ t(S, { children: e })
480
489
  }
481
490
  );
482
491
  }
483
- function Ee() {
484
- const { filters: e, handlePrice: r, t: o } = B();
485
- return /* @__PURE__ */ t(P, { direction: "row", alignItems: "center", width: { xs: "100%", md: "auto" }, justifyContent: "space-between", children: /* @__PURE__ */ t(
486
- ke,
487
- {
488
- control: /* @__PURE__ */ t(
489
- ve,
492
+ const Qt = D(ee)`
493
+ border-radius: 4px;
494
+ `, le = it(({ children: e, rounded: r, loading: o, disabled: n, ...a }, l) => /* @__PURE__ */ t(
495
+ Qt,
496
+ {
497
+ ref: l,
498
+ disableElevation: !0,
499
+ disabled: n || o,
500
+ ...a,
501
+ startIcon: o && /* @__PURE__ */ t(te, { size: "1em" }),
502
+ children: e
503
+ }
504
+ ));
505
+ le.propTypes = {
506
+ children: i.any,
507
+ rounded: i.bool,
508
+ loading: i.bool,
509
+ disabled: i.bool
510
+ };
511
+ le.defaultProps = {
512
+ children: null,
513
+ rounded: !1,
514
+ loading: !1,
515
+ disabled: !1
516
+ };
517
+ function Q({ title: e, value: r, icon: o, prepend: n, options: a, onChange: l, itemRender: c, ...d }) {
518
+ const s = U(null), v = be(), [f, y] = q(!1), [u, w] = q(r !== null ? r : ""), k = N(v.breakpoints.down("sm"));
519
+ j(() => {
520
+ w(r !== null ? r : "");
521
+ }, [r]);
522
+ const x = K(() => {
523
+ y(!1);
524
+ }, []), $ = K(() => {
525
+ y(!0);
526
+ }, []);
527
+ function b(C) {
528
+ w(C.value), l(C.value), k && x();
529
+ }
530
+ function h(C) {
531
+ return C === u;
532
+ }
533
+ return /* @__PURE__ */ m(F, { children: [
534
+ /* @__PURE__ */ m(
535
+ Xt,
536
+ {
537
+ ref: s,
538
+ onClick: $,
539
+ variant: "outlined",
540
+ size: "small",
541
+ className: ["my-select__selector", xt(u) ? "" : "my-select__selector--active"].join(" "),
542
+ sx: { minWidth: "auto" },
543
+ ...d,
544
+ children: [
545
+ /* @__PURE__ */ t("div", { className: "my-select__icon", children: o }),
546
+ e,
547
+ /* @__PURE__ */ t(Je, { className: "my-select__arrowdown", component: bt, fontSize: "small" })
548
+ ]
549
+ }
550
+ ),
551
+ /* @__PURE__ */ t(Ke, { open: f, anchorEl: s.current, transition: !0, sx: { zIndex: "9999" }, children: ({ TransitionProps: C, placement: _ }) => /* @__PURE__ */ t(Ze, { ...C, sx: { transformOrigin: _ === "bottom" ? "center top" : "center bottom" }, children: /* @__PURE__ */ t(et, { children: /* @__PURE__ */ t(tt, { onClickAway: x, children: /* @__PURE__ */ m(Yt, { autoFocusItem: f, onMouseEnter: $, onMouseLeave: x, children: [
552
+ n,
553
+ a.map((A) => c ? c(A) : /* @__PURE__ */ t(
554
+ rt,
490
555
  {
491
- checked: e.price === "free",
492
- size: "small",
493
- sx: { "& .MuiSvgIcon-fontSizeSmall": { fontSize: 16, color: "text.lighter" } },
494
- onChange: (n) => r(n.target.checked ? "free" : "")
495
- }
496
- ),
497
- label: o("blocklet.free")
556
+ onClick: () => b(A),
557
+ className: [
558
+ "my-select__option",
559
+ h(A.value) ? "my-select__option--active" : ""
560
+ ].join(" "),
561
+ children: A.name
562
+ },
563
+ A.value
564
+ ))
565
+ ] }) }) }) }) })
566
+ ] });
567
+ }
568
+ Q.propTypes = {
569
+ options: i.array.isRequired,
570
+ value: i.oneOfType([i.string, i.number, i.array]),
571
+ onChange: i.func,
572
+ itemRender: i.func,
573
+ title: i.string.isRequired,
574
+ icon: i.any,
575
+ prepend: i.any
576
+ };
577
+ Q.defaultProps = {
578
+ value: null,
579
+ icon: null,
580
+ prepend: null,
581
+ itemRender: null,
582
+ onChange: () => {
583
+ }
584
+ };
585
+ const Xt = D(le)`
586
+ border: 1px solid #f0f0f0;
587
+ padding: 6px 8px 6px 12px;
588
+ font-weight: ${(e) => e.theme.typography.fontWeightRegular};
589
+ font-size: 14px;
590
+ color: #666;
591
+ line-height: 1;
592
+ text-transform: none;
593
+ & + & {
594
+ margin-left: 10px;
595
+ }
596
+ &.my-select__selector--active {
597
+ &,
598
+ .my-select__arrowdown,
599
+ .my-select__icon svg {
600
+ color: ${(e) => e.theme.palette.primary.main};
601
+ }
602
+ }
603
+ .my-select__arrowdown {
604
+ color: #999;
605
+ font-size: 14px;
606
+ margin-left: 6px;
607
+ }
608
+ .my-select__icon {
609
+ font-size: 0;
610
+ svg {
611
+ color: #999;
612
+ font-size: 18px;
613
+ margin-right: 3px;
498
614
  }
499
- ) });
615
+ }
616
+ `, Yt = D(Ye)`
617
+ .my-select__option__icon {
618
+ color: transparent;
619
+ font-size: 14px;
620
+ margin: 0 3px 0 -5px;
621
+ }
622
+ .my-select__option {
623
+ font-size: 14px;
624
+ color: #999;
625
+ }
626
+ .my-select__option--active {
627
+ &,
628
+ .my-select__option__icon {
629
+ color: ${(e) => e.theme.palette.primary.main};
630
+ }
631
+ }
632
+ `;
633
+ function Me() {
634
+ var c;
635
+ const { filters: e, handleSort: r, handlePrice: o, t: n } = B(), a = _e(n), l = ((c = a.find((d) => d.value === e.sortBy)) == null ? void 0 : c.name) || n("sort.sort");
636
+ return /* @__PURE__ */ m(
637
+ T,
638
+ {
639
+ direction: { xs: "row", md: "column" },
640
+ alignItems: { xs: "center", md: "flex-start" },
641
+ gap: { xs: 1, md: 2 },
642
+ width: { xs: "100%", md: "auto" },
643
+ justifyContent: "space-between",
644
+ children: [
645
+ /* @__PURE__ */ t(
646
+ ke,
647
+ {
648
+ control: /* @__PURE__ */ t(
649
+ ve,
650
+ {
651
+ checked: e.price === "free",
652
+ size: "small",
653
+ sx: { "& .MuiSvgIcon-fontSizeSmall": { fontSize: 16, color: "text.lighter" } },
654
+ onChange: (d) => o(d.target.checked ? "free" : "")
655
+ }
656
+ ),
657
+ label: n("blocklet.free")
658
+ }
659
+ ),
660
+ /* @__PURE__ */ t(
661
+ Q,
662
+ {
663
+ value: e.sortBy,
664
+ options: a,
665
+ title: l,
666
+ onChange: r,
667
+ icon: null,
668
+ prepend: null,
669
+ itemRender: null
670
+ }
671
+ )
672
+ ]
673
+ }
674
+ );
500
675
  }
501
- function Qt() {
502
- const { selectedCategory: e, handleCategory: r, t: o, categoryOptions: n, filters: a, cleanFilter: l, loadings: m } = B(), { toggleOpen: d } = re();
503
- return /* @__PURE__ */ p(Gt, { children: [
676
+ function Jt() {
677
+ const { selectedCategory: e, handleCategory: r, t: o, categoryOptions: n, filters: a, cleanFilter: l, loadings: c } = B(), { toggleOpen: d } = oe();
678
+ return /* @__PURE__ */ m(Gt, { children: [
504
679
  /* @__PURE__ */ t(
505
680
  G,
506
681
  {
507
- xs: /* @__PURE__ */ p(
508
- P,
682
+ xs: /* @__PURE__ */ m(
683
+ T,
509
684
  {
510
685
  direction: "row",
511
686
  justifyContent: "space-between",
@@ -516,8 +691,8 @@ function Qt() {
516
691
  borderBottom: 1,
517
692
  borderColor: "divider",
518
693
  children: [
519
- /* @__PURE__ */ t(De, { onClick: () => d(!1), children: /* @__PURE__ */ t(Se, {}) }),
520
- /* @__PURE__ */ t(T, { flex: 1, variant: "body1", fontWeight: "fontWeightMedium", children: "Categories" })
694
+ /* @__PURE__ */ t(Ee, { onClick: () => d(!1), children: /* @__PURE__ */ t(Se, {}) }),
695
+ /* @__PURE__ */ t(I, { flex: 1, variant: "body1", fontWeight: "fontWeightMedium", children: "Categories" })
521
696
  ]
522
697
  }
523
698
  ),
@@ -525,18 +700,18 @@ function Qt() {
525
700
  }
526
701
  ),
527
702
  /* @__PURE__ */ t(
528
- P,
703
+ T,
529
704
  {
530
- visibility: m.fetchCategoriesLoading ? "hidden" : "visible",
705
+ visibility: c.fetchCategoriesLoading ? "hidden" : "visible",
531
706
  width: { xs: 268, md: 200 },
532
707
  boxSizing: "content-box",
533
708
  p: { xs: 2, md: 0 },
534
709
  pr: { md: 6 },
535
- children: a.keyword ? /* @__PURE__ */ t(Ee, {}) : /* @__PURE__ */ p(F, { children: [
536
- /* @__PURE__ */ p(S, { display: "flex", alignItems: "center", gap: 1, children: [
537
- /* @__PURE__ */ t(Ce, { icon: lt }),
710
+ children: a.keyword ? /* @__PURE__ */ t(Me, {}) : /* @__PURE__ */ m(F, { children: [
711
+ /* @__PURE__ */ m(S, { display: "flex", alignItems: "center", gap: 1, children: [
712
+ /* @__PURE__ */ t(Ce, { icon: at }),
538
713
  /* @__PURE__ */ t(
539
- T,
714
+ I,
540
715
  {
541
716
  variant: "body1",
542
717
  color: e ? "text.lighter" : "text.primary",
@@ -549,8 +724,8 @@ function Qt() {
549
724
  }
550
725
  )
551
726
  ] }),
552
- !!n.length && /* @__PURE__ */ t(P, { pt: 3, mt: 3, borderTop: 1, borderColor: "divider", gap: 2, children: n.map((s) => /* @__PURE__ */ t(
553
- T,
727
+ !!n.length && /* @__PURE__ */ t(T, { pt: 3, mt: 3, borderTop: 1, borderColor: "divider", gap: 2, children: n.map((s) => /* @__PURE__ */ t(
728
+ I,
554
729
  {
555
730
  variant: "body1",
556
731
  title: s.name,
@@ -570,24 +745,24 @@ function Qt() {
570
745
  )
571
746
  ] });
572
747
  }
573
- function Me() {
574
- const { endpoint: e, serverVersion: r, storeVersion: o } = B(), n = _e(r, o), a = E(() => Pe.create({
748
+ function Ne() {
749
+ const { endpoint: e, serverVersion: r, storeVersion: o } = B(), n = Ae(r, o), a = E(() => Pe.create({
575
750
  baseURL: e,
576
751
  headers: n
577
752
  }), [e]);
578
753
  return {
579
754
  get: async (l) => {
580
- const { data: m } = await a.get(l);
581
- return m;
755
+ const { data: c } = await a.get(l);
756
+ return c;
582
757
  },
583
- post: async (l, m) => {
584
- const { data: d } = await a.post(l, m);
758
+ post: async (l, c) => {
759
+ const { data: d } = await a.post(l, c);
585
760
  return d;
586
761
  }
587
762
  };
588
763
  }
589
- const Ne = at(function(r) {
590
- return /* @__PURE__ */ t(Te, { height: 60, display: "flex", alignItems: "center", justifyContent: "center", ...r, children: /* @__PURE__ */ t(ee, {}) });
764
+ const Oe = st(function(r) {
765
+ return /* @__PURE__ */ t(Te, { height: 60, display: "flex", alignItems: "center", justifyContent: "center", ...r, children: /* @__PURE__ */ t(te, {}) });
591
766
  });
592
767
  function fe({
593
768
  icon: e,
@@ -595,10 +770,10 @@ function fe({
595
770
  maxWidth: o = 100,
596
771
  title: n
597
772
  }) {
598
- return (r === 0 || r) && /* @__PURE__ */ p(P, { direction: "row", alignItems: "center", gap: 1, sx: { maxWidth: o, overflow: "hidden" }, children: [
773
+ return (r === 0 || r) && /* @__PURE__ */ m(T, { direction: "row", alignItems: "center", gap: 1, sx: { maxWidth: o, overflow: "hidden" }, children: [
599
774
  e,
600
775
  /* @__PURE__ */ t(
601
- T,
776
+ I,
602
777
  {
603
778
  flex: 1,
604
779
  variant: "body2",
@@ -610,11 +785,11 @@ function fe({
610
785
  ] });
611
786
  }
612
787
  const ge = 292;
613
- function Xt() {
614
- var f, g;
615
- const { t: e } = B(), { post: r } = Me(), o = ((g = (f = window.blocklet) == null ? void 0 : f.preferences) == null ? void 0 : g.homeBanner) || [], { data: n = [] } = te(async () => {
616
- const c = await r(R.exploreDidsPath, { didList: o.map((x) => x.did) });
617
- return Array.isArray(c) ? c : [];
788
+ function Kt() {
789
+ var f, y;
790
+ const { t: e } = B(), { post: r } = Ne(), o = ((y = (f = window.blocklet) == null ? void 0 : f.preferences) == null ? void 0 : y.homeBanner) || [], { data: n = [] } = re(async () => {
791
+ const u = await r(P.exploreDidsPath, { didList: o.map((w) => w.did) });
792
+ return Array.isArray(u) ? u : [];
618
793
  }), a = {
619
794
  position: "absolute",
620
795
  top: "50%",
@@ -623,10 +798,10 @@ function Xt() {
623
798
  cursor: "pointer",
624
799
  color: "text.lighter"
625
800
  };
626
- return o.length > 0 ? /* @__PURE__ */ p(F, { children: [
627
- /* @__PURE__ */ t(T, { component: "h2", variant: "h2", mt: { xs: 2, md: 0 }, mb: 3, children: e("explore.title") }),
801
+ return o.length > 0 ? /* @__PURE__ */ m(F, { children: [
802
+ /* @__PURE__ */ t(I, { component: "h2", variant: "h2", mt: { xs: 2, md: 0 }, mb: 3, children: e("explore.title") }),
628
803
  /* @__PURE__ */ t(S, { height: { xs: "auto", md: ge }, position: "relative", bgcolor: "#F0F7FF", borderRadius: 3, children: /* @__PURE__ */ t(
629
- kt,
804
+ St,
630
805
  {
631
806
  showNav: !0,
632
807
  autoPlay: !0,
@@ -637,14 +812,15 @@ function Xt() {
637
812
  showBullets: !1,
638
813
  showThumbnails: !1,
639
814
  showFullscreenButton: !1,
640
- renderLeftNav: (c) => /* @__PURE__ */ t(S, { onClick: c, sx: { display: { xs: "none", md: "block" } }, children: /* @__PURE__ */ t(xt, { sx: { ...a, left: 5 } }) }),
641
- renderRightNav: (c) => /* @__PURE__ */ t(S, { onClick: c, sx: { display: { xs: "none", md: "block" } }, children: /* @__PURE__ */ t(wt, { sx: { ...a, right: 5 } }) }),
642
- items: o.map((c, x) => ({
643
- original: c.did,
815
+ renderLeftNav: (u) => /* @__PURE__ */ t(S, { onClick: u, sx: { display: { xs: "none", md: "block" } }, children: /* @__PURE__ */ t(vt, { sx: { ...a, left: 5 } }) }),
816
+ renderRightNav: (u) => /* @__PURE__ */ t(S, { onClick: u, sx: { display: { xs: "none", md: "block" } }, children: /* @__PURE__ */ t(Ct, { sx: { ...a, right: 5 } }) }),
817
+ items: o.map((u, w) => ({
818
+ original: u.did,
644
819
  renderItem: () => {
645
- const w = n[x];
646
- return /* @__PURE__ */ p(
647
- P,
820
+ var x;
821
+ const k = n[w] || {};
822
+ return /* @__PURE__ */ m(
823
+ T,
648
824
  {
649
825
  height: { xs: "auto", md: ge },
650
826
  display: "flex",
@@ -654,14 +830,14 @@ function Xt() {
654
830
  p: { xs: 2, md: 5 },
655
831
  gap: { xs: 2, md: 5 },
656
832
  children: [
657
- l(c.cover || w.screenshots[0]),
658
- /* @__PURE__ */ p(P, { flex: 1, height: "100%", gap: 3, children: [
659
- /* @__PURE__ */ p(S, { flex: 1, children: [
660
- m(c.name || w.title || c.name),
661
- d(c.desc || w.description)
833
+ l(u.cover || ((x = k.screenshots) == null ? void 0 : x[0])),
834
+ /* @__PURE__ */ m(T, { flex: 1, height: "100%", gap: 3, children: [
835
+ /* @__PURE__ */ m(S, { flex: 1, children: [
836
+ c(u.name || k.title || u.name),
837
+ d(u.desc || k.description)
662
838
  ] }),
663
- w && s(w, c.baseNum),
664
- k(c.link, c.did)
839
+ k.did && s(k, u.baseNum),
840
+ v(u.link, u.did)
665
841
  ] })
666
842
  ]
667
843
  }
@@ -671,15 +847,15 @@ function Xt() {
671
847
  }
672
848
  ) })
673
849
  ] }) : null;
674
- function l(c) {
675
- return /* @__PURE__ */ t(S, { width: { xs: "100%", md: 338 }, height: 210, borderRadius: 2, overflow: "hidden", children: /* @__PURE__ */ t("img", { src: c, alt: "", style: { width: "100%", height: "100%", objectFit: "cover" } }) });
850
+ function l(u) {
851
+ return /* @__PURE__ */ t(S, { width: { xs: "100%", md: 338 }, height: 210, borderRadius: 2, overflow: "hidden", children: /* @__PURE__ */ t("img", { src: u, alt: "", style: { width: "100%", height: "100%", objectFit: "cover" } }) });
676
852
  }
677
- function m(c) {
678
- return /* @__PURE__ */ t(T, { variant: "h2", width: "100%", children: c });
853
+ function c(u) {
854
+ return /* @__PURE__ */ t(I, { variant: "h2", width: "100%", children: u });
679
855
  }
680
- function d(c) {
856
+ function d(u) {
681
857
  return /* @__PURE__ */ t(
682
- T,
858
+ I,
683
859
  {
684
860
  variant: "body2",
685
861
  color: "text.secondary",
@@ -695,20 +871,20 @@ function Xt() {
695
871
  overflow: "hidden",
696
872
  WebkitBoxOrient: "vertical"
697
873
  },
698
- children: c
874
+ children: u
699
875
  }
700
876
  );
701
877
  }
702
- function s(c, x = 0) {
703
- const { did: w, owner: v, stats: z } = c;
704
- return /* @__PURE__ */ p(S, { display: "flex", alignItems: "center", gap: 2, color: "text.secondary", children: [
705
- /* @__PURE__ */ t(fe, { icon: /* @__PURE__ */ t(yt, { src: v.avatar, did: w, size: 20, variant: "circle" }), children: v.fullName }),
706
- /* @__PURE__ */ t(fe, { icon: /* @__PURE__ */ t(Ce, { icon: bt }), title: `${z.downloads + x}`, children: Yt(z.downloads + x) })
878
+ function s(u, w = 0) {
879
+ const { did: k, owner: x, stats: $ } = u;
880
+ return /* @__PURE__ */ m(S, { display: "flex", alignItems: "center", gap: 2, color: "text.secondary", children: [
881
+ /* @__PURE__ */ t(fe, { icon: /* @__PURE__ */ t(wt, { src: x.avatar, did: k, size: 20, variant: "circle" }), children: x.fullName }),
882
+ /* @__PURE__ */ t(fe, { icon: /* @__PURE__ */ t(Ce, { icon: kt }), title: `${$.downloads + w}`, children: Zt($.downloads + w) })
707
883
  ] });
708
884
  }
709
- function k(c, x) {
710
- return /* @__PURE__ */ t(Xe, { href: c || `/blocklets/${x}`, align: "left", width: 100, children: /* @__PURE__ */ t(
711
- Z,
885
+ function v(u, w) {
886
+ return /* @__PURE__ */ t(ot, { href: u || `/blocklets/${w}`, align: "left", width: 100, children: /* @__PURE__ */ t(
887
+ ee,
712
888
  {
713
889
  variant: "outlined",
714
890
  size: "small",
@@ -723,176 +899,35 @@ function Xt() {
723
899
  ) });
724
900
  }
725
901
  }
726
- const Yt = (e) => Number.isNaN(e) ? 0 : e < 1e3 ? e : e < 1e6 ? `${(e / 1e3).toFixed(1)}k` : e < 1e9 ? `${(e / 1e6).toFixed(1)}m` : `${(e / 1e9).toFixed(1)}b`;
727
- function Jt({ title: e, blocklets: r }) {
902
+ const Zt = (e) => Number.isNaN(e) ? 0 : e < 1e3 ? e : e < 1e6 ? `${(e / 1e3).toFixed(1)}k` : e < 1e9 ? `${(e / 1e6).toFixed(1)}m` : `${(e / 1e9).toFixed(1)}b`;
903
+ function er({ title: e, blocklets: r }) {
728
904
  const { blockletRender: o, serverVersion: n } = B();
729
- return /* @__PURE__ */ p(S, { mt: 3, children: [
730
- /* @__PURE__ */ t(T, { component: "h3", variant: "h3", sx: { mb: 2 }, children: e }),
905
+ return /* @__PURE__ */ m(S, { mt: 3, children: [
906
+ /* @__PURE__ */ t(I, { component: "h3", variant: "h3", sx: { mb: 2 }, children: e }),
731
907
  /* @__PURE__ */ t(pe, { container: !0, spacing: 2, children: r.map((a) => /* @__PURE__ */ t(pe, { item: !0, xs: 12, md: 6, p: "2px", "data-blocklet-did": a.did, children: /* @__PURE__ */ t(S, { padding: "1px", children: o({ blocklet: a, blocklets: r, serverVersion: n }) }) }, a.did)) })
732
908
  ] });
733
909
  }
734
- function Kt() {
735
- const { get: e } = Me(), { t: r } = B(), {
910
+ function tr() {
911
+ const { get: e } = Ne(), { t: r } = B(), {
736
912
  data: o = [],
737
913
  error: n,
738
914
  loading: a
739
- } = te(async () => {
740
- const l = await e(R.explorePath);
915
+ } = re(async () => {
916
+ const l = await e(P.explorePath);
741
917
  return Array.isArray(l) ? l : [];
742
918
  });
743
- return n ? /* @__PURE__ */ t(K, { error: new Error(`Failed to fetch blocklets from ${R.explorePath}`) }) : a ? /* @__PURE__ */ t(Ne, { mt: 15 }) : /* @__PURE__ */ p(F, { children: [
744
- /* @__PURE__ */ t(Xt, {}),
919
+ return n ? /* @__PURE__ */ t(Z, { error: new Error(`Failed to fetch blocklets from ${P.explorePath}`) }) : a ? /* @__PURE__ */ t(Oe, { mt: 15 }) : /* @__PURE__ */ m(F, { children: [
920
+ /* @__PURE__ */ t(Kt, {}),
745
921
  o.map(
746
- (l) => l.blocklets.length > 0 ? /* @__PURE__ */ t(Jt, { title: r(`explore.${l.type}`), blocklets: l.blocklets }, l.type) : null
922
+ (l) => l.blocklets.length > 0 ? /* @__PURE__ */ t(er, { title: r(`explore.${l.type}`), blocklets: l.blocklets }, l.type) : null
747
923
  )
748
924
  ] });
749
925
  }
750
- const Zt = D(Z)`
751
- border-radius: 4px;
752
- `, ne = it(({ children: e, rounded: r, loading: o, disabled: n, ...a }, l) => /* @__PURE__ */ t(
753
- Zt,
754
- {
755
- ref: l,
756
- disableElevation: !0,
757
- disabled: n || o,
758
- ...a,
759
- startIcon: o && /* @__PURE__ */ t(ee, { size: "1em" }),
760
- children: e
761
- }
762
- ));
763
- ne.propTypes = {
764
- children: i.any,
765
- rounded: i.bool,
766
- loading: i.bool,
767
- disabled: i.bool
768
- };
769
- ne.defaultProps = {
770
- children: null,
771
- rounded: !1,
772
- loading: !1,
773
- disabled: !1
774
- };
775
- function le({ title: e, value: r, icon: o, prepend: n, options: a, onChange: l, itemRender: m, ...d }) {
776
- const s = U(null), k = be(), [f, g] = q(!1), [c, x] = q(r !== null ? r : ""), w = N(k.breakpoints.down("sm"));
777
- j(() => {
778
- x(r !== null ? r : "");
779
- }, [r]);
780
- const v = J(() => {
781
- g(!1);
782
- }, []), z = J(() => {
783
- g(!0);
784
- }, []);
785
- function y(C) {
786
- x(C.value), l(C.value), w && v();
787
- }
788
- function u(C) {
789
- return C === c;
790
- }
791
- return /* @__PURE__ */ p(F, { children: [
792
- /* @__PURE__ */ p(
793
- er,
794
- {
795
- ref: s,
796
- onClick: z,
797
- variant: "outlined",
798
- size: "small",
799
- className: ["my-select__selector", Ct(c) ? "" : "my-select__selector--active"].join(" "),
800
- sx: { minWidth: "auto" },
801
- ...d,
802
- children: [
803
- /* @__PURE__ */ t("div", { className: "my-select__icon", children: o }),
804
- e,
805
- /* @__PURE__ */ t(Je, { className: "my-select__arrowdown", component: vt, fontSize: "small" })
806
- ]
807
- }
808
- ),
809
- /* @__PURE__ */ t(Ke, { open: f, anchorEl: s.current, transition: !0, sx: { zIndex: "9999" }, children: ({ TransitionProps: C, placement: $ }) => /* @__PURE__ */ t(Ze, { ...C, sx: { transformOrigin: $ === "bottom" ? "center top" : "center bottom" }, children: /* @__PURE__ */ t(et, { children: /* @__PURE__ */ t(tt, { onClickAway: v, children: /* @__PURE__ */ p(tr, { autoFocusItem: f, onMouseEnter: z, onMouseLeave: v, children: [
810
- n,
811
- a.map((_) => m ? m(_) : /* @__PURE__ */ t(
812
- rt,
813
- {
814
- onClick: () => y(_),
815
- className: [
816
- "my-select__option",
817
- u(_.value) ? "my-select__option--active" : ""
818
- ].join(" "),
819
- children: _.name
820
- },
821
- _.value
822
- ))
823
- ] }) }) }) }) })
824
- ] });
825
- }
826
- le.propTypes = {
827
- options: i.array.isRequired,
828
- value: i.oneOfType([i.string, i.number, i.array]),
829
- onChange: i.func,
830
- itemRender: i.func,
831
- title: i.string.isRequired,
832
- icon: i.any,
833
- prepend: i.any
834
- };
835
- le.defaultProps = {
836
- value: null,
837
- icon: null,
838
- prepend: null,
839
- itemRender: null,
840
- onChange: () => {
841
- }
842
- };
843
- const er = D(ne)`
844
- border: 1px solid #f0f0f0;
845
- padding: 6px 8px 6px 12px;
846
- font-weight: ${(e) => e.theme.typography.fontWeightRegular};
847
- font-size: 14px;
848
- color: #666;
849
- line-height: 1;
850
- text-transform: none;
851
- & + & {
852
- margin-left: 10px;
853
- }
854
- &.my-select__selector--active {
855
- &,
856
- .my-select__arrowdown,
857
- .my-select__icon svg {
858
- color: ${(e) => e.theme.palette.primary.main};
859
- }
860
- }
861
- .my-select__arrowdown {
862
- color: #999;
863
- font-size: 14px;
864
- margin-left: 6px;
865
- }
866
- .my-select__icon {
867
- font-size: 0;
868
- svg {
869
- color: #999;
870
- font-size: 18px;
871
- margin-right: 3px;
872
- }
873
- }
874
- `, tr = D(Ye)`
875
- .my-select__option__icon {
876
- color: transparent;
877
- font-size: 14px;
878
- margin: 0 3px 0 -5px;
879
- }
880
- .my-select__option {
881
- font-size: 14px;
882
- color: #999;
883
- }
884
- .my-select__option--active {
885
- &,
886
- .my-select__option__icon {
887
- color: ${(e) => e.theme.palette.primary.main};
888
- }
889
- }
890
- `;
891
926
  function rr() {
892
927
  var d;
893
- const { filters: e, handleSort: r, handlePrice: o, t: n, getCategoryLocale: a } = B(), l = At(n), m = ((d = l.find((s) => s.value === e.sortBy)) == null ? void 0 : d.name) || n("sort.sort");
894
- return /* @__PURE__ */ p(
895
- P,
928
+ const { filters: e, handleSort: r, handlePrice: o, t: n, getCategoryLocale: a } = B(), l = _e(n), c = ((d = l.find((s) => s.value === e.sortBy)) == null ? void 0 : d.name) || n("sort.sort");
929
+ return /* @__PURE__ */ m(
930
+ T,
896
931
  {
897
932
  direction: { xs: "column", md: "row" },
898
933
  alignItems: { xs: "flex-start", md: "center" },
@@ -902,8 +937,8 @@ function rr() {
902
937
  px: 0,
903
938
  pb: 3,
904
939
  children: [
905
- /* @__PURE__ */ t(T, { variant: "h2", textTransform: "capitalize", children: a(e.category) }),
906
- /* @__PURE__ */ p(P, { direction: "row", alignItems: "center", width: { xs: "100%", md: "auto" }, justifyContent: "space-between", children: [
940
+ /* @__PURE__ */ t(I, { variant: "h2", textTransform: "capitalize", children: a(e.category) }),
941
+ /* @__PURE__ */ m(T, { direction: "row", alignItems: "center", width: { xs: "100%", md: "auto" }, justifyContent: "space-between", children: [
907
942
  /* @__PURE__ */ t(
908
943
  ke,
909
944
  {
@@ -920,11 +955,11 @@ function rr() {
920
955
  }
921
956
  ),
922
957
  /* @__PURE__ */ t(
923
- le,
958
+ Q,
924
959
  {
925
960
  value: e.sortBy,
926
961
  options: l,
927
- title: m,
962
+ title: c,
928
963
  onChange: r,
929
964
  icon: null,
930
965
  prepend: null,
@@ -942,7 +977,7 @@ function ye() {
942
977
  }
943
978
  function O({ filterTip: e, keywordTip: r }) {
944
979
  const { t: o, locale: n } = B(), a = () => n === "zh" ? "、" : " , ";
945
- return /* @__PURE__ */ p(Te, { className: "tips", children: [
980
+ return /* @__PURE__ */ m(Te, { className: "tips", children: [
946
981
  /* @__PURE__ */ t("span", { style: { marginRight: "16px" }, children: o("blocklet.emptyTip") }),
947
982
  e && /* @__PURE__ */ t("span", { children: o("blocklet.filterTip") }),
948
983
  e && r && a(),
@@ -958,14 +993,14 @@ O.defaultProps = {
958
993
  keywordTip: !1
959
994
  };
960
995
  function H({ primaryStart: e, primaryEnd: r, filter: o }) {
961
- return /* @__PURE__ */ p(Ie, { variant: "subtitle2", children: [
996
+ return /* @__PURE__ */ m(Ie, { variant: "subtitle2", children: [
962
997
  /* @__PURE__ */ t("span", { children: e }),
963
- /* @__PURE__ */ p("span", { className: "primary", children: [
998
+ /* @__PURE__ */ m("span", { className: "primary", children: [
964
999
  " ",
965
1000
  o,
966
1001
  " "
967
1002
  ] }),
968
- /* @__PURE__ */ p("span", { children: [
1003
+ /* @__PURE__ */ m("span", { children: [
969
1004
  r,
970
1005
  " "
971
1006
  ] })
@@ -976,35 +1011,35 @@ H.propTypes = {
976
1011
  primaryEnd: i.string.isRequired,
977
1012
  filter: i.string.isRequired
978
1013
  };
979
- function Oe({ blocklets: e, ...r }) {
1014
+ function qe({ blocklets: e, ...r }) {
980
1015
  const {
981
1016
  blockletRender: o,
982
1017
  errors: n,
983
1018
  loadings: a,
984
1019
  selectedCategory: l,
985
- getCategoryLocale: m,
1020
+ getCategoryLocale: c,
986
1021
  filters: d,
987
1022
  t: s,
988
- serverVersion: k,
1023
+ serverVersion: v,
989
1024
  hasNextPage: f,
990
- loadMore: g,
991
- endpoint: c
992
- } = B(), x = !!l || !!d.price, [w] = Bt({
1025
+ loadMore: y,
1026
+ endpoint: u
1027
+ } = B(), w = !!l || !!d.price, [k] = Rt({
993
1028
  loading: a.fetchBlockletsLoading || a.loadingMore,
994
1029
  hasNextPage: f,
995
- onLoadMore: g
1030
+ onLoadMore: y
996
1031
  });
997
1032
  if (n.fetchBlockletsError)
998
1033
  return /* @__PURE__ */ t(
999
- K,
1034
+ Z,
1000
1035
  {
1001
- error: new Error(`Failed to fetch blocklets from ${c}: ${n.fetchBlockletsError.message}`)
1036
+ error: new Error(`Failed to fetch blocklets from ${u}: ${n.fetchBlockletsError.message}`)
1002
1037
  }
1003
1038
  );
1004
1039
  if (a.fetchBlockletsLoading)
1005
- return /* @__PURE__ */ t(Ne, { mt: 15 });
1006
- if (d.keyword && x && e.length === 0)
1007
- return /* @__PURE__ */ p(W, { children: [
1040
+ return /* @__PURE__ */ t(Oe, { mt: 15 });
1041
+ if (d.keyword && w && e.length === 0)
1042
+ return /* @__PURE__ */ m(W, { children: [
1008
1043
  /* @__PURE__ */ t(
1009
1044
  H,
1010
1045
  {
@@ -1016,7 +1051,7 @@ function Oe({ blocklets: e, ...r }) {
1016
1051
  /* @__PURE__ */ t(O, { keywordTip: !0, filterTip: !0 })
1017
1052
  ] });
1018
1053
  if (d.keyword && e.length === 0)
1019
- return /* @__PURE__ */ p(W, { children: [
1054
+ return /* @__PURE__ */ m(W, { children: [
1020
1055
  /* @__PURE__ */ t(
1021
1056
  H,
1022
1057
  {
@@ -1027,29 +1062,29 @@ function Oe({ blocklets: e, ...r }) {
1027
1062
  ),
1028
1063
  /* @__PURE__ */ t(O, { keywordTip: !0 })
1029
1064
  ] });
1030
- if (x && e.length === 0) {
1031
- const v = m(l);
1032
- return /* @__PURE__ */ p(W, { children: [
1033
- v ? /* @__PURE__ */ t(
1065
+ if (w && e.length === 0) {
1066
+ const x = c(l);
1067
+ return /* @__PURE__ */ m(W, { children: [
1068
+ x ? /* @__PURE__ */ t(
1034
1069
  H,
1035
1070
  {
1036
1071
  primaryStart: s("blocklet.noCategoryResults1"),
1037
1072
  primaryEnd: s("blocklet.noCategoryResults2"),
1038
- filter: v
1073
+ filter: x
1039
1074
  }
1040
1075
  ) : /* @__PURE__ */ t(ye, {}),
1041
1076
  /* @__PURE__ */ t(O, { filterTip: !0 })
1042
1077
  ] });
1043
1078
  }
1044
- return e.length === 0 ? /* @__PURE__ */ t(W, { children: /* @__PURE__ */ t(ye, {}) }) : /* @__PURE__ */ p(F, { children: [
1045
- /* @__PURE__ */ t(S, { display: "grid", gridTemplateColumns: { xs: "1fr", sm: "1fr 1fr" }, p: "2px", ...r, gap: 2, children: e.map((v) => /* @__PURE__ */ t(S, { "data-blocklet-did": v.did, children: o({ blocklet: v, blocklets: e, serverVersion: k }) }, v.did)) }),
1046
- f && /* @__PURE__ */ t(S, { height: 60, display: "flex", justifyContent: "center", py: 2, ref: w, children: /* @__PURE__ */ t(ee, {}) })
1079
+ return e.length === 0 ? /* @__PURE__ */ t(W, { children: /* @__PURE__ */ t(ye, {}) }) : /* @__PURE__ */ m(F, { children: [
1080
+ /* @__PURE__ */ t(S, { display: "grid", gridTemplateColumns: { xs: "1fr", sm: "1fr 1fr" }, p: "2px", ...r, gap: 2, children: e.map((x) => /* @__PURE__ */ t(S, { "data-blocklet-did": x.did, children: o({ blocklet: x, blocklets: e, serverVersion: v }) }, x.did)) }),
1081
+ f && /* @__PURE__ */ t(S, { height: 60, display: "flex", justifyContent: "center", py: 2, ref: k, children: /* @__PURE__ */ t(te, {}) })
1047
1082
  ] });
1048
1083
  }
1049
- Oe.propTypes = {
1084
+ qe.propTypes = {
1050
1085
  blocklets: i.array.isRequired
1051
1086
  };
1052
- const W = D(St)`
1087
+ const W = D(Bt)`
1053
1088
  text-align: center;
1054
1089
  margin-top: 100px;
1055
1090
  .primary {
@@ -1060,37 +1095,37 @@ const W = D(St)`
1060
1095
  }
1061
1096
  `;
1062
1097
  function ae({ onSelect: e, wrapChildren: r }) {
1063
- const o = U(null), n = U(null), a = U(null), { storeApi: l, blockletRender: m, filters: d, endpoint: s, handleKeyword: k, t: f, serverVersion: g } = B(), c = async (y) => {
1064
- const { data: u } = await l.get(R.blockletsPath, { params: y }), C = u.dataList || [];
1065
- return C.length > 0 && C.unshift({ type: "more-result", total: u.total || 0 }), C;
1066
- }, x = (y) => {
1067
- k(y.state.query), y.setIsOpen(!1);
1068
- }, w = () => {
1098
+ const o = U(null), n = U(null), a = U(null), { storeApi: l, blockletRender: c, filters: d, endpoint: s, handleKeyword: v, t: f, serverVersion: y } = B(), u = async (b) => {
1099
+ const { data: h } = await l.get(P.blockletsPath, { params: b }), C = h.dataList || [];
1100
+ return C.length > 0 && C.unshift({ type: "more-result", total: h.total || 0 }), C;
1101
+ }, w = (b) => {
1102
+ v(b.state.query), b.setIsOpen(!1);
1103
+ }, k = () => {
1069
1104
  o.current && setTimeout(() => {
1070
- const y = o.current.querySelector("input.bl-autocomplete-input");
1071
- y && y.focus();
1105
+ const b = o.current.querySelector("input.bl-autocomplete-input");
1106
+ b && b.focus();
1072
1107
  });
1073
- }, v = (y) => {
1074
- y.setIsOpen(!1), w();
1075
- }, z = ({ prevState: y, state: u }) => {
1076
- y.query !== u.query && (u.query || (k(), w()));
1108
+ }, x = (b) => {
1109
+ b.setIsOpen(!1), k();
1110
+ }, $ = ({ prevState: b, state: h }) => {
1111
+ b.query !== h.query && (h.query || (v(), k()));
1077
1112
  };
1078
- return It(
1113
+ return Lt(
1079
1114
  "ctrl + k, command + k",
1080
- (y) => (y.stopPropagation(), y.preventDefault(), w(), !1),
1115
+ (b) => (b.stopPropagation(), b.preventDefault(), k(), !1),
1081
1116
  { enableOnTags: ["INPUT"] }
1082
1117
  ), j(() => {
1083
- w();
1118
+ k();
1084
1119
  }, [s]), j(() => {
1085
1120
  if (!o.current)
1086
1121
  return;
1087
- const y = Tt({
1122
+ const b = It({
1088
1123
  container: o.current,
1089
- renderer: { createElement: st, Fragment: ct, render: () => {
1124
+ renderer: { createElement: ct, Fragment: dt, render: () => {
1090
1125
  } },
1091
- render({ children: u }, C) {
1092
- var $;
1093
- (!n.current || a.current !== C) && (a.current = C, ($ = n.current) == null || $.unmount(), n.current = Pt(C)), n.current.render(r(u));
1126
+ render({ children: h }, C) {
1127
+ var _;
1128
+ (!n.current || a.current !== C) && (a.current = C, (_ = n.current) == null || _.unmount(), n.current = Tt(C)), n.current.render(r(h));
1094
1129
  },
1095
1130
  autoFocus: !0,
1096
1131
  openOnFocus: !1,
@@ -1113,42 +1148,41 @@ function ae({ onSelect: e, wrapChildren: r }) {
1113
1148
  initialState: {
1114
1149
  query: d.keyword
1115
1150
  },
1116
- onStateChange(u) {
1117
- z(u);
1151
+ onStateChange(h) {
1152
+ $(h);
1118
1153
  },
1119
- onSubmit: x,
1120
- onReset(u) {
1121
- v(u);
1154
+ onSubmit: w,
1155
+ onReset(h) {
1156
+ x(h);
1122
1157
  },
1123
- getSources({ query: u, state: C, ...$ }) {
1124
- const _ = {
1125
- ...d,
1126
- sortBy: R[d.sortBy],
1158
+ getSources({ query: h, state: C, ..._ }) {
1159
+ const A = {
1160
+ sortBy: P.nameDesc,
1127
1161
  page: 1,
1128
1162
  pageSize: 10,
1129
- keyword: u
1163
+ keyword: h
1130
1164
  };
1131
1165
  return jt([
1132
1166
  {
1133
1167
  sourceId: "blocklets",
1134
1168
  getItems() {
1135
- return c(_);
1169
+ return u(A);
1136
1170
  },
1137
1171
  // 选中后填充 搜索框中值
1138
- getItemInputValue({ item: L }) {
1139
- return L.type === "more-result" ? u : L.title;
1172
+ getItemInputValue({ item: z }) {
1173
+ return z.type === "more-result" ? h : z.title;
1140
1174
  },
1141
1175
  // 选中或者点击自动完成列表中的 item 时触发
1142
- onSelect({ event: L, item: I }) {
1143
- return I.type === "more-result" ? ($.setIsOpen(!1), k(u)) : L.type === "keydown" ? k(I.title) : e({
1144
- blocklet: I,
1145
- detailUrl: Lt(s, "/blocklets", I.did),
1176
+ onSelect({ event: z, item: L }) {
1177
+ return L.type === "more-result" ? (_.setIsOpen(!1), v(h)) : z.type === "keydown" ? v(L.title) : e({
1178
+ blocklet: L,
1179
+ detailUrl: zt(s, "/blocklets", L.did),
1146
1180
  storeUrl: s
1147
1181
  });
1148
1182
  },
1149
1183
  templates: {
1150
- item({ item: L }) {
1151
- return L.type === "more-result" ? /* @__PURE__ */ t("div", { children: f("autocomplete.expandResult", { name: u, number: L.total.toLocaleString() }) }) : m({ blocklet: L, autocompleteSetters: $, serverVersion: g });
1184
+ item({ item: z }) {
1185
+ return z.type === "more-result" ? /* @__PURE__ */ t("div", { children: f("autocomplete.expandResult", { name: h, number: z.total.toLocaleString() }) }) : c({ blocklet: z, autocompleteSetters: _, serverVersion: y });
1152
1186
  },
1153
1187
  noResults() {
1154
1188
  return f("blocklet.noResults");
@@ -1159,18 +1193,24 @@ function ae({ onSelect: e, wrapChildren: r }) {
1159
1193
  }
1160
1194
  });
1161
1195
  return () => {
1162
- y.destroy();
1196
+ b.destroy();
1163
1197
  };
1164
- }, [d, m]), /* @__PURE__ */ p(F, { children: [
1198
+ }, [d, c]), /* @__PURE__ */ m(F, { children: [
1165
1199
  /* @__PURE__ */ t(
1166
1200
  xe,
1167
1201
  {
1168
- styles: we`
1202
+ styles: (b) => we`
1169
1203
  .bl-autocomplete-detached-container {
1170
1204
  .bl-autocomplete-detached-cancel {
1171
1205
  white-space: nowrap;
1172
1206
  }
1173
1207
  }
1208
+ .bl-autocomplete-panel {
1209
+ @media (min-width: ${b.breakpoints.values.md}px) {
1210
+ min-width: 450px;
1211
+ left: unset !important;
1212
+ }
1213
+ }
1174
1214
  `
1175
1215
  }
1176
1216
  ),
@@ -1185,9 +1225,9 @@ ae.defaultProps = {
1185
1225
  wrapChildren: (e) => e
1186
1226
  };
1187
1227
  function ie({ placeholder: e, ...r }) {
1188
- const { filters: o, handleKeyword: n } = B(), [a, l] = q(o.keyword || ""), m = mt(n, { wait: 300 }), d = (k) => {
1189
- const { value: f } = k.target;
1190
- l(f), m.run(f);
1228
+ const { filters: o, handleKeyword: n } = B(), [a, l] = q(o.keyword || ""), c = ht(n, { wait: 300 }), d = (v) => {
1229
+ const { value: f } = v.target;
1230
+ l(f), c.run(f);
1191
1231
  }, s = () => {
1192
1232
  l(""), n();
1193
1233
  };
@@ -1216,7 +1256,7 @@ ie.propTypes = {
1216
1256
  ie.defaultProps = {
1217
1257
  placeholder: "Type to search..."
1218
1258
  };
1219
- const or = D(ot)`
1259
+ const or = D(nt)`
1220
1260
  background-color: ${(e) => e.theme.palette.grey[50]};
1221
1261
  font-size: 14px;
1222
1262
  border-radius: 6px;
@@ -1233,7 +1273,7 @@ const or = D(ot)`
1233
1273
  color: transparent;
1234
1274
  }
1235
1275
  }
1236
- `, nr = D(zt)`
1276
+ `, nr = D($t)`
1237
1277
  color: ${(e) => e.theme.palette.grey[500]};
1238
1278
  font-size: 28px;
1239
1279
  @media (max-width: ${(e) => e.theme.breakpoints.values.md}px) {
@@ -1245,9 +1285,9 @@ const or = D(ot)`
1245
1285
  cursor: pointer;
1246
1286
  `;
1247
1287
  function ar() {
1248
- const { filters: e, handleSearchSelect: r, t: o, wrapChildren: n, baseSearch: a } = B(), { toggleOpen: l } = re(), m = !!e.keyword;
1249
- return /* @__PURE__ */ p(
1250
- P,
1288
+ const { filters: e, handleSearchSelect: r, t: o, wrapChildren: n, baseSearch: a } = B(), { toggleOpen: l } = oe(), c = !!e.keyword;
1289
+ return /* @__PURE__ */ m(
1290
+ T,
1251
1291
  {
1252
1292
  direction: "row",
1253
1293
  alignItems: "center",
@@ -1261,14 +1301,14 @@ function ar() {
1261
1301
  /* @__PURE__ */ t(
1262
1302
  G,
1263
1303
  {
1264
- xs: !m && /* @__PURE__ */ t(De, { onClick: () => l(!0), children: /* @__PURE__ */ t(Rt, {}) }),
1265
- md: /* @__PURE__ */ t(T, { variant: "h1", children: o("common.title") })
1304
+ xs: !c && /* @__PURE__ */ t(Ee, { onClick: () => l(!0), children: /* @__PURE__ */ t(Pt, {}) }),
1305
+ md: /* @__PURE__ */ t(I, { variant: "h1", children: o("common.title") })
1266
1306
  }
1267
1307
  ),
1268
1308
  /* @__PURE__ */ t(
1269
1309
  S,
1270
1310
  {
1271
- width: { xs: m ? "100%" : 300, md: 300 },
1311
+ width: { xs: c ? "100%" : 300, md: 300 },
1272
1312
  className: "filter-bar",
1273
1313
  sx: {
1274
1314
  "& .bl-autocomplete-form": { borderRadius: 2 },
@@ -1284,27 +1324,27 @@ function ar() {
1284
1324
  }
1285
1325
  function ir() {
1286
1326
  const { blockletList: e, filters: r, t: o } = B(), n = r.category || r.keyword || r.price;
1287
- return /* @__PURE__ */ t($t, { children: /* @__PURE__ */ p(nt, { FallbackComponent: K, children: [
1327
+ return /* @__PURE__ */ t(_t, { children: /* @__PURE__ */ m(lt, { FallbackComponent: Z, children: [
1288
1328
  /* @__PURE__ */ t(ar, {}),
1289
- /* @__PURE__ */ p(S, { display: "flex", height: "100%", children: [
1290
- /* @__PURE__ */ t(Qt, {}),
1291
- /* @__PURE__ */ t(P, { height: "100%", position: "relative", flex: 1, overflow: "auto", children: n ? /* @__PURE__ */ p(F, { children: [
1292
- r.keyword ? /* @__PURE__ */ p(F, { children: [
1293
- /* @__PURE__ */ t(G, { xs: /* @__PURE__ */ t(Ee, {}), md: null }),
1329
+ /* @__PURE__ */ m(S, { display: "flex", height: "100%", children: [
1330
+ /* @__PURE__ */ t(Jt, {}),
1331
+ /* @__PURE__ */ t(T, { height: "100%", position: "relative", flex: 1, overflow: "visible", children: n ? /* @__PURE__ */ m(F, { children: [
1332
+ r.keyword ? /* @__PURE__ */ m(F, { children: [
1333
+ /* @__PURE__ */ t(G, { xs: /* @__PURE__ */ t(Me, {}), md: null }),
1294
1334
  a()
1295
1335
  ] }) : /* @__PURE__ */ t(rr, {}),
1296
- /* @__PURE__ */ t(Oe, { blocklets: e, height: "100%" })
1297
- ] }) : /* @__PURE__ */ t(Kt, {}) })
1336
+ /* @__PURE__ */ t(qe, { blocklets: e, height: "100%" })
1337
+ ] }) : /* @__PURE__ */ t(tr, {}) })
1298
1338
  ] })
1299
1339
  ] }) });
1300
1340
  function a() {
1301
- return /* @__PURE__ */ p(P, { direction: "row", alignItems: "center", justifyContent: "space-between", mb: 2, mt: { xs: 2, md: 0 }, children: [
1302
- /* @__PURE__ */ t(T, { variant: "h3", children: o("blocklet.search", { keyword: r.keyword }) }),
1303
- /* @__PURE__ */ t(T, { variant: "body1", color: "text.lighter", fontSize: 13, children: o("blocklet.resultCount", { count: e.length }) })
1341
+ return /* @__PURE__ */ m(T, { direction: "row", alignItems: "center", justifyContent: "space-between", mb: 2, mt: { xs: 2, md: 0 }, children: [
1342
+ /* @__PURE__ */ t(I, { variant: "h3", children: o("blocklet.search", { keyword: r.keyword }) }),
1343
+ /* @__PURE__ */ t(I, { variant: "body1", color: "text.lighter", fontSize: 13, children: o("blocklet.resultCount", { count: e.length }) })
1304
1344
  ] });
1305
1345
  }
1306
1346
  }
1307
- function qe(e) {
1347
+ function je(e) {
1308
1348
  const r = be(), o = Ot(r.palette.primary.main), n = {
1309
1349
  autocomplete: we`
1310
1350
  :root {
@@ -1344,13 +1384,13 @@ function qe(e) {
1344
1384
  }
1345
1385
  `
1346
1386
  };
1347
- return /* @__PURE__ */ p(oe, { ...e, children: [
1387
+ return /* @__PURE__ */ m(ne, { ...e, children: [
1348
1388
  /* @__PURE__ */ t(xe, { styles: n.autocomplete }),
1349
1389
  /* @__PURE__ */ t(ir, {})
1350
1390
  ] });
1351
1391
  }
1352
- qe.propTypes = ze;
1353
- qe.defaultProps = $e;
1392
+ je.propTypes = ze;
1393
+ je.defaultProps = $e;
1354
1394
  export {
1355
- qe as default
1395
+ je as default
1356
1396
  };