@@ -77,9 +77,10 @@ export interface CheckboxGroupSlots<T extends CheckboxGroupItem[] = CheckboxGrou
7777 </script >
7878
7979<script setup lang="ts" generic =" T extends CheckboxGroupItem [], VK extends GetItemKeys <T > = ' value' " >
80- import { computed , useId } from ' vue'
80+ import { computed } from ' vue'
8181import { CheckboxGroupRoot , useForwardProps , useForwardPropsEmits } from ' reka-ui'
8282import { reactivePick } from ' @vueuse/core'
83+ import { useCustomControl } from ' @formwerk/core'
8384import { useAppConfig } from ' #imports'
8485import { useFormField } from ' ../composables/useFormField'
8586import { get , omit } from ' ../utils'
@@ -101,8 +102,13 @@ const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'modelValue', '
101102const checkboxProps = useForwardProps (reactivePick (props , ' variant' , ' indicator' , ' icon' ))
102103const getProxySlots = () => omit (slots , [' legend' ])
103104
104- const { emitFormChange, emitFormInput, color, name, size, id : _id, disabled, ariaAttrs } = useFormField <CheckboxGroupProps <T >>(props , { bind: false })
105- const id = _id .value ?? useId ()
105+ const { emitFormChange, emitFormInput, color, name, size, disabled } = useFormField <CheckboxGroupProps <T >>(props , { bind: false })
106+ const { controlProps, controlId } = useCustomControl ({
107+ name ,
108+ disabled ,
109+ required: props .required ,
110+ controlType: ' UInputMenu'
111+ })
106112
107113const ui = computed (() => tv ({ extend: theme , ... (appConfig .ui ?.checkboxGroup || {}) })({
108114 size: size .value ,
@@ -115,15 +121,15 @@ const ui = computed(() => tv({ extend: theme, ...(appConfig.ui?.checkboxGroup ||
115121function normalizeItem(item : any ) {
116122 if (item === null ) {
117123 return {
118- id: ` ${id }:null ` ,
124+ id: ` ${controlId }:null ` ,
119125 value: undefined ,
120126 label: undefined
121127 }
122128 }
123129
124130 if (typeof item === ' string' || typeof item === ' number' ) {
125131 return {
126- id: ` ${id }:${item } ` ,
132+ id: ` ${controlId }:${item } ` ,
127133 value: String (item ),
128134 label: String (item )
129135 }
@@ -138,7 +144,7 @@ function normalizeItem(item: any) {
138144 value ,
139145 label ,
140146 description ,
141- id: ` ${id }:${value } `
147+ id: ` ${controlId }:${value } `
142148 }
143149}
144150
@@ -161,14 +167,14 @@ function onUpdate(value: any) {
161167<!-- eslint-disable vue/no-template-shadow -->
162168<template >
163169 <CheckboxGroupRoot
164- :id =" id "
170+ :id =" controlId "
165171 v-bind =" rootProps"
166172 :name =" name"
167173 :disabled =" disabled"
168174 :class =" ui.root({ class: [props.ui?.root, props.class] })"
169175 @update:model-value =" onUpdate"
170176 >
171- <fieldset :class =" ui.fieldset({ class: props.ui?.fieldset })" v-bind =" ariaAttrs " >
177+ <fieldset :class =" ui.fieldset({ class: props.ui?.fieldset })" v-bind =" controlProps " >
172178 <legend v-if =" legend || !!slots.legend" :class =" ui.legend({ class: props.ui?.legend })" >
173179 <slot name =" legend" >
174180 {{ legend }}
0 commit comments