@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,199 +1,116 @@
1
- <script lang="ts">
2
- import type { ButtonHTMLAttributes } from 'vue'
3
- import { tv } from 'tailwind-variants'
4
- import type { AppConfig } from '@nuxt/schema'
5
- import _appConfig from '#build/app.config'
6
- import type { RouterLinkProps, RouteLocationRaw } from 'vue-router'
7
- import theme from '#build/ui/link'
8
-
9
- interface NuxtLinkProps extends Omit<RouterLinkProps, 'to'> {
10
- /**
11
- * Route Location the link should navigate to when clicked on.
12
- */
13
- to?: RouteLocationRaw // need to manually type to avoid breaking typedPages
14
- /**
15
- * An alias for `to`. If used with `to`, `href` will be ignored
16
- */
17
- href?: NuxtLinkProps['to']
18
- /**
19
- * Forces the link to be considered as external (true) or internal (false). This is helpful to handle edge-cases
20
- */
21
- external?: boolean
22
- /**
23
- * Where to display the linked URL, as the name for a browsing context.
24
- */
25
- target?: '_blank' | '_parent' | '_self' | '_top' | (string & {}) | null
26
- /**
27
- * A rel attribute value to apply on the link. Defaults to "noopener noreferrer" for external links.
28
- */
29
- rel?: 'noopener' | 'noreferrer' | 'nofollow' | 'sponsored' | 'ugc' | (string & {}) | null
30
- /**
31
- * If set to true, no rel attribute will be added to the link
32
- */
33
- noRel?: boolean
34
- /**
35
- * A class to apply to links that have been prefetched.
36
- */
37
- prefetchedClass?: string
38
- /**
39
- * When enabled will prefetch middleware, layouts and payloads of links in the viewport.
40
- */
41
- prefetch?: boolean
42
- /**
43
- * Allows controlling when to prefetch links. By default, prefetch is triggered only on visibility.
44
- */
45
- prefetchOn?: 'visibility' | 'interaction' | Partial<{
46
- visibility: boolean
47
- interaction: boolean
48
- }>
49
- /**
50
- * Escape hatch to disable `prefetch` attribute.
51
- */
52
- noPrefetch?: boolean
53
- }
54
-
55
- const appConfigLink = _appConfig as AppConfig & { ui: { link: Partial<typeof theme> } }
56
-
57
- const link = tv({ extend: tv(theme), ...(appConfigLink.ui?.link || {}) })
58
-
59
- export interface LinkProps extends NuxtLinkProps {
60
- /**
61
- * The element or component this component should render as when not a link.
62
- * @defaultValue 'button'
63
- */
64
- as?: any
65
- /**
66
- * The type of the button when not a link.
67
- * @defaultValue 'button'
68
- */
69
- type?: ButtonHTMLAttributes['type']
70
- disabled?: boolean
71
- /** Force the link to be active independent of the current route. */
72
- active?: boolean
73
- /** Will only be active if the current route is an exact match. */
74
- exact?: boolean
75
- /** Will only be active if the current route query is an exact match. */
76
- exactQuery?: boolean | 'partial'
77
- /** Will only be active if the current route hash is an exact match. */
78
- exactHash?: boolean
79
- /** The class to apply when the link is inactive. */
80
- inactiveClass?: string
81
- custom?: boolean
82
- /** When `true`, only styles from `class`, `activeClass`, and `inactiveClass` will be applied. */
83
- raw?: boolean
84
- class?: any
85
- }
86
-
87
- export interface LinkSlots {
88
- default(props: { active: boolean }): any
89
- }
1
+ <script>
2
+ import theme from "#build/ui/link";
90
3
  </script>
91
4
 
