@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,246 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
ClassNamesConfig,
|
|
5
|
+
ComboboxSize,
|
|
6
|
+
ItemValue,
|
|
7
|
+
PopoverSlotProps,
|
|
8
|
+
TriggerRenderProps,
|
|
9
|
+
TriggerType,
|
|
10
|
+
} from '@client/src/components/business-ui/entity-combobox/shared-types';
|
|
11
|
+
|
|
12
|
+
// 重新导出共享类型
|
|
13
|
+
export type {
|
|
14
|
+
ItemValue,
|
|
15
|
+
TriggerType,
|
|
16
|
+
TriggerRenderProps,
|
|
17
|
+
ClassNamesConfig,
|
|
18
|
+
PopoverSlotProps,
|
|
19
|
+
ComboboxSize,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* EntityCombobox 组件的 Props
|
|
24
|
+
*/
|
|
25
|
+
export type EntityComboboxProps<
|
|
26
|
+
T = unknown,
|
|
27
|
+
TRaw = unknown,
|
|
28
|
+
TValue extends ItemValue<TRaw> = ItemValue<TRaw>,
|
|
29
|
+
> = {
|
|
30
|
+
// 尺寸
|
|
31
|
+
size?: ComboboxSize;
|
|
32
|
+
|
|
33
|
+
// 数据获取
|
|
34
|
+
fetchFn: (search: string) => Promise<{ items: T[] }>;
|
|
35
|
+
|
|
36
|
+
// 受控/非受控
|
|
37
|
+
multiple?: boolean;
|
|
38
|
+
value?: TValue | TValue[] | null;
|
|
39
|
+
defaultValue?: TValue | TValue[] | null;
|
|
40
|
+
onChange?: (value: TValue | TValue[] | null) => void;
|
|
41
|
+
|
|
42
|
+
// 弹层控制
|
|
43
|
+
open?: boolean;
|
|
44
|
+
defaultOpen?: boolean;
|
|
45
|
+
onOpenChange?: (open: boolean) => void;
|
|
46
|
+
|
|
47
|
+
// 配置
|
|
48
|
+
pageSize?: number;
|
|
49
|
+
debounce?: number;
|
|
50
|
+
disabled?: boolean;
|
|
51
|
+
|
|
52
|
+
// 回调
|
|
53
|
+
onSelect?: (value: TValue) => void;
|
|
54
|
+
onDeselect?: (value: TValue) => void;
|
|
55
|
+
onSearch?: (value: string) => void;
|
|
56
|
+
onClear?: () => void;
|
|
57
|
+
|
|
58
|
+
children: ReactNode;
|
|
59
|
+
|
|
60
|
+
// 转换函数
|
|
61
|
+
getItemValue: (item: T) => TValue;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* EntityCombobox Context 值
|
|
66
|
+
*/
|
|
67
|
+
export type EntityComboboxContextValue<
|
|
68
|
+
T = unknown,
|
|
69
|
+
TRaw = unknown,
|
|
70
|
+
TValue extends ItemValue<TRaw> = ItemValue<TRaw>,
|
|
71
|
+
> = {
|
|
72
|
+
// 状态
|
|
73
|
+
open: boolean;
|
|
74
|
+
setOpen: (open: boolean) => void;
|
|
75
|
+
searchValue: string;
|
|
76
|
+
setSearchValue: (value: string) => void;
|
|
77
|
+
selectedValue: TValue | TValue[] | null;
|
|
78
|
+
debouncedSearch: string;
|
|
79
|
+
|
|
80
|
+
// 方法
|
|
81
|
+
handleSelect: (value: TValue) => void;
|
|
82
|
+
handleDeselect: (value: TValue) => void;
|
|
83
|
+
handleClear: () => void;
|
|
84
|
+
|
|
85
|
+
// 数据
|
|
86
|
+
data: T[];
|
|
87
|
+
isFetching: boolean;
|
|
88
|
+
isPending: boolean;
|
|
89
|
+
isError: boolean;
|
|
90
|
+
refetch: () => void;
|
|
91
|
+
|
|
92
|
+
// 配置
|
|
93
|
+
multiple: boolean;
|
|
94
|
+
disabled: boolean;
|
|
95
|
+
size: ComboboxSize;
|
|
96
|
+
isSuccess?: boolean;
|
|
97
|
+
fetchStatus?: string;
|
|
98
|
+
isPlaceholderData?: boolean;
|
|
99
|
+
|
|
100
|
+
// 转换函数
|
|
101
|
+
getItemValue: (item: T) => TValue;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* BaseCombobox 组件的 Props
|
|
106
|
+
*/
|
|
107
|
+
export type BaseComboboxProps<
|
|
108
|
+
T = unknown,
|
|
109
|
+
TRaw = unknown,
|
|
110
|
+
TValue extends ItemValue<TRaw> = ItemValue<TRaw>,
|
|
111
|
+
> = {
|
|
112
|
+
// 尺寸
|
|
113
|
+
size?: ComboboxSize;
|
|
114
|
+
|
|
115
|
+
// 数据获取
|
|
116
|
+
fetchFn: (search: string) => Promise<{ items: T[] }>;
|
|
117
|
+
|
|
118
|
+
// 触发器
|
|
119
|
+
triggerType?: TriggerType;
|
|
120
|
+
renderTrigger?: (props: TriggerRenderProps<TRaw>) => ReactNode;
|
|
121
|
+
|
|
122
|
+
// 受控/非受控
|
|
123
|
+
multiple?: boolean;
|
|
124
|
+
value?: TValue | TValue[] | null;
|
|
125
|
+
defaultValue?: TValue | TValue[] | null;
|
|
126
|
+
onChange?: (value: TValue | TValue[] | null) => void;
|
|
127
|
+
|
|
128
|
+
// 弹层控制
|
|
129
|
+
open?: boolean;
|
|
130
|
+
defaultOpen?: boolean;
|
|
131
|
+
onOpenChange?: (open: boolean) => void;
|
|
132
|
+
|
|
133
|
+
// 配置
|
|
134
|
+
debounce?: number;
|
|
135
|
+
disabled?: boolean;
|
|
136
|
+
showSearch?: boolean;
|
|
137
|
+
autoFocus?: boolean;
|
|
138
|
+
required?: boolean;
|
|
139
|
+
name?: string;
|
|
140
|
+
|
|
141
|
+
// 渲染函数
|
|
142
|
+
renderItem: (
|
|
143
|
+
item: T,
|
|
144
|
+
isSelected: boolean,
|
|
145
|
+
className?: string,
|
|
146
|
+
disabled?: boolean,
|
|
147
|
+
) => ReactNode;
|
|
148
|
+
renderTag?: (
|
|
149
|
+
value: TValue,
|
|
150
|
+
onClose: (value: TValue, e: React.MouseEvent) => void,
|
|
151
|
+
disabled?: boolean,
|
|
152
|
+
) => ReactNode;
|
|
153
|
+
/**
|
|
154
|
+
* 判断选项是否禁用
|
|
155
|
+
* @param value 选项值
|
|
156
|
+
* @returns 如果返回 true,该选项将被禁用
|
|
157
|
+
*/
|
|
158
|
+
getOptionDisabled?: (value: TValue) => boolean;
|
|
159
|
+
getItemLabel?: (item: T) => string;
|
|
160
|
+
|
|
161
|
+
// Placeholder
|
|
162
|
+
placeholder?: string;
|
|
163
|
+
searchPlaceholder?: string;
|
|
164
|
+
emptyText?: string;
|
|
165
|
+
loadingText?: string;
|
|
166
|
+
|
|
167
|
+
// 样式
|
|
168
|
+
className?: string;
|
|
169
|
+
classNames?: ClassNamesConfig;
|
|
170
|
+
|
|
171
|
+
// 标签(多选)
|
|
172
|
+
tagClosable?: boolean;
|
|
173
|
+
maxTagCount?: number | 'responsive';
|
|
174
|
+
maxTagTextLength?: number;
|
|
175
|
+
|
|
176
|
+
// Popover 配置
|
|
177
|
+
placement?: 'top' | 'bottom' | 'left' | 'right';
|
|
178
|
+
align?: 'start' | 'center' | 'end';
|
|
179
|
+
sideOffset?: number;
|
|
180
|
+
|
|
181
|
+
// 回调
|
|
182
|
+
onSelect?: (value: TValue) => void;
|
|
183
|
+
onDeselect?: (value: TValue) => void;
|
|
184
|
+
onSearch?: (value: string) => void;
|
|
185
|
+
onClear?: () => void;
|
|
186
|
+
onFocus?: (event: React.FocusEvent<HTMLElement>) => void;
|
|
187
|
+
onBlur?: (event: React.FocusEvent<HTMLElement>) => void;
|
|
188
|
+
|
|
189
|
+
// 转换函数
|
|
190
|
+
getItemValue?: (item: T) => TValue;
|
|
191
|
+
|
|
192
|
+
slotProps?: PopoverSlotProps;
|
|
193
|
+
children?: ReactNode;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* PopoverWrapper 组件的 Props
|
|
198
|
+
*/
|
|
199
|
+
export type PopoverWrapperProps<
|
|
200
|
+
T = unknown,
|
|
201
|
+
TRaw = unknown,
|
|
202
|
+
TValue extends ItemValue<TRaw> = ItemValue<TRaw>,
|
|
203
|
+
> = {
|
|
204
|
+
size?: ComboboxSize;
|
|
205
|
+
triggerType?: TriggerType;
|
|
206
|
+
renderTrigger?: (props: TriggerRenderProps<TRaw>) => ReactNode;
|
|
207
|
+
placeholder?: string;
|
|
208
|
+
maxTagCount?: number | 'responsive';
|
|
209
|
+
maxTagTextLength?: number;
|
|
210
|
+
tagClosable?: boolean;
|
|
211
|
+
className?: string;
|
|
212
|
+
classNames?: ClassNamesConfig;
|
|
213
|
+
placement?: 'top' | 'bottom' | 'left' | 'right';
|
|
214
|
+
align?: 'start' | 'center' | 'end';
|
|
215
|
+
sideOffset?: number;
|
|
216
|
+
showSearch?: boolean;
|
|
217
|
+
searchPlaceholder?: string;
|
|
218
|
+
renderItem: (
|
|
219
|
+
item: T,
|
|
220
|
+
isSelected: boolean,
|
|
221
|
+
className?: string,
|
|
222
|
+
disabled?: boolean,
|
|
223
|
+
) => ReactNode;
|
|
224
|
+
renderTag?: (
|
|
225
|
+
value: TValue,
|
|
226
|
+
onClose: (value: TValue, e: React.MouseEvent) => void,
|
|
227
|
+
disabled?: boolean,
|
|
228
|
+
) => ReactNode;
|
|
229
|
+
getItemValue: (item: T) => TValue;
|
|
230
|
+
getOptionDisabled?: (value: TValue) => boolean;
|
|
231
|
+
emptyText?: string;
|
|
232
|
+
loadingText?: string;
|
|
233
|
+
onFocus?: (event: React.FocusEvent<HTMLElement>) => void;
|
|
234
|
+
onBlur?: (event: React.FocusEvent<HTMLElement>) => void;
|
|
235
|
+
slotProps?: PopoverSlotProps;
|
|
236
|
+
children?: ReactNode;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* 国际化文本类型
|
|
241
|
+
*/
|
|
242
|
+
export type I18nText = {
|
|
243
|
+
zh_cn: string;
|
|
244
|
+
en_us?: string;
|
|
245
|
+
ja_jp?: string;
|
|
246
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { logger } from '@lark-apaas/client-toolkit/logger';
|
|
4
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
5
|
+
|
|
6
|
+
export type UseFetchDataOptions<T> = {
|
|
7
|
+
fetchFn: (search: string) => Promise<{ items: T[] }>;
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
search: string;
|
|
10
|
+
onSearch?: (search: string) => void;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type UseFetchDataResult<T> = {
|
|
14
|
+
data: T[] | undefined;
|
|
15
|
+
isFetching: boolean;
|
|
16
|
+
isError: boolean;
|
|
17
|
+
isSuccess: boolean;
|
|
18
|
+
fetchStatus: 'fetching' | 'idle';
|
|
19
|
+
refetch: () => Promise<void>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export function useFetchData<T>({
|
|
23
|
+
fetchFn,
|
|
24
|
+
enabled,
|
|
25
|
+
search,
|
|
26
|
+
onSearch,
|
|
27
|
+
}: UseFetchDataOptions<T>): UseFetchDataResult<T> {
|
|
28
|
+
const [data, setData] = useState<T[] | undefined>();
|
|
29
|
+
const [isFetching, setIsFetching] = useState(false);
|
|
30
|
+
const [isError, setIsError] = useState(false);
|
|
31
|
+
const [isSuccess, setIsSuccess] = useState(false);
|
|
32
|
+
|
|
33
|
+
const fetchData = useCallback(async () => {
|
|
34
|
+
if (!enabled || search.trim() === '') {
|
|
35
|
+
setData([]);
|
|
36
|
+
setIsSuccess(true);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
setIsFetching(true);
|
|
42
|
+
setIsError(false);
|
|
43
|
+
|
|
44
|
+
const result = await fetchFn(search);
|
|
45
|
+
|
|
46
|
+
setData(result?.items || []);
|
|
47
|
+
setIsSuccess(true);
|
|
48
|
+
setIsError(false);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
logger.error('Failed to fetch data:', error);
|
|
51
|
+
setIsError(true);
|
|
52
|
+
setIsSuccess(false);
|
|
53
|
+
setData([]);
|
|
54
|
+
} finally {
|
|
55
|
+
setIsFetching(false);
|
|
56
|
+
}
|
|
57
|
+
}, [enabled, search, fetchFn]);
|
|
58
|
+
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (enabled && search.trim() !== '') {
|
|
61
|
+
fetchData();
|
|
62
|
+
} else {
|
|
63
|
+
setData(undefined);
|
|
64
|
+
setIsSuccess(true);
|
|
65
|
+
}
|
|
66
|
+
}, [search, enabled, fetchData]);
|
|
67
|
+
|
|
68
|
+
// 单独处理 onSearch 回调
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
onSearch?.(search);
|
|
71
|
+
}, [search, onSearch]);
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
data,
|
|
75
|
+
isFetching,
|
|
76
|
+
isError,
|
|
77
|
+
isSuccess,
|
|
78
|
+
fetchStatus: isFetching ? 'fetching' : 'idle',
|
|
79
|
+
refetch: fetchData,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
4
|
+
|
|
5
|
+
export type UseInfiniteScrollOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* 加载更多数据的回调函数
|
|
8
|
+
*/
|
|
9
|
+
onLoadMore: () => void;
|
|
10
|
+
/**
|
|
11
|
+
* 是否还有更多数据
|
|
12
|
+
*/
|
|
13
|
+
hasMore: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* 是否正在加载中
|
|
16
|
+
*/
|
|
17
|
+
isLoading: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* 是否启用无限滚动
|
|
20
|
+
* @default true
|
|
21
|
+
*/
|
|
22
|
+
enabled?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* IntersectionObserver 的 threshold
|
|
25
|
+
* @default 0.1
|
|
26
|
+
*/
|
|
27
|
+
threshold?: number;
|
|
28
|
+
/**
|
|
29
|
+
* IntersectionObserver 的 rootMargin,用于提前触发加载
|
|
30
|
+
* @default '50px'
|
|
31
|
+
*/
|
|
32
|
+
rootMargin?: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type UseInfiniteScrollResult = {
|
|
36
|
+
/**
|
|
37
|
+
* 绑定到触发元素的 ref
|
|
38
|
+
*/
|
|
39
|
+
triggerRef: React.RefObject<HTMLDivElement | null>;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 无限滚动加载 hook
|
|
44
|
+
* 使用 IntersectionObserver 检测滚动触底,自动触发加载更多
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```tsx
|
|
48
|
+
* const { triggerRef } = useInfiniteScroll({
|
|
49
|
+
* onLoadMore: fetchMore,
|
|
50
|
+
* hasMore,
|
|
51
|
+
* isLoading: isFetchingMore,
|
|
52
|
+
* })
|
|
53
|
+
*
|
|
54
|
+
* return (
|
|
55
|
+
* <ScrollArea>
|
|
56
|
+
* {items.map(item => <Item key={item.id} />)}
|
|
57
|
+
* <div ref={triggerRef} />
|
|
58
|
+
* </ScrollArea>
|
|
59
|
+
* )
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export function useInfiniteScroll({
|
|
63
|
+
onLoadMore,
|
|
64
|
+
hasMore,
|
|
65
|
+
isLoading,
|
|
66
|
+
enabled = true,
|
|
67
|
+
threshold = 0.1,
|
|
68
|
+
rootMargin = '50px',
|
|
69
|
+
}: UseInfiniteScrollOptions): UseInfiniteScrollResult {
|
|
70
|
+
const triggerRef = useRef<HTMLDivElement>(null);
|
|
71
|
+
|
|
72
|
+
const handleIntersect = useCallback(
|
|
73
|
+
(entries: IntersectionObserverEntry[]) => {
|
|
74
|
+
const [entry] = entries;
|
|
75
|
+
if (entry?.isIntersecting && hasMore && !isLoading && enabled) {
|
|
76
|
+
onLoadMore();
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
[hasMore, isLoading, enabled, onLoadMore],
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
const element = triggerRef.current;
|
|
84
|
+
if (!element || !enabled) return;
|
|
85
|
+
|
|
86
|
+
const observer = new IntersectionObserver(handleIntersect, {
|
|
87
|
+
threshold,
|
|
88
|
+
rootMargin,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
observer.observe(element);
|
|
92
|
+
|
|
93
|
+
return () => {
|
|
94
|
+
observer.disconnect();
|
|
95
|
+
};
|
|
96
|
+
}, [handleIntersect, threshold, rootMargin, enabled]);
|
|
97
|
+
|
|
98
|
+
return { triggerRef };
|
|
99
|
+
}
|
package/template/client/src/components/business-ui/entity-combobox/use-popover-outside-click.tsx
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 处理点击外部关闭浮层的 Hook
|
|
5
|
+
* 仅在 search 模式下使用
|
|
6
|
+
*/
|
|
7
|
+
export function usePopoverOutsideClick(
|
|
8
|
+
open: boolean,
|
|
9
|
+
enabled: boolean,
|
|
10
|
+
popoverRef: React.RefObject<HTMLElement | null>,
|
|
11
|
+
triggerRef: React.RefObject<HTMLElement | null>,
|
|
12
|
+
onClose: () => void,
|
|
13
|
+
) {
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!open || !enabled) return;
|
|
16
|
+
|
|
17
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
18
|
+
const target = event.target as Node;
|
|
19
|
+
if (
|
|
20
|
+
popoverRef.current &&
|
|
21
|
+
triggerRef.current &&
|
|
22
|
+
!popoverRef.current.contains(target) &&
|
|
23
|
+
!triggerRef.current.contains(target)
|
|
24
|
+
) {
|
|
25
|
+
onClose();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
30
|
+
return () => document.removeEventListener('mousedown', handleClickOutside);
|
|
31
|
+
}, [open, enabled, popoverRef, triggerRef, onClose]);
|
|
32
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { useFormGlobalProps } from '@client/src/components/business-ui/form/context';
|
|
2
|
+
import { FieldLayout } from '@client/src/components/business-ui/form/field-layout';
|
|
3
|
+
import { useFieldContext } from '@client/src/components/business-ui/form/hooks/form-context';
|
|
4
|
+
import {
|
|
5
|
+
useFieldName,
|
|
6
|
+
useFieldValidation,
|
|
7
|
+
} from '@client/src/components/business-ui/form/hooks/form-utils';
|
|
8
|
+
import type {
|
|
9
|
+
CommonFieldProps,
|
|
10
|
+
FieldLayoutClassNames,
|
|
11
|
+
FieldLayoutStyles,
|
|
12
|
+
} from '@client/src/components/business-ui/form/types';
|
|
13
|
+
import { Checkbox } from '@client/src/components/ui/checkbox';
|
|
14
|
+
import { Field, FieldLabel } from '@client/src/components/ui/field';
|
|
15
|
+
|
|
16
|
+
type CheckboxFieldProps = CommonFieldProps &
|
|
17
|
+
React.ComponentProps<typeof Checkbox> & {
|
|
18
|
+
options?: {
|
|
19
|
+
label: string;
|
|
20
|
+
value: boolean | 'indeterminate';
|
|
21
|
+
}[];
|
|
22
|
+
classNames?: Partial<FieldLayoutClassNames & Record<'checkbox', string>>;
|
|
23
|
+
styles?: Partial<
|
|
24
|
+
FieldLayoutStyles & Record<'checkbox', React.CSSProperties>
|
|
25
|
+
>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export function CheckboxField({
|
|
29
|
+
label,
|
|
30
|
+
description,
|
|
31
|
+
disabled,
|
|
32
|
+
required,
|
|
33
|
+
layout,
|
|
34
|
+
classNames,
|
|
35
|
+
styles,
|
|
36
|
+
...rest
|
|
37
|
+
}: CheckboxFieldProps) {
|
|
38
|
+
const field = useFieldContext<boolean | 'indeterminate'>();
|
|
39
|
+
const { layout: formLayout } = useFormGlobalProps();
|
|
40
|
+
const { isInvalid, errorMessage } = useFieldValidation();
|
|
41
|
+
const name = useFieldName();
|
|
42
|
+
|
|
43
|
+
const { checkbox: checkboxClassName, ...fieldLayoutClassNames } =
|
|
44
|
+
classNames ?? {};
|
|
45
|
+
const { checkbox: checkboxStyle, ...fieldLayoutStyles } = styles ?? {};
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<FieldLayout
|
|
49
|
+
description={description}
|
|
50
|
+
isInvalid={isInvalid}
|
|
51
|
+
layout={layout ?? formLayout ?? 'vertical'}
|
|
52
|
+
required={required ?? false}
|
|
53
|
+
classNames={fieldLayoutClassNames ?? {}}
|
|
54
|
+
styles={fieldLayoutStyles ?? {}}
|
|
55
|
+
errorMessage={errorMessage}
|
|
56
|
+
name={name}
|
|
57
|
+
>
|
|
58
|
+
<Field orientation="horizontal">
|
|
59
|
+
<Checkbox
|
|
60
|
+
{...rest}
|
|
61
|
+
id={name}
|
|
62
|
+
name={name}
|
|
63
|
+
className={checkboxClassName ?? ''}
|
|
64
|
+
style={checkboxStyle ?? {}}
|
|
65
|
+
required={required ?? false}
|
|
66
|
+
aria-invalid={isInvalid}
|
|
67
|
+
checked={field.state.value}
|
|
68
|
+
disabled={disabled}
|
|
69
|
+
onCheckedChange={(checked) => {
|
|
70
|
+
field.handleChange(checked);
|
|
71
|
+
}}
|
|
72
|
+
/>
|
|
73
|
+
<FieldLabel
|
|
74
|
+
style={styles?.label}
|
|
75
|
+
className={classNames?.['label']}
|
|
76
|
+
htmlFor={name}
|
|
77
|
+
>
|
|
78
|
+
{label}
|
|
79
|
+
</FieldLabel>
|
|
80
|
+
</Field>
|
|
81
|
+
</FieldLayout>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
export interface FormGlobalProps {
|
|
6
|
+
layout: 'vertical' | 'responsive' | 'horizontal';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type FormContextType = FormGlobalProps | null;
|
|
10
|
+
|
|
11
|
+
export const FormContext = React.createContext<FormContextType>(null);
|
|
12
|
+
|
|
13
|
+
export const useFormContext = () => {
|
|
14
|
+
const context = React.useContext(FormContext);
|
|
15
|
+
if (!context) {
|
|
16
|
+
throw new Error('useFormContext must be used within a FormProvider');
|
|
17
|
+
}
|
|
18
|
+
return context as FormGlobalProps;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const FormProvider: React.FC<{
|
|
22
|
+
layout: 'vertical' | 'responsive' | 'horizontal';
|
|
23
|
+
children: React.ReactNode;
|
|
24
|
+
}> = ({ layout, children }) => {
|
|
25
|
+
const value = React.useMemo(
|
|
26
|
+
() => ({
|
|
27
|
+
layout: layout,
|
|
28
|
+
}),
|
|
29
|
+
[layout],
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
return <FormContext.Provider value={value}>{children}</FormContext.Provider>;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const useFormGlobalProps = () => {
|
|
36
|
+
const context = useFormContext();
|
|
37
|
+
return context;
|
|
38
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Asterisk } from 'lucide-react';
|
|
2
|
+
|
|
3
|
+
import type { FieldLayoutProps } from '@client/src/components/business-ui/form/types';
|
|
4
|
+
import { cn } from '@/lib/utils';
|
|
5
|
+
import {
|
|
6
|
+
Field,
|
|
7
|
+
FieldContent,
|
|
8
|
+
FieldDescription,
|
|
9
|
+
FieldError,
|
|
10
|
+
FieldLabel,
|
|
11
|
+
} from '@client/src/components/ui/field';
|
|
12
|
+
|
|
13
|
+
export function FieldLayout({
|
|
14
|
+
label,
|
|
15
|
+
children,
|
|
16
|
+
description,
|
|
17
|
+
layout = 'vertical',
|
|
18
|
+
isInvalid,
|
|
19
|
+
errorMessage,
|
|
20
|
+
name,
|
|
21
|
+
required,
|
|
22
|
+
classNames,
|
|
23
|
+
styles,
|
|
24
|
+
}: React.PropsWithChildren<FieldLayoutProps>) {
|
|
25
|
+
const descriptionComponent = description && (
|
|
26
|
+
<FieldDescription
|
|
27
|
+
className={classNames?.['description']}
|
|
28
|
+
style={styles?.['description']}
|
|
29
|
+
>
|
|
30
|
+
{description}
|
|
31
|
+
</FieldDescription>
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const labelComponent = label && (
|
|
35
|
+
<FieldLabel
|
|
36
|
+
className={cn('gap-0.5', classNames?.['label'])}
|
|
37
|
+
htmlFor={name}
|
|
38
|
+
style={styles?.['label']}
|
|
39
|
+
>
|
|
40
|
+
{label}
|
|
41
|
+
{required && (
|
|
42
|
+
<span className="text-red-500">
|
|
43
|
+
<Asterisk size={12} />
|
|
44
|
+
</span>
|
|
45
|
+
)}
|
|
46
|
+
</FieldLabel>
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const errorComponent = isInvalid && (
|
|
50
|
+
<FieldError className={classNames?.['error']} style={styles?.['error']}>
|
|
51
|
+
{errorMessage}
|
|
52
|
+
</FieldError>
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
if (layout !== 'vertical') {
|
|
56
|
+
return (
|
|
57
|
+
<Field
|
|
58
|
+
orientation={layout}
|
|
59
|
+
className={cn(classNames?.['root'])}
|
|
60
|
+
style={styles?.['root']}
|
|
61
|
+
>
|
|
62
|
+
{descriptionComponent ? (
|
|
63
|
+
<FieldContent>
|
|
64
|
+
{labelComponent}
|
|
65
|
+
{descriptionComponent}
|
|
66
|
+
</FieldContent>
|
|
67
|
+
) : (
|
|
68
|
+
labelComponent
|
|
69
|
+
)}
|
|
70
|
+
<FieldContent className={'has-[>[role=switch]]:flex-initial'}>
|
|
71
|
+
{children}
|
|
72
|
+
{errorComponent}
|
|
73
|
+
</FieldContent>
|
|
74
|
+
</Field>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
return (
|
|
78
|
+
<Field
|
|
79
|
+
orientation={layout}
|
|
80
|
+
className={classNames?.['root']}
|
|
81
|
+
style={styles?.['root']}
|
|
82
|
+
>
|
|
83
|
+
{labelComponent}
|
|
84
|
+
<FieldContent className={'has-[>[role=switch]]:flex-initial'}>
|
|
85
|
+
{children}
|
|
86
|
+
{errorComponent}
|
|
87
|
+
</FieldContent>
|
|
88
|
+
{descriptionComponent}
|
|
89
|
+
</Field>
|
|
90
|
+
);
|
|
91
|
+
}
|