@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.
Files changed (228) hide show
  1. package/.nuxt/ui/accordion.ts +25 -4
  2. package/.nuxt/ui/alert.ts +52 -31
  3. package/.nuxt/ui/avatar-group.ts +24 -3
  4. package/.nuxt/ui/avatar.ts +26 -5
  5. package/.nuxt/ui/badge.ts +56 -35
  6. package/.nuxt/ui/breadcrumb.ts +28 -7
  7. package/.nuxt/ui/button-group.ts +23 -2
  8. package/.nuxt/ui/button.ts +66 -45
  9. package/.nuxt/ui/calendar.ts +39 -18
  10. package/.nuxt/ui/card.ts +28 -7
  11. package/.nuxt/ui/carousel.ts +29 -8
  12. package/.nuxt/ui/checkbox-group.ts +82 -0
  13. package/.nuxt/ui/checkbox.ts +163 -29
  14. package/.nuxt/ui/chip.ts +31 -10
  15. package/.nuxt/ui/collapsible.ts +23 -2
  16. package/.nuxt/ui/color-picker.ts +26 -5
  17. package/.nuxt/ui/command-palette.ts +37 -16
  18. package/.nuxt/ui/container.ts +24 -3
  19. package/.nuxt/ui/context-menu.ts +56 -35
  20. package/.nuxt/ui/drawer.ts +33 -12
  21. package/.nuxt/ui/dropdown-menu.ts +57 -36
  22. package/.nuxt/ui/form-field.ts +29 -8
  23. package/.nuxt/ui/form.ts +23 -2
  24. package/.nuxt/ui/index.ts +1 -0
  25. package/.nuxt/ui/input-menu.ts +65 -44
  26. package/.nuxt/ui/input-number.ts +43 -22
  27. package/.nuxt/ui/input.ts +46 -25
  28. package/.nuxt/ui/kbd.ts +27 -6
  29. package/.nuxt/ui/link.ts +26 -5
  30. package/.nuxt/ui/modal.ts +28 -7
  31. package/.nuxt/ui/navigation-menu.ts +103 -84
  32. package/.nuxt/ui/pagination.ts +23 -2
  33. package/.nuxt/ui/pin-input.ts +43 -22
  34. package/.nuxt/ui/popover.ts +25 -4
  35. package/.nuxt/ui/progress.ts +40 -19
  36. package/.nuxt/ui/radio-group.ts +273 -37
  37. package/.nuxt/ui/select-menu.ts +59 -35
  38. package/.nuxt/ui/select.ts +55 -34
  39. package/.nuxt/ui/separator.ts +31 -10
  40. package/.nuxt/ui/skeleton.ts +24 -3
  41. package/.nuxt/ui/slideover.ts +27 -6
  42. package/.nuxt/ui/slider.ts +39 -18
  43. package/.nuxt/ui/stepper.ts +41 -20
  44. package/.nuxt/ui/switch.ts +44 -23
  45. package/.nuxt/ui/table.ts +38 -17
  46. package/.nuxt/ui/tabs.ts +55 -34
  47. package/.nuxt/ui/textarea.ts +63 -37
  48. package/.nuxt/ui/toast.ts +47 -26
  49. package/.nuxt/ui/toaster.ts +23 -2
  50. package/.nuxt/ui/tooltip.ts +25 -4
  51. package/.nuxt/ui/tree.ts +41 -20
  52. package/.nuxt/ui.css +56 -12
  53. package/README.md +11 -0
  54. package/cli/templates.mjs +18 -17
  55. package/dist/module.d.mts +2 -1
  56. package/dist/module.json +5 -5
  57. package/dist/module.mjs +11 -7
  58. package/dist/runtime/components/Accordion.vue +36 -92
  59. package/dist/runtime/components/Accordion.vue.d.ts +91 -0
  60. package/dist/runtime/components/Alert.vue +37 -100
  61. package/dist/runtime/components/Alert.vue.d.ts +96 -0
  62. package/dist/runtime/components/App.vue +28 -34
  63. package/dist/runtime/components/App.vue.d.ts +24 -0
  64. package/dist/runtime/components/Avatar.vue +47 -78
  65. package/dist/runtime/components/Avatar.vue.d.ts +60 -0
  66. package/dist/runtime/components/AvatarGroup.vue +40 -77
  67. package/dist/runtime/components/AvatarGroup.vue.d.ts +40 -0
  68. package/dist/runtime/components/Badge.vue +33 -62
  69. package/dist/runtime/components/Badge.vue.d.ts +62 -0
  70. package/dist/runtime/components/Breadcrumb.vue +36 -88
  71. package/dist/runtime/components/Breadcrumb.vue.d.ts +82 -0
  72. package/dist/runtime/components/Button.vue +96 -105
  73. package/dist/runtime/components/Button.vue.d.ts +73 -0
  74. package/dist/runtime/components/ButtonGroup.vue +20 -46
  75. package/dist/runtime/components/ButtonGroup.vue.d.ts +55 -0
  76. package/dist/runtime/components/Calendar.vue +73 -127
  77. package/dist/runtime/components/Calendar.vue.d.ts +107 -0
  78. package/dist/runtime/components/Card.vue +18 -40
  79. package/dist/runtime/components/Card.vue.d.ts +38 -0
  80. package/dist/runtime/components/Carousel.vue +112 -230
  81. package/dist/runtime/components/Carousel.vue.d.ts +120 -0
  82. package/dist/runtime/components/Checkbox.vue +52 -93
  83. package/dist/runtime/components/Checkbox.vue.d.ts +76 -0
  84. package/dist/runtime/components/CheckboxGroup.vue +121 -0
  85. package/dist/runtime/components/CheckboxGroup.vue.d.ts +75 -0
  86. package/dist/runtime/components/Chip.vue +26 -69
  87. package/dist/runtime/components/Chip.vue.d.ts +71 -0
  88. package/dist/runtime/components/Collapsible.vue +22 -41
  89. package/dist/runtime/components/Collapsible.vue.d.ts +50 -0
  90. package/dist/runtime/components/ColorPicker.vue +111 -197
  91. package/dist/runtime/components/ColorPicker.vue.d.ts +63 -0
  92. package/dist/runtime/components/CommandPalette.vue +94 -234
  93. package/dist/runtime/components/CommandPalette.vue.d.ts +173 -0
  94. package/dist/runtime/components/Container.vue +15 -28
  95. package/dist/runtime/components/Container.vue.d.ts +27 -0
  96. package/dist/runtime/components/ContextMenu.vue +32 -119
  97. package/dist/runtime/components/ContextMenu.vue.d.ts +127 -0
  98. package/dist/runtime/components/ContextMenuContent.vue +71 -72
  99. package/dist/runtime/components/ContextMenuContent.vue.d.ts +105 -0
  100. package/dist/runtime/components/Drawer.vue +49 -87
  101. package/dist/runtime/components/Drawer.vue.d.ts +88 -0
  102. package/dist/runtime/components/DropdownMenu.vue +37 -129
  103. package/dist/runtime/components/DropdownMenu.vue.d.ts +141 -0
  104. package/dist/runtime/components/DropdownMenuContent.vue +76 -79
  105. package/dist/runtime/components/DropdownMenuContent.vue.d.ts +55 -0
  106. package/dist/runtime/components/Form.vue +135 -219
  107. package/dist/runtime/components/Form.vue.d.ts +66 -0
  108. package/dist/runtime/components/FormField.vue +36 -77
  109. package/dist/runtime/components/FormField.vue.d.ts +70 -0
  110. package/dist/runtime/components/Icon.vue +12 -19
  111. package/dist/runtime/components/Icon.vue.d.ts +17 -0
  112. package/dist/runtime/components/Input.vue +82 -140
  113. package/dist/runtime/components/Input.vue.d.ts +91 -0
  114. package/dist/runtime/components/InputMenu.vue +193 -302
  115. package/dist/runtime/components/InputMenu.vue.d.ts +312 -0
  116. package/dist/runtime/components/InputNumber.vue +71 -133
  117. package/dist/runtime/components/InputNumber.vue.d.ts +193 -0
  118. package/dist/runtime/components/Kbd.vue +20 -46
  119. package/dist/runtime/components/Kbd.vue.d.ts +55 -0
  120. package/dist/runtime/components/Link.vue +98 -173
  121. package/dist/runtime/components/Link.vue.d.ts +124 -0
  122. package/dist/runtime/components/LinkBase.vue +33 -41
  123. package/dist/runtime/components/LinkBase.vue.d.ts +48 -0
  124. package/dist/runtime/components/Modal.vue +53 -116
  125. package/dist/runtime/components/Modal.vue.d.ts +109 -0
  126. package/dist/runtime/components/NavigationMenu.vue +78 -186
  127. package/dist/runtime/components/NavigationMenu.vue.d.ts +159 -0
  128. package/dist/runtime/components/OverlayProvider.vue +14 -18
  129. package/dist/runtime/components/OverlayProvider.vue.d.ts +2 -0
  130. package/dist/runtime/components/Pagination.vue +46 -140
  131. package/dist/runtime/components/Pagination.vue.d.ts +143 -0
  132. package/dist/runtime/components/PinInput.vue +61 -78
  133. package/dist/runtime/components/PinInput.vue.d.ts +68 -0
  134. package/dist/runtime/components/Popover.vue +47 -84
  135. package/dist/runtime/components/Popover.vue.d.ts +80 -0
  136. package/dist/runtime/components/Progress.vue +70 -131
  137. package/dist/runtime/components/Progress.vue.d.ts +97 -0
  138. package/dist/runtime/components/RadioGroup.vue +75 -126
  139. package/dist/runtime/components/RadioGroup.vue.d.ts +88 -0
  140. package/dist/runtime/components/Select.vue +115 -202
  141. package/dist/runtime/components/Select.vue.d.ts +139 -0
  142. package/dist/runtime/components/SelectMenu.vue +167 -281
  143. package/dist/runtime/components/SelectMenu.vue.d.ts +184 -0
  144. package/dist/runtime/components/Separator.vue +29 -71
  145. package/dist/runtime/components/Separator.vue.d.ts +75 -0
  146. package/dist/runtime/components/Skeleton.vue +21 -23
  147. package/dist/runtime/components/Skeleton.vue.d.ts +26 -0
  148. package/dist/runtime/components/Slideover.vue +53 -120
  149. package/dist/runtime/components/Slideover.vue.d.ts +111 -0
  150. package/dist/runtime/components/Slider.vue +46 -84
  151. package/dist/runtime/components/Slider.vue.d.ts +71 -0
  152. package/dist/runtime/components/Stepper.vue +44 -113
  153. package/dist/runtime/components/Stepper.vue.d.ts +89 -0
  154. package/dist/runtime/components/Switch.vue +45 -93
  155. package/dist/runtime/components/Switch.vue.d.ts +73 -0
  156. package/dist/runtime/components/Table.vue +165 -264
  157. package/dist/runtime/components/Table.vue.d.ts +183 -0
  158. package/dist/runtime/components/Tabs.vue +40 -105
  159. package/dist/runtime/components/Tabs.vue.d.ts +104 -0
  160. package/dist/runtime/components/Textarea.vue +113 -158
  161. package/dist/runtime/components/Textarea.vue.d.ts +95 -0
  162. package/dist/runtime/components/Toast.vue +49 -110
  163. package/dist/runtime/components/Toast.vue.d.ts +95 -0
  164. package/dist/runtime/components/Toaster.vue +70 -107
  165. package/dist/runtime/components/Toaster.vue.d.ts +63 -0
  166. package/dist/runtime/components/Tooltip.vue +38 -65
  167. package/dist/runtime/components/Tooltip.vue.d.ts +65 -0
  168. package/dist/runtime/components/Tree.vue +57 -150
  169. package/dist/runtime/components/Tree.vue.d.ts +128 -0
  170. package/dist/runtime/composables/defineShortcuts.d.ts +1 -1
  171. package/dist/runtime/composables/defineShortcuts.js +0 -1
  172. package/dist/runtime/composables/useAvatarGroup.d.ts +1 -1
  173. package/dist/runtime/composables/useButtonGroup.d.ts +2 -2
  174. package/dist/runtime/composables/useFormField.d.ts +2 -2
  175. package/dist/runtime/composables/useFormField.js +1 -1
  176. package/dist/runtime/composables/useOverlay.d.ts +16 -8
  177. package/dist/runtime/composables/useOverlay.js +14 -6
  178. package/dist/runtime/composables/usePortal.d.ts +6 -0
  179. package/dist/runtime/composables/usePortal.js +17 -0
  180. package/dist/runtime/index.css +1 -1
  181. package/dist/runtime/inertia/components/Link.vue +146 -0
  182. package/dist/runtime/inertia/components/Link.vue.d.ts +92 -0
  183. package/dist/runtime/inertia/stubs.d.ts +43 -0
  184. package/dist/runtime/inertia/stubs.js +82 -0
  185. package/dist/runtime/locale/bg.d.ts +3 -0
  186. package/dist/runtime/locale/bg.js +54 -0
  187. package/dist/runtime/locale/hy.d.ts +3 -0
  188. package/dist/runtime/locale/hy.js +54 -0
  189. package/dist/runtime/locale/index.d.ts +6 -1
  190. package/dist/runtime/locale/index.js +6 -1
  191. package/dist/runtime/locale/kk.d.ts +3 -0
  192. package/dist/runtime/locale/kk.js +54 -0
  193. package/dist/runtime/locale/tj.d.ts +3 -0
  194. package/dist/runtime/locale/tj.js +54 -0
  195. package/dist/runtime/locale/ug_cn.d.ts +3 -0
  196. package/dist/runtime/locale/ug_cn.js +55 -0
  197. package/dist/runtime/types/form.d.ts +5 -1
  198. package/dist/runtime/types/index.d.ts +2 -0
  199. package/dist/runtime/types/index.js +2 -0
  200. package/dist/runtime/types/utils.d.ts +70 -10
  201. package/dist/runtime/utils/index.d.ts +1 -0
  202. package/dist/runtime/utils/index.js +3 -0
  203. package/dist/runtime/utils/link.d.ts +4 -27
  204. package/dist/runtime/utils/link.js +32 -1
  205. package/dist/runtime/utils/tv.js +2 -2
  206. package/dist/runtime/vue/components/Icon.vue +7 -8
  207. package/dist/runtime/vue/components/Icon.vue.d.ts +14 -0
  208. package/dist/runtime/vue/components/Link.vue +118 -199
  209. package/dist/runtime/vue/components/Link.vue.d.ts +124 -0
  210. package/dist/runtime/vue/stubs.d.ts +5 -0
  211. package/dist/runtime/vue/stubs.js +11 -2
  212. package/dist/shared/{ui.BCaWD5Ek.mjs → ui.D7lOOabO.mjs} +623 -364
  213. package/dist/types.d.mts +5 -1
  214. package/dist/unplugin.d.mts +6 -1
  215. package/dist/unplugin.mjs +25 -4
  216. package/dist/vite.mjs +1 -1
  217. package/package.json +122 -64
  218. package/dist/module.cjs +0 -62
  219. package/dist/module.d.cts +0 -44
  220. package/dist/module.d.ts +0 -44
  221. package/dist/shared/ui.C6uTSFTI.cjs +0 -3555
  222. package/dist/types.d.ts +0 -1
  223. package/dist/unplugin.cjs +0 -232
  224. package/dist/unplugin.d.cts +0 -61
  225. package/dist/unplugin.d.ts +0 -61
  226. package/dist/vite.cjs +0 -23
  227. package/dist/vite.d.cts +0 -15
  228. package/dist/vite.d.ts +0 -15
