@blocklet/ui-react 3.1.44 → 3.1.46

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.
@@ -14,7 +14,7 @@ declare function Dashboard({ meta, fallbackUrl, invalidPathFallback, headerAddon
14
14
  showRole: boolean;
15
15
  onLogout: () => void;
16
16
  } | undefined;
17
- links?: any[] | undefined;
17
+ links?: never[] | undefined;
18
18
  showDomainWarningDialog?: boolean | undefined;
19
19
  }): import("react/jsx-runtime").JSX.Element | null;
20
20
  declare namespace Dashboard {
@@ -22,7 +22,7 @@ declare namespace Dashboard {
22
22
  export { BlockletMetaProps as meta };
23
23
  export let fallbackUrl: PropTypes.Requireable<string>;
24
24
  export let invalidPathFallback: PropTypes.Requireable<(...args: any[]) => any>;
25
- export let headerAddons: PropTypes.Requireable<NonNullable<((...args: any[]) => any) | PropTypes.ReactNodeLike>>;
25
+ export let headerAddons: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike | ((...args: any[]) => any)>>;
26
26
  export { SessionManagerProps as sessionManagerProps };
27
27
  export let links: PropTypes.Requireable<NonNullable<any[] | ((...args: any[]) => any) | null | undefined>>;
28
28
  export let showDomainWarningDialog: PropTypes.Requireable<boolean>;
@@ -4,7 +4,7 @@ import { default as PropTypes } from 'prop-types';
4
4
  */
5
5
  declare function Links({ links, flowLayout, columns, ...rest }: {
6
6
  [x: string]: any;
7
- links?: any[] | undefined;
7
+ links?: never[] | undefined;
8
8
  flowLayout?: boolean | undefined;
9
9
  columns: any;
10
10
  }): import("react/jsx-runtime").JSX.Element | null;
@@ -1,7 +1,7 @@
1
1
  import { jsx as r, jsxs as m } from "react/jsx-runtime";
2
2
  import { use as we, useMemo as ye, isValidElement as X, cloneElement as Y, Children as ke } from "react";
3
- import { Box as c, Typography as Ce, CircularProgress as Pe, Divider as Se } from "@mui/material";
4
- import { useMemoizedFn as k, useCreation as u, useRequest as Z } from "ahooks";
3
+ import { Box as d, Typography as Ce, CircularProgress as Pe, Divider as Se } from "@mui/material";
4
+ import { useMemoizedFn as k, useCreation as c, useRequest as Z } from "ahooks";
5
5
  import Me from "p-wait-for";
6
6
  import ee from "react-helmet";
7
7
  import { SessionContext as De } from "@arcblock/did-connect-react/lib/Session";
@@ -42,7 +42,7 @@ import Ge from "./storage/index.js";
42
42
  import Qe from "./nft.js";
43
43
  import { UserFollowersProvider as le } from "../../contexts/user-followers.js";
44
44
  import Ve from "./fallback.js";
45
- const T = C(P, "/nfts"), F = C(P, "/settings"), z = C(P, "/did-spaces"), ae = C(P, "/user-followers"), ue = ce(c)(({ theme: v }) => ({
45
+ const T = C(P, "/nfts"), F = C(P, "/settings"), z = C(P, "/did-spaces"), ae = C(P, "/user-followers"), ue = ce(d)(({ theme: v }) => ({
46
46
  flex: 1,
47
47
  boxSizing: "border-box",
48
48
  padding: "0 16px",
@@ -56,7 +56,7 @@ const T = C(P, "/nfts"), F = C(P, "/settings"), z = C(P, "/did-spaces"), ae = C(
56
56
  [v.breakpoints.up("md")]: {
57
57
  flexDirection: "row"
58
58
  }
59
- })), W = ce(c)(({ theme: v }) => ({
59
+ })), W = ce(d)(({ theme: v }) => ({
60
60
  overflow: "hidden",
61
61
  flex: "revert",
62
62
  [v.breakpoints.up("md")]: {
@@ -84,12 +84,12 @@ function _r({
84
84
  // 只显示 profile 页面,用于 ArcSphere 只需要显示 Profile 的内容
85
85
  onDestroySelf: me = void 0
86
86
  }) {
87
- const { locale: h } = Ue(), d = $e({ key: "md" }), p = k((e, t = {}) => Ae(Ne, e, h, "en", t)), o = we(De)?.session, x = u(() => {
87
+ const { locale: h } = Ue(), l = $e({ key: "md" }), p = k((e, t = {}) => Ae(Ne, e, h, "en", t)), o = we(De)?.session, x = c(() => {
88
88
  if (M)
89
89
  return M;
90
90
  const e = window.location.href, t = Ie(e);
91
91
  return t?.did ? Array.isArray(t.did) ? t.did[0] : t.did : o?.user?.did;
92
- }, [o?.user?.did, M]), i = u(() => o?.user ? x === o?.user?.did : !1, [x, o?.user?.did]), w = ye(() => je(), []), n = Z(
92
+ }, [o?.user?.did, M]), i = c(() => o?.user ? x === o?.user?.did : !1, [x, o?.user?.did]), w = ye(() => je(), []), n = Z(
93
93
  // eslint-disable-next-line consistent-return
94
94
  async () => {
95
95
  if (await Me(() => o?.initialized), i)
@@ -107,7 +107,7 @@ function _r({
107
107
  loadingDelay: 300
108
108
  }
109
109
  ), { confirmHolder: H } = We({
110
- fullScreen: d,
110
+ fullScreen: l,
111
111
  sx: {
112
112
  ".MuiDialog-paper": {
113
113
  borderRadius: 1,
@@ -126,14 +126,14 @@ function _r({
126
126
  }
127
127
  }
128
128
  }
129
- }), N = u(() => {
129
+ }), N = c(() => {
130
130
  const e = Be(window.blocklet);
131
131
  try {
132
132
  return Ee(e);
133
133
  } catch (t) {
134
134
  return console.error("Failed to format blocklet info", t, e), e;
135
135
  }
136
- }, []), E = u(() => {
136
+ }, []), E = c(() => {
137
137
  const e = {
138
138
  label: p("common.nft"),
139
139
  protected: !1,
@@ -150,7 +150,7 @@ function _r({
150
150
  };
151
151
  let f = w ? [e, t] : [e];
152
152
  if (i) {
153
- const a = [
153
+ const u = [
154
154
  e,
155
155
  {
156
156
  label: p("common.setting"),
@@ -167,52 +167,52 @@ function _r({
167
167
  url: S(z, h)
168
168
  }
169
169
  ];
170
- f = w ? [...a, t] : a;
170
+ f = w ? [...u, t] : u;
171
171
  }
172
172
  return f;
173
- }, [i, h, w]), l = u(() => {
173
+ }, [i, h, w]), a = c(() => {
174
174
  const e = N?.navigation?.userCenter || [];
175
- return (_e(e, h) || []).concat(E).map((a) => {
176
- const K = a.value ?? a._rawLink ?? a.link ?? a.url;
175
+ return (_e(e, h) || []).concat(E).map((u) => {
176
+ const K = u.value ?? u._rawLink ?? u.link ?? u.url;
177
177
  return {
178
178
  value: K,
179
- label: a.title || a.label,
180
- url: a.link || a.url,
179
+ label: u.title || u.label,
180
+ url: u.link || u.url,
181
181
  protected: g?.data?.[K] ?? !1,
182
- isPrivate: a.isPrivate || a.private || (a?._rawLink?.includes("/customer") ?? !1),
182
+ isPrivate: u.isPrivate || u.private || (u?._rawLink?.includes("/customer") ?? !1),
183
183
  // FIXME: HACK: 隐藏 /customer 菜单, 需要一个通用的解决方案,在嵌入的时候就决定是否是私有的
184
- followersOnly: a.component === "did-comments"
184
+ followersOnly: u.component === "did-comments"
185
185
  // 是否开启仅粉丝可查看的功能,目前只对 discuss kit 开启
186
186
  // icon: x.icon,
187
187
  };
188
- }).filter((a) => i || !a.isPrivate);
189
- }, [N, n.data, g?.data, h, E, i]), s = u(() => l.find((e) => te(e.value) === te(b)), [l]), _ = u(() => {
188
+ }).filter((u) => i || !u.isPrivate);
189
+ }, [N, n.data, g?.data, h, E, i]), s = c(() => a.find((e) => te(e.value) === te(b)), [a]), _ = c(() => {
190
190
  const e = window.blocklet?.appName, f = [s?.label, p("userCenter.title")].filter(Boolean).join("-");
191
191
  return e ? `${f} | ${e}` : f;
192
192
  }, [s, p]), he = k((e) => e && (X(e) ? Y(e, {
193
193
  ...e.props || {},
194
- userCenterTabs: l
194
+ userCenterTabs: a
195
195
  }) : ke.map(e, (t) => X(t) ? Y(t, {
196
196
  ...t.props || {},
197
- userCenterTabs: l
197
+ userCenterTabs: a
198
198
  }) : t))), xe = k((e) => {
199
- const t = l.find((f) => f.value === e);
199
+ const t = a.find((f) => f.value === e);
200
200
  t && (window.location.href = ie(t.url, {
201
201
  did: i ? void 0 : x
202
202
  }));
203
- }), O = u(() => /* @__PURE__ */ r(
203
+ }), O = c(() => /* @__PURE__ */ r(
204
204
  Re,
205
205
  {
206
206
  user: n.data,
207
- settings: { userCenterTabs: l },
207
+ settings: { userCenterTabs: a },
208
208
  onSave: async (e) => e === "privacy" ? (await g.runAsync(), g.data) : (e === "profile" && await o.refresh(), null),
209
- isMobile: d,
209
+ isMobile: l,
210
210
  onDestroySelf: me
211
211
  }
212
- ), [n.data, l, g.data, g.runAsync]), R = u(() => s && s?.value === F, [s]), $ = u(() => s && s?.value === C(P, "/profile") || s?.value === T, [s]), ge = u(() => s && s?.value === z, [s]), be = o.useOAuth(), ve = o.usePasskey(), q = k(() => {
212
+ ), [n.data, a, g.data, g.runAsync]), R = c(() => s && s?.value === F, [s]), $ = c(() => s && s?.value === C(P, "/profile") || s?.value === T, [s]), ge = c(() => s && s?.value === z, [s]), be = o.useOAuth(), ve = o.usePasskey(), q = k(() => {
213
213
  o?.user?.sourceProvider === "passkey" ? ve.switchPassport(o.user) : ["google", "apple", "email", "github"].includes(o?.user?.sourceProvider ?? "") ? be.switchOAuthPassport(o.user) : o && o.switchPassport();
214
- }), D = u(() => $ ? /* @__PURE__ */ m(
215
- c,
214
+ }), D = c(() => $ ? /* @__PURE__ */ m(
215
+ d,
216
216
  {
217
217
  sx: {
218
218
  display: "flex",
@@ -220,7 +220,7 @@ function _r({
220
220
  gap: 2.5
221
221
  },
222
222
  children: [
223
- i ? /* @__PURE__ */ m(c, { sx: { border: "1px solid", borderColor: "divider", borderRadius: 1.5, p: 2 }, children: [
223
+ i ? /* @__PURE__ */ m(d, { sx: { border: "1px solid", borderColor: "divider", borderRadius: 1.5, p: 2 }, children: [
224
224
  /* @__PURE__ */ r(
225
225
  Ce,
226
226
  {
@@ -237,8 +237,8 @@ function _r({
237
237
  /* @__PURE__ */ r(Qe, { user: n.data })
238
238
  ]
239
239
  }
240
- ) : R && i ? O : ge && i ? /* @__PURE__ */ r(qe, { children: /* @__PURE__ */ r(Ge, {}) }) : null, [R, $, n, i, B, O]), G = u(() => /* @__PURE__ */ r(
241
- c,
240
+ ) : R && i ? O : ge && i ? /* @__PURE__ */ r(qe, { children: /* @__PURE__ */ r(Ge, {}) }) : null, [R, $, n, i, B, O]), G = c(() => /* @__PURE__ */ r(
241
+ d,
242
242
  {
243
243
  sx: {
244
244
  display: {
@@ -249,8 +249,8 @@ function _r({
249
249
  },
250
250
  children: /* @__PURE__ */ r(re, { children: p("emptyContent") })
251
251
  }
252
- ), [i, h]), Q = u(() => !g.data || g.loading ? /* @__PURE__ */ r(
253
- c,
252
+ ), [i, h]), Q = c(() => !g.data || g.loading ? /* @__PURE__ */ r(
253
+ d,
254
254
  {
255
255
  sx: {
256
256
  height: "100%",
@@ -263,27 +263,27 @@ function _r({
263
263
  },
264
264
  children: /* @__PURE__ */ r(Pe, {})
265
265
  }
266
- ) : /* @__PURE__ */ r(c, { sx: { flex: 1 }, children: /* @__PURE__ */ r(
266
+ ) : /* @__PURE__ */ r(d, { sx: { flex: 1 }, children: /* @__PURE__ */ r(
267
267
  Ve,
268
268
  {
269
269
  isSupportFollow: w,
270
270
  currentActiveTab: s,
271
271
  isMyself: i,
272
- children: v ? /* @__PURE__ */ r(c, { ...U, children: he(v) }) : D
272
+ children: v ? /* @__PURE__ */ r(d, { ...U, children: he(v) }) : D
273
273
  }
274
- ) }), [g, s, i, v, U, D, h]), V = u(() => {
274
+ ) }), [g, s, i, v, U, D, h]), V = c(() => {
275
275
  if (n.loading || o.loading)
276
276
  return null;
277
277
  if (n.error) {
278
278
  if (n.error?.response?.status === 404)
279
- return /* @__PURE__ */ r(c, { sx: { width: "100%" }, children: /* @__PURE__ */ r(ze, { status: 404, description: p("noUserFound") }) });
279
+ return /* @__PURE__ */ r(d, { sx: { width: "100%" }, children: /* @__PURE__ */ r(ze, { status: 404, description: p("noUserFound") }) });
280
280
  const f = {
281
281
  message: n.error.response?.data?.error || n.error.message || "error occurred"
282
282
  };
283
- return /* @__PURE__ */ r(c, { sx: { width: "100%" }, children: /* @__PURE__ */ r(Le, { error: f }) });
283
+ return /* @__PURE__ */ r(d, { sx: { width: "100%" }, children: /* @__PURE__ */ r(Le, { error: f }) });
284
284
  }
285
- return !x && !n.data ? A || /* @__PURE__ */ r(c, { sx: { width: "100%" }, children: /* @__PURE__ */ m(
286
- c,
285
+ return !x && !n.data ? A || /* @__PURE__ */ r(d, { sx: { width: "100%" }, children: /* @__PURE__ */ m(
286
+ d,
287
287
  {
288
288
  sx: {
289
289
  display: "flex",
@@ -298,11 +298,11 @@ function _r({
298
298
  ]
299
299
  }
300
300
  ) }) : I ? /* @__PURE__ */ m(W, { children: [
301
- l.length > 0 && b ? /* @__PURE__ */ r(
302
- c,
301
+ a.length > 0 && b ? /* @__PURE__ */ r(
302
+ d,
303
303
  {
304
304
  sx: {
305
- display: d ? "block" : "flex",
305
+ display: l ? "block" : "flex",
306
306
  height: "100%",
307
307
  overflow: "auto",
308
308
  padding: "1px"
@@ -310,12 +310,12 @@ function _r({
310
310
  children: Q
311
311
  }
312
312
  ) : null,
313
- l.length === 0 && G
314
- ] }) : y ? /* @__PURE__ */ r(W, { display: "flex", flexDirection: d ? "column" : "row", children: /* @__PURE__ */ r(
313
+ a.length === 0 && G
314
+ ] }) : y ? /* @__PURE__ */ r(W, { display: "flex", flexDirection: l ? "column" : "row", children: /* @__PURE__ */ r(
315
315
  ne,
316
316
  {
317
- isMobile: d,
318
- order: d ? 1 : "unset",
317
+ isMobile: l,
318
+ order: l ? 1 : "unset",
319
319
  isMyself: i,
320
320
  switchPassport: q,
321
321
  switchProfile: o.switchProfile,
@@ -325,23 +325,24 @@ function _r({
325
325
  refreshProfile: j,
326
326
  isShowSocialActions: w,
327
327
  sx: {
328
- padding: d ? "16px 0 0 0" : "40px 24px 24px 40px",
329
- ...d ? {} : { width: 320, maxWidth: 320, flexShrink: 0 },
328
+ padding: l ? "16px 0 0 0" : "40px 24px 24px 40px",
329
+ ...l ? {} : { width: 320, maxWidth: 320, flexShrink: 0 },
330
330
  boxSizing: "content-box"
331
331
  }
332
332
  }
333
- ) }) : /* @__PURE__ */ m(W, { display: "flex", flexDirection: d ? "column" : "row", children: [
333
+ ) }) : /* @__PURE__ */ m(W, { display: "flex", flexDirection: l ? "column" : "row", children: [
334
334
  /* @__PURE__ */ m(
335
- c,
335
+ d,
336
336
  {
337
337
  className: "user-center-tabs",
338
338
  sx: {
339
339
  flex: "1",
340
- order: d ? 2 : "unset"
340
+ order: l ? 2 : "unset",
341
+ width: l ? "unset" : "calc(100% - 424px)"
341
342
  },
342
343
  children: [
343
- l.length > 0 && b ? /* @__PURE__ */ m(
344
- c,
344
+ a.length > 0 && b ? /* @__PURE__ */ m(
345
+ d,
345
346
  {
346
347
  sx: {
347
348
  display: "flex",
@@ -356,7 +357,7 @@ function _r({
356
357
  {
357
358
  orientation: "horizontal",
358
359
  variant: "line",
359
- tabs: l,
360
+ tabs: a,
360
361
  current: s?.value ?? b,
361
362
  onChange: xe,
362
363
  enableTabClick: !0,
@@ -365,7 +366,7 @@ function _r({
365
366
  ".MuiTabs-flexContainer": {
366
367
  gap: 3,
367
368
  ".MuiButtonBase-root": {
368
- padding: d ? "16px 4px" : "32px 4px 16px 4px",
369
+ padding: l ? "16px 4px" : "32px 4px 16px 4px",
369
370
  fontSize: 16
370
371
  },
371
372
  ".MuiTab-root": {
@@ -399,16 +400,16 @@ function _r({
399
400
  ]
400
401
  }
401
402
  ) : null,
402
- l.length === 0 && G
403
+ a.length === 0 && G
403
404
  ]
404
405
  }
405
406
  ),
406
- !d && /* @__PURE__ */ r(Se, { orientation: "vertical", sx: { ml: 5 } }),
407
+ !l && /* @__PURE__ */ r(Se, { orientation: "vertical", sx: { ml: 5 } }),
407
408
  /* @__PURE__ */ r(
408
409
  ne,
409
410
  {
410
- isMobile: d,
411
- order: d ? 1 : "unset",
411
+ isMobile: l,
412
+ order: l ? 1 : "unset",
412
413
  isMyself: i,
413
414
  switchPassport: q,
414
415
  switchProfile: o.switchProfile,
@@ -417,8 +418,8 @@ function _r({
417
418
  showFullDid: !1,
418
419
  isShowSocialActions: w,
419
420
  sx: {
420
- padding: d ? "16px 0 0 0" : "40px 24px 24px 40px",
421
- ...d ? {} : { width: 320, maxWidth: 320, flexShrink: 0 },
421
+ padding: l ? "16px 0 0 0" : "40px 24px 24px 40px",
422
+ ...l ? {} : { width: 320, maxWidth: 320, flexShrink: 0 },
422
423
  boxSizing: "content-box"
423
424
  }
424
425
  }
@@ -426,23 +427,23 @@ function _r({
426
427
  ] });
427
428
  }, [
428
429
  n,
429
- l,
430
+ a,
430
431
  i,
431
432
  s,
432
433
  g,
433
434
  b,
434
435
  B,
435
436
  D
436
- ]), J = u(() => i ? !1 : s?.isPrivate, [i, s]);
437
- if (u(() => y ? !1 : !L && !b && l?.length > 0 || !s || J, [L, b, l, s, J, y])) {
438
- const e = l[0]?.url, t = l.find((f) => f.value === e);
437
+ ]), J = c(() => i ? !1 : s?.isPrivate, [i, s]);
438
+ if (c(() => y ? !1 : !L && !b && a?.length > 0 || !s || J, [L, b, a, s, J, y])) {
439
+ const e = a[0]?.url, t = a.find((f) => f.value === e);
439
440
  return e && !t?.isPrivate && window.location.replace(
440
441
  ie(e, {
441
442
  did: i ? void 0 : x
442
443
  })
443
444
  ), null;
444
445
  }
445
- return I || y ? /* @__PURE__ */ m(c, { children: [
446
+ return I || y ? /* @__PURE__ */ m(d, { children: [
446
447
  /* @__PURE__ */ r(ee, { children: /* @__PURE__ */ r("title", { children: _ }) }),
447
448
  /* @__PURE__ */ r(oe, { style: { display: "none" } }),
448
449
  /* @__PURE__ */ m(ue, { children: [
@@ -450,7 +451,7 @@ function _r({
450
451
  H
451
452
  ] })
452
453
  ] }) : /* @__PURE__ */ m(
453
- c,
454
+ d,
454
455
  {
455
456
  sx: {
456
457
  minHeight: "100vh",
@@ -11,7 +11,7 @@ declare function HeaderAddons({ formattedBlocklet, addons, showDomainWarningDial
11
11
  declare namespace HeaderAddons {
12
12
  namespace propTypes {
13
13
  export let formattedBlocklet: PropTypes.Validator<object>;
14
- export let addons: PropTypes.Requireable<NonNullable<((...args: any[]) => any) | PropTypes.ReactNodeLike>>;
14
+ export let addons: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike | ((...args: any[]) => any)>>;
15
15
  export { SessionManagerProps as sessionManagerProps };
16
16
  export let showDomainWarningDialog: PropTypes.Requireable<boolean>;
17
17
  }
@@ -1,47 +1,55 @@
1
- import { jsx as s, Fragment as v } from "react/jsx-runtime";
1
+ import { jsx as i, Fragment as A } from "react/jsx-runtime";
2
2
  import "iconify-icon";
3
- import r from "prop-types";
4
- import { use as b, createElement as k } from "react";
5
- import { SessionContext as w } from "@arcblock/did-connect-react/lib/Session";
6
- import L from "@arcblock/ux/lib/Config/theme-mode-toggle";
7
- import { useLocaleContext as N } from "@arcblock/ux/lib/Locale/context";
8
- import T from "@arcblock/ux/lib/Locale/selector";
3
+ import a from "prop-types";
4
+ import { use as b, createElement as L } from "react";
5
+ import { SessionContext as v } from "@arcblock/did-connect-react/lib/Session";
6
+ import N from "@arcblock/ux/lib/Config/theme-mode-toggle";
7
+ import { useLocaleContext as T } from "@arcblock/ux/lib/Locale/context";
8
+ import k from "@arcblock/ux/lib/Locale/selector";
9
9
  import C from "@arcblock/ux/lib/SessionBlocklet";
10
- import R from "@arcblock/ux/lib/SessionUser";
11
- import { getLocalizedNavigation as S, filterNavByRole as M } from "../blocklets.js";
12
- import { SessionManagerProps as B } from "../types.js";
13
- import D from "./domain-warning.js";
14
- import P from "./notification-addon.js";
15
- const j = () => !!(window?.blocklet?.navigation ?? []).find((o) => o.id === "/userCenter/notification");
10
+ import S from "@arcblock/ux/lib/SessionUser";
11
+ import { WELLKNOWN_BLOCKLET_ADMIN_PATH as D } from "@abtnode/constant";
12
+ import { getLocalizedNavigation as E, filterNavByRole as M } from "../blocklets.js";
13
+ import { SessionManagerProps as O } from "../types.js";
14
+ import R from "./domain-warning.js";
15
+ import W from "./notification-addon.js";
16
+ import P from "./org-switch/index.js";
17
+ const B = () => !!(window?.blocklet?.navigation ?? []).find((o) => o.id === "/userCenter/notification"), _ = (n) => {
18
+ const { settings: o = {} } = n ?? window?.blocklet ?? {};
19
+ return o?.org?.enabled || !1;
20
+ }, j = () => {
21
+ const { pathname: n = "" } = window.location || {};
22
+ return n.startsWith(D);
23
+ };
16
24
  function x({
17
- formattedBlocklet: l,
25
+ formattedBlocklet: n,
18
26
  addons: o = null,
19
27
  showDomainWarningDialog: m = !0,
20
28
  sessionManagerProps: u = { showRole: !0 }
21
29
  }) {
22
- const n = b(w), { locale: i, languages: p } = N() || {}, { enableConnect: g = !0, enableLocale: d = !0 } = l, h = !!n?.session?.user;
23
- let a = S(l?.navigation?.sessionManager, i) || [];
24
- a = M(a, n?.session?.user?.role);
30
+ const e = b(v), { locale: t, languages: p } = T() || {}, { enableConnect: g = !0, enableLocale: d = !0 } = n, h = !!e?.session?.user;
31
+ let l = E(n?.navigation?.sessionManager, t) || [];
32
+ l = M(l, e?.session?.user?.role);
25
33
  const c = (() => {
26
34
  if (o && typeof o != "function")
27
35
  return Array.isArray(o) ? o : [o];
28
- let e = [];
29
- if (j() && e.push(/* @__PURE__ */ s(P, { session: n.session }, "notification-addon")), d && i && p.length > 1 && e.push(/* @__PURE__ */ s(T, { showText: !1 }, "locale-selector")), e.push(/* @__PURE__ */ s(L, {}, "theme-mode-toggle")), g && n) {
36
+ let s = [];
37
+ if (B() && s.push(/* @__PURE__ */ i(W, { session: e.session }, "notification-addon")), d && t && p.length > 1 && s.push(/* @__PURE__ */ i(k, { showText: !1 }, "locale-selector")), s.push(/* @__PURE__ */ i(N, {}, "theme-mode-toggle")), g && e) {
30
38
  const f = [];
31
- h && (a ? a.slice(0, 5) : []).forEach((t) => {
39
+ h && (l ? l.slice(0, 5) : []).forEach((r) => {
32
40
  f.push({
33
- label: t.title,
34
- icon: t.icon ? /* @__PURE__ */ s("iconify-icon", { icon: t.icon, height: 24, style: { marginRight: 8 } }) : null,
41
+ label: r.title,
42
+ icon: r.icon ? /* @__PURE__ */ i("iconify-icon", { icon: r.icon, height: 24, style: { marginRight: 8 } }) : null,
35
43
  component: "a",
36
- href: t.link,
37
- key: t.link
44
+ href: r.link,
45
+ key: r.link
38
46
  });
39
- }), e.push(/* @__PURE__ */ s(C, { session: n.session, locale: i }, "session-blocklet")), e.push(
40
- /* @__PURE__ */ s(
41
- R,
47
+ }), s.push(/* @__PURE__ */ i(C, { session: e.session, locale: t }, "session-blocklet")), s.push(
48
+ /* @__PURE__ */ i(
49
+ S,
42
50
  {
43
- session: n.session,
44
- locale: i,
51
+ session: e.session,
52
+ locale: t,
45
53
  menu: f,
46
54
  showRole: !0,
47
55
  ...u
@@ -50,21 +58,21 @@ function x({
50
58
  )
51
59
  );
52
60
  }
53
- return typeof o == "function" && (e = o(e) || []), e;
54
- })(), y = Array.isArray(c) ? c : [c], A = [
55
- m ? /* @__PURE__ */ s(D, { session: n?.session, locale: i }) : null,
61
+ return !j() && _(n) && e?.session?.user && s.unshift(/* @__PURE__ */ i(P, { session: e.session, locale: t }, "orgs-switch")), typeof o == "function" && (s = o(s) || []), s;
62
+ })(), y = Array.isArray(c) ? c : [c], w = [
63
+ m ? /* @__PURE__ */ i(R, { session: e?.session, locale: t }) : null,
56
64
  ...y
57
65
  ].filter(Boolean);
58
- return k(v, null, ...A);
66
+ return L(A, null, ...w);
59
67
  }
60
68
  x.propTypes = {
61
- formattedBlocklet: r.object.isRequired,
69
+ formattedBlocklet: a.object.isRequired,
62
70
  // 需要考虑 定制的 addons 与内置的 连接钱包/选择语言 addons 共存的情况
63
71
  // - PropTypes.func: 可以把自定义 addons 插在 session-manager 或 locale-selector (如果存在的话) 前/中/后
64
72
  // - PropTypes.node: 将 addons 原样传给 UX Header 组件
65
- addons: r.oneOfType([r.func, r.node]),
66
- sessionManagerProps: B,
67
- showDomainWarningDialog: r.bool
73
+ addons: a.oneOfType([a.func, a.node]),
74
+ sessionManagerProps: O,
75
+ showDomainWarningDialog: a.bool
68
76
  };
69
77
  export {
70
78
  x as default
@@ -0,0 +1,14 @@
1
+ import { default as PropTypes } from 'prop-types';
2
+ declare function CreateOrgDialog({ onSuccess, onCancel, locale }: {
3
+ onSuccess?: ((...args: any[]) => void) | undefined;
4
+ onCancel?: ((...args: any[]) => void) | undefined;
5
+ locale?: string | undefined;
6
+ }): import("react/jsx-runtime").JSX.Element;
7
+ declare namespace CreateOrgDialog {
8
+ namespace propTypes {
9
+ let onSuccess: PropTypes.Requireable<(...args: any[]) => any>;
10
+ let onCancel: PropTypes.Requireable<(...args: any[]) => any>;
11
+ let locale: PropTypes.Requireable<string>;
12
+ }
13
+ }
14
+ export default CreateOrgDialog;
@@ -0,0 +1,124 @@
1
+ import { jsxs as m, jsx as o, Fragment as w } from "react/jsx-runtime";
2
+ import { useState as f } from "react";
3
+ import l from "prop-types";
4
+ import { useMemoizedFn as S, useReactive as B } from "ahooks";
5
+ import g from "lodash/noop";
6
+ import D from "@arcblock/ux/lib/Dialog";
7
+ import E from "@mui/material/CircularProgress";
8
+ import L from "@mui/material/DialogContentText";
9
+ import h from "@mui/material/Typography";
10
+ import y from "@mui/material/TextField";
11
+ import O from "@mui/material/Alert";
12
+ import W from "@arcblock/ux/lib/Toast";
13
+ import v from "@arcblock/ux/lib/Button";
14
+ import { translate as j } from "@arcblock/ux/lib/Locale/util";
15
+ import { formatAxiosError as k } from "../../UserCenter/libs/utils.js";
16
+ import z from "./use-org.js";
17
+ import A from "./locales.js";
18
+ function M({ onSuccess: C = g, onCancel: s = g, locale: T = "en" }) {
19
+ const [i, c] = f(!1), [p, r] = f(""), { createOrg: b } = z(), t = S((e, a = {}) => j(A, e, T, "en", a)), n = B({
20
+ name: "",
21
+ description: ""
22
+ }), x = async () => {
23
+ const e = n.name.trim();
24
+ if (!e) {
25
+ r(t("nameEmpty"));
26
+ return;
27
+ }
28
+ if (e.length > 25) {
29
+ r(t("nameTooLong", { length: 25 }));
30
+ return;
31
+ }
32
+ const a = n.description.trim();
33
+ if (a.length > 255) {
34
+ r(t("descriptionTooLong", { length: 25 }));
35
+ return;
36
+ }
37
+ r(""), c(!0);
38
+ try {
39
+ await b({ name: e, description: a }), C();
40
+ } catch (u) {
41
+ console.error(u);
42
+ const d = k(u);
43
+ r(d), W.error(d);
44
+ } finally {
45
+ c(!1);
46
+ }
47
+ }, F = /* @__PURE__ */ m("div", { children: [
48
+ /* @__PURE__ */ o(h, { component: "div", style: { marginTop: 16 }, children: /* @__PURE__ */ o(
49
+ y,
50
+ {
51
+ label: t("mutate.name"),
52
+ autoComplete: "off",
53
+ variant: "outlined",
54
+ name: "name",
55
+ "data-cy": "mutate-org-input-name",
56
+ fullWidth: !0,
57
+ autoFocus: !0,
58
+ value: n.name,
59
+ onChange: (e) => {
60
+ r(""), n.name = e.target.value;
61
+ },
62
+ disabled: i
63
+ }
64
+ ) }),
65
+ /* @__PURE__ */ o(h, { component: "div", style: { marginTop: 16, marginBottom: 16 }, children: /* @__PURE__ */ o(
66
+ y,
67
+ {
68
+ label: t("mutate.description"),
69
+ autoComplete: "off",
70
+ variant: "outlined",
71
+ name: "description",
72
+ "data-cy": "mutate-org-input-description",
73
+ fullWidth: !0,
74
+ value: n.description,
75
+ onChange: (e) => {
76
+ r(""), n.description = e.target.value;
77
+ },
78
+ disabled: i,
79
+ multiline: !0,
80
+ rows: 3
81
+ }
82
+ ) })
83
+ ] });
84
+ return /* @__PURE__ */ m(
85
+ D,
86
+ {
87
+ title: t("mutate.title", { mode: t("create") }),
88
+ fullWidth: !0,
89
+ open: !0,
90
+ onClose: s,
91
+ showCloseButton: !1,
92
+ actions: /* @__PURE__ */ m(w, { children: [
93
+ /* @__PURE__ */ o(v, { onClick: s, color: "inherit", children: t("cancel") }),
94
+ /* @__PURE__ */ m(
95
+ v,
96
+ {
97
+ "data-cy": "mutate-org-confirm",
98
+ onClick: x,
99
+ color: "primary",
100
+ disabled: i,
101
+ variant: "contained",
102
+ autoFocus: !0,
103
+ children: [
104
+ i && /* @__PURE__ */ o(E, { size: 16 }),
105
+ t("create")
106
+ ]
107
+ }
108
+ )
109
+ ] }),
110
+ children: [
111
+ /* @__PURE__ */ o(L, { component: "div", children: F }),
112
+ !!p && /* @__PURE__ */ o(O, { severity: "error", style: { width: "100%", margin: 0 }, children: p })
113
+ ]
114
+ }
115
+ );
116
+ }
117
+ M.propTypes = {
118
+ onSuccess: l.func,
119
+ onCancel: l.func,
120
+ locale: l.string
121
+ };
122
+ export {
123
+ M as default
124
+ };