@lark-apaas/miaoda-core 0.0.1-alpha.1
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/LICENSE +13 -0
- package/README.md +8 -0
- package/lib/apis/components/AppContainer.d.ts +1 -0
- package/lib/apis/components/AppContainer.js +2 -0
- package/lib/apis/components/ErrorRender.d.ts +1 -0
- package/lib/apis/components/ErrorRender.js +2 -0
- package/lib/apis/components/NotFoundRender.d.ts +1 -0
- package/lib/apis/components/NotFoundRender.js +2 -0
- package/lib/apis/components/SidebarNav.d.ts +1 -0
- package/lib/apis/components/SidebarNav.js +2 -0
- package/lib/apis/components/User.d.ts +1 -0
- package/lib/apis/components/User.js +1 -0
- package/lib/apis/components/Welcome.d.ts +1 -0
- package/lib/apis/components/Welcome.js +2 -0
- package/lib/apis/constants/img-resources/avatar.d.ts +11 -0
- package/lib/apis/constants/img-resources/avatar.js +12 -0
- package/lib/apis/constants/img-resources/banner.d.ts +24 -0
- package/lib/apis/constants/img-resources/banner.js +25 -0
- package/lib/apis/constants/img-resources/cover.d.ts +36 -0
- package/lib/apis/constants/img-resources/cover.js +37 -0
- package/lib/apis/dataloom.d.ts +1 -0
- package/lib/apis/dataloom.js +2 -0
- package/lib/apis/hooks/useAppInfo.d.ts +1 -0
- package/lib/apis/hooks/useAppInfo.js +1 -0
- package/lib/apis/hooks/useCurrentUserProfile.d.ts +1 -0
- package/lib/apis/hooks/useCurrentUserProfile.js +1 -0
- package/lib/apis/logger.d.ts +1 -0
- package/lib/apis/logger.js +1 -0
- package/lib/apis/tools/generateImage.d.ts +1 -0
- package/lib/apis/tools/generateImage.js +1 -0
- package/lib/apis/tools/generateTextStream.d.ts +1 -0
- package/lib/apis/tools/generateTextStream.js +1 -0
- package/lib/apis/tools/getAppInfo.d.ts +1 -0
- package/lib/apis/tools/getAppInfo.js +1 -0
- package/lib/apis/tools/getCurrentUserProfile.d.ts +1 -0
- package/lib/apis/tools/getCurrentUserProfile.js +1 -0
- package/lib/apis/tools/storage.d.ts +1 -0
- package/lib/apis/tools/storage.js +4 -0
- package/lib/apis/udt-types.d.ts +16 -0
- package/lib/apis/udt-types.js +0 -0
- package/lib/apis/utils/registerChinaMap.d.ts +1 -0
- package/lib/apis/utils/registerChinaMap.js +103319 -0
- package/lib/components/AppContainer/IframeBridge.d.ts +4 -0
- package/lib/components/AppContainer/IframeBridge.js +92 -0
- package/lib/components/AppContainer/LogInterceptor.d.ts +1 -0
- package/lib/components/AppContainer/LogInterceptor.js +44 -0
- package/lib/components/AppContainer/PageHoc.d.ts +4 -0
- package/lib/components/AppContainer/PageHoc.js +40 -0
- package/lib/components/AppContainer/api-proxy/core.d.ts +188 -0
- package/lib/components/AppContainer/api-proxy/core.js +290 -0
- package/lib/components/AppContainer/dayjsPlugins.d.ts +1 -0
- package/lib/components/AppContainer/dayjsPlugins.js +69 -0
- package/lib/components/AppContainer/index.d.ts +7 -0
- package/lib/components/AppContainer/index.js +65 -0
- package/lib/components/AppContainer/sonner.css +101 -0
- package/lib/components/AppContainer/sonner.d.ts +8 -0
- package/lib/components/AppContainer/sonner.js +26 -0
- package/lib/components/AppContainer/utils/api-panel.d.ts +11 -0
- package/lib/components/AppContainer/utils/api-panel.js +21 -0
- package/lib/components/AppContainer/utils/childApi.d.ts +5 -0
- package/lib/components/AppContainer/utils/childApi.js +26 -0
- package/lib/components/AppContainer/utils/listenHot.d.ts +1 -0
- package/lib/components/AppContainer/utils/listenHot.js +43 -0
- package/lib/components/ErrorRender/index.d.ts +5 -0
- package/lib/components/ErrorRender/index.js +79 -0
- package/lib/components/NotFoundRender/index.d.ts +3 -0
- package/lib/components/NotFoundRender/index.js +59 -0
- package/lib/components/SidebarNav/DrawerNav.d.ts +3 -0
- package/lib/components/SidebarNav/DrawerNav.js +64 -0
- package/lib/components/SidebarNav/DropdownNav.d.ts +3 -0
- package/lib/components/SidebarNav/DropdownNav.js +40 -0
- package/lib/components/SidebarNav/Sidebar.d.ts +3 -0
- package/lib/components/SidebarNav/Sidebar.js +33 -0
- package/lib/components/SidebarNav/index.d.ts +5 -0
- package/lib/components/SidebarNav/index.js +61 -0
- package/lib/components/User/UserDisplay.d.ts +9 -0
- package/lib/components/User/UserDisplay.js +39 -0
- package/lib/components/User/UserProfile/UserProfile.css +34 -0
- package/lib/components/User/UserProfile/UserProfile.d.ts +6 -0
- package/lib/components/User/UserProfile/UserProfile.js +41 -0
- package/lib/components/User/UserProfile/UserProfileContainer.d.ts +4 -0
- package/lib/components/User/UserProfile/UserProfileContainer.js +8 -0
- package/lib/components/User/UserProfile/UserProfileSkeleton.d.ts +3 -0
- package/lib/components/User/UserProfile/UserProfileSkeleton.js +36 -0
- package/lib/components/User/UserProfile/UserProfileUI.d.ts +8 -0
- package/lib/components/User/UserProfile/UserProfileUI.js +113 -0
- package/lib/components/User/UserProfile/index.d.ts +1 -0
- package/lib/components/User/UserProfile/index.js +2 -0
- package/lib/components/User/UserProfile/type.d.ts +8 -0
- package/lib/components/User/UserProfile/type.js +0 -0
- package/lib/components/User/UserProfile/utils.d.ts +5 -0
- package/lib/components/User/UserProfile/utils.js +26 -0
- package/lib/components/User/UserSelect.css +11 -0
- package/lib/components/User/UserSelect.d.ts +11 -0
- package/lib/components/User/UserSelect.js +172 -0
- package/lib/components/User/UserWithAvatar.d.ts +3 -0
- package/lib/components/User/UserWithAvatar.js +41 -0
- package/lib/components/User/index.d.ts +7 -0
- package/lib/components/User/index.js +5 -0
- package/lib/components/User/type.d.ts +13 -0
- package/lib/components/User/type.js +0 -0
- package/lib/components/Welcome/index.d.ts +3 -0
- package/lib/components/Welcome/index.js +17 -0
- package/lib/components/common/LogoInfo.d.ts +5 -0
- package/lib/components/common/LogoInfo.js +30 -0
- package/lib/components/common/NavItem.d.ts +20 -0
- package/lib/components/common/NavItem.js +112 -0
- package/lib/components/common/NavMenu.d.ts +9 -0
- package/lib/components/common/NavMenu.js +50 -0
- package/lib/components/common/UserAvatarLayout.d.ts +4 -0
- package/lib/components/common/UserAvatarLayout.js +41 -0
- package/lib/components/common/UserAvatarMenu.d.ts +4 -0
- package/lib/components/common/UserAvatarMenu.js +58 -0
- package/lib/components/common/index.d.ts +9 -0
- package/lib/components/common/index.js +10 -0
- package/lib/components/index.d.ts +8 -0
- package/lib/components/index.js +6 -0
- package/lib/components/theme/ThemeProvider.d.ts +20 -0
- package/lib/components/theme/ThemeProvider.js +75 -0
- package/lib/components/theme/constants.d.ts +48 -0
- package/lib/components/theme/constants.js +557 -0
- package/lib/components/theme/index.d.ts +4 -0
- package/lib/components/theme/index.js +5 -0
- package/lib/components/theme/miaoDarkTheme.d.ts +2 -0
- package/lib/components/theme/miaoDarkTheme.js +310 -0
- package/lib/components/theme/miaoLightTheme.d.ts +2 -0
- package/lib/components/theme/miaoLightTheme.js +296 -0
- package/lib/components/theme/ui-config.d.ts +1 -0
- package/lib/components/theme/ui-config.js +2 -0
- package/lib/components/theme/util.d.ts +20 -0
- package/lib/components/theme/util.js +188 -0
- package/lib/font-family.css +40 -0
- package/lib/hooks/index.d.ts +5 -0
- package/lib/hooks/index.js +5 -0
- package/lib/hooks/useAppInfo.d.ts +6 -0
- package/lib/hooks/useAppInfo.js +21 -0
- package/lib/hooks/useCurrentUserProfile.d.ts +12 -0
- package/lib/hooks/useCurrentUserProfile.js +58 -0
- package/lib/hooks/useIsMobile.d.ts +1 -0
- package/lib/hooks/useIsMobile.js +20 -0
- package/lib/hooks/useLogout.d.ts +4 -0
- package/lib/hooks/useLogout.js +37 -0
- package/lib/hooks/useTheme.d.ts +4 -0
- package/lib/hooks/useTheme.js +8 -0
- package/lib/hooks/useUpdatingRef.d.ts +1 -0
- package/lib/hooks/useUpdatingRef.js +7 -0
- package/lib/index.css +5 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +5 -0
- package/lib/inspector.dev.css +10 -0
- package/lib/integrations/dataloom.d.ts +2 -0
- package/lib/integrations/dataloom.js +32 -0
- package/lib/integrations/generateImage.d.ts +1 -0
- package/lib/integrations/generateImage.js +47 -0
- package/lib/integrations/generateTextStream.d.ts +21 -0
- package/lib/integrations/generateTextStream.js +98 -0
- package/lib/integrations/getAppInfo.d.ts +2 -0
- package/lib/integrations/getAppInfo.js +14 -0
- package/lib/integrations/getCurrentUserProfile.d.ts +6 -0
- package/lib/integrations/getCurrentUserProfile.js +5 -0
- package/lib/logger/index.d.ts +6 -0
- package/lib/logger/index.js +54 -0
- package/lib/override.css +29 -0
- package/lib/tailwind-theme.css +335 -0
- package/lib/theme-layer.css +3 -0
- package/lib/types/common.d.ts +4 -0
- package/lib/types/common.js +0 -0
- package/lib/types/iframe-events.d.ts +55 -0
- package/lib/types/iframe-events.js +0 -0
- package/lib/types/index.d.ts +43 -0
- package/lib/types/index.js +0 -0
- package/lib/utils/copyToClipboard.d.ts +6 -0
- package/lib/utils/copyToClipboard.js +32 -0
- package/lib/utils/getAppId.d.ts +6 -0
- package/lib/utils/getAppId.js +11 -0
- package/lib/utils/getCsrfToken.d.ts +5 -0
- package/lib/utils/getCsrfToken.js +10 -0
- package/lib/utils/getEnvPath.d.ts +4 -0
- package/lib/utils/getEnvPath.js +4 -0
- package/lib/utils/getInitialInfo.d.ts +20 -0
- package/lib/utils/getInitialInfo.js +32 -0
- package/lib/utils/getParentOrigin.d.ts +5 -0
- package/lib/utils/getParentOrigin.js +7 -0
- package/lib/utils/getUserProfile.d.ts +47 -0
- package/lib/utils/getUserProfile.js +39 -0
- package/lib/utils/postMessage.d.ts +8 -0
- package/lib/utils/postMessage.js +11 -0
- package/lib/utils/url.d.ts +8 -0
- package/lib/utils/url.js +22 -0
- package/lib/utils/utils.d.ts +20 -0
- package/lib/utils/utils.js +22 -0
- package/package.json +134 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
2
|
+
import "react";
|
3
|
+
import { clsxWithTw } from "../../utils/utils.js";
|
4
|
+
import { LogoInfo, NavMenu, TopHeaderThemeClass, UserAvatarLayout } from "../common/index.js";
|
5
|
+
function SidebarNav({ activeClassName, className, navList }) {
|
6
|
+
return /*#__PURE__*/ jsx("div", {
|
7
|
+
className: clsxWithTw('h-full overflow-y-auto scrollbar-none w-[260px] dark:border-gray-800', className),
|
8
|
+
children: /*#__PURE__*/ jsxs("div", {
|
9
|
+
className: clsxWithTw('fixed top-0 bottom-0 left-0 w-[260px] flex flex-col border-r', TopHeaderThemeClass, className),
|
10
|
+
children: [
|
11
|
+
/*#__PURE__*/ jsx("div", {
|
12
|
+
className: "w-full px-2 pt-2 h-12 mb-3",
|
13
|
+
children: /*#__PURE__*/ jsx(LogoInfo, {
|
14
|
+
className: "px-2 pt-[9px] pb-[15px]"
|
15
|
+
})
|
16
|
+
}),
|
17
|
+
/*#__PURE__*/ jsx("div", {
|
18
|
+
className: "flex-1 overflow-auto min-h-0",
|
19
|
+
children: /*#__PURE__*/ jsx(NavMenu, {
|
20
|
+
navList: navList,
|
21
|
+
className: clsxWithTw('border-0', className),
|
22
|
+
activeClassName: activeClassName,
|
23
|
+
mode: "vertical"
|
24
|
+
})
|
25
|
+
}),
|
26
|
+
/*#__PURE__*/ jsx(UserAvatarLayout, {
|
27
|
+
className: "mt-2"
|
28
|
+
})
|
29
|
+
]
|
30
|
+
})
|
31
|
+
});
|
32
|
+
}
|
33
|
+
export { SidebarNav as default };
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
2
|
+
import { useEffect, useMemo } from "react";
|
3
|
+
import { useIsMobile } from "../../hooks/useIsMobile.js";
|
4
|
+
import { useLocation } from "react-router-dom";
|
5
|
+
import DrawerNav from "./DrawerNav.js";
|
6
|
+
import Sidebar from "./Sidebar.js";
|
7
|
+
import DropdownNav from "./DropdownNav.js";
|
8
|
+
import { ConfigProvider } from "antd";
|
9
|
+
import { generateDarkTheme, generateLightTheme } from "../theme/util.js";
|
10
|
+
import { useTheme } from "../../hooks/useTheme.js";
|
11
|
+
function SideNavigationBar({ navList = [], className, activeClassName, mobileVariant = 'normal' }) {
|
12
|
+
const isMobile = useIsMobile();
|
13
|
+
const location = useLocation();
|
14
|
+
useEffect(()=>{
|
15
|
+
window.scrollTo(0, 0);
|
16
|
+
}, [
|
17
|
+
location.pathname
|
18
|
+
]);
|
19
|
+
if (isMobile) {
|
20
|
+
if ('dropdown' === mobileVariant) return /*#__PURE__*/ jsx(DropdownNav, {
|
21
|
+
navList: navList,
|
22
|
+
className: className,
|
23
|
+
activeClassName: activeClassName
|
24
|
+
});
|
25
|
+
return /*#__PURE__*/ jsx(DrawerNav, {
|
26
|
+
navList: navList,
|
27
|
+
className: className,
|
28
|
+
activeClassName: activeClassName
|
29
|
+
});
|
30
|
+
}
|
31
|
+
return /*#__PURE__*/ jsx(Sidebar, {
|
32
|
+
navList: navList,
|
33
|
+
className: className,
|
34
|
+
activeClassName: activeClassName
|
35
|
+
});
|
36
|
+
}
|
37
|
+
function SideNavigation(props) {
|
38
|
+
const { theme } = useTheme();
|
39
|
+
const { darkColorPrimary, lightColorPrimary } = props;
|
40
|
+
const themeToken = useMemo(()=>{
|
41
|
+
if ('dark' === theme && darkColorPrimary) return generateDarkTheme({
|
42
|
+
colorPrimary: darkColorPrimary
|
43
|
+
});
|
44
|
+
if ('light' === theme && lightColorPrimary) return generateLightTheme({
|
45
|
+
colorPrimary: lightColorPrimary
|
46
|
+
});
|
47
|
+
return {};
|
48
|
+
}, [
|
49
|
+
theme,
|
50
|
+
darkColorPrimary,
|
51
|
+
lightColorPrimary
|
52
|
+
]);
|
53
|
+
return /*#__PURE__*/ jsx(ConfigProvider, {
|
54
|
+
theme: themeToken,
|
55
|
+
children: /*#__PURE__*/ jsx(SideNavigationBar, {
|
56
|
+
...props
|
57
|
+
})
|
58
|
+
});
|
59
|
+
}
|
60
|
+
const SidebarNav = SideNavigation;
|
61
|
+
export { SideNavigation, SideNavigation as SidebarNav, SidebarNav as default };
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import type { IUserProfile } from '../../apis/udt-types';
|
3
|
+
export interface UserDisplayProps {
|
4
|
+
users: IUserProfile[];
|
5
|
+
size?: 'small' | 'medium' | 'large';
|
6
|
+
className?: string;
|
7
|
+
style?: React.CSSProperties;
|
8
|
+
}
|
9
|
+
export declare const UserDisplay: React.FC<UserDisplayProps>;
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
2
|
+
import react from "react";
|
3
|
+
import { Popover } from "antd";
|
4
|
+
import { UserWithAvatar } from "./UserWithAvatar.js";
|
5
|
+
import { clsxWithTw } from "../../utils/utils.js";
|
6
|
+
import { UserProfile } from "./UserProfile/index.js";
|
7
|
+
const UserDisplay = ({ users, size, className, style })=>{
|
8
|
+
const displayUsers = react.useMemo(()=>Array.isArray(users) ? users : [
|
9
|
+
users
|
10
|
+
].filter(Boolean), [
|
11
|
+
users
|
12
|
+
]);
|
13
|
+
if (!displayUsers.length) return null;
|
14
|
+
return /*#__PURE__*/ jsx("div", {
|
15
|
+
className: clsxWithTw('flex gap-1 flex-wrap', className),
|
16
|
+
style: style,
|
17
|
+
children: displayUsers.map((user)=>/*#__PURE__*/ jsx(Popover, {
|
18
|
+
placement: "bottomLeft",
|
19
|
+
trigger: "click",
|
20
|
+
content: /*#__PURE__*/ jsx(UserProfile, {
|
21
|
+
user_id: user.user_id
|
22
|
+
}),
|
23
|
+
arrow: false,
|
24
|
+
styles: {
|
25
|
+
body: {
|
26
|
+
padding: 0
|
27
|
+
}
|
28
|
+
},
|
29
|
+
children: /*#__PURE__*/ jsx("div", {
|
30
|
+
children: /*#__PURE__*/ jsx(UserWithAvatar, {
|
31
|
+
data: user,
|
32
|
+
size: size,
|
33
|
+
className: "cursor-pointer hover:bg-[rgba(31,35,41,0.15)] active:bg-[rgba(31,35,41,0.2)]"
|
34
|
+
})
|
35
|
+
})
|
36
|
+
}, user.user_id))
|
37
|
+
});
|
38
|
+
};
|
39
|
+
export { UserDisplay };
|
@@ -0,0 +1,34 @@
|
|
1
|
+
.user-profile-skeleton-lines .ant-skeleton-paragraph > li {
|
2
|
+
border-radius: 100px;
|
3
|
+
height: 16px;
|
4
|
+
}
|
5
|
+
|
6
|
+
.user-profile-button .ant-btn-icon {
|
7
|
+
height: 18px;
|
8
|
+
}
|
9
|
+
|
10
|
+
.no-scrollbar {
|
11
|
+
scrollbar-width: none;
|
12
|
+
}
|
13
|
+
|
14
|
+
.no-scrollbar::-webkit-scrollbar {
|
15
|
+
display: none;
|
16
|
+
}
|
17
|
+
|
18
|
+
.user-profile-avatar {
|
19
|
+
box-shadow: 0 6px 18px 6px #1f232908, 0 3px 6px -6px #1f23290d, 0 4px 8px #1f232908;
|
20
|
+
}
|
21
|
+
|
22
|
+
.user-profile-name-container {
|
23
|
+
margin-top: 10px;
|
24
|
+
padding-bottom: 4px;
|
25
|
+
}
|
26
|
+
|
27
|
+
.user-profile-name {
|
28
|
+
color: #1f2937;
|
29
|
+
margin-bottom: 0;
|
30
|
+
font-size: 22px;
|
31
|
+
font-weight: 600;
|
32
|
+
line-height: 28px;
|
33
|
+
}
|
34
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
2
|
+
import { useEffect, useState } from "react";
|
3
|
+
import { UserProfileUI } from "./UserProfileUI.js";
|
4
|
+
import { UserProfileSkeleton } from "./UserProfileSkeleton.js";
|
5
|
+
import { getUserProfile } from "../../../utils/getUserProfile.js";
|
6
|
+
import { INVALID_USER, formatI18nProfile } from "./utils.js";
|
7
|
+
import { UserProfileContainer } from "./UserProfileContainer.js";
|
8
|
+
import { logger } from "../../../logger/index.js";
|
9
|
+
function UserProfile(props) {
|
10
|
+
const { user_id } = props;
|
11
|
+
const [user, setUser] = useState(null);
|
12
|
+
const [loading, setLoading] = useState(true);
|
13
|
+
useEffect(()=>{
|
14
|
+
const fetchUser = async ()=>{
|
15
|
+
setLoading(true);
|
16
|
+
try {
|
17
|
+
const { data } = await getUserProfile({
|
18
|
+
userID: user_id
|
19
|
+
});
|
20
|
+
if (data.userProfile) {
|
21
|
+
const profile = data.userProfile;
|
22
|
+
setUser(formatI18nProfile(profile));
|
23
|
+
} else setUser(INVALID_USER);
|
24
|
+
} catch (error) {
|
25
|
+
setUser(INVALID_USER);
|
26
|
+
logger.error('Failed to fetch user profile:', error);
|
27
|
+
} finally{
|
28
|
+
setLoading(false);
|
29
|
+
}
|
30
|
+
};
|
31
|
+
fetchUser();
|
32
|
+
}, [
|
33
|
+
user_id
|
34
|
+
]);
|
35
|
+
return /*#__PURE__*/ jsx(UserProfileContainer, {
|
36
|
+
children: loading || !user ? /*#__PURE__*/ jsx(UserProfileSkeleton, {}) : /*#__PURE__*/ jsx(UserProfileUI, {
|
37
|
+
user: user
|
38
|
+
})
|
39
|
+
});
|
40
|
+
}
|
41
|
+
export { UserProfile };
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
2
|
+
import "react";
|
3
|
+
import "./UserProfile.css";
|
4
|
+
const UserProfileContainer = ({ children })=>/*#__PURE__*/ jsx("div", {
|
5
|
+
className: "w-[320px] h-[468px] rounded-[8px] overflow-y-auto no-scrollbar",
|
6
|
+
children: children
|
7
|
+
});
|
8
|
+
export { UserProfileContainer };
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
2
|
+
import "react";
|
3
|
+
import { Skeleton } from "antd";
|
4
|
+
import "./UserProfile.css";
|
5
|
+
function UserProfileSkeleton() {
|
6
|
+
return /*#__PURE__*/ jsxs("div", {
|
7
|
+
className: "p-5 bg-white",
|
8
|
+
children: [
|
9
|
+
/*#__PURE__*/ jsx(Skeleton, {
|
10
|
+
loading: true,
|
11
|
+
avatar: {
|
12
|
+
size: 90,
|
13
|
+
shape: 'circle'
|
14
|
+
},
|
15
|
+
active: true,
|
16
|
+
paragraph: false,
|
17
|
+
round: true,
|
18
|
+
title: false,
|
19
|
+
className: "mt-[68px]"
|
20
|
+
}),
|
21
|
+
/*#__PURE__*/ jsx(Skeleton, {
|
22
|
+
loading: true,
|
23
|
+
title: false,
|
24
|
+
paragraph: {
|
25
|
+
rows: 2,
|
26
|
+
width: [
|
27
|
+
'120px',
|
28
|
+
'180px'
|
29
|
+
]
|
30
|
+
},
|
31
|
+
className: "mt-[22px] user-profile-skeleton-lines"
|
32
|
+
})
|
33
|
+
]
|
34
|
+
});
|
35
|
+
}
|
36
|
+
export { UserProfileSkeleton };
|
@@ -0,0 +1,113 @@
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
2
|
+
import "react";
|
3
|
+
import { Avatar, Button, Card, Tag, Typography } from "antd";
|
4
|
+
import "./UserProfile.css";
|
5
|
+
import { getChatAppLink } from "./utils.js";
|
6
|
+
import { clsxWithTw } from "../../../utils/utils.js";
|
7
|
+
function UserProfileUI({ user }) {
|
8
|
+
return /*#__PURE__*/ jsxs(Card, {
|
9
|
+
className: "border-0",
|
10
|
+
cover: /*#__PURE__*/ jsx("img", {
|
11
|
+
alt: "cover",
|
12
|
+
src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miao/default-cover.png",
|
13
|
+
className: "h-[136px] w-full object-cover"
|
14
|
+
}),
|
15
|
+
bodyStyle: {
|
16
|
+
padding: '16px'
|
17
|
+
},
|
18
|
+
children: [
|
19
|
+
/*#__PURE__*/ jsxs("div", {
|
20
|
+
className: "relative flex flex-col -mt-16 user-profile-button",
|
21
|
+
children: [
|
22
|
+
/*#__PURE__*/ jsx(Avatar, {
|
23
|
+
size: 96,
|
24
|
+
src: user.avatar,
|
25
|
+
className: "border-4 border-white -mx-1 user-profile-avatar"
|
26
|
+
}),
|
27
|
+
/*#__PURE__*/ jsxs("div", {
|
28
|
+
className: "flex gap-1 items-center user-profile-name-container",
|
29
|
+
children: [
|
30
|
+
/*#__PURE__*/ jsx(Typography.Title, {
|
31
|
+
level: 2,
|
32
|
+
ellipsis: {
|
33
|
+
rows: 1,
|
34
|
+
tooltip: user.name
|
35
|
+
},
|
36
|
+
className: "user-profile-name",
|
37
|
+
children: user.name
|
38
|
+
}),
|
39
|
+
'inactive' === user.status && /*#__PURE__*/ jsx(Tag, {
|
40
|
+
color: "#f50",
|
41
|
+
style: {
|
42
|
+
marginRight: 0
|
43
|
+
},
|
44
|
+
children: "暂停使用"
|
45
|
+
})
|
46
|
+
]
|
47
|
+
}),
|
48
|
+
user.feishu_open_id ? /*#__PURE__*/ jsx("div", {
|
49
|
+
className: "w-ful mt-2",
|
50
|
+
children: /*#__PURE__*/ jsx(Button, {
|
51
|
+
type: "primary",
|
52
|
+
icon: /*#__PURE__*/ jsx("svg", {
|
53
|
+
width: "24",
|
54
|
+
height: "24",
|
55
|
+
viewBox: "0 0 24 24",
|
56
|
+
fill: "none",
|
57
|
+
xmlns: "http://www.w3.org/2000/svg",
|
58
|
+
className: "w-[18px] h-[18px]",
|
59
|
+
children: /*#__PURE__*/ jsx("path", {
|
60
|
+
d: "M4.44576 19.2236L3.39131 20.7324C2.86623 21.4838 3.41996 22.5 4.35448 22.5H11.7556C11.7556 22.5 11.7593 22.4996 11.7661 22.4995C11.8225 22.4984 12.094 22.4991 12.2975 22.4996L12.5 22.5C12.9236 22.5 13.3414 22.4749 13.7519 22.4261L13.7544 22.4258C18.962 21.8059 23 17.3745 23 12C23 10.567 22.5218 8.58544 22.5 8.52497C21.8654 6.76558 20.7624 5.22024 19.3364 4.03023C17.4995 2.45304 15.111 1.5 12.5 1.5C12.4676 1.5 12.4352 1.50015 12.4028 1.50044C12.3695 1.50015 12.3362 1.5 12.3028 1.5C6.33659 1.5 1.5 6.20101 1.5 12C1.5 12.197 1.50558 12.3928 1.5166 12.5871C1.65458 15.1526 2.74286 17.4735 4.44576 19.2236ZM17 10C17 10.5 16.6133 11 16 11H9.01953C8.39798 11 8 10.5 8 10C8 9.39844 8.5 9 9 9H16C16.5 9 17 9.39844 17 10ZM12.9883 13C13.6055 13 14 13.5 14 14C14 14.5 13.6055 15 13 15H9C8.5 15 8 14.6018 8 14C8 13.3982 8.5 13 9 13H12.9883Z",
|
61
|
+
fill: "#2B2F36"
|
62
|
+
})
|
63
|
+
}),
|
64
|
+
className: "gap-1 rounded-[10px] h-[42px] w-full bg-[#F5F6F7] text-[#2B2F36] hover:bg-[rgba(31,35,41,0.08)] active:bg-[rgba(31,35,41,0.12)] border-none",
|
65
|
+
href: getChatAppLink(user.feishu_open_id),
|
66
|
+
target: "_blank",
|
67
|
+
rel: "noopener noreferrer",
|
68
|
+
children: "消息"
|
69
|
+
})
|
70
|
+
}) : null
|
71
|
+
]
|
72
|
+
}),
|
73
|
+
/*#__PURE__*/ jsxs("div", {
|
74
|
+
className: "mt-2",
|
75
|
+
children: [
|
76
|
+
/*#__PURE__*/ jsxs("div", {
|
77
|
+
className: "flex py-2 gap-4",
|
78
|
+
children: [
|
79
|
+
/*#__PURE__*/ jsx("span", {
|
80
|
+
className: "text-sm text-[#646A73] min-w-[74px]",
|
81
|
+
children: "部门"
|
82
|
+
}),
|
83
|
+
/*#__PURE__*/ jsx("span", {
|
84
|
+
className: clsxWithTw('text-sm text-[#1F2329] flex-1 break-all', {
|
85
|
+
'text-[#8F959E]': !user.department
|
86
|
+
}),
|
87
|
+
children: user.department || '--'
|
88
|
+
})
|
89
|
+
]
|
90
|
+
}),
|
91
|
+
/*#__PURE__*/ jsxs("div", {
|
92
|
+
className: "flex py-2 gap-4",
|
93
|
+
children: [
|
94
|
+
/*#__PURE__*/ jsx("span", {
|
95
|
+
className: "text-sm text-[#646A73] min-w-[74px]",
|
96
|
+
children: "邮箱"
|
97
|
+
}),
|
98
|
+
user.email ? /*#__PURE__*/ jsx("a", {
|
99
|
+
href: `mailto:${user.email}`,
|
100
|
+
className: "text-sm text-blue-500 flex-1 break-all",
|
101
|
+
children: user.email
|
102
|
+
}) : /*#__PURE__*/ jsx("span", {
|
103
|
+
className: "text-sm text-[#8F959E] flex-1 break-all",
|
104
|
+
children: "--"
|
105
|
+
})
|
106
|
+
]
|
107
|
+
})
|
108
|
+
]
|
109
|
+
})
|
110
|
+
]
|
111
|
+
});
|
112
|
+
}
|
113
|
+
export { UserProfileUI };
|
@@ -0,0 +1 @@
|
|
1
|
+
export { UserProfile } from './UserProfile';
|
File without changes
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { UserProfile } from '../../../utils/getUserProfile';
|
2
|
+
import { User } from './type';
|
3
|
+
export declare const formatI18nProfile: (profile: UserProfile) => User;
|
4
|
+
export declare const getChatAppLink: (openId: string) => string;
|
5
|
+
export declare const INVALID_USER: User;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
const convertI18nTextToText = (i18nText)=>{
|
2
|
+
if (Array.isArray(i18nText) && i18nText.length > 0) {
|
3
|
+
const chineseText = i18nText.find((value)=>2052 === value.language_code);
|
4
|
+
if (chineseText) return chineseText.text;
|
5
|
+
return i18nText[0].text;
|
6
|
+
}
|
7
|
+
return '';
|
8
|
+
};
|
9
|
+
const formatI18nProfile = (profile)=>({
|
10
|
+
name: convertI18nTextToText(profile.name),
|
11
|
+
avatar: profile.avatar || '',
|
12
|
+
email: profile.email || '',
|
13
|
+
department: convertI18nTextToText(profile.departmentName),
|
14
|
+
feishu_open_id: profile.feishuOpenID || '',
|
15
|
+
status: 1 === profile.status ? 'active' : 'inactive'
|
16
|
+
});
|
17
|
+
const getChatAppLink = (openId)=>`https://applink.feishu.cn/client/chat/open?openId=${openId}`;
|
18
|
+
const INVALID_USER = {
|
19
|
+
name: '无效人员',
|
20
|
+
avatar: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miao/no-person.svg',
|
21
|
+
email: '',
|
22
|
+
department: '',
|
23
|
+
feishu_open_id: '',
|
24
|
+
status: 'active'
|
25
|
+
};
|
26
|
+
export { INVALID_USER, formatI18nProfile, getChatAppLink };
|
@@ -0,0 +1,11 @@
|
|
1
|
+
.user-select-container .ant-select-selection-item {
|
2
|
+
height: unset !important;
|
3
|
+
border-radius: 50px !important;
|
4
|
+
padding: 1px 8px 1px 1px !important;
|
5
|
+
}
|
6
|
+
|
7
|
+
.user-select-container .ant-select-focused .ant-select-selector {
|
8
|
+
box-shadow: none !important;
|
9
|
+
border-color: #1456f0 !important;
|
10
|
+
}
|
11
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import type { IUserProfile } from '../../apis/udt-types';
|
3
|
+
import './UserSelect.css';
|
4
|
+
export interface UserSelectProps {
|
5
|
+
value?: IUserProfile | IUserProfile[];
|
6
|
+
onChange?: (value: IUserProfile | IUserProfile[]) => void;
|
7
|
+
defaultValue?: IUserProfile | IUserProfile[];
|
8
|
+
mode?: 'single' | 'multiple';
|
9
|
+
placeholder?: string;
|
10
|
+
}
|
11
|
+
export declare const UserSelect: React.FC<UserSelectProps>;
|
@@ -0,0 +1,172 @@
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
2
|
+
import { useMemo, useRef, useState } from "react";
|
3
|
+
import { Avatar, Select, Spin } from "antd";
|
4
|
+
import { LoaderCircle } from "lucide-react";
|
5
|
+
import { debounce } from "lodash";
|
6
|
+
import { getDataloom } from "../../integrations/dataloom.js";
|
7
|
+
import "./UserSelect.css";
|
8
|
+
import { UserWithAvatar } from "./UserWithAvatar.js";
|
9
|
+
const mapValueToOptions = (value)=>{
|
10
|
+
if (!value) return [];
|
11
|
+
const unifiedValue = Array.isArray(value) ? value : [
|
12
|
+
value
|
13
|
+
];
|
14
|
+
return unifiedValue.map((user)=>({
|
15
|
+
value: user.user_id,
|
16
|
+
label: /*#__PURE__*/ jsx(UserWithAvatar, {
|
17
|
+
data: user,
|
18
|
+
mode: "plain",
|
19
|
+
className: "p-[1px] pr-0"
|
20
|
+
}),
|
21
|
+
avatar: user.avatar,
|
22
|
+
name: user.name,
|
23
|
+
rawValue: user
|
24
|
+
}));
|
25
|
+
};
|
26
|
+
const mapValueToSelectValue = (value)=>{
|
27
|
+
if (!value) return;
|
28
|
+
if (Array.isArray(value)) return value.map((user)=>({
|
29
|
+
value: user.user_id,
|
30
|
+
label: /*#__PURE__*/ jsx(UserWithAvatar, {
|
31
|
+
data: user,
|
32
|
+
mode: "plain",
|
33
|
+
className: "p-[1px] pr-0"
|
34
|
+
}),
|
35
|
+
avatar: user.avatar,
|
36
|
+
name: user.name,
|
37
|
+
rawValue: user
|
38
|
+
}));
|
39
|
+
return {
|
40
|
+
value: value.user_id,
|
41
|
+
label: /*#__PURE__*/ jsx(UserWithAvatar, {
|
42
|
+
data: value,
|
43
|
+
mode: "plain",
|
44
|
+
className: "p-[1px] pr-0"
|
45
|
+
}),
|
46
|
+
avatar: value.avatar,
|
47
|
+
name: value.name,
|
48
|
+
rawValue: value
|
49
|
+
};
|
50
|
+
};
|
51
|
+
const UserSelect = ({ mode = 'single', defaultValue, value, onChange, placeholder })=>{
|
52
|
+
const defaultOptions = useMemo(()=>mapValueToOptions(defaultValue), [
|
53
|
+
defaultValue
|
54
|
+
]);
|
55
|
+
const [options, setOptions] = useState(defaultOptions);
|
56
|
+
const [fetching, setFetching] = useState(false);
|
57
|
+
const fetchRef = useRef(0);
|
58
|
+
const fetchUsers = async (search)=>{
|
59
|
+
try {
|
60
|
+
const dataloom = await getDataloom();
|
61
|
+
const { data } = await dataloom.service.user.search({
|
62
|
+
name: search,
|
63
|
+
pageSize: 20
|
64
|
+
});
|
65
|
+
if (!data || !Array.isArray(data.user_list)) return [];
|
66
|
+
return data.user_list.map((user)=>({
|
67
|
+
avatar: user.avatar,
|
68
|
+
email: user.email,
|
69
|
+
name: user.name,
|
70
|
+
user_id: user.user_id,
|
71
|
+
status: user.status
|
72
|
+
}));
|
73
|
+
} catch (error) {
|
74
|
+
console.error('Failed to fetch users:', error);
|
75
|
+
return [];
|
76
|
+
}
|
77
|
+
};
|
78
|
+
const debounceFetcher = useMemo(()=>{
|
79
|
+
const loadOptions = (value)=>{
|
80
|
+
if (!value) return;
|
81
|
+
fetchRef.current += 1;
|
82
|
+
const fetchId = fetchRef.current;
|
83
|
+
setOptions([]);
|
84
|
+
setFetching(true);
|
85
|
+
fetchUsers(value).then((newOptions)=>{
|
86
|
+
if (fetchId !== fetchRef.current) return;
|
87
|
+
setOptions(newOptions.map((v)=>({
|
88
|
+
value: v.user_id,
|
89
|
+
label: /*#__PURE__*/ jsx(UserWithAvatar, {
|
90
|
+
data: v,
|
91
|
+
mode: "plain",
|
92
|
+
className: "p-[1px] pr-0"
|
93
|
+
}),
|
94
|
+
avatar: v.avatar,
|
95
|
+
name: v.name,
|
96
|
+
rawValue: v
|
97
|
+
})));
|
98
|
+
setFetching(false);
|
99
|
+
});
|
100
|
+
};
|
101
|
+
return debounce(loadOptions, 500);
|
102
|
+
}, []);
|
103
|
+
const optionRender = (option)=>{
|
104
|
+
const user = option.data;
|
105
|
+
return /*#__PURE__*/ jsxs("div", {
|
106
|
+
className: "flex items-center gap-2",
|
107
|
+
children: [
|
108
|
+
/*#__PURE__*/ jsx(Avatar, {
|
109
|
+
src: user.avatar,
|
110
|
+
size: "small",
|
111
|
+
className: "shrink-0 !border-0"
|
112
|
+
}),
|
113
|
+
/*#__PURE__*/ jsx("span", {
|
114
|
+
className: "text-sm",
|
115
|
+
children: user.name
|
116
|
+
})
|
117
|
+
]
|
118
|
+
});
|
119
|
+
};
|
120
|
+
const selectMode = 'multiple' === mode ? 'multiple' : void 0;
|
121
|
+
return /*#__PURE__*/ jsx("div", {
|
122
|
+
className: "user-select-container",
|
123
|
+
children: /*#__PURE__*/ jsx(Select, {
|
124
|
+
labelInValue: true,
|
125
|
+
showSearch: true,
|
126
|
+
className: "w-full",
|
127
|
+
maxTagCount: "responsive",
|
128
|
+
defaultValue: defaultOptions,
|
129
|
+
mode: selectMode,
|
130
|
+
filterOption: false,
|
131
|
+
onSearch: debounceFetcher,
|
132
|
+
allowClear: true,
|
133
|
+
placeholder: placeholder,
|
134
|
+
notFoundContent: fetching ? /*#__PURE__*/ jsx("div", {
|
135
|
+
className: "flex items-center justify-center",
|
136
|
+
children: /*#__PURE__*/ jsx(Spin, {
|
137
|
+
size: "small",
|
138
|
+
indicator: /*#__PURE__*/ jsx(LoaderCircle, {
|
139
|
+
className: "!text-[16px] animate-spin"
|
140
|
+
})
|
141
|
+
})
|
142
|
+
}) : /*#__PURE__*/ jsx("span", {
|
143
|
+
className: "py-[1px] px-1 text-[#8F959E]",
|
144
|
+
children: "无结果,建议更换搜索词"
|
145
|
+
}),
|
146
|
+
optionRender: optionRender,
|
147
|
+
options: options,
|
148
|
+
dropdownStyle: {
|
149
|
+
boxShadow: '0px 8px 24px 8px rgba(31, 35, 41, 0.04), 0px 6px 12px 0px rgba(31, 35, 41, 0.04), 0px 4px 8px -8px rgba(31, 35, 41, 0.06)',
|
150
|
+
padding: '3px'
|
151
|
+
},
|
152
|
+
value: mapValueToSelectValue(value),
|
153
|
+
maxTagPlaceholder: (omittedValues)=>/*#__PURE__*/ jsxs("span", {
|
154
|
+
className: "pl-2",
|
155
|
+
children: [
|
156
|
+
"+ ",
|
157
|
+
omittedValues.length
|
158
|
+
]
|
159
|
+
}),
|
160
|
+
onChange: onChange ? (_, options)=>{
|
161
|
+
if (Array.isArray(options)) {
|
162
|
+
const selectedUsers = options.map((opt)=>opt.rawValue);
|
163
|
+
onChange(selectedUsers);
|
164
|
+
} else {
|
165
|
+
const selectedUser = options?.rawValue;
|
166
|
+
if (selectedUser) onChange(selectedUser);
|
167
|
+
}
|
168
|
+
} : void 0
|
169
|
+
})
|
170
|
+
});
|
171
|
+
};
|
172
|
+
export { UserSelect };
|