-
Notifications
You must be signed in to change notification settings - Fork 8.3k
perf: perf the validation message for VbenForm in compact mode
#6665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
898503b
e4e9fc5
49eb9be
0f1f4f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,15 +5,13 @@ import type { FormSchema, MaybeComponentProps } from '../types'; | |||||||||||||
|
|
||||||||||||||
| import { computed, nextTick, onUnmounted, useTemplateRef, watch } from 'vue'; | ||||||||||||||
|
|
||||||||||||||
| import { CircleAlert } from '@vben-core/icons'; | ||||||||||||||
| import { | ||||||||||||||
| FormControl, | ||||||||||||||
| FormDescription, | ||||||||||||||
| FormField, | ||||||||||||||
| FormItem, | ||||||||||||||
| FormMessage, | ||||||||||||||
| VbenRenderContent, | ||||||||||||||
| VbenTooltip, | ||||||||||||||
| } from '@vben-core/shadcn-ui'; | ||||||||||||||
| import { cn, isFunction, isObject, isString } from '@vben-core/shared/utils'; | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -323,7 +321,7 @@ onUnmounted(() => { | |||||||||||||
| <VbenRenderContent :content="label" /> | ||||||||||||||
| </template> | ||||||||||||||
| </FormLabel> | ||||||||||||||
| <div class="flex-auto overflow-hidden p-[1px]"> | ||||||||||||||
| <div class="relative flex-auto p-[1px]"> | ||||||||||||||
| <div :class="cn('relative flex w-full items-center', wrapperClass)"> | ||||||||||||||
| <FormControl :class="cn(controlClass)"> | ||||||||||||||
| <slot | ||||||||||||||
|
|
@@ -340,6 +338,7 @@ onUnmounted(() => { | |||||||||||||
| :class="{ | ||||||||||||||
| 'border-destructive focus:border-destructive hover:border-destructive/80 focus:shadow-[0_0_0_2px_rgba(255,38,5,0.06)]': | ||||||||||||||
| isInValid, | ||||||||||||||
| 'hover:z-10 focus:z-10': compact, | ||||||||||||||
| }" | ||||||||||||||
| v-bind="createComponentProps(slotProps)" | ||||||||||||||
| :disabled="shouldDisabled" | ||||||||||||||
|
|
@@ -356,24 +355,6 @@ onUnmounted(() => { | |||||||||||||
| </template> | ||||||||||||||
| <!-- <slot></slot> --> | ||||||||||||||
| </component> | ||||||||||||||
| <VbenTooltip | ||||||||||||||
| v-if="compact && isInValid" | ||||||||||||||
| :delay-duration="300" | ||||||||||||||
| side="left" | ||||||||||||||
| > | ||||||||||||||
| <template #trigger> | ||||||||||||||
| <slot name="trigger"> | ||||||||||||||
| <CircleAlert | ||||||||||||||
| :class=" | ||||||||||||||
| cn( | ||||||||||||||
| 'text-foreground/80 hover:text-foreground inline-flex size-5 cursor-pointer', | ||||||||||||||
| ) | ||||||||||||||
| " | ||||||||||||||
| /> | ||||||||||||||
| </slot> | ||||||||||||||
| </template> | ||||||||||||||
| <FormMessage /> | ||||||||||||||
| </VbenTooltip> | ||||||||||||||
| </slot> | ||||||||||||||
| </FormControl> | ||||||||||||||
| <!-- 自定义后缀 --> | ||||||||||||||
|
|
@@ -385,8 +366,8 @@ onUnmounted(() => { | |||||||||||||
| </FormDescription> | ||||||||||||||
| </div> | ||||||||||||||
|
|
||||||||||||||
| <Transition name="slide-up" v-if="!compact"> | ||||||||||||||
| <FormMessage class="absolute" /> | ||||||||||||||
| <Transition name="slide-up"> | ||||||||||||||
| <FormMessage :compact="compact" class="absolute" /> | ||||||||||||||
| </Transition> | ||||||||||||||
|
Comment on lines
+369
to
371
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug:
Apply this diff to let - <Transition name="slide-up">
- <FormMessage :compact="compact" class="absolute" />
- </Transition>
+ <Transition name="slide-up">
+ <FormMessage :compact="compact" />
+ </Transition>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| </div> | ||||||||||||||
| </FormItem> | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,50 @@ | ||
| <script lang="ts" setup> | ||
| import { toValue } from 'vue'; | ||
|
|
||
| import { cn } from '@vben-core/shared/utils'; | ||
|
|
||
| import { ErrorMessage } from 'vee-validate'; | ||
|
|
||
| import { useFormField } from './useFormField'; | ||
|
|
||
| interface Props { | ||
| compact?: boolean; | ||
| } | ||
|
|
||
| const props = withDefaults(defineProps<Props>(), { | ||
| compact: false, | ||
| }); | ||
|
|
||
| const { formMessageId, name } = useFormField(); | ||
| </script> | ||
|
|
||
| <template> | ||
| <ErrorMessage | ||
| :id="formMessageId" | ||
| :name="toValue(name)" | ||
| as="p" | ||
| class="text-destructive text-[0.8rem]" | ||
| :as="props.compact ? 'div' : 'p'" | ||
| :class=" | ||
| cn( | ||
| 'text-[0.8rem]', | ||
| props.compact ? 'vben-form-message-compact' : 'text-destructive', | ||
| ) | ||
| " | ||
| /> | ||
| </template> | ||
|
|
||
| <style> | ||
| .vben-form-message-compact { | ||
| position: absolute; | ||
| top: 100%; | ||
| left: 1rem; | ||
| z-index: 1; | ||
| width: calc(100% - 1rem); | ||
| height: auto; | ||
| min-height: 1.5rem; | ||
| padding: 2px 8px; | ||
| color: white; | ||
| background: hsl(var(--destructive)); | ||
| border-radius: var(--radius); | ||
| opacity: 1; | ||
| } | ||
| </style> |
Uh oh!
There was an error while loading. Please reload this page.