This repository was archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathc-radio-group.tsx
72 lines (64 loc) · 1.9 KB
/
c-radio-group.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { h, PropType, defineComponent } from "vue"
import {
HTMLChakraProps,
ThemingProps,
chakra,
useMultiStyleConfig,
} from "@chakra-ui/vue-system"
import { useThemingProps, vueThemingProps } from "@chakra-ui/vue-utils"
import { UseRadioGroupProps, useRadioGroup } from "./use-radio-group"
import { RadioGroupProvider, RadioGroupStylesProvider } from "./radio-context"
export interface CRadioGroupProps
extends UseRadioGroupProps,
HTMLChakraProps<"div">,
Omit<ThemingProps<"Radio">, "orientation"> {}
export const CRadioGroup = defineComponent({
name: "CRadioGroup",
props: {
dir: {
type: String as PropType<CRadioGroupProps["dir"]>,
},
disabled: {
type: Boolean as PropType<CRadioGroupProps["disabled"]>,
},
form: {
type: String as PropType<CRadioGroupProps["form"]>,
},
getRootNode: {
type: Function as PropType<CRadioGroupProps["getRootNode"]>,
},
id: {
type: String as PropType<CRadioGroupProps["id"]>,
},
ids: {
type: Object as PropType<CRadioGroupProps["ids"]>,
},
name: {
type: String as PropType<CRadioGroupProps["name"]>,
},
modelValue: {
type: String as PropType<CRadioGroupProps["modelValue"]>,
},
orientation: {
type: String as PropType<CRadioGroupProps["orientation"]>,
},
readonly: {
type: Boolean as PropType<CRadioGroupProps["readOnly"]>,
},
...vueThemingProps,
},
emits: ["change", "update:modelValue"],
setup(props, { slots, attrs, expose }) {
const api = useRadioGroup(props)
const themeProps = useThemingProps(props)
const styles = useMultiStyleConfig("Radio", themeProps)
RadioGroupProvider(api)
RadioGroupStylesProvider(styles)
expose(api.value)
return () => (
<chakra.div __label="radio-group" {...api.value.rootProps} {...attrs}>
{slots.default?.(api.value)}
</chakra.div>
)
},
})