@blocklet/ui-react 3.1.49 → 3.1.51
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.
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Blocklet UI (React):
|
|
2
|
+
en: Blocklet UI (React)
|
|
3
|
+
zh: Blocklet UI (React)
|
|
4
|
+
zh-TW: Blocklet UI (React)
|
|
5
|
+
ja: Blocklet UI (React)
|
|
6
|
+
"@blocklet/ui-react offers components for Blocklet dev to speed up development.":
|
|
7
|
+
en: "@blocklet/ui-react offers components for Blocklet dev to speed up
|
|
8
|
+
development."
|
|
9
|
+
zh: "@blocklet/ui-react 为 Blocklet 开发者提供组件,以加快开发速度。"
|
|
10
|
+
zh-TW: "@blocklet/ui-react 為 Blocklet 開發者提供元件,以加快開發速度。"
|
|
11
|
+
ja: "@blocklet/ui-reactは、Blocklet開発を加速するためのコンポーネントを提供します。"
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import { jsxs as i, jsx as t, Fragment as
|
|
1
|
+
import { jsxs as i, jsx as t, Fragment as $ } from "react/jsx-runtime";
|
|
2
2
|
import A from "prop-types";
|
|
3
|
-
import { useState as v, useRef as
|
|
4
|
-
import { useMemoizedFn as k, useRequest as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { useState as v, useRef as Y, useMemo as E, useEffect as ee } from "react";
|
|
4
|
+
import { useMemoizedFn as k, useRequest as te, useDebounce as re, useInfiniteScroll as oe } from "ahooks";
|
|
5
|
+
import { WELLKNOWN_SERVICE_PATH_PREFIX as ne } from "@abtnode/constant";
|
|
6
|
+
import { Box as r, Button as P, Avatar as w, Typography as s, Menu as ie, TextField as se, InputAdornment as ae, Divider as W, MenuItem as L, ListItemAvatar as R, ListItemText as D } from "@mui/material";
|
|
7
|
+
import { withQuery as le, joinURL as ce } from "ufo";
|
|
8
8
|
import { KeyboardArrowDown as de, Search as pe, Add as he, OpenInNew as me } from "@mui/icons-material";
|
|
9
|
-
import ue from "
|
|
10
|
-
import
|
|
11
|
-
import xe from "./
|
|
12
|
-
import fe from "./
|
|
13
|
-
import ye from "./locales.js";
|
|
9
|
+
import { translate as ue } from "@arcblock/ux/lib/Locale/util";
|
|
10
|
+
import ge from "./use-org.js";
|
|
11
|
+
import xe from "./create.js";
|
|
12
|
+
import fe from "./locales.js";
|
|
14
13
|
const H = 20;
|
|
15
|
-
function
|
|
16
|
-
const [
|
|
17
|
-
() =>
|
|
14
|
+
function ye({ session: a, locale: h = "en" }) {
|
|
15
|
+
const [S, C] = v(null), [m, I] = v(""), [j, u] = v(!1), F = Y(null), l = k((e, o = {}) => ue(fe, e, h, "en", o)), { getOrgs: N, getCurrentOrg: _ } = ge(a), n = E(() => a?.user?.role || "", [a?.user?.role]), { data: g = {} } = te(
|
|
16
|
+
() => _(n),
|
|
18
17
|
{
|
|
19
18
|
ready: !!n,
|
|
20
19
|
refreshDeps: [n],
|
|
@@ -24,40 +23,46 @@ function be({ session: a, locale: h = "en" }) {
|
|
|
24
23
|
}
|
|
25
24
|
), d = E(() => g || {
|
|
26
25
|
name: a?.user?.passports?.find((o) => o.name === n)?.title || n || "-"
|
|
27
|
-
}, [g, n, a?.user?.passports]),
|
|
26
|
+
}, [g, n, a?.user?.passports]), B = re(m, { wait: 500 }), { data: K, loadMore: V, loadingMore: z, reload: O } = oe(
|
|
28
27
|
async (e) => {
|
|
29
|
-
const c = { page: e ? Math.ceil(e.list.length / H) + 1 : 1, pageSize: H, search: m }, y = await
|
|
30
|
-
return { list: b, total:
|
|
28
|
+
const c = { page: e ? Math.ceil(e.list.length / H) + 1 : 1, pageSize: H, search: m }, y = await N(c), { orgs: b = [], paging: Z } = y || {};
|
|
29
|
+
return { list: b, total: Z?.total || 0 };
|
|
31
30
|
},
|
|
32
31
|
{
|
|
33
32
|
ready: !!n,
|
|
34
|
-
reloadDeps: [
|
|
33
|
+
reloadDeps: [B],
|
|
35
34
|
isNoMore: (e) => e?.list.length ? e.list.length >= e?.total : !0,
|
|
36
35
|
onError: (e) => {
|
|
37
36
|
console.error("Failed to fetch organizations list", e);
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
|
-
), { list: p = [], total: q = 0 } =
|
|
39
|
+
), { list: p = [], total: q = 0 } = K || {}, T = p.length < q, U = k((e) => {
|
|
41
40
|
const o = e.target, { scrollTop: c, scrollHeight: y, clientHeight: b } = o;
|
|
42
|
-
y - c - b < 50 && !z && T &&
|
|
43
|
-
}), x = !!
|
|
44
|
-
|
|
41
|
+
y - c - b < 50 && !z && T && V();
|
|
42
|
+
}), x = !!S;
|
|
43
|
+
ee(() => {
|
|
45
44
|
x && O();
|
|
46
45
|
}, [x, O]);
|
|
47
|
-
const
|
|
46
|
+
const G = (e) => {
|
|
48
47
|
C(e.currentTarget);
|
|
49
48
|
}, f = () => {
|
|
50
49
|
C(null), u(!1), I("");
|
|
51
|
-
},
|
|
52
|
-
a.switchPassport(
|
|
53
|
-
|
|
50
|
+
}, J = (e) => {
|
|
51
|
+
a.switchPassport(
|
|
52
|
+
() => {
|
|
53
|
+
window.location.reload();
|
|
54
|
+
},
|
|
55
|
+
{ orgId: e.id }
|
|
56
|
+
), f();
|
|
57
|
+
}, Q = () => {
|
|
54
58
|
u(!0);
|
|
55
59
|
}, M = () => {
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
const e = le(ce(ne, "user/orgs"), { locale: h });
|
|
61
|
+
window.location.href = e, f();
|
|
62
|
+
}, X = (e) => /* @__PURE__ */ i(
|
|
58
63
|
L,
|
|
59
64
|
{
|
|
60
|
-
onClick: () =>
|
|
65
|
+
onClick: () => J(e),
|
|
61
66
|
selected: e.id === d.id,
|
|
62
67
|
sx: {
|
|
63
68
|
py: 1.5,
|
|
@@ -71,7 +76,7 @@ function be({ session: a, locale: h = "en" }) {
|
|
|
71
76
|
},
|
|
72
77
|
children: [
|
|
73
78
|
/* @__PURE__ */ t(R, { sx: { minWidth: 40 }, children: /* @__PURE__ */ t(
|
|
74
|
-
|
|
79
|
+
w,
|
|
75
80
|
{
|
|
76
81
|
sx: {
|
|
77
82
|
width: 28,
|
|
@@ -109,7 +114,7 @@ function be({ session: a, locale: h = "en" }) {
|
|
|
109
114
|
P,
|
|
110
115
|
{
|
|
111
116
|
ref: F,
|
|
112
|
-
onClick:
|
|
117
|
+
onClick: G,
|
|
113
118
|
endIcon: /* @__PURE__ */ t(de, {}),
|
|
114
119
|
sx: {
|
|
115
120
|
display: "flex",
|
|
@@ -127,7 +132,7 @@ function be({ session: a, locale: h = "en" }) {
|
|
|
127
132
|
"data-testid": "org-switch-button",
|
|
128
133
|
children: [
|
|
129
134
|
/* @__PURE__ */ t(
|
|
130
|
-
|
|
135
|
+
w,
|
|
131
136
|
{
|
|
132
137
|
sx: {
|
|
133
138
|
width: 24,
|
|
@@ -143,9 +148,9 @@ function be({ session: a, locale: h = "en" }) {
|
|
|
143
148
|
}
|
|
144
149
|
),
|
|
145
150
|
/* @__PURE__ */ i(
|
|
146
|
-
|
|
151
|
+
ie,
|
|
147
152
|
{
|
|
148
|
-
anchorEl:
|
|
153
|
+
anchorEl: S,
|
|
149
154
|
open: x,
|
|
150
155
|
onClose: f,
|
|
151
156
|
anchorOrigin: {
|
|
@@ -172,7 +177,7 @@ function be({ session: a, locale: h = "en" }) {
|
|
|
172
177
|
},
|
|
173
178
|
children: [
|
|
174
179
|
/* @__PURE__ */ t(r, { sx: { p: 1.5, pb: 1 }, children: /* @__PURE__ */ t(
|
|
175
|
-
|
|
180
|
+
se,
|
|
176
181
|
{
|
|
177
182
|
fullWidth: !0,
|
|
178
183
|
size: "small",
|
|
@@ -180,7 +185,7 @@ function be({ session: a, locale: h = "en" }) {
|
|
|
180
185
|
value: m,
|
|
181
186
|
onChange: (e) => I(e.target.value),
|
|
182
187
|
InputProps: {
|
|
183
|
-
startAdornment: /* @__PURE__ */ t(
|
|
188
|
+
startAdornment: /* @__PURE__ */ t(ae, { position: "start", children: /* @__PURE__ */ t(pe, { fontSize: "small", color: "action" }) })
|
|
184
189
|
},
|
|
185
190
|
onClick: (e) => e.stopPropagation(),
|
|
186
191
|
onKeyDown: (e) => e.stopPropagation(),
|
|
@@ -205,10 +210,10 @@ function be({ session: a, locale: h = "en" }) {
|
|
|
205
210
|
children: l("orgs")
|
|
206
211
|
}
|
|
207
212
|
) }),
|
|
208
|
-
/* @__PURE__ */ t(r, { sx: { maxHeight: 240, overflow: "auto" }, onScroll:
|
|
213
|
+
/* @__PURE__ */ t(r, { sx: { maxHeight: 240, overflow: "auto" }, onScroll: U, children: p.length > 0 ? /* @__PURE__ */ t($, { children: p.map((e, o) => {
|
|
209
214
|
const c = o === p.length - 1;
|
|
210
215
|
return /* @__PURE__ */ i(r, { children: [
|
|
211
|
-
|
|
216
|
+
X(e),
|
|
212
217
|
c && T && /* @__PURE__ */ t(
|
|
213
218
|
r,
|
|
214
219
|
{
|
|
@@ -228,7 +233,7 @@ function be({ session: a, locale: h = "en" }) {
|
|
|
228
233
|
/* @__PURE__ */ i(
|
|
229
234
|
L,
|
|
230
235
|
{
|
|
231
|
-
onClick:
|
|
236
|
+
onClick: Q,
|
|
232
237
|
sx: {
|
|
233
238
|
py: 1.5,
|
|
234
239
|
px: 2,
|
|
@@ -238,7 +243,7 @@ function be({ session: a, locale: h = "en" }) {
|
|
|
238
243
|
},
|
|
239
244
|
children: [
|
|
240
245
|
/* @__PURE__ */ t(R, { sx: { minWidth: 40 }, children: /* @__PURE__ */ t(
|
|
241
|
-
|
|
246
|
+
w,
|
|
242
247
|
{
|
|
243
248
|
sx: {
|
|
244
249
|
width: 28,
|
|
@@ -264,6 +269,7 @@ function be({ session: a, locale: h = "en" }) {
|
|
|
264
269
|
{
|
|
265
270
|
onClick: M,
|
|
266
271
|
variant: "text",
|
|
272
|
+
component: "a",
|
|
267
273
|
size: "small",
|
|
268
274
|
endIcon: /* @__PURE__ */ t(me, { fontSize: "small" }),
|
|
269
275
|
sx: {
|
|
@@ -283,13 +289,13 @@ function be({ session: a, locale: h = "en" }) {
|
|
|
283
289
|
]
|
|
284
290
|
}
|
|
285
291
|
),
|
|
286
|
-
|
|
292
|
+
j && /* @__PURE__ */ t(xe, { onSuccess: M, onCancel: () => u(!1), locale: h })
|
|
287
293
|
] });
|
|
288
294
|
}
|
|
289
|
-
|
|
295
|
+
ye.propTypes = {
|
|
290
296
|
session: A.object.isRequired,
|
|
291
297
|
locale: A.string
|
|
292
298
|
};
|
|
293
299
|
export {
|
|
294
|
-
|
|
300
|
+
ye as default
|
|
295
301
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.51",
|
|
4
4
|
"description": "Some useful front-end web components that can be used in Blocklets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@abtnode/constant": "1.16.52",
|
|
37
37
|
"@abtnode/util": "1.16.52",
|
|
38
|
-
"@arcblock/bridge": "3.1.
|
|
39
|
-
"@arcblock/icons": "3.1.
|
|
40
|
-
"@arcblock/react-hooks": "3.1.
|
|
38
|
+
"@arcblock/bridge": "3.1.51",
|
|
39
|
+
"@arcblock/icons": "3.1.51",
|
|
40
|
+
"@arcblock/react-hooks": "3.1.51",
|
|
41
41
|
"@arcblock/ws": "^1.25.6",
|
|
42
42
|
"@blocklet/constant": "1.16.52",
|
|
43
43
|
"@blocklet/did-space-react": "^1.1.32",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"access": "public"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@arcblock/did-connect-react": "3.1.
|
|
86
|
+
"@arcblock/did-connect-react": "3.1.51",
|
|
87
87
|
"@types/dompurify": "^3.2.0",
|
|
88
88
|
"@types/ua-parser-js": "^0.7.39",
|
|
89
89
|
"@types/validator": "^13.15.2",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"jest": "^29.7.0",
|
|
92
92
|
"unbuild": "^2.0.0"
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "8367c79c433cf59694b4aa72cbeef3b25185dd66"
|
|
95
95
|
}
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { useState, useRef, useMemo, useEffect } from 'react';
|
|
6
6
|
import { useDebounce, useInfiniteScroll, useMemoizedFn, useRequest } from 'ahooks';
|
|
7
|
-
import { useNavigate } from 'react-router-dom';
|
|
8
7
|
import { WELLKNOWN_SERVICE_PATH_PREFIX } from '@abtnode/constant';
|
|
9
8
|
import {
|
|
10
9
|
Box,
|
|
@@ -19,8 +18,8 @@ import {
|
|
|
19
18
|
ListItemText,
|
|
20
19
|
InputAdornment,
|
|
21
20
|
} from '@mui/material';
|
|
21
|
+
import { joinURL, withQuery } from 'ufo';
|
|
22
22
|
import { KeyboardArrowDown, Search, Add, OpenInNew } from '@mui/icons-material';
|
|
23
|
-
import noop from 'lodash/noop';
|
|
24
23
|
import { translate } from '@arcblock/ux/lib/Locale/util';
|
|
25
24
|
|
|
26
25
|
import useOrg from './use-org';
|
|
@@ -34,7 +33,6 @@ export default function OrgsSwitch({ session, locale = 'en' }) {
|
|
|
34
33
|
const [searchText, setSearchText] = useState('');
|
|
35
34
|
const [visible, setVisible] = useState(false);
|
|
36
35
|
const buttonRef = useRef(null);
|
|
37
|
-
const navigate = useNavigate();
|
|
38
36
|
|
|
39
37
|
const t = useMemoizedFn((key, data = {}) => {
|
|
40
38
|
return translate(translations, key, locale, 'en', data);
|
|
@@ -127,7 +125,12 @@ export default function OrgsSwitch({ session, locale = 'en' }) {
|
|
|
127
125
|
};
|
|
128
126
|
|
|
129
127
|
const handleOrgSelect = (org) => {
|
|
130
|
-
session.switchPassport(
|
|
128
|
+
session.switchPassport(
|
|
129
|
+
() => {
|
|
130
|
+
window.location.reload();
|
|
131
|
+
},
|
|
132
|
+
{ orgId: org.id }
|
|
133
|
+
);
|
|
131
134
|
handleClose();
|
|
132
135
|
};
|
|
133
136
|
|
|
@@ -136,7 +139,8 @@ export default function OrgsSwitch({ session, locale = 'en' }) {
|
|
|
136
139
|
};
|
|
137
140
|
|
|
138
141
|
const handleViewAll = () => {
|
|
139
|
-
|
|
142
|
+
const targetUrl = withQuery(joinURL(WELLKNOWN_SERVICE_PATH_PREFIX, 'user/orgs'), { locale });
|
|
143
|
+
window.location.href = targetUrl;
|
|
140
144
|
handleClose();
|
|
141
145
|
};
|
|
142
146
|
|
|
@@ -373,6 +377,7 @@ export default function OrgsSwitch({ session, locale = 'en' }) {
|
|
|
373
377
|
<Button
|
|
374
378
|
onClick={handleViewAll}
|
|
375
379
|
variant="text"
|
|
380
|
+
component="a"
|
|
376
381
|
size="small"
|
|
377
382
|
endIcon={<OpenInNew fontSize="small" />}
|
|
378
383
|
sx={{
|