@lark-apaas/miaoda-core 0.1.0-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.
Files changed (181) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +8 -0
  3. package/lib/apis/components/AppContainer.d.ts +1 -0
  4. package/lib/apis/components/AppContainer.js +2 -0
  5. package/lib/apis/components/ErrorRender.d.ts +1 -0
  6. package/lib/apis/components/ErrorRender.js +2 -0
  7. package/lib/apis/components/NotFoundRender.d.ts +1 -0
  8. package/lib/apis/components/NotFoundRender.js +2 -0
  9. package/lib/apis/components/SidebarNav.d.ts +1 -0
  10. package/lib/apis/components/SidebarNav.js +2 -0
  11. package/lib/apis/components/TopNav.d.ts +1 -0
  12. package/lib/apis/components/TopNav.js +2 -0
  13. package/lib/apis/components/User.d.ts +1 -0
  14. package/lib/apis/components/User.js +1 -0
  15. package/lib/apis/components/Welcome.d.ts +1 -0
  16. package/lib/apis/components/Welcome.js +2 -0
  17. package/lib/apis/constants/img-resources/avatar.d.ts +11 -0
  18. package/lib/apis/constants/img-resources/avatar.js +12 -0
  19. package/lib/apis/constants/img-resources/banner.d.ts +24 -0
  20. package/lib/apis/constants/img-resources/banner.js +25 -0
  21. package/lib/apis/constants/img-resources/cover.d.ts +36 -0
  22. package/lib/apis/constants/img-resources/cover.js +37 -0
  23. package/lib/apis/dataloom.d.ts +1 -0
  24. package/lib/apis/dataloom.js +2 -0
  25. package/lib/apis/hooks/useCurrentAppInfo.d.ts +1 -0
  26. package/lib/apis/hooks/useCurrentAppInfo.js +1 -0
  27. package/lib/apis/hooks/useCurrentUserProfile.d.ts +1 -0
  28. package/lib/apis/hooks/useCurrentUserProfile.js +1 -0
  29. package/lib/apis/logger.d.ts +1 -0
  30. package/lib/apis/logger.js +1 -0
  31. package/lib/apis/tools/generateImage.d.ts +1 -0
  32. package/lib/apis/tools/generateImage.js +1 -0
  33. package/lib/apis/tools/generateTextStream.d.ts +1 -0
  34. package/lib/apis/tools/generateTextStream.js +1 -0
  35. package/lib/apis/tools/getAppInfo.d.ts +1 -0
  36. package/lib/apis/tools/getAppInfo.js +1 -0
  37. package/lib/apis/tools/getCurrentUserProfile.d.ts +1 -0
  38. package/lib/apis/tools/getCurrentUserProfile.js +1 -0
  39. package/lib/apis/tools/storage.d.ts +1 -0
  40. package/lib/apis/tools/storage.js +4 -0
  41. package/lib/apis/udt-types.d.ts +16 -0
  42. package/lib/apis/udt-types.js +0 -0
  43. package/lib/apis/utils/registerChinaMap.d.ts +1 -0
  44. package/lib/apis/utils/registerChinaMap.js +103319 -0
  45. package/lib/components/AppContainer/IframeBridge.d.ts +2 -0
  46. package/lib/components/AppContainer/IframeBridge.js +80 -0
  47. package/lib/components/AppContainer/PageHoc.d.ts +4 -0
  48. package/lib/components/AppContainer/PageHoc.js +20 -0
  49. package/lib/components/AppContainer/dayjsPlugins.d.ts +1 -0
  50. package/lib/components/AppContainer/dayjsPlugins.js +69 -0
  51. package/lib/components/AppContainer/index.d.ts +7 -0
  52. package/lib/components/AppContainer/index.js +65 -0
  53. package/lib/components/AppContainer/sonner.css +101 -0
  54. package/lib/components/AppContainer/sonner.d.ts +8 -0
  55. package/lib/components/AppContainer/sonner.js +26 -0
  56. package/lib/components/ErrorRender/index.d.ts +5 -0
  57. package/lib/components/ErrorRender/index.js +79 -0
  58. package/lib/components/NotFoundRender/index.d.ts +3 -0
  59. package/lib/components/NotFoundRender/index.js +59 -0
  60. package/lib/components/SidebarNav/DrawerNav.d.ts +3 -0
  61. package/lib/components/SidebarNav/DrawerNav.js +64 -0
  62. package/lib/components/SidebarNav/DropdownNav.d.ts +3 -0
  63. package/lib/components/SidebarNav/DropdownNav.js +40 -0
  64. package/lib/components/SidebarNav/Sidebar.d.ts +3 -0
  65. package/lib/components/SidebarNav/Sidebar.js +33 -0
  66. package/lib/components/SidebarNav/index.d.ts +5 -0
  67. package/lib/components/SidebarNav/index.js +61 -0
  68. package/lib/components/TopNav/BottomNav.d.ts +12 -0
  69. package/lib/components/TopNav/BottomNav.js +81 -0
  70. package/lib/components/TopNav/TitleBar.d.ts +10 -0
  71. package/lib/components/TopNav/TitleBar.js +127 -0
  72. package/lib/components/TopNav/TopNav.d.ts +10 -0
  73. package/lib/components/TopNav/TopNav.js +86 -0
  74. package/lib/components/TopNav/index.d.ts +12 -0
  75. package/lib/components/TopNav/index.js +65 -0
  76. package/lib/components/User/UserDisplay.d.ts +9 -0
  77. package/lib/components/User/UserDisplay.js +39 -0
  78. package/lib/components/User/UserProfile/UserProfile.css +34 -0
  79. package/lib/components/User/UserProfile/UserProfile.d.ts +6 -0
  80. package/lib/components/User/UserProfile/UserProfile.js +41 -0
  81. package/lib/components/User/UserProfile/UserProfileContainer.d.ts +4 -0
  82. package/lib/components/User/UserProfile/UserProfileContainer.js +8 -0
  83. package/lib/components/User/UserProfile/UserProfileSkeleton.d.ts +3 -0
  84. package/lib/components/User/UserProfile/UserProfileSkeleton.js +36 -0
  85. package/lib/components/User/UserProfile/UserProfileUI.d.ts +8 -0
  86. package/lib/components/User/UserProfile/UserProfileUI.js +113 -0
  87. package/lib/components/User/UserProfile/index.d.ts +1 -0
  88. package/lib/components/User/UserProfile/index.js +2 -0
  89. package/lib/components/User/UserProfile/type.d.ts +8 -0
  90. package/lib/components/User/UserProfile/type.js +0 -0
  91. package/lib/components/User/UserProfile/utils.d.ts +5 -0
  92. package/lib/components/User/UserProfile/utils.js +26 -0
  93. package/lib/components/User/UserSelect.css +11 -0
  94. package/lib/components/User/UserSelect.d.ts +11 -0
  95. package/lib/components/User/UserSelect.js +171 -0
  96. package/lib/components/User/UserWithAvatar.d.ts +3 -0
  97. package/lib/components/User/UserWithAvatar.js +41 -0
  98. package/lib/components/User/index.d.ts +7 -0
  99. package/lib/components/User/index.js +5 -0
  100. package/lib/components/User/type.d.ts +13 -0
  101. package/lib/components/User/type.js +0 -0
  102. package/lib/components/Welcome/index.d.ts +3 -0
  103. package/lib/components/Welcome/index.js +33 -0
  104. package/lib/components/common/LogoInfo.d.ts +5 -0
  105. package/lib/components/common/LogoInfo.js +30 -0
  106. package/lib/components/common/NavItem.d.ts +20 -0
  107. package/lib/components/common/NavItem.js +112 -0
  108. package/lib/components/common/NavMenu.d.ts +9 -0
  109. package/lib/components/common/NavMenu.js +50 -0
  110. package/lib/components/common/UserAvatarLayout.d.ts +4 -0
  111. package/lib/components/common/UserAvatarLayout.js +41 -0
  112. package/lib/components/common/UserAvatarMenu.d.ts +4 -0
  113. package/lib/components/common/UserAvatarMenu.js +58 -0
  114. package/lib/components/common/index.d.ts +9 -0
  115. package/lib/components/common/index.js +10 -0
  116. package/lib/components/index.d.ts +9 -0
  117. package/lib/components/index.js +7 -0
  118. package/lib/components/theme/ThemeProvider.d.ts +20 -0
  119. package/lib/components/theme/ThemeProvider.js +75 -0
  120. package/lib/components/theme/constants.d.ts +48 -0
  121. package/lib/components/theme/constants.js +556 -0
  122. package/lib/components/theme/index.d.ts +4 -0
  123. package/lib/components/theme/index.js +5 -0
  124. package/lib/components/theme/miaoDarkTheme.d.ts +2 -0
  125. package/lib/components/theme/miaoDarkTheme.js +310 -0
  126. package/lib/components/theme/miaoLightTheme.d.ts +2 -0
  127. package/lib/components/theme/miaoLightTheme.js +296 -0
  128. package/lib/components/theme/ui-config.d.ts +49 -0
  129. package/lib/components/theme/ui-config.js +758 -0
  130. package/lib/components/theme/util.d.ts +20 -0
  131. package/lib/components/theme/util.js +188 -0
  132. package/lib/hooks/index.d.ts +5 -0
  133. package/lib/hooks/index.js +5 -0
  134. package/lib/hooks/useCurrentAppInfo.d.ts +6 -0
  135. package/lib/hooks/useCurrentAppInfo.js +20 -0
  136. package/lib/hooks/useCurrentUserProfile.d.ts +12 -0
  137. package/lib/hooks/useCurrentUserProfile.js +26 -0
  138. package/lib/hooks/useIsMobile.d.ts +1 -0
  139. package/lib/hooks/useIsMobile.js +20 -0
  140. package/lib/hooks/useLogout.d.ts +4 -0
  141. package/lib/hooks/useLogout.js +23 -0
  142. package/lib/hooks/useTheme.d.ts +4 -0
  143. package/lib/hooks/useTheme.js +8 -0
  144. package/lib/hooks/useUpdatingRef.d.ts +1 -0
  145. package/lib/hooks/useUpdatingRef.js +7 -0
  146. package/lib/index.css +3 -0
  147. package/lib/index.d.ts +4 -0
  148. package/lib/index.js +5 -0
  149. package/lib/integrations/dataloom.d.ts +1 -0
  150. package/lib/integrations/dataloom.js +18 -0
  151. package/lib/integrations/generateImage.d.ts +1 -0
  152. package/lib/integrations/generateImage.js +32 -0
  153. package/lib/integrations/generateTextStream.d.ts +26 -0
  154. package/lib/integrations/generateTextStream.js +83 -0
  155. package/lib/integrations/getAppInfo.d.ts +2 -0
  156. package/lib/integrations/getAppInfo.js +4 -0
  157. package/lib/integrations/getCurrentUserProfile.d.ts +6 -0
  158. package/lib/integrations/getCurrentUserProfile.js +5 -0
  159. package/lib/logger/index.d.ts +6 -0
  160. package/lib/logger/index.js +54 -0
  161. package/lib/override.css +29 -0
  162. package/lib/tailwind-theme.css +435 -0
  163. package/lib/types/common.d.ts +11 -0
  164. package/lib/types/common.js +0 -0
  165. package/lib/types/index.d.ts +40 -0
  166. package/lib/types/index.js +0 -0
  167. package/lib/utils/copyToClipboard.d.ts +6 -0
  168. package/lib/utils/copyToClipboard.js +32 -0
  169. package/lib/utils/getAppId.d.ts +11 -0
  170. package/lib/utils/getAppId.js +9 -0
  171. package/lib/utils/getEnvPath.d.ts +4 -0
  172. package/lib/utils/getEnvPath.js +4 -0
  173. package/lib/utils/getParentOrigin.d.ts +5 -0
  174. package/lib/utils/getParentOrigin.js +7 -0
  175. package/lib/utils/getUserProfile.d.ts +47 -0
  176. package/lib/utils/getUserProfile.js +33 -0
  177. package/lib/utils/url.d.ts +8 -0
  178. package/lib/utils/url.js +22 -0
  179. package/lib/utils/utils.d.ts +11 -0
  180. package/lib/utils/utils.js +9 -0
  181. package/package.json +130 -0
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import './UserProfile.css';
3
+ export declare function UserProfileSkeleton(): React.JSX.Element;
@@ -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,8 @@
1
+ import * as React from 'react';
2
+ import './UserProfile.css';
3
+ import { User } from './type';
4
+ interface UserProfileUIProps {
5
+ user: User;
6
+ }
7
+ export declare function UserProfileUI({ user }: UserProfileUIProps): React.JSX.Element;
8
+ export {};
@@ -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';
@@ -0,0 +1,2 @@
1
+ import { UserProfile } from "./UserProfile.js";
2
+ export { UserProfile };
@@ -0,0 +1,8 @@
1
+ export interface User {
2
+ name: string;
3
+ avatar: string;
4
+ email: string;
5
+ department: string;
6
+ feishu_open_id: string;
7
+ status: 'active' | 'inactive';
8
+ }
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,171 @@
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 { dataloom } 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 { data } = await dataloom.service.user.search({
61
+ name: search,
62
+ pageSize: 20
63
+ });
64
+ if (!data || !Array.isArray(data.user_list)) return [];
65
+ return data.user_list.map((user)=>({
66
+ avatar: user.avatar,
67
+ email: user.email,
68
+ name: user.name,
69
+ user_id: user.user_id,
70
+ status: user.status
71
+ }));
72
+ } catch (error) {
73
+ console.error('Failed to fetch users:', error);
74
+ return [];
75
+ }
76
+ };
77
+ const debounceFetcher = useMemo(()=>{
78
+ const loadOptions = (value)=>{
79
+ if (!value) return;
80
+ fetchRef.current += 1;
81
+ const fetchId = fetchRef.current;
82
+ setOptions([]);
83
+ setFetching(true);
84
+ fetchUsers(value).then((newOptions)=>{
85
+ if (fetchId !== fetchRef.current) return;
86
+ setOptions(newOptions.map((v)=>({
87
+ value: v.user_id,
88
+ label: /*#__PURE__*/ jsx(UserWithAvatar, {
89
+ data: v,
90
+ mode: "plain",
91
+ className: "p-[1px] pr-0"
92
+ }),
93
+ avatar: v.avatar,
94
+ name: v.name,
95
+ rawValue: v
96
+ })));
97
+ setFetching(false);
98
+ });
99
+ };
100
+ return debounce(loadOptions, 500);
101
+ }, []);
102
+ const optionRender = (option)=>{
103
+ const user = option.data;
104
+ return /*#__PURE__*/ jsxs("div", {
105
+ className: "flex items-center gap-2",
106
+ children: [
107
+ /*#__PURE__*/ jsx(Avatar, {
108
+ src: user.avatar,
109
+ size: "small",
110
+ className: "shrink-0 !border-0"
111
+ }),
112
+ /*#__PURE__*/ jsx("span", {
113
+ className: "text-sm",
114
+ children: user.name
115
+ })
116
+ ]
117
+ });
118
+ };
119
+ const selectMode = 'multiple' === mode ? 'multiple' : void 0;
120
+ return /*#__PURE__*/ jsx("div", {
121
+ className: "user-select-container",
122
+ children: /*#__PURE__*/ jsx(Select, {
123
+ labelInValue: true,
124
+ showSearch: true,
125
+ className: "w-full",
126
+ maxTagCount: "responsive",
127
+ defaultValue: defaultOptions,
128
+ mode: selectMode,
129
+ filterOption: false,
130
+ onSearch: debounceFetcher,
131
+ allowClear: true,
132
+ placeholder: placeholder,
133
+ notFoundContent: fetching ? /*#__PURE__*/ jsx("div", {
134
+ className: "flex items-center justify-center",
135
+ children: /*#__PURE__*/ jsx(Spin, {
136
+ size: "small",
137
+ indicator: /*#__PURE__*/ jsx(LoaderCircle, {
138
+ className: "!text-[16px] animate-spin"
139
+ })
140
+ })
141
+ }) : /*#__PURE__*/ jsx("span", {
142
+ className: "py-[1px] px-1 text-[#8F959E]",
143
+ children: "无结果,建议更换搜索词"
144
+ }),
145
+ optionRender: optionRender,
146
+ options: options,
147
+ dropdownStyle: {
148
+ 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)',
149
+ padding: '3px'
150
+ },
151
+ value: mapValueToSelectValue(value),
152
+ maxTagPlaceholder: (omittedValues)=>/*#__PURE__*/ jsxs("span", {
153
+ className: "pl-2",
154
+ children: [
155
+ "+ ",
156
+ omittedValues.length
157
+ ]
158
+ }),
159
+ onChange: onChange ? (_, options)=>{
160
+ if (Array.isArray(options)) {
161
+ const selectedUsers = options.map((opt)=>opt.rawValue);
162
+ onChange(selectedUsers);
163
+ } else {
164
+ const selectedUser = options?.rawValue;
165
+ if (selectedUser) onChange(selectedUser);
166
+ }
167
+ } : void 0
168
+ })
169
+ });
170
+ };
171
+ export { UserSelect };
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import type { UserWithAvatarProps } from './type';
3
+ export declare function UserWithAvatar({ data, size, mode, className }: UserWithAvatarProps): React.JSX.Element;
@@ -0,0 +1,41 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import "react";
3
+ import { Avatar, Typography } from "antd";
4
+ import { clsxWithTw } from "../../utils/utils.js";
5
+ const avatarSizeMap = {
6
+ small: 16,
7
+ medium: 20,
8
+ large: 24
9
+ };
10
+ const textVariantMap = {
11
+ small: 'text-[12px] leading-[16px]',
12
+ medium: 'text-[14px] leading-[20px]',
13
+ large: 'text-[16px] leading-[24px]'
14
+ };
15
+ function UserWithAvatar({ data, size = 'medium', mode = 'tag', className }) {
16
+ const { avatar, name } = data;
17
+ const displayName = name || '无效人员';
18
+ return /*#__PURE__*/ jsxs("div", {
19
+ className: clsxWithTw('flex items-center gap-1 rounded-full', {
20
+ 'bg-[rgba(31,35,41,0.1)]': 'tag' === mode,
21
+ 'py-0.5 pl-0.5 pr-1.5 max-w-[148px]': 'small' === size,
22
+ 'py-0.5 pl-0.5 pr-2 max-w-[172px]': 'medium' === size,
23
+ 'py-1 pl-1 pr-2.5 max-w-[196px]': 'large' === size
24
+ }, className),
25
+ children: [
26
+ /*#__PURE__*/ jsx(Avatar, {
27
+ src: avatar,
28
+ size: avatarSizeMap[size],
29
+ className: "shrink-0 border-0"
30
+ }),
31
+ /*#__PURE__*/ jsx(Typography.Text, {
32
+ ellipsis: {
33
+ tooltip: displayName
34
+ },
35
+ className: textVariantMap[size],
36
+ children: displayName
37
+ })
38
+ ]
39
+ });
40
+ }
41
+ export { UserWithAvatar };
@@ -0,0 +1,7 @@
1
+ export { UserSelect } from './UserSelect';
2
+ export type { UserSelectProps } from './UserSelect';
3
+ export { UserDisplay } from './UserDisplay';
4
+ export type { UserDisplayProps } from './UserDisplay';
5
+ export { UserWithAvatar } from './UserWithAvatar';
6
+ export type { UserWithAvatarProps } from './type';
7
+ export { UserProfile } from './UserProfile';
@@ -0,0 +1,5 @@
1
+ import { UserSelect } from "./UserSelect.js";
2
+ import { UserDisplay } from "./UserDisplay.js";
3
+ import { UserWithAvatar } from "./UserWithAvatar.js";
4
+ import { UserProfile } from "./UserProfile/index.js";
5
+ export { UserDisplay, UserProfile, UserSelect, UserWithAvatar };
@@ -0,0 +1,13 @@
1
+ import { IUserProfile } from '../../apis/udt-types';
2
+ export interface UserWithAvatarProps {
3
+ data: IUserProfile;
4
+ /**
5
+ * @default medium
6
+ */
7
+ size?: 'small' | 'medium' | 'large';
8
+ /**
9
+ * @default tag
10
+ */
11
+ mode?: 'tag' | 'plain';
12
+ className?: string;
13
+ }
File without changes
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const Welcome: React.FC;
3
+ export default Welcome;
@@ -0,0 +1,33 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import "react";
3
+ const Welcome = ()=>/*#__PURE__*/ jsxs("div", {
4
+ className: "min-h-screen bg-white p-6 flex justify-center items-center",
5
+ children: [
6
+ /*#__PURE__*/ jsxs("div", {
7
+ className: "mr-[32px] w-[280px]",
8
+ children: [
9
+ /*#__PURE__*/ jsx("div", {
10
+ className: "text-2xl font-bold mb-3",
11
+ children: "欢迎使用妙搭 \uD83D\uDC4B"
12
+ }),
13
+ /*#__PURE__*/ jsx("div", {
14
+ className: "text-[#646A73] text-sm",
15
+ children: "1. 随时发送消息,开始构建你的专属应用"
16
+ }),
17
+ /*#__PURE__*/ jsx("div", {
18
+ className: "text-[#646A73] text-sm",
19
+ children: "2. 无需担心代码实现,妙搭帮你一一解决"
20
+ })
21
+ ]
22
+ }),
23
+ /*#__PURE__*/ jsx("img", {
24
+ className: "rounded-md",
25
+ width: "372",
26
+ height: "210",
27
+ src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miao/spark-welcome-img.png",
28
+ alt: "Welcome"
29
+ })
30
+ ]
31
+ });
32
+ const components_Welcome = Welcome;
33
+ export { components_Welcome as default };
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export default function LogoInfo({ className, logoClassName, }: {
3
+ className?: string;
4
+ logoClassName?: string;
5
+ }): React.JSX.Element;
@@ -0,0 +1,30 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import "react";
3
+ import { Link } from "react-router-dom";
4
+ import { useCurrentAppInfo } from "../../hooks/useCurrentAppInfo.js";
5
+ import { clsxWithTw } from "../../utils/utils.js";
6
+ function LogoInfo({ className, logoClassName }) {
7
+ const { name, avatar } = useCurrentAppInfo();
8
+ return /*#__PURE__*/ jsx("div", {
9
+ className: clsxWithTw('overflow-hidden text-ellipsis whitespace-nowrap', className),
10
+ children: /*#__PURE__*/ jsxs(Link, {
11
+ to: "/",
12
+ className: "text-inherit flex items-center gap-2 w-full",
13
+ children: [
14
+ avatar ? /*#__PURE__*/ jsx("img", {
15
+ src: avatar,
16
+ alt: name,
17
+ className: clsxWithTw('h-7 w-7', logoClassName)
18
+ }) : null,
19
+ /*#__PURE__*/ jsxs("span", {
20
+ className: "w-full truncate",
21
+ children: [
22
+ name || '新应用',
23
+ " "
24
+ ]
25
+ })
26
+ ]
27
+ })
28
+ });
29
+ }
30
+ export { LogoInfo as default };
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ export interface NavItemProps {
3
+ name: string;
4
+ to: string;
5
+ icon?: React.ComponentType<{
6
+ className?: string;
7
+ }>;
8
+ children?: NavItemProps[];
9
+ className?: string;
10
+ hasBadge?: boolean;
11
+ direction?: 'horizontal' | 'vertical';
12
+ onClick?: () => void;
13
+ hideActive?: boolean;
14
+ forceActive?: boolean;
15
+ }
16
+ export declare const NavItem: React.ForwardRefExoticComponent<NavItemProps & React.RefAttributes<HTMLAnchorElement>>;
17
+ export declare const MoreNavItem: React.FC<{
18
+ expandedNavItemsPath: string[];
19
+ isExpanded: boolean;
20
+ } & Omit<NavItemProps, 'icon' | 'to'>>;