92
- <script setup lang="ts">
93
- import { computed, getCurrentInstance } from 'vue'
94
- import { isEqual, diff } from 'ohash/utils'
95
- import { useForwardProps } from 'reka-ui'
96
- import { reactiveOmit } from '@vueuse/core'
97
- import { hasProtocol } from 'ufo'
98
- import { useRoute } from '#imports'
99
- import { RouterLink } from 'vue-router'
100
-
101
- defineOptions({ inheritAttrs: false })
102
-
103
- const props = withDefaults(defineProps<LinkProps>(), {
104
- as: 'button',
105
- type: 'button',
106
- active: undefined,
107
- activeClass: '',
108
- inactiveClass: ''
109
- })
110
- defineSlots<LinkSlots>()
111
-
112
- // Check if vue-router is available by checking for the injection key
5
+ <script setup>
6
+ import { computed, getCurrentInstance } from "vue";
7
+ import { defu } from "defu";
8
+ import { isEqual, diff } from "ohash/utils";
9
+ import { useForwardProps } from "reka-ui";
10
+ import { reactiveOmit } from "@vueuse/core";
11
+ import { hasProtocol } from "ufo";
12
+ import { useRoute, RouterLink } from "vue-router";
13
+ import { useAppConfig } from "#imports";
14
+ import { tv } from "../../utils/tv";
15
+ defineOptions({ inheritAttrs: false });
16
+ const props = defineProps({
17
+ as: { type: null, required: false, default: "button" },
18
+ type: { type: null, required: false, default: "button" },
19
+ disabled: { type: Boolean, required: false },
20
+ active: { type: Boolean, required: false, default: void 0 },
21
+ exact: { type: Boolean, required: false },
22
+ exactQuery: { type: [Boolean, String], required: false },
23
+ exactHash: { type: Boolean, required: false },
24
+ inactiveClass: { type: String, required: false, default: "" },
25
+ custom: { type: Boolean, required: false },
26
+ raw: { type: Boolean, required: false },
27
+ class: { type: null, required: false },
28
+ to: { type: null, required: false },
29
+ href: { type: null, required: false },
30
+ external: { type: Boolean, required: false },
31
+ target: { type: [String, Object, null], required: false },
32
+ rel: { type: [String, Object, null], required: false },
33
+ noRel: { type: Boolean, required: false },
34
+ prefetchedClass: { type: String, required: false },
35
+ prefetch: { type: Boolean, required: false },
36
+ prefetchOn: { type: [String, Object], required: false },
37
+ noPrefetch: { type: Boolean, required: false },
38
+ activeClass: { type: String, required: false, default: "" },
39
+ exactActiveClass: { type: String, required: false },
40
+ ariaCurrentValue: { type: String, required: false, default: "page" },
41
+ viewTransition: { type: Boolean, required: false },
42
+ replace: { type: Boolean, required: false }
43
+ });
44
+ defineSlots();
113
45
  const hasRouter = computed(() => {
114
- const app = getCurrentInstance()?.appContext.app
115
- return !!(app?.config?.globalProperties?.$router)
116
- })
117
-
118
- // Only try to get route if router exists
46
+ const app = getCurrentInstance()?.appContext.app;
47
+ return !!app?.config?.globalProperties?.$router;
48
+ });
119
49
  const route = computed(() => {
120
- if (!hasRouter.value) return null
50
+ if (!hasRouter.value) return null;
121
51
  try {
122
- return useRoute()
52
+ return useRoute();
123
53
  } catch {
124
- return null
54
+ return null;
125
55
  }
126
- })
127
-
128
- const routerLinkProps = useForwardProps(reactiveOmit(props, 'as', 'type', 'disabled', 'active', 'exact', 'exactQuery', 'exactHash', 'activeClass', 'inactiveClass', 'to', 'raw', 'class'))
129
-
56
+ });
57
+ const appConfig = useAppConfig();
58
+ const routerLinkProps = useForwardProps(reactiveOmit(props, "as", "type", "disabled", "active", "exact", "exactQuery", "exactHash", "activeClass", "inactiveClass", "to", "raw", "class"));
130
59
  const ui = computed(() => tv({
131
- extend: link,
132
- variants: {
133
- active: {
134
- true: props.activeClass,
135
- false: props.inactiveClass
60
+ extend: tv(theme),
61
+ ...defu({
62
+ variants: {
63
+ active: {
64
+ true: props.activeClass,
65
+ false: props.inactiveClass
66
+ }
136
67
  }
137
- }
138
- }))
139
-
140
- function isPartiallyEqual(item1: any, item2: any) {
68
+ }, appConfig.ui?.link || {})
69
+ }));
70
+ function isPartiallyEqual(item1, item2) {
141
71
  const diffedKeys = diff(item1, item2).reduce((filtered, q) => {
142
- if (q.type === 'added') {
143
- filtered.add(q.key)
72
+ if (q.type === "added") {
73
+ filtered.add(q.key);
144
74
  }
145
- return filtered
146
- }, new Set<string>())
147
-
148
- const item1Filtered = Object.fromEntries(Object.entries(item1).filter(([key]) => !diffedKeys.has(key)))
149
- const item2Filtered = Object.fromEntries(Object.entries(item2).filter(([key]) => !diffedKeys.has(key)))
150
-
151
- return isEqual(item1Filtered, item2Filtered)
75
+ return filtered;
76
+ }, /* @__PURE__ */ new Set());
77
+ const item1Filtered = Object.fromEntries(Object.entries(item1).filter(([key]) => !diffedKeys.has(key)));
78
+ const item2Filtered = Object.fromEntries(Object.entries(item2).filter(([key]) => !diffedKeys.has(key)));
79
+ return isEqual(item1Filtered, item2Filtered);
152
80
  }
