@lark-apaas/coding-template-nestjs-react-fullstack 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.
- package/LICENSE +13 -0
- package/README.md +41 -0
- package/hooks/after-install.mjs +3 -0
- package/hooks/after-render.mjs +3 -0
- package/hooks/before-render.mjs +3 -0
- package/package.json +36 -0
- package/template/.codebase/pipelines/ci.yaml +34 -0
- package/template/.codebase/pipelines/coco-code-review.yaml +21 -0
- package/template/.prettierrc +8 -0
- package/template/.spark_project +16 -0
- package/template/.stylelintrc.js +12 -0
- package/template/_env.local +38 -0
- package/template/_gitignore +64 -0
- package/template/_npmrc +1 -0
- package/template/client/index.html +23 -0
- package/template/client/public/favicon.svg +40 -0
- package/template/client/src/api/index.ts +19 -0
- package/template/client/src/app.tsx +22 -0
- package/template/client/src/components/Layout.tsx +11 -0
- package/template/client/src/components/business-ui/README.md +519 -0
- package/template/client/src/components/business-ui/api/chats/queries.ts +39 -0
- package/template/client/src/components/business-ui/api/chats/service.ts +29 -0
- package/template/client/src/components/business-ui/api/departments/queries.ts +42 -0
- package/template/client/src/components/business-ui/api/departments/service.ts +18 -0
- package/template/client/src/components/business-ui/api/files/service.ts +28 -0
- package/template/client/src/components/business-ui/api/user-profiles/queries.ts +42 -0
- package/template/client/src/components/business-ui/api/user-profiles/service.ts +23 -0
- package/template/client/src/components/business-ui/api/users/queries.ts +34 -0
- package/template/client/src/components/business-ui/api/users/service.ts +40 -0
- package/template/client/src/components/business-ui/chat-select/README.md +128 -0
- package/template/client/src/components/business-ui/chat-select/chat-item.tsx +85 -0
- package/template/client/src/components/business-ui/chat-select/chat-select-tag.tsx +83 -0
- package/template/client/src/components/business-ui/chat-select/chat-select.tsx +197 -0
- package/template/client/src/components/business-ui/chat-select/index.tsx +12 -0
- package/template/client/src/components/business-ui/chat-select/types.ts +102 -0
- package/template/client/src/components/business-ui/chat-select/use-chat-value.ts +180 -0
- package/template/client/src/components/business-ui/chat-select/utils.ts +81 -0
- package/template/client/src/components/business-ui/department-select/department-item.tsx +55 -0
- package/template/client/src/components/business-ui/department-select/department-select-field.tsx +86 -0
- package/template/client/src/components/business-ui/department-select/department-select-tag.tsx +56 -0
- package/template/client/src/components/business-ui/department-select/department-select.tsx +168 -0
- package/template/client/src/components/business-ui/department-select/icon-department.tsx +22 -0
- package/template/client/src/components/business-ui/department-select/index.tsx +7 -0
- package/template/client/src/components/business-ui/department-select/types.ts +15 -0
- package/template/client/src/components/business-ui/department-select/utils.ts +17 -0
- package/template/client/src/components/business-ui/entity-combobox/base-combobox-content.tsx +35 -0
- package/template/client/src/components/business-ui/entity-combobox/base-combobox-empty.tsx +28 -0
- package/template/client/src/components/business-ui/entity-combobox/base-combobox-error.tsx +35 -0
- package/template/client/src/components/business-ui/entity-combobox/base-combobox-item.tsx +55 -0
- package/template/client/src/components/business-ui/entity-combobox/base-combobox-list.tsx +174 -0
- package/template/client/src/components/business-ui/entity-combobox/base-combobox-loading.tsx +19 -0
- package/template/client/src/components/business-ui/entity-combobox/base-combobox-search.tsx +31 -0
- package/template/client/src/components/business-ui/entity-combobox/base-combobox-trigger.tsx +281 -0
- package/template/client/src/components/business-ui/entity-combobox/base-combobox.tsx +132 -0
- package/template/client/src/components/business-ui/entity-combobox/context.tsx +19 -0
- package/template/client/src/components/business-ui/entity-combobox/entity-combobox.tsx +145 -0
- package/template/client/src/components/business-ui/entity-combobox/highlight-text.tsx +52 -0
- package/template/client/src/components/business-ui/entity-combobox/hooks.tsx +21 -0
- package/template/client/src/components/business-ui/entity-combobox/index.tsx +31 -0
- package/template/client/src/components/business-ui/entity-combobox/item-pill.tsx +179 -0
- package/template/client/src/components/business-ui/entity-combobox/popover-wrapper.tsx +149 -0
- package/template/client/src/components/business-ui/entity-combobox/search-trigger.tsx +262 -0
- package/template/client/src/components/business-ui/entity-combobox/shared-types.ts +296 -0
- package/template/client/src/components/business-ui/entity-combobox/size-variants.tsx +322 -0
- package/template/client/src/components/business-ui/entity-combobox/types.ts +246 -0
- package/template/client/src/components/business-ui/entity-combobox/use-fetch-data.tsx +81 -0
- package/template/client/src/components/business-ui/entity-combobox/use-infinite-scroll.tsx +99 -0
- package/template/client/src/components/business-ui/entity-combobox/use-popover-outside-click.tsx +32 -0
- package/template/client/src/components/business-ui/form/checkbox-field.tsx +83 -0
- package/template/client/src/components/business-ui/form/context.tsx +38 -0
- package/template/client/src/components/business-ui/form/field-layout.tsx +91 -0
- package/template/client/src/components/business-ui/form/form.tsx +54 -0
- package/template/client/src/components/business-ui/form/hooks/form-context.tsx +4 -0
- package/template/client/src/components/business-ui/form/hooks/form-utils.ts +23 -0
- package/template/client/src/components/business-ui/form/hooks/form.tsx +40 -0
- package/template/client/src/components/business-ui/form/index.tsx +4 -0
- package/template/client/src/components/business-ui/form/input-field.tsx +74 -0
- package/template/client/src/components/business-ui/form/radio-group-field.tsx +138 -0
- package/template/client/src/components/business-ui/form/select-field.tsx +155 -0
- package/template/client/src/components/business-ui/form/switch-field.tsx +66 -0
- package/template/client/src/components/business-ui/form/textarea-field.tsx +72 -0
- package/template/client/src/components/business-ui/form/types.ts +32 -0
- package/template/client/src/components/business-ui/tiptap-editor/README.md +324 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/attachment-toolbar-button.tsx +74 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/blockquote-toolbar-button.tsx +41 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/code-block-toolbar-button.tsx +41 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/color-highlight-toolbar-button.tsx +141 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/heading-toolbar-button.tsx +99 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/horizontal-rule-toolbar-button.tsx +39 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/image-upload-toolbar-button.tsx +65 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/link-edit-form.tsx +127 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/link-hover-toolbar.tsx +380 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/link-toolbar-button.tsx +96 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/list-toolbar-button.tsx +75 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/mark-toolbar-button.tsx +118 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/text-align-toolbar-button.tsx +84 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/undo-redo-toolbar-button.tsx +54 -0
- package/template/client/src/components/business-ui/tiptap-editor/extensions/attachment.tsx +539 -0
- package/template/client/src/components/business-ui/tiptap-editor/extensions/code-block-shiki.tsx +236 -0
- package/template/client/src/components/business-ui/tiptap-editor/extensions/complete-kit.ts +260 -0
- package/template/client/src/components/business-ui/tiptap-editor/extensions/image.tsx +456 -0
- package/template/client/src/components/business-ui/tiptap-editor/hooks/use-tiptap-editor.ts +47 -0
- package/template/client/src/components/business-ui/tiptap-editor/index.ts +38 -0
- package/template/client/src/components/business-ui/tiptap-editor/tiptap-editor-complete.tsx +112 -0
- package/template/client/src/components/business-ui/tiptap-editor/tiptap-editor.tsx +169 -0
- package/template/client/src/components/business-ui/types/user.ts +74 -0
- package/template/client/src/components/business-ui/user-display/index.tsx +2 -0
- package/template/client/src/components/business-ui/user-display/overflow-tooltip-text.tsx +90 -0
- package/template/client/src/components/business-ui/user-display/type.ts +27 -0
- package/template/client/src/components/business-ui/user-display/user-display.tsx +99 -0
- package/template/client/src/components/business-ui/user-display/user-with-avatar.tsx +158 -0
- package/template/client/src/components/business-ui/user-display/utils.ts +37 -0
- package/template/client/src/components/business-ui/user-profile/error-image.tsx +302 -0
- package/template/client/src/components/business-ui/user-profile/user-external-script.ts +73 -0
- package/template/client/src/components/business-ui/user-profile/user-profile.tsx +370 -0
- package/template/client/src/components/business-ui/user-select/index.tsx +28 -0
- package/template/client/src/components/business-ui/user-select/types.ts +109 -0
- package/template/client/src/components/business-ui/user-select/use-user-value.ts +160 -0
- package/template/client/src/components/business-ui/user-select/user-item.tsx +98 -0
- package/template/client/src/components/business-ui/user-select/user-pill.tsx +140 -0
- package/template/client/src/components/business-ui/user-select/user-select-tag.tsx +82 -0
- package/template/client/src/components/business-ui/user-select/user-select.tsx +359 -0
- package/template/client/src/components/business-ui/user-select/utils.tsx +188 -0
- package/template/client/src/components/business-ui/utils/user.ts +72 -0
- package/template/client/src/components/ui/README.md +134 -0
- package/template/client/src/components/ui/accordion.tsx +66 -0
- package/template/client/src/components/ui/alert-dialog.tsx +157 -0
- package/template/client/src/components/ui/alert.tsx +71 -0
- package/template/client/src/components/ui/aspect-ratio.tsx +11 -0
- package/template/client/src/components/ui/avatar.tsx +53 -0
- package/template/client/src/components/ui/badge.tsx +42 -0
- package/template/client/src/components/ui/breadcrumb.tsx +109 -0
- package/template/client/src/components/ui/button-group.tsx +83 -0
- package/template/client/src/components/ui/button.tsx +69 -0
- package/template/client/src/components/ui/calendar.tsx +213 -0
- package/template/client/src/components/ui/card.tsx +82 -0
- package/template/client/src/components/ui/carousel.tsx +241 -0
- package/template/client/src/components/ui/chart.tsx +357 -0
- package/template/client/src/components/ui/checkbox.tsx +32 -0
- package/template/client/src/components/ui/collapsible.tsx +33 -0
- package/template/client/src/components/ui/command.tsx +208 -0
- package/template/client/src/components/ui/context-menu.tsx +324 -0
- package/template/client/src/components/ui/dialog.tsx +143 -0
- package/template/client/src/components/ui/drawer.tsx +135 -0
- package/template/client/src/components/ui/dropdown-menu.tsx +329 -0
- package/template/client/src/components/ui/empty.tsx +104 -0
- package/template/client/src/components/ui/field.tsx +248 -0
- package/template/client/src/components/ui/form.tsx +167 -0
- package/template/client/src/components/ui/hover-card.tsx +44 -0
- package/template/client/src/components/ui/icons/file-ae-colorful-icon.tsx +21 -0
- package/template/client/src/components/ui/icons/file-ai-colorful-icon.tsx +36 -0
- package/template/client/src/components/ui/icons/file-android-colorful-icon.tsx +33 -0
- package/template/client/src/components/ui/icons/file-audio-colorful-icon.tsx +21 -0
- package/template/client/src/components/ui/icons/file-code-colorful-icon.tsx +28 -0
- package/template/client/src/components/ui/icons/file-csv-colorful-icon.tsx +21 -0
- package/template/client/src/components/ui/icons/file-eml-colorful-icon.tsx +29 -0
- package/template/client/src/components/ui/icons/file-ios-colorful-icon.tsx +25 -0
- package/template/client/src/components/ui/icons/file-keynote-colorful-icon.tsx +29 -0
- package/template/client/src/components/ui/icons/file-pages-colorful-icon.tsx +29 -0
- package/template/client/src/components/ui/icons/file-ps-colorful-icon.tsx +21 -0
- package/template/client/src/components/ui/icons/file-sketch-colorful-icon.tsx +21 -0
- package/template/client/src/components/ui/icons/file-slide-colorful-icon.tsx +21 -0
- package/template/client/src/components/ui/icons/file-vcf-colorful-icon.tsx +29 -0
- package/template/client/src/components/ui/icons/file-wiki-excel-colorful-icon.tsx +23 -0
- package/template/client/src/components/ui/icons/file-wiki-image-colorful-icon.tsx +27 -0
- package/template/client/src/components/ui/icons/file-wiki-pdf-colorful-icon.tsx +20 -0
- package/template/client/src/components/ui/icons/file-wiki-ppt-colorful-icon.tsx +21 -0
- package/template/client/src/components/ui/icons/file-wiki-text-colorful-icon.tsx +12 -0
- package/template/client/src/components/ui/icons/file-wiki-unknown-colorful-icon.tsx +14 -0
- package/template/client/src/components/ui/icons/file-wiki-video-colorful-icon.tsx +23 -0
- package/template/client/src/components/ui/icons/file-wiki-word-colorful-icon.tsx +38 -0
- package/template/client/src/components/ui/icons/file-wiki-zip-colorful-icon.tsx +21 -0
- package/template/client/src/components/ui/image.tsx +183 -0
- package/template/client/src/components/ui/input-group.tsx +166 -0
- package/template/client/src/components/ui/input-otp.tsx +77 -0
- package/template/client/src/components/ui/input.tsx +21 -0
- package/template/client/src/components/ui/item.tsx +193 -0
- package/template/client/src/components/ui/kbd.tsx +28 -0
- package/template/client/src/components/ui/label.tsx +24 -0
- package/template/client/src/components/ui/menubar.tsx +348 -0
- package/template/client/src/components/ui/native-select.tsx +48 -0
- package/template/client/src/components/ui/navigation-menu.tsx +168 -0
- package/template/client/src/components/ui/pagination.tsx +127 -0
- package/template/client/src/components/ui/popover.tsx +48 -0
- package/template/client/src/components/ui/progress.tsx +31 -0
- package/template/client/src/components/ui/radio-group.tsx +45 -0
- package/template/client/src/components/ui/resizable.tsx +56 -0
- package/template/client/src/components/ui/scroll-area.tsx +58 -0
- package/template/client/src/components/ui/select.tsx +243 -0
- package/template/client/src/components/ui/separator.tsx +28 -0
- package/template/client/src/components/ui/sheet.tsx +139 -0
- package/template/client/src/components/ui/sidebar.tsx +727 -0
- package/template/client/src/components/ui/skeleton.tsx +13 -0
- package/template/client/src/components/ui/slider.tsx +87 -0
- package/template/client/src/components/ui/sonner.tsx +67 -0
- package/template/client/src/components/ui/spinner.tsx +16 -0
- package/template/client/src/components/ui/streamdown.tsx +186 -0
- package/template/client/src/components/ui/switch.tsx +31 -0
- package/template/client/src/components/ui/table.tsx +116 -0
- package/template/client/src/components/ui/tabs.tsx +66 -0
- package/template/client/src/components/ui/textarea.tsx +18 -0
- package/template/client/src/components/ui/toggle-group.tsx +83 -0
- package/template/client/src/components/ui/toggle.tsx +47 -0
- package/template/client/src/components/ui/tooltip.tsx +61 -0
- package/template/client/src/hooks/use-example.ts +52 -0
- package/template/client/src/hooks/use-mobile.ts +19 -0
- package/template/client/src/index.css +7 -0
- package/template/client/src/index.tsx +36 -0
- package/template/client/src/lib/shiki.ts +92 -0
- package/template/client/src/lib/utils.ts +6 -0
- package/template/client/src/pages/ExamplePage/ExamplePage.tsx +37 -0
- package/template/client/src/pages/NotFound/NotFound.tsx +11 -0
- package/template/client/src/tailwind-theme.css +257 -0
- package/template/client/src/types/common.ts +34 -0
- package/template/client/src/types/global.d.ts +53 -0
- package/template/client/src/types/index.ts +4 -0
- package/template/client/src/typography.css +41 -0
- package/template/client/src/utils/img-resources/avatar-placeholders.ts +12 -0
- package/template/client/src/utils/img-resources/banner-placeholders.ts +29 -0
- package/template/client/src/utils/img-resources/cover-placeholders.ts +47 -0
- package/template/components.json +21 -0
- package/template/eslint.config.js +50 -0
- package/template/nest-cli.json +25 -0
- package/template/package-lock.json +29195 -0
- package/template/package.json +202 -0
- package/template/postcss.config.js +10 -0
- package/template/scripts/build.sh +120 -0
- package/template/scripts/dev.js +295 -0
- package/template/scripts/dev.sh +2 -0
- package/template/scripts/lint.js +150 -0
- package/template/scripts/prune-smart.js +281 -0
- package/template/scripts/run.sh +5 -0
- package/template/server/app.module.ts +27 -0
- package/template/server/common/constants/api_response_code.ts +54 -0
- package/template/server/common/filters/exception.filter.ts +78 -0
- package/template/server/common/interfaces/api_response.interface.ts +21 -0
- package/template/server/common/interfaces/exception.interface.ts +19 -0
- package/template/server/database/schema.ts +90 -0
- package/template/server/main.ts +31 -0
- package/template/server/modules/hello/hello.controller.ts +16 -0
- package/template/server/modules/hello/hello.module.ts +10 -0
- package/template/server/modules/hello/hello.service.ts +28 -0
- package/template/server/modules/view/view.controller.ts +17 -0
- package/template/server/modules/view/view.module.ts +8 -0
- package/template/shared/api.interface.ts +1 -0
- package/template/tailwind.config.ts +9 -0
- package/template/tsconfig.app.json +23 -0
- package/template/tsconfig.json +8 -0
- package/template/tsconfig.node.json +16 -0
- package/template/vite.config.ts +10 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Loader2 } from 'lucide-react';
|
|
4
|
+
|
|
5
|
+
import { BaseComboboxItem } from '@client/src/components/business-ui/entity-combobox/base-combobox-item';
|
|
6
|
+
import { HighlightText } from '@client/src/components/business-ui/entity-combobox/highlight-text';
|
|
7
|
+
import { isHexColor } from '@client/src/components/business-ui/entity-combobox/item-pill';
|
|
8
|
+
import {
|
|
9
|
+
listItemAvatarVariants,
|
|
10
|
+
listItemNameVariants,
|
|
11
|
+
listItemSubTextVariants,
|
|
12
|
+
listItemVariants,
|
|
13
|
+
type ComboboxSize,
|
|
14
|
+
} from '@client/src/components/business-ui/entity-combobox/size-variants';
|
|
15
|
+
import type { UserSelectItemValue } from '@client/src/components/business-ui/user-select/types';
|
|
16
|
+
import { cn } from '@/lib/utils';
|
|
17
|
+
import { getI18nText } from '@client/src/components/business-ui/utils/user';
|
|
18
|
+
import {
|
|
19
|
+
Avatar,
|
|
20
|
+
AvatarFallback,
|
|
21
|
+
AvatarImage,
|
|
22
|
+
} from '@client/src/components/ui/avatar';
|
|
23
|
+
|
|
24
|
+
const ExternalUserTag = () => (
|
|
25
|
+
<span className="dark:blue-200 inline-flex shrink-0 items-center rounded-sm bg-blue-500/20 px-1.5 py-0.5 text-xs leading-4 text-blue-900">
|
|
26
|
+
外部
|
|
27
|
+
</span>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export const UserItem = ({
|
|
31
|
+
userValue,
|
|
32
|
+
isSelected,
|
|
33
|
+
className,
|
|
34
|
+
size = 'medium',
|
|
35
|
+
searchKeyword,
|
|
36
|
+
disabled,
|
|
37
|
+
isConverting,
|
|
38
|
+
}: {
|
|
39
|
+
userValue: UserSelectItemValue;
|
|
40
|
+
isSelected: boolean;
|
|
41
|
+
className?: string;
|
|
42
|
+
size?: ComboboxSize;
|
|
43
|
+
searchKeyword?: string;
|
|
44
|
+
disabled?: boolean;
|
|
45
|
+
isConverting?: boolean;
|
|
46
|
+
}) => {
|
|
47
|
+
const user = userValue.raw;
|
|
48
|
+
const displayName = getI18nText(user?.name);
|
|
49
|
+
const isExternalUser = user?.user_type === '_externalUser';
|
|
50
|
+
|
|
51
|
+
const isHex = isHexColor(user?.avatar);
|
|
52
|
+
|
|
53
|
+
const avatarImage = !isHex ? (
|
|
54
|
+
<AvatarImage src={user?.avatar} alt={displayName} loading="eager" />
|
|
55
|
+
) : (
|
|
56
|
+
<AvatarFallback style={{ backgroundColor: user?.avatar }}>
|
|
57
|
+
{displayName?.charAt?.(0).toUpperCase()}
|
|
58
|
+
</AvatarFallback>
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<BaseComboboxItem
|
|
63
|
+
item={userValue}
|
|
64
|
+
getItemValue={(item) => item}
|
|
65
|
+
isSelected={isSelected}
|
|
66
|
+
className={cn(listItemVariants({ size }), className)}
|
|
67
|
+
disabled={disabled}
|
|
68
|
+
>
|
|
69
|
+
<div className="relative shrink-0">
|
|
70
|
+
<Avatar className={listItemAvatarVariants({ size })}>
|
|
71
|
+
{user?.avatar ? (
|
|
72
|
+
avatarImage
|
|
73
|
+
) : (
|
|
74
|
+
<AvatarFallback>{displayName?.charAt?.(0)}</AvatarFallback>
|
|
75
|
+
)}
|
|
76
|
+
</Avatar>
|
|
77
|
+
{isConverting && (
|
|
78
|
+
<div className="absolute inset-0 flex items-center justify-center rounded-full bg-black/40">
|
|
79
|
+
<Loader2 className="h-3.5 w-3.5 animate-spin text-white" />
|
|
80
|
+
</div>
|
|
81
|
+
)}
|
|
82
|
+
</div>
|
|
83
|
+
<div className="flex min-w-0 flex-1 flex-col gap-px">
|
|
84
|
+
<div className="flex items-center gap-1">
|
|
85
|
+
<HighlightText
|
|
86
|
+
text={userValue.name}
|
|
87
|
+
highlight={searchKeyword}
|
|
88
|
+
className={listItemNameVariants({ size })}
|
|
89
|
+
/>
|
|
90
|
+
{isExternalUser && <ExternalUserTag />}
|
|
91
|
+
</div>
|
|
92
|
+
<span className={listItemSubTextVariants({ size })}>
|
|
93
|
+
{getI18nText(user?.department?.name) || user?.tenantName}
|
|
94
|
+
</span>
|
|
95
|
+
</div>
|
|
96
|
+
</BaseComboboxItem>
|
|
97
|
+
);
|
|
98
|
+
};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
ItemPill,
|
|
7
|
+
renderPillAvatar,
|
|
8
|
+
} from '@client/src/components/business-ui/entity-combobox/item-pill';
|
|
9
|
+
import type { ComboboxSize } from '@client/src/components/business-ui/entity-combobox/size-variants';
|
|
10
|
+
import { UserProfile } from '@client/src/components/business-ui/user-profile/user-profile';
|
|
11
|
+
import type { AccountType } from '@client/src/components/business-ui/user-select/types';
|
|
12
|
+
import { cn } from '@/lib/utils';
|
|
13
|
+
import {
|
|
14
|
+
Popover,
|
|
15
|
+
PopoverContent,
|
|
16
|
+
PopoverTrigger,
|
|
17
|
+
} from '@client/src/components/ui/popover';
|
|
18
|
+
|
|
19
|
+
export type UserPillProps = {
|
|
20
|
+
/**
|
|
21
|
+
* 用户 ID,用于 UserProfile 展示
|
|
22
|
+
*/
|
|
23
|
+
userId: string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 账户类型
|
|
27
|
+
* @default "apaas"
|
|
28
|
+
*/
|
|
29
|
+
accountType?: AccountType;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 显示的用户名
|
|
33
|
+
*/
|
|
34
|
+
label: string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 头像 URL
|
|
38
|
+
*/
|
|
39
|
+
avatarUrl?: string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 尺寸
|
|
43
|
+
* @default "medium"
|
|
44
|
+
*/
|
|
45
|
+
size?: ComboboxSize;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 是否禁用
|
|
49
|
+
*/
|
|
50
|
+
disabled?: boolean;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 最大文本长度
|
|
54
|
+
*/
|
|
55
|
+
maxTextLength?: number;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 后缀(如关闭按钮)
|
|
59
|
+
*/
|
|
60
|
+
suffix?: React.ReactNode;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 自定义样式
|
|
64
|
+
*/
|
|
65
|
+
className?: string;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 是否启用点击头像弹出 UserProfile
|
|
69
|
+
* @default true
|
|
70
|
+
*/
|
|
71
|
+
enableProfile?: boolean;
|
|
72
|
+
|
|
73
|
+
avatarFallback?: boolean;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const UserPill: React.FC<UserPillProps> = ({
|
|
77
|
+
userId,
|
|
78
|
+
accountType = 'apaas',
|
|
79
|
+
label,
|
|
80
|
+
avatarUrl,
|
|
81
|
+
size = 'medium',
|
|
82
|
+
disabled,
|
|
83
|
+
maxTextLength,
|
|
84
|
+
suffix,
|
|
85
|
+
className,
|
|
86
|
+
enableProfile = true,
|
|
87
|
+
avatarFallback,
|
|
88
|
+
}) => {
|
|
89
|
+
const baseAvatarElement = renderPillAvatar({
|
|
90
|
+
avatarUrl,
|
|
91
|
+
label,
|
|
92
|
+
size,
|
|
93
|
+
avatarFallback,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const avatarWithPopover = React.useMemo(() => {
|
|
97
|
+
if (!enableProfile) {
|
|
98
|
+
return baseAvatarElement;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
|
|
102
|
+
e.stopPropagation();
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<Popover>
|
|
107
|
+
<PopoverTrigger asChild>
|
|
108
|
+
<button
|
|
109
|
+
type="button"
|
|
110
|
+
className={cn('cursor-pointer rounded-full')}
|
|
111
|
+
onClick={handleClick}
|
|
112
|
+
>
|
|
113
|
+
{baseAvatarElement}
|
|
114
|
+
</button>
|
|
115
|
+
</PopoverTrigger>
|
|
116
|
+
<PopoverContent
|
|
117
|
+
side="bottom"
|
|
118
|
+
align="start"
|
|
119
|
+
sideOffset={8}
|
|
120
|
+
className="w-80 p-0"
|
|
121
|
+
>
|
|
122
|
+
<UserProfile userId={userId} accountType={accountType} />
|
|
123
|
+
</PopoverContent>
|
|
124
|
+
</Popover>
|
|
125
|
+
);
|
|
126
|
+
}, [enableProfile, baseAvatarElement, userId, accountType]);
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<ItemPill
|
|
130
|
+
label={label}
|
|
131
|
+
avatar={avatarWithPopover}
|
|
132
|
+
className={className}
|
|
133
|
+
maxTextLength={maxTextLength}
|
|
134
|
+
suffix={suffix}
|
|
135
|
+
size={size}
|
|
136
|
+
disabled={disabled}
|
|
137
|
+
avatarFallback={avatarFallback}
|
|
138
|
+
/>
|
|
139
|
+
);
|
|
140
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { X } from 'lucide-react';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
tagCloseIconVariants,
|
|
7
|
+
type ComboboxSize,
|
|
8
|
+
} from '@client/src/components/business-ui/entity-combobox/size-variants';
|
|
9
|
+
import type {
|
|
10
|
+
AccountType,
|
|
11
|
+
UserSelectItemValue,
|
|
12
|
+
} from '@client/src/components/business-ui/user-select/types';
|
|
13
|
+
import { UserPill } from '@client/src/components/business-ui/user-select/user-pill';
|
|
14
|
+
import { Skeleton } from '@client/src/components/ui/skeleton';
|
|
15
|
+
|
|
16
|
+
export const UserSelectTag = ({
|
|
17
|
+
userValue,
|
|
18
|
+
onClose,
|
|
19
|
+
maxTextLength,
|
|
20
|
+
className,
|
|
21
|
+
size = 'medium',
|
|
22
|
+
disabled,
|
|
23
|
+
isLoading,
|
|
24
|
+
accountType = 'apaas',
|
|
25
|
+
}: {
|
|
26
|
+
userValue: UserSelectItemValue;
|
|
27
|
+
onClose: (value: UserSelectItemValue, e: React.MouseEvent) => void;
|
|
28
|
+
maxTextLength?: number;
|
|
29
|
+
className?: string;
|
|
30
|
+
size?: ComboboxSize;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* 是否正在加载用户信息(ID 模式下查询中)
|
|
34
|
+
*/
|
|
35
|
+
isLoading?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* 账户类型,用于 UserProfile 展示
|
|
38
|
+
*/
|
|
39
|
+
accountType?: AccountType;
|
|
40
|
+
}) => {
|
|
41
|
+
const user = userValue.raw;
|
|
42
|
+
|
|
43
|
+
const handleClose = (e: React.MouseEvent) => {
|
|
44
|
+
e.stopPropagation();
|
|
45
|
+
onClose(userValue, e);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const closeButton = !disabled ? (
|
|
49
|
+
<button
|
|
50
|
+
type="button"
|
|
51
|
+
className="rounded-sm text-foreground opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none"
|
|
52
|
+
onClick={handleClose}
|
|
53
|
+
>
|
|
54
|
+
<X className={tagCloseIconVariants({ size })} />
|
|
55
|
+
<span className="sr-only">移除 {userValue.name}</span>
|
|
56
|
+
</button>
|
|
57
|
+
) : null;
|
|
58
|
+
|
|
59
|
+
// 加载中状态显示 Skeleton(不触发 UserProfile)
|
|
60
|
+
if (isLoading && !user) {
|
|
61
|
+
return (
|
|
62
|
+
<div className="inline-flex items-center gap-1 rounded-md bg-secondary px-1.5 py-0.5">
|
|
63
|
+
<Skeleton className="h-4 w-4 rounded-full" />
|
|
64
|
+
<Skeleton className="h-3 w-12" />
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<UserPill
|
|
71
|
+
userId={userValue.id}
|
|
72
|
+
accountType={accountType}
|
|
73
|
+
label={userValue.name}
|
|
74
|
+
avatarUrl={userValue.avatar || user?.avatar}
|
|
75
|
+
className={className}
|
|
76
|
+
maxTextLength={maxTextLength}
|
|
77
|
+
suffix={closeButton}
|
|
78
|
+
size={size}
|
|
79
|
+
disabled={disabled}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useCallback, useMemo, useRef, useState } from 'react';
|
|
4
|
+
import { toast } from 'sonner';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
searchUsers,
|
|
8
|
+
convertExternalContact,
|
|
9
|
+
type AccountType,
|
|
10
|
+
} from '@client/src/components/business-ui/api/users/service';
|
|
11
|
+
import { BaseCombobox } from '@client/src/components/business-ui/entity-combobox/base-combobox';
|
|
12
|
+
import { useEntityComboboxContext } from '@client/src/components/business-ui/entity-combobox/context';
|
|
13
|
+
import type {
|
|
14
|
+
UserSelectItemValue,
|
|
15
|
+
UserSelectProps,
|
|
16
|
+
} from '@client/src/components/business-ui/user-select/types';
|
|
17
|
+
import { useUserValue } from '@client/src/components/business-ui/user-select/use-user-value';
|
|
18
|
+
import { UserItem } from '@client/src/components/business-ui/user-select/user-item';
|
|
19
|
+
import { UserSelectTag } from '@client/src/components/business-ui/user-select/user-select-tag';
|
|
20
|
+
import {
|
|
21
|
+
searchUserInfoToUser,
|
|
22
|
+
isUnregisteredExternalContact,
|
|
23
|
+
} from '@client/src/components/business-ui/user-select/utils';
|
|
24
|
+
|
|
25
|
+
function createUsersFetcher(options: { accountType?: AccountType; pageSize?: number } = {}) {
|
|
26
|
+
const { accountType = 'apaas', pageSize = 100 } = options;
|
|
27
|
+
|
|
28
|
+
return async (search: string) => {
|
|
29
|
+
const response = await searchUsers({ query: search, pageSize });
|
|
30
|
+
const userList = response?.data?.userList || [];
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
items: userList.map((user) => searchUserInfoToUser(user, accountType)),
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 内部包装组件用于获取 context 中的 size
|
|
39
|
+
const UserItemWrapper = ({
|
|
40
|
+
userValue,
|
|
41
|
+
isSelected,
|
|
42
|
+
className,
|
|
43
|
+
disabled,
|
|
44
|
+
isConverting,
|
|
45
|
+
}: {
|
|
46
|
+
userValue: UserSelectItemValue;
|
|
47
|
+
isSelected: boolean;
|
|
48
|
+
className?: string;
|
|
49
|
+
disabled?: boolean;
|
|
50
|
+
isConverting?: boolean;
|
|
51
|
+
}) => {
|
|
52
|
+
const { size, searchValue } = useEntityComboboxContext();
|
|
53
|
+
return (
|
|
54
|
+
<UserItem
|
|
55
|
+
userValue={userValue}
|
|
56
|
+
isSelected={isSelected}
|
|
57
|
+
className={className}
|
|
58
|
+
size={size}
|
|
59
|
+
searchKeyword={searchValue}
|
|
60
|
+
disabled={disabled}
|
|
61
|
+
isConverting={isConverting}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const UserSelectTagWrapper = ({
|
|
67
|
+
userValue,
|
|
68
|
+
onClose,
|
|
69
|
+
className,
|
|
70
|
+
disabled,
|
|
71
|
+
isLoading,
|
|
72
|
+
accountType,
|
|
73
|
+
}: {
|
|
74
|
+
userValue: UserSelectItemValue;
|
|
75
|
+
onClose: (value: UserSelectItemValue, e: React.MouseEvent) => void;
|
|
76
|
+
className?: string;
|
|
77
|
+
disabled?: boolean;
|
|
78
|
+
isLoading?: boolean;
|
|
79
|
+
accountType?: 'apaas' | 'lark';
|
|
80
|
+
}) => {
|
|
81
|
+
const { size } = useEntityComboboxContext();
|
|
82
|
+
return (
|
|
83
|
+
<UserSelectTag
|
|
84
|
+
userValue={userValue}
|
|
85
|
+
onClose={onClose}
|
|
86
|
+
className={className}
|
|
87
|
+
size={size}
|
|
88
|
+
disabled={disabled}
|
|
89
|
+
isLoading={isLoading}
|
|
90
|
+
accountType={accountType}
|
|
91
|
+
/>
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const UserSelect: React.FC<UserSelectProps> = (props) => {
|
|
96
|
+
const {
|
|
97
|
+
size = 'medium',
|
|
98
|
+
triggerType = 'button',
|
|
99
|
+
renderTrigger,
|
|
100
|
+
multiple = false,
|
|
101
|
+
value,
|
|
102
|
+
valueType = 'string',
|
|
103
|
+
accountType = 'apaas',
|
|
104
|
+
defaultValue,
|
|
105
|
+
onChange,
|
|
106
|
+
defaultOpen,
|
|
107
|
+
disabled,
|
|
108
|
+
autoFocus,
|
|
109
|
+
required,
|
|
110
|
+
name,
|
|
111
|
+
className,
|
|
112
|
+
classNames,
|
|
113
|
+
placeholder = '请选择',
|
|
114
|
+
emptyText = '没有匹配结果,换个关键词试试吧',
|
|
115
|
+
tagClosable,
|
|
116
|
+
maxTagCount,
|
|
117
|
+
onSelect,
|
|
118
|
+
onDeselect,
|
|
119
|
+
onClear,
|
|
120
|
+
onFocus,
|
|
121
|
+
onBlur,
|
|
122
|
+
slotProps,
|
|
123
|
+
getOptionDisabled,
|
|
124
|
+
} = props;
|
|
125
|
+
|
|
126
|
+
// 使用 useUserValue 处理不同类型的 value(包括 defaultValue)
|
|
127
|
+
const { internalValue, isLoading, toExternalValue } = useUserValue(
|
|
128
|
+
value ?? null,
|
|
129
|
+
multiple,
|
|
130
|
+
accountType,
|
|
131
|
+
valueType,
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
// 始终追踪最新 internalValue,避免异步开户回调中闭包捕获过期值
|
|
135
|
+
const internalValueRef = useRef(internalValue);
|
|
136
|
+
internalValueRef.current = internalValue;
|
|
137
|
+
|
|
138
|
+
// 同样处理 defaultValue,确保 ID 字符串类型的 defaultValue 也能正确解析
|
|
139
|
+
const { internalValue: internalDefaultValue } = useUserValue(
|
|
140
|
+
defaultValue ?? null,
|
|
141
|
+
multiple,
|
|
142
|
+
accountType,
|
|
143
|
+
valueType,
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
const baseFetchFn = useMemo(() => createUsersFetcher({ accountType }), [accountType]);
|
|
147
|
+
|
|
148
|
+
// 正在开户中的用户 ID 集合
|
|
149
|
+
const [convertingSet, setConvertingSet] = useState<Set<string>>(() => new Set());
|
|
150
|
+
|
|
151
|
+
// 已开户用户映射:旧 ID → 转换后的 UserSelectItemValue,用于回写到待选列表
|
|
152
|
+
const [convertedMap, setConvertedMap] = useState<Map<string, UserSelectItemValue>>(
|
|
153
|
+
() => new Map(),
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
// 包装 fetchFn,将已开户用户替换到搜索结果中
|
|
157
|
+
// convertedMap 变化 → fetchFn 引用变化 → useFetchData 自动 refetch
|
|
158
|
+
const fetchFn = useCallback(
|
|
159
|
+
async (search: string) => {
|
|
160
|
+
const result = await baseFetchFn(search);
|
|
161
|
+
if (convertedMap.size === 0) return result;
|
|
162
|
+
return {
|
|
163
|
+
...result,
|
|
164
|
+
items: result.items.map((item) => convertedMap.get(item.id) ?? item),
|
|
165
|
+
};
|
|
166
|
+
},
|
|
167
|
+
[baseFetchFn, convertedMap],
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
// 标记是否有即将开户的用户(用于在 handleOpenChange 中阻止关闭)
|
|
171
|
+
// 时序:handleChange(设置标记)→ handleOpenChange(检查标记)→ handleSelect(开始开户)
|
|
172
|
+
const pendingConvertRef = useRef(false);
|
|
173
|
+
|
|
174
|
+
// 受控 open 状态:开户期间阻止 popover 关闭
|
|
175
|
+
const [open, setOpen] = useState(defaultOpen ?? false);
|
|
176
|
+
const handleOpenChange = useCallback((nextOpen: boolean) => {
|
|
177
|
+
// 有正在开户或即将开户的用户时,不允许关闭下拉
|
|
178
|
+
if (!nextOpen && pendingConvertRef.current) return;
|
|
179
|
+
setOpen(nextOpen);
|
|
180
|
+
}, []);
|
|
181
|
+
|
|
182
|
+
// 开户中的用户禁止再次点击
|
|
183
|
+
const mergedGetOptionDisabled = useCallback(
|
|
184
|
+
(option: UserSelectItemValue) => {
|
|
185
|
+
if (convertingSet.has(option.id)) return true;
|
|
186
|
+
if (isUnregisteredExternalContact(option)) return false;
|
|
187
|
+
return getOptionDisabled?.(option) ?? false;
|
|
188
|
+
},
|
|
189
|
+
[getOptionDisabled, convertingSet],
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* onChange 门卫:过滤掉未注册外部联系人,不允许未开户用户进入选中列表。
|
|
194
|
+
* 同时设置 pendingConvertRef 标记,阻止 handleOpenChange 关闭下拉。
|
|
195
|
+
*/
|
|
196
|
+
const handleChange = useCallback(
|
|
197
|
+
(newValue: UserSelectItemValue | UserSelectItemValue[] | null) => {
|
|
198
|
+
if (!onChange) return;
|
|
199
|
+
|
|
200
|
+
if (multiple && Array.isArray(newValue)) {
|
|
201
|
+
const hasUnregistered = newValue.some((u) => isUnregisteredExternalContact(u));
|
|
202
|
+
if (hasUnregistered) {
|
|
203
|
+
pendingConvertRef.current = true;
|
|
204
|
+
}
|
|
205
|
+
const filtered = newValue.filter((u) => !isUnregisteredExternalContact(u));
|
|
206
|
+
const externalValue = toExternalValue(filtered, multiple);
|
|
207
|
+
(onChange as (value: unknown) => void)(externalValue);
|
|
208
|
+
} else if (!multiple) {
|
|
209
|
+
const user = newValue as UserSelectItemValue | null;
|
|
210
|
+
if (user && isUnregisteredExternalContact(user)) {
|
|
211
|
+
// 不允许未注册用户进入选中值,标记即将开户
|
|
212
|
+
pendingConvertRef.current = true;
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const externalValue = toExternalValue(newValue, multiple);
|
|
216
|
+
(onChange as (value: unknown) => void)(externalValue);
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
[onChange, multiple, toExternalValue],
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* onSelect 拦截:检测未注册外部联系人,触发开户流程。
|
|
224
|
+
* 开户成功后手动调用 onChange 回填转换后的用户。
|
|
225
|
+
*/
|
|
226
|
+
const handleSelect = useCallback(
|
|
227
|
+
(user: UserSelectItemValue) => {
|
|
228
|
+
if (!isUnregisteredExternalContact(user)) {
|
|
229
|
+
onSelect?.(user);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const larkUserID = user.raw?.larkUserId;
|
|
234
|
+
if (!larkUserID) return;
|
|
235
|
+
if (convertingSet.has(user.id)) return;
|
|
236
|
+
|
|
237
|
+
setConvertingSet((prev) => new Set(prev).add(user.id));
|
|
238
|
+
// pendingConvertRef 已在 handleChange 中设置,此处转为正式开户状态
|
|
239
|
+
|
|
240
|
+
void (async () => {
|
|
241
|
+
try {
|
|
242
|
+
const result = await convertExternalContact(larkUserID);
|
|
243
|
+
const { userInfo } = result.data;
|
|
244
|
+
const forceUserID = String(userInfo.userID);
|
|
245
|
+
const convertedUser: UserSelectItemValue = {
|
|
246
|
+
...user,
|
|
247
|
+
id: forceUserID,
|
|
248
|
+
raw: user.raw ? { ...user.raw, user_id: forceUserID } : undefined,
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
// 回写到待选列表:触发 fetchFn 引用变化 → useFetchData refetch → 列表更新
|
|
252
|
+
setConvertedMap((prev) => new Map(prev).set(user.id, convertedUser));
|
|
253
|
+
|
|
254
|
+
onSelect?.(convertedUser);
|
|
255
|
+
if (onChange) {
|
|
256
|
+
if (multiple) {
|
|
257
|
+
const current = Array.isArray(internalValueRef.current)
|
|
258
|
+
? internalValueRef.current
|
|
259
|
+
: [];
|
|
260
|
+
const externalValue = toExternalValue([...current, convertedUser], multiple);
|
|
261
|
+
(onChange as (value: unknown) => void)(externalValue);
|
|
262
|
+
} else {
|
|
263
|
+
const externalValue = toExternalValue(convertedUser, multiple);
|
|
264
|
+
(onChange as (value: unknown) => void)(externalValue);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
// 开户成功后关闭下拉(单选)
|
|
268
|
+
if (!multiple) {
|
|
269
|
+
pendingConvertRef.current = false;
|
|
270
|
+
setOpen(false);
|
|
271
|
+
}
|
|
272
|
+
} catch {
|
|
273
|
+
toast.error('外部用户添加失败');
|
|
274
|
+
} finally {
|
|
275
|
+
setConvertingSet((prev) => {
|
|
276
|
+
const next = new Set(prev);
|
|
277
|
+
next.delete(user.id);
|
|
278
|
+
// 所有开户完成后清除标记
|
|
279
|
+
if (next.size === 0) {
|
|
280
|
+
pendingConvertRef.current = false;
|
|
281
|
+
}
|
|
282
|
+
return next;
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
})();
|
|
286
|
+
},
|
|
287
|
+
[onSelect, onChange, multiple, toExternalValue, convertingSet],
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
const renderTagWithLoading = useCallback(
|
|
291
|
+
(
|
|
292
|
+
userValue: UserSelectItemValue,
|
|
293
|
+
onClose: (value: UserSelectItemValue, e: React.MouseEvent) => void,
|
|
294
|
+
tagDisabled?: boolean,
|
|
295
|
+
) => (
|
|
296
|
+
<UserSelectTagWrapper
|
|
297
|
+
key={userValue.id}
|
|
298
|
+
userValue={userValue}
|
|
299
|
+
onClose={onClose}
|
|
300
|
+
disabled={tagDisabled}
|
|
301
|
+
isLoading={isLoading}
|
|
302
|
+
accountType={accountType}
|
|
303
|
+
/>
|
|
304
|
+
),
|
|
305
|
+
[isLoading, accountType],
|
|
306
|
+
);
|
|
307
|
+
|
|
308
|
+
return (
|
|
309
|
+
<BaseCombobox
|
|
310
|
+
autoFocus={autoFocus}
|
|
311
|
+
className={className}
|
|
312
|
+
classNames={classNames}
|
|
313
|
+
debounce={300}
|
|
314
|
+
open={open}
|
|
315
|
+
onOpenChange={handleOpenChange}
|
|
316
|
+
defaultValue={internalDefaultValue}
|
|
317
|
+
disabled={disabled}
|
|
318
|
+
emptyText={emptyText}
|
|
319
|
+
fetchFn={fetchFn}
|
|
320
|
+
getItemLabel={(userValue) => userValue.name}
|
|
321
|
+
getItemValue={(userValue) => userValue}
|
|
322
|
+
getOptionDisabled={mergedGetOptionDisabled}
|
|
323
|
+
maxTagCount={maxTagCount}
|
|
324
|
+
multiple={multiple}
|
|
325
|
+
name={name}
|
|
326
|
+
onBlur={onBlur}
|
|
327
|
+
onChange={handleChange}
|
|
328
|
+
onClear={onClear}
|
|
329
|
+
onDeselect={onDeselect}
|
|
330
|
+
onFocus={onFocus}
|
|
331
|
+
onSelect={handleSelect}
|
|
332
|
+
placeholder={placeholder}
|
|
333
|
+
renderItem={(userValue, isSelected, itemClassName, itemDisabled) => (
|
|
334
|
+
<UserItemWrapper
|
|
335
|
+
key={userValue.id}
|
|
336
|
+
userValue={userValue}
|
|
337
|
+
isSelected={isSelected}
|
|
338
|
+
className={itemClassName}
|
|
339
|
+
disabled={itemDisabled}
|
|
340
|
+
isConverting={convertingSet.has(userValue.id)}
|
|
341
|
+
/>
|
|
342
|
+
)}
|
|
343
|
+
renderTag={renderTagWithLoading}
|
|
344
|
+
renderTrigger={renderTrigger}
|
|
345
|
+
required={required}
|
|
346
|
+
searchPlaceholder=""
|
|
347
|
+
showSearch
|
|
348
|
+
size={size}
|
|
349
|
+
slotProps={slotProps}
|
|
350
|
+
tagClosable={tagClosable}
|
|
351
|
+
triggerType={triggerType}
|
|
352
|
+
value={internalValue}
|
|
353
|
+
/>
|
|
354
|
+
);
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
export { type UserSelectItemValue as UserValue };
|
|
358
|
+
|
|
359
|
+
export { ItemPill } from '@client/src/components/business-ui/entity-combobox/item-pill';
|