|
7 | 7 | import type { Slot } from 'vue' |
8 | 8 |
|
9 | 9 | import { computed, provide, ref, warn } from 'vue' |
10 | | -import { createElementId } from '../../utils/createElementId.ts' |
| 10 | +import NcFormBox from '../NcFormBox/NcFormBox.vue' |
| 11 | +import NcFormGroup from '../NcFormGroup/NcFormGroup.vue' |
11 | 12 | import { INSIDE_RADIO_GROUP_KEY } from './useNcRadioGroup.ts' |
12 | 13 |
|
13 | 14 | const modelValue = defineModel<string>({ required: false, default: '' }) |
@@ -40,7 +41,6 @@ defineSlots<{ |
40 | 41 | default?: Slot |
41 | 42 | }>() |
42 | 43 |
|
43 | | -const descriptionId = createElementId() |
44 | 44 | const buttonVariant = ref<boolean>() |
45 | 45 |
|
46 | 46 | provide(INSIDE_RADIO_GROUP_KEY, computed(() => ({ |
@@ -72,62 +72,22 @@ function onUpdate(value: string) { |
72 | 72 | </script> |
73 | 73 |
|
74 | 74 | <template> |
75 | | - <fieldset |
76 | | - :aria-describedby="description ? descriptionId : undefined" |
77 | | - :class="[{ |
78 | | - [$style.radioGroup_buttonVariant]: buttonVariant, |
79 | | - }, $style.radioGroup]"> |
80 | | - <legend :class="[$style.radioGroup__label, { 'hidden-visually': labelHidden }]"> |
81 | | - {{ label }} |
82 | | - </legend> |
83 | | - <p v-if="description" :id="descriptionId" :class="$style.radioGroup__description"> |
84 | | - {{ description }} |
85 | | - </p> |
86 | | - <div :class="$style.radioGroup__wrapper"> |
| 75 | + <NcFormGroup |
| 76 | + :label |
| 77 | + :description |
| 78 | + :hide-label="labelHidden"> |
| 79 | + <NcFormBox v-if="buttonVariant" row> |
87 | 80 | <slot /> |
88 | | - </div> |
89 | | - </fieldset> |
| 81 | + </NcFormBox> |
| 82 | + <span v-else :class="$style.radioGroup_checkboxRadioContainer"> |
| 83 | + <slot /> |
| 84 | + </span> |
| 85 | + </NcFormGroup> |
90 | 86 | </template> |
91 | 87 |
|
92 | 88 | <style module lang="scss"> |
93 | | -.radioGroup { |
94 | | - display: flex; |
95 | | - flex-direction: column; |
96 | | -
|
97 | | - &:not(.radioGroup_buttonVariant) :global(.checkbox-content) { |
98 | | - max-width: unset !important; |
99 | | - } |
100 | | -} |
101 | | -
|
102 | | -.radioGroup__label { |
103 | | - font-size: 1.2em; |
104 | | - font-weight: bold; |
105 | | - margin-inline-start: var(--border-radius-element); |
106 | | -} |
107 | | -
|
108 | | -.radioGroup__description { |
109 | | - color: var(--color-text-maxcontrast); |
110 | | - margin-block-end: var(--default-grid-baseline); |
111 | | - margin-inline-start: var(--border-radius-element); |
112 | | -} |
113 | | -
|
114 | | -.radioGroup__wrapper { |
115 | | - display: flex; |
116 | | - flex-direction: column; |
117 | | -
|
118 | | - > * { |
119 | | - flex: 1 0 1px; |
120 | | - } |
121 | | -} |
122 | | -
|
123 | | -.radioGroup__label + .radioGroup__wrapper { |
124 | | - // when there is no description we need to add some margin between wrapper and label |
125 | | - margin-block-start: var(--default-grid-baseline); |
126 | | -} |
127 | | -
|
128 | | -.radioGroup_buttonVariant .radioGroup__wrapper { |
129 | | - flex-direction: row; |
130 | | - gap: var(--default-grid-baseline); |
| 89 | +.radioGroup_checkboxRadioContainer :global(.checkbox-content) { |
| 90 | + max-width: unset !important; |
131 | 91 | } |
132 | 92 | </style> |
133 | 93 |
|
|
0 commit comments