@blocklet/list 0.12.76 → 0.12.78

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.
@@ -11,7 +11,10 @@ const en = {
11
11
  searchStore: 'Search the store',
12
12
  price: 'Price',
13
13
  category: 'Category',
14
- resourceType: 'Resource Type'
14
+ resourceType: 'Resource Type',
15
+ clear: 'Clear',
16
+ cancel: 'Cancel',
17
+ search: 'Search'
15
18
  },
16
19
  sort: {
17
20
  sort: 'Sort',
@@ -47,7 +50,10 @@ const zh = {
47
50
  searchStore: '搜索商店内应用',
48
51
  price: '价格',
49
52
  category: '类别',
50
- resourceType: '资源类型'
53
+ resourceType: '资源类型',
54
+ clear: '清除',
55
+ cancel: '取消',
56
+ search: '搜索'
51
57
  },
52
58
  sort: {
53
59
  sort: '排序',
@@ -9,13 +9,16 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _client = require("react-dom/client");
10
10
  var _autocompleteJs = require("@algolia/autocomplete-js");
11
11
  var _reactHotkeysHook = require("react-hotkeys-hook");
12
+ var _react2 = require("@emotion/react");
12
13
  var _urlJoin = _interopRequireDefault(require("url-join"));
13
14
  var _constant = _interopRequireDefault(require("../../libs/constant"));
14
15
  var _utils = require("../../libs/utils");
15
16
  var _filter = require("../../contexts/filter");
16
17
  var _jsxRuntime = require("react/jsx-runtime");
18
+ var _templateObject;
17
19
  const _excluded = ["query", "state"];
18
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
19
22
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
20
23
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
21
24
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -127,7 +130,15 @@ function Autocomplete(_ref) {
127
130
  label: 'bl-autocomplete-label',
128
131
  form: 'bl-autocomplete-form',
129
132
  input: 'bl-autocomplete-input',
130
- clearButton: 'bl-autocomplete-clear'
133
+ clearButton: 'bl-autocomplete-clear',
134
+ detachedCancelButton: 'bl-autocomplete-detached-cancel',
135
+ detachedContainer: 'bl-autocomplete-detached-container'
136
+ },
137
+ translations: {
138
+ clearButtonTitle: t('common.clear'),
139
+ detachedCancelButtonText: t('common.cancel'),
140
+ submitButtonTitle: t('common.search'),
141
+ detachedSearchButtonTitle: t('common.search')
131
142
  },
132
143
  placeholder: t('common.searchStore'),
133
144
  initialState: {
@@ -216,9 +227,13 @@ function Autocomplete(_ref) {
216
227
  };
217
228
  // eslint-disable-next-line react-hooks/exhaustive-deps
218
229
  }, [filters, blockletRender]);
219
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
220
- className: "bl-search-container",
221
- ref: containerRef
230
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
231
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Global, {
232
+ styles: (0, _react2.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .bl-autocomplete-detached-container {\n .bl-autocomplete-detached-cancel {\n white-space: nowrap;\n }\n }\n "])))
233
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
234
+ className: "bl-search-container",
235
+ ref: containerRef
236
+ })]
222
237
  });
223
238
  }
