@blocklet/list 0.13.38 → 0.13.39

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