feat: add Checkbox and Radio field families
This commit is contained in:
@@ -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)
|
||||
"
|
||||
|
||||
Reference in New Issue
Block a user