@blocklet/list 0.14.5 → 0.14.7

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 +718 -785
  2. package/package.json +3 -5
package/lib/index.es.js CHANGED
@@ -1,57 +1,56 @@
1
- import { jsx as t, jsxs as p, Fragment as z } from "react/jsx-runtime";
2
- import { styled as E, useTheme as xe } from "@arcblock/ux/lib/Theme";
3
- import { Global as we, css as ke } from "@emotion/react";
1
+ import { jsx as t, jsxs as f, Fragment as M } from "react/jsx-runtime";
2
+ import { styled as E, useTheme as fe } from "@arcblock/ux/lib/Theme";
3
+ import { Box as v, Autocomplete as Qe, TextField as Xe, OutlinedInput as Ke, InputAdornment as ae, Button as J, useTheme as ge, useMediaQuery as O, Drawer as Ye, CircularProgress as Z, MenuList as Je, SvgIcon as Ze, Popper as et, Grow as tt, Paper as rt, ClickAwayListener as ot, MenuItem as nt, Stack as z, FormControlLabel as ye, Checkbox as xe, Typography as L, Link as lt, Grid as se, Chip as it, createTheme as at, ThemeProvider as st } from "@mui/material";
4
+ import ct from "lodash/merge";
4
5
  import { ErrorFallback as ee } from "@arcblock/ux/lib/ErrorBoundary";
5
- import { Button as te, useTheme as ve, useMediaQuery as D, Drawer as Je, Box as C, CircularProgress as re, MenuList as Ke, SvgIcon as Ze, Popper as et, Grow as tt, Paper as rt, ClickAwayListener as ot, MenuItem as nt, Stack as I, FormControlLabel as Ce, Checkbox as Se, Typography as L, Link as lt, Grid as he, Chip as at, OutlinedInput as it, InputAdornment as me } from "@mui/material";
6
- import { ErrorBoundary as st } from "react-error-boundary";
7
- import ct from "@iconify-icons/tabler/compass";
8
- import { Icon as Be } from "@iconify/react";
9
- import Re from "@mui/icons-material/Close";
10
- import { createContext as Pe, useState as q, useMemo as M, useContext as Te, useCallback as Z, useEffect as W, forwardRef as dt, useRef as G, memo as ut, createElement as pt, Fragment as ht } from "react";
11
- import { createAxios as Ie } from "@blocklet/js-sdk";
12
- import mt from "lodash/orderBy";
13
- import { useInfiniteScroll as ft, useRequest as oe, useReactive as gt, useDebounceFn as yt } from "ahooks";
14
- import bt from "lodash/omitBy";
15
- import xt from "json-stable-stringify";
16
- import wt from "color";
6
+ import { ErrorBoundary as dt } from "react-error-boundary";
7
+ import ut from "@iconify-icons/tabler/compass";
8
+ import { Icon as be } from "@iconify/react";
9
+ import we from "@mui/icons-material/Close";
10
+ import { createContext as ke, useState as F, useMemo as D, useContext as ve, useCallback as X, useEffect as N, useRef as K, forwardRef as pt, memo as ht } from "react";
11
+ import { createAxios as Ce } from "@blocklet/js-sdk";
12
+ import mt from "lodash/omitBy";
13
+ import ft from "lodash/orderBy";
14
+ import { useRequest as U, useDebounceFn as Se, useInfiniteScroll as gt, useReactive as yt } from "ahooks";
15
+ import "color";
17
16
  import "lodash/cloneDeep";
18
- import { parseURL as kt, parseQuery as vt, parseFilename as Ct, stringifyParsedURL as St, withQuery as Le, joinURL as Bt } from "ufo";
19
- import fe from "flat";
17
+ import { parseURL as xt, parseQuery as bt, parseFilename as wt, stringifyParsedURL as kt, withQuery as Pe, joinURL as ce } from "ufo";
18
+ import de from "flat";
19
+ import Be from "@arcblock/ux/lib/Avatar";
20
+ import Y from "@mui/icons-material/Search";
21
+ import vt from "@mui/material/CircularProgress";
22
+ import { useHotkeys as Ct } from "react-hotkeys-hook";
20
23
  import w from "prop-types";
21
- import Rt from "@mui/icons-material/KeyboardArrowDown";
22
- import Pt from "lodash/isEmpty";
23
- import Fe from "@mui/material/Box";
24
- import Tt from "@arcblock/ux/lib/Avatar";
25
- import It from "@arcblock/ux/lib/Img";
26
- import Lt from "@iconify-icons/tabler/cloud-download";
27
- import Ft from "@mui/icons-material/ChevronLeft";
28
- import $t from "@mui/icons-material/ChevronRight";
29
- import _t from "react-image-gallery";
24
+ import St from "@mui/icons-material/Check";
25
+ import Pt from "@mui/icons-material/KeyboardArrowDown";
26
+ import Bt from "lodash/isEmpty";
27
+ import Te from "@mui/material/Box";
28
+ import Tt from "@arcblock/ux/lib/Img";
29
+ import Rt from "@iconify-icons/tabler/cloud-download";
30
+ import It from "@mui/icons-material/ChevronLeft";
31
+ import Lt from "@mui/icons-material/ChevronRight";
32
+ import At from "react-image-gallery";
30
33
  import "react-image-gallery/styles/css/image-gallery.css";
31
34
  import zt from "@arcblock/ux/lib/Empty";
32
- import At from "react-infinite-scroll-hook";
33
- import $e from "@mui/material/Typography";
35
+ import _t from "react-infinite-scroll-hook";
36
+ import Re from "@mui/material/Typography";
37
+ import Ft from "json-stable-stringify";
34
38
  import Et from "@mui/icons-material/Menu";
