@lark-apaas/client-toolkit 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 (188) 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/User.d.ts +1 -0
  12. package/lib/apis/components/User.js +1 -0
  13. package/lib/apis/components/Welcome.d.ts +1 -0
  14. package/lib/apis/components/Welcome.js +2 -0
  15. package/lib/apis/constants/img-resources/avatar.d.ts +11 -0
  16. package/lib/apis/constants/img-resources/avatar.js +12 -0
  17. package/lib/apis/constants/img-resources/banner.d.ts +24 -0
  18. package/lib/apis/constants/img-resources/banner.js +25 -0
  19. package/lib/apis/constants/img-resources/cover.d.ts +36 -0
  20. package/lib/apis/constants/img-resources/cover.js +37 -0
  21. package/lib/apis/dataloom.d.ts +1 -0
  22. package/lib/apis/dataloom.js +2 -0
  23. package/lib/apis/hooks/useAppInfo.d.ts +1 -0
  24. package/lib/apis/hooks/useAppInfo.js +1 -0
  25. package/lib/apis/hooks/useCurrentUserProfile.d.ts +1 -0
  26. package/lib/apis/hooks/useCurrentUserProfile.js +1 -0
  27. package/lib/apis/logger.d.ts +1 -0
  28. package/lib/apis/logger.js +1 -0
  29. package/lib/apis/tools/generateImage.d.ts +1 -0
  30. package/lib/apis/tools/generateImage.js +1 -0
  31. package/lib/apis/tools/generateTextStream.d.ts +1 -0
  32. package/lib/apis/tools/generateTextStream.js +1 -0
  33. package/lib/apis/tools/getAppInfo.d.ts +1 -0
  34. package/lib/apis/tools/getAppInfo.js +1 -0
  35. package/lib/apis/tools/getCurrentUserProfile.d.ts +1 -0
  36. package/lib/apis/tools/getCurrentUserProfile.js +1 -0
  37. package/lib/apis/tools/storage.d.ts +1 -0
  38. package/lib/apis/tools/storage.js +4 -0
  39. package/lib/apis/udt-types.d.ts +16 -0
  40. package/lib/apis/udt-types.js +0 -0
  41. package/lib/apis/utils/registerChinaMap.d.ts +1 -0
  42. package/lib/apis/utils/registerChinaMap.js +103319 -0
  43. package/lib/components/AppContainer/IframeBridge.d.ts +4 -0
  44. package/lib/components/AppContainer/IframeBridge.js +92 -0
  45. package/lib/components/AppContainer/LogInterceptor.d.ts +1 -0
  46. package/lib/components/AppContainer/LogInterceptor.js +44 -0
  47. package/lib/components/AppContainer/PageHoc.d.ts +4 -0
  48. package/lib/components/AppContainer/PageHoc.js +30 -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/AppContainer/utils/childApi.d.ts +5 -0
  57. package/lib/components/AppContainer/utils/childApi.js +20 -0
  58. package/lib/components/AppContainer/utils/listenHot.d.ts +1 -0
  59. package/lib/components/AppContainer/utils/listenHot.js +43 -0
  60. package/lib/components/ErrorRender/index.d.ts +5 -0
  61. package/lib/components/ErrorRender/index.js +79 -0
  62. package/lib/components/NotFoundRender/index.d.ts +3 -0
  63. package/lib/components/NotFoundRender/index.js +59 -0
  64. package/lib/components/SidebarNav/DrawerNav.d.ts +3 -0
  65. package/lib/components/SidebarNav/DrawerNav.js +64 -0
  66. package/lib/components/SidebarNav/DropdownNav.d.ts +3 -0
  67. package/lib/components/SidebarNav/DropdownNav.js +40 -0
  68. package/lib/components/SidebarNav/Sidebar.d.ts +3 -0
  69. package/lib/components/SidebarNav/Sidebar.js +33 -0
  70. package/lib/components/SidebarNav/index.d.ts +5 -0
  71. package/lib/components/SidebarNav/index.js +61 -0
  72. package/lib/components/User/UserDisplay.d.ts +9 -0
  73. package/lib/components/User/UserDisplay.js +39 -0
  74. package/lib/components/User/UserProfile/UserProfile.css +34 -0
  75. package/lib/components/User/UserProfile/UserProfile.d.ts +6 -0
  76. package/lib/components/User/UserProfile/UserProfile.js +41 -0
  77. package/lib/components/User/UserProfile/UserProfileContainer.d.ts +4 -0
  78. package/lib/components/User/UserProfile/UserProfileContainer.js +8 -0
  79. package/lib/components/User/UserProfile/UserProfileSkeleton.d.ts +3 -0
  80. package/lib/components/User/UserProfile/UserProfileSkeleton.js +36 -0
  81. package/lib/components/User/UserProfile/UserProfileUI.d.ts +8 -0
  82. package/lib/components/User/UserProfile/UserProfileUI.js +113 -0
  83. package/lib/components/User/UserProfile/index.d.ts +1 -0
  84. package/lib/components/User/UserProfile/index.js +2 -0
  85. package/lib/components/User/UserProfile/type.d.ts +8 -0
  86. package/lib/components/User/UserProfile/type.js +0 -0
  87. package/lib/components/User/UserProfile/utils.d.ts +5 -0
  88. package/lib/components/User/UserProfile/utils.js +26 -0
  89. package/lib/components/User/UserSelect.css +11 -0
  90. package/lib/components/User/UserSelect.d.ts +11 -0
  91. package/lib/components/User/UserSelect.js +172 -0
  92. package/lib/components/User/UserWithAvatar.d.ts +3 -0
  93. package/lib/components/User/UserWithAvatar.js +41 -0
  94. package/lib/components/User/index.d.ts +7 -0
  95. package/lib/components/User/index.js +5 -0
  96. package/lib/components/User/type.d.ts +13 -0
  97. package/lib/components/User/type.js +0 -0
  98. package/lib/components/Welcome/index.d.ts +3 -0
  99. package/lib/components/Welcome/index.js +17 -0
  100. package/lib/components/common/LogoInfo.d.ts +5 -0
  101. package/lib/components/common/LogoInfo.js +30 -0
  102. package/lib/components/common/NavItem.d.ts +20 -0
  103. package/lib/components/common/NavItem.js +112 -0
  104. package/lib/components/common/NavMenu.d.ts +9 -0
  105. package/lib/components/common/NavMenu.js +50 -0
  106. package/lib/components/common/UserAvatarLayout.d.ts +4 -0
  107. package/lib/components/common/UserAvatarLayout.js +41 -0
  108. package/lib/components/common/UserAvatarMenu.d.ts +4 -0
  109. package/lib/components/common/UserAvatarMenu.js +58 -0
  110. package/lib/components/common/index.d.ts +9 -0
  111. package/lib/components/common/index.js +10 -0
  112. package/lib/components/index.d.ts +8 -0
  113. package/lib/components/index.js +6 -0
  114. package/lib/components/theme/ThemeProvider.d.ts +20 -0
  115. package/lib/components/theme/ThemeProvider.js +75 -0
  116. package/lib/components/theme/constants.d.ts +48 -0
  117. package/lib/components/theme/constants.js +557 -0
  118. package/lib/components/theme/index.d.ts +4 -0
  119. package/lib/components/theme/index.js +5 -0
  120. package/lib/components/theme/miaoDarkTheme.d.ts +2 -0
  121. package/lib/components/theme/miaoDarkTheme.js +310 -0
  122. package/lib/components/theme/miaoLightTheme.d.ts +2 -0
  123. package/lib/components/theme/miaoLightTheme.js +296 -0
  124. package/lib/components/theme/ui-config.d.ts +1 -0
  125. package/lib/components/theme/ui-config.js +2 -0
  126. package/lib/components/theme/util.d.ts +20 -0
  127. package/lib/components/theme/util.js +188 -0
  128. package/lib/font-family.css +40 -0
  129. package/lib/hooks/index.d.ts +5 -0
  130. package/lib/hooks/index.js +5 -0
  131. package/lib/hooks/useAppInfo.d.ts +6 -0
  132. package/lib/hooks/useAppInfo.js +21 -0
  133. package/lib/hooks/useCurrentUserProfile.d.ts +12 -0
  134. package/lib/hooks/useCurrentUserProfile.js +58 -0
  135. package/lib/hooks/useIsMobile.d.ts +1 -0
  136. package/lib/hooks/useIsMobile.js +20 -0
  137. package/lib/hooks/useLogout.d.ts +4 -0
  138. package/lib/hooks/useLogout.js +37 -0
  139. package/lib/hooks/useTheme.d.ts +4 -0
  140. package/lib/hooks/useTheme.js +8 -0
  141. package/lib/hooks/useUpdatingRef.d.ts +1 -0
  142. package/lib/hooks/useUpdatingRef.js +7 -0
  143. package/lib/index.css +5 -0
  144. package/lib/index.d.ts +4 -0
  145. package/lib/index.js +5 -0
  146. package/lib/inspector.dev.css +10 -0
  147. package/lib/integrations/dataloom.d.ts +2 -0
  148. package/lib/integrations/dataloom.js +32 -0
  149. package/lib/integrations/generateImage.d.ts +1 -0
  150. package/lib/integrations/generateImage.js +47 -0
  151. package/lib/integrations/generateTextStream.d.ts +21 -0
  152. package/lib/integrations/generateTextStream.js +98 -0
  153. package/lib/integrations/getAppInfo.d.ts +2 -0
  154. package/lib/integrations/getAppInfo.js +14 -0
  155. package/lib/integrations/getCurrentUserProfile.d.ts +6 -0
  156. package/lib/integrations/getCurrentUserProfile.js +5 -0
  157. package/lib/logger/index.d.ts +6 -0
  158. package/lib/logger/index.js +54 -0
  159. package/lib/override.css +29 -0
  160. package/lib/tailwind-theme.css +335 -0
  161. package/lib/theme-layer.css +3 -0
  162. package/lib/types/common.d.ts +4 -0
  163. package/lib/types/common.js +0 -0
  164. package/lib/types/iframe-events.d.ts +50 -0
  165. package/lib/types/iframe-events.js +0 -0
  166. package/lib/types/index.d.ts +43 -0
  167. package/lib/types/index.js +0 -0
  168. package/lib/utils/copyToClipboard.d.ts +6 -0
  169. package/lib/utils/copyToClipboard.js +32 -0
  170. package/lib/utils/getAppId.d.ts +6 -0
  171. package/lib/utils/getAppId.js +11 -0
  172. package/lib/utils/getCsrfToken.d.ts +5 -0
  173. package/lib/utils/getCsrfToken.js +10 -0
  174. package/lib/utils/getEnvPath.d.ts +4 -0
  175. package/lib/utils/getEnvPath.js +4 -0
  176. package/lib/utils/getInitialInfo.d.ts +20 -0
  177. package/lib/utils/getInitialInfo.js +32 -0
  178. package/lib/utils/getParentOrigin.d.ts +5 -0
  179. package/lib/utils/getParentOrigin.js +7 -0
  180. package/lib/utils/getUserProfile.d.ts +47 -0
  181. package/lib/utils/getUserProfile.js +39 -0
  182. package/lib/utils/postMessage.d.ts +8 -0
  183. package/lib/utils/postMessage.js +11 -0
  184. package/lib/utils/url.d.ts +8 -0
  185. package/lib/utils/url.js +22 -0
  186. package/lib/utils/utils.d.ts +20 -0
  187. package/lib/utils/utils.js +22 -0
  188. package/package.json +135 -0
