55
66<script setup lang="ts">
77import Vue , { computed , provide , ref } from ' vue'
8- import { createElementId } from ' ../../utils/createElementId.ts'
8+ import NcFormBox from ' ../NcFormBox/NcFormBox.vue'
9+ import NcFormGroup from ' ../NcFormGroup/NcFormGroup.vue'
910import { INSIDE_RADIO_GROUP_KEY } from ' ./useNcRadioGroup.ts'
1011
1112const props = defineProps <{
@@ -32,10 +33,9 @@ const props = defineProps<{
3233}>()
3334
3435const emit = defineEmits <{
35- (e : ' update:modelValue' , v : string ): void
36+ (event : ' update:modelValue' , value : string ): void
3637}>()
3738
38- const descriptionId = createElementId ()
3939const buttonVariant = ref <boolean >()
4040
4141provide (INSIDE_RADIO_GROUP_KEY , computed (() => ({
@@ -76,65 +76,25 @@ export default {
7676 </script >
7777
7878<template >
79- <fieldset
80- :aria-describedby =" description ? descriptionId : undefined"
81- :class =" [{
82- [$style.radioGroup_buttonVariant]: buttonVariant,
83- }, $style.radioGroup]" >
84- <legend :class =" [$style.radioGroup__label, { 'hidden-visually': labelHidden }]" >
85- {{ label }}
86- </legend >
87- <p v-if =" description" :id =" descriptionId" :class =" $style.radioGroup__description" >
88- {{ description }}
89- </p >
90- <div :class =" $style.radioGroup__wrapper" >
79+ <NcFormGroup
80+ :label =" label"
81+ :description =" description"
82+ :hide-label =" labelHidden" >
83+ <NcFormBox v-if =" buttonVariant" row >
9184 <!-- @slot Slot for the included radio buttons (`NcCheckboxRadioSwitch`).
9285 The `type` prop of the `NcCheckboxRadioSwitch` will be automatically set (and forced) to `radio`.
9386 If you want the button variant, then you have to use `NcRadioGroupButton`.-->
9487 <slot />
95- </div >
96- </fieldset >
88+ </NcFormBox >
89+ <span v-else :class =" $style.radioGroup_checkboxRadioContainer" >
90+ <slot />
91+ </span >
92+ </NcFormGroup >
9793</template >
9894
9995<style module lang="scss">
100- .radioGroup {
101- display : flex ;
102- flex-direction : column ;
103-
104- & :not (.radioGroup_buttonVariant ) :global (.checkbox-content ) {
105- max-width : unset !important ;
106- }
107- }
108-
109- .radioGroup__label {
110- font-size : 1.2em ;
111- font-weight : bold ;
112- margin-inline-start : var (--border-radius-element );
113- }
114-
115- .radioGroup__description {
116- color : var (--color-text-maxcontrast );
117- margin-block-end : var (--default-grid-baseline );
118- margin-inline-start : var (--border-radius-element );
119- }
120-
121- .radioGroup__wrapper {
122- display : flex ;
123- flex-direction : column ;
124-
125- > * {
126- flex : 1 0 1px ;
127- }
128- }
129-
130- .radioGroup__label + .radioGroup__wrapper {
131- // when there is no description we need to add some margin between wrapper and label
132- margin-block-start : var (--default-grid-baseline );
133- }
134-
135- .radioGroup_buttonVariant .radioGroup__wrapper {
136- flex-direction : row ;
137- gap : var (--default-grid-baseline );
96+ .radioGroup_checkboxRadioContainer :global(.checkbox-content ) {
97+ max-width : unset !important ;
13898}
13999 </style >
140100
0 commit comments