@blocklet/list 0.12.43 → 0.12.45

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.
@@ -8,16 +8,15 @@ var _react = require("react");
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _Theme = require("@arcblock/ux/lib/Theme");
10
10
  var _Empty = _interopRequireDefault(require("@arcblock/ux/lib/Empty"));
11
- var _Box = _interopRequireDefault(require("@mui/material/Box"));
12
- var _Grid = _interopRequireDefault(require("@mui/material/Grid"));
13
- var _CircularProgress = _interopRequireDefault(require("@mui/material/CircularProgress"));
11
+ var _material = require("@mui/material");
14
12
  var _reactInfiniteScrollHook = _interopRequireDefault(require("react-infinite-scroll-hook"));
15
13
  var _ErrorBoundary = require("@arcblock/ux/lib/ErrorBoundary");
14
+ var _ahooks = require("ahooks");
16
15
  var _empty = require("./empty");
17
16
  var _filter = require("../../contexts/filter");
18
17
  var _jsxRuntime = require("react/jsx-runtime");
19
18
  var _templateObject, _templateObject2, _templateObject3;
20
- const _excluded = ["blocklets"]; // import styled from '@emotion/styled';
19
+ const _excluded = ["blocklets"];
21
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
21
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
23
22
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -44,6 +43,22 @@ function BlockletList(_ref) {
44
43
  loadMore,
45
44
  endpoint
46
45
  } = (0, _filter.useFilterContext)();
46
+ const refContainer = (0, _react.useRef)(null);
47
+ const size = (0, _ahooks.useSize)(refContainer.current);
48
+
49
+ // 根据当前容器的宽度来决定 columns,而不是屏幕宽度
50
+ const columns = (0, _ahooks.useCreation)(() => {
51
+ if (size) {
52
+ if (size.width > 900) {
53
+ return 12;
54
+ }
55
+ if (size.width > 600) {
56
+ return 8;
57
+ }
58
+ return 4;
59
+ }
60
+ return 0;
61
+ }, [size]);
47
62
  const showFilterTip = !!selectedCategory || !!filters.price;
48
63
  const [sentryRef] = (0, _reactInfiniteScrollHook.default)({
49
64
  loading: loadings.fetchBlockletsLoading || loadings.loadingMore,
@@ -56,12 +71,12 @@ function BlockletList(_ref) {
56
71
  });
57
72
  }
58
73
  if (loadings.fetchBlockletsLoading) {
59
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
74
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
60
75
  height: 60,
61
76
  display: "flex",
62
77
  alignItems: "center",
63
78
  justifyContent: "center",
64
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {})
79
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.CircularProgress, {})
65
80
  });
66
81
  }
67
82
  if (filters.keyword && showFilterTip && blocklets.length === 0) {
@@ -107,12 +122,11 @@ function BlockletList(_ref) {
107
122
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(StyledGrid, _objectSpread(_objectSpread({
108
123
  container: true
109
124
  }, rest), {}, {
125
+ columns: columns,
126
+ ref: refContainer,
110
127
  children: [blocklets.map(blocklet => /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledGridItem, {
111
128
  item: true,
112
- lg: 4,
113
- md: 6,
114
- sm: 6,
115
- xs: 12,
129
+ xs: 4,
116
130
  "data-blocklet-did": blocklet.did,
117
131
  children: blockletRender({
118
132
  blocklet,
@@ -120,15 +134,13 @@ function BlockletList(_ref) {
120
134
  })
121
135
  }, blocklet.did)), hasNextPage && /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledGridItem, {
122
136
  item: true,
123
- md: 12,
124
- sm: 12,
125
137
  xs: 12,
126
138
  ref: sentryRef,
127
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
139
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
128
140
  height: 60,
129
141
  display: "flex",
130
142
  justifyContent: "center",
131
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {})
143
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.CircularProgress, {})
132
144
  })
133
145
  })]
134
146
  }));
@@ -137,6 +149,6 @@ BlockletList.propTypes = {
137
149
  blocklets: _propTypes.default.array.isRequired
138
150
  };
139
151
  BlockletList.defaultProps = {};
