@blocklet/list 0.13.30 → 0.13.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.es.js +63 -63
  2. package/package.json +3 -3
package/lib/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx as t, jsxs as h, Fragment as le } from "react/jsx-runtime";
2
- import { styled as P, useTheme as ae } from "@arcblock/ux/lib/Theme";
2
+ import { styled as R, useTheme as ae } from "@arcblock/ux/lib/Theme";
3
3
  import { Global as xe, css as ke } from "@emotion/react";
4
4
  import _e from "@mui/icons-material/Sort";
5
5
  import { Button as Ne, CircularProgress as oe, MenuList as Le, useMediaQuery as Se, SvgIcon as Me, Popper as Oe, Grow as Fe, Paper as Ae, ClickAwayListener as Ee, MenuItem as qe, Chip as Ce, Box as _, Unstable_Grid2 as te, OutlinedInput as je, InputAdornment as ge, Typography as ve, Hidden as ye, Stack as Ue } from "@mui/material";
@@ -52,7 +52,7 @@ const vt = (e) => [
52
52
  ], Tt = (e) => [
53
53
  { name: e("blocklet.free"), value: "free" },
54
54
  { name: e("blocklet.payment"), value: "payment" }
55
- ], Pt = (e = [], n = "en") => e.map((r) => ({ name: r.locales[n] || `Category.${n}`, value: r._id })), Rt = (e, n) => (
55
+ ], Pt = (e = [], n = "en") => e.map((r) => ({ name: r.locales[n] || r.locales.en, value: r._id })), Rt = (e, n) => (
56
56
  // eslint-disable-next-line no-prototype-builtins
57
57
  e.replace(/{(\w*)}/g, (r, a) => n.hasOwnProperty(a) ? n[a] : "")
58
58
  ), Bt = () => window.innerWidth <= 600, $t = (e) => ct(e).rgb().object();