153
-
154
81
  const isExternal = computed(() => {
155
- if (!props.to) return false
156
- return typeof props.to === 'string' && hasProtocol(props.to, { acceptRelative: true })
157
- })
158
-
159
- function isLinkActive({ route: linkRoute, isActive, isExactActive }: any) {
160
- if (props.active !== undefined) {
161
- return props.active
82
+ if (!props.to) return false;
83
+ return typeof props.to === "string" && hasProtocol(props.to, { acceptRelative: true });
84
+ });
85
+ function isLinkActive({ route: linkRoute, isActive, isExactActive }) {
86
+ if (props.active !== void 0) {
87
+ return props.active;
162
88
  }
163
-
164
89
  if (!props.to || !route.value) {
165
- return false
90
+ return false;
166
91
  }
167
-
168
- if (props.exactQuery === 'partial') {
169
- if (!isPartiallyEqual(linkRoute.query, route.value.query)) return false
92
+ if (props.exactQuery === "partial") {
93
+ if (!isPartiallyEqual(linkRoute.query, route.value.query)) return false;
170
94
  } else if (props.exactQuery === true) {
171
- if (!isEqual(linkRoute.query, route.value.query)) return false
95
+ if (!isEqual(linkRoute.query, route.value.query)) return false;
172
96
  }
173
-
174
97
  if (props.exactHash && linkRoute.hash !== route.value.hash) {
175
- return false
98
+ return false;
176
99
  }
177
-
178
100
  if (props.exact && isExactActive) {
179
- return true
101
+ return true;
180
102
  }
181
-
182
103
  if (!props.exact && isActive) {
183
- return true
104
+ return true;
184
105
  }
185
-
186
- return false
106
+ return false;
187
107
  }
188
-
189
- function resolveLinkClass({ route, isActive, isExactActive }: any = {}) {
190
- const active = isLinkActive({ route, isActive, isExactActive })
191
-
108
+ function resolveLinkClass({ route: route2, isActive, isExactActive } = {}) {
109
+ const active = isLinkActive({ route: route2, isActive, isExactActive });
192
110
  if (props.raw) {
193
- return [props.class, active ? props.activeClass : props.inactiveClass]
111
+ return [props.class, active ? props.activeClass : props.inactiveClass];
194
112
  }
195
-
196
- return ui.value({ class: props.class, active, disabled: props.disabled })
113
+ return ui.value({ class: props.class, active, disabled: props.disabled });
197
114
  }
198
115
  </script>
199
116
 
@@ -203,26 +120,28 @@ function resolveLinkClass({ route, isActive, isExactActive }: any = {}) {
203
120
  <template v-if="custom">
204
121
  <slot
205
122
  v-bind="{
206
- ...$attrs,
207
- as,
208
- type,
209
- disabled,
210
- href: to ? href : undefined,
211
- navigate,
212
- active: isLinkActive({ route: linkRoute, isActive, isExactActive })
213
- }"
123
+ ...$attrs,
124
+ ...exact && isExactActive ? { 'aria-current': props.ariaCurrentValue } : {},
125
+ as,
126
+ type,
127
+ disabled,
128
+ href: to ? href : void 0,
129
+ navigate,
130
+ active: isLinkActive({ route: linkRoute, isActive, isExactActive })
131
+ }"
214
132
  />
215
133
  </template>
216
134
  <ULinkBase
217
135
  v-else
218
136
  v-bind="{
219
- ...$attrs,
220
- as,
221
- type,
222
- disabled,
223
- href: to ? href : undefined,
224
- navigate
225
- }"
137
+ ...$attrs,
138
+ ...exact && isExactActive ? { 'aria-current': props.ariaCurrentValue } : {},
139
+ as,
140
+ type,
141
+ disabled,
142
+ href: to ? href : void 0,
143
+ navigate
144
+ }"
226
145
  :class="resolveLinkClass({ route: linkRoute, isActive, isExactActive })"