35
- import { createRoot as Nt } from "react-dom/client";
36
- import { autocomplete as Dt } from "@algolia/autocomplete-js";
37
- import { useHotkeys as Mt } from "react-hotkeys-hook";
38
- import Ot from "@mui/icons-material/Search";
39
- import "@algolia/autocomplete-theme-classic/dist/theme.css";
40
- const _e = Pe({
39
+ const Ie = ke({
41
40
  open: !1,
42
41
  toggleOpen: (e) => {
43
42
  }
44
43
  });
45
- function jt({ children: e }) {
46
- const [r, o] = q(!1), l = (a) => {
44
+ function Ot({ children: e }) {
45
+ const [r, o] = F(!1), l = (a) => {
47
46
  o(a ?? !a);
48
- }, n = M(() => ({ open: r, toggleOpen: l }), [r]);
49
- return /* @__PURE__ */ t(_e.Provider, { value: n, children: e });
47
+ }, n = D(() => ({ open: r, toggleOpen: l }), [r]);
48
+ return /* @__PURE__ */ t(Ie.Provider, { value: n, children: e });
50
49
  }
51
- function ne() {
52
- return Te(_e);
50
+ function te() {
51
+ return ve(Ie);
53
52
  }
54
- const T = {
53
+ const I = {
55
54
  nameAsc: "title",
56
55
  nameDesc: "title",
57
56
  popularity: "stats.downloads",
@@ -65,32 +64,13 @@ const T = {
65
64
  explorePath: "/api/blocklets/explore",
66
65
  exploreDidsPath: "/api/blocklets/dids",
67
66
  cacheSize: 100
68
- }, qt = (e, r, o, l) => ft(
69
- async (n) => {
70
- n || (o.currentPage = o.defaultCurrentPage);
71
- const { currentPage: a, pageSize: d } = o, c = {
72
- ...r,
73
- category: r.category === "All" ? "" : r.category,
74
- sortBy: T[r.sortBy],
75
- page: a,
76
- pageSize: d
77
- };
78
- l(null);
79
- const { data: s = {} } = await e.get(T.blockletsPath, { params: c });
80
- return o.currentPage++, { page: a, pageSize: d, list: (s == null ? void 0 : s.dataList) || [], total: (s == null ? void 0 : s.total) || 0 };
81
- },
82
- {
83
- isNoMore: (n) => n ? n.page * n.pageSize >= n.total : !1,
84
- reloadDeps: [e, xt(r)],
85
- onError: l
86
- }
87
- ), Wt = (e) => oe(
67
+ }, Dt = (e) => U(
88
68
  async () => {
89
- const { data: r } = await e.get(T.categoriesPath);
69
+ const { data: r } = await e.get(I.categoriesPath);
90
70
  return Array.isArray(r) ? r : [];
91
71
  },
92
72
  { manual: !0 }
93
- ), ze = (e) => [
73
+ ), Le = (e) => [
94
74
  {
95
75
  name: e("sort.popularity"),
96
76
  value: "popularity"
@@ -103,40 +83,32 @@ const T = {
103
83
  // name: t('sort.rating'),
104
84
  // value: 'rating',
105
85
  // },
106
- ], Vt = (e, r, o) => {
107
- var f, m;
108
- const l = kt(e), n = vt(l.search);
109
- if ((f = Ct(e, { strict: !0 })) == null ? void 0 : f.endsWith(".gif"))
110
- return n.imageFilter ? St({ ...l, search: "" }) : e;
86
+ ], Ae = (e, r, o) => {
87
+ var g, h;
88
+ const l = xt(e), n = bt(l.search);
89
+ if ((g = wt(e, { strict: !0 })) == null ? void 0 : g.endsWith(".gif"))
90
+ return n.imageFilter ? kt({ ...l, search: "" }) : e;
111
91
  if (n.imageFilter)
112
92
  return e;
113
- const d = (m = window.blocklet) == null ? void 0 : m.version, { w: c, h: s } = typeof r == "object" ? { w: r.w, h: r.h } : { w: r, h: r };
114
- return Le(e, {
115
- ...c || s ? { imageFilter: "resize", w: c, h: s } : {},
93
+ const d = o || ((h = window.blocklet) == null ? void 0 : h.version), { w: u, h: i } = typeof r == "object" ? { w: r.w, h: r.h } : { w: r, h: r };
94
+ return Pe(e, {
95
+ ...u || i ? { imageFilter: "resize", w: u, h: i } : {},
116
96
  v: d
117
97
  });
118
- }, Ut = (e) => [
98
+ }, Mt = (e) => [
119
99
  { name: e("blocklet.free"), value: "free" },
120
100
  { name: e("blocklet.payment"), value: "payment" }
121
- ], Gt = (e = [], r = "en") => e.map((o) => ({ name: o.locales[r] || o.locales.en, value: o._id })), Ht = (e, r) => (
101
+ ], Nt = (e = [], r = "en") => e.map((o) => ({ name: o.locales[r] || o.locales.en, value: o._id })), $t = (e, r) => (
122
102
  // eslint-disable-next-line no-prototype-builtins
123
103
  e == null ? void 0 : e.replace(/{(\w*)}/g, (o, l) => r.hasOwnProperty(l) ? r[l] : "")
124
- ), Qt = () => window.innerWidth <= 600, Xt = (e) => wt(e).rgb().object();
125
- function Yt(e, r) {
126
- let o;
127
- return function(...n) {
128
- return o && clearTimeout(o), new Promise((a) => {
129
- o = setTimeout(() => a(e(...n)), r);
130
- });
131
- };
132
- }
133
- const Jt = Yt((e) => Promise.resolve(e), 300), Kt = {
104
+ ), Wt = () => window.innerWidth <= 600, jt = {
134
105
  common: {
135
106
  title: "Blocklet Store",
136
107
  searchStore: "Search Blocklet",
137
108
  showResources: "Show resources",
138
109
  price: "Price",
139
110
  category: "Category",
111
+ categories: "Categories",
140
112
  resourceType: "Resource Type",
141
113
  clear: "Clear",
142
114
  cancel: "Cancel",
@@ -178,13 +150,14 @@ const Jt = Yt((e) => Promise.resolve(e), 300), Kt = {
178
150
  autocomplete: {
179
151
  expandResult: 'View all search results for "{name}"'
180
152
  }
181
- }, Zt = {
153
+ }, qt = {
182
154
  common: {
183
155
  title: "Blocklet 商店",
184
156
  searchStore: "搜索 Blocklet",
185
157
  showResources: "显示资源型应用",
186
158
  price: "价格",
187
159
  category: "类别",
160
+ categories: "类别",
188
161
  resourceType: "资源类型",
189
162
  clear: "清除",
190
163
  cancel: "取消",
@@ -226,37 +199,32 @@ const Jt = Yt((e) => Promise.resolve(e), 300), Kt = {
226
199
  autocomplete: {
227
200
  expandResult: "查看 “{name}” 的所有搜索结果"
228
201
  }
229
- }, K = {
230
- en: fe(Kt),
231
- zh: fe(Zt)
232
- }, Ae = (e, r) => {
202
+ }, Q = {
203
+ en: de(jt),
204
+ zh: de(qt)
205
+ }, ze = (e, r) => {
233
206
  const o = {};
234
207
  return e && (o["x-blocklet-server-version"] = e), r && (o["x-blocklet-store-version"] = r), o;
235
- }, er = (e) => (r, o) => {
236
- const l = K[e] ? K[e][r] : K.en[r];
237
- return Ht(l, o) || r;
238
- }, Ee = {
208
+ }, Ut = (e) => (r, o) => {
209
+ const l = Q[e] ? Q[e][r] : Q.en[r];
210
+ return $t(l, o) || r;
211
+ }, _e = {
239
212
  errors: {
240
- fetchBlockletsError: null,
241
213
  fetchCategoriesError: null
242
214
  },
243
215
  loadings: {
244
- fetchBlockletsLoading: !1,
245
- fetchCategoriesLoading: !1,
246
- loadingMore: !1
216
+ fetchCategoriesLoading: !1
247
217
  },
248
218
  endpoint: "",
249
- blockletList: [],
250
219
  wrapChildren: () => null,
251
220
  t: (e) => e,
252
221
  storeVersion: "",
253
- minItemWidth: 400,
222
+ minItemWidth: 350,
254
223
  serverVersion: "",
255
224
  filters: {},
256
225
  layout: {},
257
226
  selectedCategory: void 0,
258
227
  categoryList: [],
259
- total: 0,
260
228
  blockletRender: () => null,
261
229
  locale: "en",
262
230
  categoryOptions: [],
@@ -266,7 +234,6 @@ const Jt = Yt((e) => Promise.resolve(e), 300), Kt = {
266
234
  showResourcesSwitch: !1,
267
235
  showCategory: !1,
268
236
  tagFilters: [],
269
- hasNextPage: !1,
270
237
  onFilterChange: () => {
271
238
  },
272
239
  handleSort: () => {
@@ -283,182 +250,328 @@ const Jt = Yt((e) => Promise.resolve(e), 300), Kt = {
283
250
  },
284
251
  handlePage: () => {
285
252
  },
286
- handleSwitchShowResources: () => {
253
+ developerName: "",
254
+ updateDeveloperName: () => {
287
255
  },
288
- loadMore: () => {
256
+ handleSwitchShowResources: () => {
289
257
  },
290
258
  getCategoryLocale: () => null,
291
- developerName: "",
292
259
  handleSearchSelect: () => {
293
260
  }
294
- }, Ne = Pe(Ee), { Provider: tr, Consumer: no } = Ne;
295
- function rr(e) {
296
- var ue;
261
+ }, Fe = ke(_e), { Provider: Vt, Consumer: Yr } = Fe;
262
+ function Ht(e) {
297
263
  const {
298
264
  locale: r = "zh",
299
265
  filters: o = {},
300
266
  serverVersion: l = "",
301
267
  onFilterChange: n = () => {
302
268
  },
303
- onSearchSelect: a = ({ detailUrl: i }) => {
304
- window.location.href = i;
269
+ onSearchSelect: a = ({ detailUrl: p }) => {
270
+ window.location.href = p;
305
271
  },
306
- minItemWidth: d = 400,
307
- queryFilter: c = !0,
308
- layout: s = {},
309
- wrapChildren: f = (i) => i,
310
- extraFilter: m = (i) => i,
311
- baseSearch: k = !1,
312
- fetchCategoryDelay: F = 0,
272
+ minItemWidth: d = 350,
273
+ queryFilter: u = !0,
274
+ layout: i = {},
275
+ wrapChildren: g = (p) => p,
276
+ extraFilter: h = (p) => p,
277
+ baseSearch: m = !1,
278
+ fetchCategoryDelay: C = 0,
313
279
  showResourcesSwitch: R = !1,
314
- showCategory: S = !0,
315
- tagFilters: u = [],
316
- children: x,
317
- storeVersion: h,
318
- endpoint: g,
319
- blockletRender: v
320
- } = e, _ = Ae(l, h), $ = M(() => Ie({ baseURL: g, headers: _ }), [g]), y = { sortBy: "popularity", sortDirection: "desc", ...o };
321
- !y.category && !s.showExplore && (y.category = "All");
322
- const N = y.category, We = gt({
323
- currentPage: T.currentPage,
324
- pageSize: Qt() ? T.mobilePageSize : T.pageSize,
325
- defaultCurrentPage: T.defaultCurrentPage
326
- }), [Ve, Ue] = q(null), A = qt($, y, We, Ue), {
327
- data: Y = [],
328
- error: Ge,
329
- loading: He,
330
- run: se
331
- } = Wt($), J = M(() => {
332
- const i = mt(Y, [(P) => P.name], ["asc"]), b = i.findIndex((P) => P.name === "All" || P.locales.en === "All");
333
- return b > -1 ? [{ ...i[b], _id: "All" }, ...i.slice(0, b), ...i.slice(b + 1)] : i;
334
- }, [Y]), ce = M(
335
- () => {
336
- var i;
337
- return m(((i = A.data) == null ? void 0 : i.list) || []) || [];
338
- },
339
- [A.data, m]
340
- ), de = Z(er(r), [r]), Qe = M(() => Gt(J, r), [J, r]), Xe = Ut(de), Ye = {
341
- errors: { fetchBlockletsError: Ve, fetchCategoriesError: Ge },
280
+ showCategory: A = !0,
281
+ tagFilters: c = [],
282
+ children: k,
283
+ storeVersion: x,
284
+ endpoint: B,
285
+ blockletRender: s
286
+ } = e, y = ze(l, x), T = D(() => Ce({ baseURL: B, headers: y }), [B]), P = { sortBy: "popularity", sortDirection: "desc", ...o };
287
+ !P.category && !i.showExplore && (P.category = "All");
288
+ const [Ne, $e] = F(""), We = P.category, {
289
+ data: H = [],
290
+ error: je,
291
+ loading: qe,
292
+ run: le
293
+ } = Dt(T), G = D(() => {
294
+ const p = ft(H, [(_) => _.name], ["asc"]), b = p.findIndex((_) => _.name === "All" || _.locales.en === "All");
295
+ return b > -1 ? [{ ...p[b], _id: "All" }, ...p.slice(0, b), ...p.slice(b + 1)] : p;
296
+ }, [H]), ie = X(Ut(r), [r]), Ue = D(() => Nt(G, r), [G, r]), Ve = Mt(ie), He = {
297
+ errors: { fetchCategoriesError: je },
342
298
  loadings: {
343
- fetchBlockletsLoading: A.loading,
344
- fetchCategoriesLoading: He,
345
- loadingMore: A.loadingMore
299
+ fetchCategoriesLoading: qe
346
300
  },
347
- endpoint: g,
348
- queryFilter: c,
301
+ extraFilter: h,
302
+ endpoint: B,
303
+ queryFilter: u,
349
304
  layout: {
350
- showExplore: s.showExplore ?? !1,
351
- showCategory: s.showCategory ?? !0,
352
- showTitle: s.showTitle ?? !0,
353
- showSearch: s.showSearch ?? !0
305
+ showExplore: i.showExplore ?? !1,
306
+ showCategory: i.showCategory ?? !0,
307
+ showTitle: i.showTitle ?? !0,
308
+ showSearch: i.showSearch ?? !0
354
309
  },
355
310
  minItemWidth: d,
356
- blockletList: ce,
357
- total: ((ue = A.data) == null ? void 0 : ue.total) || 0,
358
- wrapChildren: f,
359
- t: de,
360
- storeVersion: h,
311
+ wrapChildren: g,
312
+ t: ie,
313
+ storeVersion: x,
361
314
  serverVersion: l,
362
- filters: y,
363
- selectedCategory: N,
364
- categoryList: J,
365
- blockletRender: v,
315
+ filters: P,
316
+ selectedCategory: We,
317
+ categoryList: G,
318
+ blockletRender: s,
366
319
  locale: r,
367
- categoryOptions: Qe,
368
- priceOptions: Xe,
369
- storeApi: $,
370
- baseSearch: k,
320
+ categoryOptions: Ue,
321
+ priceOptions: Ve,
322
+ storeApi: T,
323
+ baseSearch: m,
371
324
  showResourcesSwitch: R,
372
- showCategory: S,
373
- tagFilters: u,
374
- hasNextPage: !A.noMore,
325
+ showCategory: A,
326
+ tagFilters: c,
375
327
  onFilterChange: n,
376
- cleanFilter: (i) => {
377
- const b = i ? bt(y, (P, O) => i == null ? void 0 : i.includes(O)) : {};
328
+ cleanFilter: (p) => {
329
+ const b = p ? mt(P, (_, Ge) => p == null ? void 0 : p.includes(Ge)) : {};
378
330
  n(b);
379
331
  },
380
- handleSort: (i) => {
381
- const b = { ...y, sortBy: i, sortDirection: i === "nameAsc" ? "asc" : "desc" };
332
+ handleSort: (p) => {
333
+ const b = { ...P, sortBy: p, sortDirection: p === "nameAsc" ? "asc" : "desc" };
382
334
  n(b);
383
335
  },
384
- handleKeyword: (i) => {
385
- const b = { ...y, category: void 0, keyword: i || void 0 };
336
+ handleKeyword: (p) => {
337
+ const b = { ...P, category: void 0, keyword: p || void 0 };
386
338
  n(b);
387
339
  },
388
- handlePrice: (i) => {
389
- const b = { ...y, price: i === y.price ? void 0 : i };
340
+ handlePrice: (p) => {
341
+ const b = { ...P, price: p === P.price ? void 0 : p };
390
342
  n(b);
391
343
  },
392
- handleCategory: (i) => {
393
- const b = i === "all" || i === y.category ? "" : i, P = { ...y, category: b };
394
- n(P);
344
+ handleCategory: (p) => {
345
+ const b = p === "all" || p === P.category ? "" : p, _ = { ...P, category: b };
346
+ n(_);
395
347
  },
396
- handleDeveloper: (i) => {
397
- const b = { ...y, owner: i || void 0 };
348
+ handleDeveloper: (p) => {
349
+ const b = { ...P, owner: p || void 0 };
398
350
  n(b);
399
351
  },
400
- handlePage: (i) => {
401
- const b = { ...y, currentPage: i };
352
+ handlePage: (p) => {
353
+ const b = { ...P, currentPage: p };
402
354
  n(b);
403
355
  },
404
356
  handleSwitchShowResources: () => {
405
- const i = { ...y };
406
- n(i);
357
+ const p = { ...P };
358
+ n(p);
407
359
  },
408
- loadMore: A.loadMore,
409
- getCategoryLocale: (i) => {
410
- if (!i)
360
+ getCategoryLocale: (p) => {
361
+ if (!p)
411
362
  return null;
412
- const b = Y.find((P) => P._id === i);
363
+ const b = H.find((_) => _._id === p);
413
364
  return b ? b.locales[r] || b.locales.en : null;
414
365
  },
415
366
  get developerName() {
416
- var b, P;
417
- const i = ce.find((O) => {
418
- var pe;
419
- return ((pe = O == null ? void 0 : O.owner) == null ? void 0 : pe.did) === y.owner;
420
- });
421
- return ((b = i == null ? void 0 : i.owner) == null ? void 0 : b.fullName) || ((P = i == null ? void 0 : i.author) == null ? void 0 : P.name) || "";
367
+ return Ne;
422
368
  },
369
+ updateDeveloperName: $e,
423
370
  handleSearchSelect: a
424
371
  };
425
- return W(() => {
426
- setTimeout(se, F || 0);
427
- }, [g, se, F]), /* @__PURE__ */ t(tr, { value: Ye, children: x });
372
+ return N(() => {
373
+ setTimeout(le, C || 0);
374
+ }, [B, le, C]), /* @__PURE__ */ t(Vt, { value: He, children: k });
375
+ }
376
+ function S() {
377
+ const e = ve(Fe);
378
+ return e || _e;
379
+ }
380
+ const ue = "__FREE_TEXT__";
381
+ function Gt() {
382
+ const e = K(null), r = K(!1), [o, l] = F(!1), [n, a] = F(""), { storeApi: d, filters: u, endpoint: i, handleKeyword: g, t: h, handleSearchSelect: m } = S(), C = async (s) => {
383
+ const { data: y } = await d.get(I.blockletsPath, { params: s });
384
+ return y.dataList || [];
385
+ }, { loading: R, data: A, run: c } = U(
386
+ (s) => s ? C({
387
+ sortBy: I.nameDesc,
388
+ page: 1,
389
+ pageSize: 10,
390
+ keyword: s
391
+ }) : Promise.resolve([]),
392
+ {
393
+ manual: !0
394
+ }
395
+ );
396
+ N(() => {
397
+ c(u.keyword), a(u.keyword || "");
398
+ }, [u.keyword, c]), Ct(
399
+ "ctrl + k, command + k",
400
+ (s) => {
401
+ var y, T;
402
+ return s.stopPropagation(), s.preventDefault(), (T = (y = e.current) == null ? void 0 : y.querySelector("input")) == null || T.focus(), !1;
403
+ },
404
+ { enableOnTags: ["INPUT"] }
405
+ );
406
+ const k = Se((s) => c(s), { wait: 300 }), x = { name: ue, title: n, did: "" };
407
+ return /* @__PURE__ */ t(v, { overflow: "hidden", children: /* @__PURE__ */ t(
408
+ Qe,
409
+ {
410
+ ref: e,
411
+ open: !!n && o,
412
+ size: "small",
413
+ onOpen: () => {
414
+ l(!0);
415
+ },
416
+ onClose: (s, y) => {
417
+ l(!1), y === "selectOption" && !r.current && g(n);
418
+ },
419
+ options: n ? [x, ...A || []] : [],
420
+ renderOption: (s, y) => /* @__PURE__ */ f(v, { component: "li", ...s, gap: 1, children: [
421
+ B(y),
422
+ y.title
423
+ ] }),
424
+ value: x,
425
+ onChange: (s, y) => {
426
+ y != null && y.did && (r.current = !0, m({
427
+ blocklet: y,
428
+ detailUrl: ce(i, "blocklets", y.did),
429
+ storeUrl: i
430
+ }));
431
+ },
432
+ inputValue: n,
433
+ onInputChange: (s, y, T) => {
434
+ a(y), r.current = !1, k.run(y), T === "clear" && g("");
435
+ },
436
+ isOptionEqualToValue: (s, y) => s.name === y.name,
437
+ getOptionLabel: (s) => s.title,
438
+ getOptionKey: (s) => s.name,
439
+ noOptionsText: h("blocklet.noResults"),
440
+ loading: R,
441
+ autoHighlight: !0,
442
+ forcePopupIcon: !1,
443
+ slotProps: { paper: { sx: { mt: 0.5, minWidth: "100%", width: "fit-content" } } },
444
+ sx: {
445
+ bgcolor: "#F9FAFB",
446
+ borderRadius: "8px",
447
+ overflow: "hidden",
448
+ ".MuiAutocomplete-clearIndicator": { visibility: n ? "visible" : "hidden" },
449
+ ".MuiOutlinedInput-notchedOutline": {
450
+ borderRadius: "8px",
451
+ borderColor: "transparent"
452
+ },
453
+ "&&:hover .MuiOutlinedInput-notchedOutline, &&.Mui-focused .MuiOutlinedInput-notchedOutline": {
454
+ borderColor: "divider"
455
+ }
456
+ },
457
+ renderInput: (s) => /* @__PURE__ */ t(
458
+ Xe,
459
+ {
460
+ ...s,
461
+ InputProps: {
462
+ ...s.InputProps,
463
+ autoFocus: !0,
464
+ placeholder: h("common.searchStore"),
465
+ className: "bl-autocomplete-input",
466
+ value: n,
467
+ startAdornment: /* @__PURE__ */ t(v, { sx: { display: "flex", pl: 0.5, alignItems: "center", color: "text.lighter" }, children: R ? /* @__PURE__ */ t(vt, { color: "inherit", size: 16 }) : /* @__PURE__ */ t(Y, { sx: { fontSize: 16 } }) })
468
+ }
469
+ }
470
+ ),
471
+ filterOptions: (s) => s
472
+ }
473
+ ) });
474
+ function B(s) {
475
+ if (s.name === ue)
476
+ return /* @__PURE__ */ t(v, { width: 20, display: "flex", justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ t(Y, { sx: { fontSize: 16 } }) });
477
+ let y = "";
478
+ return s.logo && (y = ce(i, "assets", s.did, Ae(s.logo, 20, s.version))), /* @__PURE__ */ t(Be, { src: y, size: 20 });
479
+ }
428
480
  }
429
- function B() {
430
- const e = Te(Ne);
431
- return e || Ee;
481
+ function re({ placeholder: e, ...r }) {
482
+ const { filters: o, handleKeyword: l } = S(), [n, a] = F(o.keyword || ""), d = Se(l, { wait: 300 }), u = (g) => {
483
+ const { value: h } = g.target;
484
+ a(h), d.run(h);
485
+ }, i = () => {
486
+ a(""), l();
487
+ };
488
+ return N(() => {
489
+ a(o.keyword || "");
490
+ }, [o.keyword]), /* @__PURE__ */ t(
491
+ Qt,
492
+ {
493
+ inputProps: {
494
+ "data-cy": "search-blocklet"
495
+ },
496
+ startAdornment: /* @__PURE__ */ t(ae, { position: "start", children: /* @__PURE__ */ t(Xt, {}) }),
497
+ onChange: u,
498
+ placeholder: e,
499
+ value: n,
500
+ title: e,
501
+ "data-cy": "search",
502
+ endAdornment: n && /* @__PURE__ */ t(ae, { position: "end", children: /* @__PURE__ */ t(Kt, { "data-cy": "search-delete", onClick: i }) }),
503
+ ...r
504
+ }
505
+ );
432
506
  }
433
- function De({
507
+ re.propTypes = {
508
+ placeholder: w.string
509
+ };
510
+ re.defaultProps = {
511
+ placeholder: "Type to search..."
512
+ };
513
+ const Qt = E(Ke)`
514
+ background-color: ${(e) => e.theme.palette.grey[50]};
515
+ font-size: 14px;
516
+ border-radius: 6px;
517
+ width: 100%;
518
+ .MuiInputBase-input {
519
+ padding: 8px 0 8px 10px;
520
+ }
521
+ .MuiOutlinedInput-notchedOutline {
522
+ border: none;
523
+ }
524
+ .Mui-focused {
525
+ background-color: #f6f6f6;
526
+ .MuiInputBase-input::placeholder {
527
+ color: transparent;
528
+ }
529
+ }
530
+ `, Xt = E(Y)`
531
+ color: ${(e) => e.theme.palette.grey[500]};
532
+ font-size: 28px;
533
+ @media (max-width: ${(e) => e.theme.breakpoints.values.md}px) {
534
+ font-size: 24px;
535
+ }
536
+ `, Kt = E(we)`
537
+ color: ${(e) => e.theme.palette.grey[500]};
538
+ font-size: 16px;
539
+ cursor: pointer;
540
+ `;
541
+ function Ee({
434
542
  children: e,
435
543
  onClick: r,
436
- size: o = 32
544
+ size: o = 32,
545
+ ...l
437
546
  }) {
438
547
  return /* @__PURE__ */ t(
439
- te,
548
+ J,
440
549
  {
550
+ ...l,
441
551
  onClick: r,
442
552
  variant: "outlined",
443
- sx: {
444
- minWidth: o,
445
- height: o,
446
- p: 0,
447
- borderColor: "divider",
448
- "&:hover": {
449
- borderColor: "divider"
553
+ sx: [
554
+ {
555
+ minWidth: o,
556
+ height: o,
557
+ p: 0,
558
+ borderColor: "divider",
559
+ "&:hover": {
560
+ borderColor: "divider"
561
+ },
562
+ borderRadius: 2,
563
+ color: "text.secondary"
450
564
  },
451
- borderRadius: 2,
452
- color: "text.secondary"
453
- },
565
+ ...Array.isArray(l.sx) ? l.sx : [l.sx]
566
+ ],
454
567
  children: e
455
568
  }
456
569
  );
457
570
  }
458
- function V(e, r) {
571
+ function W(e, r) {
459
572
  return e === void 0 ? r : e;
460
573
  }
461
- function Q({
574
+ function oe({
462
575
  xs: e,
463
576
  sm: r,
464
577
  md: o,
@@ -466,99 +579,96 @@ function Q({
466
579
  xl: n,
467
580
  exact: a
468
581
  }) {
469
- const d = ve(), c = D(d.breakpoints.down("sm")), s = D(d.breakpoints.between("sm", "md")), f = D(d.breakpoints.between("md", "lg")), m = D(d.breakpoints.between("lg", "xl"));
582
+ const d = ge(), u = O(d.breakpoints.down("sm")), i = O(d.breakpoints.between("sm", "md")), g = O(d.breakpoints.between("md", "lg")), h = O(d.breakpoints.between("lg", "xl"));
470
583
  if (a)
471
- return c ? e || null : s ? r || null : f ? o || null : m ? l || null : n || null;
472
- let k = e;
473
- return c || (k = V(r, k), s) || (k = V(o, k), f) || (k = V(l, k), m) ? k : V(n, k);
584
+ return u ? e || null : i ? r || null : g ? o || null : h ? l || null : n || null;
585
+ let m = e;
586
+ return u || (m = W(r, m), i) || (m = W(o, m), g) || (m = W(l, m), h) ? m : W(n, m);
474
587
  }
475
- function or({ children: e }) {
476
- const { open: r, toggleOpen: o } = ne();
588
+ function Yt({ children: e }) {
589
+ const { open: r, toggleOpen: o } = te();
477
590
  return /* @__PURE__ */ t(
478
- Q,
591
+ oe,
479
592
  {
480
- xs: /* @__PURE__ */ t(Je, { open: r, onClose: () => o(!1), children: e }),
481
- md: /* @__PURE__ */ t(C, { children: e })
593
+ xs: /* @__PURE__ */ t(Ye, { open: r, onClose: () => o(!1), children: e }),
594
+ md: /* @__PURE__ */ t(v, { children: e })
482
595
  }
483
596
  );
484
597
  }
485
- const nr = E(te)`
598
+ const Jt = E(J)`
486
599
  border-radius: 4px;
487
- `, le = dt(({ children: e, rounded: r, loading: o, disabled: l, ...n }, a) => /* @__PURE__ */ t(
488
- nr,
600
+ `, ne = pt(({ children: e, rounded: r, loading: o, disabled: l, ...n }, a) => /* @__PURE__ */ t(
601
+ Jt,
489
602
  {
490
603
  ref: a,
491
604
  disableElevation: !0,
492
605
  disabled: l || o,
493
606
  ...n,
494
- startIcon: o && /* @__PURE__ */ t(re, { size: "1em" }),
607
+ startIcon: o && /* @__PURE__ */ t(Z, { size: "1em" }),
495
608
  children: e
496
609
  }
497
610
  ));
498
- le.propTypes = {
611
+ ne.propTypes = {
499
612
  children: w.any,
500
613
  rounded: w.bool,
501
614
  loading: w.bool,
502
615
  disabled: w.bool
503
616
  };
504
- le.defaultProps = {
617
+ ne.defaultProps = {
505
618
  children: null,
506
619
  rounded: !1,
507
620
  loading: !1,
508
621
  disabled: !1
509
622
  };
510
- function X({ title: e, value: r, icon: o, prepend: l, options: n, onChange: a, itemRender: d, ...c }) {
511
- const s = G(null), f = xe(), [m, k] = q(!1), [F, R] = q(r !== null ? r : ""), S = D(f.breakpoints.down("sm"));
512
- W(() => {
623
+ function V({ title: e, value: r, icon: o, prepend: l, options: n, onChange: a, itemRender: d, ...u }) {
624
+ const i = K(null), g = fe(), [h, m] = F(!1), [C, R] = F(r !== null ? r : ""), A = O(g.breakpoints.down("sm"));
625
+ N(() => {
513
626
  R(r !== null ? r : "");
514
627
  }, [r]);
515
- const u = Z(() => {
516
- k(!1);
517
- }, []), x = Z(() => {
518
- k(!0);
628
+ const c = X(() => {
629
+ m(!1);
630
+ }, []), k = X(() => {
631
+ m(!0);
519
632
  }, []);
520
- function h(v) {
521
- R(v.value), a(v.value), S && u();
633
+ function x(s) {
634
+ R(s.value), a(s.value), A && c();
522
635
  }
523
- function g(v) {
524
- return v === F;
636
+ function B(s) {
637
+ return s === C;
525
638
  }
526
- return /* @__PURE__ */ p(z, { children: [
527
- /* @__PURE__ */ p(
528
- lr,
639
+ return /* @__PURE__ */ f(M, { children: [
640
+ /* @__PURE__ */ f(
641
+ Zt,
529
642
  {
530
- ref: s,
531
- onClick: x,
643
+ ref: i,
644
+ onClick: k,
532
645
  variant: "outlined",
533
646
  size: "small",
534
- className: ["my-select__selector", Pt(F) ? "" : "my-select__selector--active"].join(" "),
647
+ className: ["my-select__selector", Bt(C) ? "" : "my-select__selector--active"].join(" "),
535
648
  sx: { minWidth: "auto" },
536
- ...c,
649
+ ...u,
537
650
  children: [
538
651
  /* @__PURE__ */ t("div", { className: "my-select__icon", children: o }),
539
652
  e,
540
- /* @__PURE__ */ t(Ze, { className: "my-select__arrowdown", component: Rt, fontSize: "small" })
653
+ /* @__PURE__ */ t(Ze, { className: "my-select__arrowdown", component: Pt, fontSize: "small" })
541
654
  ]
542
655
  }
543
656
  ),
544
- /* @__PURE__ */ t(et, { open: m, anchorEl: s.current, transition: !0, sx: { zIndex: "9999" }, children: ({ TransitionProps: v, placement: _ }) => /* @__PURE__ */ t(tt, { ...v, sx: { transformOrigin: _ === "bottom" ? "center top" : "center bottom" }, children: /* @__PURE__ */ t(rt, { children: /* @__PURE__ */ t(ot, { onClickAway: u, children: /* @__PURE__ */ p(ar, { autoFocusItem: m, onMouseEnter: x, onMouseLeave: u, children: [
657
+ /* @__PURE__ */ t(et, { open: h, anchorEl: i.current, transition: !0, sx: { zIndex: "9999" }, children: ({ TransitionProps: s, placement: y }) => /* @__PURE__ */ t(tt, { ...s, sx: { transformOrigin: y === "bottom" ? "center top" : "center bottom" }, children: /* @__PURE__ */ t(rt, { children: /* @__PURE__ */ t(ot, { onClickAway: c, children: /* @__PURE__ */ f(er, { autoFocusItem: h, onMouseEnter: k, onMouseLeave: c, children: [
545
658
  l,
546
- n.map(($) => d ? d($) : /* @__PURE__ */ t(
547
- nt,
548
- {
549
- onClick: () => h($),
550
- className: [
551
- "my-select__option",
552
- g($.value) ? "my-select__option--active" : ""
553
- ].join(" "),
554
- children: $.name
555
- },
556
- $.value
557
- ))
659
+ n.map((T) => d ? d(T) : /* @__PURE__ */ f(nt, { onClick: () => x(T), children: [
660
+ /* @__PURE__ */ t(
661
+ St,
662
+ {
663
+ sx: { mr: 1, fontSize: 16, visibility: B(T.value) ? "visible" : "hidden" }
664
+ }
665
+ ),
666
+ T.name
667
+ ] }, T.value))
558
668
  ] }) }) }) }) })
559
669
  ] });
560
670
  }
561
- X.propTypes = {
671
+ V.propTypes = {
562
672
  options: w.array.isRequired,
563
673
  value: w.oneOfType([w.string, w.number, w.array]),
564
674
  onChange: w.func,
@@ -567,7 +677,7 @@ X.propTypes = {
567
677
  icon: w.any,
568
678
  prepend: w.any
569
679
  };
570
- X.defaultProps = {
680
+ V.defaultProps = {
571
681
  value: null,
572
682
  icon: null,
573
683
  prepend: null,
@@ -575,7 +685,7 @@ X.defaultProps = {
575
685
  onChange: () => {
576
686
  }
577
687
  };
578
- const lr = E(le)`
688
+ const Zt = E(ne)`
579
689
  border: 1px solid #f0f0f0;
580
690
  padding: 6px 8px 6px 12px;
581
691
  font-weight: ${(e) => e.theme.typography.fontWeightRegular};
@@ -606,7 +716,7 @@ const lr = E(le)`
606
716
  margin-right: 3px;
607
717
  }
608
718
  }
609
- `, ar = E(Ke)`
719
+ `, er = E(Je)`
610
720
  .my-select__option__icon {
611
721
  color: transparent;
612
722
  font-size: 14px;
@@ -623,11 +733,11 @@ const lr = E(le)`
623
733
  }
624
734
  }
625
735
  `;
626
- function Me() {
736
+ function Oe() {
627
737
  var d;
628
- const { filters: e, handleSort: r, handlePrice: o, t: l } = B(), n = ze(l), a = ((d = n.find((c) => c.value === e.sortBy)) == null ? void 0 : d.name) || l("sort.sort");
629
- return /* @__PURE__ */ p(
630
- I,
738
+ const { filters: e, handleSort: r, handlePrice: o, t: l } = S(), n = Le(l), a = ((d = n.find((u) => u.value === e.sortBy)) == null ? void 0 : d.name) || l("sort.sort");
739
+ return /* @__PURE__ */ f(
740
+ z,
631
741
  {
632
742
  direction: { xs: "row", md: "column" },
633
743
  alignItems: { xs: "center", md: "flex-start" },
@@ -636,22 +746,22 @@ function Me() {
636
746
  justifyContent: "space-between",
637
747
  children: [
638
748
  /* @__PURE__ */ t(
639
- Ce,
749
+ ye,
640
750
  {
641
751
  control: /* @__PURE__ */ t(
642
- Se,
752
+ xe,
643
753
  {
644
754
  checked: e.price === "free",
645
755
  size: "small",
646
756
  sx: { "& .MuiSvgIcon-fontSizeSmall": { fontSize: 16, color: "text.lighter" } },
647
- onChange: (c) => o(c.target.checked ? "free" : "")
757
+ onChange: (u) => o(u.target.checked ? "free" : "")
648
758
  }
649
759
  ),
650
760
  label: l("blocklet.free")
651
761
  }
652
762
  ),
653
763
  /* @__PURE__ */ t(
654
- X,
764
+ V,
655
765
  {
656
766
  value: e.sortBy,
657
767
  options: n,
@@ -666,14 +776,16 @@ function Me() {
666
776
  }
667
777
  );
668
778
  }
669
- function ir() {
670
- const { selectedCategory: e, handleCategory: r, t: o, categoryOptions: l, filters: n, cleanFilter: a, loadings: d, layout: c } = B(), { toggleOpen: s } = ne();
671
- return c.showCategory ? /* @__PURE__ */ p(or, { children: [
779
+ function tr() {
780
+ const { selectedCategory: e, handleCategory: r, t: o, categoryOptions: l, filters: n, cleanFilter: a, loadings: d, layout: u, baseSearch: i } = S(), { toggleOpen: g } = te();
781
+ return N(() => {
782
+ g(!1);
783
+ }, [n.category, n.owner, n.keyword, n.sortBy, n.sortDirection, n.resourceType]), u.showCategory ? /* @__PURE__ */ f(Yt, { children: [
672
784
  /* @__PURE__ */ t(
673
- Q,
785
+ oe,
674
786
  {
675
- xs: /* @__PURE__ */ p(
676
- I,
787
+ xs: /* @__PURE__ */ f(
788
+ z,
677
789
  {
678
790
  direction: "row",
679
791
  justifyContent: "space-between",
@@ -684,62 +796,65 @@ function ir() {
684
796
  borderBottom: 1,
685
797
  borderColor: "divider",
686
798
  children: [
687
- /* @__PURE__ */ t(De, { onClick: () => s(!1), children: /* @__PURE__ */ t(Re, {}) }),
688
- /* @__PURE__ */ t(L, { flex: 1, variant: "body1", fontWeight: "fontWeightMedium", children: "Categories" })
799
+ /* @__PURE__ */ t(Ee, { onClick: () => g(!1), children: /* @__PURE__ */ t(we, {}) }),
800
+ /* @__PURE__ */ t(L, { flex: 1, variant: "body1", fontWeight: "fontWeightMedium", children: o("common.category") })
689
801
  ]
690
802
  }
691
803
  ),
692
804
  md: null
693
805
  }
694
806
  ),
695
- /* @__PURE__ */ t(
696
- I,
807
+ /* @__PURE__ */ f(
808
+ z,
697
809
  {
698
810
  visibility: d.fetchCategoriesLoading ? "hidden" : "visible",
699
811
  width: { xs: 268, md: 200 },
700
812
  boxSizing: "content-box",
701
813
  p: { xs: 2, md: 0 },
702
814
  pr: { md: 6 },
703
- children: n.keyword ? /* @__PURE__ */ t(Me, {}) : /* @__PURE__ */ p(z, { children: [
704
- c.showExplore && /* @__PURE__ */ p(C, { display: "flex", alignItems: "center", gap: 1, mb: 3, pb: 3, borderBottom: 1, borderColor: "divider", children: [
705
- /* @__PURE__ */ t(Be, { icon: ct }),
706
- /* @__PURE__ */ t(
815
+ children: [
816
+ u.showSearch ? /* @__PURE__ */ t(v, { className: "filter-bar", mb: 3, pb: 3, borderBottom: 1, borderColor: "divider", children: i ? /* @__PURE__ */ t(re, { className: "bl-search-container", placeholder: o("common.searchStore"), sx: { pl: 1.5 } }) : /* @__PURE__ */ t(Gt, {}) }) : null,
817
+ n.keyword ? /* @__PURE__ */ t(Oe, {}) : /* @__PURE__ */ f(M, { children: [
818
+ u.showExplore && /* @__PURE__ */ f(v, { display: "flex", alignItems: "center", gap: 1, mb: 3, pb: 3, borderBottom: 1, borderColor: "divider", children: [
819
+ /* @__PURE__ */ t(be, { icon: ut }),
820
+ /* @__PURE__ */ t(
821
+ L,
822
+ {
823
+ variant: "body1",
824
+ color: e ? "text.lighter" : "text.primary",
825
+ fontWeight: e ? void 0 : "fontWeightMedium",
826
+ sx: { cursor: "pointer" },
827
+ onClick: () => {
828
+ g(!1), a();
829
+ },
830
+ children: o("explore.title")
831
+ }
832
+ )
833
+ ] }),
834
+ !!l.length && /* @__PURE__ */ t(z, { gap: 2, children: l.map((h) => /* @__PURE__ */ t(
707
835
  L,
708
836
  {
709
837
  variant: "body1",
710
- color: e ? "text.lighter" : "text.primary",
711
- fontWeight: e ? void 0 : "fontWeightMedium",
838
+ title: h.name,
712
839
  sx: { cursor: "pointer" },
840
+ "data-cy": "filter",
841
+ color: e === h.value ? "text.primary" : "text.lighter",
842
+ textTransform: "capitalize",
713
843
  onClick: () => {
714
- s(!1), a();
844
+ e === h.value ? a() : r(h.value), g(!1);
715
845
  },
716
- children: o("explore.title")
717
- }
718
- )
719
- ] }),
720
- !!l.length && /* @__PURE__ */ t(I, { gap: 2, children: l.map((f) => /* @__PURE__ */ t(
721
- L,
722
- {
723
- variant: "body1",
724
- title: f.name,
725
- sx: { cursor: "pointer" },
726
- "data-cy": "filter",
727
- color: e === f.value ? "text.primary" : "text.lighter",
728
- textTransform: "capitalize",
729
- onClick: () => {
730
- e === f.value ? a() : r(f.value), s(!1);
846
+ children: h.name
731
847
  },
732
- children: f.name
733
- },
734
- f.value
735
- )) })
736
- ] })
848
+ h.value
849
+ )) })
850
+ ] })
851
+ ]
737
852
  }
738
853
  )
739
854
  ] }) : null;
740
855
  }
741
- function Oe() {
742
- const { endpoint: e, serverVersion: r, storeVersion: o } = B(), l = Ae(r, o), n = M(() => Ie({
856
+ function De() {
857
+ const { endpoint: e, serverVersion: r, storeVersion: o } = S(), l = ze(r, o), n = D(() => Ce({
743
858
  baseURL: e,
744
859
  headers: l
745
860
  }), [e]);
@@ -749,21 +864,21 @@ function Oe() {
749
864
  return d;
750
865
  },
751
866
  post: async (a, d) => {
752
- const { data: c } = await n.post(a, d);
753
- return c;
867
+ const { data: u } = await n.post(a, d);
868
+ return u;
754
869
  }
755
870
  };
756
871
  }
757
- const je = ut(function(r) {
758
- return /* @__PURE__ */ t(Fe, { height: 60, display: "flex", alignItems: "center", justifyContent: "center", ...r, children: /* @__PURE__ */ t(re, {}) });
872
+ const Me = ht(function(r) {
873
+ return /* @__PURE__ */ t(Te, { height: 60, display: "flex", alignItems: "center", justifyContent: "center", ...r, children: /* @__PURE__ */ t(Z, {}) });
759
874
  });
760
- function ge({
875
+ function pe({
761
876
  icon: e,
762
877
  children: r,
763
878
  maxWidth: o = 100,
764
879
  title: l
765
880
  }) {
766
- return (r === 0 || r) && /* @__PURE__ */ p(I, { direction: "row", alignItems: "center", gap: 1, sx: { maxWidth: o, overflow: "hidden" }, children: [
881
+ return (r === 0 || r) && /* @__PURE__ */ f(z, { direction: "row", alignItems: "center", gap: 1, sx: { maxWidth: o, overflow: "hidden" }, children: [
767
882
  e,
768
883
  /* @__PURE__ */ t(
769
884
  L,
@@ -777,17 +892,17 @@ function ge({
777
892
  )
778
893
  ] });
779
894
  }
780
- const ye = 292;
781
- function sr() {
782
- var R, S;
783
- const { t: e } = B(), { get: r } = Oe(), o = ve(), l = D(o.breakpoints.down("md")), n = ((S = (R = window.blocklet) == null ? void 0 : R.preferences) == null ? void 0 : S.homeBanner) || [], { data: a = [], error: d } = oe(async () => {
784
- const u = await r(
785
- Le(T.blockletsPath, { didList: n.map((x) => x.did).join(",") })
895
+ const he = 292;
896
+ function rr() {
897
+ var R, A;
898
+ const { t: e } = S(), { get: r } = De(), o = ge(), l = O(o.breakpoints.down("md")), n = ((A = (R = window.blocklet) == null ? void 0 : R.preferences) == null ? void 0 : A.homeBanner) || [], { data: a = [], error: d } = U(async () => {
899
+ const c = await r(
900
+ Pe(I.blockletsPath, { didList: n.map((k) => k.did).join(",") })
786
901
  );
787
- return u != null && u.dataList ? n.map((x) => u.dataList.find((h) => h.did === x.did)) : [];
902
+ return c != null && c.dataList ? n.map((k) => c.dataList.find((x) => x.did === k.did)) : [];
788
903
  });
789
904
  d && console.error("Get Banner Blocklets error:", d);
790
- const c = {
905
+ const u = {
791
906
  position: "absolute",
792
907
  top: "50%",
793
908
  transform: "translateY(-50%)",
@@ -795,71 +910,88 @@ function sr() {
795
910
  cursor: "pointer",
796
911
  color: "text.lighter"
797
912
  };
798
- return !d && n.length > 0 ? /* @__PURE__ */ p(z, { children: [
913
+ return !d && n.length > 0 ? /* @__PURE__ */ f(M, { children: [
799
914
  /* @__PURE__ */ t(L, { component: "h2", variant: "h2", mt: { xs: 2, md: 0 }, mb: 3, children: e("explore.title") }),
800
- /* @__PURE__ */ t(C, { height: { xs: "auto", md: ye }, position: "relative", bgcolor: "#F0F7FF", borderRadius: 3, children: /* @__PURE__ */ t(
801
- _t,
915
+ /* @__PURE__ */ t(
916
+ v,
802
917
  {
803
- showNav: !0,
804
- autoPlay: !0,
805
- slideDuration: 1e3,
806
- slideInterval: 5e3,
807
- showPlayButton: !1,
808
- showIndex: !1,
809
- showBullets: !1,
810
- showThumbnails: !1,
811
- showFullscreenButton: !1,
812
- renderLeftNav: (u) => /* @__PURE__ */ t(C, { onClick: u, sx: { display: { xs: "none", md: "block" } }, children: /* @__PURE__ */ t(Ft, { sx: { ...c, left: 5 } }) }),
813
- renderRightNav: (u) => /* @__PURE__ */ t(C, { onClick: u, sx: { display: { xs: "none", md: "block" } }, children: /* @__PURE__ */ t($t, { sx: { ...c, right: 5 } }) }),
814
- items: n.map((u, x) => ({
815
- original: u.did,
816
- renderItem: () => {
817
- var g;
818
- const h = a[x] || {};
819
- return /* @__PURE__ */ p(
820
- I,
821
- {
822
- height: { xs: "auto", md: ye },
823
- display: "flex",
824
- direction: { xs: "column", md: "row" },
825
- justifyContent: "center",
826
- alignItems: { xs: "flex-start", md: "center" },
827
- p: { xs: 2, md: 5 },
828
- gap: { xs: 2, md: 5 },
829
- children: [
830
- s(u.cover || dr(u.did, (g = h.screenshots) == null ? void 0 : g[0])),
831
- /* @__PURE__ */ p(I, { flex: 1, height: "100%", gap: 3, children: [
832
- /* @__PURE__ */ p(C, { flex: 1, children: [
833
- f(u.name || h.title || u.name),
834
- m(u.desc || h.description)
835
- ] }),
836
- h.did && k(h, u.baseNum),
837
- F(u.link, u.did)
838
- ] })
839
- ]
918
+ height: { xs: "auto", md: he },
919
+ position: "relative",
920
+ border: 1,
921
+ borderColor: "divider",
922
+ borderRadius: 3,
923
+ overflow: "hidden",
924
+ children: /* @__PURE__ */ t(
925
+ At,
926
+ {
927
+ showNav: !0,
928
+ autoPlay: !0,
929
+ slideDuration: 1e3,
930
+ slideInterval: 5e3,
931
+ showPlayButton: !1,
932
+ showIndex: !1,
933
+ showBullets: !1,
934
+ showThumbnails: !1,
935
+ showFullscreenButton: !1,
936
+ renderLeftNav: (c) => /* @__PURE__ */ t(v, { onClick: c, sx: { display: { xs: "none", md: "block" } }, children: /* @__PURE__ */ t(It, { sx: { ...u, left: 5 } }) }),
937
+ renderRightNav: (c) => /* @__PURE__ */ t(v, { onClick: c, sx: { display: { xs: "none", md: "block" } }, children: /* @__PURE__ */ t(Lt, { sx: { ...u, right: 5 } }) }),
938
+ items: n.map((c, k) => ({
939
+ original: c.did,
940
+ renderItem: () => {
941
+ var y;
942
+ const x = a[k] || {}, B = c.cover || nr(c.did, (y = x.screenshots) == null ? void 0 : y[0]), s = Ae(B, { h: 400, w: 700 });
943
+ return /* @__PURE__ */ f(
944
+ z,
945
+ {
946
+ height: { xs: "auto", md: he },
947
+ sx: {
948
+ "&::before": {
949
+ content: '""',
950
+ position: "absolute",
951
+ top: 0,
952
+ left: 0,
953
+ right: 0,
954
+ bottom: 0,
955
+ backgroundImage: `url("${s}")`,
956
+ backgroundSize: "cover",
957
+ filter: "blur(8px)",
958
+ opacity: 0.15,
959
+ zIndex: 0
960
+ }
961
+ },
962
+ display: "flex",
963
+ direction: { xs: "column", md: "row" },
964
+ justifyContent: "center",
965
+ alignItems: { xs: "flex-start", md: "center" },
966
+ p: { xs: 2, md: 5 },
967
+ gap: { xs: 2, md: 5 },
968
+ children: [
969
+ i(s),
970
+ /* @__PURE__ */ f(z, { flex: 1, height: "100%", gap: 3, children: [
971
+ /* @__PURE__ */ f(v, { flex: 1, children: [
972
+ g(c.name || x.title || c.name),
973
+ h(c.desc || x.description)
974
+ ] }),
975
+ x.did && m(x, c.baseNum),
976
+ C(c.link, c.did)
977
+ ] })
978
+ ]
979
+ }
980
+ );
840
981
  }
841
- );
982
+ }))
842
983
  }
843
- }))
984
+ )
844
985
  }
845
- ) })
986
+ )
846
987
  ] }) : null;
847
- function s(u) {
848
- return /* @__PURE__ */ t(C, { width: { xs: "100%", md: 338 }, height: 210, borderRadius: 2, overflow: "hidden", position: "relative", children: /* @__PURE__ */ t(
849
- It,
850
- {
851
- src: Vt(u, { h: 400, w: 700 }),
852
- alt: "",
853
- width: l ? void 0 : 338,
854
- height: 210,
855
- style: { objectFit: "cover" }
856
- }
857
- ) });
988
+ function i(c) {
989
+ return /* @__PURE__ */ t(v, { width: { xs: "100%", md: 338 }, height: 210, borderRadius: 2, overflow: "hidden", position: "relative", children: /* @__PURE__ */ t(Tt, { src: c, alt: "", width: l ? void 0 : 338, height: 210, style: { objectFit: "cover" } }) });
858
990
  }
859
- function f(u) {
860
- return /* @__PURE__ */ t(L, { variant: "h2", width: "100%", children: u });
991
+ function g(c) {
992
+ return /* @__PURE__ */ t(L, { variant: "h2", width: "100%", children: c });
861
993
  }
862
- function m(u) {
994
+ function h(c) {
863
995
  return /* @__PURE__ */ t(
864
996
  L,
865
997
  {
@@ -867,6 +999,8 @@ function sr() {
867
999
  color: "text.secondary",
868
1000
  textAlign: "left",
869
1001
  width: "100%",
1002
+ minHeight: 70,
1003
+ maxHeight: 70,
870
1004
  pt: 1,
871
1005
  sx: {
872
1006
  display: "-webkit-box",
@@ -877,20 +1011,20 @@ function sr() {
877
1011
  overflow: "hidden",
878
1012
  WebkitBoxOrient: "vertical"
879
1013
  },
880
- children: u
1014
+ children: c
881
1015
  }
882
1016
  );
883
1017
  }
884
- function k(u, x = 0) {
885
- const { did: h, owner: g, stats: v } = u;
886
- return /* @__PURE__ */ p(C, { display: "flex", alignItems: "center", gap: 2, color: "text.secondary", children: [
887
- /* @__PURE__ */ t(ge, { icon: /* @__PURE__ */ t(Tt, { src: g.avatar, did: h, size: 20, variant: "circle" }), children: g.fullName }),
888
- /* @__PURE__ */ t(ge, { icon: /* @__PURE__ */ t(Be, { icon: Lt }), title: `${v.downloads + x}`, children: cr(v.downloads + x) })
1018
+ function m(c, k = 0) {
1019
+ const { did: x, owner: B, stats: s } = c;
1020
+ return /* @__PURE__ */ f(v, { display: "flex", alignItems: "center", gap: 2, color: "text.secondary", children: [
1021
+ /* @__PURE__ */ t(pe, { icon: /* @__PURE__ */ t(Be, { src: B.avatar, did: x, size: 20, variant: "circle" }), children: B.fullName }),
1022
+ /* @__PURE__ */ t(pe, { icon: /* @__PURE__ */ t(be, { icon: Rt }), title: `${s.downloads + k}`, children: or(s.downloads + k) })
889
1023
  ] });
890
1024
  }
891
- function F(u, x) {
892
- return /* @__PURE__ */ t(lt, { href: u || `/blocklets/${x}`, align: "left", width: 100, children: /* @__PURE__ */ t(
893
- te,
1025
+ function C(c, k) {
1026
+ return /* @__PURE__ */ t(lt, { href: c || `/blocklets/${k}`, align: "left", width: 100, children: /* @__PURE__ */ t(
1027
+ J,
894
1028
  {
895
1029
  variant: "outlined",
896
1030
  size: "small",
@@ -905,35 +1039,35 @@ function sr() {
905
1039
  ) });
906
1040
  }
907
1041
  }
908
- const cr = (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`, dr = (e, r) => e && r ? `/assets/${e}/screenshots/${r}` : "";
909
- function ur({ title: e, blocklets: r }) {
910
- const { blockletRender: o, serverVersion: l } = B();
911
- return /* @__PURE__ */ p(C, { mt: 3, children: [
1042
+ const or = (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`, nr = (e, r) => e && r ? `/assets/${e}/screenshots/${r}` : "";
1043
+ function lr({ title: e, blocklets: r }) {
1044
+ const { blockletRender: o, serverVersion: l } = S();
1045
+ return /* @__PURE__ */ f(v, { mt: 3, children: [
912
1046
  /* @__PURE__ */ t(L, { component: "h3", variant: "h3", sx: { mb: 2 }, children: e }),
913
- /* @__PURE__ */ t(he, { container: !0, spacing: 2, children: r.map((n) => /* @__PURE__ */ t(he, { item: !0, xs: 12, md: 6, p: "2px", "data-blocklet-did": n.did, children: /* @__PURE__ */ t(C, { padding: "1px", children: o({ blocklet: n, blocklets: r, serverVersion: l }) }) }, n.did)) })
1047
+ /* @__PURE__ */ t(se, { container: !0, spacing: 2, children: r.map((n) => /* @__PURE__ */ t(se, { item: !0, xs: 12, md: 6, p: "2px", "data-blocklet-did": n.did, children: /* @__PURE__ */ t(v, { padding: "1px", children: o({ blocklet: n, blocklets: r, serverVersion: l }) }) }, n.did)) })
914
1048
  ] });
915
1049
  }
916
- function pr() {
917
- const { get: e } = Oe(), { t: r } = B(), {
1050
+ function ir() {
1051
+ const { get: e } = De(), { t: r } = S(), {
918
1052
  data: o = [],
919
1053
  error: l,
920
1054
  loading: n
921
- } = oe(async () => {
922
- const a = await e(T.explorePath);
1055
+ } = U(async () => {
1056
+ const a = await e(I.explorePath);
923
1057
  return Array.isArray(a) ? a : [];
924
1058
  });
925
- return l ? /* @__PURE__ */ t(ee, { error: new Error(`Failed to fetch blocklets from ${T.explorePath}`) }) : n ? /* @__PURE__ */ t(je, { mt: 15 }) : /* @__PURE__ */ p(z, { children: [
926
- /* @__PURE__ */ t(sr, {}),
1059
+ return l ? /* @__PURE__ */ t(ee, { error: new Error(`Failed to fetch blocklets from ${I.explorePath}`) }) : n ? /* @__PURE__ */ t(Me, { mt: 15 }) : /* @__PURE__ */ f(M, { children: [
1060
+ /* @__PURE__ */ t(rr, {}),
927
1061
  o.map(
928
- (a) => a.blocklets.length > 0 ? /* @__PURE__ */ t(ur, { title: r(`explore.${a.type}`), blocklets: a.blocklets }, a.type) : null
1062
+ (a) => a.blocklets.length > 0 ? /* @__PURE__ */ t(lr, { title: r(`explore.${a.type}`), blocklets: a.blocklets }, a.type) : null
929
1063
  )
930
1064
  ] });
931
1065
  }
932
- function hr() {
933
- var f;
934
- const { filters: e, handleSort: r, handlePrice: o, t: l, getCategoryLocale: n, developerName: a, handleDeveloper: d } = B(), c = ze(l), s = ((f = c.find((m) => m.value === e.sortBy)) == null ? void 0 : f.name) || l("sort.sort");
935
- return /* @__PURE__ */ p(
936
- I,
1066
+ function ar() {
1067
+ var g;
1068
+ const { filters: e, handleSort: r, handlePrice: o, t: l, getCategoryLocale: n, developerName: a, handleDeveloper: d } = S(), u = Le(l), i = ((g = u.find((h) => h.value === e.sortBy)) == null ? void 0 : g.name) || l("sort.sort");
1069
+ return /* @__PURE__ */ f(
1070
+ z,
937
1071
  {
938
1072
  direction: { xs: "column", md: "row" },
939
1073
  alignItems: { xs: "flex-start", md: "center" },
@@ -944,8 +1078,8 @@ function hr() {
944
1078
  pb: 3,
945
1079
  children: [
946
1080
  /* @__PURE__ */ t(L, { variant: "h2", textTransform: "capitalize", children: n(e.category) }),
947
- /* @__PURE__ */ p(
948
- I,
1081
+ /* @__PURE__ */ f(
1082
+ z,
949
1083
  {
950
1084
  direction: "row",
951
1085
  alignItems: "center",
@@ -953,29 +1087,29 @@ function hr() {
953
1087
  justifyContent: "space-between",
954
1088
  gap: 2,
955
1089
  children: [
956
- e.owner && /* @__PURE__ */ t(at, { label: a, size: "small", onDelete: () => d("") }),
1090
+ e.owner && a && /* @__PURE__ */ t(it, { label: a, size: "small", onDelete: () => d("") }),
957
1091
  /* @__PURE__ */ t(
958
- Ce,
1092
+ ye,
959
1093
  {
960
1094
  sx: { m: 0 },
961
1095
  control: /* @__PURE__ */ t(
962
- Se,
1096
+ xe,
963
1097
  {
964
1098
  checked: e.price === "free",
965
1099
  size: "small",
966
1100
  sx: { p: 0, pr: 1, "& .MuiSvgIcon-fontSizeSmall": { fontSize: 16, color: "text.lighter" } },
967
- onChange: (m) => o(m.target.checked ? "free" : "")
1101
+ onChange: (h) => o(h.target.checked ? "free" : "")
968
1102
  }
969
1103
  ),
970
1104
  label: l("blocklet.free")
971
1105
  }
972
1106
  ),
973
1107
  /* @__PURE__ */ t(
974
- X,
1108
+ V,
975
1109
  {
976
1110
  value: e.sortBy,
977
- options: c,
978
- title: s,
1111
+ options: u,
1112
+ title: i,
979
1113
  onChange: r,
980
1114
  icon: null,
981
1115
  prepend: null,
@@ -989,131 +1123,166 @@ function hr() {
989
1123
  }
990
1124
  );
991
1125
  }
992
- function be() {
993
- const { t: e } = B();
994
- return /* @__PURE__ */ t($e, { style: { textAlign: "center" }, variant: "subtitle2", children: e("blocklet.noResults") });
1126
+ function me() {
1127
+ const { t: e } = S();
1128
+ return /* @__PURE__ */ t(Re, { style: { textAlign: "center" }, variant: "subtitle2", children: e("blocklet.noResults") });
995
1129
  }
996
- function j({ filterTip: e, keywordTip: r }) {
997
- const { t: o, locale: l } = B(), n = () => l === "zh" ? "、" : " , ";
998
- return /* @__PURE__ */ p(Fe, { className: "tips", children: [
1130
+ function $({ filterTip: e, keywordTip: r }) {
1131
+ const { t: o, locale: l } = S(), n = () => l === "zh" ? "、" : " , ";
1132
+ return /* @__PURE__ */ f(Te, { className: "tips", children: [
999
1133
  /* @__PURE__ */ t("span", { style: { marginRight: "16px" }, children: o("blocklet.emptyTip") }),
1000
1134
  e && /* @__PURE__ */ t("span", { children: o("blocklet.filterTip") }),
1001
1135
  e && r && n(),
1002
1136
  r && /* @__PURE__ */ t("span", { children: o("blocklet.keywordTip") })
1003
1137
  ] });
1004
1138
  }
1005
- j.propTypes = {
1139
+ $.propTypes = {
1006
1140
  filterTip: w.bool,
1007
1141
  keywordTip: w.bool
1008
1142
  };
1009
- j.defaultProps = {
1143
+ $.defaultProps = {
1010
1144
  filterTip: !1,
1011
1145
  keywordTip: !1
1012
1146
  };
1013
- function H({ primaryStart: e, primaryEnd: r, filter: o }) {
1014
- return /* @__PURE__ */ p($e, { variant: "subtitle2", children: [
1147
+ function q({ primaryStart: e, primaryEnd: r, filter: o }) {
1148
+ return /* @__PURE__ */ f(Re, { variant: "subtitle2", children: [
1015
1149
  /* @__PURE__ */ t("span", { children: e }),
1016
- /* @__PURE__ */ p("span", { className: "primary", children: [
1150
+ /* @__PURE__ */ f("span", { className: "primary", children: [
1017
1151
  " ",
1018
1152
  o,
1019
1153
  " "
1020
1154
  ] }),
1021
- /* @__PURE__ */ p("span", { children: [
1155
+ /* @__PURE__ */ f("span", { children: [
1022
1156
  r,
1023
1157
  " "
1024
1158
  ] })
1025
1159
  ] });
1026
1160
  }
1027
- H.propTypes = {
1161
+ q.propTypes = {
1028
1162
  primaryStart: w.string.isRequired,
1029
1163
  primaryEnd: w.string.isRequired,
1030
1164
  filter: w.string.isRequired
1031
1165
  };
1032
- function qe({ blocklets: e, ...r }) {
1033
- const {
1034
- blockletRender: o,
1035
- errors: l,
1036
- loadings: n,
1037
- selectedCategory: a,
1038
- getCategoryLocale: d,
1039
- filters: c,
1040
- t: s,
1041
- serverVersion: f,
1042
- hasNextPage: m,
1043
- loadMore: k,
1044
- endpoint: F,
1045
- minItemWidth: R
1046
- } = B(), S = !!a || !!c.price, [u] = At({
1047
- loading: n.fetchBlockletsLoading || n.loadingMore,
1048
- hasNextPage: m,
1049
- onLoadMore: k
1166
+ const sr = (e, r, o, l) => gt(
1167
+ async (n) => {
1168
+ n || (o.currentPage = o.defaultCurrentPage);
1169
+ const { currentPage: a, pageSize: d } = o, u = {
1170
+ ...r,
1171
+ category: r.category === "All" ? "" : r.category,
1172
+ sortBy: I[r.sortBy],
1173
+ page: a,
1174
+ pageSize: d
1175
+ };
1176
+ l(null);
1177
+ const { data: i = {} } = await e.get(I.blockletsPath, { params: u });
1178
+ return o.currentPage++, { page: a, pageSize: d, list: (i == null ? void 0 : i.dataList) || [], total: (i == null ? void 0 : i.total) || 0 };
1179
+ },
1180
+ {
1181
+ isNoMore: (n) => n ? n.page * n.pageSize >= n.total : !1,
1182
+ reloadDeps: [e, Ft(r)],
1183
+ onError: l
1184
+ }
1185
+ );
1186
+ function cr() {
1187
+ var h;
1188
+ const { storeApi: e, filters: r, extraFilter: o, errors: l, updateDeveloperName: n } = S(), a = yt({
1189
+ currentPage: I.currentPage,
1190
+ pageSize: Wt() ? I.mobilePageSize : I.pageSize,
1191
+ defaultCurrentPage: I.defaultCurrentPage
1192
+ }), [d, u] = F(null), i = sr(e, r, a, u), g = D(
1193
+ () => {
1194
+ var m, C;
1195
+ return o ? o(((m = i.data) == null ? void 0 : m.list) || []) : ((C = i.data) == null ? void 0 : C.list) || [];
1196
+ },
1197
+ [i.data, o]
1198
+ );
1199
+ return N(() => {
1200
+ const m = g.find((C) => C.owner.did === r.owner);
1201
+ n((m == null ? void 0 : m.owner.fullName) || (m == null ? void 0 : m.author.name) || "");
1202
+ }, [r.owner, g, n]), {
1203
+ blocklets: g,
1204
+ fetchBlockletsError: d,
1205
+ loadMore: i.loadMore,
1206
+ hasNextPage: !i.noMore,
1207
+ total: (h = i.data) == null ? void 0 : h.total,
1208
+ loadings: {
1209
+ fetchBlockletsLoading: i.loading,
1210
+ loadingMore: i.loadingMore
1211
+ },
1212
+ errors: {
1213
+ ...l,
1214
+ fetchBlockletsError: d
1215
+ }
1216
+ };
1217
+ }
1218
+ function dr() {
1219
+ const { t: e, filters: r, endpoint: o, blockletRender: l, serverVersion: n, minItemWidth: a, selectedCategory: d, getCategoryLocale: u } = S(), { blocklets: i, errors: g, loadMore: h, loadings: m, hasNextPage: C, total: R } = cr(), A = !!d || !!r.price, [c] = _t({
1220
+ loading: m.fetchBlockletsLoading || m.loadingMore,
1221
+ hasNextPage: C,
1222
+ onLoadMore: h
1050
1223
  });
1051
- if (l.fetchBlockletsError)
1052
- return /* @__PURE__ */ t(
1053
- ee,
1054
- {
1055
- error: new Error(`Failed to fetch blocklets from ${F}: ${l.fetchBlockletsError.message}`)
1056
- }
1057
- );
1058
- if (n.fetchBlockletsLoading)
1059
- return /* @__PURE__ */ t(je, { mt: 15 });
1060
- if (c.keyword && S && e.length === 0)
1061
- return /* @__PURE__ */ p(U, { children: [
1224
+ if (g.fetchBlockletsError) {
1225
+ const x = new Error(`Failed to fetch blocklets from ${o}: ${g.fetchBlockletsError.message}`);
1226
+ return /* @__PURE__ */ t(ee, { error: x });
1227
+ }
1228
+ if (m.fetchBlockletsLoading)
1229
+ return /* @__PURE__ */ t(Me, { mt: 15 });
1230
+ if (r.keyword && A && i.length === 0)
1231
+ return /* @__PURE__ */ f(j, { children: [
1062
1232
  /* @__PURE__ */ t(
1063
- H,
1233
+ q,
1064
1234
  {
1065
- primaryStart: s("blocklet.noBlockletPart1"),
1066
- primaryEnd: s("blocklet.noBlockletPart2"),
1067
- filter: c.keyword
1235
+ primaryStart: e("blocklet.noBlockletPart1"),
1236
+ primaryEnd: e("blocklet.noBlockletPart2"),
1237
+ filter: r.keyword
1068
1238
  }
1069
1239
  ),
1070
- /* @__PURE__ */ t(j, { keywordTip: !0, filterTip: !0 })
1240
+ /* @__PURE__ */ t($, { keywordTip: !0, filterTip: !0 })
1071
1241
  ] });
1072
- if (c.keyword && e.length === 0)
1073
- return /* @__PURE__ */ p(U, { children: [
1242
+ if (r.keyword && i.length === 0)
1243
+ return /* @__PURE__ */ f(j, { children: [
1074
1244
  /* @__PURE__ */ t(
1075
- H,
1245
+ q,
1076
1246
  {
1077
- primaryStart: s("blocklet.noBlockletPart1"),
1078
- primaryEnd: s("blocklet.noBlockletPart2"),
1079
- filter: c.keyword
1247
+ primaryStart: e("blocklet.noBlockletPart1"),
1248
+ primaryEnd: e("blocklet.noBlockletPart2"),
1249
+ filter: r.keyword
1080
1250
  }
1081
1251
  ),
1082
- /* @__PURE__ */ t(j, { keywordTip: !0 })
1252
+ /* @__PURE__ */ t($, { keywordTip: !0 })
1083
1253
  ] });
1084
- if (S && e.length === 0) {
1085
- const x = d(a);
1086
- return /* @__PURE__ */ p(U, { children: [
1254
+ if (A && i.length === 0) {
1255
+ const x = u(d);
1256
+ return /* @__PURE__ */ f(j, { children: [
1087
1257
  x ? /* @__PURE__ */ t(
1088
- H,
1258
+ q,
1089
1259
  {
1090
- primaryStart: s("blocklet.noCategoryResults1"),
1091
- primaryEnd: s("blocklet.noCategoryResults2"),
1260
+ primaryStart: e("blocklet.noCategoryResults1"),
1261
+ primaryEnd: e("blocklet.noCategoryResults2"),
1092
1262
  filter: x
1093
1263
  }
1094
- ) : /* @__PURE__ */ t(be, {}),
1095
- /* @__PURE__ */ t(j, { filterTip: !0 })
1264
+ ) : /* @__PURE__ */ t(me, {}),
1265
+ /* @__PURE__ */ t($, { filterTip: !0 })
1096
1266
  ] });
1097
1267
  }
1098
- return e.length === 0 ? /* @__PURE__ */ t(U, { children: /* @__PURE__ */ t(be, {}) }) : /* @__PURE__ */ p(z, { children: [
1099
- /* @__PURE__ */ t(
1100
- C,
1101
- {
1102
- display: "grid",
1103
- gridTemplateColumns: `repeat(auto-fill, minmax(${R}px, 1fr))`,
1104
- p: "2px",
1105
- ...r,
1106
- gap: 2,
1107
- children: e.map((x) => /* @__PURE__ */ t(C, { "data-blocklet-did": x.did, sx: { minWidth: R }, children: o({ blocklet: x, blocklets: e, serverVersion: f }) }, x.did))
1108
- }
1109
- ),
1110
- m && /* @__PURE__ */ t(C, { height: 60, display: "flex", justifyContent: "center", py: 2, ref: u, children: /* @__PURE__ */ t(re, {}) })
1268
+ if (i.length === 0)
1269
+ return /* @__PURE__ */ t(j, { children: /* @__PURE__ */ t(me, {}) });
1270
+ return /* @__PURE__ */ f(M, { children: [
1271
+ r.keyword ? /* @__PURE__ */ f(M, { children: [
1272
+ /* @__PURE__ */ t(oe, { xs: /* @__PURE__ */ t(Oe, {}), md: null }),
1273
+ k()
1274
+ ] }) : /* @__PURE__ */ t(ar, {}),
1275
+ /* @__PURE__ */ t(v, { display: "grid", gridTemplateColumns: `repeat(auto-fill, minmax(${a}px, 1fr))`, p: "2px", gap: 2, children: i.map((x) => /* @__PURE__ */ t(v, { "data-blocklet-did": x.did, sx: { minWidth: a }, children: l({ blocklet: x, blocklets: i, serverVersion: n }) }, x.did)) }),
1276
+ C && /* @__PURE__ */ t(v, { height: 60, display: "flex", justifyContent: "center", py: 2, ref: c, children: /* @__PURE__ */ t(Z, {}) })
1111
1277
  ] });
1278
+ function k() {
1279
+ return /* @__PURE__ */ f(z, { direction: "row", alignItems: "center", justifyContent: "space-between", mb: 2, mt: { xs: 2, md: 0 }, children: [
1280
+ /* @__PURE__ */ t(L, { variant: "h3", children: e("blocklet.search", { keyword: r.keyword }) }),
1281
+ /* @__PURE__ */ t(L, { variant: "body1", color: "text.lighter", fontSize: 13, children: e("blocklet.resultCount", { count: R }) })
1282
+ ] });
1283
+ }
1112
1284
  }
1113
- qe.propTypes = {
1114
- blocklets: w.array.isRequired
1115
- };
1116
- const U = E(zt)`
1285
+ const j = E(zt)`
1117
1286
  text-align: center;
1118
1287
  margin-top: 100px;
1119
1288
  .primary {
@@ -1123,302 +1292,66 @@ const U = E(zt)`
1123
1292
  margin-top: ${(e) => e.theme.spacing(1)};
1124
1293
  }
1125
1294
  `;
1126
- function ae({ onSelect: e, wrapChildren: r }) {
1127
- const o = G(null), l = G(null), n = G(null), { storeApi: a, blockletRender: d, filters: c, endpoint: s, handleKeyword: f, t: m, serverVersion: k } = B(), F = async (h) => {
1128
- const { data: g } = await a.get(T.blockletsPath, { params: h }), v = g.dataList || [];
1129
- return v.length > 0 && v.unshift({ type: "more-result", total: g.total || 0 }), v;
1130
- }, R = (h) => {
1131
- f(h.state.query), h.setIsOpen(!1);
1132
- }, S = () => {
1133
- o.current && setTimeout(() => {
1134
- const h = o.current.querySelector("input.bl-autocomplete-input");
1135
- h && h.focus();
1136
- });
1137
- }, u = (h) => {
1138
- h.setIsOpen(!1), S();
1139
- }, x = ({ prevState: h, state: g }) => {
1140
- h.query !== g.query && (g.query || (f(), S()));
1141
- };
1142
- return Mt(
1143
- "ctrl + k, command + k",
1144
- (h) => (h.stopPropagation(), h.preventDefault(), S(), !1),
1145
- { enableOnTags: ["INPUT"] }
1146
- ), W(() => {
1147
- S();
1148
- }, [s]), W(() => {
1149
- if (!o.current)
1150
- return;
1151
- const h = Dt({
1152
- container: o.current,
1153
- renderer: { createElement: pt, Fragment: ht, render: () => {
1154
- } },
1155
- render({ children: g }, v) {
1156
- var _;
1157
- (!l.current || n.current !== v) && (n.current = v, (_ = l.current) == null || _.unmount(), l.current = Nt(v)), l.current.render(r(g));
1158
- },
1159
- autoFocus: !0,
1160
- openOnFocus: !1,
1161
- classNames: {
1162
- panel: "bl-autocomplete-panel",
1163
- label: "bl-autocomplete-label",
1164
- form: "bl-autocomplete-form",
1165
- input: "bl-autocomplete-input",
1166
- clearButton: "bl-autocomplete-clear",
1167
- detachedCancelButton: "bl-autocomplete-detached-cancel",
1168
- detachedContainer: "bl-autocomplete-detached-container"
1169
- },
1170
- translations: {
1171
- clearButtonTitle: m("common.clear"),
1172
- detachedCancelButtonText: m("common.cancel"),
1173
- submitButtonTitle: m("common.search"),
1174
- detachedSearchButtonTitle: m("common.search")
1175
- },
1176
- placeholder: m("common.searchStore"),
1177
- initialState: {
1178
- query: c.keyword
1179
- },
1180
- onStateChange(g) {
1181
- x(g);
1182
- },
1183
- onSubmit: R,
1184
- onReset(g) {
1185
- u(g);
1186
- },
1187
- getSources({ query: g, state: v, ..._ }) {
1188
- const $ = {
1189
- sortBy: T.nameDesc,
1190
- page: 1,
1191
- pageSize: 10,
1192
- keyword: g
1193
- };
1194
- return Jt([
1195
- {
1196
- sourceId: "blocklets",
1197
- getItems() {
1198
- return F($);
1199
- },
1200
- // 选中后填充 搜索框中值
1201
- getItemInputValue({ item: y }) {
1202
- return y.type === "more-result" ? g : y.title;
1203
- },
1204
- // 选中或者点击自动完成列表中的 item 时触发
1205
- onSelect({ event: y, item: N }) {
1206
- return N.type === "more-result" ? (_.setIsOpen(!1), f(g)) : y.type === "keydown" ? f(N.title) : e({
1207
- blocklet: N,
1208
- detailUrl: Bt(s, "/blocklets", N.did),
1209
- storeUrl: s
1210
- });
1211
- },
1212
- templates: {
1213
- item({ item: y }) {
1214
- return y.type === "more-result" ? /* @__PURE__ */ t("div", { children: m("autocomplete.expandResult", { name: g, number: y.total.toLocaleString() }) }) : d({ blocklet: y, autocompleteSetters: _, serverVersion: k });
1215
- },
1216
- noResults() {
1217
- return m("blocklet.noResults");
1218
- }
1219
- }
1220
- }
1221
- ]);
1222
- }
1223
- });
1224
- return () => {
1225
- h.destroy();
1226
- };
1227
- }, [c, d]), /* @__PURE__ */ p(z, { children: [
1228
- /* @__PURE__ */ t(
1229
- we,
1230
- {
1231
- styles: (h) => ke`
1232
- .bl-autocomplete-detached-container {
1233
- .bl-autocomplete-detached-cancel {
1234
- white-space: nowrap;
1235
- }
1236
- }
1237
- .bl-autocomplete-panel {
1238
- @media (min-width: ${h.breakpoints.values.md}px) {
1239
- min-width: 450px;
1240
- left: unset !important;
1241
- }
1242
- }
1243
- `
1244
- }
1245
- ),
1246
- /* @__PURE__ */ t("div", { className: "bl-search-container", ref: o })
1247
- ] });
1248
- }
1249
- ae.propTypes = {
1250
- onSelect: w.func.isRequired,
1251
- wrapChildren: w.func
1252
- };
1253
- ae.defaultProps = {
1254
- wrapChildren: (e) => e
1255
- };
1256
- function ie({ placeholder: e, ...r }) {
1257
- const { filters: o, handleKeyword: l } = B(), [n, a] = q(o.keyword || ""), d = yt(l, { wait: 300 }), c = (f) => {
1258
- const { value: m } = f.target;
1259
- a(m), d.run(m);
1260
- }, s = () => {
1261
- a(""), l();
1262
- };
1263
- return W(() => {
1264
- a(o.keyword || "");
1265
- }, [o.keyword]), /* @__PURE__ */ t(
1266
- mr,
1295
+ function ur() {
1296
+ const { t: e } = S(), { toggleOpen: r } = te();
1297
+ return /* @__PURE__ */ f(
1298
+ L,
1267
1299
  {
1268
- inputProps: {
1269
- "data-cy": "search-blocklet"
1270
- },
1271
- startAdornment: /* @__PURE__ */ t(me, { position: "start", children: /* @__PURE__ */ t(fr, {}) }),
1272
- onChange: c,
1273
- placeholder: e,
1274
- value: n,
1275
- title: e,
1276
- "data-cy": "search",
1277
- endAdornment: n && /* @__PURE__ */ t(me, { position: "end", children: /* @__PURE__ */ t(gr, { "data-cy": "search-delete", onClick: s }) }),
1278
- ...r
1279
- }
1280
- );
1281
- }
1282
- ie.propTypes = {
1283
- placeholder: w.string
1284
- };
1285
- ie.defaultProps = {
1286
- placeholder: "Type to search..."
1287
- };
1288
- const mr = E(it)`
1289
- background-color: ${(e) => e.theme.palette.grey[50]};
1290
- font-size: 14px;
1291
- border-radius: 6px;
1292
- width: 100%;
1293
- .MuiInputBase-input {
1294
- padding: 8px 0 8px 10px;
1295
- }
1296
- .MuiOutlinedInput-notchedOutline {
1297
- border: none;
1298
- }
1299
- .Mui-focused {
1300
- background-color: #f6f6f6;
1301
- .MuiInputBase-input::placeholder {
1302
- color: transparent;
1303
- }
1304
- }
1305
- `, fr = E(Ot)`
1306
- color: ${(e) => e.theme.palette.grey[500]};
1307
- font-size: 28px;
1308
- @media (max-width: ${(e) => e.theme.breakpoints.values.md}px) {
1309
- font-size: 24px;
1310
- }
1311
- `, gr = E(Re)`
1312
- color: ${(e) => e.theme.palette.grey[500]};
1313
- font-size: 16px;
1314
- cursor: pointer;
1315
- `;
1316
- function yr() {
1317
- const { filters: e, handleSearchSelect: r, t: o, wrapChildren: l, baseSearch: n, layout: a } = B(), { toggleOpen: d } = ne(), c = !!e.keyword;
1318
- return a.showTitle || a.showSearch ? /* @__PURE__ */ p(
1319
- I,
1320
- {
1321
- className: "title-bar",
1322
- direction: "row",
1300
+ variant: "body1",
1301
+ display: { xs: "flex", md: "none" },
1323
1302
  alignItems: "center",
1324
- justifyContent: "space-between",
1325
- pt: { xs: 2, md: 5 },
1326
- pb: { xs: 2, md: 3 },
1327
- borderBottom: 1,
1328
- borderColor: { xs: "transparent", md: "divider" },
1329
- mb: { xs: 0, md: 3 },
1303
+ gap: 1,
1304
+ py: 2,
1305
+ fontWeight: "fontWeightMedium",
1330
1306
  children: [
1331
- /* @__PURE__ */ t(
1332
- Q,
1333
- {
1334
- xs: !c && /* @__PURE__ */ t(De, { onClick: () => d(!0), children: /* @__PURE__ */ t(Et, {}) }),
1335
- md: a.showTitle ? /* @__PURE__ */ t(L, { variant: "h1", children: o("common.title") }) : /* @__PURE__ */ t(C, {})
1336
- }
1337
- ),
1338
- a.showSearch ? /* @__PURE__ */ t(
1339
- C,
1340
- {
1341
- width: { xs: c ? "100%" : 300, md: 300 },
1342
- className: "filter-bar",
1343
- sx: {
1344
- "& .bl-autocomplete-form": { borderRadius: 2 },
1345
- "& .aa-SubmitButton, & .aa-LoadingIndicator": { width: "auto", pl: 1.5, pr: 1 },
1346
- "& .aa-SubmitIcon, & .aa-LoadingIcon": { height: 16, width: 16 }
1347
- },
1348
- children: n ? /* @__PURE__ */ t(ie, { className: "bl-search-container", placeholder: o("common.searchStore"), sx: { pl: 1.5 } }) : /* @__PURE__ */ t(ae, { onSelect: r, wrapChildren: l })
1349
- }
1350
- ) : null
1307
+ /* @__PURE__ */ t(Ee, { onClick: () => r(!0), children: /* @__PURE__ */ t(Et, {}) }),
1308
+ e("common.category")
1351
1309
  ]
1352
1310
  }
1353
- ) : null;
1311
+ );
1354
1312
  }
1355
- function br() {
1356
- const { blockletList: e, total: r, filters: o, t: l } = B(), n = o.category || o.keyword || o.price;
1357
- return /* @__PURE__ */ t(jt, { children: /* @__PURE__ */ p(st, { FallbackComponent: ee, children: [
1358
- /* @__PURE__ */ t(yr, {}),
1359
- /* @__PURE__ */ p(C, { display: "flex", height: "100%", children: [
1360
- /* @__PURE__ */ t(ir, {}),
1361
- /* @__PURE__ */ t(I, { height: "100%", position: "relative", flex: 1, overflow: "visible", children: n ? /* @__PURE__ */ p(z, { children: [
1362
- o.keyword ? /* @__PURE__ */ p(z, { children: [
1363
- /* @__PURE__ */ t(Q, { xs: /* @__PURE__ */ t(Me, {}), md: null }),
1364
- a()
1365
- ] }) : /* @__PURE__ */ t(hr, {}),
1366
- /* @__PURE__ */ t(qe, { blocklets: e, height: "100%" })
1367
- ] }) : /* @__PURE__ */ t(pr, {}) })
1313
+ function pr() {
1314
+ const { blockletList: e, filters: r } = S(), o = r.category || r.keyword || r.price;
1315
+ return /* @__PURE__ */ t(Ot, { children: /* @__PURE__ */ f(dt, { FallbackComponent: ee, children: [
1316
+ /* @__PURE__ */ t(ur, {}),
1317
+ /* @__PURE__ */ f(v, { display: "flex", height: "100%", className: "list-container", pt: { xs: 0, md: 5 }, children: [
1318
+ /* @__PURE__ */ t(tr, {}),
1319
+ /* @__PURE__ */ t(z, { height: "100%", position: "relative", flex: 1, overflow: "visible", children: o ? /* @__PURE__ */ t(dr, { blocklets: e }) : /* @__PURE__ */ t(ir, {}) })
1368
1320
  ] })
1369
1321
  ] }) });
1370
- function a() {
1371
- return /* @__PURE__ */ p(I, { direction: "row", alignItems: "center", justifyContent: "space-between", mb: 2, mt: { xs: 2, md: 0 }, children: [
1372
- /* @__PURE__ */ t(L, { variant: "h3", children: l("blocklet.search", { keyword: o.keyword }) }),
1373
- /* @__PURE__ */ t(L, { variant: "body1", color: "text.lighter", fontSize: 13, children: l("blocklet.resultCount", { count: r }) })
1374
- ] });
1375
- }
1376
1322
  }
1377
- function lo(e) {
1378
- const r = xe(), o = Xt(r.palette.primary.main), l = {
1379
- autocomplete: ke`
1380
- :root {
1381
- --aa-detached-media-query: (max-width: ${r.breakpoints.values.md}px) !important;
1382
- --aa-detached-modal-media-query: (min-width: ${r.breakpoints.values.md}px) !important;
1383
- --aa-detached-modal-max-width: ${r.breakpoints.values.md}px !important;
1384
- --aa-selected-color-rgb: ${o.r}, ${o.g}, ${o.b} !important;
1385
- --aa-primary-color-rgb: ${o.r}, ${o.g}, ${o.b} !important;
1386
- --aa-input-background-color-rgb: 250, 250, 250 !important;
1387
- }
1388
- .bl-autocomplete-panel {
1389
- z-index: ${r.zIndex.modal};
1390
- }
1391
- .bl-autocomplete-label {
1392
- .aa-SubmitIcon {
1393
- color: ${r.palette.grey[500]} !important;
1394
- }
1395
- }
1396
- .bl-autocomplete-form {
1397
- border: 1px solid #fff !important;
1398
- &:focus-within {
1399
- box-shadow: none !important;
1400
- border: 1px solid rgba(0, 0, 0, 0.12) !important;
1401
- }
1402
- }
1403
- .aa-DetachedSearchButton {
1404
- border: none !important;
1405
- &:focus-within {
1406
- box-shadow: none !important;
1407
- }
1408
- .aa-SubmitIcon {
1409
- color: ${r.palette.grey[500]} !important;
1410
- }
1411
- }
1412
- .aa-Panel .arcblock-blocklet button {
1413
- border: 1px solid rgba(${o.r}, ${o.g}, ${o.b}, 0.5);
1323
+ function Jr(e) {
1324
+ const r = fe(), o = at(
1325
+ ct({
1326
+ ...r,
1327
+ typography: {
1328
+ h1: {
1329
+ fontSize: 32,
1330
+ fontWeight: 700,
1331
+ lineHeight: 1.375,
1332
+ textAlign: "left"
1333
+ },
1334
+ h2: {
1335
+ fontSize: 24,
1336
+ fontWeight: 700,
1337
+ lineHeight: 1.3333333,
1338
+ textAlign: "left"
1339
+ },
1340
+ h3: {
1341
+ fontSize: 18,
1342
+ fontWeight: 600,
1343
+ lineHeight: 1.5,
1344
+ textAlign: "left"
1345
+ },
1346
+ fontWeightLight: 300,
1347
+ fontWeightRegular: 400,
1348
+ fontWeightMedium: 500,
1349
+ fontWeightBold: 700
1414
1350
  }
1415
- `
1416
- };
1417
- return /* @__PURE__ */ p(rr, { ...e, children: [
1418
- /* @__PURE__ */ t(we, { styles: l.autocomplete }),
1419
- /* @__PURE__ */ t(br, {})
1420
- ] });
1351
+ })
1352
+ );
1353
+ return /* @__PURE__ */ t(st, { theme: o, children: /* @__PURE__ */ t(Ht, { ...e, children: /* @__PURE__ */ t(pr, {}) }) });
1421
1354
  }
1422
1355
  export {
1423
- lo as default
1356
+ Jr as default
1424
1357
  };