feat: add Checkbox and Radio field families
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent, h } from "vue";
|
||||
import ChoiceContent from "../choice/ChoiceContent.vue";
|
||||
export default defineComponent({
|
||||
name: "RadioContent",
|
||||
inheritAttrs: false,
|
||||
setup(_, { attrs, slots }) {
|
||||
return () => h(ChoiceContent, attrs, slots);
|
||||
},
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import { inject } from "vue";
|
||||
import { choiceKey } from "../choice/context";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
const context = inject(choiceKey);
|
||||
if (!context) throw new Error("RadioControl must be inside Radio");
|
||||
</script>
|
||||
<template>
|
||||
<span
|
||||
v-bind="$attrs"
|
||||
:class="[context.slots.value.control(), $attrs.class]"
|
||||
data-slot="radio-control"
|
||||
>
|
||||
<slot v-bind="context.state()"></slot>
|
||||
</span>
|
||||
</template>
|
||||
@@ -0,0 +1,23 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent, h, inject } from "vue";
|
||||
import { choiceKey } from "../choice/context";
|
||||
export default defineComponent({
|
||||
name: "RadioIndicator",
|
||||
inheritAttrs: false,
|
||||
setup(_, { attrs, slots }) {
|
||||
const context = inject(choiceKey);
|
||||
if (!context) throw new Error("RadioIndicator must be inside Radio");
|
||||
return () =>
|
||||
h(
|
||||
"span",
|
||||
{
|
||||
...attrs,
|
||||
class: [context.slots.value.indicator(), attrs.class],
|
||||
"aria-hidden": "true",
|
||||
"data-slot": "radio-indicator",
|
||||
},
|
||||
slots.default?.(context.state()),
|
||||
);
|
||||
},
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user