@@ -211,9 +211,9 @@ function ie({
211
211
  baseSearch: x,
212
212
  serverVersion: u,
213
213
  storeVersion: S,
214
- fetchCategoryDelay: R,
214
+ fetchCategoryDelay: B,
215
215
  showResourcesSwitch: T,
216
- showCategory: B,
216
+ showCategory: $,
217
217
  tagFilters: C
218
218
  }) {
219
219
  const y = {};
@@ -229,22 +229,22 @@ function ie({
229
229
  currentPage: N.currentPage,
230
230
  pageSize: Bt() ? N.mobilePageSize : N.pageSize,
231
231
  defaultCurrentPage: N.defaultCurrentPage
232
- }), [z, $] = E(null), v = Xe(
232
+ }), [z, I] = E(null), v = Xe(
233
233
  async (l) => {
234
234
  l || (k.currentPage = k.defaultCurrentPage);
235
- const { currentPage: p, pageSize: I } = k, A = {
235
+ const { currentPage: p, pageSize: P } = k, A = {
236
236
  ...i,
237
237
  sortBy: N[i.sortBy],
238
238
  page: p,
239
- pageSize: I
239
+ pageSize: P
240
240
  };
241
- $(null);
241
+ I(null);
242
242
  const { data: D = {} } = await d.get(N.blockletsPath, {
243
243
  params: A
244
244
  });
245
245
  return k.currentPage++, {
246
246
  page: p,
247
- pageSize: I,
247
+ pageSize: P,
248
248
  list: (D == null ? void 0 : D.dataList) || [],
249
249
  total: (D == null ? void 0 : D.total) || 0
250
250
  };
@@ -253,7 +253,7 @@ function ie({
253
253
  isNoMore: (l) => l ? l.page * l.pageSize >= l.total : !1,
254
254
  reloadDeps: [r, st(e)],
255
255
  onError: (l) => {
256
- $(l);
256
+ I(l);
257
257
  }
258
258
  }
259
259
  ), {
@@ -269,8 +269,8 @@ function ie({
269
269
  { manual: !0 }
270
270
  ), F = Q(() => at(V || [], [(p) => p.name], ["asc"]), [V]), G = ne(
271
271
  (l, p) => {
272
- const I = re[a] ? re[a][l] : re.en[l];
273
- return Rt(I, p);
272
+ const P = re[a] ? re[a][l] : re.en[l];
273
+ return Rt(P, p);
274
274
  },
275
275
  [a]
276
276
  ), K = Q(() => {
@@ -299,7 +299,7 @@ function ie({
299
299
  storeApi: d,
300
300
  baseSearch: x,
301
301
  showResourcesSwitch: T,
302
- showCategory: B,
302
+ showCategory: $,
303
303
  tagFilters: C,
304
304
  hasNextPage: !v.noMore,
305
305
  onFilterChange: c,
@@ -325,8 +325,8 @@ function ie({
325
325
  handleCategory: (l) => {
326
326
  let p = l;
327
327
  (l === "all" || l === i.category) && (p = void 0);
328
- const I = { ...i, category: p };
329
- c(I);
328
+ const P = { ...i, category: p };
329
+ c(P);
330
330
  },
331
331
  handleDeveloper: (l) => {
332
332
  const p = { ...i, owner: l || void 0 };
@@ -345,22 +345,22 @@ function ie({
345
345
  if (!l)
346
346
  return null;
347
347
  let p = null;
348
- const I = V.find((A) => A._id === l);
349
- return I && (p = I.locales[a]), p;
348
+ const P = V.find((A) => A._id === l);
349
+ return P && (p = P.locales[a] || P.locales.en), p;
350
350
  },
351
351
  get developerName() {
352
- var p, I;
353
- return ((I = (p = K.find((A) => {
352
+ var p, P;
353
+ return ((P = (p = K.find((A) => {
354
354
  var D;
355
355
  return ((D = A == null ? void 0 : A.owner) == null ? void 0 : D.did) === i.owner;
356
- })) == null ? void 0 : p.owner) == null ? void 0 : I.name) || "";
356
+ })) == null ? void 0 : p.owner) == null ? void 0 : P.name) || "";
357
357
  },
358
358
  handleSearchSelect: w
359
359
  };
360
360
  return j(() => {
361
361
  setTimeout(() => {
362
362
  W();
363
- }, R || 0);
363
+ }, B || 0);
364
364
  }, [r]), /* @__PURE__ */ t(Nt, { value: M, children: n });
365
365
  }
366
366
  ie.propTypes = {
@@ -372,7 +372,7 @@ function L() {
372
372
  const e = Ke(Ie);
373
373
  return e || {};
374
374
  }
375
- const Lt = P(Ne)`
375
+ const Lt = R(Ne)`
376
376
  border-radius: 4px;
377
377
  `, se = He(({ children: e, rounded: n, loading: r, disabled: a, ...s }, c) => /* @__PURE__ */ t(
378
378
  Lt,
@@ -398,7 +398,7 @@ se.defaultProps = {
398
398
  disabled: !1
399
399
  };
400
400
  function ce({ title: e, value: n, icon: r, prepend: a, options: s, onChange: c, itemRender: w, ...g }) {
401
- const m = J(null), x = ae(), [u, S] = E(!1), [R, T] = E(n !== null ? n : ""), B = Se(x.breakpoints.down("sm"));
401
+ const m = J(null), x = ae(), [u, S] = E(!1), [B, T] = E(n !== null ? n : ""), $ = Se(x.breakpoints.down("sm"));
402
402
  j(() => {
403
403
  T(n !== null ? n : "");
404
404
  }, [n]);
@@ -408,10 +408,10 @@ function ce({ title: e, value: n, icon: r, prepend: a, options: s, onChange: c,
408
408
  S(!0);
409
409
  }, []);
410
410
  function d(b) {
411
- T(b.value), c(b.value), B && C();
411
+ T(b.value), c(b.value), $ && C();
412
412
  }
413
413
  function i(b) {
414
- return b === R;
414
+ return b === B;
415
415
  }
416
416
  return /* @__PURE__ */ h(le, { children: [
417
417
  /* @__PURE__ */ h(
@@ -421,7 +421,7 @@ function ce({ title: e, value: n, icon: r, prepend: a, options: s, onChange: c,
421
421
  onClick: y,
422
422
  variant: "outlined",
423
423
  size: "small",
424
- className: ["my-select__selector", ut(R) ? "" : "my-select__selector--active"].join(" "),
424
+ className: ["my-select__selector", ut(B) ? "" : "my-select__selector--active"].join(" "),
425
425
  sx: { minWidth: "auto" },
426
426
  ...g,
427
427
  children: [
@@ -465,7 +465,7 @@ ce.defaultProps = {
465
465
  onChange: () => {
466
466
  }
467
467
  };
468
- const Mt = P(se)`
468
+ const Mt = R(se)`
469
469
  border: 1px solid #f0f0f0;
470
470
  padding: 6px 8px 6px 12px;
471
471
  font-weight: ${(e) => e.theme.typography.fontWeightBold};
@@ -496,7 +496,7 @@ const Mt = P(se)`
496
496
  margin-right: 3px;
497
497
  }
498
498
  }
499
- `, Ot = P(Le)`
499
+ `, Ot = R(Le)`
500
500
  .my-select__option__icon {
501
501
  color: transparent;
502
502
  font-size: 16px;
@@ -529,7 +529,7 @@ function U({ options: e, onChange: n, title: r, value: a }) {
529
529
  )) })
530
530
  ] });
531
531
  }
532
- const Ft = P("div")`
532
+ const Ft = R("div")`
533
533
  .title {
534
534
  font-size: 18px;
535
535
  font-weight: bold;
@@ -598,7 +598,7 @@ function pe() {
598
598
  ] })
599
599
  ] });