@@ -1,159 +1,50 @@
1
- <!-- eslint-disable vue/block-tag-newline -->
2
- <script lang="ts">
3
- import type { VariantProps } from 'tailwind-variants'
4
- import type { NavigationMenuRootProps, NavigationMenuRootEmits, NavigationMenuContentProps, NavigationMenuContentEmits, CollapsibleRootProps } from 'reka-ui'
5
- import type { AppConfig } from '@nuxt/schema'
6
- import _appConfig from '#build/app.config'
7
- import theme from '#build/ui/navigation-menu'
8
- import { tv } from '../utils/tv'
9
- import type { AvatarProps, BadgeProps, LinkProps } from '../types'
10
- import type { DynamicSlots, MaybeArrayOfArray, MaybeArrayOfArrayItem, PartialString, EmitsToProps } from '../types/utils'
11
-
12
- const appConfigNavigationMenu = _appConfig as AppConfig & { ui: { navigationMenu: Partial<typeof theme> } }
13
-
14
- const navigationMenu = tv({ extend: tv(theme), ...(appConfigNavigationMenu.ui?.navigationMenu || {}) })
15
-
16
- export interface NavigationMenuChildItem extends Omit<NavigationMenuItem, 'children' | 'type'> {
17
- /** Description is only used when `orientation` is `horizontal`. */
18
- description?: string
19
- }
20
-
21
- export interface NavigationMenuItem extends Omit<LinkProps, 'type' | 'raw' | 'custom'>, Pick<CollapsibleRootProps, 'defaultOpen' | 'open'> {
22
- label?: string
23
- /**
24
- * @IconifyIcon
25
- */
26
- icon?: string
27
- avatar?: AvatarProps
28
- /**
29
- * Display a badge on the item.
30
- * `{ size: 'sm', color: 'neutral', variant: 'outline' }`{lang="ts-type"}
31
- */
32
- badge?: string | number | BadgeProps
33
- /**
34
- * @IconifyIcon
35
- */
36
- trailingIcon?: string
37
- /**
38
- * The type of the item.
39
- * The `label` type only works on `vertical` orientation.
40
- * @defaultValue 'link'
41
- */
42
- type?: 'label' | 'link'
43
- slot?: string
44
- value?: string
45
- children?: NavigationMenuChildItem[]
46
- onSelect?(e: Event): void
47
- }
48
-
49
- type NavigationMenuVariants = VariantProps<typeof navigationMenu>
50
-
51
- export interface NavigationMenuProps<T> extends Pick<NavigationMenuRootProps, 'modelValue' | 'defaultValue' | 'delayDuration' | 'disableClickTrigger' | 'disableHoverTrigger' | 'skipDelayDuration' | 'disablePointerLeaveClose' | 'unmountOnHide'> {
52
- /**
53
- * The element or component this component should render as.
54
- * @defaultValue 'div'
55
- */
56
- as?: any
57
- /**
58
- * The icon displayed to open the menu.
59
- * @defaultValue appConfig.ui.icons.chevronDown
60
- * @IconifyIcon
61
- */
62
- trailingIcon?: string
63
- /**
64
- * The icon displayed when the item is an external link.
65
- * Set to `false` to hide the external icon.
66
- * @defaultValue appConfig.ui.icons.external
67
- * @IconifyIcon
68
- */
69
- externalIcon?: boolean | string
70
- items?: T
71
- /**
72
- * @defaultValue 'primary'
73
- */
74
- color?: NavigationMenuVariants['color']
75
- /**
76
- * @defaultValue 'pill'
77
- */
78
- variant?: NavigationMenuVariants['variant']
79
- /**
80
- * The orientation of the menu.
81
- * @defaultValue 'horizontal'
82
- */
83
- orientation?: NavigationMenuRootProps['orientation']
84
- /**
85
- * Collapse the navigation menu to only show icons.
86
- * Only works when `orientation` is `vertical`.
87
- * @defaultValue false
88
- */
89
- collapsed?: boolean
90
- /** Display a line next to the active item. */
91
- highlight?: boolean
92
- /**
93
- * @defaultValue 'primary'
94
- */
95
- highlightColor?: NavigationMenuVariants['highlightColor']
96
- /** The content of the menu. */
97
- content?: Omit<NavigationMenuContentProps, 'as' | 'asChild' | 'forceMount'> & Partial<EmitsToProps<NavigationMenuContentEmits>>
98
- /**
99
- * The orientation of the content.
100
- * Only works when `orientation` is `horizontal`.
101
- * @defaultValue 'horizontal'
102
- */
103
- contentOrientation?: NavigationMenuVariants['contentOrientation']
104
- /**
105
- * Display an arrow alongside the menu.
106
- * @defaultValue false
107
- */
108
- arrow?: boolean
109
- /**
110
- * The key used to get the label from the item.
111
- * @defaultValue 'label'
112
- */
113
- labelKey?: string
114
- class?: any
115
- ui?: PartialString<typeof navigationMenu.slots>
116
- }
117
-
118
- export interface NavigationMenuEmits extends NavigationMenuRootEmits {}
119
-
120
- type SlotProps<T> = (props: { item: T, index: number, active?: boolean }) => any
121
-
122
- export type NavigationMenuSlots<T extends { slot?: string }> = {
123
- 'item': SlotProps<T>
124
- 'item-leading': SlotProps<T>
125
- 'item-label': SlotProps<T>
126
- 'item-trailing': SlotProps<T>
127
- 'item-content': SlotProps<T>
128
- } & DynamicSlots<T, SlotProps<T>>
129
-
1
+ <script>
2
+ import theme from "#build/ui/navigation-menu";
130
3
  </script>