227
146
  >
228
147
  <slot :active="isLinkActive({ route: linkRoute, isActive, isExactActive })" />
@@ -234,26 +153,26 @@ function resolveLinkClass({ route, isActive, isExactActive }: any = {}) {
234
153
  <template v-if="custom">
235
154
  <slot
236
155
  v-bind="{
237
- ...$attrs,
238
- as,
239
- type,
240
- disabled,
241
- href: to,
242
- target: isExternal ? '_blank' : undefined,
243
- active: false
244
- }"
156
+ ...$attrs,
157
+ as,
158
+ type,
159
+ disabled,
160
+ href: to,
161
+ target: isExternal ? '_blank' : void 0,
162
+ active: false
163
+ }"
245
164
  />
246
165
  </template>
247
166
  <ULinkBase
248
167
  v-else
249
168
  v-bind="{
250
- ...$attrs,
251
- as,
252
- type,
253
- disabled,
254
- href: (to as string),
255
- target: isExternal ? '_blank' : undefined
256
- }"
169
+ ...$attrs,
170
+ as,
171
+ type,
172
+ disabled,
173
+ href: to,
174
+ target: isExternal ? '_blank' : void 0
175
+ }"
257
176
  :is-external="isExternal"
258
177
  :class="resolveLinkClass()"
259
178
  >