600
600
  }
601
- const At = P("div")`
601
+ const At = R("div")`
602
602
  .filter-button {
603
603
  border-color: rgb(240, 240, 240);
604
604
  padding: 5px 8px;
@@ -611,7 +611,7 @@ const At = P("div")`
611
611
  `;
612
612
  pe.propTypes = {};
613
613
  pe.defaultProps = {};
614
- const Et = P("div")`
614
+ const Et = R("div")`
615
615
  .MuiChip-root {
616
616
  border-radius: 4px;
617
617
  height: initial;
@@ -697,8 +697,8 @@ function ue({ blocklets: e, ...n }) {
697
697
  serverVersion: x,
698
698
  hasNextPage: u,
699
699
  loadMore: S,
700
- endpoint: R
701
- } = L(), T = !!c || !!g.price, [B] = gt({
700
+ endpoint: B
701
+ } = L(), T = !!c || !!g.price, [$] = gt({
702
702
  loading: s.fetchBlockletsLoading || s.loadingMore,
703
703
  hasNextPage: u,
704
704
  onLoadMore: S
@@ -707,7 +707,7 @@ function ue({ blocklets: e, ...n }) {
707
707
  return /* @__PURE__ */ t(
708
708
  Te,
709
709
  {
710
- error: new Error(`Failed to fetch blocklets from ${R}: ${a.fetchBlockletsError.message}`)
710
+ error: new Error(`Failed to fetch blocklets from ${B}: ${a.fetchBlockletsError.message}`)
711
711
  }
712
712
  );
713
713
  if (s.fetchBlockletsLoading)
@@ -763,8 +763,8 @@ function ue({ blocklets: e, ...n }) {
763
763
  opacity: () => y > 0 ? 1 : 0
764
764
  },
765
765
  children: [
766
- e.map((d) => /* @__PURE__ */ t(te, { xs: 4, "data-blocklet-did": d.did, children: r({ blocklet: d, blocklets: e, serverVersion: x }) }, d.did)),
767
- u && /* @__PURE__ */ t(te, { xs: 12, ref: B, children: /* @__PURE__ */ t(_, { height: 60, display: "flex", justifyContent: "center", children: /* @__PURE__ */ t(oe, {}) }) })
766
+ e.map((d) => /* @__PURE__ */ t(te, { xs: 6, "data-blocklet-did": d.did, children: r({ blocklet: d, blocklets: e, serverVersion: x }) }, d.did)),
767
+ u && /* @__PURE__ */ t(te, { xs: 12, ref: $, children: /* @__PURE__ */ t(_, { height: 60, display: "flex", justifyContent: "center", children: /* @__PURE__ */ t(oe, {}) }) })
768
768
  ]
769
769
  }
770
770
  ) });
@@ -773,7 +773,7 @@ ue.propTypes = {
773
773
  blocklets: o.array.isRequired
774
774
  };
775
775
  ue.defaultProps = {};
776
- const Y = P(ft)`
776
+ const Y = R(ft)`
777
777
  text-align: center;
778
778
  .primary {
779
779
  color: ${(e) => e.theme.palette.primary.main};
@@ -797,7 +797,7 @@ function de() {
797
797
  ) })
798
798
  ] });
799
799
  }
800
- const jt = P("aside")`
800
+ const jt = R("aside")`
801
801
  width: 220px;
802
802
  margin-right: ${(e) => e.theme.spacing(2)};
803
803
  height: 100%;