131
4
 
132
- <script setup lang="ts" generic="T extends MaybeArrayOfArrayItem<I>, I extends MaybeArrayOfArray<NavigationMenuItem>">
133
- import { computed, toRef } from 'vue'
134
- import { NavigationMenuRoot, NavigationMenuList, NavigationMenuItem, NavigationMenuTrigger, NavigationMenuContent, NavigationMenuLink, NavigationMenuIndicator, NavigationMenuViewport, useForwardPropsEmits } from 'reka-ui'
135
- import { createReusableTemplate } from '@vueuse/core'
136
- import { useAppConfig } from '#imports'
137
- import { get } from '../utils'
138
- import { pickLinkProps } from '../utils/link'
139
- import ULinkBase from './LinkBase.vue'
140
- import ULink from './Link.vue'
141
- import UAvatar from './Avatar.vue'
142
- import UIcon from './Icon.vue'
143
- import UBadge from './Badge.vue'
144
- import UCollapsible from './Collapsible.vue'
145
-
146
- const props = withDefaults(defineProps<NavigationMenuProps<I>>(), {
147
- orientation: 'horizontal',
148
- contentOrientation: 'horizontal',
149
- externalIcon: true,
150
- delayDuration: 0,
151
- unmountOnHide: true,
152
- labelKey: 'label'
153
- })
154
- const emits = defineEmits<NavigationMenuEmits>()
155
- const slots = defineSlots<NavigationMenuSlots<T>>()
156
-
5
+ <script setup>
6
+ import { computed, toRef } from "vue";
7
+ import { NavigationMenuRoot, NavigationMenuList, NavigationMenuItem, NavigationMenuTrigger, NavigationMenuContent, NavigationMenuLink, NavigationMenuIndicator, NavigationMenuViewport, useForwardPropsEmits } from "reka-ui";
8
+ import { createReusableTemplate } from "@vueuse/core";
9
+ import { useAppConfig } from "#imports";
10
+ import { get, isArrayOfArray } from "../utils";
11
+ import { tv } from "../utils/tv";
12
+ import { pickLinkProps } from "../utils/link";
13
+ import ULinkBase from "./LinkBase.vue";
14
+ import ULink from "./Link.vue";
15
+ import UAvatar from "./Avatar.vue";
16
+ import UIcon from "./Icon.vue";
17
+ import UBadge from "./Badge.vue";
18
+ import UCollapsible from "./Collapsible.vue";
19
+ const props = defineProps({
20
+ as: { type: null, required: false },
21
+ trailingIcon: { type: String, required: false },
22
+ externalIcon: { type: [Boolean, String], required: false, default: true },
23
+ items: { type: null, required: false },
24
+ color: { type: null, required: false },
25
+ variant: { type: null, required: false },
26
+ orientation: { type: null, required: false, default: "horizontal" },
27
+ collapsed: { type: Boolean, required: false },
28
+ highlight: { type: Boolean, required: false },
29
+ highlightColor: { type: null, required: false },
30
+ content: { type: Object, required: false },
31
+ contentOrientation: { type: null, required: false, default: "horizontal" },
32
+ arrow: { type: Boolean, required: false },
33
+ labelKey: { type: null, required: false, default: "label" },
34
+ class: { type: null, required: false },
35
+ ui: { type: null, required: false },
36
+ modelValue: { type: String, required: false },
37
+ defaultValue: { type: String, required: false },
38
+ delayDuration: { type: Number, required: false, default: 0 },
39
+ disableClickTrigger: { type: Boolean, required: false },
40
+ disableHoverTrigger: { type: Boolean, required: false },
41
+ skipDelayDuration: { type: Number, required: false },
42
+ disablePointerLeaveClose: { type: Boolean, required: false },
43
+ unmountOnHide: { type: Boolean, required: false, default: true }
44
+ });
45
+ const emits = defineEmits(["update:modelValue"]);
46
+ const slots = defineSlots();
47
+ const appConfig = useAppConfig();
157
48
  const rootProps = useForwardPropsEmits(computed(() => ({
158
49
  as: props.as,
159
50
  modelValue: props.modelValue,
@@ -165,21 +56,17 @@ const rootProps = useForwardPropsEmits(computed(() => ({
165
56
  disableHoverTrigger: props.disableHoverTrigger,
166
57
  disablePointerLeaveClose: props.disablePointerLeaveClose,
167
58
  unmountOnHide: props.unmountOnHide
168
- })), emits)
169
-
170
- const contentProps = toRef(() => props.content)
171
-
172
- const appConfig = useAppConfig()
173
- const [DefineLinkTemplate, ReuseLinkTemplate] = createReusableTemplate<{ item: NavigationMenuItem, index: number, active?: boolean }>()
174
- const [DefineItemTemplate, ReuseItemTemplate] = createReusableTemplate<{ item: NavigationMenuItem, index: number, level?: number }>({
59
+ })), emits);
60
+ const contentProps = toRef(() => props.content);
61
+ const [DefineLinkTemplate, ReuseLinkTemplate] = createReusableTemplate();
62
+ const [DefineItemTemplate, ReuseItemTemplate] = createReusableTemplate({
175
63
  props: {
176
64
  item: Object,
177
65
  index: Number,
178
66
  level: Number
179
67
  }
180
- })
181
-
182
- const ui = computed(() => navigationMenu({
68
+ });
69
+ const ui = computed(() => tv({ extend: tv(theme), ...appConfig.ui?.navigationMenu || {} })({
183
70
  orientation: props.orientation,
184
71
  contentOrientation: props.contentOrientation,
185
72
  collapsed: props.collapsed,
@@ -187,42 +74,43 @@ const ui = computed(() => navigationMenu({
187
74
  variant: props.variant,
188
75
  highlight: props.highlight,
189
76
  highlightColor: props.highlightColor || props.color
190
- }))
191
-
192
- const lists = computed(() => props.items?.length ? (Array.isArray(props.items[0]) ? props.items : [props.items]) as T[][] : [])
77
+ }));
78
+ const lists = computed(
79
+ () => props.items?.length ? isArrayOfArray(props.items) ? props.items : [props.items] : []
80
+ );
193
81
  </script>
194
82
 
195
83
  <template>
196
84
  <DefineLinkTemplate v-slot="{ item, active, index }">
197
- <slot :name="item.slot || 'item'" :item="(item as T)" :index="index">
198
- <slot :name="item.slot ? `${item.slot}-leading` : 'item-leading'" :item="(item as T)" :active="active" :index="index">
199
- <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 })" />
85
+ <slot :name="item.slot || 'item'" :item="item" :index="index">
86
+ <slot :name="item.slot ? `${item.slot}-leading` : 'item-leading'" :item="item" :active="active" :index="index">
87
+ <UAvatar v-if="item.avatar" :size="props.ui?.linkLeadingAvatarSize || ui.linkLeadingAvatarSize()" v-bind="item.avatar" :class="ui.linkLeadingAvatar({ class: props.ui?.linkLeadingAvatar, active, disabled: !!item.disabled })" />
200
88
  <UIcon v-else-if="item.icon" :name="item.icon" :class="ui.linkLeadingIcon({ class: props.ui?.linkLeadingIcon, active, disabled: !!item.disabled })" />
201
89
  </slot>
202
90
 
203
91
  <span
204
- v-if="(!collapsed || orientation !== 'vertical') && (get(item, props.labelKey as string) || !!slots[item.slot ? `${item.slot}-label` : 'item-label'])"
92
+ v-if="(!collapsed || orientation !== 'vertical') && (get(item, props.labelKey) || !!slots[item.slot ? `${item.slot}-label` : 'item-label'])"
205
93
  :class="ui.linkLabel({ class: props.ui?.linkLabel })"
206
94
  >
207
- <slot :name="item.slot ? `${item.slot}-label` : 'item-label'" :item="(item as T)" :active="active" :index="index">
208
- {{ get(item, props.labelKey as string) }}
95
+ <slot :name="item.slot ? `${item.slot}-label` : 'item-label'" :item="item" :active="active" :index="index">
96
+ {{ get(item, props.labelKey) }}
209
97
  </slot>
210
98
 
211
99
  <UIcon v-if="item.target === '_blank' && externalIcon !== false" :name="typeof externalIcon === 'string' ? externalIcon : appConfig.ui.icons.external" :class="ui.linkLabelExternalIcon({ class: props.ui?.linkLabelExternalIcon, active })" />
212
100
  </span>
213
101
 
214
- <span v-if="(!collapsed || orientation !== 'vertical') && (item.badge || (orientation === 'horizontal' && (item.children?.length || !!slots[item.slot ? `${item.slot}-content` : 'item-content'])) || (orientation === 'vertical' && item.children?.length) || item.trailingIcon || !!slots[item.slot ? `${item.slot}-trailing` : 'item-trailing'])" :class="ui.linkTrailing({ class: props.ui?.linkTrailing })">
215
- <slot :name="item.slot ? `${item.slot}-trailing` : 'item-trailing'" :item="(item as T)" :active="active" :index="index">
102
+ <span v-if="(!collapsed || orientation !== 'vertical') && (item.badge || orientation === 'horizontal' && (item.children?.length || !!slots[item.slot ? `${item.slot}-content` : 'item-content']) || orientation === 'vertical' && item.children?.length || item.trailingIcon || !!slots[item.slot ? `${item.slot}-trailing` : 'item-trailing'])" :class="ui.linkTrailing({ class: props.ui?.linkTrailing })">
103
+ <slot :name="item.slot ? `${item.slot}-trailing` : 'item-trailing'" :item="item" :active="active" :index="index">
216
104
  <UBadge
217
105
  v-if="item.badge"
218
106
  color="neutral"
219
107
  variant="outline"
220
- :size="((props.ui?.linkTrailingBadgeSize || ui.linkTrailingBadgeSize()) as BadgeProps['size'])"
221
- v-bind="(typeof item.badge === 'string' || typeof item.badge === 'number') ? { label: item.badge } : item.badge"
108
+ :size="props.ui?.linkTrailingBadgeSize || ui.linkTrailingBadgeSize()"
109
+ v-bind="typeof item.badge === 'string' || typeof item.badge === 'number' ? { label: item.badge } : item.badge"
222
110
  :class="ui.linkTrailingBadge({ class: props.ui?.linkTrailingBadge })"
223
111
  />
224
112
 
225
- <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 })" />
113
+ <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 })" />
226
114
  <UIcon v-else-if="item.trailingIcon" :name="item.trailingIcon" :class="ui.linkTrailingIcon({ class: props.ui?.linkTrailingIcon, active })" />