140
- const StyledGrid = (0, _Theme.styled)(_Grid.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &.MuiGrid-root {\n width: 100%;\n margin: 0 -16px;\n }\n"])));
141
- const StyledGridItem = /*#__PURE__*/(0, _react.memo)((0, _Theme.styled)(_Grid.default)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n @media (max-width: ", "px) {\n &.MuiGrid-item {\n padding-bottom: 0px;\n }\n }\n @media (min-width: ", "px) {\n &.MuiGrid-item {\n margin-bottom: ", ";\n }\n }\n"])), props => props.theme.breakpoints.values.sm, props => props.theme.breakpoints.values.sm, props => props.theme.spacing(2)));
152
+ const StyledGrid = (0, _Theme.styled)(_material.Grid)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n opacity: ", ";\n &.MuiGrid-root {\n width: 100%;\n margin: 0 -16px;\n }\n"])), props => props.columns > 0 ? 1 : 0);
153
+ const StyledGridItem = /*#__PURE__*/(0, _react.memo)((0, _Theme.styled)(_material.Grid)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n @media (max-width: ", "px) {\n &.MuiGrid-item {\n padding-bottom: 0px;\n }\n }\n @media (min-width: ", "px) {\n &.MuiGrid-item {\n margin-bottom: ", ";\n }\n }\n"])), props => props.theme.breakpoints.values.sm, props => props.theme.breakpoints.values.sm, props => props.theme.spacing(2)));
142
154
  const CustomEmpty = (0, _Theme.styled)(_Empty.default)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n text-align: center;\n .primary {\n color: ", ";\n }\n .tips {\n margin-top: ", ";\n }\n"])), props => props.theme.palette.primary.main, props => props.theme.spacing(1));
package/lib/index.es.js CHANGED
@@ -1,15 +1,15 @@
1
- import { jsx as t, jsxs as g, Fragment as Pe } from "react/jsx-runtime";
2
- import { useTheme as de } from "@mui/material/styles";
3
- import { css as Be, Global as $e } from "@emotion/react";
1
+ import { jsx as t, jsxs as h, Fragment as Ce } from "react/jsx-runtime";
2
+ import { useTheme as pe } from "@mui/material/styles";
3
+ import { css as Pe, Global as Be } from "@emotion/react";
4
4
  import { styled as C } from "@arcblock/ux/lib/Theme";
5
- import Te from "@mui/icons-material/Sort";
6
- import { Button as Re, CircularProgress as ze, MenuList as Ie, useMediaQuery as _e, SvgIcon as De, Popper as Ne, Grow as Ae, Paper as Le, ClickAwayListener as Me, MenuItem as Oe, Chip as Fe, OutlinedInput as Ee, InputAdornment as le, Box as F, Hidden as ae } from "@mui/material";
7
- import qe from "@mui/icons-material/Face";
8
- import { ErrorBoundary as je } from "react-error-boundary";
5
+ import $e from "@mui/icons-material/Sort";
6
+ import { Button as Te, CircularProgress as W, MenuList as Re, useMediaQuery as ze, SvgIcon as Ie, Popper as _e, Grow as De, Paper as Ne, ClickAwayListener as Ae, MenuItem as Le, Chip as Me, Grid as de, Box as _, OutlinedInput as Oe, InputAdornment as le, Hidden as ae } from "@mui/material";
7
+ import Fe from "@mui/icons-material/Face";
8
+ import { ErrorBoundary as Ee } from "react-error-boundary";
9
9
  import { ErrorFallback as ue } from "@arcblock/ux/lib/ErrorBoundary";
10
- import { createContext as Ge, useMemo as N, useState as M, useCallback as W, useEffect as O, useContext as Ue, forwardRef as Ke, useRef as q, memo as We, createElement as He, Fragment as Ve } from "react";
10
+ import { createContext as qe, useMemo as A, useState as F, useCallback as H, useEffect as E, useContext as je, forwardRef as Ge, useRef as L, memo as Ue, createElement as Ke, Fragment as We } from "react";
11
11
  import n from "prop-types";
12
- import { useReactive as Qe, useInfiniteScroll as Je, useRequest as Xe, useDebounceFn as Ye } from "ahooks";
12
+ import { useReactive as He, useInfiniteScroll as Ve, useRequest as Qe, useSize as Je, useCreation as Xe, useDebounceFn as Ye } from "ahooks";
13
13
  import Ze from "lodash/orderBy";
14
14
  import et from "axios";
15
15
  import tt from "json-stable-stringify";
@@ -22,19 +22,17 @@ import lt from "@mui/icons-material/FilterAltOutlined";
22
22
  import at from "@arcblock/ux/lib/Dialog";
23
23
  import it from "@mui/material/Button";
24
24
  import st from "@arcblock/ux/lib/Empty";
25
- import H from "@mui/material/Box";
26
- import me from "@mui/material/Grid";
27
- import se from "@mui/material/CircularProgress";
28
25
  import ct from "react-infinite-scroll-hook";
29
- import fe from "@mui/material/Typography";
30
- import pt from "@mui/icons-material/Search";
31
- import dt from "@mui/icons-material/Close";
32
- import { createRoot as ut } from "react-dom/client";
33
- import { autocomplete as mt } from "@algolia/autocomplete-js";
34
- import { useHotkeys as ft } from "react-hotkeys-hook";
35
- import ht from "url-join";
26
+ import pt from "@mui/material/Box";
27
+ import me from "@mui/material/Typography";
28
+ import dt from "@mui/icons-material/Search";
29
+ import ut from "@mui/icons-material/Close";
30
+ import { createRoot as mt } from "react-dom/client";
31
+ import { autocomplete as ft } from "@algolia/autocomplete-js";
32
+ import { useHotkeys as ht } from "react-hotkeys-hook";
33
+ import gt from "url-join";
36
34
  import "@algolia/autocomplete-theme-classic/dist/theme.css";
37
- const gt = (e) => [
35
+ const yt = (e) => [
38
36
  {
39
37
  name: e("sort.popularity"),
40
38
  value: "popularity"
@@ -51,25 +49,25 @@ const gt = (e) => [
51
49
  name: e("sort.nameDescend"),
52
50
  value: "nameDesc"
53
51
  }
54
- ], yt = (e) => [
52
+ ], bt = (e) => [
55
53
  { name: e("blocklet.free"), value: "free" },
56
54
  { name: e("blocklet.payment"), value: "payment" }
57
- ], bt = (e = [], o = "en") => e.map((r) => ({ name: r.locales[o] || `Category.${o}`, value: r._id })), xt = (e, o) => (
55
+ ], xt = (e = [], o = "en") => e.map((r) => ({ name: r.locales[o] || `Category.${o}`, value: r._id })), kt = (e, o) => (
58
56
  // eslint-disable-next-line no-prototype-builtins
59
57
  e.replace(/{(\w*)}/g, (r, l) => o.hasOwnProperty(l) ? o[l] : "")
60
- ), kt = () => window.innerWidth <= 600, wt = (e, o) => {
58
+ ), wt = () => window.innerWidth <= 600, vt = (e, o) => {
61
59
  const r = (e + o) / o;
62
60
  return r > 1 ? r.toFixed() : 1;
63
- }, vt = (e) => rt(e).rgb().object();
64
- function St(e, o) {
61
+ }, St = (e) => rt(e).rgb().object();
62
+ function Ct(e, o) {
65
63
  let r;
66
64
  return function(...i) {
67
- return r && clearTimeout(r), new Promise((s) => {
68
- r = setTimeout(() => s(e(...i)), o);
65
+ return r && clearTimeout(r), new Promise((c) => {
66
+ r = setTimeout(() => c(e(...i)), o);
69
67
  });
70
68
  };
71
69
  }
72
- const Ct = St((e) => Promise.resolve(e), 300), Pt = {
70
+ const Pt = Ct((e) => Promise.resolve(e), 300), Bt = {
73
71
  common: {
74
72
  searchStore: "Search the store",
75
73
  price: "Price",
@@ -103,7 +101,7 @@ const Ct = St((e) => Promise.resolve(e), 300), Pt = {
103
101
  autocomplete: {
104
102
  expandResult: 'Show {number} search results for "{name}" '
105
103
  }
106
- }, Bt = {
104
+ }, $t = {
107
105
  common: {
108
106
  searchStore: "搜索商店内应用",
109
107
  price: "价格",
@@ -138,9 +136,9 @@ const Ct = St((e) => Promise.resolve(e), 300), Pt = {
138
136
  expandResult: "显示 {number} 条 “{name}” 的搜索结果 "
139
137
  }
140
138
  }, K = {
141
- en: ie(Pt),
142
- zh: ie(Bt)
143
- }, he = {
139
+ en: ie(Bt),
140
+ zh: ie($t)
141
+ }, fe = {
144
142
  filters: n.shape({
145
143
  keyword: n.string,
146
144
  sortBy: n.string,
@@ -157,7 +155,7 @@ const Ct = St((e) => Promise.resolve(e), 300), Pt = {
157
155
  onSearchSelect: n.func,
158
156
  locale: n.oneOf(["zh", "en"]),
159
157
  baseSearch: n.bool
160
- }, ge = {
158
+ }, he = {
161
159
  locale: "zh",
162
160
  filters: {},
163
161
  onFilterChange: () => {
@@ -179,169 +177,169 @@ const Ct = St((e) => Promise.resolve(e), 300), Pt = {
179
177
  blockletsPath: "/api/v2/blocklets.json",
180
178
  categoriesPath: "/api/blocklets/categories",
181
179
  cacheSize: 100
182
- }, ye = Ge({}), { Provider: $t, Consumer: Cr } = ye;
180
+ }, ge = qe({}), { Provider: Tt, Consumer: Sr } = ge;
183
181
  function V({
184
182
  filters: e,
185
183
  children: o,
186
184
  endpoint: r,
187
185
  locale: l,
188
186
  blockletRender: i,
189
- onFilterChange: s,
190
- onSearchSelect: x,
191
- extraFilter: y,
192
- wrapChildren: p,
187
+ onFilterChange: c,
188
+ onSearchSelect: k,
189
+ extraFilter: g,
190
+ wrapChildren: d,
193
191
  baseSearch: b,
194
192
  serverVersion: m,
195
193
  storeVersion: P
196
194
  }) {
197
195
  const B = {};
198
196
  m && (B["x-blocklet-server-version"] = m), P && (B["x-blocklet-store-version"] = P);
199
- const S = N(() => et.create({
197
+ const x = A(() => et.create({
200
198
  baseURL: r,
201
199
  headers: B
202
- }), [r]), c = N(() => ({ sortBy: "popularity", sortDirection: "desc", ...e }), [e]), $ = c.category, d = Qe({
200
+ }), [r]), y = A(() => ({ sortBy: "popularity", sortDirection: "desc", ...e }), [e]), $ = y.category, p = He({
203
201
  currentPage: T.currentPage,
204
- pageSize: kt() ? T.mobilePageSize : T.pageSize,
202
+ pageSize: wt() ? T.mobilePageSize : T.pageSize,
205
203
  defaultCurrentPage: T.defaultCurrentPage
206
- }), [f, k] = M(null), {
207
- data: h = { list: [], total: 0 },
208
- loading: D,
209
- loadMore: w,
204
+ }), [s, w] = F(null), {
205
+ data: f = { list: [], total: 0 },
206
+ loading: N,
207
+ loadMore: v,
210
208
  loadingMore: I
211
- } = Je(
209
+ } = Ve(
212
210
  async (a) => {
213
211
  var R;
214
212
  const u = {
215
- ...c,
216
- sortBy: T[c.sortBy],
217
- page: wt(((R = a == null ? void 0 : a.list) == null ? void 0 : R.length) || 0, d.pageSize),
218
- pageSize: d.pageSize
213
+ ...y,
214
+ sortBy: T[y.sortBy],
215
+ page: vt(((R = a == null ? void 0 : a.list) == null ? void 0 : R.length) || 0, p.pageSize),
216
+ pageSize: p.pageSize
219
217
  };
220
- k(null);
221
- const { data: v = {} } = await S.get(T.blockletsPath, {
218
+ w(null);
219
+ const { data: S = {} } = await x.get(T.blockletsPath, {
222
220
  params: u
223
221
  });
224
- return { list: (v == null ? void 0 : v.dataList) || [], total: (v == null ? void 0 : v.total) || 0 };
222
+ return { list: (S == null ? void 0 : S.dataList) || [], total: (S == null ? void 0 : S.total) || 0 };
225
223
  },
226
224
  {
227
225
  isNoMore: (a) => a ? a.list.length >= a.total : !1,
228
226
  reloadDeps: [r, tt(e)],
229
227
  onError: (a) => {
230
- k(a);
228
+ w(a);
231
229
  }
232
230
  }
233
231
  ), {
234
232
  data: G = [],
235
- error: xe,
236
- loading: ke,
237
- run: we
238
- } = Xe(
233
+ error: be,
234
+ loading: xe,
235
+ run: ke
236
+ } = Qe(
239
237
  async () => {
240
- const { data: a } = await S.get(T.categoriesPath);
238
+ const { data: a } = await x.get(T.categoriesPath);
241
239
  return Array.isArray(a) ? a : [];
242
240
  },
243
241
  { manual: !0 }
244
- ), U = N(() => Ze(G || [], [(u) => u.name], ["asc"]), [G]), re = W(
242
+ ), U = A(() => Ze(G || [], [(u) => u.name], ["asc"]), [G]), re = H(
245
243
  (a, u) => {
246
- const v = K[l] ? K[l][a] : K.en[a];
247
- return xt(v, u);
244
+ const S = K[l] ? K[l][a] : K.en[a];
245
+ return kt(S, u);
248
246
  },
249
247
  [l]
250
- ), oe = N(() => {
251
- let a = h.list || [];
252
- return a = y(a), a;
253
- }, [h, y]), ve = N(() => bt(U, l), [U, l]), Se = yt(re), Ce = {
254
- errors: { fetchBlockletsError: f, fetchCategoriesError: xe },
255
- loadings: { fetchBlockletsLoading: D, fetchCategoriesLoading: ke, loadingMore: I },
248
+ ), oe = A(() => {
249
+ let a = f.list || [];
250
+ return a = g(a), a;
251
+ }, [f, g]), we = A(() => xt(U, l), [U, l]), ve = bt(re), Se = {
252
+ errors: { fetchBlockletsError: s, fetchCategoriesError: be },
253
+ loadings: { fetchBlockletsLoading: N, fetchCategoriesLoading: xe, loadingMore: I },
256
254
  endpoint: r,
257
255
  blockletList: oe,
258
- wrapChildren: p,
256
+ wrapChildren: d,
259
257
  t: re,
260
- filters: c,
258
+ filters: y,
261
259
  selectedCategory: $,
262
260
  categoryList: U,
263
261
  blockletRender: i,
264
262
  locale: l,
265
- categoryOptions: ve,
266
- priceOptions: Se,
267
- storeApi: S,
263
+ categoryOptions: we,
264
+ priceOptions: ve,
265
+ storeApi: x,
268
266
  baseSearch: b,
269
- hasNextPage: h.list.length < h.total,
267
+ hasNextPage: f.list.length < f.total,
270
268
  handleSort: (a) => {
271
269
  const u = {
272
- ...c,
270
+ ...y,
273
271
  sortBy: a,
274
272
  sortDirection: a === "nameAsc" ? "asc" : "desc"
275
273
  };
276
- s(u);
274
+ c(u);
277
275
  },
278
276
  handleKeyword: (a) => {
279
- const u = { ...c, keyword: a || void 0 };
280
- s(u);
277
+ const u = { ...y, keyword: a || void 0 };
278
+ c(u);
281
279
  },
282
280
  handlePrice: (a) => {
283
281
  const u = {
284
- ...c,
285
- price: a === c.price ? void 0 : a
282
+ ...y,
283
+ price: a === y.price ? void 0 : a
286
284
  };
287
- s(u);
285
+ c(u);
288
286
  },
289
287
  handleCategory: (a) => {
290
288
  let u = a;
291
- (a === "all" || a === c.category) && (u = void 0);
292
- const v = { ...c, category: u };
293
- s(v);
289
+ (a === "all" || a === y.category) && (u = void 0);
290
+ const S = { ...y, category: u };
291
+ c(S);
294
292
  },
295
293
  handleDeveloper: (a) => {
296
- const u = { ...c, owner: a || void 0 };
297
- s(u);
294
+ const u = { ...y, owner: a || void 0 };
295
+ c(u);
298
296
  },
299
297
  handlePage: (a) => {
300
- const u = { ...c, currentPage: a };
301
- s(u);
298
+ const u = { ...y, currentPage: a };
299
+ c(u);
302
300
  },
303
301
  loadMore: () => {
304
- w();
302
+ v();
305
303
  },
306
304
  getCategoryLocale: (a) => {
307
305
  if (!a)
308
306
  return null;
309
307
  let u = null;
310
- const v = G.find((R) => R._id === a);
311
- return v && (u = v.locales[l]), u;
308
+ const S = G.find((R) => R._id === a);
309
+ return S && (u = S.locales[l]), u;
312
310
  },
313
311
  get developerName() {
314
- var u, v;
315
- return ((v = (u = oe.find((R) => {
312
+ var u, S;
313
+ return ((S = (u = oe.find((R) => {
316
314
  var ne;
317
- return ((ne = R == null ? void 0 : R.owner) == null ? void 0 : ne.did) === c.owner;
318
- })) == null ? void 0 : u.owner) == null ? void 0 : v.name) || "";
315
+ return ((ne = R == null ? void 0 : R.owner) == null ? void 0 : ne.did) === y.owner;
316
+ })) == null ? void 0 : u.owner) == null ? void 0 : S.name) || "";
319
317
  },
320
- handleSearchSelect: x
318
+ handleSearchSelect: k
321
319
  };
322
- return O(() => {
323
- we();
324
- }, [r]), /* @__PURE__ */ t($t, { value: Ce, children: o });
320
+ return E(() => {
321
+ ke();
322
+ }, [r]), /* @__PURE__ */ t(Tt, { value: Se, children: o });
325
323
  }
326
324
  V.propTypes = {
327
- ...he,
325
+ ...fe,
328
326
  children: n.any.isRequired
329
327
  };
330
- V.defaultProps = ge;
328
+ V.defaultProps = he;
331
329
  function z() {
332
- const e = Ue(ye);
330
+ const e = je(ge);
333
331
  return e || {};
334
332
  }
335
- const Tt = C(Re)`
333
+ const Rt = C(Te)`
336
334
  border-radius: 4px;
337
- `, Q = Ke(({ children: e, rounded: o, loading: r, disabled: l, ...i }, s) => /* @__PURE__ */ t(
338
- Tt,
335
+ `, Q = Ge(({ children: e, rounded: o, loading: r, disabled: l, ...i }, c) => /* @__PURE__ */ t(
336
+ Rt,
339
337
  {
340
- ref: s,
338
+ ref: c,
341
339
  disableElevation: !0,
342
340
  disabled: l || r,
343
341
  ...i,
344
- startIcon: r && /* @__PURE__ */ t(ze, { size: "1em" }),
342
+ startIcon: r && /* @__PURE__ */ t(W, { size: "1em" }),
345
343
  children: e
346
344
  }
347
345
  ));
@@ -357,57 +355,57 @@ Q.defaultProps = {
357
355
  loading: !1,
358
356
  disabled: !1
359
357
  };
360
- function J({ title: e, value: o, icon: r, prepend: l, options: i, onChange: s, itemRender: x, ...y }) {
361
- const p = q(null), b = de(), [m, P] = M(!1), [B, S] = M(o !== null ? o : ""), c = _e(b.breakpoints.down("sm"));
362
- O(() => {
363
- S(o !== null ? o : "");
358
+ function J({ title: e, value: o, icon: r, prepend: l, options: i, onChange: c, itemRender: k, ...g }) {
359
+ const d = L(null), b = pe(), [m, P] = F(!1), [B, x] = F(o !== null ? o : ""), y = ze(b.breakpoints.down("sm"));
360
+ E(() => {
361
+ x(o !== null ? o : "");
364
362
  }, [o]);
365
- const $ = W(() => {
363
+ const $ = H(() => {
366
364
  P(!1);
367
- }, []), d = W(() => {
365
+ }, []), p = H(() => {
368
366
  P(!0);
369
367
  }, []);
370
- function f(h) {
371
- S(h.value), s(h.value), c && $();
368
+ function s(f) {
369
+ x(f.value), c(f.value), y && $();
372
370
  }
373
- function k(h) {
374
- return h === B;
371
+ function w(f) {
372
+ return f === B;
375
373
  }
376
- return /* @__PURE__ */ g(Pe, { children: [
377
- /* @__PURE__ */ g(
378
- Rt,
374
+ return /* @__PURE__ */ h(Ce, { children: [
375
+ /* @__PURE__ */ h(
376
+ zt,
379
377
  {
380
- ref: p,
381
- onClick: d,
378
+ ref: d,
379
+ onClick: p,
382
380
  variant: "outlined",
383
381
  size: "small",
384
382
  className: ["my-select__selector", nt(B) ? "" : "my-select__selector--active"].join(" "),
385
- ...y,
383
+ ...g,
386
384
  children: [
387
385
  /* @__PURE__ */ t("div", { className: "my-select__icon", children: r }),
388
386
  e,
389
- /* @__PURE__ */ t(De, { className: "my-select__arrowdown", component: ot, fontSize: "small" })
387
+ /* @__PURE__ */ t(Ie, { className: "my-select__arrowdown", component: ot, fontSize: "small" })
390
388
  ]
391
389
  }
392
390
  ),
393
- /* @__PURE__ */ t(Ne, { open: m, anchorEl: p.current, transition: !0, style: { zIndex: "9999" }, children: ({ TransitionProps: h, placement: D }) => /* @__PURE__ */ t(
394
- Ae,
391
+ /* @__PURE__ */ t(_e, { open: m, anchorEl: d.current, transition: !0, style: { zIndex: "9999" }, children: ({ TransitionProps: f, placement: N }) => /* @__PURE__ */ t(
392
+ De,
395
393
  {
396
- ...h,
397
- style: { transformOrigin: D === "bottom" ? "center top" : "center bottom" },
398
- children: /* @__PURE__ */ t(Le, { children: /* @__PURE__ */ t(Me, { onClickAway: $, children: /* @__PURE__ */ g(zt, { autoFocusItem: m, onMouseEnter: d, onMouseLeave: $, children: [
394
+ ...f,
395
+ style: { transformOrigin: N === "bottom" ? "center top" : "center bottom" },
396
+ children: /* @__PURE__ */ t(Ne, { children: /* @__PURE__ */ t(Ae, { onClickAway: $, children: /* @__PURE__ */ h(It, { autoFocusItem: m, onMouseEnter: p, onMouseLeave: $, children: [
399
397
  l,
400
- i.map((w) => x ? x(w) : /* @__PURE__ */ t(
401
- Oe,
398
+ i.map((v) => k ? k(v) : /* @__PURE__ */ t(
399
+ Le,
402
400
  {
403
- onClick: () => f(w),
401
+ onClick: () => s(v),
404
402
  className: [
405
403
  "my-select__option",
406
- k(w.value) ? "my-select__option--active" : ""
404
+ w(v.value) ? "my-select__option--active" : ""
407
405
  ].join(" "),
408
- children: w.name
406
+ children: v.name
409
407
  },
410
- w.value
408
+ v.value
411
409
  ))
412
410
  ] }) }) })
413
411
  }
@@ -431,7 +429,7 @@ J.defaultProps = {
431
429
  onChange: () => {
432
430
  }
433
431
  };
434
- const Rt = C(Q)`
432
+ const zt = C(Q)`
435
433
  border: 1px solid #f0f0f0;
436
434
  padding: 6px 8px 6px 12px;
437
435
  font-weight: ${(e) => e.theme.typography.fontWeightBold};
@@ -463,7 +461,7 @@ const Rt = C(Q)`
463
461
  margin-right: 3px;
464
462
  }
465
463
  }
466
- `, zt = C(Ie)`
464
+ `, It = C(Re)`
467
465
  .my-select__option__icon {
468
466
  color: transparent;
469
467
  font-size: 16px;
@@ -480,8 +478,8 @@ const Rt = C(Q)`
480
478
  }
481
479
  }
482
480
  `;
483
- function _({ options: e, onChange: o, title: r, value: l }) {
484
- return /* @__PURE__ */ g(It, { children: [
481
+ function D({ options: e, onChange: o, title: r, value: l }) {
482
+ return /* @__PURE__ */ h(_t, { children: [
485
483
  /* @__PURE__ */ t("div", { className: "title", children: r }),
486
484
  /* @__PURE__ */ t("div", { className: "list", children: e.map((i) => /* @__PURE__ */ t(
487
485
  "div",
@@ -496,7 +494,7 @@ function _({ options: e, onChange: o, title: r, value: l }) {
496
494
  )) })
497
495
  ] });
498
496
  }
499
- const It = C("div")`
497
+ const _t = C("div")`
500
498
  .title {
501
499
  font-size: 18px;
502
500
  font-weight: bold;
@@ -524,38 +522,38 @@ const It = C("div")`
524
522
  font-weight: bold;
525
523
  }
526
524
  `;
527
- _.propTypes = {
525
+ D.propTypes = {
528
526
  title: n.string.isRequired,
529
527
  options: n.array.isRequired,
530
528
  onChange: n.func.isRequired,
531
529
  value: n.oneOfType([n.string, n.number])
532
530
  };
533
- _.defaultProps = {
531
+ D.defaultProps = {
534
532
  value: null
535
533
  };
536
534
  function X() {
537
- const { selectedCategory: e, handleCategory: o, t: r, handlePrice: l, filters: i, categoryOptions: s, priceOptions: x } = z(), [y, p] = M(!1), b = (m, P) => {
538
- m === "category" && o(P), m === "price" && l(P), p(!1);
535
+ const { selectedCategory: e, handleCategory: o, t: r, handlePrice: l, filters: i, categoryOptions: c, priceOptions: k } = z(), [g, d] = F(!1), b = (m, P) => {
536
+ m === "category" && o(P), m === "price" && l(P), d(!1);
539
537
  };
540
- return /* @__PURE__ */ g(_t, { children: [
541
- /* @__PURE__ */ t(it, { variant: "outlined", className: "filter-button", onClick: () => p(!0), children: /* @__PURE__ */ t(lt, { className: "filter-icon", fontSize: "small" }) }),
542
- /* @__PURE__ */ g(at, { fullWidth: !0, title: "", open: y, onClose: () => p(!1), children: [
538
+ return /* @__PURE__ */ h(Dt, { children: [
539
+ /* @__PURE__ */ t(it, { variant: "outlined", className: "filter-button", onClick: () => d(!0), children: /* @__PURE__ */ t(lt, { className: "filter-icon", fontSize: "small" }) }),
540
+ /* @__PURE__ */ h(at, { fullWidth: !0, title: "", open: g, onClose: () => d(!1), children: [
543
541
  /* @__PURE__ */ t(
544
- _,
542
+ D,
545
543
  {
546
544
  title: r("common.price"),
547
- options: x,
545
+ options: k,
548
546
  value: i.price,
549
547
  onChange: (m) => {
550
548
  b("price", m);
551
549
  }
552
550
  }
553
551
  ),
554
- s.length > 0 && /* @__PURE__ */ t("div", { style: { marginTop: "16px" }, children: /* @__PURE__ */ t(
555
- _,
552
+ c.length > 0 && /* @__PURE__ */ t("div", { style: { marginTop: "16px" }, children: /* @__PURE__ */ t(
553
+ D,
556
554
  {
557
555
  title: r("common.category"),
558
- options: s,
556
+ options: c,
559
557
  value: e,
560
558
  onChange: (m) => {
561
559
  b("category", m);
@@ -565,7 +563,7 @@ function X() {
565
563
  ] })
566
564
  ] });
567
565
  }
568
- const _t = C("div")`
566
+ const Dt = C("div")`
569
567
  .filter-button {
570
568
  margin-right: 16px;
571
569
  border-color: rgb(240, 240, 240);
@@ -579,7 +577,7 @@ const _t = C("div")`
579
577
  `;
580
578
  X.propTypes = {};
581
579
  X.defaultProps = {};
582
- const Dt = C("div")`
580
+ const Nt = C("div")`
583
581
  .MuiChip-root {
584
582
  border-radius: 4px;
585
583
  height: initial;
@@ -588,50 +586,50 @@ const Dt = C("div")`
588
586
  padding: 4px 0;
589
587
  }
590
588
  `;
591
- function A({ label: e, icon: o, onDelete: r, ...l }) {
592
- return e ? /* @__PURE__ */ t(Dt, { ...l, children: /* @__PURE__ */ t(Fe, { color: "primary", "data-cy": "filter-tag", icon: o, label: e, onDelete: r }) }) : null;
589
+ function M({ label: e, icon: o, onDelete: r, ...l }) {
590
+ return e ? /* @__PURE__ */ t(Nt, { ...l, children: /* @__PURE__ */ t(Me, { color: "primary", "data-cy": "filter-tag", icon: o, label: e, onDelete: r }) }) : null;
593
591
  }
594
- A.propTypes = {
592
+ M.propTypes = {
595
593
  label: n.string,
596
594
  onDelete: n.func,
597
595
  icon: n.element
598
596
  };
599
- A.defaultProps = {
597
+ M.defaultProps = {
600
598
  onDelete: () => {
601
599
  },
602
600
  icon: null,
603
601
  label: null
604
602
  };
605
- function ce() {
603
+ function se() {
606
604
  const { t: e } = z();
607
- return /* @__PURE__ */ t(fe, { style: { textAlign: "center" }, variant: "subtitle2", children: e("blocklet.noResults") });
605
+ return /* @__PURE__ */ t(me, { style: { textAlign: "center" }, variant: "subtitle2", children: e("blocklet.noResults") });
608
606
  }
609
- function L({ filterTip: e, keywordTip: o }) {
607
+ function O({ filterTip: e, keywordTip: o }) {
610
608
  const { t: r, locale: l } = z(), i = () => l === "zh" ? "、" : " , ";
611
- return /* @__PURE__ */ g(H, { className: "tips", children: [
609
+ return /* @__PURE__ */ h(pt, { className: "tips", children: [
612
610
  /* @__PURE__ */ t("span", { style: { marginRight: "16px" }, children: r("blocklet.emptyTip") }),
613
611
  e && /* @__PURE__ */ t("span", { children: r("blocklet.filterTip") }),
614
612
  e && o && i(),
615
613
  o && /* @__PURE__ */ t("span", { children: r("blocklet.keywordTip") })
616
614
  ] });
617
615
  }
618
- L.propTypes = {
616
+ O.propTypes = {
619
617
  filterTip: n.bool,
620
618
  keywordTip: n.bool
621
619
  };
622
- L.defaultProps = {
620
+ O.defaultProps = {
623
621
  filterTip: !1,
624
622
  keywordTip: !1
625
623
  };
626
624
  function j({ primaryStart: e, primaryEnd: o, filter: r }) {
627
- return /* @__PURE__ */ g(fe, { variant: "subtitle2", children: [
625
+ return /* @__PURE__ */ h(me, { variant: "subtitle2", children: [
628
626
  /* @__PURE__ */ t("span", { children: e }),
629
- /* @__PURE__ */ g("span", { className: "primary", children: [
627
+ /* @__PURE__ */ h("span", { className: "primary", children: [
630
628
  " ",
631
629
  r,
632
630
  " "
633
631
  ] }),
634
- /* @__PURE__ */ g("span", { children: [
632
+ /* @__PURE__ */ h("span", { children: [
635
633
  o,
636
634
  " "
637
635
  ] })
@@ -647,14 +645,14 @@ function Y({ blocklets: e, ...o }) {
647
645
  blockletRender: r,
648
646
  errors: l,
649
647
  loadings: i,
650
- selectedCategory: s,
651
- getCategoryLocale: x,
652
- filters: y,
653
- t: p,
648
+ selectedCategory: c,
649
+ getCategoryLocale: k,
650
+ filters: g,
651
+ t: d,
654
652
  hasNextPage: b,
655
653
  loadMore: m,
656
654
  endpoint: P
657
- } = z(), B = !!s || !!y.price, [S] = ct({
655
+ } = z(), B = L(null), x = Je(B.current), y = Xe(() => x ? x.width > 900 ? 12 : x.width > 600 ? 8 : 4 : 0, [x]), $ = !!c || !!g.price, [p] = ct({
658
656
  loading: i.fetchBlockletsLoading || i.loadingMore,
659
657
  hasNextPage: b,
660
658
  onLoadMore: m
@@ -667,60 +665,61 @@ function Y({ blocklets: e, ...o }) {
667
665
  }
668
666
  );
669
667
  if (i.fetchBlockletsLoading)
670
- return /* @__PURE__ */ t(H, { height: 60, display: "flex", alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ t(se, {}) });
671
- if (y.keyword && B && e.length === 0)
672
- return /* @__PURE__ */ g(E, { children: [
668
+ return /* @__PURE__ */ t(_, { height: 60, display: "flex", alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ t(W, {}) });
669
+ if (g.keyword && $ && e.length === 0)
670
+ return /* @__PURE__ */ h(q, { children: [
673
671
  /* @__PURE__ */ t(
674
672
  j,
675
673
  {
676
- primaryStart: p("blocklet.noBlockletPart1"),
677
- primaryEnd: p("blocklet.noBlockletPart2"),
678
- filter: y.keyword
674
+ primaryStart: d("blocklet.noBlockletPart1"),
675
+ primaryEnd: d("blocklet.noBlockletPart2"),
676
+ filter: g.keyword
679
677
  }
680
678
  ),
681
- /* @__PURE__ */ t(L, { keywordTip: !0, filterTip: !0 })
679
+ /* @__PURE__ */ t(O, { keywordTip: !0, filterTip: !0 })
682
680
  ] });
683
- if (y.keyword && e.length === 0)
684
- return /* @__PURE__ */ g(E, { children: [
681
+ if (g.keyword && e.length === 0)
682
+ return /* @__PURE__ */ h(q, { children: [
685
683
  /* @__PURE__ */ t(
686
684
  j,
687
685
  {
688
- primaryStart: p("blocklet.noBlockletPart1"),
689
- primaryEnd: p("blocklet.noBlockletPart2"),
690
- filter: y.keyword
686
+ primaryStart: d("blocklet.noBlockletPart1"),
687
+ primaryEnd: d("blocklet.noBlockletPart2"),
688
+ filter: g.keyword
691
689
  }
692
690
  ),
693
- /* @__PURE__ */ t(L, { keywordTip: !0 })
691
+ /* @__PURE__ */ t(O, { keywordTip: !0 })
694
692
  ] });
695
- if (B && e.length === 0) {
696
- const c = x(s);
697
- return /* @__PURE__ */ g(E, { children: [
698
- c ? /* @__PURE__ */ t(
693
+ if ($ && e.length === 0) {
694
+ const s = k(c);
695
+ return /* @__PURE__ */ h(q, { children: [
696
+ s ? /* @__PURE__ */ t(
699
697
  j,
700
698
  {
701
- primaryStart: p("blocklet.noCategoryResults1"),
702
- primaryEnd: p("blocklet.noCategoryResults2"),
703
- filter: c
699
+ primaryStart: d("blocklet.noCategoryResults1"),
700
+ primaryEnd: d("blocklet.noCategoryResults2"),
701
+ filter: s
704
702
  }
705
- ) : /* @__PURE__ */ t(ce, {}),
706
- /* @__PURE__ */ t(L, { filterTip: !0 })
703
+ ) : /* @__PURE__ */ t(se, {}),
704
+ /* @__PURE__ */ t(O, { filterTip: !0 })
707
705
  ] });
708
706
  }
709
- return e.length === 0 ? /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(ce, {}) }) : /* @__PURE__ */ g(Nt, { container: !0, ...o, children: [
710
- e.map((c) => /* @__PURE__ */ t(pe, { item: !0, lg: 4, md: 6, sm: 6, xs: 12, "data-blocklet-did": c.did, children: r({ blocklet: c, blocklets: e }) }, c.did)),
711
- b && /* @__PURE__ */ t(pe, { item: !0, md: 12, sm: 12, xs: 12, ref: S, children: /* @__PURE__ */ t(H, { height: 60, display: "flex", justifyContent: "center", children: /* @__PURE__ */ t(se, {}) }) })
707
+ return e.length === 0 ? /* @__PURE__ */ t(q, { children: /* @__PURE__ */ t(se, {}) }) : /* @__PURE__ */ h(At, { container: !0, ...o, columns: y, ref: B, children: [
708
+ e.map((s) => /* @__PURE__ */ t(ce, { item: !0, xs: 4, "data-blocklet-did": s.did, children: r({ blocklet: s, blocklets: e }) }, s.did)),
709
+ b && /* @__PURE__ */ t(ce, { item: !0, xs: 12, ref: p, children: /* @__PURE__ */ t(_, { height: 60, display: "flex", justifyContent: "center", children: /* @__PURE__ */ t(W, {}) }) })
712
710
  ] });
713
711
  }
714
712
  Y.propTypes = {
715
713
  blocklets: n.array.isRequired
716
714
  };
717
715
  Y.defaultProps = {};
718
- const Nt = C(me)`
716
+ const At = C(de)`
717
+ opacity: ${(e) => e.columns > 0 ? 1 : 0};
719
718
  &.MuiGrid-root {
720
719
  width: 100%;
721
720
  margin: 0 -16px;
722
721
  }
723
- `, pe = We(C(me)`
722
+ `, ce = Ue(C(de)`
724
723
  @media (max-width: ${(e) => e.theme.breakpoints.values.sm}px) {
725
724
  &.MuiGrid-item {
726
725
  padding-bottom: 0px;
@@ -731,7 +730,7 @@ const Nt = C(me)`
731
730
  margin-bottom: ${(e) => e.theme.spacing(2)};
732
731
  }
733
732
  }
734
- `), E = C(st)`
733
+ `), q = C(st)`
735
734
  text-align: center;
736
735
  .primary {
737
736
  color: ${(e) => e.theme.palette.primary.main};
@@ -741,21 +740,21 @@ const Nt = C(me)`
741
740
  }
742
741
  `;
743
742
  function Z() {
744
- const { selectedCategory: e, handleCategory: o, t: r, handlePrice: l, filters: i, categoryOptions: s, priceOptions: x } = z();
745
- return /* @__PURE__ */ g(At, { children: [
746
- /* @__PURE__ */ t("div", { children: /* @__PURE__ */ t(_, { title: r("common.price"), options: x, value: i.price, onChange: l }) }),
747
- s.length > 0 && /* @__PURE__ */ t("div", { style: { marginTop: "16px" }, children: /* @__PURE__ */ t(
748
- _,
743
+ const { selectedCategory: e, handleCategory: o, t: r, handlePrice: l, filters: i, categoryOptions: c, priceOptions: k } = z();
744
+ return /* @__PURE__ */ h(Lt, { children: [
745
+ /* @__PURE__ */ t("div", { children: /* @__PURE__ */ t(D, { title: r("common.price"), options: k, value: i.price, onChange: l }) }),
746
+ c.length > 0 && /* @__PURE__ */ t("div", { style: { marginTop: "16px" }, children: /* @__PURE__ */ t(
747
+ D,
749
748
  {
750
749
  title: r("common.category"),
751
- options: s,
750
+ options: c,
752
751
  value: e,
753
752
  onChange: o
754
753
  }
755
754
  ) })
756
755
  ] });
757
756
  }
758
- const At = C("aside")`
757
+ const Lt = C("aside")`
759
758
  width: 220px;
760
759
  margin-right: ${(e) => e.theme.spacing(2)};
761
760
  height: 100%;
@@ -767,27 +766,27 @@ const At = C("aside")`
767
766
  Z.propTypes = {};
768
767
  Z.defaultProps = {};
769
768
  function ee({ placeholder: e, ...o }) {
770
- const { filters: r, handleKeyword: l } = z(), [i, s] = M(r.keyword || ""), x = Ye(l, { wait: 300 }), y = (b) => {
769
+ const { filters: r, handleKeyword: l } = z(), [i, c] = F(r.keyword || ""), k = Ye(l, { wait: 300 }), g = (b) => {
771
770
  const { value: m } = b.target;
772
- s(m), x.run(m);
773
- }, p = () => {
774
- s(""), l();
771
+ c(m), k.run(m);
772
+ }, d = () => {
773
+ c(""), l();
775
774
  };
776
- return O(() => {
777
- s(r.keyword || "");
775
+ return E(() => {
776
+ c(r.keyword || "");
778
777
  }, [r.keyword]), /* @__PURE__ */ t(
779
- Lt,
778
+ Mt,
780
779
  {
781
780
  inputProps: {
782
781
  "data-cy": "search-blocklet"
783
782
  },
784
- startAdornment: /* @__PURE__ */ t(le, { position: "start", children: /* @__PURE__ */ t(Mt, {}) }),
785
- onChange: y,
783
+ startAdornment: /* @__PURE__ */ t(le, { position: "start", children: /* @__PURE__ */ t(Ot, {}) }),
784
+ onChange: g,
786
785
  placeholder: e,
787
786
  value: i,
788
787
  title: e,
789
788
  "data-cy": "search",
790
- endAdornment: i && /* @__PURE__ */ t(le, { position: "end", children: /* @__PURE__ */ t(Ot, { "data-cy": "search-delete", onClick: p }) }),
789
+ endAdornment: i && /* @__PURE__ */ t(le, { position: "end", children: /* @__PURE__ */ t(Ft, { "data-cy": "search-delete", onClick: d }) }),
791
790
  ...o
792
791
  }
793
792
  );
@@ -798,7 +797,7 @@ ee.propTypes = {
798
797
  ee.defaultProps = {
799
798
  placeholder: "Type to search..."
800
799
  };
801
- const Lt = C(Ee)`
800
+ const Mt = C(Oe)`
802
801
  background-color: ${(e) => e.theme.palette.grey[50]};
803
802
  font-size: 14px;
804
803
  border-radius: 6px;
@@ -814,49 +813,49 @@ const Lt = C(Ee)`
814
813
  color: transparent;
815
814
  }
816
815
  }
817
- `, Mt = C(pt)`
816
+ `, Ot = C(dt)`
818
817
  color: ${(e) => e.theme.palette.grey[500]};
819
818
  font-size: 28px;
820
819
  @media (max-width: ${(e) => e.theme.breakpoints.values.md}px) {
821
820
  font-size: 24px;
822
821
  }
823
- `, Ot = C(dt)`
822
+ `, Ft = C(ut)`
824
823
  color: ${(e) => e.theme.palette.grey[500]};
825
824
  font-size: 16px;
826
825
  cursor: pointer;
827
826
  `;
828
827
  function te({ onSelect: e, wrapChildren: o }) {
829
- const r = q(null), l = q(null), i = q(null), { storeApi: s, blockletRender: x, filters: y, endpoint: p, handleKeyword: b, t: m } = z(), P = async (d) => {
830
- const { data: f } = await s.get(T.blockletsPath, { params: d }), k = f.dataList || [];
831
- return k.length > 0 && k.unshift({ type: "more-result", total: f.total || 0 }), k;
832
- }, B = (d) => {
833
- b(d.state.query), d.setIsOpen(!1);
834
- }, S = () => {
828
+ const r = L(null), l = L(null), i = L(null), { storeApi: c, blockletRender: k, filters: g, endpoint: d, handleKeyword: b, t: m } = z(), P = async (p) => {
829
+ const { data: s } = await c.get(T.blockletsPath, { params: p }), w = s.dataList || [];
830
+ return w.length > 0 && w.unshift({ type: "more-result", total: s.total || 0 }), w;
831
+ }, B = (p) => {
832
+ b(p.state.query), p.setIsOpen(!1);
833
+ }, x = () => {
835
834
  r.current && setTimeout(() => {
836
- const d = r.current.querySelector("input.bl-autocomplete-input");
837
- d && d.focus();
835
+ const p = r.current.querySelector("input.bl-autocomplete-input");
836
+ p && p.focus();
838
837
  });
839
- }, c = (d) => {
840
- d.setIsOpen(!1), S();
841
- }, $ = ({ prevState: d, state: f }) => {
842
- d.query !== f.query && (f.query || b());
838
+ }, y = (p) => {
839
+ p.setIsOpen(!1), x();
840
+ }, $ = ({ prevState: p, state: s }) => {
841
+ p.query !== s.query && (s.query || b());
843
842
  };
844
- return ft(
843
+ return ht(
845
844
  "ctrl + k, command + k",
846
- (d) => (d.stopPropagation(), d.preventDefault(), S(), !1),
845
+ (p) => (p.stopPropagation(), p.preventDefault(), x(), !1),
847
846
  { enableOnTags: ["INPUT"] }
848
- ), O(() => {
849
- S();
850
- }, [p]), O(() => {
847
+ ), E(() => {
848
+ x();
849
+ }, [d]), E(() => {
851
850
  if (!r.current)
852
851
  return;
853
- const d = mt({
852
+ const p = ft({
854
853
  container: r.current,
855
- renderer: { createElement: He, Fragment: Ve, render: () => {
854
+ renderer: { createElement: Ke, Fragment: We, render: () => {
856
855
  } },
857
- render({ children: f }, k) {
858
- var h;
859
- (!l.current || i.current !== k) && (i.current = k, (h = l.current) == null || h.unmount(), l.current = ut(k)), l.current.render(o(f));
856
+ render({ children: s }, w) {
857
+ var f;
858
+ (!l.current || i.current !== w) && (i.current = w, (f = l.current) == null || f.unmount(), l.current = mt(w)), l.current.render(o(s));
860
859
  },
861
860
  autoFocus: !0,
862
861
  openOnFocus: !1,
@@ -869,44 +868,44 @@ function te({ onSelect: e, wrapChildren: o }) {
869
868
  },
870
869
  placeholder: m("common.searchStore"),
871
870
  initialState: {
872
- query: y.keyword
871
+ query: g.keyword
873
872
  },
874
- onStateChange(f) {
875
- $(f);
873
+ onStateChange(s) {
874
+ $(s);
876
875
  },
877
876
  onSubmit: B,
878
- onReset(f) {
879
- c(f);
877
+ onReset(s) {
878
+ y(s);
880
879
  },
881
- getSources({ query: f, state: k, ...h }) {
882
- const D = {
883
- ...y,
884
- sortBy: T[y.sortBy],
880
+ getSources({ query: s, state: w, ...f }) {
881
+ const N = {
882
+ ...g,
883
+ sortBy: T[g.sortBy],
885
884
  page: 1,
886
885
  pageSize: 10,
887
- keyword: f
886
+ keyword: s
888
887
  };
889
- return Ct([
888
+ return Pt([
890
889
  {
891
890
  sourceId: "blocklets",
892
891
  getItems() {
893
- return P(D);
892
+ return P(N);
894
893
  },
895
894
  // 选中后填充 搜索框中值
896
- getItemInputValue({ item: w }) {
897
- return w.type === "more-result" ? f : w.title;
895
+ getItemInputValue({ item: v }) {
896
+ return v.type === "more-result" ? s : v.title;
898
897
  },
899
898
  // 选中或者点击自动完成列表中的 item 时触发
900
- onSelect({ event: w, item: I }) {
901
- return I.type === "more-result" ? (h.setIsOpen(!1), b(f)) : w.type === "keydown" ? b(I.title) : e({
899
+ onSelect({ event: v, item: I }) {
900
+ return I.type === "more-result" ? (f.setIsOpen(!1), b(s)) : v.type === "keydown" ? b(I.title) : e({
902
901
  blocklet: I,
903
- detailUrl: ht(p, `/blocklets/${I.did}`),
904
- storeUrl: p
902
+ detailUrl: gt(d, `/blocklets/${I.did}`),
903
+ storeUrl: d
905
904
  });
906
905
  },
907
906
  templates: {
908
- item({ item: w }) {
909
- return w.type === "more-result" ? /* @__PURE__ */ t("div", { children: m("autocomplete.expandResult", { name: f, number: w.total.toLocaleString() }) }) : x({ blocklet: w, autocompleteSetters: h });
907
+ item({ item: v }) {
908
+ return v.type === "more-result" ? /* @__PURE__ */ t("div", { children: m("autocomplete.expandResult", { name: s, number: v.total.toLocaleString() }) }) : k({ blocklet: v, autocompleteSetters: f });
910
909
  },
911
910
  noResults() {
912
911
  return m("blocklet.noResults");
@@ -917,9 +916,9 @@ function te({ onSelect: e, wrapChildren: o }) {
917
916
  }
918
917
  });
919
918
  return () => {
920
- d.destroy();
919
+ p.destroy();
921
920
  };
922
- }, [y, x]), /* @__PURE__ */ t("div", { className: "bl-search-container", ref: r });
921
+ }, [g, k]), /* @__PURE__ */ t("div", { className: "bl-search-container", ref: r });
923
922
  }
924
923
  te.propTypes = {
925
924
  onSelect: n.func.isRequired,
@@ -928,81 +927,81 @@ te.propTypes = {
928
927
  te.defaultProps = {
929
928
  wrapChildren: (e) => e
930
929
  };
931
- function Ft() {
932
- var f, k;
930
+ function Et() {
931
+ var s, w;
933
932
  const {
934
933
  handleDeveloper: e,
935
934
  blockletList: o,
936
935
  filters: r,
937
936
  developerName: l,
938
937
  handleSort: i,
939
- handleCategory: s,
940
- handlePrice: x,
941
- handleSearchSelect: y,
942
- t: p,
938
+ handleCategory: c,
939
+ handlePrice: k,
940
+ handleSearchSelect: g,
941
+ t: d,
943
942
  getCategoryLocale: b,
944
943
  priceOptions: m,
945
944
  wrapChildren: P,
946
945
  baseSearch: B
947
- } = z(), S = gt(p), c = ((f = S.find((h) => h.value === r.sortBy)) == null ? void 0 : f.name) || p("sort.sort"), $ = b(r.category), d = (k = m.find((h) => h.value === r.price)) == null ? void 0 : k.name;
948
- return /* @__PURE__ */ g(F, { display: "flex", alignItems: "flex-start", height: "100%", children: [
946
+ } = z(), x = yt(d), y = ((s = x.find((f) => f.value === r.sortBy)) == null ? void 0 : s.name) || d("sort.sort"), $ = b(r.category), p = (w = m.find((f) => f.value === r.price)) == null ? void 0 : w.name;
947
+ return /* @__PURE__ */ h(_, { display: "flex", alignItems: "flex-start", height: "100%", children: [
949
948
  /* @__PURE__ */ t(ae, { mdDown: !0, children: /* @__PURE__ */ t(Z, {}) }),
950
- /* @__PURE__ */ g(Et, { children: [
951
- /* @__PURE__ */ g(qt, { children: [
952
- /* @__PURE__ */ g(F, { className: "filter-bar", display: "flex", alignItems: "center", children: [
953
- B ? /* @__PURE__ */ t(ee, { className: "bl-search-container", placeholder: p("common.searchStore") }) : /* @__PURE__ */ t(te, { onSelect: y, wrapChildren: P }),
954
- /* @__PURE__ */ g(F, { mt: 0, ml: "16px", className: "filter-container", children: [
949
+ /* @__PURE__ */ h(qt, { children: [
950
+ /* @__PURE__ */ h(jt, { children: [
951
+ /* @__PURE__ */ h(_, { className: "filter-bar", display: "flex", alignItems: "center", children: [
952
+ B ? /* @__PURE__ */ t(ee, { className: "bl-search-container", placeholder: d("common.searchStore") }) : /* @__PURE__ */ t(te, { onSelect: g, wrapChildren: P }),
953
+ /* @__PURE__ */ h(_, { mt: 0, ml: "16px", className: "filter-container", children: [
955
954
  /* @__PURE__ */ t(ae, { mdUp: !0, children: /* @__PURE__ */ t(X, {}) }),
956
955
  /* @__PURE__ */ t(
957
956
  J,
958
957
  {
959
958
  value: r.sortBy,
960
- options: S,
961
- title: c,
962
- icon: /* @__PURE__ */ t(Te, {}),
963
- onChange: (h) => {
964
- i(h);
959
+ options: x,
960
+ title: y,
961
+ icon: /* @__PURE__ */ t($e, {}),
962
+ onChange: (f) => {
963
+ i(f);
965
964
  }
966
965
  }
967
966
  )
968
967
  ] })
969
968
  ] }),
970
- /* @__PURE__ */ g(F, { display: "flex", flexWrap: "wrap", alignItems: "center", mb: "16px", children: [
969
+ /* @__PURE__ */ h(_, { display: "flex", flexWrap: "wrap", alignItems: "center", mb: "16px", children: [
971
970
  /* @__PURE__ */ t(
972
- A,
971
+ M,
973
972
  {
974
973
  label: l,
975
- icon: /* @__PURE__ */ t(qe, {}),
974
+ icon: /* @__PURE__ */ t(Fe, {}),
976
975
  onDelete: () => {
977
976
  e(null);
978
977
  }
979
978
  }
980
979
  ),
981
980
  /* @__PURE__ */ t(
982
- A,
981
+ M,
983
982
  {
984
983
  label: $,
985
984
  onDelete: () => {
986
- s(null);
985
+ c(null);
987
986
  }
988
987
  }
989
988
  ),
990
989
  /* @__PURE__ */ t(
991
- A,
990
+ M,
992
991
  {
993
- label: d,
992
+ label: p,
994
993
  onDelete: () => {
995
- x(null);
994
+ k(null);
996
995
  }
997
996
  }
998
997
  )
999
998
  ] })
1000
999
  ] }),
1001
- /* @__PURE__ */ t(je, { FallbackComponent: ue, children: /* @__PURE__ */ t("div", { style: { position: "relative", flex: 1, overflow: "auto" }, children: /* @__PURE__ */ t(Y, { blocklets: o }) }) })
1000
+ /* @__PURE__ */ t(Ee, { FallbackComponent: ue, children: /* @__PURE__ */ t("div", { style: { position: "relative", flex: 1, overflow: "auto" }, children: /* @__PURE__ */ t(Y, { blocklets: o }) }) })
1002
1001
  ] })
1003
1002
  ] });
1004
1003
  }
1005
- const Et = C("main")`
1004
+ const qt = C("main")`
1006
1005
  display: flex;
1007
1006
  flex-direction: column;
1008
1007
  flex: 1;
@@ -1046,15 +1045,15 @@ const Et = C("main")`
1046
1045
  font-size: 12px;
1047
1046
  }
1048
1047
  }
1049
- `, qt = C("div")`
1048
+ `, jt = C("div")`
1050
1049
  position: sticky;
1051
1050
  top: 0;
1052
1051
  z-index: 9;
1053
1052
  background-color: white;
1054
1053
  `;
1055
- function be(e) {
1056
- const o = de(), r = vt(o.palette.primary.main), l = {
1057
- autocomplete: Be`
1054
+ function ye(e) {
1055
+ const o = pe(), r = St(o.palette.primary.main), l = {
1056
+ autocomplete: Pe`
1058
1057
  :root {
1059
1058
  --aa-detached-media-query: (max-width: ${o.breakpoints.values.md}px) !important;
1060
1059
  --aa-detached-modal-media-query: (min-width: ${o.breakpoints.values.md}px) !important;
@@ -1092,13 +1091,13 @@ function be(e) {
1092
1091
  }
1093
1092
  `
1094
1093
  };
1095
- return /* @__PURE__ */ g(V, { ...e, children: [
1096
- /* @__PURE__ */ t($e, { styles: l.autocomplete }),
1097
- /* @__PURE__ */ t(Ft, {})
1094
+ return /* @__PURE__ */ h(V, { ...e, children: [
1095
+ /* @__PURE__ */ t(Be, { styles: l.autocomplete }),
1096
+ /* @__PURE__ */ t(Et, {})
1098
1097
  ] });
1099
1098
  }
1100
- be.propTypes = he;
1101
- be.defaultProps = ge;
1099
+ ye.propTypes = fe;
1100
+ ye.defaultProps = he;
1102
1101
  export {
1103
- be as default
1102
+ ye as default
1104
1103
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/list",
3
- "version": "0.12.43",
3
+ "version": "0.12.45",
4
4
  "description": "Common ux components of blocklet",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -52,7 +52,7 @@
52
52
  "dependencies": {
53
53
  "@algolia/autocomplete-js": "^1.7.1",
54
54
  "@algolia/autocomplete-theme-classic": "^1.7.1",
55
- "@arcblock/ux": "^2.7.21",
55
+ "@arcblock/ux": "^2.7.25",
56
56
  "@emotion/react": "^11.10.0",
57
57
  "@emotion/styled": "^11.10.0",
58
58
  "@mui/icons-material": "^5.14.9",
@@ -83,5 +83,5 @@
83
83
  "prettier": "^2.7.1",
84
84
  "vite": "^4.4.9"
85
85
  },
86
- "gitHead": "dcd0f015f82cb76d2cd1b33145743b905c3c1927"
86
+ "gitHead": "af2dc0bea8f1efa9d104aa84c6d0cca87a55218d"
87
87
  }