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