227
115
  </slot>
228
116
  </span>
@@ -231,31 +119,31 @@ const lists = computed(() => props.items?.length ? (Array.isArray(props.items[0]
231
119
 
232
120
  <DefineItemTemplate v-slot="{ item, index, level = 0 }">
233
121
  <component
234
- :is="(orientation === 'vertical' && item.children?.length && !collapsed) ? UCollapsible : NavigationMenuItem"
122
+ :is="orientation === 'vertical' && item.children?.length && !collapsed ? UCollapsible : NavigationMenuItem"
235
123
  as="li"
236
124
  :value="item.value || String(index)"
237
125
  :default-open="item.defaultOpen"
238
- :unmount-on-hide="(orientation === 'vertical' && item.children?.length && !collapsed) ? unmountOnHide : undefined"
126
+ :unmount-on-hide="orientation === 'vertical' && item.children?.length && !collapsed ? unmountOnHide : void 0"
239
127
  :open="item.open"
240
128
  >
241
129
  <div v-if="orientation === 'vertical' && item.type === 'label'" :class="ui.label({ class: props.ui?.label })">
242
- <ReuseLinkTemplate :item="(item as T)" :index="index" />
130
+ <ReuseLinkTemplate :item="item" :index="index" />
243
131
  </div>
244
- <ULink v-else-if="item.type !== 'label'" v-slot="{ active, ...slotProps }" v-bind="(orientation === 'vertical' && item.children?.length && !collapsed) ? {} : pickLinkProps(item as Omit<NavigationMenuItem, 'type'>)" custom>
132
+ <ULink v-else-if="item.type !== 'label'" v-slot="{ active, ...slotProps }" v-bind="orientation === 'vertical' && item.children?.length && !collapsed ? {} : pickLinkProps(item)" custom>
245
133
  <component
246
- :is="(orientation === 'horizontal' && (item.children?.length || !!slots[item.slot ? `${item.slot}-content` : 'item-content'])) ? NavigationMenuTrigger : NavigationMenuLink"
134
+ :is="orientation === 'horizontal' && (item.children?.length || !!slots[item.slot ? `${item.slot}-content` : 'item-content']) ? NavigationMenuTrigger : NavigationMenuLink"
247
135
  as-child
248
136
  :active="active || item.active"
249
137
  :disabled="item.disabled"
250
138
  @select="item.onSelect"
251
139
  >
252
140
  <ULinkBase v-bind="slotProps" :class="ui.link({ class: [props.ui?.link, item.class], active: active || item.active, disabled: !!item.disabled, level: orientation === 'horizontal' || level > 0 })">
253
- <ReuseLinkTemplate :item="(item as T)" :active="active || item.active" :index="index" />
141
+ <ReuseLinkTemplate :item="item" :active="active || item.active" :index="index" />
254
142
  </ULinkBase>
255
143
  </component>
256
144
 
257
145
  <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 })">
258
- <slot :name="item.slot ? `${item.slot}-content` : 'item-content'" :item="(item as T)" :active="active" :index="index">
146
+ <slot :name="item.slot ? `${item.slot}-content` : 'item-content'" :item="item" :active="active" :index="index">
259
147
  <ul :class="ui.childList({ class: props.ui?.childList })">
260
148
  <li v-for="(childItem, childIndex) in item.children" :key="childIndex" :class="ui.childItem({ class: props.ui?.childItem })">
261
149
  <ULink v-slot="{ active: childActive, ...childSlotProps }" v-bind="pickLinkProps(childItem)" custom>
@@ -265,7 +153,7 @@ const lists = computed(() => props.items?.length ? (Array.isArray(props.items[0]
265
153
 
266
154
  <div :class="ui.childLinkWrapper({ class: props.ui?.childLinkWrapper })">
267
155
  <p :class="ui.childLinkLabel({ class: props.ui?.childLinkLabel, active: childActive })">
268
- {{ get(childItem, props.labelKey as string) }}
156
+ {{ get(childItem, props.labelKey) }}
269
157
 
270
158
  <UIcon v-if="childItem.target === '_blank' && externalIcon !== false" :name="typeof externalIcon === 'string' ? externalIcon : appConfig.ui.icons.external" :class="ui.childLinkLabelExternalIcon({ class: props.ui?.childLinkLabelExternalIcon, active: childActive })" />
271
159
  </p>
@@ -298,6 +186,8 @@ const lists = computed(() => props.items?.length ? (Array.isArray(props.items[0]
298
186
  </DefineItemTemplate>
299
187
 
300
188
  <NavigationMenuRoot v-bind="rootProps" :data-collapsed="collapsed" :class="ui.root({ class: [props.class, props.ui?.root] })">
189
+ <slot name="list-leading" />
190
+
301
191
  <template v-for="(list, listIndex) in lists" :key="`list-${listIndex}`">
302
192
  <NavigationMenuList :class="ui.list({ class: props.ui?.list })">
303
193
  <ReuseItemTemplate v-for="(item, index) in list" :key="`list-${listIndex}-${index}`" :item="item" :index="index" :class="ui.item({ class: props.ui?.item })" />
@@ -306,6 +196,8 @@ const lists = computed(() => props.items?.length ? (Array.isArray(props.items[0]
306
196
  <div v-if="orientation === 'vertical' && listIndex < lists.length - 1" :class="ui.separator({ class: props.ui?.separator })" />
307
197
  </template>
308
198
 
199
+ <slot name="list-trailing" />
200
+
309
201
  <div v-if="orientation === 'horizontal'" :class="ui.viewportWrapper({ class: props.ui?.viewportWrapper })">
310
202
  <NavigationMenuIndicator v-if="arrow" :class="ui.indicator({ class: props.ui?.indicator })">
311
203
  <div :class="ui.arrow({ class: props.ui?.arrow })" />
@@ -0,0 +1,159 @@
1
+ import type { NavigationMenuRootProps, NavigationMenuRootEmits, NavigationMenuContentProps, NavigationMenuContentEmits, CollapsibleRootProps } from 'reka-ui';
2
+ import type { AppConfig } from '@nuxt/schema';
3
+ import theme from '#build/ui/navigation-menu';
4
+ import type { AvatarProps, BadgeProps, LinkProps } from '../types';
5
+ import type { ArrayOrNested, DynamicSlots, MergeTypes, NestedItem, EmitsToProps, ComponentConfig } from '../types/utils';
6
+ type NavigationMenu = ComponentConfig<typeof theme, AppConfig, 'navigationMenu'>;
7
+ export interface NavigationMenuChildItem extends Omit<NavigationMenuItem, 'type'> {
8
+ /** Description is only used when `orientation` is `horizontal`. */
9
+ description?: string;
10
+ [key: string]: any;
11
+ }
12
+ export interface NavigationMenuItem extends Omit<LinkProps, 'type' | 'raw' | 'custom'>, Pick<CollapsibleRootProps, 'defaultOpen' | 'open'> {
13
+ label?: string;
14
+ /**
15
+ * @IconifyIcon
16
+ */
17
+ icon?: string;
18
+ avatar?: AvatarProps;
19
+ /**
20
+ * Display a badge on the item.
21
+ * `{ size: 'sm', color: 'neutral', variant: 'outline' }`{lang="ts-type"}
22
+ */
23
+ badge?: string | number | BadgeProps;
24
+ /**
25
+ * @IconifyIcon
26
+ */
27
+ trailingIcon?: string;
28
+ /**
29
+ * The type of the item.
30
+ * The `label` type only works on `vertical` orientation.
31
+ * @defaultValue 'link'
32
+ */
33
+ type?: 'label' | 'link';
34
+ slot?: string;
35
+ value?: string;
36
+ children?: NavigationMenuChildItem[];
37
+ onSelect?(e: Event): void;
38
+ [key: string]: any;
39
+ }
40
+ export interface NavigationMenuProps<T extends ArrayOrNested<NavigationMenuItem> = ArrayOrNested<NavigationMenuItem>> extends Pick<NavigationMenuRootProps, 'modelValue' | 'defaultValue' | 'delayDuration' | 'disableClickTrigger' | 'disableHoverTrigger' | 'skipDelayDuration' | 'disablePointerLeaveClose' | 'unmountOnHide'> {
41
+ /**
42
+ * The element or component this component should render as.
43
+ * @defaultValue 'div'
44
+ */
45
+ as?: any;
46
+ /**
47
+ * The icon displayed to open the menu.
48
+ * @defaultValue appConfig.ui.icons.chevronDown
49
+ * @IconifyIcon
50
+ */
51
+ trailingIcon?: string;
52
+ /**
53
+ * The icon displayed when the item is an external link.
54
+ * Set to `false` to hide the external icon.
55
+ * @defaultValue appConfig.ui.icons.external
56
+ * @IconifyIcon
57
+ */
58
+ externalIcon?: boolean | string;
59
+ items?: T;
60
+ /**
61
+ * @defaultValue 'primary'
62
+ */
63
+ color?: NavigationMenu['variants']['color'];
64
+ /**
65
+ * @defaultValue 'pill'
66
+ */
67
+ variant?: NavigationMenu['variants']['variant'];
68
+ /**
69
+ * The orientation of the menu.
70
+ * @defaultValue 'horizontal'
71
+ */
72
+ orientation?: NavigationMenuRootProps['orientation'];
73
+ /**
74
+ * Collapse the navigation menu to only show icons.
75
+ * Only works when `orientation` is `vertical`.
76
+ * @defaultValue false
77
+ */
78
+ collapsed?: boolean;
79
+ /** Display a line next to the active item. */
80
+ highlight?: boolean;
81
+ /**
82
+ * @defaultValue 'primary'
83
+ */
84
+ highlightColor?: NavigationMenu['variants']['highlightColor'];
85
+ /** The content of the menu. */
86
+ content?: Omit<NavigationMenuContentProps, 'as' | 'asChild' | 'forceMount'> & Partial<EmitsToProps<NavigationMenuContentEmits>>;
87
+ /**
88
+ * The orientation of the content.
89
+ * Only works when `orientation` is `horizontal`.
90
+ * @defaultValue 'horizontal'
91
+ */
92
+ contentOrientation?: NavigationMenu['variants']['contentOrientation'];
93
+ /**
94
+ * Display an arrow alongside the menu.
95
+ * @defaultValue false
96
+ */
97
+ arrow?: boolean;
98
+ /**
99
+ * The key used to get the label from the item.
100
+ * @defaultValue 'label'
101
+ */
102
+ labelKey?: keyof NestedItem<T>;
103
+ class?: any;
104
+ ui?: NavigationMenu['slots'];
105
+ }
106
+ export interface NavigationMenuEmits extends NavigationMenuRootEmits {
107
+ }
108
+ type SlotProps<T extends NavigationMenuItem> = (props: {
109
+ item: T;
110
+ index: number;
111
+ active?: boolean;
112
+ }) => any;
113
+ export type NavigationMenuSlots<A extends ArrayOrNested<NavigationMenuItem> = ArrayOrNested<NavigationMenuItem>, T extends NestedItem<A> = NestedItem<A>> = {
114
+ 'item': SlotProps<T>;
115
+ 'item-leading': SlotProps<T>;
116
+ 'item-label': SlotProps<T>;
117
+ 'item-trailing': SlotProps<T>;
118
+ 'item-content': SlotProps<T>;
119
+ 'list-leading': (props?: {}) => any;
120
+ 'list-trailing': (props?: {}) => any;
121
+ } & DynamicSlots<MergeTypes<T>, 'leading' | 'label' | 'trailing' | 'content', {
122
+ index: number;
123
+ active?: boolean;
124
+ }>;
125
+ declare const _default: <T extends ArrayOrNested<NavigationMenuItem>>(__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<{
126
+ props: __VLS_PrettifyLocal<any & NavigationMenuProps<T> & Partial<{}>> & (import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps);
127
+ expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
128
+ attrs: any;
129
+ slots: Readonly<{
130
+ item: SlotProps<NestedItem<T>>;
131
+ 'item-leading': SlotProps<NestedItem<T>>;
132
+ 'item-label': SlotProps<NestedItem<T>>;
133
+ 'item-trailing': SlotProps<NestedItem<T>>;
134
+ 'item-content': SlotProps<NestedItem<T>>;
135
+ 'list-leading': (props?: {}) => any;
136
+ 'list-trailing': (props?: {}) => any;
137
+ } & DynamicSlots<MergeTypes<NestedItem<T>>, "trailing" | "leading" | "content" | "label", {
138
+ index: number;
139
+ active?: boolean;
140
+ }>> & {
141
+ item: SlotProps<NestedItem<T>>;
142
+ 'item-leading': SlotProps<NestedItem<T>>;
143
+ 'item-label': SlotProps<NestedItem<T>>;
144
+ 'item-trailing': SlotProps<NestedItem<T>>;
145
+ 'item-content': SlotProps<NestedItem<T>>;
146
+ 'list-leading': (props?: {}) => any;
147
+ 'list-trailing': (props?: {}) => any;
148
+ } & DynamicSlots<MergeTypes<NestedItem<T>>, "trailing" | "leading" | "content" | "label", {
149
+ index: number;
150
+ active?: boolean;
151
+ }>;
152
+ emit: (evt: "update:modelValue", value: string) => void;
153
+ }>) => import("vue").VNode & {
154
+ __ctx?: Awaited<typeof __VLS_setup>;
155
+ };
156
+ export default _default;
157
+ type __VLS_PrettifyLocal<T> = {
158
+ [K in keyof T]: T[K];
159
+ } & {};
@@ -1,19 +1,15 @@
1
- <script setup lang="ts">
2
- import { computed } from 'vue'
3
- import { useOverlay, type Overlay } from '../composables/useOverlay'
4
-
5
- const { overlays, unMount, close } = useOverlay()
6
-
7
- const mountedOverlays = computed(() => overlays.filter((overlay: Overlay) => overlay.isMounted))
8
-
9
- const onAfterLeave = (id: symbol) => {
10
- close(id)
11
- unMount(id)
12
- }
13
-
14
- const onClose = (id: symbol, value: any) => {
15
- close(id, value)
16
- }
1
+ <script setup>
2
+ import { computed } from "vue";
3
+ import { useOverlay } from "../composables/useOverlay";
4
+ const { overlays, unMount, close } = useOverlay();
5
+ const mountedOverlays = computed(() => overlays.filter((overlay) => overlay.isMounted));
6
+ const onAfterLeave = (id) => {
7
+ close(id);
8
+ unMount(id);
9
+ };
10
+ const onClose = (id, value) => {
11
+ close(id, value);
12
+ };
17
13
  </script>
18
14
 
19
15
  <template>
@@ -22,8 +18,8 @@ const onClose = (id: symbol, value: any) => {
22
18
  v-for="overlay in mountedOverlays"
23
19
  :key="overlay.id"
24
20
  v-bind="overlay.props"
25
- v-model:open="overlay.modelValue"
26
- @close="(value:any) => onClose(overlay.id, value)"
21
+ v-model:open="overlay.isOpen"
22
+ @close="(value) => onClose(overlay.id, value)"
27
23
  @after:leave="onAfterLeave(overlay.id)"
28
24
  />
29
25
  </template>
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ export default _default;