@nuxt/ui 3.0.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nuxt/ui/accordion.ts +25 -4
- package/.nuxt/ui/alert.ts +52 -31
- package/.nuxt/ui/avatar-group.ts +24 -3
- package/.nuxt/ui/avatar.ts +26 -5
- package/.nuxt/ui/badge.ts +56 -35
- package/.nuxt/ui/breadcrumb.ts +28 -7
- package/.nuxt/ui/button-group.ts +23 -2
- package/.nuxt/ui/button.ts +66 -45
- package/.nuxt/ui/calendar.ts +39 -18
- package/.nuxt/ui/card.ts +28 -7
- package/.nuxt/ui/carousel.ts +29 -8
- package/.nuxt/ui/checkbox-group.ts +82 -0
- package/.nuxt/ui/checkbox.ts +163 -29
- package/.nuxt/ui/chip.ts +31 -10
- package/.nuxt/ui/collapsible.ts +23 -2
- package/.nuxt/ui/color-picker.ts +26 -5
- package/.nuxt/ui/command-palette.ts +37 -16
- package/.nuxt/ui/container.ts +24 -3
- package/.nuxt/ui/context-menu.ts +56 -35
- package/.nuxt/ui/drawer.ts +33 -12
- package/.nuxt/ui/dropdown-menu.ts +57 -36
- package/.nuxt/ui/form-field.ts +29 -8
- package/.nuxt/ui/form.ts +23 -2
- package/.nuxt/ui/index.ts +1 -0
- package/.nuxt/ui/input-menu.ts +65 -44
- package/.nuxt/ui/input-number.ts +43 -22
- package/.nuxt/ui/input.ts +46 -25
- package/.nuxt/ui/kbd.ts +27 -6
- package/.nuxt/ui/link.ts +26 -5
- package/.nuxt/ui/modal.ts +28 -7
- package/.nuxt/ui/navigation-menu.ts +103 -84
- package/.nuxt/ui/pagination.ts +23 -2
- package/.nuxt/ui/pin-input.ts +43 -22
- package/.nuxt/ui/popover.ts +25 -4
- package/.nuxt/ui/progress.ts +40 -19
- package/.nuxt/ui/radio-group.ts +273 -37
- package/.nuxt/ui/select-menu.ts +59 -35
- package/.nuxt/ui/select.ts +55 -34
- package/.nuxt/ui/separator.ts +31 -10
- package/.nuxt/ui/skeleton.ts +24 -3
- package/.nuxt/ui/slideover.ts +27 -6
- package/.nuxt/ui/slider.ts +39 -18
- package/.nuxt/ui/stepper.ts +41 -20
- package/.nuxt/ui/switch.ts +44 -23
- package/.nuxt/ui/table.ts +38 -17
- package/.nuxt/ui/tabs.ts +55 -34
- package/.nuxt/ui/textarea.ts +63 -37
- package/.nuxt/ui/toast.ts +47 -26
- package/.nuxt/ui/toaster.ts +23 -2
- package/.nuxt/ui/tooltip.ts +25 -4
- package/.nuxt/ui/tree.ts +41 -20
- package/.nuxt/ui.css +56 -12
- package/README.md +11 -0
- package/cli/templates.mjs +18 -17
- package/dist/module.d.mts +2 -1
- package/dist/module.json +5 -5
- package/dist/module.mjs +11 -7
- package/dist/runtime/components/Accordion.vue +36 -92
- package/dist/runtime/components/Accordion.vue.d.ts +91 -0
- package/dist/runtime/components/Alert.vue +37 -100
- package/dist/runtime/components/Alert.vue.d.ts +96 -0
- package/dist/runtime/components/App.vue +28 -34
- package/dist/runtime/components/App.vue.d.ts +24 -0
- package/dist/runtime/components/Avatar.vue +47 -78
- package/dist/runtime/components/Avatar.vue.d.ts +60 -0
- package/dist/runtime/components/AvatarGroup.vue +40 -77
- package/dist/runtime/components/AvatarGroup.vue.d.ts +40 -0
- package/dist/runtime/components/Badge.vue +33 -62
- package/dist/runtime/components/Badge.vue.d.ts +62 -0
- package/dist/runtime/components/Breadcrumb.vue +36 -88
- package/dist/runtime/components/Breadcrumb.vue.d.ts +82 -0
- package/dist/runtime/components/Button.vue +96 -105
- package/dist/runtime/components/Button.vue.d.ts +73 -0
- package/dist/runtime/components/ButtonGroup.vue +20 -46
- package/dist/runtime/components/ButtonGroup.vue.d.ts +55 -0
- package/dist/runtime/components/Calendar.vue +73 -127
- package/dist/runtime/components/Calendar.vue.d.ts +107 -0
- package/dist/runtime/components/Card.vue +18 -40
- package/dist/runtime/components/Card.vue.d.ts +38 -0
- package/dist/runtime/components/Carousel.vue +112 -230
- package/dist/runtime/components/Carousel.vue.d.ts +120 -0
- package/dist/runtime/components/Checkbox.vue +52 -93
- package/dist/runtime/components/Checkbox.vue.d.ts +76 -0
- package/dist/runtime/components/CheckboxGroup.vue +121 -0
- package/dist/runtime/components/CheckboxGroup.vue.d.ts +75 -0
- package/dist/runtime/components/Chip.vue +26 -69
- package/dist/runtime/components/Chip.vue.d.ts +71 -0
- package/dist/runtime/components/Collapsible.vue +22 -41
- package/dist/runtime/components/Collapsible.vue.d.ts +50 -0
- package/dist/runtime/components/ColorPicker.vue +111 -197
- package/dist/runtime/components/ColorPicker.vue.d.ts +63 -0
- package/dist/runtime/components/CommandPalette.vue +94 -234
- package/dist/runtime/components/CommandPalette.vue.d.ts +173 -0
- package/dist/runtime/components/Container.vue +15 -28
- package/dist/runtime/components/Container.vue.d.ts +27 -0
- package/dist/runtime/components/ContextMenu.vue +32 -119
- package/dist/runtime/components/ContextMenu.vue.d.ts +127 -0
- package/dist/runtime/components/ContextMenuContent.vue +71 -72
- package/dist/runtime/components/ContextMenuContent.vue.d.ts +105 -0
- package/dist/runtime/components/Drawer.vue +49 -87
- package/dist/runtime/components/Drawer.vue.d.ts +88 -0
- package/dist/runtime/components/DropdownMenu.vue +37 -129
- package/dist/runtime/components/DropdownMenu.vue.d.ts +141 -0
- package/dist/runtime/components/DropdownMenuContent.vue +76 -79
- package/dist/runtime/components/DropdownMenuContent.vue.d.ts +55 -0
- package/dist/runtime/components/Form.vue +135 -219
- package/dist/runtime/components/Form.vue.d.ts +66 -0
- package/dist/runtime/components/FormField.vue +36 -77
- package/dist/runtime/components/FormField.vue.d.ts +70 -0
- package/dist/runtime/components/Icon.vue +12 -19
- package/dist/runtime/components/Icon.vue.d.ts +17 -0
- package/dist/runtime/components/Input.vue +82 -140
- package/dist/runtime/components/Input.vue.d.ts +91 -0
- package/dist/runtime/components/InputMenu.vue +193 -302
- package/dist/runtime/components/InputMenu.vue.d.ts +312 -0
- package/dist/runtime/components/InputNumber.vue +71 -133
- package/dist/runtime/components/InputNumber.vue.d.ts +193 -0
- package/dist/runtime/components/Kbd.vue +20 -46
- package/dist/runtime/components/Kbd.vue.d.ts +55 -0
- package/dist/runtime/components/Link.vue +98 -173
- package/dist/runtime/components/Link.vue.d.ts +124 -0
- package/dist/runtime/components/LinkBase.vue +33 -41
- package/dist/runtime/components/LinkBase.vue.d.ts +48 -0
- package/dist/runtime/components/Modal.vue +53 -116
- package/dist/runtime/components/Modal.vue.d.ts +109 -0
- package/dist/runtime/components/NavigationMenu.vue +78 -186
- package/dist/runtime/components/NavigationMenu.vue.d.ts +159 -0
- package/dist/runtime/components/OverlayProvider.vue +14 -18
- package/dist/runtime/components/OverlayProvider.vue.d.ts +2 -0
- package/dist/runtime/components/Pagination.vue +46 -140
- package/dist/runtime/components/Pagination.vue.d.ts +143 -0
- package/dist/runtime/components/PinInput.vue +61 -78
- package/dist/runtime/components/PinInput.vue.d.ts +68 -0
- package/dist/runtime/components/Popover.vue +47 -84
- package/dist/runtime/components/Popover.vue.d.ts +80 -0
- package/dist/runtime/components/Progress.vue +70 -131
- package/dist/runtime/components/Progress.vue.d.ts +97 -0
- package/dist/runtime/components/RadioGroup.vue +75 -126
- package/dist/runtime/components/RadioGroup.vue.d.ts +88 -0
- package/dist/runtime/components/Select.vue +115 -202
- package/dist/runtime/components/Select.vue.d.ts +139 -0
- package/dist/runtime/components/SelectMenu.vue +167 -281
- package/dist/runtime/components/SelectMenu.vue.d.ts +184 -0
- package/dist/runtime/components/Separator.vue +29 -71
- package/dist/runtime/components/Separator.vue.d.ts +75 -0
- package/dist/runtime/components/Skeleton.vue +21 -23
- package/dist/runtime/components/Skeleton.vue.d.ts +26 -0
- package/dist/runtime/components/Slideover.vue +53 -120
- package/dist/runtime/components/Slideover.vue.d.ts +111 -0
- package/dist/runtime/components/Slider.vue +46 -84
- package/dist/runtime/components/Slider.vue.d.ts +71 -0
- package/dist/runtime/components/Stepper.vue +44 -113
- package/dist/runtime/components/Stepper.vue.d.ts +89 -0
- package/dist/runtime/components/Switch.vue +45 -93
- package/dist/runtime/components/Switch.vue.d.ts +73 -0
- package/dist/runtime/components/Table.vue +165 -264
- package/dist/runtime/components/Table.vue.d.ts +183 -0
- package/dist/runtime/components/Tabs.vue +40 -105
- package/dist/runtime/components/Tabs.vue.d.ts +104 -0
- package/dist/runtime/components/Textarea.vue +113 -158
- package/dist/runtime/components/Textarea.vue.d.ts +95 -0
- package/dist/runtime/components/Toast.vue +49 -110
- package/dist/runtime/components/Toast.vue.d.ts +95 -0
- package/dist/runtime/components/Toaster.vue +70 -107
- package/dist/runtime/components/Toaster.vue.d.ts +63 -0
- package/dist/runtime/components/Tooltip.vue +38 -65
- package/dist/runtime/components/Tooltip.vue.d.ts +65 -0
- package/dist/runtime/components/Tree.vue +57 -150
- package/dist/runtime/components/Tree.vue.d.ts +128 -0
- package/dist/runtime/composables/defineShortcuts.d.ts +1 -1
- package/dist/runtime/composables/defineShortcuts.js +0 -1
- package/dist/runtime/composables/useAvatarGroup.d.ts +1 -1
- package/dist/runtime/composables/useButtonGroup.d.ts +2 -2
- package/dist/runtime/composables/useFormField.d.ts +2 -2
- package/dist/runtime/composables/useFormField.js +1 -1
- package/dist/runtime/composables/useOverlay.d.ts +16 -8
- package/dist/runtime/composables/useOverlay.js +14 -6
- package/dist/runtime/composables/usePortal.d.ts +6 -0
- package/dist/runtime/composables/usePortal.js +17 -0
- package/dist/runtime/index.css +1 -1
- package/dist/runtime/inertia/components/Link.vue +146 -0
- package/dist/runtime/inertia/components/Link.vue.d.ts +92 -0
- package/dist/runtime/inertia/stubs.d.ts +43 -0
- package/dist/runtime/inertia/stubs.js +82 -0
- package/dist/runtime/locale/bg.d.ts +3 -0
- package/dist/runtime/locale/bg.js +54 -0
- package/dist/runtime/locale/hy.d.ts +3 -0
- package/dist/runtime/locale/hy.js +54 -0
- package/dist/runtime/locale/index.d.ts +6 -1
- package/dist/runtime/locale/index.js +6 -1
- package/dist/runtime/locale/kk.d.ts +3 -0
- package/dist/runtime/locale/kk.js +54 -0
- package/dist/runtime/locale/tj.d.ts +3 -0
- package/dist/runtime/locale/tj.js +54 -0
- package/dist/runtime/locale/ug_cn.d.ts +3 -0
- package/dist/runtime/locale/ug_cn.js +55 -0
- package/dist/runtime/types/form.d.ts +5 -1
- package/dist/runtime/types/index.d.ts +2 -0
- package/dist/runtime/types/index.js +2 -0
- package/dist/runtime/types/utils.d.ts +70 -10
- package/dist/runtime/utils/index.d.ts +1 -0
- package/dist/runtime/utils/index.js +3 -0
- package/dist/runtime/utils/link.d.ts +4 -27
- package/dist/runtime/utils/link.js +32 -1
- package/dist/runtime/utils/tv.js +2 -2
- package/dist/runtime/vue/components/Icon.vue +7 -8
- package/dist/runtime/vue/components/Icon.vue.d.ts +14 -0
- package/dist/runtime/vue/components/Link.vue +118 -199
- package/dist/runtime/vue/components/Link.vue.d.ts +124 -0
- package/dist/runtime/vue/stubs.d.ts +5 -0
- package/dist/runtime/vue/stubs.js +11 -2
- package/dist/shared/{ui.BCaWD5Ek.mjs → ui.D7lOOabO.mjs} +623 -364
- package/dist/types.d.mts +5 -1
- package/dist/unplugin.d.mts +6 -1
- package/dist/unplugin.mjs +25 -4
- package/dist/vite.mjs +1 -1
- package/package.json +122 -64
- package/dist/module.cjs +0 -62
- package/dist/module.d.cts +0 -44
- package/dist/module.d.ts +0 -44
- package/dist/shared/ui.C6uTSFTI.cjs +0 -3555
- package/dist/types.d.ts +0 -1
- package/dist/unplugin.cjs +0 -232
- package/dist/unplugin.d.cts +0 -61
- package/dist/unplugin.d.ts +0 -61
- package/dist/vite.cjs +0 -23
- package/dist/vite.d.cts +0 -15
- package/dist/vite.d.ts +0 -15
|
@@ -1,142 +1,88 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import
|
|
3
|
-
import type { RadioGroupRootProps, RadioGroupRootEmits, AcceptableValue } from 'reka-ui'
|
|
4
|
-
import type { AppConfig } from '@nuxt/schema'
|
|
5
|
-
import _appConfig from '#build/app.config'
|
|
6
|
-
import theme from '#build/ui/radio-group'
|
|
7
|
-
import { tv } from '../utils/tv'
|
|
8
|
-
|
|
9
|
-
const appConfigRadioGroup = _appConfig as AppConfig & { ui: { radioGroup: Partial<typeof theme> } }
|
|
10
|
-
|
|
11
|
-
const radioGroup = tv({ extend: tv(theme), ...(appConfigRadioGroup.ui?.radioGroup || {}) })
|
|
12
|
-
|
|
13
|
-
type RadioGroupVariants = VariantProps<typeof radioGroup>
|
|
14
|
-
|
|
15
|
-
export interface RadioGroupItem {
|
|
16
|
-
label?: string
|
|
17
|
-
description?: string
|
|
18
|
-
disabled?: boolean
|
|
19
|
-
value?: string
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface RadioGroupProps<T> extends Pick<RadioGroupRootProps, 'defaultValue' | 'disabled' | 'loop' | 'modelValue' | 'name' | 'required'> {
|
|
23
|
-
/**
|
|
24
|
-
* The element or component this component should render as.
|
|
25
|
-
* @defaultValue 'div'
|
|
26
|
-
*/
|
|
27
|
-
as?: any
|
|
28
|
-
legend?: string
|
|
29
|
-
/**
|
|
30
|
-
* When `items` is an array of objects, select the field to use as the value.
|
|
31
|
-
* @defaultValue 'value'
|
|
32
|
-
*/
|
|
33
|
-
valueKey?: string
|
|
34
|
-
/**
|
|
35
|
-
* When `items` is an array of objects, select the field to use as the label.
|
|
36
|
-
* @defaultValue 'label'
|
|
37
|
-
*/
|
|
38
|
-
labelKey?: string
|
|
39
|
-
/**
|
|
40
|
-
* When `items` is an array of objects, select the field to use as the description.
|
|
41
|
-
* @defaultValue 'description'
|
|
42
|
-
*/
|
|
43
|
-
descriptionKey?: string
|
|
44
|
-
items?: T[]
|
|
45
|
-
/**
|
|
46
|
-
* @defaultValue 'md'
|
|
47
|
-
*/
|
|
48
|
-
size?: RadioGroupVariants['size']
|
|
49
|
-
/**
|
|
50
|
-
* @defaultValue 'primary'
|
|
51
|
-
*/
|
|
52
|
-
color?: RadioGroupVariants['color']
|
|
53
|
-
/**
|
|
54
|
-
* The orientation the radio buttons are laid out.
|
|
55
|
-
* @defaultValue 'vertical'
|
|
56
|
-
*/
|
|
57
|
-
orientation?: RadioGroupRootProps['orientation']
|
|
58
|
-
class?: any
|
|
59
|
-
ui?: Partial<typeof radioGroup.slots>
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export type RadioGroupEmits = RadioGroupRootEmits & {
|
|
63
|
-
change: [payload: Event]
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
type SlotProps<T> = (props: { item: T, modelValue?: AcceptableValue }) => any
|
|
67
|
-
|
|
68
|
-
export interface RadioGroupSlots<T> {
|
|
69
|
-
legend(props?: {}): any
|
|
70
|
-
label: SlotProps<T>
|
|
71
|
-
description: SlotProps<T>
|
|
72
|
-
}
|
|
1
|
+
<script>
|
|
2
|
+
import theme from "#build/ui/radio-group";
|
|
73
3
|
</script>
|
|
74
4
|
|
|
75
|
-
<script setup
|
|
76
|
-
import { computed, useId } from
|
|
77
|
-
import { RadioGroupRoot, RadioGroupItem, RadioGroupIndicator, Label, useForwardPropsEmits } from
|
|
78
|
-
import { reactivePick } from
|
|
79
|
-
import {
|
|
80
|
-
import {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
5
|
+
<script setup>
|
|
6
|
+
import { computed, useId } from "vue";
|
|
7
|
+
import { RadioGroupRoot, RadioGroupItem, RadioGroupIndicator, Label, useForwardPropsEmits } from "reka-ui";
|
|
8
|
+
import { reactivePick } from "@vueuse/core";
|
|
9
|
+
import { useAppConfig } from "#imports";
|
|
10
|
+
import { useFormField } from "../composables/useFormField";
|
|
11
|
+
import { get } from "../utils";
|
|
12
|
+
import { tv } from "../utils/tv";
|
|
13
|
+
const props = defineProps({
|
|
14
|
+
as: { type: null, required: false },
|
|
15
|
+
legend: { type: String, required: false },
|
|
16
|
+
valueKey: { type: String, required: false, default: "value" },
|
|
17
|
+
labelKey: { type: String, required: false, default: "label" },
|
|
18
|
+
descriptionKey: { type: String, required: false, default: "description" },
|
|
19
|
+
items: { type: Array, required: false },
|
|
20
|
+
size: { type: null, required: false },
|
|
21
|
+
variant: { type: null, required: false },
|
|
22
|
+
color: { type: null, required: false },
|
|
23
|
+
orientation: { type: null, required: false, default: "vertical" },
|
|
24
|
+
indicator: { type: null, required: false },
|
|
25
|
+
class: { type: null, required: false },
|
|
26
|
+
ui: { type: null, required: false },
|
|
27
|
+
defaultValue: { type: [String, Number, Object, null], required: false },
|
|
28
|
+
disabled: { type: Boolean, required: false },
|
|
29
|
+
loop: { type: Boolean, required: false },
|
|
30
|
+
modelValue: { type: [String, Number, Object, null], required: false },
|
|
31
|
+
name: { type: String, required: false },
|
|
32
|
+
required: { type: Boolean, required: false }
|
|
33
|
+
});
|
|
34
|
+
const emits = defineEmits(["update:modelValue", "change"]);
|
|
35
|
+
const slots = defineSlots();
|
|
36
|
+
const appConfig = useAppConfig();
|
|
37
|
+
const rootProps = useForwardPropsEmits(reactivePick(props, "as", "modelValue", "defaultValue", "orientation", "loop", "required"), emits);
|
|
38
|
+
const { emitFormChange, emitFormInput, color, name, size, id: _id, disabled, ariaAttrs } = useFormField(props, { bind: false });
|
|
39
|
+
const id = _id.value ?? useId();
|
|
40
|
+
const ui = computed(() => tv({ extend: tv(theme), ...appConfig.ui?.radioGroup || {} })({
|
|
97
41
|
size: size.value,
|
|
98
42
|
color: color.value,
|
|
99
43
|
disabled: disabled.value,
|
|
100
44
|
required: props.required,
|
|
101
|
-
orientation: props.orientation
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
45
|
+
orientation: props.orientation,
|
|
46
|
+
variant: props.variant,
|
|
47
|
+
indicator: props.indicator
|
|
48
|
+
}));
|
|
49
|
+
function normalizeItem(item) {
|
|
50
|
+
if (item === null) {
|
|
51
|
+
return {
|
|
52
|
+
id: `${id}:null`,
|
|
53
|
+
value: void 0,
|
|
54
|
+
label: void 0
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (typeof item === "string" || typeof item === "number") {
|
|
106
58
|
return {
|
|
107
59
|
id: `${id}:${item}`,
|
|
108
|
-
value: item,
|
|
109
|
-
label: item
|
|
110
|
-
}
|
|
60
|
+
value: String(item),
|
|
61
|
+
label: String(item)
|
|
62
|
+
};
|
|
111
63
|
}
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
const
|
|
115
|
-
const description = get(item, props.descriptionKey as string)
|
|
116
|
-
|
|
64
|
+
const value = get(item, props.valueKey);
|
|
65
|
+
const label = get(item, props.labelKey);
|
|
66
|
+
const description = get(item, props.descriptionKey);
|
|
117
67
|
return {
|
|
118
68
|
...item,
|
|
119
69
|
value,
|
|
120
70
|
label,
|
|
121
71
|
description,
|
|
122
72
|
id: `${id}:${value}`
|
|
123
|
-
}
|
|
73
|
+
};
|
|
124
74
|
}
|
|
125
|
-
|
|
126
75
|
const normalizedItems = computed(() => {
|
|
127
76
|
if (!props.items) {
|
|
128
|
-
return []
|
|
77
|
+
return [];
|
|
129
78
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
emits('change', event)
|
|
138
|
-
emitFormChange()
|
|
139
|
-
emitFormInput()
|
|
79
|
+
return props.items.map(normalizeItem);
|
|
80
|
+
});
|
|
81
|
+
function onUpdate(value) {
|
|
82
|
+
const event = new Event("change", { target: { value } });
|
|
83
|
+
emits("change", event);
|
|
84
|
+
emitFormChange();
|
|
85
|
+
emitFormInput();
|
|
140
86
|
}
|
|
141
87
|
</script>
|
|
142
88
|
|
|
@@ -156,7 +102,8 @@ function onUpdate(value: any) {
|
|
|
156
102
|
{{ legend }}
|
|
157
103
|
</slot>
|
|
158
104
|
</legend>
|
|
159
|
-
|
|
105
|
+
|
|
106
|
+
<component :is="variant === 'list' ? 'div' : Label" v-for="item in normalizedItems" :key="item.value" :class="ui.item({ class: props.ui?.item })">
|
|
160
107
|
<div :class="ui.container({ class: props.ui?.container })">
|
|
161
108
|
<RadioGroupItem
|
|
162
109
|
:id="item.id"
|
|
@@ -168,17 +115,19 @@ function onUpdate(value: any) {
|
|
|
168
115
|
</RadioGroupItem>
|
|
169
116
|
</div>
|
|
170
117
|
|
|
171
|
-
<div :class="ui.wrapper({ class: props.ui?.wrapper })">
|
|
172
|
-
<Label :class="ui.label({ class: props.ui?.label })"
|
|
173
|
-
<slot name="label" :item="item" :model-value="modelValue">
|
|
174
|
-
|
|
118
|
+
<div v-if="item.label || !!slots.label || (item.description || !!slots.description)" :class="ui.wrapper({ class: props.ui?.wrapper })">
|
|
119
|
+
<component :is="variant === 'list' ? Label : 'p'" v-if="item.label || !!slots.label" :for="item.id" :class="ui.label({ class: props.ui?.label })">
|
|
120
|
+
<slot name="label" :item="item" :model-value="modelValue">
|
|
121
|
+
{{ item.label }}
|
|
122
|
+
</slot>
|
|
123
|
+
</component>
|
|
175
124
|
<p v-if="item.description || !!slots.description" :class="ui.description({ class: props.ui?.description })">
|
|
176
125
|
<slot name="description" :item="item" :model-value="modelValue">
|
|
177
126
|
{{ item.description }}
|
|
178
127
|
</slot>
|
|
179
128
|
</p>
|
|
180
129
|
</div>
|
|
181
|
-
</
|
|
130
|
+
</component>
|
|
182
131
|
</fieldset>
|
|
183
132
|
</RadioGroupRoot>
|
|
184
133
|
</template>
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { RadioGroupRootProps, RadioGroupRootEmits } from 'reka-ui';
|
|
2
|
+
import type { AppConfig } from '@nuxt/schema';
|
|
3
|
+
import theme from '#build/ui/radio-group';
|
|
4
|
+
import type { AcceptableValue, ComponentConfig } from '../types/utils';
|
|
5
|
+
type RadioGroup = ComponentConfig<typeof theme, AppConfig, 'radioGroup'>;
|
|
6
|
+
export type RadioGroupValue = AcceptableValue;
|
|
7
|
+
export type RadioGroupItem = {
|
|
8
|
+
label?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
value?: string;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
} | RadioGroupValue;
|
|
14
|
+
export interface RadioGroupProps<T extends RadioGroupItem = RadioGroupItem> extends Pick<RadioGroupRootProps, 'defaultValue' | 'disabled' | 'loop' | 'modelValue' | 'name' | 'required'> {
|
|
15
|
+
/**
|
|
16
|
+
* The element or component this component should render as.
|
|
17
|
+
* @defaultValue 'div'
|
|
18
|
+
*/
|
|
19
|
+
as?: any;
|
|
20
|
+
legend?: string;
|
|
21
|
+
/**
|
|
22
|
+
* When `items` is an array of objects, select the field to use as the value.
|
|
23
|
+
* @defaultValue 'value'
|
|
24
|
+
*/
|
|
25
|
+
valueKey?: string;
|
|
26
|
+
/**
|
|
27
|
+
* When `items` is an array of objects, select the field to use as the label.
|
|
28
|
+
* @defaultValue 'label'
|
|
29
|
+
*/
|
|
30
|
+
labelKey?: string;
|
|
31
|
+
/**
|
|
32
|
+
* When `items` is an array of objects, select the field to use as the description.
|
|
33
|
+
* @defaultValue 'description'
|
|
34
|
+
*/
|
|
35
|
+
descriptionKey?: string;
|
|
36
|
+
items?: T[];
|
|
37
|
+
/**
|
|
38
|
+
* @defaultValue 'md'
|
|
39
|
+
*/
|
|
40
|
+
size?: RadioGroup['variants']['size'];
|
|
41
|
+
/**
|
|
42
|
+
* @defaultValue 'list'
|
|
43
|
+
*/
|
|
44
|
+
variant?: RadioGroup['variants']['variant'];
|
|
45
|
+
/**
|
|
46
|
+
* @defaultValue 'primary'
|
|
47
|
+
*/
|
|
48
|
+
color?: RadioGroup['variants']['color'];
|
|
49
|
+
/**
|
|
50
|
+
* The orientation the radio buttons are laid out.
|
|
51
|
+
* @defaultValue 'vertical'
|
|
52
|
+
*/
|
|
53
|
+
orientation?: RadioGroupRootProps['orientation'];
|
|
54
|
+
/**
|
|
55
|
+
* Position of the indicator.
|
|
56
|
+
* @defaultValue 'start'
|
|
57
|
+
*/
|
|
58
|
+
indicator?: RadioGroup['variants']['indicator'];
|
|
59
|
+
class?: any;
|
|
60
|
+
ui?: RadioGroup['slots'];
|
|
61
|
+
}
|
|
62
|
+
export type RadioGroupEmits = RadioGroupRootEmits & {
|
|
63
|
+
change: [payload: Event];
|
|
64
|
+
};
|
|
65
|
+
type SlotProps<T extends RadioGroupItem> = (props: {
|
|
66
|
+
item: T & {
|
|
67
|
+
id: string;
|
|
68
|
+
};
|
|
69
|
+
modelValue?: RadioGroupValue;
|
|
70
|
+
}) => any;
|
|
71
|
+
export interface RadioGroupSlots<T extends RadioGroupItem = RadioGroupItem> {
|
|
72
|
+
legend(props?: {}): any;
|
|
73
|
+
label: SlotProps<T>;
|
|
74
|
+
description: SlotProps<T>;
|
|
75
|
+
}
|
|
76
|
+
declare const _default: <T extends RadioGroupItem>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
77
|
+
props: __VLS_PrettifyLocal<any & RadioGroupProps<T> & Partial<{}>> & (import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps);
|
|
78
|
+
expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
|
|
79
|
+
attrs: any;
|
|
80
|
+
slots: Readonly<RadioGroupSlots<T>> & RadioGroupSlots<T>;
|
|
81
|
+
emit: ((evt: "change", payload: Event) => void) & ((evt: "update:modelValue", payload: string) => void);
|
|
82
|
+
}>) => import("vue").VNode & {
|
|
83
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
84
|
+
};
|
|
85
|
+
export default _default;
|
|
86
|
+
type __VLS_PrettifyLocal<T> = {
|
|
87
|
+
[K in keyof T]: T[K];
|
|
88
|
+
} & {};
|