@@ -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 };
@@ -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,17 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import "react";
3
+ const Welcome = ()=>/*#__PURE__*/ jsxs("div", {
4
+ className: "min-h-screen min-w-screen flex flex-col items-center justify-center",
5
+ children: [
6
+ /*#__PURE__*/ jsx("div", {
7
+ className: "text-xl font-bold leading-8 mb-2",
8
+ children: "初始化应用"
9
+ }),
10
+ /*#__PURE__*/ jsx("div", {
11
+ className: "leading-5",
12
+ children: "通过对话搭建你的专属应用"
13
+ })
14
+ ]
15
+ });
16
+ const components_Welcome = Welcome;
17
+ 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 { useAppInfo } from "../../hooks/useAppInfo.js";
5
+ import { clsxWithTw } from "../../utils/utils.js";
6
+ function LogoInfo({ className, logoClassName }) {
7
+ const { name, avatar } = useAppInfo();
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'>>;
@@ -0,0 +1,112 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import react, { forwardRef, useCallback, useEffect, useMemo, useState } from "react";
3
+ import { NavLink, matchPath, useLocation } from "react-router-dom";
4
+ import { Button } from "antd";
5
+ import { clsxWithTw } from "../../utils/utils.js";
6
+ import { MoreHorizontal } from "lucide-react";
7
+ const HashLink = /*#__PURE__*/ forwardRef(({ className, to, name, icon, onClick, direction, hideActive = false }, _ref)=>{
8
+ const [isActive, setIsActive] = useState(false);
9
+ useEffect(()=>{
10
+ const checkHash = ()=>{
11
+ setIsActive(window.location.hash === to);
12
+ };
13
+ checkHash();
14
+ window.addEventListener('hashchange', checkHash);
15
+ return ()=>window.removeEventListener('hashchange', checkHash);
16
+ }, [
17
+ to
18
+ ]);
19
+ const iconNode = icon ? /*#__PURE__*/ react.createElement(icon, {
20
+ className: 'w-6 h-6'
21
+ }) : null;
22
+ return /*#__PURE__*/ jsxs(Button, {
23
+ variant: "link",
24
+ href: to,
25
+ onClick: ()=>{
26
+ setIsActive(true);
27
+ onClick?.();
28
+ },
29
+ color: isActive && !hideActive ? 'primary' : 'default',
30
+ className: clsxWithTw('miao-nav p-0 b-0 h-full w-full', 'transition-colors inline-flex gap-1 items-center overflow-hidden', {
31
+ 'flex-col': 'vertical' === direction,
32
+ 'w-full': 'vertical' === direction,
33
+ 'justify-center': 'horizontal' === direction,
34
+ 'text-inherit': !isActive
35
+ }, className),
36
+ children: [
37
+ iconNode,
38
+ name ? /*#__PURE__*/ jsx("span", {
39
+ className: clsxWithTw('truncate w-full', {
40
+ 'text-center': 'vertical' === direction
41
+ }),
42
+ children: name
43
+ }) : null
44
+ ]
45
+ });
46
+ });
47
+ HashLink.displayName = 'HashLink';
48
+ const NavItem = /*#__PURE__*/ react.forwardRef((props, ref)=>{
49
+ const isHashLink = props.to.startsWith('#');
50
+ if (isHashLink) return /*#__PURE__*/ jsx(HashLink, {
51
+ ref: ref,
52
+ ...props
53
+ });
54
+ return /*#__PURE__*/ jsx(NavLink, {
55
+ ref: ref,
56
+ to: props.to,
57
+ end: true,
58
+ onClick: props.onClick,
59
+ className: ()=>clsxWithTw('inline-flex justify-center'),
60
+ children: ({ isActive: linkIsActive })=>/*#__PURE__*/ jsxs(Button, {
61
+ variant: "link",
62
+ color: linkIsActive && !props.hideActive || props.forceActive ? 'primary' : 'default',
63
+ className: clsxWithTw('miao-nav p-0 b-0 h-full w-full', 'transition-colors inline-flex gap-1 items-center overflow-hidden', {
64
+ 'flex-col': 'vertical' === props.direction,
65
+ 'justify-center': 'horizontal' === props.direction,
66
+ 'text-inherit': !(linkIsActive && !props.hideActive || props.forceActive)
67
+ }, props.className),
68
+ children: [
69
+ props.icon ? /*#__PURE__*/ jsx(props.icon, {
70
+ className: "w-6 h-6"
71
+ }) : null,
72
+ props.name ? /*#__PURE__*/ jsx("span", {
73
+ className: clsxWithTw('truncate w-full', {
74
+ ' text-center': 'vertical' === props.direction
75
+ }),
76
+ children: props.name
77
+ }) : null
78
+ ]
79
+ })
80
+ });
81
+ });
82
+ NavItem.displayName = 'NavItem';
83
+ const MoreNavItem = ({ expandedNavItemsPath, onClick, isExpanded, name = '更多', ...restProps })=>{
84
+ const { pathname } = useLocation();
85
+ const isActive = useMemo(()=>{
86
+ const matched = expandedNavItemsPath.some((path)=>{
87
+ const match = matchPath(path, pathname);
88
+ return match && match.pathname === pathname;
89
+ });
90
+ return matched;
91
+ }, [
92
+ expandedNavItemsPath,
93
+ pathname
94
+ ]);
95
+ const handleClick = useCallback((e)=>{
96
+ e.preventDefault();
97
+ onClick?.();
98
+ }, [
99
+ onClick
100
+ ]);
101
+ return /*#__PURE__*/ jsx(NavItem, {
102
+ icon: MoreHorizontal,
103
+ name: name,
104
+ to: "",
105
+ hideActive: !isActive,
106
+ forceActive: isExpanded || isActive,
107
+ onClick: handleClick,
108
+ ...restProps
109
+ });
110
+ };
111
+ MoreNavItem.displayName = 'MoreNavItem';
112
+ export { MoreNavItem, NavItem };
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { BaseNavProps } from '../../types';
3
+ type NavMenuProps = BaseNavProps & {
4
+ mode?: 'horizontal' | 'vertical';
5
+ iconClassName?: string;
6
+ onClick?: (key: string) => void;
7
+ };
8
+ export default function NavMenu({ navList, className, iconClassName, mode, onClick, }: NavMenuProps): React.JSX.Element;
9
+ export {};
@@ -0,0 +1,50 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Menu } from "antd";
3
+ import react, { useEffect, useMemo, useState } from "react";
4
+ import { NavLink, useLocation } from "react-router-dom";
5
+ import { clsxWithTw } from "../../utils/utils.js";
6
+ function NavMenu({ navList, className, iconClassName = '', mode = 'horizontal', onClick }) {
7
+ const location = useLocation();
8
+ const [currentMenu, setCurrentMenu] = useState(location.pathname);
9
+ useEffect(()=>{
10
+ setCurrentMenu(location.pathname);
11
+ }, [
12
+ location
13
+ ]);
14
+ const menuItems = useMemo(()=>navList?.map((n)=>({
15
+ label: /*#__PURE__*/ jsxs(NavLink, {
16
+ to: n.to,
17
+ end: true,
18
+ className: ({ isActive })=>clsxWithTw('flex items-center', {
19
+ 'text-[var(--ant-menu-horizontal-item-selected-color)]': isActive
20
+ }),
21
+ children: [
22
+ n.icon ? /*#__PURE__*/ react.createElement(n.icon, {
23
+ className: clsxWithTw('w-4 h-4', iconClassName)
24
+ }) : null,
25
+ /*#__PURE__*/ jsx("span", {
26
+ children: n.name
27
+ })
28
+ ]
29
+ }),
30
+ key: n.to
31
+ })), [
32
+ navList
33
+ ]);
34
+ return /*#__PURE__*/ jsx(Menu, {
35
+ className: clsxWithTw('bg-inherit h-full', className),
36
+ items: menuItems,
37
+ selectedKeys: [
38
+ currentMenu
39
+ ],
40
+ onClick: (info)=>{
41
+ setCurrentMenu(info.key);
42
+ onClick?.(info.key);
43
+ },
44
+ mode: mode,
45
+ style: {
46
+ borderBottomWidth: 0
47
+ }
48
+ });
49
+ }
50
+ export { NavMenu as default };
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ export default function UserAvatarLayout({ className, }: {
3
+ className?: string;
4
+ }): React.JSX.Element;
@@ -0,0 +1,41 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import "react";
3
+ import { Button } from "antd";
4
+ import { LogOut } from "lucide-react";
5
+ import { useCurrentUserProfile, useLogout } from "../../hooks/index.js";
6
+ import { clsxWithTw } from "../../utils/utils.js";
7
+ function UserAvatarLayout({ className }) {
8
+ const { name, avatar } = useCurrentUserProfile();
9
+ const { handlerLogout } = useLogout();
10
+ return /*#__PURE__*/ jsx(Fragment, {
11
+ children: name ? /*#__PURE__*/ jsx("div", {
12
+ className: clsxWithTw('py-4 px-5 border-gray-200 border-t', className),
13
+ children: /*#__PURE__*/ jsxs("div", {
14
+ className: "flex items-center justify-between",
15
+ children: [
16
+ /*#__PURE__*/ jsxs("div", {
17
+ className: "flex items-center gap-2 overflow-hidden text-ellipsis whitespace-nowrap",
18
+ children: [
19
+ avatar ? /*#__PURE__*/ jsx("img", {
20
+ src: avatar,
21
+ alt: name,
22
+ className: "h-8 w-8 rounded-full"
23
+ }) : null,
24
+ /*#__PURE__*/ jsx("span", {
25
+ className: "text-sm font-medium truncate",
26
+ children: name
27
+ })
28
+ ]
29
+ }),
30
+ /*#__PURE__*/ jsx(Button, {
31
+ type: "text",
32
+ className: "text-inherit",
33
+ icon: /*#__PURE__*/ jsx(LogOut, {}),
34
+ onClick: handlerLogout
35
+ })
36
+ ]
37
+ })
38
+ }) : null
39
+ });
40
+ }
41
+ export { UserAvatarLayout as default };
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ export default function UserAvatarMenu({ className }: {
3
+ className?: string;
4
+ }): React.JSX.Element;
@@ -0,0 +1,58 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import "react";
3
+ import { Avatar, Dropdown, Menu } from "antd";
4
+ import { LogOut } from "lucide-react";
5
+ import { useCurrentUserProfile, useLogout } from "../../hooks/index.js";
6
+ import { clsxWithTw } from "../../utils/utils.js";
7
+ function UserAvatarMenu({ className }) {
8
+ const { name, avatar } = useCurrentUserProfile();
9
+ const { handlerLogout } = useLogout();
10
+ if (!name) return null;
11
+ return /*#__PURE__*/ jsx(Dropdown, {
12
+ placement: "bottomRight",
13
+ overlay: /*#__PURE__*/ jsxs(Menu, {
14
+ className: clsxWithTw('min-w-48', className),
15
+ children: [
16
+ /*#__PURE__*/ jsx(Menu.Item, {
17
+ children: /*#__PURE__*/ jsxs("div", {
18
+ className: "flex items-center gap-2",
19
+ children: [
20
+ /*#__PURE__*/ jsx(Avatar, {
21
+ src: avatar,
22
+ className: "w-10 h-10"
23
+ }),
24
+ /*#__PURE__*/ jsx("span", {
25
+ className: "flex-1 text-ellipsis overflow-hidden whitespace-nowrap max-w-[120px]",
26
+ children: name
27
+ })
28
+ ]
29
+ })
30
+ }, "user-info"),
31
+ /*#__PURE__*/ jsx(Menu.Divider, {}),
32
+ /*#__PURE__*/ jsx(Menu.Item, {
33
+ onClick: handlerLogout,
34
+ children: /*#__PURE__*/ jsxs("div", {
35
+ className: "flex items-center gap-2",
36
+ children: [
37
+ /*#__PURE__*/ jsx(LogOut, {}),
38
+ /*#__PURE__*/ jsx("span", {
39
+ children: "退出登录"
40
+ })
41
+ ]
42
+ })
43
+ }, "logout")
44
+ ]
45
+ }),
46
+ trigger: [
47
+ 'click'
48
+ ],
49
+ children: /*#__PURE__*/ jsx("div", {
50
+ className: "cursor-pointer py-3 flex items-center justify-center",
51
+ children: /*#__PURE__*/ jsx(Avatar, {
52
+ src: avatar,
53
+ className: "w-8 h-8"
54
+ })
55
+ })
56
+ });
57
+ }
58
+ export { UserAvatarMenu as default };
@@ -0,0 +1,9 @@
1
+ export { default as UserAvatarMenu } from './UserAvatarMenu';
2
+ export { default as UserAvatarLayout } from './UserAvatarLayout';
3
+ export { default as NavMenu } from './NavMenu';
4
+ export { default as LogoInfo } from './LogoInfo';
5
+ export * from './NavItem';
6
+ export declare const TopHeaderThemeClass = "bg-white text-gray-900 border-gray-200 dark:bg-neutral-50 dark:text-white dark:border-gray-700 border-b";
7
+ export declare const DropdownThemeClass = "bg-white text-gray-900 border-gray-200 dark:bg-neutral-50 dark:text-white dark:border-gray-700 border-b";
8
+ export declare const BottomBarThemeClass = "bg-white dark:bg-gray-800 text-[#646A73] dark:text-gray-300";
9
+ export declare const MaskThemeClass = "bg-black/55";
@@ -0,0 +1,10 @@
1
+ import UserAvatarMenu from "./UserAvatarMenu.js";
2
+ import UserAvatarLayout from "./UserAvatarLayout.js";
3
+ import NavMenu from "./NavMenu.js";
4
+ import LogoInfo from "./LogoInfo.js";
5
+ export * from "./NavItem.js";
6
+ const TopHeaderThemeClass = 'bg-white text-gray-900 border-gray-200 dark:bg-neutral-50 dark:text-white dark:border-gray-700 border-b';
7
+ const DropdownThemeClass = TopHeaderThemeClass;
8
+ const BottomBarThemeClass = 'bg-white dark:bg-gray-800 text-[#646A73] dark:text-gray-300';
9
+ const MaskThemeClass = 'bg-black/55';
10
+ export { BottomBarThemeClass, DropdownThemeClass, LogoInfo, MaskThemeClass, NavMenu, TopHeaderThemeClass, UserAvatarLayout, UserAvatarMenu };