@lark-apaas/client-toolkit 0.1.0-alpha.log.1 → 0.1.0-alpha.log.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/apis/hooks/useTheme.d.ts +1 -0
- package/lib/apis/hooks/useTheme.js +1 -0
- package/lib/components/AppContainer/LogInterceptor.js +3 -0
- package/lib/components/AppContainer/index.js +2 -0
- package/lib/components/User/UserDisplay.d.ts +1 -1
- package/lib/components/User/UserDisplay.js +101 -25
- package/lib/components/User/UserProfile/UserProfile.css +1 -1
- package/lib/components/User/UserProfile/UserProfileContainer.d.ts +1 -1
- package/lib/components/User/UserProfile/UserProfileSkeleton.d.ts +0 -1
- package/lib/components/User/UserProfile/UserProfileSkeleton.js +21 -29
- package/lib/components/User/UserProfile/UserProfileUI.d.ts +1 -2
- package/lib/components/User/UserProfile/UserProfileUI.js +106 -92
- package/lib/components/User/UserSelect.d.ts +1 -1
- package/lib/components/User/UserSelect.js +17 -143
- package/lib/components/User/UserSelectUI/ActionButtons.d.ts +11 -0
- package/lib/components/User/UserSelectUI/ActionButtons.js +44 -0
- package/lib/components/User/UserSelectUI/Dropdown.d.ts +12 -0
- package/lib/components/User/UserSelectUI/Dropdown.js +66 -0
- package/lib/components/User/UserSelectUI/MultipleSelectionTags.d.ts +14 -0
- package/lib/components/User/UserSelectUI/MultipleSelectionTags.js +48 -0
- package/lib/components/User/UserSelectUI/SingleSelectionPreview.d.ts +9 -0
- package/lib/components/User/UserSelectUI/SingleSelectionPreview.js +37 -0
- package/lib/components/User/UserSelectUI/Spinner.d.ts +2 -0
- package/lib/components/User/UserSelectUI/Spinner.js +13 -0
- package/lib/components/User/UserSelectUI/UserSelectUI.d.ts +5 -0
- package/lib/components/User/UserSelectUI/UserSelectUI.js +230 -0
- package/lib/components/User/UserSelectUI/index.d.ts +2 -0
- package/lib/components/User/UserSelectUI/index.js +2 -0
- package/lib/components/User/UserSelectUI/types.d.ts +14 -0
- package/lib/components/User/UserSelectUI/types.js +0 -0
- package/lib/components/User/UserWithAvatar.js +38 -21
- package/lib/components/index.d.ts +2 -5
- package/lib/components/index.js +2 -3
- package/lib/components/ui/avatar.d.ts +6 -0
- package/lib/components/ui/avatar.js +27 -0
- package/lib/components/ui/badge.d.ts +9 -0
- package/lib/components/ui/badge.js +29 -0
- package/lib/components/ui/button.d.ts +10 -0
- package/lib/components/ui/button.js +42 -0
- package/lib/components/ui/input.d.ts +3 -0
- package/lib/components/ui/input.js +12 -0
- package/lib/components/ui/overflow-tooltip-text.d.ts +8 -0
- package/lib/components/ui/overflow-tooltip-text.js +66 -0
- package/lib/components/ui/popover.d.ts +7 -0
- package/lib/components/ui/popover.js +35 -0
- package/lib/components/ui/skeleton.d.ts +7 -0
- package/lib/components/ui/skeleton.js +10 -0
- package/lib/components/ui/tooltip.d.ts +7 -0
- package/lib/components/ui/tooltip.js +24 -0
- package/lib/integrations/getAppInfo.js +11 -1
- package/lib/logger/__tests__/batch-logger.test.d.ts +1 -0
- package/lib/logger/__tests__/batch-logger.test.js +367 -0
- package/lib/logger/batch-logger.d.ts +77 -0
- package/lib/logger/batch-logger.js +131 -0
- package/lib/override.css +0 -16
- package/lib/types/index.d.ts +0 -29
- package/lib/utils/axiosConfig.js +18 -22
- package/package.json +8 -1
- package/lib/apis/components/SidebarNav.d.ts +0 -1
- package/lib/apis/components/SidebarNav.js +0 -2
- package/lib/components/SidebarNav/DrawerNav.d.ts +0 -3
- package/lib/components/SidebarNav/DrawerNav.js +0 -64
- package/lib/components/SidebarNav/DropdownNav.d.ts +0 -3
- package/lib/components/SidebarNav/DropdownNav.js +0 -40
- package/lib/components/SidebarNav/Sidebar.d.ts +0 -3
- package/lib/components/SidebarNav/Sidebar.js +0 -33
- package/lib/components/SidebarNav/index.d.ts +0 -5
- package/lib/components/SidebarNav/index.js +0 -61
- package/lib/components/User/UserSelect.css +0 -11
- package/lib/components/common/LogoInfo.d.ts +0 -5
- package/lib/components/common/LogoInfo.js +0 -30
- package/lib/components/common/NavItem.d.ts +0 -20
- package/lib/components/common/NavItem.js +0 -112
- package/lib/components/common/NavMenu.d.ts +0 -9
- package/lib/components/common/NavMenu.js +0 -50
- package/lib/components/common/UserAvatarLayout.d.ts +0 -4
- package/lib/components/common/UserAvatarLayout.js +0 -41
- package/lib/components/common/UserAvatarMenu.d.ts +0 -4
- package/lib/components/common/UserAvatarMenu.js +0 -58
- package/lib/components/common/index.d.ts +0 -9
- package/lib/components/common/index.js +0 -10
|
@@ -1,61 +1,10 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import
|
|
3
|
-
import { Avatar, Select, Spin } from "antd";
|
|
4
|
-
import { LoaderCircle } from "lucide-react";
|
|
5
|
-
import { debounce } from "lodash";
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import react from "react";
|
|
6
3
|
import { getDataloom } from "../../integrations/dataloom.js";
|
|
7
|
-
import "./
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
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)=>{
|
|
4
|
+
import { UserSelectUI } from "./UserSelectUI/index.js";
|
|
5
|
+
const UserSelect = ({ mode = 'single', defaultValue, value, onChange, placeholder, fetchUsers })=>{
|
|
6
|
+
const fetchUsersImpl = react.useCallback(async (search)=>{
|
|
7
|
+
if (fetchUsers) return fetchUsers(search);
|
|
59
8
|
try {
|
|
60
9
|
const dataloom = await getDataloom();
|
|
61
10
|
const { data } = await dataloom.service.user.search({
|
|
@@ -74,98 +23,23 @@ const UserSelect = ({ mode = 'single', defaultValue, value, onChange, placeholde
|
|
|
74
23
|
console.error('Failed to fetch users:', error);
|
|
75
24
|
return [];
|
|
76
25
|
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
};
|
|
26
|
+
}, [
|
|
27
|
+
fetchUsers
|
|
28
|
+
]);
|
|
120
29
|
const selectMode = 'multiple' === mode ? 'multiple' : void 0;
|
|
121
30
|
return /*#__PURE__*/ jsx("div", {
|
|
122
31
|
className: "user-select-container",
|
|
123
|
-
children: /*#__PURE__*/ jsx(
|
|
124
|
-
|
|
125
|
-
showSearch: true,
|
|
126
|
-
className: "w-full",
|
|
127
|
-
maxTagCount: "responsive",
|
|
128
|
-
defaultValue: defaultOptions,
|
|
32
|
+
children: /*#__PURE__*/ jsx(UserSelectUI, {
|
|
33
|
+
defaultValue: defaultValue,
|
|
129
34
|
mode: selectMode,
|
|
130
|
-
|
|
131
|
-
onSearch: debounceFetcher,
|
|
35
|
+
onSearch: fetchUsersImpl,
|
|
132
36
|
allowClear: true,
|
|
133
37
|
placeholder: placeholder,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
|
38
|
+
value: value,
|
|
39
|
+
onChange: (value)=>{
|
|
40
|
+
if ('multiple' === selectMode) onChange?.(value ?? []);
|
|
41
|
+
else onChange?.(value);
|
|
42
|
+
}
|
|
169
43
|
})
|
|
170
44
|
});
|
|
171
45
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface ActionButtonsProps {
|
|
3
|
+
loading: boolean;
|
|
4
|
+
canClear: boolean;
|
|
5
|
+
isOpen: boolean;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
onClear: (event: React.MouseEvent) => void;
|
|
8
|
+
onToggle: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const ActionButtons: React.ForwardRefExoticComponent<ActionButtonsProps & React.RefAttributes<HTMLDivElement>>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { ChevronDown, X } from "lucide-react";
|
|
4
|
+
import { clsxWithTw } from "../../../utils/utils.js";
|
|
5
|
+
import { Spinner } from "./Spinner.js";
|
|
6
|
+
const ActionButtons_ActionButtons = /*#__PURE__*/ forwardRef(function({ loading, canClear, isOpen, disabled, onClear, onToggle }, ref) {
|
|
7
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
8
|
+
ref: ref,
|
|
9
|
+
className: "flex flex-shrink-0 items-center gap-1 pr-2.5 ml-auto",
|
|
10
|
+
children: [
|
|
11
|
+
loading && /*#__PURE__*/ jsx(Spinner, {
|
|
12
|
+
className: "text-muted-foreground"
|
|
13
|
+
}),
|
|
14
|
+
canClear && /*#__PURE__*/ jsx("button", {
|
|
15
|
+
type: "button",
|
|
16
|
+
onClick: onClear,
|
|
17
|
+
"data-select-interactive": "true",
|
|
18
|
+
className: clsxWithTw('flex size-3 items-center justify-center rounded-full bg-foreground/60 transition-colors duration-200', 'cursor-pointer hover:bg-primary', 'opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto'),
|
|
19
|
+
children: /*#__PURE__*/ jsx(X, {
|
|
20
|
+
size: 11,
|
|
21
|
+
strokeWidth: 3,
|
|
22
|
+
className: "text-white"
|
|
23
|
+
})
|
|
24
|
+
}),
|
|
25
|
+
/*#__PURE__*/ jsx("button", {
|
|
26
|
+
type: "button",
|
|
27
|
+
"data-select-interactive": "true",
|
|
28
|
+
className: clsxWithTw('flex size-3 items-center justify-center rounded-full text-muted-foreground transition-all duration-200 cursor-pointer', {
|
|
29
|
+
'rotate-180': isOpen,
|
|
30
|
+
'opacity-50 cursor-not-allowed': disabled
|
|
31
|
+
}),
|
|
32
|
+
onClick: ()=>{
|
|
33
|
+
if (!disabled) onToggle();
|
|
34
|
+
},
|
|
35
|
+
children: /*#__PURE__*/ jsx(ChevronDown, {
|
|
36
|
+
size: 12,
|
|
37
|
+
strokeWidth: 3
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
ActionButtons_ActionButtons.displayName = 'ActionButtons';
|
|
44
|
+
export { ActionButtons_ActionButtons as ActionButtons };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { IUserProfile } from '../../../apis/udt-types';
|
|
3
|
+
interface DropdownProps {
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
fetching: boolean;
|
|
6
|
+
searchResults: IUserProfile[];
|
|
7
|
+
onSelect: (user: IUserProfile) => void;
|
|
8
|
+
isSelected: (userId: string) => boolean;
|
|
9
|
+
onOptionMouseDown?: () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function Dropdown({ isOpen, fetching, searchResults, onSelect, isSelected, onOptionMouseDown, }: DropdownProps): React.JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { Avatar, AvatarFallback, AvatarImage } from "../../ui/avatar.js";
|
|
4
|
+
import { clsxWithTw } from "../../../utils/utils.js";
|
|
5
|
+
import { Check } from "lucide-react";
|
|
6
|
+
import { Spinner } from "./Spinner.js";
|
|
7
|
+
function Dropdown({ isOpen, fetching, searchResults, onSelect, isSelected, onOptionMouseDown }) {
|
|
8
|
+
if (!isOpen) return null;
|
|
9
|
+
return /*#__PURE__*/ jsx("div", {
|
|
10
|
+
className: "absolute top-full left-0 right-0 z-50 mt-1 rounded-md border border-solid border-border bg-card shadow-lg",
|
|
11
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
12
|
+
className: "max-h-[165px] overflow-y-auto p-[3px]",
|
|
13
|
+
children: fetching ? /*#__PURE__*/ jsx("div", {
|
|
14
|
+
className: "flex items-center justify-center px-3 py-2",
|
|
15
|
+
children: /*#__PURE__*/ jsx(Spinner, {
|
|
16
|
+
className: "text-primary"
|
|
17
|
+
})
|
|
18
|
+
}) : 0 === searchResults.length ? /*#__PURE__*/ jsx("div", {
|
|
19
|
+
className: "px-2 py-[5px] text-[14px] leading-[22px] text-muted-foreground",
|
|
20
|
+
children: "无结果,建议更换搜索词"
|
|
21
|
+
}) : searchResults.map((user)=>{
|
|
22
|
+
const selected = isSelected(user.user_id);
|
|
23
|
+
const displayName = user.name?.trim() || '无效人员';
|
|
24
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
25
|
+
className: "relative flex cursor-pointer items-center gap-2 rounded-sm py-1 pl-3 pr-[7px] text-foreground transition-colors hover:bg-foreground/8",
|
|
26
|
+
onMouseDown: (event)=>{
|
|
27
|
+
onOptionMouseDown?.();
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
},
|
|
30
|
+
onClick: ()=>onSelect(user),
|
|
31
|
+
children: [
|
|
32
|
+
/*#__PURE__*/ jsxs("div", {
|
|
33
|
+
className: "flex min-w-0 flex-1 items-center gap-2",
|
|
34
|
+
children: [
|
|
35
|
+
/*#__PURE__*/ jsxs(Avatar, {
|
|
36
|
+
className: "h-6 w-6 flex-shrink-0",
|
|
37
|
+
children: [
|
|
38
|
+
/*#__PURE__*/ jsx(AvatarImage, {
|
|
39
|
+
src: user.avatar,
|
|
40
|
+
alt: displayName
|
|
41
|
+
}),
|
|
42
|
+
/*#__PURE__*/ jsx(AvatarFallback, {
|
|
43
|
+
className: "bg-muted text-[12px] text-foreground",
|
|
44
|
+
children: displayName.slice(0, 1)
|
|
45
|
+
})
|
|
46
|
+
]
|
|
47
|
+
}),
|
|
48
|
+
/*#__PURE__*/ jsx("span", {
|
|
49
|
+
className: clsxWithTw('truncate text-[14px] leading-[20px]', selected ? 'text-primary' : void 0),
|
|
50
|
+
title: displayName,
|
|
51
|
+
children: displayName
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
}),
|
|
55
|
+
selected ? /*#__PURE__*/ jsx(Check, {
|
|
56
|
+
size: 12,
|
|
57
|
+
className: "text-primary",
|
|
58
|
+
strokeWidth: 3
|
|
59
|
+
}) : null
|
|
60
|
+
]
|
|
61
|
+
}, user.user_id);
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
export { Dropdown };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { IUserProfile } from '../../../apis/udt-types';
|
|
3
|
+
interface MultipleSelectionTagsProps {
|
|
4
|
+
displayUsers: IUserProfile[];
|
|
5
|
+
allUsers: IUserProfile[];
|
|
6
|
+
hiddenCount: number;
|
|
7
|
+
onRemove: (userId: string, event: React.MouseEvent) => void;
|
|
8
|
+
containerRef?: React.RefObject<HTMLDivElement>;
|
|
9
|
+
measureRef?: React.RefObject<HTMLDivElement>;
|
|
10
|
+
moreIndicatorRef?: React.RefObject<HTMLSpanElement>;
|
|
11
|
+
maxWidth?: number | null;
|
|
12
|
+
}
|
|
13
|
+
export declare function MultipleSelectionTags({ displayUsers, onRemove, }: MultipleSelectionTagsProps): React.JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { clsxWithTw } from "../../../utils/utils.js";
|
|
4
|
+
import { Avatar, AvatarFallback, AvatarImage } from "../../ui/avatar.js";
|
|
5
|
+
import { Badge } from "../../ui/badge.js";
|
|
6
|
+
import { Button } from "../../ui/button.js";
|
|
7
|
+
import { X } from "lucide-react";
|
|
8
|
+
function MultipleSelectionTags({ displayUsers, onRemove }) {
|
|
9
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
10
|
+
children: displayUsers?.map((user, index)=>/*#__PURE__*/ jsxs(Badge, {
|
|
11
|
+
variant: "secondary",
|
|
12
|
+
"data-user-tag": true,
|
|
13
|
+
className: clsxWithTw('cursor-pointer flex items-center pl-0.5 pr-2 max-w-[200px] group bg-foreground/10 hover:bg-foreground/10 transition-colors rounded-full whitespace-nowrap my-[3px]', index > 0 ? 'ml-0' : ''),
|
|
14
|
+
children: [
|
|
15
|
+
/*#__PURE__*/ jsxs(Avatar, {
|
|
16
|
+
className: "size-[20px] flex-shrink-0",
|
|
17
|
+
children: [
|
|
18
|
+
/*#__PURE__*/ jsx(AvatarImage, {
|
|
19
|
+
src: user.avatar
|
|
20
|
+
}),
|
|
21
|
+
/*#__PURE__*/ jsx(AvatarFallback, {
|
|
22
|
+
className: "bg-primary/10 text-[10px]",
|
|
23
|
+
children: user.name.slice(0, 1)
|
|
24
|
+
})
|
|
25
|
+
]
|
|
26
|
+
}),
|
|
27
|
+
/*#__PURE__*/ jsx("span", {
|
|
28
|
+
className: "inline-block truncate text-foreground text-[14px] leading-[20px]",
|
|
29
|
+
title: user.name,
|
|
30
|
+
children: user.name
|
|
31
|
+
}),
|
|
32
|
+
/*#__PURE__*/ jsx(Button, {
|
|
33
|
+
variant: "ghost",
|
|
34
|
+
size: "sm",
|
|
35
|
+
"data-select-interactive": "true",
|
|
36
|
+
className: "h-3 w-3 p-0 rounded-full opacity-60 hover:opacity-100 transition-all duration-200 cursor-pointer flex-shrink-0",
|
|
37
|
+
onClick: (e)=>onRemove(user.user_id, e),
|
|
38
|
+
title: `移除 ${user.name}`,
|
|
39
|
+
children: /*#__PURE__*/ jsx(X, {
|
|
40
|
+
size: 10,
|
|
41
|
+
strokeWidth: 3
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
]
|
|
45
|
+
}, user.user_id))
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export { MultipleSelectionTags };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { IUserProfile } from '../../../apis/udt-types';
|
|
3
|
+
interface SingleSelectionPreviewProps {
|
|
4
|
+
user: IUserProfile;
|
|
5
|
+
canClear: boolean;
|
|
6
|
+
isOpen: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function SingleSelectionPreview({ user, canClear, isOpen, }: SingleSelectionPreviewProps): React.JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { Avatar, AvatarFallback, AvatarImage } from "../../ui/avatar.js";
|
|
4
|
+
import { clsxWithTw } from "../../../utils/utils.js";
|
|
5
|
+
function SingleSelectionPreview({ user, canClear, isOpen }) {
|
|
6
|
+
const displayName = user.name?.trim() ?? '';
|
|
7
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
8
|
+
className: clsxWithTw('pointer-events-none absolute top-1/2 z-0 flex -translate-y-1/2 items-center gap-1 rounded-md text-sm text-foreground/70', {
|
|
9
|
+
'opacity-50': isOpen
|
|
10
|
+
}),
|
|
11
|
+
style: {
|
|
12
|
+
left: 'calc(0.75rem + 1px)',
|
|
13
|
+
right: canClear ? '3.5rem' : '2.5rem',
|
|
14
|
+
maxWidth: canClear ? 'calc(100% - 3.5rem)' : 'calc(100% - 2.5rem)'
|
|
15
|
+
},
|
|
16
|
+
children: [
|
|
17
|
+
/*#__PURE__*/ jsxs(Avatar, {
|
|
18
|
+
className: "h-5 w-5 flex-shrink-0",
|
|
19
|
+
children: [
|
|
20
|
+
/*#__PURE__*/ jsx(AvatarImage, {
|
|
21
|
+
src: user.avatar
|
|
22
|
+
}),
|
|
23
|
+
/*#__PURE__*/ jsx(AvatarFallback, {
|
|
24
|
+
className: "text-[11px] text-foreground",
|
|
25
|
+
children: displayName.slice(0, 1)
|
|
26
|
+
})
|
|
27
|
+
]
|
|
28
|
+
}),
|
|
29
|
+
/*#__PURE__*/ jsx("span", {
|
|
30
|
+
className: "truncate text-[14px] leading-[20px] text-foreground",
|
|
31
|
+
title: displayName,
|
|
32
|
+
children: displayName
|
|
33
|
+
})
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export { SingleSelectionPreview };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { Loader2Icon } from "lucide-react";
|
|
4
|
+
import { clsxWithTw } from "../../../utils/utils.js";
|
|
5
|
+
function Spinner({ className }) {
|
|
6
|
+
return /*#__PURE__*/ jsx(Loader2Icon, {
|
|
7
|
+
role: "status",
|
|
8
|
+
"aria-label": "Loading",
|
|
9
|
+
strokeWidth: 2,
|
|
10
|
+
className: clsxWithTw('size-4 animate-spin', className)
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export { Spinner };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** biome-ignore-all lint/a11y/noStaticElementInteractions: <explanation> */
|
|
2
|
+
/** biome-ignore-all lint/a11y/useKeyWithClickEvents: <explanation> */
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import type { UserSelectProps } from './types';
|
|
5
|
+
export declare const UserSelectUI: React.FC<UserSelectProps>;
|