@@ -840,7 +840,7 @@ me.propTypes = {
840
840
  me.defaultProps = {
841
841
  placeholder: "Type to search..."
842
842
  };
843
- const Ut = P(je)`
843
+ const Ut = R(je)`
844
844
  background-color: ${(e) => e.theme.palette.grey[50]};
845
845
  font-size: 14px;
846
846
  border-radius: 6px;
@@ -857,39 +857,39 @@ const Ut = P(je)`
857
857
  color: transparent;
858
858
  }
859
859
  }
860
- `, Vt = P(bt)`
860
+ `, Vt = R(bt)`
861
861
  color: ${(e) => e.theme.palette.grey[500]};
862
862
  font-size: 28px;
863
863
  @media (max-width: ${(e) => e.theme.breakpoints.values.md}px) {
864
864
  font-size: 24px;
865
865
  }
866
- `, Wt = P(wt)`
866
+ `, Wt = R(wt)`
867
867
  color: ${(e) => e.theme.palette.grey[500]};
868
868
  font-size: 16px;
869
869
  cursor: pointer;
870
870
  `;
871
871
  function he({ onSelect: e, wrapChildren: n }) {
872
- const r = J(null), a = J(null), s = J(null), { storeApi: c, blockletRender: w, filters: g, endpoint: m, handleKeyword: x, t: u, serverVersion: S } = L(), R = async (d) => {
872
+ const r = J(null), a = J(null), s = J(null), { storeApi: c, blockletRender: w, filters: g, endpoint: m, handleKeyword: x, t: u, serverVersion: S } = L(), B = async (d) => {
873
873
  const { data: i } = await c.get(N.blockletsPath, { params: d }), b = i.dataList || [];
874
874
  return b.length > 0 && b.unshift({ type: "more-result", total: i.total || 0 }), b;
875
875
  }, T = (d) => {
876
876
  x(d.state.query), d.setIsOpen(!1);
877
- }, B = () => {
877
+ }, $ = () => {
878
878
  r.current && setTimeout(() => {
879
879
  const d = r.current.querySelector("input.bl-autocomplete-input");
880
880
  d && d.focus();
881
881
  });
882
882
  }, C = (d) => {
883
- d.setIsOpen(!1), B();
883
+ d.setIsOpen(!1), $();
884
884
  }, y = ({ prevState: d, state: i }) => {
885
- d.query !== i.query && (i.query || (x(), B()));
885
+ d.query !== i.query && (i.query || (x(), $()));
886
886
  };
887
887
  return St(
888
888
  "ctrl + k, command + k",
889
- (d) => (d.stopPropagation(), d.preventDefault(), B(), !1),
889
+ (d) => (d.stopPropagation(), d.preventDefault(), $(), !1),
890
890
  { enableOnTags: ["INPUT"] }
891
891
  ), j(() => {
892
- B();
892
+ $();
893
893
  }, [m]), j(() => {
894
894
  if (!r.current)
895
895
  return;
@@ -941,23 +941,23 @@ function he({ onSelect: e, wrapChildren: n }) {
941
941
  {
942
942
  sourceId: "blocklets",
943
943
  getItems() {
944
- return R(z);
944
+ return B(z);
945
945
  },
946
946
  // 选中后填充 搜索框中值
947
- getItemInputValue({ item: $ }) {
948
- return $.type === "more-result" ? i : $.title;
947
+ getItemInputValue({ item: I }) {
948
+ return I.type === "more-result" ? i : I.title;
949
949
  },
950
950
  // 选中或者点击自动完成列表中的 item 时触发
951
- onSelect({ event: $, item: v }) {
952
- return v.type === "more-result" ? (k.setIsOpen(!1), x(i)) : $.type === "keydown" ? x(v.title) : e({
951
+ onSelect({ event: I, item: v }) {
952
+ return v.type === "more-result" ? (k.setIsOpen(!1), x(i)) : I.type === "keydown" ? x(v.title) : e({
953
953
  blocklet: v,
954
954
  detailUrl: nt(m, "/blocklets", v.did),
955
955
  storeUrl: m
956
956
  });
957
957
  },
958
958
  templates: {
959
- item({ item: $ }) {
960
- return $.type === "more-result" ? /* @__PURE__ */ t("div", { children: u("autocomplete.expandResult", { name: i, number: $.total.toLocaleString() }) }) : w({ blocklet: $, autocompleteSetters: k, serverVersion: S });
959
+ item({ item: I }) {
960
+ return I.type === "more-result" ? /* @__PURE__ */ t("div", { children: u("autocomplete.expandResult", { name: i, number: I.total.toLocaleString() }) }) : w({ blocklet: I, autocompleteSetters: k, serverVersion: S });
961
961
  },
962
962
  noResults() {
963
963
  return u("blocklet.noResults");
@@ -1027,12 +1027,12 @@ function Gt() {
1027
1027
  getCategoryLocale: x,
1028
1028
  priceOptions: u,
1029
1029
  wrapChildren: S,
1030
- showResourcesSwitch: R,
1030
+ showResourcesSwitch: B,
1031
1031
  showCategory: T,
1032
- baseSearch: B,
1032
+ baseSearch: $,
1033
1033
  onFilterChange: C,
1034
1034
  tagFilters: y
1035
- } = L(), d = vt(m), i = ((G = d.find((f) => f.value === r.sortBy)) == null ? void 0 : G.name) || m("sort.sort"), b = x(r.category), { resourceType: k } = r || {}, z = (K = u.find((f) => f.value === r.price)) == null ? void 0 : K.name, [$, v] = E(!1), V = ae(), ee = Se(() => V.breakpoints.down("md")), O = Pe({
1035
+ } = L(), d = vt(m), i = ((G = d.find((f) => f.value === r.sortBy)) == null ? void 0 : G.name) || m("sort.sort"), b = x(r.category), { resourceType: k } = r || {}, z = (K = u.find((f) => f.value === r.price)) == null ? void 0 : K.name, [I, v] = E(!1), V = ae(), ee = Se(() => V.breakpoints.down("md")), O = Pe({
1036
1036
  chooseTagId: ""
1037
1037
  }), W = tt((f) => {
1038
1038
  O.chooseTagId = f.id, ["category", "resourceType", "resourceDid"].forEach((M) => {
@@ -1057,11 +1057,11 @@ function Gt() {
1057
1057
  display: "flex",
1058
1058
  flexDirection: {
1059
1059
  lg: "row",
1060
- md: R ? "column" : "row"
1060
+ md: B ? "column" : "row"
1061
1061
  },
1062
1062
  alignItems: {
1063
1063
  lg: "center",
1064
- md: R ? "flex-start" : "center",
1064
+ md: B ? "flex-start" : "center",
1065
1065
  xs: "center"
1066
1066
  },
1067
1067
  gap: 1
@@ -1085,11 +1085,11 @@ function Gt() {
1085
1085
  onBlur: () => {
1086
1086
  v(!1);
1087
1087
  },
1088
- children: B ? /* @__PURE__ */ t(me, { className: "bl-search-container", placeholder: m("common.searchStore") }) : /* @__PURE__ */ t(he, { onSelect: g, wrapChildren: S })
1088
+ children: $ ? /* @__PURE__ */ t(me, { className: "bl-search-container", placeholder: m("common.searchStore") }) : /* @__PURE__ */ t(he, { onSelect: g, wrapChildren: S })
1089
1089
  }
1090
1090
  ),
1091
1091
  /* @__PURE__ */ h(_, { className: "filter-container", display: "flex", alignItems: "center", children: [
1092
- !ee && R && /* @__PURE__ */ t(_, { ml: 1, mr: 1, children: /* @__PURE__ */ t(fe, { t: m }) }),
1092
+ !ee && B && /* @__PURE__ */ t(_, { ml: 1, mr: 1, children: /* @__PURE__ */ t(fe, { t: m }) }),
1093
1093
  /* @__PURE__ */ t(
1094
1094
  ce,
1095
1095
  {
@@ -1158,7 +1158,7 @@ function Gt() {
1158
1158
  ] })
1159
1159
  ] });
1160
1160
  }
1161
- const Kt = P("main")`
1161
+ const Kt = R("main")`
1162
1162
  display: flex;
1163
1163
  flex-direction: column;
1164
1164
  flex: 1;
@@ -1196,7 +1196,7 @@ const Kt = P("main")`
1196
1196
  font-size: 12px;
1197
1197
  }
1198
1198
  }
1199
- `, Ht = P("div")`
1199
+ `, Ht = R("div")`
1200
1200
  position: sticky;
1201
1201
  top: 0;
1202
1202
  z-index: 9;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/list",
3
- "version": "0.13.30",
3
+ "version": "0.13.32",
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.17.0",
54
54
  "@algolia/autocomplete-theme-classic": "^1.17.0",
55
- "@blocklet/util": "0.13.30",
55
+ "@blocklet/util": "0.13.32",
56
56
  "@emotion/react": "^11.10.0",
57
57
  "@emotion/styled": "^11.10.0",
58
58
  "@mui/icons-material": "^5.16.4",
@@ -83,5 +83,5 @@
83
83
  "prettier": "^3.3.2",
84
84
  "vite": "^5.2.12"
85
85
  },
86
- "gitHead": "48c6b64002da59f253e11ccb0656f08e6713e4e4"
86
+ "gitHead": "9a623ec8c6cd65c48f5cd8237203fc2c47e2c23c"
87
87
  }