224
239
  Autocomplete.propTypes = {
package/lib/index.es.js CHANGED
@@ -1,12 +1,12 @@
1
- import { jsx as t, jsxs as h, Fragment as Pe } from "react/jsx-runtime";
2
- import { useTheme as pe } from "@mui/material/styles";
3
- import { css as Te, Global as Be } from "@emotion/react";
1
+ import { jsx as t, jsxs as f, Fragment as pe } from "react/jsx-runtime";
2
+ import { useTheme as de } from "@mui/material/styles";
3
+ import { Global as ue, css as me } from "@emotion/react";
4
4
  import { styled as C } from "@arcblock/ux/lib/Theme";
5
5
  import $e from "@mui/icons-material/Sort";
6
- import { Button as Re, CircularProgress as W, MenuList as ze, useMediaQuery as Ie, SvgIcon as _e, Popper as De, Grow as Ne, Paper as Ae, ClickAwayListener as Le, MenuItem as Me, Chip as Oe, Grid as ue, Box as D, OutlinedInput as Fe, InputAdornment as le, Hidden as ae } from "@mui/material";
6
+ import { Button as Re, CircularProgress as W, MenuList as ze, useMediaQuery as Ie, SvgIcon as _e, Popper as De, Grow as Ne, Paper as Ae, ClickAwayListener as Le, MenuItem as Me, Chip as Oe, Grid as he, Box as D, OutlinedInput as Fe, InputAdornment as le, Hidden as ae } from "@mui/material";
7
7
  import Ee from "@mui/icons-material/Face";
8
8
  import { ErrorBoundary as qe } from "react-error-boundary";
9
- import { ErrorFallback as de } from "@arcblock/ux/lib/ErrorBoundary";
9
+ import { ErrorFallback as fe } from "@arcblock/ux/lib/ErrorBoundary";
10
10
  import { createContext as je, useMemo as L, useState as F, useCallback as H, useEffect as E, useContext as Ge, forwardRef as Ue, useRef as M, memo as Ke, createElement as We, Fragment as He } from "react";
11
11
  import o from "prop-types";
12
12
  import { useReactive as Ve, useInfiniteScroll as Qe, useRequest as Je, useSize as Xe, useCreation as Ye, useDebounceFn as Ze } from "ahooks";
@@ -23,12 +23,12 @@ import it from "@arcblock/ux/lib/Dialog";
23
23
  import st from "@mui/material/Button";
24
24
  import ct from "@arcblock/ux/lib/Empty";
25
25
  import pt from "react-infinite-scroll-hook";
26
- import ut from "@mui/material/Box";
27
- import me from "@mui/material/Typography";
28
- import dt from "@mui/icons-material/Search";
26
+ import dt from "@mui/material/Box";
27
+ import ge from "@mui/material/Typography";
28
+ import ut from "@mui/icons-material/Search";
29
29
  import mt from "@mui/icons-material/Close";
30
- import { createRoot as ft } from "react-dom/client";
31
- import { autocomplete as ht } from "@algolia/autocomplete-js";
30
+ import { createRoot as ht } from "react-dom/client";
31
+ import { autocomplete as ft } from "@algolia/autocomplete-js";
32
32
  import { useHotkeys as gt } from "react-hotkeys-hook";
33
33
  import yt from "url-join";
34
34
  import "@algolia/autocomplete-theme-classic/dist/theme.css";
@@ -55,7 +55,7 @@ const bt = (e) => [
55
55
  ], kt = (e = [], n = "en") => e.map((r) => ({ name: r.locales[n] || `Category.${n}`, value: r._id })), wt = (e, n) => (
56
56
  // eslint-disable-next-line no-prototype-builtins
57
57
  e.replace(/{(\w*)}/g, (r, l) => n.hasOwnProperty(l) ? n[l] : "")
58
- ), vt = () => window.innerWidth <= 600, St = (e, n) => {
58
+ ), St = () => window.innerWidth <= 600, vt = (e, n) => {
59
59
  const r = (e + n) / n;
60
60
  return r > 1 ? r.toFixed() : 1;
61
61
  }, Ct = (e) => ot(e).rgb().object();
@@ -72,7 +72,10 @@ const Tt = Pt((e) => Promise.resolve(e), 300), Bt = {
72
72
  searchStore: "Search the store",
73
73
  price: "Price",
74
74
  category: "Category",
75
- resourceType: "Resource Type"
75
+ resourceType: "Resource Type",
76
+ clear: "Clear",
77
+ cancel: "Cancel",
78
+ search: "Search"
76
79
  },
77
80
  sort: {
78
81
  sort: "Sort",
@@ -107,7 +110,10 @@ const Tt = Pt((e) => Promise.resolve(e), 300), Bt = {
107
110
  searchStore: "搜索商店内应用",
108
111
  price: "价格",
109
112
  category: "类别",
110
- resourceType: "资源类型"
113
+ resourceType: "资源类型",
114
+ clear: "清除",
115
+ cancel: "取消",
116
+ search: "搜索"
111
117
  },
112
118
  sort: {
113
119
  sort: "排序",
@@ -140,7 +146,7 @@ const Tt = Pt((e) => Promise.resolve(e), 300), Bt = {
140
146
  }, K = {
141
147
  en: ie(Bt),
142
148
  zh: ie($t)
143
- }, fe = {
149
+ }, ye = {
144
150
  filters: o.shape({
145
151
  keyword: o.string,
146
152
  sortBy: o.string,
@@ -160,7 +166,7 @@ const Tt = Pt((e) => Promise.resolve(e), 300), Bt = {
160
166
  baseSearch: o.bool,
161
167
  // sometimes blocklet list can be rendered only before the category is fetched
162
168
  fetchCategoryDelay: o.number
163
- }, he = {
169
+ }, be = {
164
170
  locale: "zh",
165
171
  filters: {},
166
172
  onFilterChange: () => {
@@ -183,7 +189,7 @@ const Tt = Pt((e) => Promise.resolve(e), 300), Bt = {
183
189
  blockletsPath: "/api/v2/blocklets.json",
184
190
  categoriesPath: "/api/blocklets/categories",
185
191
  cacheSize: 100
186
- }, ge = je({}), { Provider: Rt, Consumer: Cr } = ge;
192
+ }, xe = je({}), { Provider: Rt, Consumer: Cr } = xe;
187
193
  function V({
188
194
  filters: e,
189
195
  children: n,
@@ -193,40 +199,40 @@ function V({
193
199
  onFilterChange: c,
194
200
  onSearchSelect: k,
195
201
  extraFilter: g,
196
- wrapChildren: p,
202
+ wrapChildren: d,
197
203
  baseSearch: y,
198
- serverVersion: f,
204
+ serverVersion: p,
199
205
  storeVersion: P,
200
206
  fetchCategoryDelay: B
201
207
  }) {
202
208
  const b = {};
203
- f && (b["x-blocklet-server-version"] = f), P && (b["x-blocklet-store-version"] = P);
209
+ p && (b["x-blocklet-server-version"] = p), P && (b["x-blocklet-store-version"] = P);
204
210
  const $ = L(() => tt.create({
205
211
  baseURL: r,
206
212
  headers: b
207
- }), [r]), d = L(() => ({ sortBy: "popularity", sortDirection: "desc", ...e }), [e]), u = d.category, s = Ve({
213
+ }), [r]), m = L(() => ({ sortBy: "popularity", sortDirection: "desc", ...e }), [e]), u = m.category, s = Ve({
208
214
  currentPage: R.currentPage,
209
- pageSize: vt() ? R.mobilePageSize : R.pageSize,
215
+ pageSize: St() ? R.mobilePageSize : R.pageSize,
210
216
  defaultCurrentPage: R.defaultCurrentPage
211
- }), [S, x] = F(null), {
217
+ }), [v, x] = F(null), {
212
218
  data: T = { list: [], total: 0 },
213
219
  loading: w,
214
220
  loadMore: _,
215
- loadingMore: be
221
+ loadingMore: we
216
222
  } = Qe(
217
223
  async (a) => {
218
224
  var z;
219
- const m = {
220
- ...d,
221
- sortBy: R[d.sortBy],
222
- page: St(((z = a == null ? void 0 : a.list) == null ? void 0 : z.length) || 0, s.pageSize),
225
+ const h = {
226
+ ...m,
227
+ sortBy: R[m.sortBy],
228
+ page: vt(((z = a == null ? void 0 : a.list) == null ? void 0 : z.length) || 0, s.pageSize),
223
229
  pageSize: s.pageSize
224
230
  };
225
231
  x(null);
226
- const { data: v = {} } = await $.get(R.blockletsPath, {
227
- params: m
232
+ const { data: S = {} } = await $.get(R.blockletsPath, {
233
+ params: h
228
234
  });
229
- return { list: (v == null ? void 0 : v.dataList) || [], total: (v == null ? void 0 : v.total) || 0 };
235
+ return { list: (S == null ? void 0 : S.dataList) || [], total: (S == null ? void 0 : S.total) || 0 };
230
236
  },
231
237
  {
232
238
  isNoMore: (a) => a ? a.list.length >= a.total : !1,
@@ -237,73 +243,73 @@ function V({
237
243
  }
238
244
  ), {
239
245
  data: G = [],
240
- error: xe,
241
- loading: ke,
242
- run: we
246
+ error: Se,
247
+ loading: ve,
248
+ run: Ce
243
249
  } = Je(
244
250
  async () => {
245
251
  const { data: a } = await $.get(R.categoriesPath);
246
252
  return Array.isArray(a) ? a : [];
247
253
  },
248
254
  { manual: !0 }
249
- ), U = L(() => et(G || [], [(m) => m.name], ["asc"]), [G]), re = H(
250
- (a, m) => {
251
- const v = K[l] ? K[l][a] : K.en[a];
252
- return wt(v, m);
255
+ ), U = L(() => et(G || [], [(h) => h.name], ["asc"]), [G]), re = H(
256
+ (a, h) => {
257
+ const S = K[l] ? K[l][a] : K.en[a];
258
+ return wt(S, h);
253
259
  },
254
260
  [l]
255
261
  ), oe = L(() => {
256
262
  let a = T.list || [];
257
263
  return a = g(a), a;
258
- }, [T, g]), ve = L(() => kt(U, l), [U, l]), Se = xt(re), Ce = {
259
- errors: { fetchBlockletsError: S, fetchCategoriesError: xe },
260
- loadings: { fetchBlockletsLoading: w, fetchCategoriesLoading: ke, loadingMore: be },
264
+ }, [T, g]), Pe = L(() => kt(U, l), [U, l]), Te = xt(re), Be = {
265
+ errors: { fetchBlockletsError: v, fetchCategoriesError: Se },
266
+ loadings: { fetchBlockletsLoading: w, fetchCategoriesLoading: ve, loadingMore: we },
261
267
  endpoint: r,
262
268
  blockletList: oe,
263
- wrapChildren: p,
269
+ wrapChildren: d,
264
270
  t: re,
265
- filters: d,
271
+ filters: m,
266
272
  selectedCategory: u,
267
273
  categoryList: U,
268
274
  blockletRender: i,
269
275
  locale: l,
270
- categoryOptions: ve,
271
- priceOptions: Se,
276
+ categoryOptions: Pe,
277
+ priceOptions: Te,
272
278
  storeApi: $,
273
279
  baseSearch: y,
274
280
  hasNextPage: T.list.length < T.total,
275
281
  handleSort: (a) => {
276
- const m = {
277
- ...d,
282
+ const h = {
283
+ ...m,
278
284
  sortBy: a,
279
285
  sortDirection: a === "nameAsc" ? "asc" : "desc"
280
286
  };
281
- c(m);
287
+ c(h);
282
288
  },
283
289
  handleKeyword: (a) => {
284
- const m = { ...d, keyword: a || void 0 };
285
- c(m);
290
+ const h = { ...m, keyword: a || void 0 };
291
+ c(h);
286
292
  },
287
293
  handlePrice: (a) => {
288
- const m = {
289
- ...d,
290
- price: a === d.price ? void 0 : a
294
+ const h = {
295
+ ...m,
296
+ price: a === m.price ? void 0 : a
291
297
  };
292
- c(m);
298
+ c(h);
293
299
  },
294
300
  handleCategory: (a) => {
295
- let m = a;
296
- (a === "all" || a === d.category) && (m = void 0);
297
- const v = { ...d, category: m };
298
- c(v);
301
+ let h = a;
302
+ (a === "all" || a === m.category) && (h = void 0);
303
+ const S = { ...m, category: h };
304
+ c(S);
299
305
  },
300
306
  handleDeveloper: (a) => {
301
- const m = { ...d, owner: a || void 0 };
302
- c(m);
307
+ const h = { ...m, owner: a || void 0 };
308
+ c(h);
303
309
  },
304
310
  handlePage: (a) => {
305
- const m = { ...d, currentPage: a };
306
- c(m);
311
+ const h = { ...m, currentPage: a };
312
+ c(h);
307
313
  },
308
314
  loadMore: () => {
309
315
  _();
@@ -311,32 +317,32 @@ function V({
311
317
  getCategoryLocale: (a) => {
312
318
  if (!a)
313
319
  return null;
314
- let m = null;
315
- const v = G.find((z) => z._id === a);
316
- return v && (m = v.locales[l]), m;
320
+ let h = null;
321
+ const S = G.find((z) => z._id === a);
322
+ return S && (h = S.locales[l]), h;
317
323
  },
318
324
  get developerName() {
319
- var m, v;
320
- return ((v = (m = oe.find((z) => {
325
+ var h, S;
326
+ return ((S = (h = oe.find((z) => {
321
327
  var ne;
322
- return ((ne = z == null ? void 0 : z.owner) == null ? void 0 : ne.did) === d.owner;
323
- })) == null ? void 0 : m.owner) == null ? void 0 : v.name) || "";
328
+ return ((ne = z == null ? void 0 : z.owner) == null ? void 0 : ne.did) === m.owner;
329
+ })) == null ? void 0 : h.owner) == null ? void 0 : S.name) || "";
324
330
  },
325
331
  handleSearchSelect: k
326
332
  };
327
333
  return E(() => {
328
334
  setTimeout(() => {
329
- we();
335
+ Ce();
330
336
  }, B || 0);
331
- }, [r]), /* @__PURE__ */ t(Rt, { value: Ce, children: n });
337
+ }, [r]), /* @__PURE__ */ t(Rt, { value: Be, children: n });
332
338
  }
333
339
  V.propTypes = {
334
- ...fe,
340
+ ...ye,
335
341
  children: o.any.isRequired
336
342
  };
337
- V.defaultProps = he;
343
+ V.defaultProps = be;
338
344
  function I() {
339
- const e = Ge(ge);
345
+ const e = Ge(xe);
340
346
  return e || {};
341
347
  }
342
348
  const zt = C(Re)`
@@ -365,26 +371,26 @@ Q.defaultProps = {
365
371
  disabled: !1
366
372
  };
367
373
  function J({ title: e, value: n, icon: r, prepend: l, options: i, onChange: c, itemRender: k, ...g }) {
368
- const p = M(null), y = pe(), [f, P] = F(!1), [B, b] = F(n !== null ? n : ""), $ = Ie(y.breakpoints.down("sm"));
374
+ const d = M(null), y = de(), [p, P] = F(!1), [B, b] = F(n !== null ? n : ""), $ = Ie(y.breakpoints.down("sm"));
369
375
  E(() => {
370
376
  b(n !== null ? n : "");
371
377
  }, [n]);
372
- const d = H(() => {
378
+ const m = H(() => {
373
379
  P(!1);
374
380
  }, []), u = H(() => {
375
381
  P(!0);
376
382
  }, []);
377
383
  function s(x) {
378
- b(x.value), c(x.value), $ && d();
384
+ b(x.value), c(x.value), $ && m();
379
385
  }
380
- function S(x) {
386
+ function v(x) {
381
387
  return x === B;
382
388
  }
383
- return /* @__PURE__ */ h(Pe, { children: [
384
- /* @__PURE__ */ h(
389
+ return /* @__PURE__ */ f(pe, { children: [
390
+ /* @__PURE__ */ f(
385
391
  It,
386
392
  {
387
- ref: p,
393
+ ref: d,
388
394
  onClick: u,
389
395
  variant: "outlined",
390
396
  size: "small",
@@ -397,12 +403,12 @@ function J({ title: e, value: n, icon: r, prepend: l, options: i, onChange: c, i
397
403
  ]
398
404
  }
399
405
  ),
400
- /* @__PURE__ */ t(De, { open: f, anchorEl: p.current, transition: !0, style: { zIndex: "9999" }, children: ({ TransitionProps: x, placement: T }) => /* @__PURE__ */ t(
406
+ /* @__PURE__ */ t(De, { open: p, anchorEl: d.current, transition: !0, style: { zIndex: "9999" }, children: ({ TransitionProps: x, placement: T }) => /* @__PURE__ */ t(
401
407
  Ne,
402
408
  {
403
409
  ...x,
404
410
  style: { transformOrigin: T === "bottom" ? "center top" : "center bottom" },
405
- children: /* @__PURE__ */ t(Ae, { children: /* @__PURE__ */ t(Le, { onClickAway: d, children: /* @__PURE__ */ h(_t, { autoFocusItem: f, onMouseEnter: u, onMouseLeave: d, children: [
411
+ children: /* @__PURE__ */ t(Ae, { children: /* @__PURE__ */ t(Le, { onClickAway: m, children: /* @__PURE__ */ f(_t, { autoFocusItem: p, onMouseEnter: u, onMouseLeave: m, children: [
406
412
  l,
407
413
  i.map((w) => k ? k(w) : /* @__PURE__ */ t(
408
414
  Me,
@@ -410,7 +416,7 @@ function J({ title: e, value: n, icon: r, prepend: l, options: i, onChange: c, i
410
416
  onClick: () => s(w),
411
417
  className: [
412
418
  "my-select__option",
413
- S(w.value) ? "my-select__option--active" : ""
419
+ v(w.value) ? "my-select__option--active" : ""
414
420
  ].join(" "),
415
421
  children: w.name
416
422
  },
@@ -488,7 +494,7 @@ const It = C(Q)`
488
494
  }
489
495
  `;
490
496
  function A({ options: e, onChange: n, title: r, value: l }) {
491
- return /* @__PURE__ */ h(Dt, { children: [
497
+ return /* @__PURE__ */ f(Dt, { children: [
492
498
  /* @__PURE__ */ t("div", { className: "title", children: r }),
493
499
  /* @__PURE__ */ t("div", { className: "list", children: e.map((i) => /* @__PURE__ */ t(
494
500
  "div",
@@ -541,20 +547,20 @@ A.defaultProps = {
541
547
  value: null
542
548
  };
543
549
  function X() {
544
- const { selectedCategory: e, handleCategory: n, t: r, handlePrice: l, filters: i, categoryOptions: c, priceOptions: k } = I(), [g, p] = F(!1), y = (f, P) => {
545
- f === "category" && n(P), f === "price" && l(P), p(!1);
550
+ const { selectedCategory: e, handleCategory: n, t: r, handlePrice: l, filters: i, categoryOptions: c, priceOptions: k } = I(), [g, d] = F(!1), y = (p, P) => {
551
+ p === "category" && n(P), p === "price" && l(P), d(!1);
546
552
  };
547
- return /* @__PURE__ */ h(Nt, { children: [
548
- /* @__PURE__ */ t(st, { variant: "outlined", className: "filter-button", onClick: () => p(!0), children: /* @__PURE__ */ t(at, { className: "filter-icon", fontSize: "small" }) }),
549
- /* @__PURE__ */ h(it, { fullWidth: !0, title: "", open: g, onClose: () => p(!1), children: [
553
+ return /* @__PURE__ */ f(Nt, { children: [
554
+ /* @__PURE__ */ t(st, { variant: "outlined", className: "filter-button", onClick: () => d(!0), children: /* @__PURE__ */ t(at, { className: "filter-icon", fontSize: "small" }) }),
555
+ /* @__PURE__ */ f(it, { fullWidth: !0, title: "", open: g, onClose: () => d(!1), children: [
550
556
  /* @__PURE__ */ t(
551
557
  A,
552
558
  {
553
559
  title: r("common.price"),
554
560
  options: k,
555
561
  value: i.price,
556
- onChange: (f) => {
557
- y("price", f);
562
+ onChange: (p) => {
563
+ y("price", p);
558
564
  }
559
565
  }
560
566
  ),
@@ -564,8 +570,8 @@ function X() {
564
570
  title: r("common.category"),
565
571
  options: c,
566
572
  value: e,
567
- onChange: (f) => {
568
- y("category", f);
573
+ onChange: (p) => {
574
+ y("category", p);
569
575
  }
570
576
  }
571
577
  ) })
@@ -610,11 +616,11 @@ N.defaultProps = {
610
616
  };
611
617
  function se() {
612
618
  const { t: e } = I();
613
- return /* @__PURE__ */ t(me, { style: { textAlign: "center" }, variant: "subtitle2", children: e("blocklet.noResults") });
619
+ return /* @__PURE__ */ t(ge, { style: { textAlign: "center" }, variant: "subtitle2", children: e("blocklet.noResults") });
614
620
  }
615
621
  function O({ filterTip: e, keywordTip: n }) {
616
622
  const { t: r, locale: l } = I(), i = () => l === "zh" ? "、" : " , ";
617
- return /* @__PURE__ */ h(ut, { className: "tips", children: [
623
+ return /* @__PURE__ */ f(dt, { className: "tips", children: [
618
624
  /* @__PURE__ */ t("span", { style: { marginRight: "16px" }, children: r("blocklet.emptyTip") }),
619
625
  e && /* @__PURE__ */ t("span", { children: r("blocklet.filterTip") }),
620
626
  e && n && i(),
@@ -630,14 +636,14 @@ O.defaultProps = {
630
636
  keywordTip: !1
631
637
  };
632
638
  function j({ primaryStart: e, primaryEnd: n, filter: r }) {
633
- return /* @__PURE__ */ h(me, { variant: "subtitle2", children: [
639
+ return /* @__PURE__ */ f(ge, { variant: "subtitle2", children: [
634
640
  /* @__PURE__ */ t("span", { children: e }),
635
- /* @__PURE__ */ h("span", { className: "primary", children: [
641
+ /* @__PURE__ */ f("span", { className: "primary", children: [
636
642
  " ",
637
643
  r,
638
644
  " "
639
645
  ] }),
640
- /* @__PURE__ */ h("span", { children: [
646
+ /* @__PURE__ */ f("span", { children: [
641
647
  n,
642
648
  " "
643
649
  ] })
@@ -656,63 +662,63 @@ function Y({ blocklets: e, ...n }) {
656
662
  selectedCategory: c,
657
663
  getCategoryLocale: k,
658
664
  filters: g,
659
- t: p,
665
+ t: d,
660
666
  hasNextPage: y,
661
- loadMore: f,
667
+ loadMore: p,
662
668
  endpoint: P
663
- } = I(), B = M(null), b = Xe(B.current), $ = Ye(() => b ? b.width > 900 ? 12 : b.width > 600 ? 8 : 4 : 0, [b]), d = !!c || !!g.price, [u] = pt({
669
+ } = I(), B = M(null), b = Xe(B.current), $ = Ye(() => b ? b.width > 900 ? 12 : b.width > 600 ? 8 : 4 : 0, [b]), m = !!c || !!g.price, [u] = pt({
664
670
  loading: i.fetchBlockletsLoading || i.loadingMore,
665
671
  hasNextPage: y,
666
- onLoadMore: f
672
+ onLoadMore: p
667
673
  });
668
674
  if (l.fetchBlockletsError)
669
675
  return /* @__PURE__ */ t(
670
- de,
676
+ fe,
671
677
  {
672
678
  error: new Error(`Failed to fetch blocklets from ${P}: ${l.fetchBlockletsError.message}`)
673
679
  }
674
680
  );
675
681
  if (i.fetchBlockletsLoading)
676
682
  return /* @__PURE__ */ t(D, { height: 60, display: "flex", alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ t(W, {}) });
677
- if (g.keyword && d && e.length === 0)
678
- return /* @__PURE__ */ h(q, { children: [
683
+ if (g.keyword && m && e.length === 0)
684
+ return /* @__PURE__ */ f(q, { children: [
679
685
  /* @__PURE__ */ t(
680
686
  j,
681
687
  {
682
- primaryStart: p("blocklet.noBlockletPart1"),
683
- primaryEnd: p("blocklet.noBlockletPart2"),
688
+ primaryStart: d("blocklet.noBlockletPart1"),
689
+ primaryEnd: d("blocklet.noBlockletPart2"),
684
690
  filter: g.keyword
685
691
  }
686
692
  ),
687
693
  /* @__PURE__ */ t(O, { keywordTip: !0, filterTip: !0 })
688
694
  ] });
689
695
  if (g.keyword && e.length === 0)
690
- return /* @__PURE__ */ h(q, { children: [
696
+ return /* @__PURE__ */ f(q, { children: [
691
697
  /* @__PURE__ */ t(
692
698
  j,
693
699
  {
694
- primaryStart: p("blocklet.noBlockletPart1"),
695
- primaryEnd: p("blocklet.noBlockletPart2"),
700
+ primaryStart: d("blocklet.noBlockletPart1"),
701
+ primaryEnd: d("blocklet.noBlockletPart2"),
696
702
  filter: g.keyword
697
703
  }
698
704
  ),
699
705
  /* @__PURE__ */ t(O, { keywordTip: !0 })
700
706
  ] });
701
- if (d && e.length === 0) {
707
+ if (m && e.length === 0) {
702
708
  const s = k(c);
703
- return /* @__PURE__ */ h(q, { children: [
709
+ return /* @__PURE__ */ f(q, { children: [
704
710
  s ? /* @__PURE__ */ t(
705
711
  j,
706
712
  {
707
- primaryStart: p("blocklet.noCategoryResults1"),
708
- primaryEnd: p("blocklet.noCategoryResults2"),
713
+ primaryStart: d("blocklet.noCategoryResults1"),
714
+ primaryEnd: d("blocklet.noCategoryResults2"),
709
715
  filter: s
710
716
  }
711
717
  ) : /* @__PURE__ */ t(se, {}),
712
718
  /* @__PURE__ */ t(O, { filterTip: !0 })
713
719
  ] });
714
720
  }
715
- return e.length === 0 ? /* @__PURE__ */ t(q, { children: /* @__PURE__ */ t(se, {}) }) : /* @__PURE__ */ h(Lt, { container: !0, ...n, columns: $, ref: B, children: [
721
+ return e.length === 0 ? /* @__PURE__ */ t(q, { children: /* @__PURE__ */ t(se, {}) }) : /* @__PURE__ */ f(Lt, { container: !0, ...n, columns: $, ref: B, children: [
716
722
  e.map((s) => /* @__PURE__ */ t(ce, { item: !0, xs: 4, "data-blocklet-did": s.did, children: r({ blocklet: s, blocklets: e }) }, s.did)),
717
723
  y && /* @__PURE__ */ t(ce, { item: !0, xs: 12, ref: u, children: /* @__PURE__ */ t(D, { height: 60, display: "flex", justifyContent: "center", children: /* @__PURE__ */ t(W, {}) }) })
718
724
  ] });
@@ -721,13 +727,13 @@ Y.propTypes = {
721
727
  blocklets: o.array.isRequired
722
728
  };
723
729
  Y.defaultProps = {};
724
- const Lt = C(ue)`
730
+ const Lt = C(he)`
725
731
  opacity: ${(e) => e.columns > 0 ? 1 : 0};
726
732
  &.MuiGrid-root {
727
733
  width: 100%;
728
734
  margin: 0 -16px;
729
735
  }
730
- `, ce = Ke(C(ue)`
736
+ `, ce = Ke(C(he)`
731
737
  @media (max-width: ${(e) => e.theme.breakpoints.values.sm}px) {
732
738
  &.MuiGrid-item {
733
739
  padding-bottom: 0px;
@@ -749,7 +755,7 @@ const Lt = C(ue)`
749
755
  `;
750
756
  function Z() {
751
757
  const { selectedCategory: e, handleCategory: n, t: r, handlePrice: l, filters: i, categoryOptions: c, priceOptions: k } = I();
752
- return /* @__PURE__ */ h(Mt, { children: [
758
+ return /* @__PURE__ */ f(Mt, { children: [
753
759
  /* @__PURE__ */ t("div", { children: /* @__PURE__ */ t(A, { title: r("common.price"), options: k, value: i.price, onChange: l }) }),
754
760
  c.length > 0 && /* @__PURE__ */ t("div", { style: { marginTop: "16px" }, children: /* @__PURE__ */ t(
755
761
  A,
@@ -775,9 +781,9 @@ Z.propTypes = {};
775
781
  Z.defaultProps = {};
776
782
  function ee({ placeholder: e, ...n }) {
777
783
  const { filters: r, handleKeyword: l } = I(), [i, c] = F(r.keyword || ""), k = Ze(l, { wait: 300 }), g = (y) => {
778
- const { value: f } = y.target;
779
- c(f), k.run(f);
780
- }, p = () => {
784
+ const { value: p } = y.target;
785
+ c(p), k.run(p);
786
+ }, d = () => {
781
787
  c(""), l();
782
788
  };
783
789
  return E(() => {
@@ -794,7 +800,7 @@ function ee({ placeholder: e, ...n }) {
794
800
  value: i,
795
801
  title: e,
796
802
  "data-cy": "search",
797
- endAdornment: i && /* @__PURE__ */ t(le, { position: "end", children: /* @__PURE__ */ t(Et, { "data-cy": "search-delete", onClick: p }) }),
803
+ endAdornment: i && /* @__PURE__ */ t(le, { position: "end", children: /* @__PURE__ */ t(Et, { "data-cy": "search-delete", onClick: d }) }),
798
804
  ...n
799
805
  }
800
806
  );
@@ -821,7 +827,7 @@ const Ot = C(Fe)`
821
827
  color: transparent;
822
828
  }
823
829
  }
824
- `, Ft = C(dt)`
830
+ `, Ft = C(ut)`
825
831
  color: ${(e) => e.theme.palette.grey[500]};
826
832
  font-size: 28px;
827
833
  @media (max-width: ${(e) => e.theme.breakpoints.values.md}px) {
@@ -833,9 +839,9 @@ const Ot = C(Fe)`
833
839
  cursor: pointer;
834
840
  `;
835
841
  function te({ onSelect: e, wrapChildren: n }) {
836
- const r = M(null), l = M(null), i = M(null), { storeApi: c, blockletRender: k, filters: g, endpoint: p, handleKeyword: y, t: f } = I(), P = async (u) => {
837
- const { data: s } = await c.get(R.blockletsPath, { params: u }), S = s.dataList || [];
838
- return S.length > 0 && S.unshift({ type: "more-result", total: s.total || 0 }), S;
842
+ const r = M(null), l = M(null), i = M(null), { storeApi: c, blockletRender: k, filters: g, endpoint: d, handleKeyword: y, t: p } = I(), P = async (u) => {
843
+ const { data: s } = await c.get(R.blockletsPath, { params: u }), v = s.dataList || [];
844
+ return v.length > 0 && v.unshift({ type: "more-result", total: s.total || 0 }), v;
839
845
  }, B = (u) => {
840
846
  y(u.state.query), u.setIsOpen(!1);
841
847
  }, b = () => {
@@ -845,7 +851,7 @@ function te({ onSelect: e, wrapChildren: n }) {
845
851
  });
846
852
  }, $ = (u) => {
847
853
  u.setIsOpen(!1), b();
848
- }, d = ({ prevState: u, state: s }) => {
854
+ }, m = ({ prevState: u, state: s }) => {
849
855
  u.query !== s.query && (s.query || y());
850
856
  };
851
857
  return gt(
@@ -854,16 +860,16 @@ function te({ onSelect: e, wrapChildren: n }) {
854
860
  { enableOnTags: ["INPUT"] }
855
861
  ), E(() => {
856
862
  b();
857
- }, [p]), E(() => {
863
+ }, [d]), E(() => {
858
864
  if (!r.current)
859
865
  return;
860
- const u = ht({
866
+ const u = ft({
861
867
  container: r.current,
862
868
  renderer: { createElement: We, Fragment: He, render: () => {
863
869
  } },
864
- render({ children: s }, S) {
870
+ render({ children: s }, v) {
865
871
  var x;
866
- (!l.current || i.current !== S) && (i.current = S, (x = l.current) == null || x.unmount(), l.current = ft(S)), l.current.render(n(s));
872
+ (!l.current || i.current !== v) && (i.current = v, (x = l.current) == null || x.unmount(), l.current = ht(v)), l.current.render(n(s));
867
873
  },
868
874
  autoFocus: !0,
869
875
  openOnFocus: !1,
@@ -872,20 +878,28 @@ function te({ onSelect: e, wrapChildren: n }) {
872
878
  label: "bl-autocomplete-label",
873
879
  form: "bl-autocomplete-form",
874
880
  input: "bl-autocomplete-input",
875
- clearButton: "bl-autocomplete-clear"
881
+ clearButton: "bl-autocomplete-clear",
882
+ detachedCancelButton: "bl-autocomplete-detached-cancel",
883
+ detachedContainer: "bl-autocomplete-detached-container"
876
884
  },
877
- placeholder: f("common.searchStore"),
885
+ translations: {
886
+ clearButtonTitle: p("common.clear"),
887
+ detachedCancelButtonText: p("common.cancel"),
888
+ submitButtonTitle: p("common.search"),
889
+ detachedSearchButtonTitle: p("common.search")
890
+ },
891
+ placeholder: p("common.searchStore"),
878
892
  initialState: {
879
893
  query: g.keyword
880
894
  },
881
895
  onStateChange(s) {
882
- d(s);
896
+ m(s);
883
897
  },
884
898
  onSubmit: B,
885
899
  onReset(s) {
886
900
  $(s);
887
901
  },
888
- getSources({ query: s, state: S, ...x }) {
902
+ getSources({ query: s, state: v, ...x }) {
889
903
  const T = {
890
904
  ...g,
891
905
  sortBy: R[g.sortBy],
@@ -907,16 +921,16 @@ function te({ onSelect: e, wrapChildren: n }) {
907
921
  onSelect({ event: w, item: _ }) {
908
922
  return _.type === "more-result" ? (x.setIsOpen(!1), y(s)) : w.type === "keydown" ? y(_.title) : e({
909
923
  blocklet: _,
910
- detailUrl: yt(p, `/blocklets/${_.did}`),
911
- storeUrl: p
924
+ detailUrl: yt(d, `/blocklets/${_.did}`),
925
+ storeUrl: d
912
926
  });
913
927
  },
914
928
  templates: {
915
929
  item({ item: w }) {
916
- return w.type === "more-result" ? /* @__PURE__ */ t("div", { children: f("autocomplete.expandResult", { name: s, number: w.total.toLocaleString() }) }) : k({ blocklet: w, autocompleteSetters: x });
930
+ return w.type === "more-result" ? /* @__PURE__ */ t("div", { children: p("autocomplete.expandResult", { name: s, number: w.total.toLocaleString() }) }) : k({ blocklet: w, autocompleteSetters: x });
917
931
  },
918
932
  noResults() {
919
- return f("blocklet.noResults");
933
+ return p("blocklet.noResults");
920
934
  }
921
935
  }
922
936
  }
@@ -926,7 +940,21 @@ function te({ onSelect: e, wrapChildren: n }) {
926
940
  return () => {
927
941
  u.destroy();
928
942
  };
929
- }, [g, k]), /* @__PURE__ */ t("div", { className: "bl-search-container", ref: r });
943
+ }, [g, k]), /* @__PURE__ */ f(pe, { children: [
944
+ /* @__PURE__ */ t(
945
+ ue,
946
+ {
947
+ styles: me`
948
+ .bl-autocomplete-detached-container {
949
+ .bl-autocomplete-detached-cancel {
950
+ white-space: nowrap;
951
+ }
952
+ }
953
+ `
954
+ }
955
+ ),
956
+ /* @__PURE__ */ t("div", { className: "bl-search-container", ref: r })
957
+ ] });
930
958
  }
931
959
  te.propTypes = {
932
960
  onSelect: o.func.isRequired,
@@ -936,7 +964,7 @@ te.defaultProps = {
936
964
  wrapChildren: (e) => e
937
965
  };
938
966
  function qt() {
939
- var S, x;
967
+ var v, x;
940
968
  const {
941
969
  handleDeveloper: e,
942
970
  blockletList: n,
@@ -946,19 +974,19 @@ function qt() {
946
974
  handleCategory: c,
947
975
  handlePrice: k,
948
976
  handleSearchSelect: g,
949
- t: p,
977
+ t: d,
950
978
  getCategoryLocale: y,
951
- priceOptions: f,
979
+ priceOptions: p,
952
980
  wrapChildren: P,
953
981
  baseSearch: B
954
- } = I(), b = bt(p), $ = ((S = b.find((T) => T.value === r.sortBy)) == null ? void 0 : S.name) || p("sort.sort"), d = y(r.category), { resourceType: u } = r || {}, s = (x = f.find((T) => T.value === r.price)) == null ? void 0 : x.name;
955
- return /* @__PURE__ */ h(D, { display: "flex", alignItems: "flex-start", height: "100%", children: [
982
+ } = I(), b = bt(d), $ = ((v = b.find((T) => T.value === r.sortBy)) == null ? void 0 : v.name) || d("sort.sort"), m = y(r.category), { resourceType: u } = r || {}, s = (x = p.find((T) => T.value === r.price)) == null ? void 0 : x.name;
983
+ return /* @__PURE__ */ f(D, { display: "flex", alignItems: "flex-start", height: "100%", children: [
956
984
  /* @__PURE__ */ t(ae, { mdDown: !0, children: /* @__PURE__ */ t(Z, {}) }),
957
- /* @__PURE__ */ h(jt, { children: [
958
- /* @__PURE__ */ h(Gt, { children: [
959
- /* @__PURE__ */ h(D, { className: "filter-bar", display: "flex", alignItems: "center", children: [
960
- B ? /* @__PURE__ */ t(ee, { className: "bl-search-container", placeholder: p("common.searchStore") }) : /* @__PURE__ */ t(te, { onSelect: g, wrapChildren: P }),
961
- /* @__PURE__ */ h(D, { mt: 0, ml: "16px", className: "filter-container", children: [
985
+ /* @__PURE__ */ f(jt, { children: [
986
+ /* @__PURE__ */ f(Gt, { children: [
987
+ /* @__PURE__ */ f(D, { className: "filter-bar", display: "flex", alignItems: "center", children: [
988
+ B ? /* @__PURE__ */ t(ee, { className: "bl-search-container", placeholder: d("common.searchStore") }) : /* @__PURE__ */ t(te, { onSelect: g, wrapChildren: P }),
989
+ /* @__PURE__ */ f(D, { mt: 0, ml: "16px", className: "filter-container", children: [
962
990
  /* @__PURE__ */ t(ae, { mdUp: !0, children: /* @__PURE__ */ t(X, {}) }),
963
991
  /* @__PURE__ */ t(
964
992
  J,
@@ -974,7 +1002,7 @@ function qt() {
974
1002
  )
975
1003
  ] })
976
1004
  ] }),
977
- /* @__PURE__ */ h(D, { display: "flex", flexWrap: "wrap", alignItems: "center", mb: "16px", children: [
1005
+ /* @__PURE__ */ f(D, { display: "flex", flexWrap: "wrap", alignItems: "center", mb: "16px", children: [
978
1006
  /* @__PURE__ */ t(
979
1007
  N,
980
1008
  {
@@ -988,7 +1016,7 @@ function qt() {
988
1016
  /* @__PURE__ */ t(
989
1017
  N,
990
1018
  {
991
- label: d,
1019
+ label: m,
992
1020
  onDelete: () => {
993
1021
  c(null);
994
1022
  }
@@ -1003,10 +1031,10 @@ function qt() {
1003
1031
  }
1004
1032
  }
1005
1033
  ),
1006
- u && /* @__PURE__ */ t(N, { label: `${p("common.resourceType")}: ${u}` })
1034
+ u && /* @__PURE__ */ t(N, { label: `${d("common.resourceType")}: ${u}` })
1007
1035
  ] })
1008
1036
  ] }),
1009
- /* @__PURE__ */ t(qe, { FallbackComponent: de, children: /* @__PURE__ */ t("div", { style: { position: "relative", flex: 1, overflow: "auto" }, children: /* @__PURE__ */ t(Y, { blocklets: n }) }) })
1037
+ /* @__PURE__ */ t(qe, { FallbackComponent: fe, children: /* @__PURE__ */ t("div", { style: { position: "relative", flex: 1, overflow: "auto" }, children: /* @__PURE__ */ t(Y, { blocklets: n }) }) })
1010
1038
  ] })
1011
1039
  ] });
1012
1040
  }
@@ -1060,9 +1088,9 @@ const jt = C("main")`
1060
1088
  z-index: 9;
1061
1089
  background-color: white;
1062
1090
  `;
1063
- function ye(e) {
1064
- const n = pe(), r = Ct(n.palette.primary.main), l = {
1065
- autocomplete: Te`
1091
+ function ke(e) {
1092
+ const n = de(), r = Ct(n.palette.primary.main), l = {
1093
+ autocomplete: me`
1066
1094
  :root {
1067
1095
  --aa-detached-media-query: (max-width: ${n.breakpoints.values.md}px) !important;
1068
1096
  --aa-detached-modal-media-query: (min-width: ${n.breakpoints.values.md}px) !important;
@@ -1100,13 +1128,13 @@ function ye(e) {
1100
1128
  }
1101
1129
  `
1102
1130
  };
1103
- return /* @__PURE__ */ h(V, { ...e, children: [
1104
- /* @__PURE__ */ t(Be, { styles: l.autocomplete }),
1131
+ return /* @__PURE__ */ f(V, { ...e, children: [
1132
+ /* @__PURE__ */ t(ue, { styles: l.autocomplete }),
1105
1133
  /* @__PURE__ */ t(qt, {})
1106
1134
  ] });
1107
1135
  }
1108
- ye.propTypes = fe;
1109
- ye.defaultProps = he;
1136
+ ke.propTypes = ye;
1137
+ ke.defaultProps = be;
1110
1138
  export {
1111
- ye as default
1139
+ ke as default
1112
1140
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/list",
3
- "version": "0.12.76",
3
+ "version": "0.12.78",
4
4
  "description": "Common ux components of blocklet",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -50,9 +50,9 @@
50
50
  "react-dom": ">=18.2.0"
51
51
  },
52
52
  "dependencies": {
53
- "@algolia/autocomplete-js": "^1.7.1",
54
- "@algolia/autocomplete-theme-classic": "^1.7.1",
55
- "@arcblock/ux": "^2.9.41",
53
+ "@algolia/autocomplete-js": "^1.17.0",
54
+ "@algolia/autocomplete-theme-classic": "^1.17.0",
55
+ "@arcblock/ux": "^2.9.57",
56
56
  "@emotion/react": "^11.10.0",
57
57
  "@emotion/styled": "^11.10.0",
58
58
  "@mui/icons-material": "^5.15.12",
@@ -83,5 +83,5 @@
83
83
  "prettier": "^2.7.1",
84
84
  "vite": "^5.0.12"
85
85
  },
86
- "gitHead": "4736782a5cc1347c3854567873334948dd0441d6"
86
+ "gitHead": "4a6511fcc83abf7c4fd27cd4366677a0c992087d"
87
87
  }