Skip to content

Commit add1e61

Browse files
authored
fix: show validation message as tooltip in compact form (#6087)
* 紧凑模式表单的校验消息将显示为一个tooltip
1 parent 20c15f3 commit add1e61

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

packages/@core/ui-kit/form-ui/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
},
3939
"dependencies": {
4040
"@vben-core/composables": "workspace:*",
41+
"@vben-core/icons": "workspace:*",
4142
"@vben-core/shadcn-ui": "workspace:*",
4243
"@vben-core/shared": "workspace:*",
4344
"@vben-core/typings": "workspace:*",

packages/@core/ui-kit/form-ui/src/form-render/form-field.vue

+21-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import type { FormSchema, MaybeComponentProps } from '../types';
55
66
import { computed, nextTick, onUnmounted, useTemplateRef, watch } from 'vue';
77
8+
import { CircleAlert } from '@vben-core/icons';
89
import {
910
FormControl,
1011
FormDescription,
1112
FormField,
1213
FormItem,
1314
FormMessage,
1415
VbenRenderContent,
16+
VbenTooltip,
1517
} from '@vben-core/shadcn-ui';
1618
import { cn, isFunction, isObject, isString } from '@vben-core/shared/utils';
1719
@@ -354,6 +356,24 @@ onUnmounted(() => {
354356
</template>
355357
<!-- <slot></slot> -->
356358
</component>
359+
<VbenTooltip
360+
v-if="compact && isInValid"
361+
:delay-duration="300"
362+
side="left"
363+
>
364+
<template #trigger>
365+
<slot name="trigger">
366+
<CircleAlert
367+
:class="
368+
cn(
369+
'text-foreground/80 hover:text-foreground inline-flex size-5 cursor-pointer',
370+
)
371+
"
372+
/>
373+
</slot>
374+
</template>
375+
<FormMessage />
376+
</VbenTooltip>
357377
</slot>
358378
</FormControl>
359379
<!-- 自定义后缀 -->
@@ -365,7 +385,7 @@ onUnmounted(() => {
365385
</FormDescription>
366386
</div>
367387

368-
<Transition name="slide-up">
388+
<Transition name="slide-up" v-if="!compact">
369389
<FormMessage class="absolute bottom-1" />
370390
</Transition>
371391
</div>

pnpm-lock.yaml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)