feat: add Checkbox and Radio field families

This commit is contained in:
maoyingjie
2026-10-22 09:15:27 +08:00
parent a4fb3c550a
commit bcadbeaf8c
75 changed files with 5293 additions and 22 deletions
+9 -1
View File
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { inject, useAttrs } from "vue";
import { useFieldPart } from "../field/useFieldPart";
import { useInheritedDisabled } from "../field/disabled";
import { fieldContextKey } from "../field/context";
defineOptions({ inheritAttrs: false });
@@ -10,14 +11,21 @@ const props = defineProps<{
isDisabled?: boolean;
isInvalid?: boolean;
}>();
const labelPart =
field?.kind === "group" ? useFieldPart("label", attrs) : undefined;
const disabled = useInheritedDisabled(
() => props.isDisabled || field?.disabled.value,
);
</script>
<template>
<component
:is="field?.kind === 'toggle' && !attrs.for ? 'span' : 'label'"
:is="
(field?.kind === 'toggle' || field?.kind === 'group') && !attrs.for
? 'span'
: 'label'
"
v-bind="attrs"
:id="labelPart?.id.value ?? attrs.id"
:for="
attrs.for ?? (field?.kind === 'text' ? field.controlId.value : undefined)
"