@@ -0,0 +1,124 @@
1
+ import type { ButtonHTMLAttributes } from 'vue';
2
+ import type { RouterLinkProps, RouteLocationRaw } from 'vue-router';
3
+ interface NuxtLinkProps extends Omit<RouterLinkProps, 'to'> {
4
+ /**
5
+ * Route Location the link should navigate to when clicked on.
6
+ */
7
+ to?: RouteLocationRaw;
8
+ /**
9
+ * An alias for `to`. If used with `to`, `href` will be ignored
10
+ */
11
+ href?: NuxtLinkProps['to'];
12
+ /**
13
+ * Forces the link to be considered as external (true) or internal (false). This is helpful to handle edge-cases
14
+ */
15
+ external?: boolean;
16
+ /**
17
+ * Where to display the linked URL, as the name for a browsing context.
18
+ */
19
+ target?: '_blank' | '_parent' | '_self' | '_top' | (string & {}) | null;
20
+ /**
21
+ * A rel attribute value to apply on the link. Defaults to "noopener noreferrer" for external links.
22
+ */
23
+ rel?: 'noopener' | 'noreferrer' | 'nofollow' | 'sponsored' | 'ugc' | (string & {}) | null;
24
+ /**
25
+ * If set to true, no rel attribute will be added to the link
26
+ */
27
+ noRel?: boolean;
28
+ /**
29
+ * A class to apply to links that have been prefetched.
30
+ */
31
+ prefetchedClass?: string;
32
+ /**
33
+ * When enabled will prefetch middleware, layouts and payloads of links in the viewport.
34
+ */
35
+ prefetch?: boolean;
36
+ /**
37
+ * Allows controlling when to prefetch links. By default, prefetch is triggered only on visibility.
38
+ */
39
+ prefetchOn?: 'visibility' | 'interaction' | Partial<{
40
+ visibility: boolean;
41
+ interaction: boolean;
42
+ }>;
43
+ /**
44
+ * Escape hatch to disable `prefetch` attribute.
45
+ */
46
+ noPrefetch?: boolean;
47
+ }
48
+ export interface LinkProps extends NuxtLinkProps {
49
+ /**
50
+ * The element or component this component should render as when not a link.
51
+ * @defaultValue 'button'
52
+ */
53
+ as?: any;
54
+ /**
55
+ * The type of the button when not a link.
56
+ * @defaultValue 'button'
57
+ */
58
+ type?: ButtonHTMLAttributes['type'];
59
+ disabled?: boolean;
60
+ /** Force the link to be active independent of the current route. */
61
+ active?: boolean;
62
+ /** Will only be active if the current route is an exact match. */
63
+ exact?: boolean;
64
+ /** Will only be active if the current route query is an exact match. */
65
+ exactQuery?: boolean | 'partial';
66
+ /** Will only be active if the current route hash is an exact match. */
67
+ exactHash?: boolean;
68
+ /** The class to apply when the link is inactive. */
69
+ inactiveClass?: string;
70
+ custom?: boolean;
71
+ /** When `true`, only styles from `class`, `activeClass`, and `inactiveClass` will be applied. */
72
+ raw?: boolean;
73
+ class?: any;
74
+ }
75
+ export interface LinkSlots {
76
+ default(props: {
77
+ active: boolean;
78
+ }): any;
79
+ }
80
+ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<LinkProps>, {
81
+ as: string;
82
+ type: string;
83
+ ariaCurrentValue: string;
84
+ active: undefined;
85
+ activeClass: string;
86
+ inactiveClass: string;
87
+ }>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<LinkProps>, {
88
+ as: string;
89
+ type: string;
90
+ ariaCurrentValue: string;
91
+ active: undefined;
92
+ activeClass: string;
93
+ inactiveClass: string;
94
+ }>>> & Readonly<{}>, {
95
+ type: "reset" | "submit" | "button";
96
+ as: any;
97
+ activeClass: string;
98
+ ariaCurrentValue: "page" | "step" | "location" | "date" | "time" | "true" | "false";
99
+ active: boolean;
100
+ inactiveClass: string;
101
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, Readonly<LinkSlots> & LinkSlots>;
102
+ export default _default;
103
+ type __VLS_WithDefaults<P, D> = {
104
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
105
+ default: D[K];
106
+ }> : P[K];
107
+ };
108
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
109
+ type __VLS_TypePropsToOption<T> = {
110
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
111
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
112
+ } : {
113
+ type: import('vue').PropType<T[K]>;
114
+ required: true;
115
+ };
116
+ };
117
+ type __VLS_WithTemplateSlots<T, S> = T & {
118
+ new (): {
119
+ $slots: S;
120
+ };
121
+ };
122
+ type __VLS_PrettifyLocal<T> = {
123
+ [K in keyof T]: T[K];
124
+ } & {};
@@ -29,7 +29,12 @@ export declare function useNuxtApp(): {
29
29
  payload: {
30
30
  serverRendered: boolean;
31
31
  };
32
+ hooks: import("hookable").Hookable<Record<string, any>, string>;
33
+ hook: <NameT extends string>(name: NameT, function_: any, options?: {
34
+ allowDeprecated?: boolean;
35
+ }) => () => void;
32
36
  };
37
+ export declare function useRuntimeHook(name: string, fn: (...args: any[]) => void): void;
33
38
  export declare function defineNuxtPlugin(plugin: (nuxtApp: NuxtApp) => void): {
34
39
  install(app: import("vue").App<any>): void;
35
40
  };
@@ -1,4 +1,5 @@
1
- import { ref } from "vue";
1
+ import { ref, onScopeDispose } from "vue";
2
+ import { createHooks } from "hookable";
2
3
  import appConfig from "#build/app.config";
3
4
  import { useColorMode as useColorModeVueUse } from "@vueuse/core";
4
5
  export { useHead } from "@unhead/vue";
@@ -50,12 +51,20 @@ export const useState = (key, init) => {
50
51
  state[key] = value;
51
52
  return value;
52
53
  };
54
+ const hooks = createHooks();
53
55
  export function useNuxtApp() {
54
56
  return {
55
57
  isHydrating: true,
56
- payload: { serverRendered: false }
58
+ payload: { serverRendered: false },
59
+ hooks,
60
+ hook: hooks.hook
57
61
  };
58
62
  }
63
+ export function useRuntimeHook(name, fn) {
64
+ const nuxtApp = useNuxtApp();
65
+ const unregister = nuxtApp.hook(name, fn);
66
+ onScopeDispose(unregister);
67
+ }
59
68
  export function defineNuxtPlugin(plugin) {
60
69
  return {
61
70
  install(app) {