@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.
@@ -1,59 +1,51 @@
1
- import { jsx as i, Fragment as b } from "react/jsx-runtime";
1
+ import { jsx as s, Fragment as b } from "react/jsx-runtime";
2
2
  import "iconify-icon";
3
- import a from "prop-types";
4
- import { use as L, createElement as v } from "react";
5
- import { SessionContext as N } from "@arcblock/did-connect-react/lib/Session";
6
- import T from "@arcblock/ux/lib/Config/theme-mode-toggle";
7
- import { useLocaleContext as k } from "@arcblock/ux/lib/Locale/context";
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 S from "@arcblock/ux/lib/SessionBlocklet";
10
- import D from "@arcblock/ux/lib/SessionUser";
11
- import { WELLKNOWN_BLOCKLET_ADMIN_PATH as E } from "@abtnode/constant";
12
- import { getLocalizedNavigation as M, filterNavByRole as O } from "../blocklets.js";
13
- import { SessionManagerProps as R } from "../types.js";
14
- import W from "./domain-warning.js";
15
- import P from "./notification-addon.js";
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: n,
17
+ formattedBlocklet: l,
26
18
  addons: o = null,
27
19
  showDomainWarningDialog: m = !0,
28
20
  sessionManagerProps: u = { showRole: !0 }
29
21
  }) {
30
- const e = L(N), { locale: t, languages: p, defaultLocale: g } = k() || {}, { enableConnect: d = !0, enableLocale: h = !0 } = n, y = !!e?.session?.user;
31
- let l = M({
32
- navigation: n?.navigation?.sessionManager,
33
- locale: t,
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
- l = O(l, e?.session?.user?.role);
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 s = [];
41
- if (_() && s.push(/* @__PURE__ */ i(P, { session: e.session }, "notification-addon")), h && t && p.length > 1 && s.push(/* @__PURE__ */ i(C, { showText: !1 }, "locale-selector")), s.push(/* @__PURE__ */ i(T, {}, "theme-mode-toggle")), d && e) {
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 && (l ? l.slice(0, 5) : []).forEach((r) => {
35
+ y && (a ? a.slice(0, 5) : []).forEach((t) => {
44
36
  f.push({
45
- label: r.title,
46
- icon: r.icon ? /* @__PURE__ */ i("iconify-icon", { icon: r.icon, height: 24, style: { marginRight: 8 } }) : null,
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: r.link,
49
- key: r.link
40
+ href: t.link,
41
+ key: t.link
50
42
  });
51
- }), s.push(/* @__PURE__ */ i(S, { session: e.session, locale: t }, "session-blocklet")), s.push(
52
- /* @__PURE__ */ i(
53
- D,
43
+ }), e.push(/* @__PURE__ */ s(R, { session: n.session, locale: i }, "session-blocklet")), e.push(
44
+ /* @__PURE__ */ s(
45
+ S,
54
46
  {
55
- session: e.session,
56
- locale: t,
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 !x() && j(n) && e?.session?.user && s.unshift(/* @__PURE__ */ i(B, { session: e.session, locale: t }, "orgs-switch")), typeof o == "function" && (s = o(s) || []), s;
66
- })(), w = Array.isArray(c) ? c : [c], A = [
67
- m ? /* @__PURE__ */ i(W, { session: e?.session, locale: t }) : null,
68
- ...w
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 v(b, null, ...A);
62
+ return k(b, null, ...A);
71
63
  }
72
64
  z.propTypes = {
73
- formattedBlocklet: a.object.isRequired,
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: a.oneOfType([a.func, a.node]),
78
- sessionManagerProps: R,
79
- showDomainWarningDialog: a.bool
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 CreateOrgDialog({ onSuccess, onCancel, locale }: {
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 CreateOrgDialog {
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 CreateOrgDialog;
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 r, Fragment as w } from "react/jsx-runtime";
2
- import { useState as f } from "react";
3
- import l from "prop-types";
4
- import { useMemoizedFn as B, useReactive as D } from "ahooks";
5
- import g from "lodash/noop";
6
- import E from "@arcblock/ux/lib/Dialog";
7
- import { Typography as h, TextField as y, DialogContentText as L, Alert as O, CircularProgress as S } from "@mui/material";
8
- import W from "@arcblock/ux/lib/Toast";
9
- import v from "@arcblock/ux/lib/Button";
10
- import { translate as j } from "@arcblock/ux/lib/Locale/util";
11
- import { formatAxiosError as k } from "../../UserCenter/libs/utils.js";
12
- import z from "./use-org.js";
13
- import A from "./locales.js";
14
- function M({ onSuccess: C = g, onCancel: s = g, locale: T = "en" }) {
15
- const [i, c] = f(!1), [u, o] = f(""), { createOrg: b } = z(), t = B((e, a = {}) => j(A, e, T, "en", a)), n = D({
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
- }), x = async () => {
19
- const e = n.name.trim();
20
- if (!e) {
21
- o(t("nameEmpty"));
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
- if (e.length > 25) {
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
- await b({ name: e, description: a }), C();
36
- } catch (d) {
37
- console.error(d);
38
- const p = k(d);
39
- o(p), W.error(p);
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
- c(!1);
59
+ y(!1);
42
60
  }
43
- }, F = /* @__PURE__ */ m("div", { children: [
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
- E,
63
+ G,
82
64
  {
83
- title: t("mutate.title", { mode: t("create") }),
65
+ title: W,
84
66
  fullWidth: !0,
85
67
  open: !0,
86
- onClose: s,
68
+ onClose: h,
87
69
  showCloseButton: !1,
88
- actions: /* @__PURE__ */ m(w, { children: [
89
- /* @__PURE__ */ r(v, { onClick: s, color: "inherit", children: t("cancel") }),
70
+ actions: /* @__PURE__ */ m(P, { children: [
71
+ /* @__PURE__ */ o(O, { onClick: h, color: "inherit", children: e("cancel") }),
90
72
  /* @__PURE__ */ m(
91
- v,
73
+ O,
92
74
  {
93
75
  "data-cy": "mutate-org-confirm",
94
- onClick: x,
76
+ onClick: S,
95
77
  color: "primary",
96
- disabled: i,
78
+ disabled: c,
97
79
  variant: "contained",
98
80
  autoFocus: !0,
99
81
  children: [
100
- i && /* @__PURE__ */ r(S, { size: 16 }),
101
- t("create")
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__ */ r(L, { component: "div", children: F }),
108
- !!u && /* @__PURE__ */ r(O, { severity: "error", style: { width: "100%", margin: 0 }, children: u })
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
- M.propTypes = {
114
- onSuccess: l.func,
115
- onCancel: l.func,
116
- locale: l.string
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
- M as default
179
+ v as CreateOrgDialog,
180
+ v as default
120
181
  };