@nuxt/ui 3.0.0-alpha.6 → 3.0.0-alpha.8
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 +20 -0
- package/.nuxt/ui/alert.ts +242 -0
- package/.nuxt/ui/avatar-group.ts +40 -0
- package/.nuxt/ui/avatar.ts +42 -0
- package/.nuxt/ui/badge.ts +194 -0
- package/.nuxt/ui/breadcrumb.ts +45 -0
- package/.nuxt/ui/button-group.ts +16 -0
- package/.nuxt/ui/button.ts +344 -0
- package/.nuxt/ui/card.ts +8 -0
- package/.nuxt/ui/carousel.ts +41 -0
- package/.nuxt/ui/checkbox.ts +105 -0
- package/.nuxt/ui/chip.ts +67 -0
- package/.nuxt/ui/collapsible.ts +6 -0
- package/.nuxt/ui/command-palette.ts +40 -0
- package/.nuxt/ui/container.ts +3 -0
- package/.nuxt/ui/context-menu.ts +198 -0
- package/.nuxt/ui/drawer.ts +55 -0
- package/.nuxt/ui/dropdown-menu.ts +199 -0
- package/.nuxt/ui/form-field.ts +40 -0
- package/.nuxt/ui/form.ts +3 -0
- package/.nuxt/ui/index.ts +43 -0
- package/.nuxt/ui/input-menu.ts +411 -0
- package/.nuxt/ui/input.ts +263 -0
- package/.nuxt/ui/kbd.ts +19 -0
- package/.nuxt/ui/link.ts +15 -0
- package/.nuxt/ui/modal.ts +28 -0
- package/.nuxt/ui/navigation-menu.ts +390 -0
- package/.nuxt/ui/pagination.ts +8 -0
- package/.nuxt/ui/popover.ts +6 -0
- package/.nuxt/ui/progress.ts +258 -0
- package/.nuxt/ui/radio-group.ts +112 -0
- package/.nuxt/ui/select-menu.ts +321 -0
- package/.nuxt/ui/select.ts +314 -0
- package/.nuxt/ui/separator.ts +143 -0
- package/.nuxt/ui/skeleton.ts +3 -0
- package/.nuxt/ui/slideover.ts +63 -0
- package/.nuxt/ui/slider.ts +148 -0
- package/.nuxt/ui/switch.ts +113 -0
- package/.nuxt/ui/table.ts +128 -0
- package/.nuxt/ui/tabs.ts +227 -0
- package/.nuxt/ui/textarea.ts +263 -0
- package/.nuxt/ui/toast.ts +66 -0
- package/.nuxt/ui/toaster.ts +75 -0
- package/.nuxt/ui/tooltip.ts +9 -0
- package/cli/templates.mjs +1 -1
- package/dist/chunks/component-meta.cjs +73264 -0
- package/dist/chunks/component-meta.mjs +73262 -0
- package/dist/client/devtools/200.html +1 -0
- package/dist/client/devtools/404.html +1 -0
- package/dist/client/devtools/_fonts/rP2Wp2ywxg089UriCZaSExd86J3t9jz86MvyyKK58UfivUw4aw-SK92LTmKP0.woff2 +0 -0
- package/dist/client/devtools/_fonts/rP2Wp2ywxg089UriCZaSExd86J3t9jz86MvyyKy58UfivUw-9uYm8d48E4.woff2 +0 -0
- package/dist/client/devtools/_fonts/rP2Yp2ywxg089UriI5-g4vlH9VoD8Cmcqbu0-K6z9mXg-VNw7NHvqnp.woff2 +0 -0
- package/dist/client/devtools/_fonts/rP2Yp2ywxg089UriI5-g4vlH9VoD8Cmcqbu6-K6z9mXgjU0-EkYdMs3MAX.woff2 +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat-7DW3w-R7n06NbhGy.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat-JDG3w-leGNfkTmsj.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat-JDW3w-ciElMF03ku.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat8JCm3w-sB722Uoa0f.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat8JDW3w-PBDI1JDjwV.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat8gCm3w-0q1hqVn09O.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat9XCm3w-ByvzuLy2fa.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat9uCm3w-5TKCIs6EEw.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat_XDW3w-r2swRDGfn2.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAC5thTQ-ldB60l5U8r.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAIpthTQ-wbFKGFDrgo.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAIpxhTQ-LLUBv5jskj.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwARZthTQ-F71RdTRbNg.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwA_JxhTQ-6nh65gZkc0.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAfJthTQ-aMoWEJLmTt.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAkJxhTQ-WMBvmLOgKm.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAop1hTQ-utGC2hnWq2.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAopxhTQ-YpyTieVa5B.woff +0 -0
- package/dist/client/devtools/_nuxt/Bj9hdafK.js +1 -0
- package/dist/client/devtools/_nuxt/DM3_wAgz.js +62 -0
- package/dist/client/devtools/_nuxt/builds/latest.json +1 -0
- package/dist/client/devtools/_nuxt/builds/meta/e6b425f7-b919-4014-915b-0ea07c316790.json +1 -0
- package/dist/client/devtools/_nuxt/entry.DaJP-ZMB.css +24 -0
- package/dist/client/devtools/_nuxt/error-404.B0Nmv3fV.css +1 -0
- package/dist/client/devtools/_nuxt/error-500.C8fgTxVz.css +1 -0
- package/dist/client/devtools/_nuxt/hKiujHsR.js +1 -0
- package/dist/client/devtools/favicon.svg +1 -0
- package/dist/client/devtools/index.html +1 -0
- package/dist/devtools/runtime/DevtoolsRenderer.vue +53 -0
- package/dist/devtools/runtime/examples/AvatarGroupExample.vue +7 -0
- package/dist/devtools/runtime/examples/ButtonGroupExample.vue +8 -0
- package/dist/devtools/runtime/examples/CardExample.vue +13 -0
- package/dist/devtools/runtime/examples/CarouselExample.vue +13 -0
- package/dist/devtools/runtime/examples/ChipExample.vue +5 -0
- package/dist/devtools/runtime/examples/CollapsibleExample.vue +8 -0
- package/dist/devtools/runtime/examples/CommandPaletteExample.vue +29 -0
- package/dist/devtools/runtime/examples/ContainerExample.vue +5 -0
- package/dist/devtools/runtime/examples/ContextMenuExample.vue +5 -0
- package/dist/devtools/runtime/examples/DrawerExample.vue +8 -0
- package/dist/devtools/runtime/examples/DropdownMenuExample.vue +5 -0
- package/dist/devtools/runtime/examples/FormExample.vue +30 -0
- package/dist/devtools/runtime/examples/FormFieldExample.vue +5 -0
- package/dist/devtools/runtime/examples/LinkExample.vue +5 -0
- package/dist/devtools/runtime/examples/ModalExample.vue +8 -0
- package/dist/devtools/runtime/examples/PopoverExample.vue +8 -0
- package/dist/devtools/runtime/examples/SkeletonExample.vue +3 -0
- package/dist/devtools/runtime/examples/SlideoverExample.vue +8 -0
- package/dist/devtools/runtime/examples/ToasterExample.vue +11 -0
- package/dist/devtools/runtime/examples/TooltipExample.vue +5 -0
- package/dist/module.cjs +222 -4
- package/dist/module.d.cts +54 -0
- package/dist/module.d.mts +16 -6
- package/dist/module.d.ts +16 -6
- package/dist/module.json +1 -1
- package/dist/module.mjs +157 -2629
- package/dist/runtime/components/Accordion.vue +45 -6
- package/dist/runtime/components/Alert.vue +4 -0
- package/dist/runtime/components/App.vue +8 -0
- package/dist/runtime/components/Avatar.vue +23 -5
- package/dist/runtime/components/AvatarGroup.vue +3 -0
- package/dist/runtime/components/Badge.vue +33 -3
- package/dist/runtime/components/Breadcrumb.vue +39 -7
- package/dist/runtime/components/Button.vue +10 -3
- package/dist/runtime/components/ButtonGroup.vue +4 -1
- package/dist/runtime/components/Card.vue +3 -0
- package/dist/runtime/components/Carousel.vue +13 -8
- package/dist/runtime/components/Checkbox.vue +7 -6
- package/dist/runtime/components/Chip.vue +9 -2
- package/dist/runtime/components/Collapsible.vue +3 -0
- package/dist/runtime/components/CommandPalette.vue +28 -17
- package/dist/runtime/components/Container.vue +3 -0
- package/dist/runtime/components/ContextMenu.vue +95 -10
- package/dist/runtime/components/ContextMenuContent.vue +41 -13
- package/dist/runtime/components/Drawer.vue +3 -0
- package/dist/runtime/components/DropdownMenu.vue +83 -10
- package/dist/runtime/components/DropdownMenuContent.vue +43 -13
- package/dist/runtime/components/Form.vue +6 -1
- package/dist/runtime/components/FormField.vue +3 -0
- package/dist/runtime/components/Input.vue +7 -4
- package/dist/runtime/components/InputMenu.vue +61 -34
- package/dist/runtime/components/Kbd.vue +2 -0
- package/dist/runtime/components/Link.vue +50 -1
- package/dist/runtime/components/LinkBase.vue +4 -2
- package/dist/runtime/components/Modal.vue +3 -0
- package/dist/runtime/components/NavigationMenu.vue +159 -75
- package/dist/runtime/components/Pagination.vue +5 -1
- package/dist/runtime/components/Popover.vue +3 -0
- package/dist/runtime/components/Progress.vue +1 -1
- package/dist/runtime/components/RadioGroup.vue +26 -4
- package/dist/runtime/components/Select.vue +44 -21
- package/dist/runtime/components/SelectMenu.vue +67 -43
- package/dist/runtime/components/Separator.vue +1 -1
- package/dist/runtime/components/Skeleton.vue +3 -0
- package/dist/runtime/components/Slideover.vue +3 -0
- package/dist/runtime/components/Slider.vue +1 -1
- package/dist/runtime/components/Switch.vue +5 -1
- package/dist/runtime/components/Table.vue +241 -0
- package/dist/runtime/components/Tabs.vue +35 -8
- package/dist/runtime/components/Toast.vue +4 -0
- package/dist/runtime/components/Toaster.vue +8 -1
- package/dist/runtime/components/Tooltip.vue +3 -0
- package/dist/runtime/composables/defineShortcuts.js +1 -7
- package/dist/runtime/composables/extendDevtoolsMeta.d.ts +7 -0
- package/dist/runtime/composables/extendDevtoolsMeta.js +2 -0
- package/dist/runtime/composables/useComponentIcons.d.ts +3 -0
- package/dist/runtime/composables/useKbd.d.ts +10 -3
- package/dist/runtime/composables/useKbd.js +14 -8
- package/dist/runtime/composables/useModal.d.ts +1 -1
- package/dist/runtime/composables/useSlideover.d.ts +1 -1
- package/dist/runtime/index.css +1 -1
- package/dist/runtime/keyframes.css +1 -0
- package/dist/runtime/types/form.d.ts +2 -1
- package/dist/runtime/types/index.d.ts +1 -0
- package/dist/runtime/types/index.js +1 -0
- package/dist/runtime/types/utils.d.ts +7 -0
- package/dist/runtime/utils/form.d.ts +3 -0
- package/dist/runtime/utils/form.js +14 -0
- package/dist/runtime/utils/index.d.ts +1 -0
- package/dist/runtime/utils/index.js +3 -0
- package/dist/runtime/utils/link.d.ts +1 -1
- package/dist/runtime/vue/components/Icon.vue +15 -0
- package/dist/runtime/vue/components/Link.vue +195 -0
- package/dist/runtime/vue/plugins/color-mode.d.ts +4 -0
- package/dist/runtime/vue/plugins/color-mode.js +6 -0
- package/dist/runtime/vue/plugins/head.d.ts +4 -0
- package/dist/runtime/vue/plugins/head.js +6 -0
- package/dist/runtime/vue/stubs.d.ts +15 -0
- package/dist/runtime/vue/stubs.js +27 -0
- package/dist/shared/ui.BU7wzH0D.cjs +2872 -0
- package/dist/shared/ui.BufKhDiD.mjs +2865 -0
- package/dist/unplugin.cjs +192 -0
- package/dist/unplugin.d.cts +47 -0
- package/dist/unplugin.d.mts +47 -0
- package/dist/unplugin.d.ts +47 -0
- package/dist/unplugin.mjs +181 -0
- package/dist/vite.cjs +22 -0
- package/dist/vite.d.cts +13 -0
- package/dist/vite.d.mts +13 -0
- package/dist/vite.d.ts +13 -0
- package/dist/vite.mjs +20 -0
- package/package.json +73 -32
- package/vue-plugin.d.ts +5 -0
- package/cli/node_modules/.ignored/citty/LICENSE +0 -36
- package/cli/node_modules/.ignored/citty/README.md +0 -134
- package/cli/node_modules/.ignored/citty/dist/index.cjs +0 -475
- package/cli/node_modules/.ignored/citty/dist/index.d.cts +0 -80
- package/cli/node_modules/.ignored/citty/dist/index.d.mts +0 -80
- package/cli/node_modules/.ignored/citty/dist/index.d.ts +0 -80
- package/cli/node_modules/.ignored/citty/dist/index.mjs +0 -463
- package/cli/node_modules/.ignored/citty/package.json +0 -49
- package/cli/node_modules/.ignored/consola/LICENSE +0 -47
- package/cli/node_modules/.ignored/consola/README.md +0 -318
- package/cli/node_modules/.ignored/consola/core.d.ts +0 -1
- package/cli/node_modules/.ignored/consola/dist/basic.cjs +0 -32
- package/cli/node_modules/.ignored/consola/dist/basic.d.ts +0 -9
- package/cli/node_modules/.ignored/consola/dist/basic.mjs +0 -24
- package/cli/node_modules/.ignored/consola/dist/browser.cjs +0 -80
- package/cli/node_modules/.ignored/consola/dist/browser.d.ts +0 -7
- package/cli/node_modules/.ignored/consola/dist/browser.mjs +0 -72
- package/cli/node_modules/.ignored/consola/dist/chunks/prompt.cjs +0 -436
- package/cli/node_modules/.ignored/consola/dist/chunks/prompt.mjs +0 -429
- package/cli/node_modules/.ignored/consola/dist/core.cjs +0 -415
- package/cli/node_modules/.ignored/consola/dist/core.d.ts +0 -124
- package/cli/node_modules/.ignored/consola/dist/core.mjs +0 -410
- package/cli/node_modules/.ignored/consola/dist/index.cjs +0 -21
- package/cli/node_modules/.ignored/consola/dist/index.d.ts +0 -9
- package/cli/node_modules/.ignored/consola/dist/index.mjs +0 -8
- package/cli/node_modules/.ignored/consola/dist/shared/consola.06ad8a64.mjs +0 -62
- package/cli/node_modules/.ignored/consola/dist/shared/consola.36c0034f.mjs +0 -636
- package/cli/node_modules/.ignored/consola/dist/shared/consola.4bbae468.cjs +0 -645
- package/cli/node_modules/.ignored/consola/dist/shared/consola.deac7d5a.cjs +0 -65
- package/cli/node_modules/.ignored/consola/dist/utils.cjs +0 -308
- package/cli/node_modules/.ignored/consola/dist/utils.d.ts +0 -169
- package/cli/node_modules/.ignored/consola/dist/utils.mjs +0 -284
- package/cli/node_modules/.ignored/consola/lib/index.cjs +0 -9
- package/cli/node_modules/.ignored/consola/package.json +0 -101
- package/cli/node_modules/.ignored/consola/utils.d.ts +0 -1
- package/cli/node_modules/.ignored/pathe/LICENSE +0 -44
- package/cli/node_modules/.ignored/pathe/README.md +0 -69
- package/cli/node_modules/.ignored/pathe/dist/index.cjs +0 -23
- package/cli/node_modules/.ignored/pathe/dist/index.d.cts +0 -36
- package/cli/node_modules/.ignored/pathe/dist/index.d.mts +0 -36
- package/cli/node_modules/.ignored/pathe/dist/index.d.ts +0 -36
- package/cli/node_modules/.ignored/pathe/dist/index.mjs +0 -1
- package/cli/node_modules/.ignored/pathe/dist/shared/pathe.1f0a373c.cjs +0 -238
- package/cli/node_modules/.ignored/pathe/dist/shared/pathe.ff20891b.mjs +0 -221
- package/cli/node_modules/.ignored/pathe/dist/utils.cjs +0 -58
- package/cli/node_modules/.ignored/pathe/dist/utils.d.cts +0 -5
- package/cli/node_modules/.ignored/pathe/dist/utils.d.mts +0 -5
- package/cli/node_modules/.ignored/pathe/dist/utils.d.ts +0 -5
- package/cli/node_modules/.ignored/pathe/dist/utils.mjs +0 -54
- package/cli/node_modules/.ignored/pathe/package.json +0 -48
- package/cli/node_modules/.ignored/pathe/utils.d.ts +0 -1
- package/cli/node_modules/.ignored/scule/LICENSE +0 -21
- package/cli/node_modules/.ignored/scule/README.md +0 -149
- package/cli/node_modules/.ignored/scule/dist/index.cjs +0 -92
- package/cli/node_modules/.ignored/scule/dist/index.d.cts +0 -57
- package/cli/node_modules/.ignored/scule/dist/index.d.mts +0 -57
- package/cli/node_modules/.ignored/scule/dist/index.d.ts +0 -57
- package/cli/node_modules/.ignored/scule/dist/index.mjs +0 -80
- package/cli/node_modules/.ignored/scule/package.json +0 -43
- package/cli/node_modules/.package-lock.json +0 -33
- package/dist/runtime/types/component.d.ts +0 -17
- package/dist/runtime/types/component.js +0 -0
|
@@ -1,33 +1,32 @@
|
|
|
1
|
-
<!-- eslint-disable vue/block-tag-newline -->
|
|
2
1
|
<script lang="ts">
|
|
3
2
|
import { tv, type VariantProps } from 'tailwind-variants'
|
|
4
|
-
import type { NavigationMenuRootProps, NavigationMenuRootEmits,
|
|
3
|
+
import type { NavigationMenuRootProps, NavigationMenuRootEmits, NavigationMenuContentProps } from 'radix-vue'
|
|
5
4
|
import type { AppConfig } from '@nuxt/schema'
|
|
6
5
|
import _appConfig from '#build/app.config'
|
|
7
6
|
import theme from '#build/ui/navigation-menu'
|
|
7
|
+
import { extendDevtoolsMeta } from '../composables/extendDevtoolsMeta'
|
|
8
8
|
import type { AvatarProps, BadgeProps, LinkProps } from '../types'
|
|
9
|
-
import type { DynamicSlots, PartialString } from '../types/utils'
|
|
9
|
+
import type { DynamicSlots, MaybeArrayOfArray, MaybeArrayOfArrayItem, PartialString } from '../types/utils'
|
|
10
10
|
|
|
11
11
|
const appConfig = _appConfig as AppConfig & { ui: { navigationMenu: Partial<typeof theme> } }
|
|
12
12
|
|
|
13
13
|
const navigationMenu = tv({ extend: tv(theme), ...(appConfig.ui?.navigationMenu || {}) })
|
|
14
14
|
|
|
15
|
-
export interface NavigationMenuChildItem extends Omit<
|
|
16
|
-
|
|
15
|
+
export interface NavigationMenuChildItem extends Omit<NavigationMenuItem, 'children'> {
|
|
16
|
+
/** Description is only used when `orientation` is `horizontal`. */
|
|
17
17
|
description?: string
|
|
18
|
-
icon?: string
|
|
19
|
-
select?(e: Event): void
|
|
20
18
|
}
|
|
21
19
|
|
|
22
|
-
export interface NavigationMenuItem extends Omit<LinkProps, 'raw' | 'custom'
|
|
20
|
+
export interface NavigationMenuItem extends Omit<LinkProps, 'raw' | 'custom'> {
|
|
23
21
|
label?: string
|
|
24
22
|
icon?: string
|
|
25
23
|
avatar?: AvatarProps
|
|
26
24
|
badge?: string | number | BadgeProps
|
|
27
25
|
trailingIcon?: string
|
|
28
26
|
slot?: string
|
|
27
|
+
value?: string
|
|
29
28
|
children?: NavigationMenuChildItem[]
|
|
30
|
-
|
|
29
|
+
onSelect?(e: Event): void
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
type NavigationMenuVariants = VariantProps<typeof navigationMenu>
|
|
@@ -35,7 +34,7 @@ type NavigationMenuVariants = VariantProps<typeof navigationMenu>
|
|
|
35
34
|
export interface NavigationMenuProps<T> extends Pick<NavigationMenuRootProps, 'defaultValue' | 'delayDuration' | 'disableClickTrigger' | 'disableHoverTrigger' | 'modelValue' | 'skipDelayDuration'> {
|
|
36
35
|
/**
|
|
37
36
|
* The element or component this component should render as.
|
|
38
|
-
* @defaultValue
|
|
37
|
+
* @defaultValue 'div'
|
|
39
38
|
*/
|
|
40
39
|
as?: any
|
|
41
40
|
/**
|
|
@@ -43,7 +42,7 @@ export interface NavigationMenuProps<T> extends Pick<NavigationMenuRootProps, 'd
|
|
|
43
42
|
* @defaultValue appConfig.ui.icons.chevronDown
|
|
44
43
|
*/
|
|
45
44
|
trailingIcon?: string
|
|
46
|
-
items?: T
|
|
45
|
+
items?: T
|
|
47
46
|
color?: NavigationMenuVariants['color']
|
|
48
47
|
variant?: NavigationMenuVariants['variant']
|
|
49
48
|
/**
|
|
@@ -61,6 +60,11 @@ export interface NavigationMenuProps<T> extends Pick<NavigationMenuRootProps, 'd
|
|
|
61
60
|
* @defaultValue false
|
|
62
61
|
*/
|
|
63
62
|
arrow?: boolean
|
|
63
|
+
/**
|
|
64
|
+
* The key used to get the label from the item.
|
|
65
|
+
* @defaultValue 'label'
|
|
66
|
+
*/
|
|
67
|
+
labelKey?: string
|
|
64
68
|
class?: any
|
|
65
69
|
ui?: PartialString<typeof navigationMenu.slots>
|
|
66
70
|
}
|
|
@@ -74,31 +78,83 @@ export type NavigationMenuSlots<T extends { slot?: string }> = {
|
|
|
74
78
|
'item-leading': SlotProps<T>
|
|
75
79
|
'item-label': SlotProps<T>
|
|
76
80
|
'item-trailing': SlotProps<T>
|
|
81
|
+
'item-content': SlotProps<T>
|
|
77
82
|
} & DynamicSlots<T, SlotProps<T>>
|
|
78
83
|
|
|
84
|
+
extendDevtoolsMeta({
|
|
85
|
+
ignoreProps: ['items'],
|
|
86
|
+
defaultProps: {
|
|
87
|
+
items: [
|
|
88
|
+
[{
|
|
89
|
+
label: 'Documentation',
|
|
90
|
+
icon: 'i-lucide-book-open',
|
|
91
|
+
badge: 10,
|
|
92
|
+
children: [{
|
|
93
|
+
label: 'Introduction',
|
|
94
|
+
description: 'Fully styled and customizable components for Nuxt.',
|
|
95
|
+
icon: 'i-lucide-house'
|
|
96
|
+
}, {
|
|
97
|
+
label: 'Installation',
|
|
98
|
+
description: 'Learn how to install and configure Nuxt UI in your application.',
|
|
99
|
+
icon: 'i-lucide-cloud-download'
|
|
100
|
+
}, {
|
|
101
|
+
label: 'Theming',
|
|
102
|
+
description: 'Learn how to customize the look and feel of the components.',
|
|
103
|
+
icon: 'i-lucide-swatch-book'
|
|
104
|
+
}, {
|
|
105
|
+
label: 'Shortcuts',
|
|
106
|
+
description: 'Learn how to display and define keyboard shortcuts in your app.',
|
|
107
|
+
icon: 'i-lucide-monitor'
|
|
108
|
+
}]
|
|
109
|
+
}, {
|
|
110
|
+
label: 'GitHub',
|
|
111
|
+
icon: 'i-simple-icons-github',
|
|
112
|
+
to: 'https://github.com/nuxt/ui',
|
|
113
|
+
target: '_blank'
|
|
114
|
+
}, {
|
|
115
|
+
label: 'Help',
|
|
116
|
+
icon: 'i-lucide-circle-help',
|
|
117
|
+
disabled: true
|
|
118
|
+
}]
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
})
|
|
79
122
|
</script>
|
|
80
123
|
|
|
81
|
-
<script setup lang="ts" generic="T extends NavigationMenuItem">
|
|
82
|
-
import { computed, toRef } from 'vue'
|
|
124
|
+
<script setup lang="ts" generic="T extends MaybeArrayOfArrayItem<I>, I extends MaybeArrayOfArray<NavigationMenuItem>">
|
|
125
|
+
import { computed, reactive, toRef } from 'vue'
|
|
83
126
|
import { NavigationMenuRoot, NavigationMenuList, NavigationMenuItem, NavigationMenuTrigger, NavigationMenuContent, NavigationMenuLink, NavigationMenuIndicator, NavigationMenuViewport, useForwardPropsEmits } from 'radix-vue'
|
|
84
|
-
import {
|
|
127
|
+
import { createReusableTemplate } from '@vueuse/core'
|
|
128
|
+
import { get } from '../utils'
|
|
129
|
+
import { pickLinkProps } from '../utils/link'
|
|
85
130
|
import ULinkBase from './LinkBase.vue'
|
|
86
131
|
import ULink from './Link.vue'
|
|
87
132
|
import UAvatar from './Avatar.vue'
|
|
88
133
|
import UIcon from './Icon.vue'
|
|
89
134
|
import UBadge from './Badge.vue'
|
|
90
|
-
import
|
|
135
|
+
import UCollapsible from './Collapsible.vue'
|
|
91
136
|
|
|
92
|
-
const props = withDefaults(defineProps<NavigationMenuProps<
|
|
137
|
+
const props = withDefaults(defineProps<NavigationMenuProps<I>>(), {
|
|
93
138
|
orientation: 'horizontal',
|
|
94
|
-
delayDuration: 0
|
|
139
|
+
delayDuration: 0,
|
|
140
|
+
labelKey: 'label'
|
|
95
141
|
})
|
|
96
142
|
const emits = defineEmits<NavigationMenuEmits>()
|
|
97
143
|
const slots = defineSlots<NavigationMenuSlots<T>>()
|
|
98
144
|
|
|
99
|
-
const rootProps = useForwardPropsEmits(
|
|
145
|
+
const rootProps = useForwardPropsEmits(reactive({
|
|
146
|
+
as: props.as,
|
|
147
|
+
modelValue: props.modelValue,
|
|
148
|
+
defaultValue: props.defaultValue,
|
|
149
|
+
delayDuration: props.delayDuration,
|
|
150
|
+
skipDelayDuration: props.skipDelayDuration,
|
|
151
|
+
orientation: props.orientation
|
|
152
|
+
}), emits)
|
|
153
|
+
|
|
100
154
|
const contentProps = toRef(() => props.content)
|
|
101
155
|
|
|
156
|
+
const [DefineItemTemplate, ReuseItemTemplate] = createReusableTemplate<{ item: NavigationMenuItem, active?: boolean, index: number }>()
|
|
157
|
+
|
|
102
158
|
const ui = computed(() => navigationMenu({
|
|
103
159
|
orientation: props.orientation,
|
|
104
160
|
color: props.color,
|
|
@@ -111,76 +167,104 @@ const lists = computed(() => props.items?.length ? (Array.isArray(props.items[0]
|
|
|
111
167
|
</script>
|
|
112
168
|
|
|
113
169
|
<template>
|
|
114
|
-
<
|
|
170
|
+
<DefineItemTemplate v-slot="{ item, active, index }">
|
|
171
|
+
<slot :name="item.slot || 'item'" :item="(item as T)" :index="index">
|
|
172
|
+
<slot :name="item.slot ? `${item.slot}-leading` : 'item-leading'" :item="(item as T)" :active="active" :index="index">
|
|
173
|
+
<UAvatar v-if="item.avatar" :size="((props.ui?.linkLeadingAvatarSize || ui.linkLeadingAvatarSize()) as AvatarProps['size'])" v-bind="item.avatar" :class="ui.linkLeadingAvatar({ class: props.ui?.linkLeadingAvatar, active, disabled: !!item.disabled })" />
|
|
174
|
+
<UIcon v-else-if="item.icon" :name="item.icon" :class="ui.linkLeadingIcon({ class: props.ui?.linkLeadingIcon, active, disabled: !!item.disabled })" />
|
|
175
|
+
</slot>
|
|
176
|
+
|
|
177
|
+
<span v-if="get(item, props.labelKey as string) || !!slots[item.slot ? `${item.slot}-label` : 'item-label']" :class="ui.linkLabel({ class: props.ui?.linkLabel })">
|
|
178
|
+
<slot :name="item.slot ? `${item.slot}-label` : 'item-label'" :item="(item as T)" :active="active" :index="index">
|
|
179
|
+
{{ get(item, props.labelKey as string) }}
|
|
180
|
+
</slot>
|
|
181
|
+
|
|
182
|
+
<UIcon v-if="item.target === '_blank'" :name="appConfig.ui.icons.external" :class="ui.linkLabelExternalIcon({ class: props.ui?.linkLabelExternalIcon, active })" />
|
|
183
|
+
</span>
|
|
184
|
+
|
|
185
|
+
<span v-if="item.badge || item.children?.length || !!slots[item.slot ? `${item.slot}-trailing` : 'item-trailing']" :class="ui.linkTrailing({ class: props.ui?.linkTrailing })">
|
|
186
|
+
<slot :name="item.slot ? `${item.slot}-trailing` : 'item-trailing'" :item="(item as T)" :active="active" :index="index">
|
|
187
|
+
<UBadge
|
|
188
|
+
v-if="item.badge"
|
|
189
|
+
color="neutral"
|
|
190
|
+
variant="outline"
|
|
191
|
+
:size="((props.ui?.linkTrailingBadgeSize || ui.linkTrailingBadgeSize()) as BadgeProps['size'])"
|
|
192
|
+
v-bind="(typeof item.badge === 'string' || typeof item.badge === 'number') ? { label: item.badge } : item.badge"
|
|
193
|
+
:class="ui.linkTrailingBadge({ class: props.ui?.linkTrailingBadge })"
|
|
194
|
+
/>
|
|
195
|
+
|
|
196
|
+
<UIcon v-if="(orientation === 'horizontal' && (item.children?.length || !!slots[item.slot ? `${item.slot}-content` : 'item-content'])) || (orientation === 'vertical' && item.children?.length)" :name="item.trailingIcon || trailingIcon || appConfig.ui.icons.chevronDown" :class="ui.linkTrailingIcon({ class: props.ui?.linkTrailingIcon, active })" />
|
|
197
|
+
</slot>
|
|
198
|
+
</span>
|
|
199
|
+
</slot>
|
|
200
|
+
</DefineItemTemplate>
|
|
201
|
+
|
|
202
|
+
<NavigationMenuRoot v-bind="rootProps" :data-orientation="orientation" :class="ui.root({ class: [props.class, props.ui?.root] })">
|
|
115
203
|
<template v-for="(list, listIndex) in lists" :key="`list-${listIndex}`">
|
|
116
204
|
<NavigationMenuList :class="ui.list({ class: props.ui?.list })">
|
|
117
|
-
<
|
|
205
|
+
<component
|
|
206
|
+
:is="(item.children?.length && orientation === 'vertical') ? UCollapsible : NavigationMenuItem"
|
|
207
|
+
v-for="(item, index) in list"
|
|
208
|
+
:key="`list-${listIndex}-${index}`"
|
|
209
|
+
as="li"
|
|
210
|
+
:value="item.value || String(index)"
|
|
211
|
+
:class="ui.item({ class: props.ui?.item })"
|
|
212
|
+
>
|
|
118
213
|
<ULink v-slot="{ active, ...slotProps }" v-bind="pickLinkProps(item)" custom>
|
|
119
214
|
<component
|
|
120
|
-
:is="item.children?.length ? NavigationMenuTrigger : NavigationMenuLink"
|
|
121
|
-
v-bind="item.children?.length ? { disabled: item.disabled } : { active }"
|
|
215
|
+
:is="(orientation === 'horizontal' && (item.children?.length || !!slots[item.slot ? `${item.slot}-content` : 'item-content'])) ? NavigationMenuTrigger : NavigationMenuLink"
|
|
122
216
|
as-child
|
|
123
217
|
:active="active"
|
|
124
|
-
|
|
218
|
+
:disabled="item.disabled"
|
|
219
|
+
@select="item.onSelect"
|
|
125
220
|
>
|
|
126
221
|
<ULinkBase v-bind="slotProps" :class="ui.link({ class: [props.ui?.link, item.class], active, disabled: !!item.disabled })">
|
|
127
|
-
<
|
|
128
|
-
<slot :name="item.slot ? `${item.slot}-leading`: 'item-leading'" :item="item" :active="active" :index="index">
|
|
129
|
-
<UAvatar v-if="item.avatar" :size="((props.ui?.linkLeadingAvatarSize || ui.linkLeadingAvatarSize()) as AvatarProps['size'])" v-bind="item.avatar" :class="ui.linkLeadingAvatar({ class: props.ui?.linkLeadingAvatar, active, disabled: !!item.disabled })" />
|
|
130
|
-
<UIcon v-else-if="item.icon" :name="item.icon" :class="ui.linkLeadingIcon({ class: props.ui?.linkLeadingIcon, active, disabled: !!item.disabled })" />
|
|
131
|
-
</slot>
|
|
132
|
-
|
|
133
|
-
<span v-if="item.label || !!slots[item.slot ? `${item.slot}-label`: 'item-label']" :class="ui.linkLabel({ class: props.ui?.linkLabel })">
|
|
134
|
-
<slot :name="item.slot ? `${item.slot}-label`: 'item-label'" :item="item" :active="active" :index="index">
|
|
135
|
-
{{ item.label }}
|
|
136
|
-
</slot>
|
|
137
|
-
|
|
138
|
-
<UIcon v-if="item.target === '_blank'" :name="appConfig.ui.icons.external" :class="ui.linkLabelExternalIcon({ class: props.ui?.linkLabelExternalIcon, active })" />
|
|
139
|
-
</span>
|
|
140
|
-
|
|
141
|
-
<span v-if="item.badge || (item.children?.length && orientation === 'horizontal') || !!slots[item.slot ? `${item.slot}-trailing`: 'item-trailing']" :class="ui.linkTrailing({ class: props.ui?.linkTrailing })">
|
|
142
|
-
<slot :name="item.slot ? `${item.slot}-trailing`: 'item-trailing'" :item="item" :active="active" :index="index">
|
|
143
|
-
<UBadge
|
|
144
|
-
v-if="item.badge"
|
|
145
|
-
color="neutral"
|
|
146
|
-
variant="outline"
|
|
147
|
-
:size="((props.ui?.linkTrailingBadgeSize || ui.linkTrailingBadgeSize()) as BadgeProps['size'])"
|
|
148
|
-
v-bind="(typeof item.badge === 'string' || typeof item.badge === 'number') ? { label: item.badge } : item.badge"
|
|
149
|
-
:class="ui.linkTrailingBadge({ class: props.ui?.linkTrailingBadge })"
|
|
150
|
-
/>
|
|
151
|
-
<UIcon v-if="item.children?.length && orientation === 'horizontal'" :name="item.trailingIcon || trailingIcon || appConfig.ui.icons.chevronDown" :class="ui.linkTrailingIcon({ class: props.ui?.linkTrailingIcon, active })" />
|
|
152
|
-
</slot>
|
|
153
|
-
</span>
|
|
154
|
-
</slot>
|
|
222
|
+
<ReuseItemTemplate :item="(item as T)" :active="active" :index="index" />
|
|
155
223
|
</ULinkBase>
|
|
156
224
|
</component>
|
|
157
225
|
|
|
158
|
-
<NavigationMenuContent v-if="item.children?.length
|
|
159
|
-
<
|
|
160
|
-
<
|
|
161
|
-
<
|
|
162
|
-
<
|
|
163
|
-
<
|
|
164
|
-
<
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
<
|
|
168
|
-
{
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
226
|
+
<NavigationMenuContent v-if="orientation === 'horizontal' && (item.children?.length || !!slots[item.slot ? `${item.slot}-content` : 'item-content'])" v-bind="contentProps" :class="ui.content({ class: props.ui?.content })">
|
|
227
|
+
<slot :name="item.slot ? `${item.slot}-content` : 'item-content'" :item="(item as T)" :active="active" :index="index">
|
|
228
|
+
<ul :class="ui.childList({ class: props.ui?.childList })">
|
|
229
|
+
<li v-for="(childItem, childIndex) in item.children" :key="childIndex" :class="ui.childItem({ class: props.ui?.childItem })">
|
|
230
|
+
<ULink v-slot="{ active: childActive, ...childSlotProps }" v-bind="pickLinkProps(childItem)" custom>
|
|
231
|
+
<NavigationMenuLink as-child :active="childActive" @select="childItem.onSelect">
|
|
232
|
+
<ULinkBase v-bind="childSlotProps" :class="ui.childLink({ class: [props.ui?.childLink, childItem.class], active: childActive })">
|
|
233
|
+
<UIcon v-if="childItem.icon" :name="childItem.icon" :class="ui.childLinkIcon({ class: props.ui?.childLinkIcon, active: childActive })" />
|
|
234
|
+
|
|
235
|
+
<div :class="ui.childLinkWrapper({ class: props.ui?.childLinkWrapper })">
|
|
236
|
+
<p :class="ui.childLinkLabel({ class: props.ui?.childLinkLabel, active: childActive })">
|
|
237
|
+
{{ get(childItem, props.labelKey as string) }}
|
|
238
|
+
|
|
239
|
+
<UIcon v-if="childItem.target === '_blank'" :name="appConfig.ui.icons.external" :class="ui.childLinkLabelExternalIcon({ class: props.ui?.childLinkLabelExternalIcon, active: childActive })" />
|
|
240
|
+
</p>
|
|
241
|
+
<p v-if="childItem.description" :class="ui.childLinkDescription({ class: props.ui?.childLinkDescription, active: childActive })">
|
|
242
|
+
{{ childItem.description }}
|
|
243
|
+
</p>
|
|
244
|
+
</div>
|
|
245
|
+
</ULinkBase>
|
|
246
|
+
</NavigationMenuLink>
|
|
247
|
+
</ULink>
|
|
248
|
+
</li>
|
|
249
|
+
</ul>
|
|
250
|
+
</slot>
|
|
181
251
|
</NavigationMenuContent>
|
|
182
252
|
</ULink>
|
|
183
|
-
|
|
253
|
+
|
|
254
|
+
<template v-if="orientation === 'vertical' && item.children?.length" #content>
|
|
255
|
+
<ul :class="ui.childList({ class: props.ui?.childList })">
|
|
256
|
+
<li v-for="(childItem, childIndex) in item.children" :key="childIndex" :class="ui.childItem({ class: props.ui?.childItem })">
|
|
257
|
+
<ULink v-slot="{ active: childActive, ...childSlotProps }" v-bind="pickLinkProps(childItem)" custom>
|
|
258
|
+
<NavigationMenuLink as-child :active="childActive" @select="childItem.onSelect">
|
|
259
|
+
<ULinkBase v-bind="childSlotProps" :class="ui.link({ class: [props.ui?.link, childItem.class], active: childActive, disabled: !!childItem.disabled })">
|
|
260
|
+
<ReuseItemTemplate :item="(childItem as T)" :active="childActive" :index="childIndex" />
|
|
261
|
+
</ULinkBase>
|
|
262
|
+
</NavigationMenuLink>
|
|
263
|
+
</ULink>
|
|
264
|
+
</li>
|
|
265
|
+
</ul>
|
|
266
|
+
</template>
|
|
267
|
+
</component>
|
|
184
268
|
</NavigationMenuList>
|
|
185
269
|
|
|
186
270
|
<div v-if="orientation === 'vertical' && listIndex < lists.length - 1" :class="ui.separator({ class: props.ui?.separator })" />
|
|
@@ -5,6 +5,7 @@ import type { AppConfig } from '@nuxt/schema'
|
|
|
5
5
|
import type { RouteLocationRaw } from '#vue-router'
|
|
6
6
|
import _appConfig from '#build/app.config'
|
|
7
7
|
import theme from '#build/ui/pagination'
|
|
8
|
+
import { extendDevtoolsMeta } from '../composables/extendDevtoolsMeta'
|
|
8
9
|
import type { ButtonProps } from '../types'
|
|
9
10
|
|
|
10
11
|
const appConfig = _appConfig as AppConfig & { ui: { pagination: Partial<typeof theme> } }
|
|
@@ -14,7 +15,7 @@ const pagination = tv({ extend: tv(theme), ...(appConfig.ui?.pagination || {}) }
|
|
|
14
15
|
export interface PaginationProps extends Pick<PaginationRootProps, 'defaultPage' | 'disabled' | 'itemsPerPage' | 'page' | 'showEdges' | 'siblingCount' | 'total'> {
|
|
15
16
|
/**
|
|
16
17
|
* The element or component this component should render as.
|
|
17
|
-
* @defaultValue
|
|
18
|
+
* @defaultValue 'div'
|
|
18
19
|
*/
|
|
19
20
|
as?: any
|
|
20
21
|
/**
|
|
@@ -97,12 +98,15 @@ export interface PaginationSlots {
|
|
|
97
98
|
index: number
|
|
98
99
|
}): any
|
|
99
100
|
}
|
|
101
|
+
|
|
102
|
+
extendDevtoolsMeta({ defaultProps: { total: 50 } })
|
|
100
103
|
</script>
|
|
101
104
|
|
|
102
105
|
<script setup lang="ts">
|
|
103
106
|
import { PaginationRoot, PaginationList, PaginationListItem, PaginationFirst, PaginationPrev, PaginationEllipsis, PaginationNext, PaginationLast, useForwardPropsEmits } from 'radix-vue'
|
|
104
107
|
import { reactivePick } from '@vueuse/core'
|
|
105
108
|
import { useAppConfig } from '#imports'
|
|
109
|
+
import UButton from './Button.vue'
|
|
106
110
|
|
|
107
111
|
const props = withDefaults(defineProps<PaginationProps>(), {
|
|
108
112
|
size: 'md',
|
|
@@ -4,6 +4,7 @@ import type { PopoverRootProps, HoverCardRootProps, PopoverRootEmits, PopoverCon
|
|
|
4
4
|
import type { AppConfig } from '@nuxt/schema'
|
|
5
5
|
import _appConfig from '#build/app.config'
|
|
6
6
|
import theme from '#build/ui/popover'
|
|
7
|
+
import { extendDevtoolsMeta } from '../composables/extendDevtoolsMeta'
|
|
7
8
|
|
|
8
9
|
const appConfig = _appConfig as AppConfig & { ui: { popover: Partial<typeof theme> } }
|
|
9
10
|
|
|
@@ -40,6 +41,8 @@ export interface PopoverSlots {
|
|
|
40
41
|
default(props: { open: boolean }): any
|
|
41
42
|
content(props?: {}): any
|
|
42
43
|
}
|
|
44
|
+
|
|
45
|
+
extendDevtoolsMeta({ example: 'PopoverExample' })
|
|
43
46
|
</script>
|
|
44
47
|
|
|
45
48
|
<script setup lang="ts">
|
|
@@ -15,7 +15,7 @@ type ProgressVariants = VariantProps<typeof progress>
|
|
|
15
15
|
export interface ProgressProps extends Pick<ProgressRootProps, 'getValueLabel' | 'modelValue'> {
|
|
16
16
|
/**
|
|
17
17
|
* The element or component this component should render as.
|
|
18
|
-
* @defaultValue
|
|
18
|
+
* @defaultValue 'div'
|
|
19
19
|
*/
|
|
20
20
|
as?: any
|
|
21
21
|
/** The maximum progress value. */
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { tv, type VariantProps } from 'tailwind-variants'
|
|
3
|
-
import type { RadioGroupRootProps, RadioGroupRootEmits
|
|
3
|
+
import type { RadioGroupRootProps, RadioGroupRootEmits } from 'radix-vue'
|
|
4
4
|
import type { AppConfig } from '@nuxt/schema'
|
|
5
5
|
import _appConfig from '#build/app.config'
|
|
6
6
|
import theme from '#build/ui/radio-group'
|
|
7
|
+
import { extendDevtoolsMeta } from '../composables/extendDevtoolsMeta'
|
|
7
8
|
import type { AcceptableValue } from '../types/utils'
|
|
8
9
|
|
|
9
10
|
const appConfig = _appConfig as AppConfig & { ui: { radioGroup: Partial<typeof theme> } }
|
|
@@ -12,15 +13,17 @@ const radioGroup = tv({ extend: tv(theme), ...(appConfig.ui?.radioGroup || {}) }
|
|
|
12
13
|
|
|
13
14
|
type RadioGroupVariants = VariantProps<typeof radioGroup>
|
|
14
15
|
|
|
15
|
-
export interface RadioGroupItem
|
|
16
|
+
export interface RadioGroupItem {
|
|
16
17
|
label?: string
|
|
17
18
|
description?: string
|
|
19
|
+
disabled?: boolean
|
|
20
|
+
value?: string
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
export interface RadioGroupProps<T> extends Pick<RadioGroupRootProps, 'defaultValue' | 'disabled' | 'loop' | 'modelValue' | 'name' | 'required'> {
|
|
21
24
|
/**
|
|
22
25
|
* The element or component this component should render as.
|
|
23
|
-
* @defaultValue
|
|
26
|
+
* @defaultValue 'div'
|
|
24
27
|
*/
|
|
25
28
|
as?: any
|
|
26
29
|
legend?: string
|
|
@@ -29,6 +32,16 @@ export interface RadioGroupProps<T> extends Pick<RadioGroupRootProps, 'defaultVa
|
|
|
29
32
|
* @defaultValue 'value'
|
|
30
33
|
*/
|
|
31
34
|
valueKey?: string
|
|
35
|
+
/**
|
|
36
|
+
* When `items` is an array of objects, select the field to use as the label.
|
|
37
|
+
* @defaultValue 'label'
|
|
38
|
+
*/
|
|
39
|
+
labelKey?: string
|
|
40
|
+
/**
|
|
41
|
+
* When `items` is an array of objects, select the field to use as the description.
|
|
42
|
+
* @defaultValue 'description'
|
|
43
|
+
*/
|
|
44
|
+
descriptionKey?: string
|
|
32
45
|
items?: T[]
|
|
33
46
|
size?: RadioGroupVariants['size']
|
|
34
47
|
color?: RadioGroupVariants['color']
|
|
@@ -52,6 +65,8 @@ export interface RadioGroupSlots<T> {
|
|
|
52
65
|
label: SlotProps<T>
|
|
53
66
|
description: SlotProps<T>
|
|
54
67
|
}
|
|
68
|
+
|
|
69
|
+
extendDevtoolsMeta({ defaultProps: { items: ['Option 1', 'Option 2', 'Option 3'] } })
|
|
55
70
|
</script>
|
|
56
71
|
|
|
57
72
|
<script setup lang="ts" generic="T extends RadioGroupItem | AcceptableValue">
|
|
@@ -59,9 +74,12 @@ import { computed, useId } from 'vue'
|
|
|
59
74
|
import { RadioGroupRoot, RadioGroupItem, RadioGroupIndicator, Label, useForwardPropsEmits } from 'radix-vue'
|
|
60
75
|
import { reactivePick } from '@vueuse/core'
|
|
61
76
|
import { useFormField } from '../composables/useFormField'
|
|
77
|
+
import { get } from '../utils'
|
|
62
78
|
|
|
63
79
|
const props = withDefaults(defineProps<RadioGroupProps<T>>(), {
|
|
64
80
|
valueKey: 'value',
|
|
81
|
+
labelKey: 'label',
|
|
82
|
+
descriptionKey: 'description',
|
|
65
83
|
orientation: 'vertical'
|
|
66
84
|
})
|
|
67
85
|
const emits = defineEmits<RadioGroupEmits>()
|
|
@@ -89,11 +107,15 @@ function normalizeItem(item: any) {
|
|
|
89
107
|
}
|
|
90
108
|
}
|
|
91
109
|
|
|
92
|
-
const value = item
|
|
110
|
+
const value = get(item, props.valueKey as string)
|
|
111
|
+
const label = get(item, props.labelKey as string)
|
|
112
|
+
const description = get(item, props.descriptionKey as string)
|
|
93
113
|
|
|
94
114
|
return {
|
|
95
115
|
...item,
|
|
96
116
|
value,
|
|
117
|
+
label,
|
|
118
|
+
description,
|
|
97
119
|
id: `${id}:${value}`
|
|
98
120
|
}
|
|
99
121
|
}
|