@blocklet/list 0.12.57 → 0.12.59

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.
package/lib/base.js CHANGED
@@ -45,6 +45,7 @@ function ListBase() {
45
45
  const {
46
46
  resourceType
47
47
  } = filters || {};
48
+ const displayedResourceType = (0, _utils.getDisplayedResourceType)(resourceType);
48
49
  const priceLocale = (_priceOptions$find = priceOptions.find(price => price.value === filters.price)) === null || _priceOptions$find === void 0 ? void 0 : _priceOptions$find.name;
49
50
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
50
51
  display: "flex",
@@ -103,8 +104,8 @@ function ListBase() {
103
104
  onDelete: () => {
104
105
  handlePrice(null);
105
106
  }
106
- }), resourceType && /*#__PURE__*/(0, _jsxRuntime.jsx)(_filter2.CustomChip, {
107
- label: "".concat(t('common.resourceType'), ": ").concat(resourceType)
107
+ }), displayedResourceType && /*#__PURE__*/(0, _jsxRuntime.jsx)(_filter2.CustomChip, {
108
+ label: "".concat(t('common.resourceType'), ": ").concat(displayedResourceType)
108
109
  })]
109
110
  })]
110
111
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactErrorBoundary.ErrorBoundary, {
package/lib/index.es.js CHANGED
@@ -1,7 +1,7 @@
1
- import { jsx as t, jsxs as h, Fragment as Pe } from "react/jsx-runtime";
1
+ import { jsx as t, jsxs as g, Fragment as Pe } from "react/jsx-runtime";
2
2
  import { useTheme as pe } from "@mui/material/styles";
3
3
  import { css as Te, Global as Be } from "@emotion/react";
4
- import { styled as C } from "@arcblock/ux/lib/Theme";
4
+ import { styled as S } from "@arcblock/ux/lib/Theme";
5
5
  import $e from "@mui/icons-material/Sort";
6
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";
7
7
  import Ee from "@mui/icons-material/Face";
@@ -67,7 +67,7 @@ function Pt(e, n) {
67
67
  });
68
68
  };
69
69
  }
