@blocklet/ui-react 3.4.7 → 3.4.8
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/common/header-addons.js +40 -48
- package/lib/common/org-switch/avatar-uploader.d.ts +30 -0
- package/lib/common/org-switch/avatar-uploader.js +170 -0
- package/lib/common/org-switch/create.d.ts +24 -4
- package/lib/common/org-switch/create.js +152 -91
- package/lib/common/org-switch/index.js +6 -6
- package/lib/common/org-switch/locales.d.ts +18 -0
- package/lib/common/org-switch/locales.js +16 -4
- package/lib/common/org-switch/use-org.d.ts +1 -0
- package/lib/common/org-switch/use-org.js +30 -23
- package/package.json +7 -6
- package/src/common/header-addons.jsx +0 -17
- package/src/common/org-switch/avatar-uploader.jsx +271 -0
- package/src/common/org-switch/create.jsx +179 -55
- package/src/common/org-switch/index.jsx +1 -1
- package/src/common/org-switch/locales.js +12 -0
- package/src/common/org-switch/use-org.jsx +14 -2
|
@@ -1,59 +1,51 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as s, Fragment as b } from "react/jsx-runtime";
|
|
2
2
|
import "iconify-icon";
|
|
3
|
-
import
|
|
4
|
-
import { use as L, createElement as
|
|
5
|
-
import { SessionContext as
|
|
6
|
-
import
|
|
7
|
-
import { useLocaleContext as
|
|
3
|
+
import r from "prop-types";
|
|
4
|
+
import { use as L, createElement as k } from "react";
|
|
5
|
+
import { SessionContext as w } 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
8
|
import C from "@arcblock/ux/lib/Locale/selector";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
import B from "./org-switch/index.js";
|
|
17
|
-
const _ = () => !!(window?.blocklet?.navigation ?? []).find((o) => o.id === "/userCenter/notification"), j = (n) => {
|
|
18
|
-
const { settings: o = {} } = n ?? window?.blocklet ?? {};
|
|
19
|
-
return o?.org?.enabled || !1;
|
|
20
|
-
}, x = () => {
|
|
21
|
-
const { pathname: n = "" } = window.location || {};
|
|
22
|
-
return n.startsWith(E);
|
|
23
|
-
};
|
|
9
|
+
import R from "@arcblock/ux/lib/SessionBlocklet";
|
|
10
|
+
import S from "@arcblock/ux/lib/SessionUser";
|
|
11
|
+
import { getLocalizedNavigation as M, filterNavByRole as B } from "../blocklets.js";
|
|
12
|
+
import { SessionManagerProps as D } from "../types.js";
|
|
13
|
+
import P from "./domain-warning.js";
|
|
14
|
+
import j from "./notification-addon.js";
|
|
15
|
+
const x = () => !!(window?.blocklet?.navigation ?? []).find((o) => o.id === "/userCenter/notification");
|
|
24
16
|
function z({
|
|
25
|
-
formattedBlocklet:
|
|
17
|
+
formattedBlocklet: l,
|
|
26
18
|
addons: o = null,
|
|
27
19
|
showDomainWarningDialog: m = !0,
|
|
28
20
|
sessionManagerProps: u = { showRole: !0 }
|
|
29
21
|
}) {
|
|
30
|
-
const
|
|
31
|
-
let
|
|
32
|
-
navigation:
|
|
33
|
-
locale:
|
|
22
|
+
const n = L(w), { locale: i, languages: p, defaultLocale: g } = T() || {}, { enableConnect: d = !0, enableLocale: h = !0 } = l, y = !!n?.session?.user;
|
|
23
|
+
let a = M({
|
|
24
|
+
navigation: l?.navigation?.sessionManager,
|
|
25
|
+
locale: i,
|
|
34
26
|
defaultLocale: g
|
|
35
27
|
}) || [];
|
|
36
|
-
|
|
28
|
+
a = B(a, n?.session?.user?.role);
|
|
37
29
|
const c = (() => {
|
|
38
30
|
if (o && typeof o != "function")
|
|
39
31
|
return Array.isArray(o) ? o : [o];
|
|
40
|
-
let
|
|
41
|
-
if (
|
|
32
|
+
let e = [];
|
|
33
|
+
if (x() && e.push(/* @__PURE__ */ s(j, { session: n.session }, "notification-addon")), h && i && p.length > 1 && e.push(/* @__PURE__ */ s(C, { showText: !1 }, "locale-selector")), e.push(/* @__PURE__ */ s(N, {}, "theme-mode-toggle")), d && n) {
|
|
42
34
|
const f = [];
|
|
43
|
-
y && (
|
|
35
|
+
y && (a ? a.slice(0, 5) : []).forEach((t) => {
|
|
44
36
|
f.push({
|
|
45
|
-
label:
|
|
46
|
-
icon:
|
|
37
|
+
label: t.title,
|
|
38
|
+
icon: t.icon ? /* @__PURE__ */ s("iconify-icon", { icon: t.icon, height: 24, style: { marginRight: 8 } }) : null,
|
|
47
39
|
component: "a",
|
|
48
|
-
href:
|
|
49
|
-
key:
|
|
40
|
+
href: t.link,
|
|
41
|
+
key: t.link
|
|
50
42
|
});
|
|
51
|
-
}),
|
|
52
|
-
/* @__PURE__ */
|
|
53
|
-
|
|
43
|
+
}), e.push(/* @__PURE__ */ s(R, { session: n.session, locale: i }, "session-blocklet")), e.push(
|
|
44
|
+
/* @__PURE__ */ s(
|
|
45
|
+
S,
|
|
54
46
|
{
|
|
55
|
-
session:
|
|
56
|
-
locale:
|
|
47
|
+
session: n.session,
|
|
48
|
+
locale: i,
|
|
57
49
|
menu: f,
|
|
58
50
|
showRole: !0,
|
|
59
51
|
...u
|
|
@@ -62,21 +54,21 @@ function z({
|
|
|
62
54
|
)
|
|
63
55
|
);
|
|
64
56
|
}
|
|
65
|
-
return
|
|
66
|
-
})(),
|
|
67
|
-
m ? /* @__PURE__ */
|
|
68
|
-
...
|
|
57
|
+
return typeof o == "function" && (e = o(e) || []), e;
|
|
58
|
+
})(), v = Array.isArray(c) ? c : [c], A = [
|
|
59
|
+
m ? /* @__PURE__ */ s(P, { session: n?.session, locale: i }) : null,
|
|
60
|
+
...v
|
|
69
61
|
].filter(Boolean);
|
|
70
|
-
return
|
|
62
|
+
return k(b, null, ...A);
|
|
71
63
|
}
|
|
72
64
|
z.propTypes = {
|
|
73
|
-
formattedBlocklet:
|
|
65
|
+
formattedBlocklet: r.object.isRequired,
|
|
74
66
|
// 需要考虑 定制的 addons 与内置的 连接钱包/选择语言 addons 共存的情况
|
|
75
67
|
// - PropTypes.func: 可以把自定义 addons 插在 session-manager 或 locale-selector (如果存在的话) 前/中/后
|
|
76
68
|
// - PropTypes.node: 将 addons 原样传给 UX Header 组件
|
|
77
|
-
addons:
|
|
78
|
-
sessionManagerProps:
|
|
79
|
-
showDomainWarningDialog:
|
|
69
|
+
addons: r.oneOfType([r.func, r.node]),
|
|
70
|
+
sessionManagerProps: D,
|
|
71
|
+
showDomainWarningDialog: r.bool
|
|
80
72
|
};
|
|
81
73
|
export {
|
|
82
74
|
z as default
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { default as PropTypes } from 'prop-types';
|
|
2
|
+
declare function AvatarUploader({ org, size, teamDid: teamDidProp, prefix, locale, headers, onChange, onError, editable, }: {
|
|
3
|
+
org?: null | undefined;
|
|
4
|
+
size?: number | undefined;
|
|
5
|
+
teamDid?: string | undefined;
|
|
6
|
+
prefix?: string | undefined;
|
|
7
|
+
locale?: string | undefined;
|
|
8
|
+
headers?: ((...args: any[]) => void) | undefined;
|
|
9
|
+
onChange?: ((...args: any[]) => void) | undefined;
|
|
10
|
+
onError?: ((...args: any[]) => void) | undefined;
|
|
11
|
+
editable?: boolean | undefined;
|
|
12
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
declare namespace AvatarUploader {
|
|
14
|
+
namespace propTypes {
|
|
15
|
+
let org: PropTypes.Requireable<PropTypes.InferProps<{
|
|
16
|
+
id: PropTypes.Requireable<string>;
|
|
17
|
+
name: PropTypes.Requireable<string>;
|
|
18
|
+
avatar: PropTypes.Requireable<string>;
|
|
19
|
+
}>>;
|
|
20
|
+
let size: PropTypes.Requireable<number>;
|
|
21
|
+
let teamDid: PropTypes.Requireable<string>;
|
|
22
|
+
let prefix: PropTypes.Requireable<string>;
|
|
23
|
+
let headers: PropTypes.Requireable<(...args: any[]) => any>;
|
|
24
|
+
let onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
25
|
+
let onError: PropTypes.Requireable<(...args: any[]) => any>;
|
|
26
|
+
let editable: PropTypes.Requireable<boolean>;
|
|
27
|
+
let locale: PropTypes.Requireable<string>;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export default AvatarUploader;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { jsxs as E, jsx as n, Fragment as k } from "react/jsx-runtime";
|
|
2
|
+
import { lazy as M, useRef as D, useState as I, useMemo as g, Suspense as T } from "react";
|
|
3
|
+
import v from "lodash/noop";
|
|
4
|
+
import e from "prop-types";
|
|
5
|
+
import { Box as b, CircularProgress as X } from "@mui/material";
|
|
6
|
+
import { styled as Z } from "@arcblock/ux/lib/Theme";
|
|
7
|
+
import { joinURL as y } from "ufo";
|
|
8
|
+
import { useMemoizedFn as l } from "ahooks";
|
|
9
|
+
import $ from "@mui/icons-material/CameraAlt";
|
|
10
|
+
import { translate as K } from "@arcblock/ux/lib/Locale/util";
|
|
11
|
+
import q from "@arcblock/ux/lib/Img";
|
|
12
|
+
import B from "./locales.js";
|
|
13
|
+
const H = M(() => import("@blocklet/uploader").then((t) => ({ default: t.Uploader }))), P = "/blocklet", V = [".png", ".jpg", ".jpeg", ".webp", ".bmp", ".ico"], G = 5 * 1024 * 1024, A = 256, S = 3;
|
|
14
|
+
function J(t, o, a) {
|
|
15
|
+
return y(t, P, o, "orgs", "avatar", a);
|
|
16
|
+
}
|
|
17
|
+
function Q(t, o) {
|
|
18
|
+
return y(t, P, o, "orgs", "avatar", "upload");
|
|
19
|
+
}
|
|
20
|
+
function Y({
|
|
21
|
+
org: t = null,
|
|
22
|
+
size: o = 80,
|
|
23
|
+
teamDid: a = "",
|
|
24
|
+
prefix: i = "/.well-known/service",
|
|
25
|
+
locale: U = "en",
|
|
26
|
+
headers: R = v,
|
|
27
|
+
onChange: O = v,
|
|
28
|
+
onError: x = v,
|
|
29
|
+
editable: p = !0
|
|
30
|
+
}) {
|
|
31
|
+
const C = l((r, h = {}) => K(B, r, U, "en", h)), u = D(null), [d, c] = I(!1), [m, F] = I(""), s = g(() => a || (typeof window < "u" ? window.blocklet?.did : ""), [a]), f = g(() => s ? Q(i, s) : null, [i, s]), _ = p && !!f, z = l(() => {
|
|
32
|
+
_ && !d && u.current?.open();
|
|
33
|
+
}), L = l((r) => {
|
|
34
|
+
u.current?.close(), c(!1);
|
|
35
|
+
const { avatarPath: h } = r.data;
|
|
36
|
+
F(r.uploadURL), O(h);
|
|
37
|
+
}), N = l(() => {
|
|
38
|
+
c(!0);
|
|
39
|
+
}), W = l((r) => {
|
|
40
|
+
c(!1), console.error("Avatar upload failed:", r), x(r);
|
|
41
|
+
}), w = g(() => {
|
|
42
|
+
if (m)
|
|
43
|
+
return m;
|
|
44
|
+
const r = t?.avatar;
|
|
45
|
+
return r ? t?.id ? J(i, s, r) : r.startsWith("http://") || r.startsWith("https://") || r.startsWith("/") ? r : y(i, r) : null;
|
|
46
|
+
}, [m, t?.avatar, t?.id, i, s]), j = t?.name || "";
|
|
47
|
+
return /* @__PURE__ */ E(tt, { $size: o, $editable: p, $uploading: d, onClick: z, children: [
|
|
48
|
+
f && /* @__PURE__ */ n(T, { fallback: null, children: /* @__PURE__ */ n(
|
|
49
|
+
H,
|
|
50
|
+
{
|
|
51
|
+
ref: u,
|
|
52
|
+
locale: U,
|
|
53
|
+
popup: !0,
|
|
54
|
+
onUploadFinish: L,
|
|
55
|
+
onUploadStart: N,
|
|
56
|
+
onError: W,
|
|
57
|
+
plugins: ["ImageEditor"],
|
|
58
|
+
installerProps: { disabled: !0 },
|
|
59
|
+
apiPathProps: {
|
|
60
|
+
uploader: f,
|
|
61
|
+
disableMediaKitPrefix: !0,
|
|
62
|
+
disableMediaKitStatus: !0
|
|
63
|
+
},
|
|
64
|
+
coreProps: {
|
|
65
|
+
restrictions: {
|
|
66
|
+
allowedFileExts: V,
|
|
67
|
+
maxFileSize: G,
|
|
68
|
+
maxNumberOfFiles: 1
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
dashboardProps: {
|
|
72
|
+
autoOpen: "imageEditor"
|
|
73
|
+
},
|
|
74
|
+
imageEditorProps: {
|
|
75
|
+
actions: {
|
|
76
|
+
revert: !0,
|
|
77
|
+
rotate: !0,
|
|
78
|
+
granularRotate: !0,
|
|
79
|
+
flip: !0,
|
|
80
|
+
zoomIn: !0,
|
|
81
|
+
zoomOut: !0,
|
|
82
|
+
cropSquare: !1,
|
|
83
|
+
cropWidescreen: !1,
|
|
84
|
+
cropWidescreenVertical: !1
|
|
85
|
+
},
|
|
86
|
+
cropperOptions: {
|
|
87
|
+
autoCrop: !0,
|
|
88
|
+
autoCropArea: 1,
|
|
89
|
+
aspectRatio: 1,
|
|
90
|
+
initialAspectRatio: 1,
|
|
91
|
+
croppedCanvasOptions: {
|
|
92
|
+
minWidth: A,
|
|
93
|
+
minHeight: A
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
tusProps: {
|
|
98
|
+
headers: R
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
) }),
|
|
102
|
+
/* @__PURE__ */ n(
|
|
103
|
+
q,
|
|
104
|
+
{
|
|
105
|
+
src: w || "",
|
|
106
|
+
alt: j,
|
|
107
|
+
width: o,
|
|
108
|
+
height: o,
|
|
109
|
+
ratio: 1,
|
|
110
|
+
size: "cover",
|
|
111
|
+
position: "center",
|
|
112
|
+
lazy: !1,
|
|
113
|
+
style: {
|
|
114
|
+
borderRadius: "50%",
|
|
115
|
+
overflow: "hidden"
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
w || "no-avatar"
|
|
119
|
+
),
|
|
120
|
+
p && /* @__PURE__ */ n(b, { className: "upload-overlay", children: d ? /* @__PURE__ */ n(X, { size: o / S, sx: { color: "white" } }) : /* @__PURE__ */ E(k, { children: [
|
|
121
|
+
/* @__PURE__ */ n($, { sx: { fontSize: o / S, color: "white" } }),
|
|
122
|
+
/* @__PURE__ */ n(b, { component: "span", sx: { fontSize: 12, color: "white" }, children: C("upload") })
|
|
123
|
+
] }) })
|
|
124
|
+
] });
|
|
125
|
+
}
|
|
126
|
+
Y.propTypes = {
|
|
127
|
+
org: e.shape({
|
|
128
|
+
id: e.string,
|
|
129
|
+
name: e.string,
|
|
130
|
+
avatar: e.string
|
|
131
|
+
}),
|
|
132
|
+
size: e.number,
|
|
133
|
+
teamDid: e.string,
|
|
134
|
+
prefix: e.string,
|
|
135
|
+
headers: e.func,
|
|
136
|
+
onChange: e.func,
|
|
137
|
+
onError: e.func,
|
|
138
|
+
editable: e.bool,
|
|
139
|
+
locale: e.string
|
|
140
|
+
};
|
|
141
|
+
const tt = Z(b, {
|
|
142
|
+
shouldForwardProp: (t) => !["$size", "$editable", "$uploading"].includes(t)
|
|
143
|
+
})(({ $size: t, $editable: o, $uploading: a }) => ({
|
|
144
|
+
position: "relative",
|
|
145
|
+
width: t,
|
|
146
|
+
height: t,
|
|
147
|
+
borderRadius: "50%",
|
|
148
|
+
overflow: "hidden",
|
|
149
|
+
cursor: o && !a ? "pointer" : "default",
|
|
150
|
+
".upload-overlay": {
|
|
151
|
+
position: "absolute",
|
|
152
|
+
top: 0,
|
|
153
|
+
left: 0,
|
|
154
|
+
right: 0,
|
|
155
|
+
bottom: 0,
|
|
156
|
+
display: "flex",
|
|
157
|
+
flexDirection: "column",
|
|
158
|
+
alignItems: "center",
|
|
159
|
+
justifyContent: "center",
|
|
160
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
161
|
+
opacity: a ? 1 : 0,
|
|
162
|
+
transition: "opacity 0.2s ease-in-out"
|
|
163
|
+
},
|
|
164
|
+
"&:hover .upload-overlay": {
|
|
165
|
+
opacity: o ? 1 : 0
|
|
166
|
+
}
|
|
167
|
+
}));
|
|
168
|
+
export {
|
|
169
|
+
Y as default
|
|
170
|
+
};
|
|
@@ -1,14 +1,34 @@
|
|
|
1
1
|
import { default as PropTypes } from 'prop-types';
|
|
2
|
-
declare function
|
|
2
|
+
declare function OrgMutateDialog({ mode, org, onSuccess, onCancel, locale, teamDid: teamDidProp, prefix, headers, }: {
|
|
3
|
+
mode?: string | undefined;
|
|
4
|
+
org?: null | undefined;
|
|
3
5
|
onSuccess?: ((...args: any[]) => void) | undefined;
|
|
4
6
|
onCancel?: ((...args: any[]) => void) | undefined;
|
|
5
7
|
locale?: string | undefined;
|
|
8
|
+
teamDid?: string | undefined;
|
|
9
|
+
prefix?: string | undefined;
|
|
10
|
+
headers?: ((...args: any[]) => void) | undefined;
|
|
6
11
|
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
declare namespace
|
|
8
|
-
namespace propTypes {
|
|
12
|
+
declare namespace OrgMutateDialog {
|
|
13
|
+
export namespace propTypes {
|
|
14
|
+
let mode: PropTypes.Requireable<string>;
|
|
15
|
+
let org: PropTypes.Requireable<PropTypes.InferProps<{
|
|
16
|
+
id: PropTypes.Requireable<string>;
|
|
17
|
+
name: PropTypes.Requireable<string>;
|
|
18
|
+
description: PropTypes.Requireable<string>;
|
|
19
|
+
avatar: PropTypes.Requireable<string>;
|
|
20
|
+
}>>;
|
|
9
21
|
let onSuccess: PropTypes.Requireable<(...args: any[]) => any>;
|
|
10
22
|
let onCancel: PropTypes.Requireable<(...args: any[]) => any>;
|
|
11
23
|
let locale: PropTypes.Requireable<string>;
|
|
24
|
+
let teamDid: PropTypes.Requireable<string>;
|
|
25
|
+
let prefix: PropTypes.Requireable<string>;
|
|
26
|
+
let headers: PropTypes.Requireable<(...args: any[]) => any>;
|
|
12
27
|
}
|
|
28
|
+
export { MODE_CREATE };
|
|
29
|
+
export { MODE_EDIT };
|
|
13
30
|
}
|
|
14
|
-
export default
|
|
31
|
+
export default OrgMutateDialog;
|
|
32
|
+
export { OrgMutateDialog as CreateOrgDialog };
|
|
33
|
+
declare const MODE_CREATE: "create";
|
|
34
|
+
declare const MODE_EDIT: "edit";
|
|
@@ -1,120 +1,181 @@
|
|
|
1
|
-
import { jsxs as m, jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import
|
|
4
|
-
import { useMemoizedFn as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { translate as
|
|
11
|
-
import { formatAxiosError as
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { jsxs as m, jsx as o, Fragment as P } from "react/jsx-runtime";
|
|
2
|
+
import { useState as D, useEffect as q } from "react";
|
|
3
|
+
import a from "prop-types";
|
|
4
|
+
import { useMemoizedFn as d, useReactive as U } from "ahooks";
|
|
5
|
+
import u from "lodash/noop";
|
|
6
|
+
import G from "@arcblock/ux/lib/Dialog";
|
|
7
|
+
import { DialogContentText as H, Box as J, Typography as p, TextField as w, Alert as K, CircularProgress as N } from "@mui/material";
|
|
8
|
+
import Q from "@arcblock/ux/lib/Toast";
|
|
9
|
+
import O from "@arcblock/ux/lib/Button";
|
|
10
|
+
import { translate as V } from "@arcblock/ux/lib/Locale/util";
|
|
11
|
+
import { formatAxiosError as X } from "../../UserCenter/libs/utils.js";
|
|
12
|
+
import Y from "./use-org.js";
|
|
13
|
+
import Z from "./locales.js";
|
|
14
|
+
import $ from "./avatar-uploader.js";
|
|
15
|
+
const f = "create", g = "edit";
|
|
16
|
+
function v({
|
|
17
|
+
mode: _ = f,
|
|
18
|
+
org: i = null,
|
|
19
|
+
onSuccess: b = u,
|
|
20
|
+
onCancel: h = u,
|
|
21
|
+
locale: M = "en",
|
|
22
|
+
teamDid: A = "",
|
|
23
|
+
prefix: F = "/.well-known/service",
|
|
24
|
+
headers: B = u
|
|
25
|
+
}) {
|
|
26
|
+
const s = _ === g, [c, y] = D(!1), [E, n] = D(""), { createOrg: k, updateOrg: z } = Y(), I = A || (typeof window < "u" ? window.blocklet?.did : ""), e = d((r, l = {}) => V(Z, r, M, "en", l)), t = U({
|
|
16
27
|
name: "",
|
|
17
|
-
description: ""
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
description: "",
|
|
29
|
+
avatar: ""
|
|
30
|
+
});
|
|
31
|
+
q(() => {
|
|
32
|
+
s && i && (t.name = i.name || "", t.description = i.description || "", t.avatar = i.avatar || "");
|
|
33
|
+
}, [s, i]);
|
|
34
|
+
const L = d((r) => {
|
|
35
|
+
n(""), t.avatar = r;
|
|
36
|
+
}), R = d(() => {
|
|
37
|
+
const r = t.name.trim();
|
|
38
|
+
return r ? r.length > 25 ? (n(e("nameTooLong", { length: 25 })), !1) : t.description.trim().length > 255 ? (n(e("descriptionTooLong", { length: 255 })), !1) : t.avatar ? !0 : (n(e("avatarEmpty")), !1) : (n(e("nameEmpty")), !1);
|
|
39
|
+
}), S = async () => {
|
|
40
|
+
if (!R())
|
|
22
41
|
return;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
o(t("nameTooLong", { length: 25 }));
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const a = n.description.trim();
|
|
29
|
-
if (a.length > 255) {
|
|
30
|
-
o(t("descriptionTooLong", { length: 25 }));
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
o(""), c(!0);
|
|
42
|
+
n(""), y(!0);
|
|
43
|
+
const r = t.name.trim(), l = t.description.trim(), T = t.avatar;
|
|
34
44
|
try {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
s && i?.id ? await z(i.id, {
|
|
46
|
+
name: r,
|
|
47
|
+
description: l,
|
|
48
|
+
avatar: T
|
|
49
|
+
}) : await k({
|
|
50
|
+
name: r,
|
|
51
|
+
description: l,
|
|
52
|
+
avatar: T
|
|
53
|
+
}), b();
|
|
54
|
+
} catch (x) {
|
|
55
|
+
console.error(x);
|
|
56
|
+
const C = X(x);
|
|
57
|
+
n(C), Q.error(C);
|
|
40
58
|
} finally {
|
|
41
|
-
|
|
59
|
+
y(!1);
|
|
42
60
|
}
|
|
43
|
-
},
|
|
44
|
-
/* @__PURE__ */ r(h, { component: "div", style: { marginTop: 16 }, children: /* @__PURE__ */ r(
|
|
45
|
-
y,
|
|
46
|
-
{
|
|
47
|
-
label: t("mutate.name"),
|
|
48
|
-
autoComplete: "off",
|
|
49
|
-
variant: "outlined",
|
|
50
|
-
name: "name",
|
|
51
|
-
"data-cy": "mutate-org-input-name",
|
|
52
|
-
fullWidth: !0,
|
|
53
|
-
autoFocus: !0,
|
|
54
|
-
value: n.name,
|
|
55
|
-
onChange: (e) => {
|
|
56
|
-
o(""), n.name = e.target.value;
|
|
57
|
-
},
|
|
58
|
-
disabled: i
|
|
59
|
-
}
|
|
60
|
-
) }),
|
|
61
|
-
/* @__PURE__ */ r(h, { component: "div", style: { marginTop: 16, marginBottom: 16 }, children: /* @__PURE__ */ r(
|
|
62
|
-
y,
|
|
63
|
-
{
|
|
64
|
-
label: t("mutate.description"),
|
|
65
|
-
autoComplete: "off",
|
|
66
|
-
variant: "outlined",
|
|
67
|
-
name: "description",
|
|
68
|
-
"data-cy": "mutate-org-input-description",
|
|
69
|
-
fullWidth: !0,
|
|
70
|
-
value: n.description,
|
|
71
|
-
onChange: (e) => {
|
|
72
|
-
o(""), n.description = e.target.value;
|
|
73
|
-
},
|
|
74
|
-
disabled: i,
|
|
75
|
-
multiline: !0,
|
|
76
|
-
rows: 3
|
|
77
|
-
}
|
|
78
|
-
) })
|
|
79
|
-
] });
|
|
61
|
+
}, W = s ? e("mutate.title", { mode: e("edit") }) : e("mutate.title", { mode: e("create") }), j = e(s ? "save" : "create");
|
|
80
62
|
return /* @__PURE__ */ m(
|
|
81
|
-
|
|
63
|
+
G,
|
|
82
64
|
{
|
|
83
|
-
title:
|
|
65
|
+
title: W,
|
|
84
66
|
fullWidth: !0,
|
|
85
67
|
open: !0,
|
|
86
|
-
onClose:
|
|
68
|
+
onClose: h,
|
|
87
69
|
showCloseButton: !1,
|
|
88
|
-
actions: /* @__PURE__ */ m(
|
|
89
|
-
/* @__PURE__ */
|
|
70
|
+
actions: /* @__PURE__ */ m(P, { children: [
|
|
71
|
+
/* @__PURE__ */ o(O, { onClick: h, color: "inherit", children: e("cancel") }),
|
|
90
72
|
/* @__PURE__ */ m(
|
|
91
|
-
|
|
73
|
+
O,
|
|
92
74
|
{
|
|
93
75
|
"data-cy": "mutate-org-confirm",
|
|
94
|
-
onClick:
|
|
76
|
+
onClick: S,
|
|
95
77
|
color: "primary",
|
|
96
|
-
disabled:
|
|
78
|
+
disabled: c,
|
|
97
79
|
variant: "contained",
|
|
98
80
|
autoFocus: !0,
|
|
99
81
|
children: [
|
|
100
|
-
|
|
101
|
-
|
|
82
|
+
c && /* @__PURE__ */ o(N, { size: 16, sx: { mr: 1 } }),
|
|
83
|
+
j
|
|
102
84
|
]
|
|
103
85
|
}
|
|
104
86
|
)
|
|
105
87
|
] }),
|
|
106
88
|
children: [
|
|
107
|
-
/* @__PURE__ */
|
|
108
|
-
|
|
89
|
+
/* @__PURE__ */ m(H, { component: "div", children: [
|
|
90
|
+
/* @__PURE__ */ m(
|
|
91
|
+
J,
|
|
92
|
+
{
|
|
93
|
+
sx: {
|
|
94
|
+
display: "flex",
|
|
95
|
+
flexDirection: "column",
|
|
96
|
+
alignItems: "center",
|
|
97
|
+
py: 2
|
|
98
|
+
},
|
|
99
|
+
children: [
|
|
100
|
+
/* @__PURE__ */ o(
|
|
101
|
+
$,
|
|
102
|
+
{
|
|
103
|
+
org: s ? i : { name: t.name },
|
|
104
|
+
size: 90,
|
|
105
|
+
teamDid: I,
|
|
106
|
+
prefix: F,
|
|
107
|
+
headers: B,
|
|
108
|
+
onChange: L,
|
|
109
|
+
value: t.avatar,
|
|
110
|
+
editable: !0
|
|
111
|
+
}
|
|
112
|
+
),
|
|
113
|
+
/* @__PURE__ */ o(p, { variant: "caption", color: "text.secondary", sx: { mt: 1 }, children: e("avatar") })
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
),
|
|
117
|
+
/* @__PURE__ */ o(p, { component: "div", style: { marginTop: 16 }, children: /* @__PURE__ */ o(
|
|
118
|
+
w,
|
|
119
|
+
{
|
|
120
|
+
label: e("mutate.name"),
|
|
121
|
+
autoComplete: "off",
|
|
122
|
+
variant: "outlined",
|
|
123
|
+
name: "name",
|
|
124
|
+
"data-cy": "mutate-org-input-name",
|
|
125
|
+
fullWidth: !0,
|
|
126
|
+
autoFocus: !0,
|
|
127
|
+
value: t.name,
|
|
128
|
+
onChange: (r) => {
|
|
129
|
+
n(""), t.name = r.target.value;
|
|
130
|
+
},
|
|
131
|
+
disabled: c,
|
|
132
|
+
required: !0
|
|
133
|
+
}
|
|
134
|
+
) }),
|
|
135
|
+
/* @__PURE__ */ o(p, { component: "div", style: { marginTop: 16, marginBottom: 16 }, children: /* @__PURE__ */ o(
|
|
136
|
+
w,
|
|
137
|
+
{
|
|
138
|
+
label: e("mutate.description"),
|
|
139
|
+
autoComplete: "off",
|
|
140
|
+
variant: "outlined",
|
|
141
|
+
name: "description",
|
|
142
|
+
"data-cy": "mutate-org-input-description",
|
|
143
|
+
fullWidth: !0,
|
|
144
|
+
value: t.description,
|
|
145
|
+
onChange: (r) => {
|
|
146
|
+
n(""), t.description = r.target.value;
|
|
147
|
+
},
|
|
148
|
+
disabled: c,
|
|
149
|
+
multiline: !0,
|
|
150
|
+
rows: 3
|
|
151
|
+
}
|
|
152
|
+
) })
|
|
153
|
+
] }),
|
|
154
|
+
!!E && /* @__PURE__ */ o(K, { severity: "error", style: { width: "100%", margin: 0 }, children: E })
|
|
109
155
|
]
|
|
110
156
|
}
|
|
111
157
|
);
|
|
112
158
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
159
|
+
v.propTypes = {
|
|
160
|
+
/** 操作模式:'create' 创建 | 'edit' 编辑 */
|
|
161
|
+
mode: a.oneOf([f, g]),
|
|
162
|
+
/** 编辑模式下的组织数据 */
|
|
163
|
+
org: a.shape({
|
|
164
|
+
id: a.string,
|
|
165
|
+
name: a.string,
|
|
166
|
+
description: a.string,
|
|
167
|
+
avatar: a.string
|
|
168
|
+
}),
|
|
169
|
+
onSuccess: a.func,
|
|
170
|
+
onCancel: a.func,
|
|
171
|
+
locale: a.string,
|
|
172
|
+
teamDid: a.string,
|
|
173
|
+
prefix: a.string,
|
|
174
|
+
headers: a.func
|
|
117
175
|
};
|
|
176
|
+
v.MODE_CREATE = f;
|
|
177
|
+
v.MODE_EDIT = g;
|
|
118
178
|
export {
|
|
119
|
-
|
|
179
|
+
v as CreateOrgDialog,
|
|
180
|
+
v as default
|
|
120
181
|
};
|