@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.
- package/lib/components/list/index.js +28 -16
- package/lib/index.es.js +301 -302
- package/package.json +3 -3
|
@@ -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
|
|
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"];
|
|
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)(
|
|
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)(
|
|
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
|
-
|
|
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)(
|
|
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)(
|
|
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)(
|
|
141
|
-
const StyledGridItem = /*#__PURE__*/(0, _react.memo)((0, _Theme.styled)(
|
|
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
|
|
2
|
-
import { useTheme as
|
|
3
|
-
import { css as
|
|
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
|
|
6
|
-
import { Button as
|
|
7
|
-
import
|
|
8
|
-
import { ErrorBoundary as
|
|
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
|
|
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
|
|
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
|
|
30
|
-
import
|
|
31
|
-
import dt from "@mui/icons-material/
|
|
32
|
-
import
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import ht from "
|
|
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
|
|
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
|
-
],
|
|
52
|
+
], bt = (e) => [
|
|
55
53
|
{ name: e("blocklet.free"), value: "free" },
|
|
56
54
|
{ name: e("blocklet.payment"), value: "payment" }
|
|
57
|
-
],
|
|
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
|
-
),
|
|
58
|
+
), wt = () => window.innerWidth <= 600, vt = (e, o) => {
|
|
61
59
|
const r = (e + o) / o;
|
|
62
60
|
return r > 1 ? r.toFixed() : 1;
|
|
63
|
-
},
|
|
64
|
-
function
|
|
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((
|
|
68
|
-
r = setTimeout(() =>
|
|
65
|
+
return r && clearTimeout(r), new Promise((c) => {
|
|
66
|
+
r = setTimeout(() => c(e(...i)), o);
|
|
69
67
|
});
|
|
70
68
|
};
|
|
71
69
|
}
|
|
72
|
-
const
|
|
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
|
-
},
|
|
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(
|
|
142
|
-
zh: ie(
|
|
143
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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:
|
|
190
|
-
onSearchSelect:
|
|
191
|
-
extraFilter:
|
|
192
|
-
wrapChildren:
|
|
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
|
|
197
|
+
const x = A(() => et.create({
|
|
200
198
|
baseURL: r,
|
|
201
199
|
headers: B
|
|
202
|
-
}), [r]),
|
|
200
|
+
}), [r]), y = A(() => ({ sortBy: "popularity", sortDirection: "desc", ...e }), [e]), $ = y.category, p = He({
|
|
203
201
|
currentPage: T.currentPage,
|
|
204
|
-
pageSize:
|
|
202
|
+
pageSize: wt() ? T.mobilePageSize : T.pageSize,
|
|
205
203
|
defaultCurrentPage: T.defaultCurrentPage
|
|
206
|
-
}), [
|
|
207
|
-
data:
|
|
208
|
-
loading:
|
|
209
|
-
loadMore:
|
|
204
|
+
}), [s, w] = F(null), {
|
|
205
|
+
data: f = { list: [], total: 0 },
|
|
206
|
+
loading: N,
|
|
207
|
+
loadMore: v,
|
|
210
208
|
loadingMore: I
|
|
211
|
-
} =
|
|
209
|
+
} = Ve(
|
|
212
210
|
async (a) => {
|
|
213
211
|
var R;
|
|
214
212
|
const u = {
|
|
215
|
-
...
|
|
216
|
-
sortBy: T[
|
|
217
|
-
page:
|
|
218
|
-
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
|
-
|
|
221
|
-
const { data:
|
|
218
|
+
w(null);
|
|
219
|
+
const { data: S = {} } = await x.get(T.blockletsPath, {
|
|
222
220
|
params: u
|
|
223
221
|
});
|
|
224
|
-
return { list: (
|
|
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
|
-
|
|
228
|
+
w(a);
|
|
231
229
|
}
|
|
232
230
|
}
|
|
233
231
|
), {
|
|
234
232
|
data: G = [],
|
|
235
|
-
error:
|
|
236
|
-
loading:
|
|
237
|
-
run:
|
|
238
|
-
} =
|
|
233
|
+
error: be,
|
|
234
|
+
loading: xe,
|
|
235
|
+
run: ke
|
|
236
|
+
} = Qe(
|
|
239
237
|
async () => {
|
|
240
|
-
const { data: a } = await
|
|
238
|
+
const { data: a } = await x.get(T.categoriesPath);
|
|
241
239
|
return Array.isArray(a) ? a : [];
|
|
242
240
|
},
|
|
243
241
|
{ manual: !0 }
|
|
244
|
-
), U =
|
|
242
|
+
), U = A(() => Ze(G || [], [(u) => u.name], ["asc"]), [G]), re = H(
|
|
245
243
|
(a, u) => {
|
|
246
|
-
const
|
|
247
|
-
return
|
|
244
|
+
const S = K[l] ? K[l][a] : K.en[a];
|
|
245
|
+
return kt(S, u);
|
|
248
246
|
},
|
|
249
247
|
[l]
|
|
250
|
-
), oe =
|
|
251
|
-
let a =
|
|
252
|
-
return a =
|
|
253
|
-
}, [
|
|
254
|
-
errors: { fetchBlockletsError:
|
|
255
|
-
loadings: { fetchBlockletsLoading:
|
|
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:
|
|
256
|
+
wrapChildren: d,
|
|
259
257
|
t: re,
|
|
260
|
-
filters:
|
|
258
|
+
filters: y,
|
|
261
259
|
selectedCategory: $,
|
|
262
260
|
categoryList: U,
|
|
263
261
|
blockletRender: i,
|
|
264
262
|
locale: l,
|
|
265
|
-
categoryOptions:
|
|
266
|
-
priceOptions:
|
|
267
|
-
storeApi:
|
|
263
|
+
categoryOptions: we,
|
|
264
|
+
priceOptions: ve,
|
|
265
|
+
storeApi: x,
|
|
268
266
|
baseSearch: b,
|
|
269
|
-
hasNextPage:
|
|
267
|
+
hasNextPage: f.list.length < f.total,
|
|
270
268
|
handleSort: (a) => {
|
|
271
269
|
const u = {
|
|
272
|
-
...
|
|
270
|
+
...y,
|
|
273
271
|
sortBy: a,
|
|
274
272
|
sortDirection: a === "nameAsc" ? "asc" : "desc"
|
|
275
273
|
};
|
|
276
|
-
|
|
274
|
+
c(u);
|
|
277
275
|
},
|
|
278
276
|
handleKeyword: (a) => {
|
|
279
|
-
const u = { ...
|
|
280
|
-
|
|
277
|
+
const u = { ...y, keyword: a || void 0 };
|
|
278
|
+
c(u);
|
|
281
279
|
},
|
|
282
280
|
handlePrice: (a) => {
|
|
283
281
|
const u = {
|
|
284
|
-
...
|
|
285
|
-
price: a ===
|
|
282
|
+
...y,
|
|
283
|
+
price: a === y.price ? void 0 : a
|
|
286
284
|
};
|
|
287
|
-
|
|
285
|
+
c(u);
|
|
288
286
|
},
|
|
289
287
|
handleCategory: (a) => {
|
|
290
288
|
let u = a;
|
|
291
|
-
(a === "all" || a ===
|
|
292
|
-
const
|
|
293
|
-
|
|
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 = { ...
|
|
297
|
-
|
|
294
|
+
const u = { ...y, owner: a || void 0 };
|
|
295
|
+
c(u);
|
|
298
296
|
},
|
|
299
297
|
handlePage: (a) => {
|
|
300
|
-
const u = { ...
|
|
301
|
-
|
|
298
|
+
const u = { ...y, currentPage: a };
|
|
299
|
+
c(u);
|
|
302
300
|
},
|
|
303
301
|
loadMore: () => {
|
|
304
|
-
|
|
302
|
+
v();
|
|
305
303
|
},
|
|
306
304
|
getCategoryLocale: (a) => {
|
|
307
305
|
if (!a)
|
|
308
306
|
return null;
|
|
309
307
|
let u = null;
|
|
310
|
-
const
|
|
311
|
-
return
|
|
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,
|
|
315
|
-
return ((
|
|
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) ===
|
|
318
|
-
})) == null ? void 0 : u.owner) == null ? void 0 :
|
|
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:
|
|
318
|
+
handleSearchSelect: k
|
|
321
319
|
};
|
|
322
|
-
return
|
|
323
|
-
|
|
324
|
-
}, [r]), /* @__PURE__ */ t(
|
|
320
|
+
return E(() => {
|
|
321
|
+
ke();
|
|
322
|
+
}, [r]), /* @__PURE__ */ t(Tt, { value: Se, children: o });
|
|
325
323
|
}
|
|
326
324
|
V.propTypes = {
|
|
327
|
-
...
|
|
325
|
+
...fe,
|
|
328
326
|
children: n.any.isRequired
|
|
329
327
|
};
|
|
330
|
-
V.defaultProps =
|
|
328
|
+
V.defaultProps = he;
|
|
331
329
|
function z() {
|
|
332
|
-
const e =
|
|
330
|
+
const e = je(ge);
|
|
333
331
|
return e || {};
|
|
334
332
|
}
|
|
335
|
-
const
|
|
333
|
+
const Rt = C(Te)`
|
|
336
334
|
border-radius: 4px;
|
|
337
|
-
`, Q =
|
|
338
|
-
|
|
335
|
+
`, Q = Ge(({ children: e, rounded: o, loading: r, disabled: l, ...i }, c) => /* @__PURE__ */ t(
|
|
336
|
+
Rt,
|
|
339
337
|
{
|
|
340
|
-
ref:
|
|
338
|
+
ref: c,
|
|
341
339
|
disableElevation: !0,
|
|
342
340
|
disabled: l || r,
|
|
343
341
|
...i,
|
|
344
|
-
startIcon: r && /* @__PURE__ */ t(
|
|
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:
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
|
|
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 $ =
|
|
363
|
+
const $ = H(() => {
|
|
366
364
|
P(!1);
|
|
367
|
-
}, []),
|
|
365
|
+
}, []), p = H(() => {
|
|
368
366
|
P(!0);
|
|
369
367
|
}, []);
|
|
370
|
-
function f
|
|
371
|
-
|
|
368
|
+
function s(f) {
|
|
369
|
+
x(f.value), c(f.value), y && $();
|
|
372
370
|
}
|
|
373
|
-
function
|
|
374
|
-
return
|
|
371
|
+
function w(f) {
|
|
372
|
+
return f === B;
|
|
375
373
|
}
|
|
376
|
-
return /* @__PURE__ */
|
|
377
|
-
/* @__PURE__ */
|
|
378
|
-
|
|
374
|
+
return /* @__PURE__ */ h(Ce, { children: [
|
|
375
|
+
/* @__PURE__ */ h(
|
|
376
|
+
zt,
|
|
379
377
|
{
|
|
380
|
-
ref:
|
|
381
|
-
onClick:
|
|
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
|
-
...
|
|
383
|
+
...g,
|
|
386
384
|
children: [
|
|
387
385
|
/* @__PURE__ */ t("div", { className: "my-select__icon", children: r }),
|
|
388
386
|
e,
|
|
389
|
-
/* @__PURE__ */ t(
|
|
387
|
+
/* @__PURE__ */ t(Ie, { className: "my-select__arrowdown", component: ot, fontSize: "small" })
|
|
390
388
|
]
|
|
391
389
|
}
|
|
392
390
|
),
|
|
393
|
-
/* @__PURE__ */ t(
|
|
394
|
-
|
|
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
|
-
...
|
|
397
|
-
style: { transformOrigin:
|
|
398
|
-
children: /* @__PURE__ */ t(
|
|
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((
|
|
401
|
-
|
|
398
|
+
i.map((v) => k ? k(v) : /* @__PURE__ */ t(
|
|
399
|
+
Le,
|
|
402
400
|
{
|
|
403
|
-
onClick: () =>
|
|
401
|
+
onClick: () => s(v),
|
|
404
402
|
className: [
|
|
405
403
|
"my-select__option",
|
|
406
|
-
|
|
404
|
+
w(v.value) ? "my-select__option--active" : ""
|
|
407
405
|
].join(" "),
|
|
408
|
-
children:
|
|
406
|
+
children: v.name
|
|
409
407
|
},
|
|
410
|
-
|
|
408
|
+
v.value
|
|
411
409
|
))
|
|
412
410
|
] }) }) })
|
|
413
411
|
}
|
|
@@ -431,7 +429,7 @@ J.defaultProps = {
|
|
|
431
429
|
onChange: () => {
|
|
432
430
|
}
|
|
433
431
|
};
|
|
434
|
-
const
|
|
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
|
-
`,
|
|
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
|
|
484
|
-
return /* @__PURE__ */
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
538
|
-
m === "category" && o(P), m === "price" && l(P),
|
|
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__ */
|
|
541
|
-
/* @__PURE__ */ t(it, { variant: "outlined", className: "filter-button", onClick: () =>
|
|
542
|
-
/* @__PURE__ */
|
|
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:
|
|
545
|
+
options: k,
|
|
548
546
|
value: i.price,
|
|
549
547
|
onChange: (m) => {
|
|
550
548
|
b("price", m);
|
|
551
549
|
}
|
|
552
550
|
}
|
|
553
551
|
),
|
|
554
|
-
|
|
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:
|
|
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
|
|
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
|
|
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
|
|
592
|
-
return e ? /* @__PURE__ */ t(
|
|
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
|
-
|
|
592
|
+
M.propTypes = {
|
|
595
593
|
label: n.string,
|
|
596
594
|
onDelete: n.func,
|
|
597
595
|
icon: n.element
|
|
598
596
|
};
|
|
599
|
-
|
|
597
|
+
M.defaultProps = {
|
|
600
598
|
onDelete: () => {
|
|
601
599
|
},
|
|
602
600
|
icon: null,
|
|
603
601
|
label: null
|
|
604
602
|
};
|
|
605
|
-
function
|
|
603
|
+
function se() {
|
|
606
604
|
const { t: e } = z();
|
|
607
|
-
return /* @__PURE__ */ t(
|
|
605
|
+
return /* @__PURE__ */ t(me, { style: { textAlign: "center" }, variant: "subtitle2", children: e("blocklet.noResults") });
|
|
608
606
|
}
|
|
609
|
-
function
|
|
607
|
+
function O({ filterTip: e, keywordTip: o }) {
|
|
610
608
|
const { t: r, locale: l } = z(), i = () => l === "zh" ? "、" : " , ";
|
|
611
|
-
return /* @__PURE__ */
|
|
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
|
-
|
|
616
|
+
O.propTypes = {
|
|
619
617
|
filterTip: n.bool,
|
|
620
618
|
keywordTip: n.bool
|
|
621
619
|
};
|
|
622
|
-
|
|
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__ */
|
|
625
|
+
return /* @__PURE__ */ h(me, { variant: "subtitle2", children: [
|
|
628
626
|
/* @__PURE__ */ t("span", { children: e }),
|
|
629
|
-
/* @__PURE__ */
|
|
627
|
+
/* @__PURE__ */ h("span", { className: "primary", children: [
|
|
630
628
|
" ",
|
|
631
629
|
r,
|
|
632
630
|
" "
|
|
633
631
|
] }),
|
|
634
|
-
/* @__PURE__ */
|
|
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:
|
|
651
|
-
getCategoryLocale:
|
|
652
|
-
filters:
|
|
653
|
-
t:
|
|
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 = !!
|
|
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(
|
|
671
|
-
if (
|
|
672
|
-
return /* @__PURE__ */
|
|
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:
|
|
677
|
-
primaryEnd:
|
|
678
|
-
filter:
|
|
674
|
+
primaryStart: d("blocklet.noBlockletPart1"),
|
|
675
|
+
primaryEnd: d("blocklet.noBlockletPart2"),
|
|
676
|
+
filter: g.keyword
|
|
679
677
|
}
|
|
680
678
|
),
|
|
681
|
-
/* @__PURE__ */ t(
|
|
679
|
+
/* @__PURE__ */ t(O, { keywordTip: !0, filterTip: !0 })
|
|
682
680
|
] });
|
|
683
|
-
if (
|
|
684
|
-
return /* @__PURE__ */
|
|
681
|
+
if (g.keyword && e.length === 0)
|
|
682
|
+
return /* @__PURE__ */ h(q, { children: [
|
|
685
683
|
/* @__PURE__ */ t(
|
|
686
684
|
j,
|
|
687
685
|
{
|
|
688
|
-
primaryStart:
|
|
689
|
-
primaryEnd:
|
|
690
|
-
filter:
|
|
686
|
+
primaryStart: d("blocklet.noBlockletPart1"),
|
|
687
|
+
primaryEnd: d("blocklet.noBlockletPart2"),
|
|
688
|
+
filter: g.keyword
|
|
691
689
|
}
|
|
692
690
|
),
|
|
693
|
-
/* @__PURE__ */ t(
|
|
691
|
+
/* @__PURE__ */ t(O, { keywordTip: !0 })
|
|
694
692
|
] });
|
|
695
|
-
if (
|
|
696
|
-
const
|
|
697
|
-
return /* @__PURE__ */
|
|
698
|
-
|
|
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:
|
|
702
|
-
primaryEnd:
|
|
703
|
-
filter:
|
|
699
|
+
primaryStart: d("blocklet.noCategoryResults1"),
|
|
700
|
+
primaryEnd: d("blocklet.noCategoryResults2"),
|
|
701
|
+
filter: s
|
|
704
702
|
}
|
|
705
|
-
) : /* @__PURE__ */ t(
|
|
706
|
-
/* @__PURE__ */ t(
|
|
703
|
+
) : /* @__PURE__ */ t(se, {}),
|
|
704
|
+
/* @__PURE__ */ t(O, { filterTip: !0 })
|
|
707
705
|
] });
|
|
708
706
|
}
|
|
709
|
-
return e.length === 0 ? /* @__PURE__ */ t(
|
|
710
|
-
e.map((
|
|
711
|
-
b && /* @__PURE__ */ t(
|
|
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
|
|
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
|
-
`,
|
|
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
|
-
`),
|
|
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:
|
|
745
|
-
return /* @__PURE__ */
|
|
746
|
-
/* @__PURE__ */ t("div", { children: /* @__PURE__ */ t(
|
|
747
|
-
|
|
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:
|
|
750
|
+
options: c,
|
|
752
751
|
value: e,
|
|
753
752
|
onChange: o
|
|
754
753
|
}
|
|
755
754
|
) })
|
|
756
755
|
] });
|
|
757
756
|
}
|
|
758
|
-
const
|
|
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,
|
|
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
|
-
|
|
773
|
-
},
|
|
774
|
-
|
|
771
|
+
c(m), k.run(m);
|
|
772
|
+
}, d = () => {
|
|
773
|
+
c(""), l();
|
|
775
774
|
};
|
|
776
|
-
return
|
|
777
|
-
|
|
775
|
+
return E(() => {
|
|
776
|
+
c(r.keyword || "");
|
|
778
777
|
}, [r.keyword]), /* @__PURE__ */ t(
|
|
779
|
-
|
|
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(
|
|
785
|
-
onChange:
|
|
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(
|
|
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
|
|
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
|
-
`,
|
|
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
|
-
`,
|
|
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 =
|
|
830
|
-
const { data:
|
|
831
|
-
return
|
|
832
|
-
}, B = (
|
|
833
|
-
b(
|
|
834
|
-
},
|
|
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
|
|
837
|
-
|
|
835
|
+
const p = r.current.querySelector("input.bl-autocomplete-input");
|
|
836
|
+
p && p.focus();
|
|
838
837
|
});
|
|
839
|
-
},
|
|
840
|
-
|
|
841
|
-
}, $ = ({ prevState:
|
|
842
|
-
|
|
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
|
|
843
|
+
return ht(
|
|
845
844
|
"ctrl + k, command + k",
|
|
846
|
-
(
|
|
845
|
+
(p) => (p.stopPropagation(), p.preventDefault(), x(), !1),
|
|
847
846
|
{ enableOnTags: ["INPUT"] }
|
|
848
|
-
),
|
|
849
|
-
|
|
850
|
-
}, [
|
|
847
|
+
), E(() => {
|
|
848
|
+
x();
|
|
849
|
+
}, [d]), E(() => {
|
|
851
850
|
if (!r.current)
|
|
852
851
|
return;
|
|
853
|
-
const
|
|
852
|
+
const p = ft({
|
|
854
853
|
container: r.current,
|
|
855
|
-
renderer: { createElement:
|
|
854
|
+
renderer: { createElement: Ke, Fragment: We, render: () => {
|
|
856
855
|
} },
|
|
857
|
-
render({ children:
|
|
858
|
-
var
|
|
859
|
-
(!l.current || i.current !==
|
|
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:
|
|
871
|
+
query: g.keyword
|
|
873
872
|
},
|
|
874
|
-
onStateChange(
|
|
875
|
-
$(
|
|
873
|
+
onStateChange(s) {
|
|
874
|
+
$(s);
|
|
876
875
|
},
|
|
877
876
|
onSubmit: B,
|
|
878
|
-
onReset(
|
|
879
|
-
|
|
877
|
+
onReset(s) {
|
|
878
|
+
y(s);
|
|
880
879
|
},
|
|
881
|
-
getSources({ query:
|
|
882
|
-
const
|
|
883
|
-
...
|
|
884
|
-
sortBy: T[
|
|
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:
|
|
886
|
+
keyword: s
|
|
888
887
|
};
|
|
889
|
-
return
|
|
888
|
+
return Pt([
|
|
890
889
|
{
|
|
891
890
|
sourceId: "blocklets",
|
|
892
891
|
getItems() {
|
|
893
|
-
return P(
|
|
892
|
+
return P(N);
|
|
894
893
|
},
|
|
895
894
|
// 选中后填充 搜索框中值
|
|
896
|
-
getItemInputValue({ item:
|
|
897
|
-
return
|
|
895
|
+
getItemInputValue({ item: v }) {
|
|
896
|
+
return v.type === "more-result" ? s : v.title;
|
|
898
897
|
},
|
|
899
898
|
// 选中或者点击自动完成列表中的 item 时触发
|
|
900
|
-
onSelect({ event:
|
|
901
|
-
return I.type === "more-result" ? (
|
|
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:
|
|
904
|
-
storeUrl:
|
|
902
|
+
detailUrl: gt(d, `/blocklets/${I.did}`),
|
|
903
|
+
storeUrl: d
|
|
905
904
|
});
|
|
906
905
|
},
|
|
907
906
|
templates: {
|
|
908
|
-
item({ item:
|
|
909
|
-
return
|
|
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
|
-
|
|
919
|
+
p.destroy();
|
|
921
920
|
};
|
|
922
|
-
}, [
|
|
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
|
|
932
|
-
var
|
|
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:
|
|
940
|
-
handlePrice:
|
|
941
|
-
handleSearchSelect:
|
|
942
|
-
t:
|
|
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(),
|
|
948
|
-
return /* @__PURE__ */
|
|
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__ */
|
|
951
|
-
/* @__PURE__ */
|
|
952
|
-
/* @__PURE__ */
|
|
953
|
-
B ? /* @__PURE__ */ t(ee, { className: "bl-search-container", placeholder:
|
|
954
|
-
/* @__PURE__ */
|
|
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:
|
|
961
|
-
title:
|
|
962
|
-
icon: /* @__PURE__ */ t(
|
|
963
|
-
onChange: (
|
|
964
|
-
i(
|
|
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__ */
|
|
969
|
+
/* @__PURE__ */ h(_, { display: "flex", flexWrap: "wrap", alignItems: "center", mb: "16px", children: [
|
|
971
970
|
/* @__PURE__ */ t(
|
|
972
|
-
|
|
971
|
+
M,
|
|
973
972
|
{
|
|
974
973
|
label: l,
|
|
975
|
-
icon: /* @__PURE__ */ t(
|
|
974
|
+
icon: /* @__PURE__ */ t(Fe, {}),
|
|
976
975
|
onDelete: () => {
|
|
977
976
|
e(null);
|
|
978
977
|
}
|
|
979
978
|
}
|
|
980
979
|
),
|
|
981
980
|
/* @__PURE__ */ t(
|
|
982
|
-
|
|
981
|
+
M,
|
|
983
982
|
{
|
|
984
983
|
label: $,
|
|
985
984
|
onDelete: () => {
|
|
986
|
-
|
|
985
|
+
c(null);
|
|
987
986
|
}
|
|
988
987
|
}
|
|
989
988
|
),
|
|
990
989
|
/* @__PURE__ */ t(
|
|
991
|
-
|
|
990
|
+
M,
|
|
992
991
|
{
|
|
993
|
-
label:
|
|
992
|
+
label: p,
|
|
994
993
|
onDelete: () => {
|
|
995
|
-
|
|
994
|
+
k(null);
|
|
996
995
|
}
|
|
997
996
|
}
|
|
998
997
|
)
|
|
999
998
|
] })
|
|
1000
999
|
] }),
|
|
1001
|
-
/* @__PURE__ */ t(
|
|
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
|
|
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
|
-
`,
|
|
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
|
|
1056
|
-
const o =
|
|
1057
|
-
autocomplete:
|
|
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__ */
|
|
1096
|
-
/* @__PURE__ */ t(
|
|
1097
|
-
/* @__PURE__ */ t(
|
|
1094
|
+
return /* @__PURE__ */ h(V, { ...e, children: [
|
|
1095
|
+
/* @__PURE__ */ t(Be, { styles: l.autocomplete }),
|
|
1096
|
+
/* @__PURE__ */ t(Et, {})
|
|
1098
1097
|
] });
|
|
1099
1098
|
}
|
|
1100
|
-
|
|
1101
|
-
|
|
1099
|
+
ye.propTypes = fe;
|
|
1100
|
+
ye.defaultProps = he;
|
|
1102
1101
|
export {
|
|
1103
|
-
|
|
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.
|
|
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.
|
|
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": "
|
|
86
|
+
"gitHead": "af2dc0bea8f1efa9d104aa84c6d0cca87a55218d"
|
|
87
87
|
}
|