70
- const Tt = Pt((e) => Promise.resolve(e), 300), Bt = {
70
+ const Tt = Pt((e) => Promise.resolve(e), 300), Bt = (e) => (e || "").split(".").slice(-1)[0], $t = {
71
71
  common: {
72
72
  searchStore: "Search the store",
73
73
  price: "Price",
@@ -102,7 +102,7 @@ const Tt = Pt((e) => Promise.resolve(e), 300), Bt = {
102
102
  autocomplete: {
103
103
  expandResult: 'Show {number} search results for "{name}" '
104
104
  }
105
- }, $t = {
105
+ }, Rt = {
106
106
  common: {
107
107
  searchStore: "搜索商店内应用",
108
108
  price: "价格",
@@ -138,8 +138,8 @@ const Tt = Pt((e) => Promise.resolve(e), 300), Bt = {
138
138
  expandResult: "显示 {number} 条 “{name}” 的搜索结果 "
139
139
  }
140
140
  }, K = {
141
- en: ie(Bt),
142
- zh: ie($t)
141
+ en: ie($t),
142
+ zh: ie(Rt)
143
143
  }, fe = {
144
144
  filters: o.shape({
145
145
  keyword: o.string,
@@ -183,7 +183,7 @@ const Tt = Pt((e) => Promise.resolve(e), 300), Bt = {
183
183
  blockletsPath: "/api/v2/blocklets.json",
184
184
  categoriesPath: "/api/blocklets/categories",
185
185
  cacheSize: 100
186
- }, ge = je({}), { Provider: Rt, Consumer: Cr } = ge;
186
+ }, ge = je({}), { Provider: zt, Consumer: Pr } = ge;
187
187
  function V({
188
188
  filters: e,
189
189
  children: n,
@@ -191,26 +191,26 @@ function V({
191
191
  locale: l,
192
192
  blockletRender: i,
193
193
  onFilterChange: c,
194
- onSearchSelect: k,
195
- extraFilter: g,
194
+ onSearchSelect: w,
195
+ extraFilter: y,
196
196
  wrapChildren: p,
197
- baseSearch: y,
197
+ baseSearch: b,
198
198
  serverVersion: f,
199
- storeVersion: P,
200
- fetchCategoryDelay: B
199
+ storeVersion: C,
200
+ fetchCategoryDelay: T
201
201
  }) {
202
- const b = {};
203
- f && (b["x-blocklet-server-version"] = f), P && (b["x-blocklet-store-version"] = P);
204
- const $ = L(() => tt.create({
202
+ const x = {};
203
+ f && (x["x-blocklet-server-version"] = f), C && (x["x-blocklet-store-version"] = C);
204
+ const B = L(() => tt.create({
205
205
  baseURL: r,
206
- headers: b
206
+ headers: x
207
207
  }), [r]), d = L(() => ({ sortBy: "popularity", sortDirection: "desc", ...e }), [e]), u = d.category, s = Ve({
208
208
  currentPage: R.currentPage,
209
209
  pageSize: vt() ? R.mobilePageSize : R.pageSize,
210
210
  defaultCurrentPage: R.defaultCurrentPage
211
- }), [S, x] = F(null), {
212
- data: T = { list: [], total: 0 },
213
- loading: w,
211
+ }), [P, k] = F(null), {
212
+ data: $ = { list: [], total: 0 },
213
+ loading: h,
214
214
  loadMore: _,
215
215
  loadingMore: be
216
216
  } = Qe(
@@ -222,8 +222,8 @@ function V({
222
222
  page: St(((z = a == null ? void 0 : a.list) == null ? void 0 : z.length) || 0, s.pageSize),
223
223
  pageSize: s.pageSize
224
224
  };
225
- x(null);
226
- const { data: v = {} } = await $.get(R.blockletsPath, {
225
+ k(null);
226
+ const { data: v = {} } = await B.get(R.blockletsPath, {
227
227
  params: m
228
228
  });
229
229
  return { list: (v == null ? void 0 : v.dataList) || [], total: (v == null ? void 0 : v.total) || 0 };
@@ -232,7 +232,7 @@ function V({
232
232
  isNoMore: (a) => a ? a.list.length >= a.total : !1,
233
233
  reloadDeps: [r, rt(e)],
234
234
  onError: (a) => {
235
- x(a);
235
+ k(a);
236
236
  }
237
237
  }
238
238
  ), {
@@ -242,7 +242,7 @@ function V({
242
242
  run: we
243
243
  } = Je(
244
244
  async () => {
245
- const { data: a } = await $.get(R.categoriesPath);
245
+ const { data: a } = await B.get(R.categoriesPath);
246
246
  return Array.isArray(a) ? a : [];
247
247
  },
248
248
  { manual: !0 }
@@ -253,11 +253,11 @@ function V({
253
253
  },
254
254
  [l]
255
255
  ), oe = L(() => {
256
- let a = T.list || [];
257
- 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 },
256
+ let a = $.list || [];
257
+ return a = y(a), a;
258
+ }, [$, y]), ve = L(() => kt(U, l), [U, l]), Se = xt(re), Ce = {
259
+ errors: { fetchBlockletsError: P, fetchCategoriesError: xe },
260
+ loadings: { fetchBlockletsLoading: h, fetchCategoriesLoading: ke, loadingMore: be },
261
261
  endpoint: r,
262
262
  blockletList: oe,
263
263
  wrapChildren: p,
@@ -269,9 +269,9 @@ function V({
269
269
  locale: l,
270
270
  categoryOptions: ve,
271
271
  priceOptions: Se,
272
- storeApi: $,
273
- baseSearch: y,
274
- hasNextPage: T.list.length < T.total,
272
+ storeApi: B,
273
+ baseSearch: b,
274
+ hasNextPage: $.list.length < $.total,
275
275
  handleSort: (a) => {
276
276
  const m = {
277
277
  ...d,
@@ -322,13 +322,13 @@ function V({
322
322
  return ((ne = z == null ? void 0 : z.owner) == null ? void 0 : ne.did) === d.owner;
323
323
  })) == null ? void 0 : m.owner) == null ? void 0 : v.name) || "";
324
324
  },
325
- handleSearchSelect: k
325
+ handleSearchSelect: w
326
326
  };
327
327
  return E(() => {
328
328
  setTimeout(() => {
329
329
  we();
330
- }, B || 0);
331
- }, [r]), /* @__PURE__ */ t(Rt, { value: Ce, children: n });
330
+ }, T || 0);
331
+ }, [r]), /* @__PURE__ */ t(zt, { value: Ce, children: n });
332
332
  }
333
333
  V.propTypes = {
334
334
  ...fe,
@@ -339,10 +339,10 @@ function I() {
339
339
  const e = Ge(ge);
340
340
  return e || {};
341
341
  }
342
- const zt = C(Re)`
342
+ const It = S(Re)`
343
343
  border-radius: 4px;
344
344
  `, Q = Ue(({ children: e, rounded: n, loading: r, disabled: l, ...i }, c) => /* @__PURE__ */ t(
345
- zt,
345
+ It,
346
346
  {
347
347
  ref: c,
348
348
  disableElevation: !0,
@@ -364,32 +364,32 @@ Q.defaultProps = {
364
364
  loading: !1,
365
365
  disabled: !1
366
366
  };
367
- 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"));
367
+ function J({ title: e, value: n, icon: r, prepend: l, options: i, onChange: c, itemRender: w, ...y }) {
368
+ const p = M(null), b = pe(), [f, C] = F(!1), [T, x] = F(n !== null ? n : ""), B = Ie(b.breakpoints.down("sm"));
369
369
  E(() => {
370
- b(n !== null ? n : "");
370
+ x(n !== null ? n : "");
371
371
  }, [n]);
372
372
  const d = H(() => {
373
- P(!1);
373
+ C(!1);
374
374
  }, []), u = H(() => {
375
- P(!0);
375
+ C(!0);
376
376
  }, []);
377
- function s(x) {
378
- b(x.value), c(x.value), $ && d();
377
+ function s(k) {
378
+ x(k.value), c(k.value), B && d();
379
379
  }
380
- function S(x) {
381
- return x === B;
380
+ function P(k) {
381
+ return k === T;
382
382
  }
383
- return /* @__PURE__ */ h(Pe, { children: [
384
- /* @__PURE__ */ h(
385
- It,
383
+ return /* @__PURE__ */ g(Pe, { children: [
384
+ /* @__PURE__ */ g(
385
+ _t,
386
386
  {
387
387
  ref: p,
388
388
  onClick: u,
389
389
  variant: "outlined",
390
390
  size: "small",
391
- className: ["my-select__selector", lt(B) ? "" : "my-select__selector--active"].join(" "),
392
- ...g,
391
+ className: ["my-select__selector", lt(T) ? "" : "my-select__selector--active"].join(" "),
392
+ ...y,
393
393
  children: [
394
394
  /* @__PURE__ */ t("div", { className: "my-select__icon", children: r }),
395
395
  e,
@@ -397,24 +397,24 @@ function J({ title: e, value: n, icon: r, prepend: l, options: i, onChange: c, i
397
397
  ]
398
398
  }
399
399
  ),
400
- /* @__PURE__ */ t(De, { open: f, anchorEl: p.current, transition: !0, style: { zIndex: "9999" }, children: ({ TransitionProps: x, placement: T }) => /* @__PURE__ */ t(
400
+ /* @__PURE__ */ t(De, { open: f, anchorEl: p.current, transition: !0, style: { zIndex: "9999" }, children: ({ TransitionProps: k, placement: $ }) => /* @__PURE__ */ t(
401
401
  Ne,
402
402
  {
403
- ...x,
404
- 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: [
403
+ ...k,
404
+ style: { transformOrigin: $ === "bottom" ? "center top" : "center bottom" },
405
+ children: /* @__PURE__ */ t(Ae, { children: /* @__PURE__ */ t(Le, { onClickAway: d, children: /* @__PURE__ */ g(Dt, { autoFocusItem: f, onMouseEnter: u, onMouseLeave: d, children: [
406
406
  l,
407
- i.map((w) => k ? k(w) : /* @__PURE__ */ t(
407
+ i.map((h) => w ? w(h) : /* @__PURE__ */ t(
408
408
  Me,
409
409
  {
410
- onClick: () => s(w),
410
+ onClick: () => s(h),
411
411
  className: [
412
412
  "my-select__option",
413
- S(w.value) ? "my-select__option--active" : ""
413
+ P(h.value) ? "my-select__option--active" : ""
414
414
  ].join(" "),
415
- children: w.name
415
+ children: h.name
416
416
  },
417
- w.value
417
+ h.value
418
418
  ))
419
419
  ] }) }) })
420
420
  }
@@ -438,7 +438,7 @@ J.defaultProps = {
438
438
  onChange: () => {
439
439
  }
440
440
  };
441
- const It = C(Q)`
441
+ const _t = S(Q)`
442
442
  border: 1px solid #f0f0f0;
443
443
  padding: 6px 8px 6px 12px;
444
444
  font-weight: ${(e) => e.theme.typography.fontWeightBold};
@@ -470,7 +470,7 @@ const It = C(Q)`
470
470
  margin-right: 3px;
471
471
  }
472
472
  }
473
- `, _t = C(ze)`
473
+ `, Dt = S(ze)`
474
474
  .my-select__option__icon {
475
475
  color: transparent;
476
476
  font-size: 16px;
@@ -488,7 +488,7 @@ const It = C(Q)`
488
488
  }
489
489
  `;
490
490
  function A({ options: e, onChange: n, title: r, value: l }) {
491
- return /* @__PURE__ */ h(Dt, { children: [
491
+ return /* @__PURE__ */ g(Nt, { children: [
492
492
  /* @__PURE__ */ t("div", { className: "title", children: r }),
493
493
  /* @__PURE__ */ t("div", { className: "list", children: e.map((i) => /* @__PURE__ */ t(
494
494
  "div",
@@ -503,7 +503,7 @@ function A({ options: e, onChange: n, title: r, value: l }) {
503
503
  )) })
504
504
  ] });
505
505
  }
506
- const Dt = C("div")`
506
+ const Nt = S("div")`
507
507
  .title {
508
508
  font-size: 18px;
509
509
  font-weight: bold;
@@ -541,20 +541,20 @@ A.defaultProps = {
541
541
  value: null
542
542
  };
543
543
  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);
544
+ const { selectedCategory: e, handleCategory: n, t: r, handlePrice: l, filters: i, categoryOptions: c, priceOptions: w } = I(), [y, p] = F(!1), b = (f, C) => {
545
+ f === "category" && n(C), f === "price" && l(C), p(!1);
546
546
  };
547
- return /* @__PURE__ */ h(Nt, { children: [
547
+ return /* @__PURE__ */ g(At, { children: [
548
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: [
549
+ /* @__PURE__ */ g(it, { fullWidth: !0, title: "", open: y, onClose: () => p(!1), children: [
550
550
  /* @__PURE__ */ t(
551
551
  A,
552
552
  {
553
553
  title: r("common.price"),
554
- options: k,
554
+ options: w,
555
555
  value: i.price,
556
556
  onChange: (f) => {
557
- y("price", f);
557
+ b("price", f);
558
558
  }
559
559
  }
560
560
  ),
@@ -565,14 +565,14 @@ function X() {
565
565
  options: c,
566
566
  value: e,
567
567
  onChange: (f) => {
568
- y("category", f);
568
+ b("category", f);
569
569
  }
570
570
  }
571
571
  ) })
572
572
  ] })
573
573
  ] });
574
574
  }
575
- const Nt = C("div")`
575
+ const At = S("div")`
576
576
  .filter-button {
577
577
  margin-right: 16px;
578
578
  border-color: rgb(240, 240, 240);
@@ -586,7 +586,7 @@ const Nt = C("div")`
586
586
  `;
587
587
  X.propTypes = {};
588
588
  X.defaultProps = {};
589
- const At = C("div")`
589
+ const Lt = S("div")`
590
590
  .MuiChip-root {
591
591
  border-radius: 4px;
592
592
  height: initial;
@@ -596,7 +596,7 @@ const At = C("div")`
596
596
  }
597
597
  `;
598
598
  function N({ label: e, icon: n, onDelete: r, ...l }) {
599
- return e ? /* @__PURE__ */ t(At, { ...l, children: /* @__PURE__ */ t(Oe, { color: "primary", "data-cy": "filter-tag", icon: n, label: e, onDelete: r }) }) : null;
599
+ return e ? /* @__PURE__ */ t(Lt, { ...l, children: /* @__PURE__ */ t(Oe, { color: "primary", "data-cy": "filter-tag", icon: n, label: e, onDelete: r }) }) : null;
600
600
  }
601
601
  N.propTypes = {
602
602
  label: o.string,
@@ -614,7 +614,7 @@ function se() {
614
614
  }
615
615
  function O({ filterTip: e, keywordTip: n }) {
616
616
  const { t: r, locale: l } = I(), i = () => l === "zh" ? "、" : " , ";
617
- return /* @__PURE__ */ h(ut, { className: "tips", children: [
617
+ return /* @__PURE__ */ g(ut, { className: "tips", children: [
618
618
  /* @__PURE__ */ t("span", { style: { marginRight: "16px" }, children: r("blocklet.emptyTip") }),
619
619
  e && /* @__PURE__ */ t("span", { children: r("blocklet.filterTip") }),
620
620
  e && n && i(),
@@ -630,14 +630,14 @@ O.defaultProps = {
630
630
  keywordTip: !1
631
631
  };
632
632
  function j({ primaryStart: e, primaryEnd: n, filter: r }) {
633
- return /* @__PURE__ */ h(me, { variant: "subtitle2", children: [
633
+ return /* @__PURE__ */ g(me, { variant: "subtitle2", children: [
634
634
  /* @__PURE__ */ t("span", { children: e }),
635
- /* @__PURE__ */ h("span", { className: "primary", children: [
635
+ /* @__PURE__ */ g("span", { className: "primary", children: [
636
636
  " ",
637
637
  r,
638
638
  " "
639
639
  ] }),
640
- /* @__PURE__ */ h("span", { children: [
640
+ /* @__PURE__ */ g("span", { children: [
641
641
  n,
642
642
  " "
643
643
  ] })
@@ -654,53 +654,53 @@ function Y({ blocklets: e, ...n }) {
654
654
  errors: l,
655
655
  loadings: i,
656
656
  selectedCategory: c,
657
- getCategoryLocale: k,
658
- filters: g,
657
+ getCategoryLocale: w,
658
+ filters: y,
659
659
  t: p,
660
- hasNextPage: y,
660
+ hasNextPage: b,
661
661
  loadMore: f,
662
- 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({
662
+ endpoint: C
663
+ } = I(), T = M(null), x = Xe(T.current), B = Ye(() => x ? x.width > 900 ? 12 : x.width > 600 ? 8 : 4 : 0, [x]), d = !!c || !!y.price, [u] = pt({
664
664
  loading: i.fetchBlockletsLoading || i.loadingMore,
665
- hasNextPage: y,
665
+ hasNextPage: b,
666
666
  onLoadMore: f
667
667
  });
668
668
  if (l.fetchBlockletsError)
669
669
  return /* @__PURE__ */ t(
670
670
  de,
671
671
  {
672
- error: new Error(`Failed to fetch blocklets from ${P}: ${l.fetchBlockletsError.message}`)
672
+ error: new Error(`Failed to fetch blocklets from ${C}: ${l.fetchBlockletsError.message}`)
673
673
  }
674
674
  );
675
675
  if (i.fetchBlockletsLoading)
676
676
  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: [
677
+ if (y.keyword && d && e.length === 0)
678
+ return /* @__PURE__ */ g(q, { children: [
679
679
  /* @__PURE__ */ t(
680
680
  j,
681
681
  {
682
682
  primaryStart: p("blocklet.noBlockletPart1"),
683
683
  primaryEnd: p("blocklet.noBlockletPart2"),
684
- filter: g.keyword
684
+ filter: y.keyword
685
685
  }
686
686
  ),
687
687
  /* @__PURE__ */ t(O, { keywordTip: !0, filterTip: !0 })
688
688
  ] });
689
- if (g.keyword && e.length === 0)
690
- return /* @__PURE__ */ h(q, { children: [
689
+ if (y.keyword && e.length === 0)
690
+ return /* @__PURE__ */ g(q, { children: [
691
691
  /* @__PURE__ */ t(
692
692
  j,
693
693
  {
694
694
  primaryStart: p("blocklet.noBlockletPart1"),
695
695
  primaryEnd: p("blocklet.noBlockletPart2"),
696
- filter: g.keyword
696
+ filter: y.keyword
697
697
  }
698
698
  ),
699
699
  /* @__PURE__ */ t(O, { keywordTip: !0 })
700
700
  ] });
701
701
  if (d && e.length === 0) {
702
- const s = k(c);
703
- return /* @__PURE__ */ h(q, { children: [
702
+ const s = w(c);
703
+ return /* @__PURE__ */ g(q, { children: [
704
704
  s ? /* @__PURE__ */ t(
705
705
  j,
706
706
  {
@@ -712,22 +712,22 @@ function Y({ blocklets: e, ...n }) {
712
712
  /* @__PURE__ */ t(O, { filterTip: !0 })
713
713
  ] });
714
714
  }
715
- return e.length === 0 ? /* @__PURE__ */ t(q, { children: /* @__PURE__ */ t(se, {}) }) : /* @__PURE__ */ h(Lt, { container: !0, ...n, columns: $, ref: B, children: [
715
+ return e.length === 0 ? /* @__PURE__ */ t(q, { children: /* @__PURE__ */ t(se, {}) }) : /* @__PURE__ */ g(Mt, { container: !0, ...n, columns: B, ref: T, children: [
716
716
  e.map((s) => /* @__PURE__ */ t(ce, { item: !0, xs: 4, "data-blocklet-did": s.did, children: r({ blocklet: s, blocklets: e }) }, s.did)),
717
- y && /* @__PURE__ */ t(ce, { item: !0, xs: 12, ref: u, children: /* @__PURE__ */ t(D, { height: 60, display: "flex", justifyContent: "center", children: /* @__PURE__ */ t(W, {}) }) })
717
+ b && /* @__PURE__ */ t(ce, { item: !0, xs: 12, ref: u, children: /* @__PURE__ */ t(D, { height: 60, display: "flex", justifyContent: "center", children: /* @__PURE__ */ t(W, {}) }) })
718
718
  ] });
719
719
  }
720
720
  Y.propTypes = {
721
721
  blocklets: o.array.isRequired
722
722
  };
723
723
  Y.defaultProps = {};
724
- const Lt = C(ue)`
724
+ const Mt = S(ue)`
725
725
  opacity: ${(e) => e.columns > 0 ? 1 : 0};
726
726
  &.MuiGrid-root {
727
727
  width: 100%;
728
728
  margin: 0 -16px;
729
729
  }
730
- `, ce = Ke(C(ue)`
730
+ `, ce = Ke(S(ue)`
731
731
  @media (max-width: ${(e) => e.theme.breakpoints.values.sm}px) {
732
732
  &.MuiGrid-item {
733
733
  padding-bottom: 0px;
@@ -738,7 +738,7 @@ const Lt = C(ue)`
738
738
  margin-bottom: ${(e) => e.theme.spacing(2)};
739
739
  }
740
740
  }
741
- `), q = C(ct)`
741
+ `), q = S(ct)`
742
742
  text-align: center;
743
743
  .primary {
744
744
  color: ${(e) => e.theme.palette.primary.main};
@@ -748,9 +748,9 @@ const Lt = C(ue)`
748
748
  }
749
749
  `;
750
750
  function Z() {
751
- const { selectedCategory: e, handleCategory: n, t: r, handlePrice: l, filters: i, categoryOptions: c, priceOptions: k } = I();
752
- return /* @__PURE__ */ h(Mt, { children: [
753
- /* @__PURE__ */ t("div", { children: /* @__PURE__ */ t(A, { title: r("common.price"), options: k, value: i.price, onChange: l }) }),
751
+ const { selectedCategory: e, handleCategory: n, t: r, handlePrice: l, filters: i, categoryOptions: c, priceOptions: w } = I();
752
+ return /* @__PURE__ */ g(Ot, { children: [
753
+ /* @__PURE__ */ t("div", { children: /* @__PURE__ */ t(A, { title: r("common.price"), options: w, value: i.price, onChange: l }) }),
754
754
  c.length > 0 && /* @__PURE__ */ t("div", { style: { marginTop: "16px" }, children: /* @__PURE__ */ t(
755
755
  A,
756
756
  {
@@ -762,7 +762,7 @@ function Z() {
762
762
  ) })
763
763
  ] });
764
764
  }
765
- const Mt = C("aside")`
765
+ const Ot = S("aside")`
766
766
  width: 220px;
767
767
  margin-right: ${(e) => e.theme.spacing(2)};
768
768
  height: 100%;
@@ -774,27 +774,27 @@ const Mt = C("aside")`
774
774
  Z.propTypes = {};
775
775
  Z.defaultProps = {};
776
776
  function ee({ placeholder: e, ...n }) {
777
- 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);
777
+ const { filters: r, handleKeyword: l } = I(), [i, c] = F(r.keyword || ""), w = Ze(l, { wait: 300 }), y = (b) => {
778
+ const { value: f } = b.target;
779
+ c(f), w.run(f);
780
780
  }, p = () => {
781
781
  c(""), l();
782
782
  };
783
783
  return E(() => {
784
784
  c(r.keyword || "");
785
785
  }, [r.keyword]), /* @__PURE__ */ t(
786
- Ot,
786
+ Ft,
787
787
  {
788
788
  inputProps: {
789
789
  "data-cy": "search-blocklet"
790
790
  },
791
- startAdornment: /* @__PURE__ */ t(le, { position: "start", children: /* @__PURE__ */ t(Ft, {}) }),
792
- onChange: g,
791
+ startAdornment: /* @__PURE__ */ t(le, { position: "start", children: /* @__PURE__ */ t(Et, {}) }),
792
+ onChange: y,
793
793
  placeholder: e,
794
794
  value: i,
795
795
  title: e,
796
796
  "data-cy": "search",
797
- endAdornment: i && /* @__PURE__ */ t(le, { position: "end", children: /* @__PURE__ */ t(Et, { "data-cy": "search-delete", onClick: p }) }),
797
+ endAdornment: i && /* @__PURE__ */ t(le, { position: "end", children: /* @__PURE__ */ t(qt, { "data-cy": "search-delete", onClick: p }) }),
798
798
  ...n
799
799
  }
800
800
  );
@@ -805,7 +805,7 @@ ee.propTypes = {
805
805
  ee.defaultProps = {
806
806
  placeholder: "Type to search..."
807
807
  };
808
- const Ot = C(Fe)`
808
+ const Ft = S(Fe)`
809
809
  background-color: ${(e) => e.theme.palette.grey[50]};
810
810
  font-size: 14px;
811
811
  border-radius: 6px;
@@ -821,39 +821,39 @@ const Ot = C(Fe)`
821
821
  color: transparent;
822
822
  }
823
823
  }
824
- `, Ft = C(dt)`
824
+ `, Et = S(dt)`
825
825
  color: ${(e) => e.theme.palette.grey[500]};
826
826
  font-size: 28px;
827
827
  @media (max-width: ${(e) => e.theme.breakpoints.values.md}px) {
828
828
  font-size: 24px;
829
829
  }
830
- `, Et = C(mt)`
830
+ `, qt = S(mt)`
831
831
  color: ${(e) => e.theme.palette.grey[500]};
832
832
  font-size: 16px;
833
833
  cursor: pointer;
834
834
  `;
835
835
  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;
839
- }, B = (u) => {
840
- y(u.state.query), u.setIsOpen(!1);
841
- }, b = () => {
836
+ const r = M(null), l = M(null), i = M(null), { storeApi: c, blockletRender: w, filters: y, endpoint: p, handleKeyword: b, t: f } = I(), C = async (u) => {
837
+ const { data: s } = await c.get(R.blockletsPath, { params: u }), P = s.dataList || [];
838
+ return P.length > 0 && P.unshift({ type: "more-result", total: s.total || 0 }), P;
839
+ }, T = (u) => {
840
+ b(u.state.query), u.setIsOpen(!1);
841
+ }, x = () => {
842
842
  r.current && setTimeout(() => {
843
843
  const u = r.current.querySelector("input.bl-autocomplete-input");
844
844
  u && u.focus();
845
845
  });
846
- }, $ = (u) => {
847
- u.setIsOpen(!1), b();
846
+ }, B = (u) => {
847
+ u.setIsOpen(!1), x();
848
848
  }, d = ({ prevState: u, state: s }) => {
849
- u.query !== s.query && (s.query || y());
849
+ u.query !== s.query && (s.query || b());
850
850
  };
851
851
  return gt(
852
852
  "ctrl + k, command + k",
853
- (u) => (u.stopPropagation(), u.preventDefault(), b(), !1),
853
+ (u) => (u.stopPropagation(), u.preventDefault(), x(), !1),
854
854
  { enableOnTags: ["INPUT"] }
855
855
  ), E(() => {
856
- b();
856
+ x();
857
857
  }, [p]), E(() => {
858
858
  if (!r.current)
859
859
  return;
@@ -861,9 +861,9 @@ function te({ onSelect: e, wrapChildren: n }) {
861
861
  container: r.current,
862
862
  renderer: { createElement: We, Fragment: He, render: () => {
863
863
  } },
864
- render({ children: s }, S) {
865
- 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));
864
+ render({ children: s }, P) {
865
+ var k;
866
+ (!l.current || i.current !== P) && (i.current = P, (k = l.current) == null || k.unmount(), l.current = ft(P)), l.current.render(n(s));
867
867
  },
868
868
  autoFocus: !0,
869
869
  openOnFocus: !1,
@@ -876,19 +876,19 @@ function te({ onSelect: e, wrapChildren: n }) {
876
876
  },
877
877
  placeholder: f("common.searchStore"),
878
878
  initialState: {
879
- query: g.keyword
879
+ query: y.keyword
880
880
  },
881
881
  onStateChange(s) {
882
882
  d(s);
883
883
  },
884
- onSubmit: B,
884
+ onSubmit: T,
885
885
  onReset(s) {
886
- $(s);
886
+ B(s);
887
887
  },
888
- getSources({ query: s, state: S, ...x }) {
889
- const T = {
890
- ...g,
891
- sortBy: R[g.sortBy],
888
+ getSources({ query: s, state: P, ...k }) {
889
+ const $ = {
890
+ ...y,
891
+ sortBy: R[y.sortBy],
892
892
  page: 1,
893
893
  pageSize: 10,
894
894
  keyword: s
@@ -897,23 +897,23 @@ function te({ onSelect: e, wrapChildren: n }) {
897
897
  {
898
898
  sourceId: "blocklets",
899
899
  getItems() {
900
- return P(T);
900
+ return C($);
901
901
  },
902
902
  // 选中后填充 搜索框中值
903
- getItemInputValue({ item: w }) {
904
- return w.type === "more-result" ? s : w.title;
903
+ getItemInputValue({ item: h }) {
904
+ return h.type === "more-result" ? s : h.title;
905
905
  },
906
906
  // 选中或者点击自动完成列表中的 item 时触发
907
- onSelect({ event: w, item: _ }) {
908
- return _.type === "more-result" ? (x.setIsOpen(!1), y(s)) : w.type === "keydown" ? y(_.title) : e({
907
+ onSelect({ event: h, item: _ }) {
908
+ return _.type === "more-result" ? (k.setIsOpen(!1), b(s)) : h.type === "keydown" ? b(_.title) : e({
909
909
  blocklet: _,
910
910
  detailUrl: yt(p, `/blocklets/${_.did}`),
911
911
  storeUrl: p
912
912
  });
913
913
  },
914
914
  templates: {
915
- 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 });
915
+ item({ item: h }) {
916
+ return h.type === "more-result" ? /* @__PURE__ */ t("div", { children: f("autocomplete.expandResult", { name: s, number: h.total.toLocaleString() }) }) : w({ blocklet: h, autocompleteSetters: k });
917
917
  },
918
918
  noResults() {
919
919
  return f("blocklet.noResults");
@@ -926,7 +926,7 @@ function te({ onSelect: e, wrapChildren: n }) {
926
926
  return () => {
927
927
  u.destroy();
928
928
  };
929
- }, [g, k]), /* @__PURE__ */ t("div", { className: "bl-search-container", ref: r });
929
+ }, [y, w]), /* @__PURE__ */ t("div", { className: "bl-search-container", ref: r });
930
930
  }
931
931
  te.propTypes = {
932
932
  onSelect: o.func.isRequired,
@@ -935,8 +935,8 @@ te.propTypes = {
935
935
  te.defaultProps = {
936
936
  wrapChildren: (e) => e
937
937
  };
938
- function qt() {
939
- var S, x;
938
+ function jt() {
939
+ var k, $;
940
940
  const {
941
941
  handleDeveloper: e,
942
942
  blockletList: n,
@@ -944,37 +944,37 @@ function qt() {
944
944
  developerName: l,
945
945
  handleSort: i,
946
946
  handleCategory: c,
947
- handlePrice: k,
948
- handleSearchSelect: g,
947
+ handlePrice: w,
948
+ handleSearchSelect: y,
949
949
  t: p,
950
- getCategoryLocale: y,
950
+ getCategoryLocale: b,
951
951
  priceOptions: f,
952
- wrapChildren: P,
953
- 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: [
952
+ wrapChildren: C,
953
+ baseSearch: T
954
+ } = I(), x = bt(p), B = ((k = x.find((h) => h.value === r.sortBy)) == null ? void 0 : k.name) || p("sort.sort"), d = b(r.category), { resourceType: u } = r || {}, s = Bt(u), P = ($ = f.find((h) => h.value === r.price)) == null ? void 0 : $.name;
955
+ return /* @__PURE__ */ g(D, { display: "flex", alignItems: "flex-start", height: "100%", children: [
956
956
  /* @__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: [
957
+ /* @__PURE__ */ g(Gt, { children: [
958
+ /* @__PURE__ */ g(Ut, { children: [
959
+ /* @__PURE__ */ g(D, { className: "filter-bar", display: "flex", alignItems: "center", children: [
960
+ T ? /* @__PURE__ */ t(ee, { className: "bl-search-container", placeholder: p("common.searchStore") }) : /* @__PURE__ */ t(te, { onSelect: y, wrapChildren: C }),
961
+ /* @__PURE__ */ g(D, { mt: 0, ml: "16px", className: "filter-container", children: [
962
962
  /* @__PURE__ */ t(ae, { mdUp: !0, children: /* @__PURE__ */ t(X, {}) }),
963
963
  /* @__PURE__ */ t(
964
964
  J,
965
965
  {
966
966
  value: r.sortBy,
967
- options: b,
968
- title: $,
967
+ options: x,
968
+ title: B,
969
969
  icon: /* @__PURE__ */ t($e, {}),
970
- onChange: (T) => {
971
- i(T);
970
+ onChange: (h) => {
971
+ i(h);
972
972
  }
973
973
  }
974
974
  )
975
975
  ] })
976
976
  ] }),
977
- /* @__PURE__ */ h(D, { display: "flex", flexWrap: "wrap", alignItems: "center", mb: "16px", children: [
977
+ /* @__PURE__ */ g(D, { display: "flex", flexWrap: "wrap", alignItems: "center", mb: "16px", children: [
978
978
  /* @__PURE__ */ t(
979
979
  N,
980
980
  {
@@ -997,20 +997,20 @@ function qt() {
997
997
  /* @__PURE__ */ t(
998
998
  N,
999
999
  {
1000
- label: s,
1000
+ label: P,
1001
1001
  onDelete: () => {
1002
- k(null);
1002
+ w(null);
1003
1003
  }
1004
1004
  }
1005
1005
  ),
1006
- u && /* @__PURE__ */ t(N, { label: `${p("common.resourceType")}: ${u}` })
1006
+ s && /* @__PURE__ */ t(N, { label: `${p("common.resourceType")}: ${s}` })
1007
1007
  ] })
1008
1008
  ] }),
1009
1009
  /* @__PURE__ */ t(qe, { FallbackComponent: de, children: /* @__PURE__ */ t("div", { style: { position: "relative", flex: 1, overflow: "auto" }, children: /* @__PURE__ */ t(Y, { blocklets: n }) }) })
1010
1010
  ] })
1011
1011
  ] });
1012
1012
  }
1013
- const jt = C("main")`
1013
+ const Gt = S("main")`
1014
1014
  display: flex;
1015
1015
  flex-direction: column;
1016
1016
  flex: 1;
@@ -1054,7 +1054,7 @@ const jt = C("main")`
1054
1054
  font-size: 12px;
1055
1055
  }
1056
1056
  }
1057
- `, Gt = C("div")`
1057
+ `, Ut = S("div")`
1058
1058
  position: sticky;
1059
1059
  top: 0;
1060
1060
  z-index: 9;
@@ -1100,9 +1100,9 @@ function ye(e) {
1100
1100
  }
1101
1101
  `
1102
1102
  };
1103
- return /* @__PURE__ */ h(V, { ...e, children: [
1103
+ return /* @__PURE__ */ g(V, { ...e, children: [
1104
1104
  /* @__PURE__ */ t(Be, { styles: l.autocomplete }),
1105
- /* @__PURE__ */ t(qt, {})
1105
+ /* @__PURE__ */ t(jt, {})
1106
1106
  ] });
1107
1107
  }
1108
1108
  ye.propTypes = fe;
package/lib/libs/utils.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.urlStringify = exports.toColorRgb = exports.replaceTranslate = exports.removeUndefined = exports.isMobileScreen = exports.getSortOptions = exports.getPrices = exports.getCurrentPage = exports.getCategoryOptions = exports.formatError = exports.filterBlockletByPrice = exports.debounced = void 0;
6
+ exports.urlStringify = exports.toColorRgb = exports.replaceTranslate = exports.removeUndefined = exports.isMobileScreen = exports.getSortOptions = exports.getPrices = exports.getDisplayedResourceType = exports.getCurrentPage = exports.getCategoryOptions = exports.formatError = exports.filterBlockletByPrice = exports.debounced = void 0;
7
7
  var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
8
8
  var _color = _interopRequireDefault(require("color"));
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -127,4 +127,6 @@ function debouncePromise(fn, time) {
127
127
  };
128
128
  }
129
129
  const debounced = debouncePromise(items => Promise.resolve(items), 300);
130
- exports.debounced = debounced;
130
+ exports.debounced = debounced;
131
+ const getDisplayedResourceType = resourceType => (resourceType || '').split('.').slice(-1)[0];
132
+ exports.getDisplayedResourceType = getDisplayedResourceType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/list",
3
- "version": "0.12.57",
3
+ "version": "0.12.59",
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.8.20",
55
+ "@arcblock/ux": "^2.8.22",
56
56
  "@emotion/react": "^11.10.0",
57
57
  "@emotion/styled": "^11.10.0",
58
58
  "@mui/icons-material": "^5.14.16",
@@ -83,5 +83,5 @@
83
83
  "prettier": "^2.7.1",
84
84
  "vite": "^4.4.9"
85
85
  },
86
- "gitHead": "fa9323b4a992f7c88e75fd1f0d69d03e449fd1ee"
86
+ "gitHead": "bd7e8c2f43a3fd30dfafa8b8ec7c9385ee4391ce"
87
87
  }