diff --git a/src/runtime/components/CheckboxGroup.vue b/src/runtime/components/CheckboxGroup.vue index 9f2736f5..6886f5ba 100644 --- a/src/runtime/components/CheckboxGroup.vue +++ b/src/runtime/components/CheckboxGroup.vue @@ -50,14 +50,14 @@ export interface CheckboxGroupProps = (props: { item: T & { id: string }, modelValue?: CheckboxGroupValue }) => any +type SlotProps = (props: { item: T & { id: string } }) => any export interface CheckboxGroupSlots { legend(props?: {}): any @@ -72,7 +72,7 @@ import { CheckboxGroupRoot, useForwardProps, useForwardPropsEmits } from 'reka-u import { reactivePick } from '@vueuse/core' import { useAppConfig } from '#imports' import { useFormField } from '../composables/useFormField' -import { get } from '../utils' +import { get, omit } from '../utils' import { tv } from '../utils/tv' const props = withDefaults(defineProps>(), { @@ -88,6 +88,7 @@ const appConfig = useAppConfig() as CheckboxGroup['AppConfig'] const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'modelValue', 'defaultValue', 'orientation', 'loop', 'required'), emits) const checkboxProps = useForwardProps(reactivePick(props, 'variant', 'indicator', 'icon')) +const proxySlots = omit(slots, ['legend']) const { emitFormChange, emitFormInput, color, name, size, id: _id, disabled, ariaAttrs } = useFormField>(props, { bind: false }) const id = _id.value ?? useId() @@ -169,7 +170,13 @@ function onUpdate(value: any) { :size="size" :name="name" :disabled="item.disabled || disabled" - /> + :ui="props.ui ? omit(props.ui, ['root']) : undefined" + :class="ui.item({ class: props.ui?.item })" + > + + diff --git a/src/theme/checkbox-group.ts b/src/theme/checkbox-group.ts index bd4b4dc7..fe80ad44 100644 --- a/src/theme/checkbox-group.ts +++ b/src/theme/checkbox-group.ts @@ -2,7 +2,8 @@ export default { slots: { root: 'relative', fieldset: 'flex gap-x-2', - legend: 'mb-1 block font-medium text-default' + legend: 'mb-1 block font-medium text-default', + item: '' }, variants: { orientation: { diff --git a/test/components/CheckboxGroup.spec.ts b/test/components/CheckboxGroup.spec.ts index b3eba134..1cb37206 100644 --- a/test/components/CheckboxGroup.spec.ts +++ b/test/components/CheckboxGroup.spec.ts @@ -38,11 +38,11 @@ describe('CheckboxGroup', () => { ['with ariaLabel', { props, attrs: { 'aria-label': 'Aria label' } }], ['with as', { props: { ...props, as: 'section' } }], ['with class', { props: { ...props, class: 'absolute' } }], - ['with ui', { props: { ...props, ui: { wrapper: 'ms-4' } } }], + ['with ui', { props: { ...props, ui: { fieldset: 'gap-x-4', label: 'text-red' } } }], // Slots - ['with legend slot', { props, slots: { label: () => 'Legend slot' } }], + ['with legend slot', { props, slots: { legend: () => 'Legend slot' } }], ['with label slot', { props, slots: { label: () => 'Label slot' } }], - ['with description slot', { props, slots: { label: () => 'Description slot' } }] + ['with description slot', { props, slots: { description: () => 'Description slot' } }] ])('renders %s correctly', async (nameOrHtml: string, options: { props?: CheckboxGroupProps, slots?: Partial }) => { const html = await ComponentRender(nameOrHtml, options, CheckboxGroup) expect(html).toMatchSnapshot() diff --git a/test/components/__snapshots__/CheckboxGroup-vue.spec.ts.snap b/test/components/__snapshots__/CheckboxGroup-vue.spec.ts.snap index 76aa334f..0288cb64 100644 --- a/test/components/__snapshots__/CheckboxGroup-vue.spec.ts.snap +++ b/test/components/__snapshots__/CheckboxGroup-vue.spec.ts.snap @@ -189,7 +189,7 @@ exports[`CheckboxGroup > renders with description slot correctly 1`] = `

Option 1

- +

Description slot

@@ -507,7 +507,7 @@ exports[`CheckboxGroup > renders with label slot correctly 1`] = `
-

Option 1

+

Label slot

@@ -573,7 +573,7 @@ exports[`CheckboxGroup > renders with labelKey correctly 1`] = ` exports[`CheckboxGroup > renders with legend slot correctly 1`] = ` "
-
-

Option 2

+

Option 2

diff --git a/test/components/__snapshots__/CheckboxGroup.spec.ts.snap b/test/components/__snapshots__/CheckboxGroup.spec.ts.snap index 46b3136a..e5bca1c3 100644 --- a/test/components/__snapshots__/CheckboxGroup.spec.ts.snap +++ b/test/components/__snapshots__/CheckboxGroup.spec.ts.snap @@ -189,7 +189,7 @@ exports[`CheckboxGroup > renders with description slot correctly 1`] = `

Option 1

- +

Description slot

@@ -507,7 +507,7 @@ exports[`CheckboxGroup > renders with label slot correctly 1`] = `
-

Option 1

+

Label slot

@@ -573,7 +573,7 @@ exports[`CheckboxGroup > renders with labelKey correctly 1`] = ` exports[`CheckboxGroup > renders with legend slot correctly 1`] = ` "
-
-

Option 2

+

Option 2