Skip to content

Commit c9ccd2b

Browse files
authored
fix: form label and control style (#5580)
* fix: form label and control style * fix: empty label mark with required rules
1 parent 5aff8ba commit c9ccd2b

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,17 +301,18 @@ function autofocus() {
301301
)
302302
"
303303
:help="help"
304+
:colon="colon"
305+
:label="label"
304306
:required="shouldRequired && !hideRequiredMark"
305307
:style="labelStyle"
306308
>
307309
<template v-if="label">
308310
<VbenRenderContent :content="label" />
309-
<span v-if="colon" class="ml-[2px]">:</span>
310311
</template>
311312
</FormLabel>
312313
<div class="w-full overflow-hidden">
313314
<div :class="cn('relative flex w-full items-center', wrapperClass)">
314-
<div class="flex-auto overflow-hidden">
315+
<div class="flex-auto overflow-hidden p-[2px]">
315316
<FormControl :class="cn(controlClass)">
316317
<slot
317318
v-bind="{

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import { cn } from '@vben-core/shared/utils';
1010
1111
interface Props {
1212
class?: string;
13+
colon?: boolean;
1314
help?: CustomRenderType;
15+
label?: CustomRenderType;
1416
required?: boolean;
1517
}
1618
@@ -24,5 +26,6 @@ const props = defineProps<Props>();
2426
<VbenHelpTooltip v-if="help" trigger-class="size-3.5 ml-1">
2527
<VbenRenderContent :content="help" />
2628
</VbenHelpTooltip>
29+
<span v-if="colon && label" class="ml-[2px]">:</span>
2730
</FormLabel>
2831
</template>

playground/src/views/examples/form/basic.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ const [BaseForm, baseFormApi] = useVbenForm({
235235
default: () => ['我已阅读并同意'],
236236
};
237237
},
238-
rules: z.any().refine((v) => v, { message: '为什么不同意?勾上它!' }),
238+
rules: z
239+
.boolean()
240+
.refine((v) => v, { message: '为什么不同意?勾上它!' }),
239241
},
240242
{
241243
component: 'Mentions',
@@ -266,7 +268,8 @@ const [BaseForm, baseFormApi] = useVbenForm({
266268
class: 'w-auto',
267269
},
268270
fieldName: 'switch',
269-
help: () => ['这是一个帮助信息', '第二行'].map((v) => h('p', () => v)),
271+
help: () =>
272+
['这是一个多行帮助信息', '第二行', '第三行'].map((v) => h('p', v)),
270273
label: '开关',
271274
},
272275
{

0 commit comments

Comments
 (0)