@byyuurin/ui 0.0.9 → 0.0.11

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 (215) hide show
  1. package/README.md +2 -5
  2. package/dist/module.json +3 -3
  3. package/dist/module.mjs +1 -1
  4. package/dist/module.mjs.map +1 -1
  5. package/dist/runtime/app/injections.d.ts +9323 -3
  6. package/dist/runtime/app/injections.js +35 -0
  7. package/dist/runtime/components/Accordion.vue +36 -69
  8. package/dist/runtime/components/Accordion.vue.d.ts +52 -0
  9. package/dist/runtime/components/Alert.vue +37 -75
  10. package/dist/runtime/components/Alert.vue.d.ts +59 -0
  11. package/dist/runtime/components/App.vue +25 -40
  12. package/dist/runtime/components/App.vue.d.ts +24 -0
  13. package/dist/runtime/components/Avatar.vue +31 -51
  14. package/dist/runtime/components/Avatar.vue.d.ts +25 -0
  15. package/dist/runtime/components/AvatarGroup.vue +38 -69
  16. package/dist/runtime/components/AvatarGroup.vue.d.ts +27 -0
  17. package/dist/runtime/components/Badge.vue +25 -51
  18. package/dist/runtime/components/Badge.vue.d.ts +44 -0
  19. package/dist/runtime/components/Breadcrumb.vue +35 -77
  20. package/dist/runtime/components/Breadcrumb.vue.d.ts +52 -0
  21. package/dist/runtime/components/Button.vue +62 -51
  22. package/dist/runtime/components/Button.vue.d.ts +29 -0
  23. package/dist/runtime/components/ButtonGroup.vue +17 -37
  24. package/dist/runtime/components/ButtonGroup.vue.d.ts +26 -0
  25. package/dist/runtime/components/Calendar.vue +75 -101
  26. package/dist/runtime/components/Calendar.vue.d.ts +75 -0
  27. package/dist/runtime/components/Card.vue +25 -42
  28. package/dist/runtime/components/Card.vue.d.ts +30 -0
  29. package/dist/runtime/components/Carousel.vue +118 -223
  30. package/dist/runtime/components/Carousel.vue.d.ts +104 -0
  31. package/dist/runtime/components/Checkbox.vue +49 -71
  32. package/dist/runtime/components/Checkbox.vue.d.ts +56 -0
  33. package/dist/runtime/components/Chip.vue +31 -48
  34. package/dist/runtime/components/Chip.vue.d.ts +30 -0
  35. package/dist/runtime/components/Collapsible.vue +22 -30
  36. package/dist/runtime/components/Collapsible.vue.d.ts +26 -0
  37. package/dist/runtime/components/Drawer.vue +52 -102
  38. package/dist/runtime/components/Drawer.vue.d.ts +80 -0
  39. package/dist/runtime/components/DropdownMenu.vue +65 -0
  40. package/dist/runtime/components/DropdownMenu.vue.d.ts +99 -0
  41. package/dist/runtime/components/DropdownMenuContent.vue +192 -0
  42. package/dist/runtime/components/DropdownMenuContent.vue.d.ts +39 -0
  43. package/dist/runtime/components/Form.vue +197 -0
  44. package/dist/runtime/components/Form.vue.d.ts +78 -0
  45. package/dist/runtime/components/FormItem.vue +90 -0
  46. package/dist/runtime/components/FormItem.vue.d.ts +60 -0
  47. package/dist/runtime/components/Input.vue +93 -115
  48. package/dist/runtime/components/Input.vue.d.ts +64 -0
  49. package/dist/runtime/components/InputNumber.vue +81 -116
  50. package/dist/runtime/components/InputNumber.vue.d.ts +245 -0
  51. package/dist/runtime/components/Kbd.vue +18 -39
  52. package/dist/runtime/components/Kbd.vue.d.ts +28 -0
  53. package/dist/runtime/components/Link.vue +170 -244
  54. package/dist/runtime/components/Link.vue.d.ts +95 -0
  55. package/dist/runtime/components/LinkBase.vue +36 -54
  56. package/dist/runtime/components/LinkBase.vue.d.ts +28 -0
  57. package/dist/runtime/components/Modal.vue +50 -85
  58. package/dist/runtime/components/Modal.vue.d.ts +66 -0
  59. package/dist/runtime/components/OverlayProvider.vue +10 -14
  60. package/dist/runtime/components/OverlayProvider.vue.d.ts +2 -0
  61. package/dist/runtime/components/Pagination.vue +55 -121
  62. package/dist/runtime/components/Pagination.vue.d.ts +93 -0
  63. package/dist/runtime/components/PinInput.vue +57 -57
  64. package/dist/runtime/components/PinInput.vue.d.ts +35 -0
  65. package/dist/runtime/components/Popover.vue +39 -68
  66. package/dist/runtime/components/Popover.vue.d.ts +45 -0
  67. package/dist/runtime/components/Progress.vue +68 -120
  68. package/dist/runtime/components/Progress.vue.d.ts +54 -0
  69. package/dist/runtime/components/RadioGroup.vue +75 -129
  70. package/dist/runtime/components/RadioGroup.vue.d.ts +74 -0
  71. package/dist/runtime/components/ScrollArea.vue +31 -31
  72. package/dist/runtime/components/ScrollArea.vue.d.ts +17 -0
  73. package/dist/runtime/components/Select.vue +119 -199
  74. package/dist/runtime/components/Select.vue.d.ts +119 -0
  75. package/dist/runtime/components/Separator.vue +26 -44
  76. package/dist/runtime/components/Separator.vue.d.ts +27 -0
  77. package/dist/runtime/components/Skeleton.vue +12 -21
  78. package/dist/runtime/components/Skeleton.vue.d.ts +19 -0
  79. package/dist/runtime/components/Slider.vue +54 -71
  80. package/dist/runtime/components/Slider.vue.d.ts +36 -0
  81. package/dist/runtime/components/Switch.vue +54 -68
  82. package/dist/runtime/components/Switch.vue.d.ts +49 -0
  83. package/dist/runtime/components/Table.vue +113 -186
  84. package/dist/runtime/components/Table.vue.d.ts +148 -0
  85. package/dist/runtime/components/Tabs.vue +35 -79
  86. package/dist/runtime/components/Tabs.vue.d.ts +65 -0
  87. package/dist/runtime/components/Textarea.vue +82 -123
  88. package/dist/runtime/components/Textarea.vue.d.ts +60 -0
  89. package/dist/runtime/components/Toast.vue +51 -76
  90. package/dist/runtime/components/Toast.vue.d.ts +131 -0
  91. package/dist/runtime/components/ToastProvider.vue +65 -101
  92. package/dist/runtime/components/ToastProvider.vue.d.ts +38 -0
  93. package/dist/runtime/components/Tooltip.vue +36 -47
  94. package/dist/runtime/components/Tooltip.vue.d.ts +31 -0
  95. package/dist/runtime/composables/useAvatarGroup.d.ts +1 -1
  96. package/dist/runtime/composables/useButtonGroup.d.ts +2 -2
  97. package/dist/runtime/composables/useFormItem.d.ts +27 -0
  98. package/dist/runtime/composables/useFormItem.js +64 -0
  99. package/dist/runtime/composables/useKbd.d.ts +1 -1
  100. package/dist/runtime/composables/useLocale.d.ts +3 -3
  101. package/dist/runtime/composables/useTheme.d.ts +1 -1
  102. package/dist/runtime/composables/useTheme.js +2 -1
  103. package/dist/runtime/composables/useToast.d.ts +1 -1
  104. package/dist/runtime/index.d.ts +3 -0
  105. package/dist/runtime/index.js +3 -0
  106. package/dist/runtime/locale/en.d.ts +1 -1
  107. package/dist/runtime/locale/zh-tw.d.ts +1 -1
  108. package/dist/runtime/theme/accordion.d.ts +45 -51
  109. package/dist/runtime/theme/accordion.js +1 -1
  110. package/dist/runtime/theme/alert.d.ts +115 -121
  111. package/dist/runtime/theme/alert.js +1 -1
  112. package/dist/runtime/theme/app.d.ts +1 -0
  113. package/dist/runtime/theme/app.js +2 -1
  114. package/dist/runtime/theme/avatar-group.d.ts +42 -48
  115. package/dist/runtime/theme/avatar-group.js +1 -1
  116. package/dist/runtime/theme/avatar.d.ts +46 -52
  117. package/dist/runtime/theme/avatar.js +1 -1
  118. package/dist/runtime/theme/badge.d.ts +63 -93
  119. package/dist/runtime/theme/badge.js +1 -1
  120. package/dist/runtime/theme/breadcrumb.d.ts +52 -58
  121. package/dist/runtime/theme/breadcrumb.js +1 -1
  122. package/dist/runtime/theme/button-group.d.ts +36 -42
  123. package/dist/runtime/theme/button.d.ts +165 -117
  124. package/dist/runtime/theme/button.js +1 -1
  125. package/dist/runtime/theme/calendar.d.ts +52 -50
  126. package/dist/runtime/theme/calendar.js +20 -3
  127. package/dist/runtime/theme/card.d.ts +52 -58
  128. package/dist/runtime/theme/card.js +1 -1
  129. package/dist/runtime/theme/carousel.d.ts +98 -104
  130. package/dist/runtime/theme/carousel.js +1 -1
  131. package/dist/runtime/theme/checkbox.d.ts +77 -83
  132. package/dist/runtime/theme/checkbox.js +1 -1
  133. package/dist/runtime/theme/chip.d.ts +50 -89
  134. package/dist/runtime/theme/chip.js +1 -1
  135. package/dist/runtime/theme/collapsible.d.ts +29 -35
  136. package/dist/runtime/theme/collapsible.js +1 -1
  137. package/dist/runtime/theme/drawer.d.ts +131 -102
  138. package/dist/runtime/theme/drawer.js +1 -1
  139. package/dist/runtime/theme/dropdown-menu.d.ts +65 -0
  140. package/dist/runtime/theme/dropdown-menu.js +83 -0
  141. package/dist/runtime/theme/form-item.d.ts +70 -0
  142. package/dist/runtime/theme/form-item.js +34 -0
  143. package/dist/runtime/theme/form.d.ts +2 -0
  144. package/dist/runtime/theme/form.js +7 -0
  145. package/dist/runtime/theme/index.d.ts +3 -0
  146. package/dist/runtime/theme/index.js +3 -0
  147. package/dist/runtime/theme/input-number.d.ts +100 -126
  148. package/dist/runtime/theme/input-number.js +1 -1
  149. package/dist/runtime/theme/input.d.ts +153 -131
  150. package/dist/runtime/theme/input.js +3 -3
  151. package/dist/runtime/theme/kbd.d.ts +30 -36
  152. package/dist/runtime/theme/link.d.ts +37 -43
  153. package/dist/runtime/theme/modal.d.ts +35 -69
  154. package/dist/runtime/theme/modal.js +1 -1
  155. package/dist/runtime/theme/pagination.d.ts +71 -77
  156. package/dist/runtime/theme/pagination.js +1 -1
  157. package/dist/runtime/theme/pinInput.d.ts +82 -88
  158. package/dist/runtime/theme/pinInput.js +2 -2
  159. package/dist/runtime/theme/popover.d.ts +29 -35
  160. package/dist/runtime/theme/popover.js +1 -1
  161. package/dist/runtime/theme/progress.d.ts +167 -109
  162. package/dist/runtime/theme/progress.js +1 -1
  163. package/dist/runtime/theme/radio-group.d.ts +99 -105
  164. package/dist/runtime/theme/radio-group.js +1 -1
  165. package/dist/runtime/theme/scroll-area.d.ts +62 -68
  166. package/dist/runtime/theme/scroll-area.js +1 -1
  167. package/dist/runtime/theme/select.d.ts +168 -158
  168. package/dist/runtime/theme/select.js +3 -2
  169. package/dist/runtime/theme/separator.d.ts +64 -85
  170. package/dist/runtime/theme/separator.js +1 -1
  171. package/dist/runtime/theme/skeleton.d.ts +1 -7
  172. package/dist/runtime/theme/slider.d.ts +62 -68
  173. package/dist/runtime/theme/slider.js +1 -1
  174. package/dist/runtime/theme/switch.d.ts +111 -117
  175. package/dist/runtime/theme/switch.js +1 -1
  176. package/dist/runtime/theme/table.d.ts +75 -78
  177. package/dist/runtime/theme/table.js +3 -2
  178. package/dist/runtime/theme/tabs.d.ts +116 -139
  179. package/dist/runtime/theme/tabs.js +1 -1
  180. package/dist/runtime/theme/textarea.d.ts +78 -90
  181. package/dist/runtime/theme/textarea.js +2 -2
  182. package/dist/runtime/theme/toast-provider.d.ts +110 -131
  183. package/dist/runtime/theme/toast-provider.js +1 -1
  184. package/dist/runtime/theme/toast.d.ts +74 -80
  185. package/dist/runtime/theme/toast.js +1 -1
  186. package/dist/runtime/theme/tooltip.d.ts +35 -41
  187. package/dist/runtime/theme/tooltip.js +1 -1
  188. package/dist/runtime/types/components.d.ts +3 -0
  189. package/dist/runtime/types/form.d.ts +45 -0
  190. package/dist/runtime/types/form.js +0 -0
  191. package/dist/runtime/types/index.d.ts +5 -2
  192. package/dist/runtime/types/index.js +1 -0
  193. package/dist/runtime/types/utils.d.ts +37 -16
  194. package/dist/runtime/utils/extend-theme.js +15 -4
  195. package/dist/runtime/utils/form.d.ts +5 -0
  196. package/dist/runtime/utils/form.js +24 -0
  197. package/dist/runtime/utils/index.d.ts +2 -0
  198. package/dist/runtime/utils/index.js +4 -0
  199. package/dist/runtime/utils/link.d.ts +4 -28
  200. package/dist/runtime/utils/link.js +10 -3
  201. package/dist/runtime/utils/styler.d.ts +2 -2
  202. package/dist/runtime/utils/styler.js +2 -2
  203. package/dist/shared/ui.D1BTWZFB.mjs +5 -0
  204. package/dist/shared/ui.D1BTWZFB.mjs.map +1 -0
  205. package/dist/types.d.mts +1 -1
  206. package/dist/unocss.mjs +7 -6
  207. package/dist/unocss.mjs.map +1 -1
  208. package/dist/unplugin.mjs +1 -1
  209. package/dist/unplugin.mjs.map +1 -1
  210. package/dist/vite.mjs +1 -1
  211. package/package.json +78 -74
  212. package/dist/module.cjs +0 -5
  213. package/dist/shared/ui.1a1f119c.mjs +0 -5
  214. package/dist/shared/ui.1a1f119c.mjs.map +0 -1
  215. package/dist/types.d.ts +0 -1
@@ -1,224 +1,140 @@
1
- <script lang="ts">
2
- import type { PrimitiveProps } from 'reka-ui'
3
- import type { ButtonHTMLAttributes } from 'vue'
4
- import type { RouteLocationRaw, RouterLinkProps } from 'vue-router'
5
- import type { link } from '../theme'
6
- import type { ComponentAttrs } from '../types'
1
+ <script>
7
2
 
8
- export interface LinkSlots {
9
- default?: (props: { active: boolean }) => any
10
- }
11
-
12
- interface NuxtLinkProps extends Omit<RouterLinkProps, 'to'> {
13
- /**
14
- * Route Location the link should navigate to when clicked on.
15
- */
16
- to?: RouteLocationRaw // need to manually type to avoid breaking typedPages
17
- /**
18
- * An alias for `to`. If used with `to`, `href` will be ignored
19
- */
20
- href?: NuxtLinkProps['to']
21
- /**
22
- * Forces the link to be considered as external (true) or internal (false). This is helpful to handle edge-cases
23
- */
24
- external?: boolean
25
- /**
26
- * Where to display the linked URL, as the name for a browsing context.
27
- */
28
- target?: '_blank' | '_parent' | '_self' | '_top' | (string & {}) | null
29
- /**
30
- * A rel attribute value to apply on the link. Defaults to "noopener noreferrer" for external links.
31
- */
32
- rel?: 'noopener' | 'noreferrer' | 'nofollow' | 'sponsored' | 'ugc' | (string & {}) | null
33
- /**
34
- * If set to true, no rel attribute will be added to the link
35
- */
36
- noRel?: boolean
37
- /**
38
- * A class to apply to links that have been prefetched.
39
- */
40
- prefetchedClass?: string
41
- /**
42
- * When enabled will prefetch middleware, layouts and payloads of links in the viewport.
43
- */
44
- prefetch?: boolean
45
- /**
46
- * Allows controlling when to prefetch links. By default, prefetch is triggered only on visibility.
47
- */
48
- prefetchOn?: 'visibility' | 'interaction' | Partial<{
49
- visibility: boolean
50
- interaction: boolean
51
- }>
52
- /**
53
- * Escape hatch to disable `prefetch` attribute.
54
- */
55
- noPrefetch?: boolean
56
- }
57
-
58
- export interface LinkProps extends Omit<ComponentAttrs<typeof link>, 'ui'>, NuxtLinkProps {
59
- /**
60
- * The element or component this component should render as when not a link.
61
- * @default "button"
62
- */
63
- as?: PrimitiveProps['as']
64
- /**
65
- * The type of the button when not a link.
66
- * @default "button"
67
- */
68
- type?: ButtonHTMLAttributes['type']
69
- label?: string
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
- /** The class to apply when the link is disabled. */
82
- disableClass?: string
83
- custom?: boolean
84
- underline?: boolean
85
- /** When `true`, only styles from `class`, `ui.active`, and `ui.inactive` will be applied. */
86
- raw?: boolean
87
- }
88
3
  </script>
89
4
 
90
- <script setup lang="ts">
91
- import { reactiveOmit } from '@vueuse/core'
92
- import { diff, isEqual } from 'ohash/utils'
93
- import { useForwardProps } from 'reka-ui'
94
- import { hasProtocol } from 'ufo'
95
- import { computed, getCurrentInstance, resolveComponent } from 'vue'
96
- import { useNuxtApp, useRoute } from '#imports'
97
- import { useTheme } from '../composables/useTheme'
98
- import LinkBase from './LinkBase.vue'
99
-
100
- defineOptions({ inheritAttrs: false })
101
-
102
- const props = withDefaults(defineProps<LinkProps>(), {
103
- as: 'button',
104
- type: 'button',
105
- })
106
- defineSlots<LinkSlots>()
107
-
108
- // Check if vue-router is available by checking for the injection key
5
+ <script setup>
6
+ import { reactiveOmit } from "@vueuse/core";
7
+ import { diff, isEqual } from "ohash/utils";
8
+ import { useForwardProps } from "reka-ui";
9
+ import { hasProtocol } from "ufo";
10
+ import { computed, getCurrentInstance, resolveComponent } from "vue";
11
+ import { useNuxtApp, useRoute } from "#imports";
12
+ import { useTheme } from "../composables/useTheme";
13
+ import LinkBase from "./LinkBase.vue";
14
+ defineOptions({ inheritAttrs: false });
15
+ const props = defineProps({
16
+ as: { type: null, required: false, default: "button" },
17
+ type: { type: null, required: false, default: "button" },
18
+ label: { type: String, required: false },
19
+ disabled: { type: Boolean, required: false },
20
+ active: { type: Boolean, required: false },
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 },
25
+ disableClass: { type: String, required: false },
26
+ custom: { type: Boolean, required: false },
27
+ underline: { type: Boolean, required: false },
28
+ raw: { type: Boolean, required: false },
29
+ class: { type: null, required: false },
30
+ to: { type: null, required: false },
31
+ href: { type: null, required: false },
32
+ external: { type: Boolean, required: false },
33
+ target: { type: [String, Object, null], required: false },
34
+ rel: { type: [String, Object, null], required: false },
35
+ noRel: { type: Boolean, required: false },
36
+ prefetchedClass: { type: String, required: false },
37
+ prefetch: { type: Boolean, required: false },
38
+ prefetchOn: { type: [String, Object], required: false },
39
+ noPrefetch: { type: Boolean, required: false },
40
+ activeClass: { type: String, required: false },
41
+ exactActiveClass: { type: String, required: false },
42
+ ariaCurrentValue: { type: String, required: false },
43
+ viewTransition: { type: Boolean, required: false },
44
+ replace: { type: Boolean, required: false }
45
+ });
46
+ defineSlots();
109
47
  const hasRouter = computed(() => {
110
- const app = getCurrentInstance()?.appContext.app
111
- return !!(app?.config?.globalProperties?.$router)
112
- })
113
-
114
- const nuxtApp = useNuxtApp()
115
- const hasNuxtLink = !!nuxtApp.$router
116
-
48
+ const app = getCurrentInstance()?.appContext.app;
49
+ return !!app?.config?.globalProperties?.$router;
50
+ });
51
+ const nuxtApp = useNuxtApp();
52
+ const hasNuxtLink = !!nuxtApp.$router;
117
53
  const linkComponent = computed(() => ({
118
- NuxtLink: nuxtApp.$router ? resolveComponent('NuxtLink') : null,
119
- RouterLink: hasRouter.value ? resolveComponent('RouterLink') : null,
120
- }))
121
-
122
- // Only try to get route if router exists
54
+ NuxtLink: nuxtApp.$router ? resolveComponent("NuxtLink") : null,
55
+ RouterLink: hasRouter.value ? resolveComponent("RouterLink") : null
56
+ }));
123
57
  const route = computed(() => {
124
58
  if (!hasRouter.value)
125
- return null
126
-
59
+ return null;
127
60
  try {
128
- return useRoute()
129
- }
130
- catch {
131
- return null
61
+ return useRoute();
62
+ } catch {
63
+ return null;
132
64
  }
133
- })
134
-
65
+ });
135
66
  const linkProps = useForwardProps(reactiveOmit(
136
67
  props,
137
- 'as',
138
- 'type',
139
- 'disabled',
140
- 'active',
141
- 'exact',
142
- 'exactQuery',
143
- 'exactHash',
144
- 'activeClass',
145
- 'inactiveClass',
146
- 'raw',
147
- 'class',
148
- ...(hasNuxtLink ? [] : ['to'] as const),
149
- ))
150
-
151
- function isPartiallyEqual(item1: any, item2: any) {
68
+ "as",
69
+ "type",
70
+ "disabled",
71
+ "active",
72
+ "exact",
73
+ "exactQuery",
74
+ "exactHash",
75
+ "activeClass",
76
+ "inactiveClass",
77
+ "raw",
78
+ "class",
79
+ ...hasNuxtLink ? [] : ["to"]
80
+ ));
81
+ function isPartiallyEqual(item1, item2) {
152
82
  const diffedKeys = diff(item1, item2).reduce((filtered, q) => {
153
- if (q.type === 'added')
154
- filtered.add(q.key)
155
-
156
- return filtered
157
- }, new Set<string>())
158
-
159
- const item1Filtered = Object.fromEntries(Object.entries(item1).filter(([key]) => !diffedKeys.has(key)))
160
- const item2Filtered = Object.fromEntries(Object.entries(item2).filter(([key]) => !diffedKeys.has(key)))
161
-
162
- return isEqual(item1Filtered, item2Filtered)
83
+ if (q.type === "added")
84
+ filtered.add(q.key);
85
+ return filtered;
86
+ }, /* @__PURE__ */ new Set());
87
+ const item1Filtered = Object.fromEntries(Object.entries(item1).filter(([key]) => !diffedKeys.has(key)));
88
+ const item2Filtered = Object.fromEntries(Object.entries(item2).filter(([key]) => !diffedKeys.has(key)));
89
+ return isEqual(item1Filtered, item2Filtered);
163
90
  }
164
-
165
91
  const isExternalLink = computed(() => {
166
- const to = props.to || props.href
167
-
92
+ const to = props.to || props.href;
168
93
  if (!to)
169
- return false
170
-
171
- return typeof to === 'string' && hasProtocol(to, { acceptRelative: true })
172
- })
173
-
174
- function isLinkActive({ route: linkRoute, isActive, isExactActive }: any) {
175
- if (props.active !== undefined)
176
- return props.active
177
-
178
- if (props.exactQuery === 'partial') {
94
+ return false;
95
+ if (props.target === "_blank")
96
+ return true;
97
+ return typeof to === "string" && hasProtocol(to, { acceptRelative: true });
98
+ });
99
+ function isLinkActive({ route: linkRoute, isActive, isExactActive }) {
100
+ if (props.active !== void 0)
101
+ return props.active;
102
+ if (isExternalLink.value || !props.to)
103
+ return false;
104
+ if (props.exactQuery === "partial") {
179
105
  if (!isPartiallyEqual(linkRoute?.query, route.value?.query))
180
- return false
181
- }
182
- else if (props.exactQuery === true && !isEqual(linkRoute?.query, route.value?.query)) {
183
- return false
106
+ return false;
107
+ } else if (props.exactQuery === true && !isEqual(linkRoute?.query, route.value?.query)) {
108
+ return false;
184
109
  }
185
-
186
110
  if (props.exactHash && linkRoute?.hash !== route.value?.hash)
187
- return false
188
-
111
+ return false;
189
112
  if (props.exact && isExactActive)
190
- return true
191
-
113
+ return true;
192
114
  if (!props.exact && isActive)
193
- return true
194
-
195
- return false
115
+ return true;
116
+ return false;
196
117
  }
197
-
198
- const { theme, createStyler } = useTheme()
199
-
200
- function resolveLinkClass({ route, isActive, isExactActive }: any = {}) {
201
- const { link } = theme.value
202
- const active = isLinkActive({ route, isActive, isExactActive })
203
-
118
+ const { theme, createStyler } = useTheme();
119
+ function resolveLinkClass({ route: route2, isActive, isExactActive } = {}) {
120
+ const { link } = theme.value;
121
+ const active = isLinkActive({ route: route2, isActive, isExactActive });
204
122
  if (props.raw)
205
- return [props.class, active ? props.activeClass : props.inactiveClass]
206
-
123
+ return [props.class, active ? props.activeClass : props.inactiveClass];
207
124
  const styler = createStyler({
208
125
  ...link,
209
126
  variants: {
210
127
  ...link.variants,
211
128
  active: {
212
129
  true: [link.variants.active.true, props.activeClass],
213
- false: [link.variants.active.false, props.inactiveClass],
130
+ false: [link.variants.active.false, props.inactiveClass]
214
131
  },
215
132
  disabled: {
216
- true: [link.variants.disabled.true, props.disableClass],
217
- },
218
- },
219
- })
220
-
221
- return styler({ ...props, active })
133
+ true: [link.variants.disabled.true, props.disableClass]
134
+ }
135
+ }
136
+ });
137
+ return styler({ ...props, active }).base();
222
138
  }
223
139
  </script>
224
140
 
@@ -229,23 +145,23 @@ function resolveLinkClass({ route, isActive, isExactActive }: any = {}) {
229
145
  v-if="hasNuxtLink"
230
146
  v-slot="{ href, navigate, route: linkRoute, rel, target, isExternal, isActive, isExactActive }"
231
147
  v-bind="linkProps"
232
- :href="to ? undefined : href"
148
+ :href="to ? void 0 : href"
233
149
  custom
234
150
  >
235
151
  <template v-if="custom">
236
152
  <slot
237
153
  v-bind="{
238
- ...$attrs,
239
- as,
240
- type,
241
- disabled,
242
- href,
243
- navigate,
244
- rel,
245
- target,
246
- isExternal,
247
- active: isLinkActive({ route: linkRoute, isActive, isExactActive }),
248
- }"
154
+ ...$attrs,
155
+ as,
156
+ type,
157
+ disabled,
158
+ href,
159
+ navigate,
160
+ rel,
161
+ target,
162
+ isExternal,
163
+ active: isLinkActive({ route: linkRoute, isActive, isExactActive })
164
+ }"
249
165
  >
250
166
  {{ props.label }}
251
167
  </slot>
@@ -253,17 +169,18 @@ function resolveLinkClass({ route, isActive, isExactActive }: any = {}) {
253
169
  <LinkBase
254
170
  v-else
255
171
  v-bind="{
256
- ...$attrs,
257
- as,
258
- type,
259
- disabled,
260
- href,
261
- navigate,
262
- rel,
263
- target,
264
- isExternal,
265
- }"
172
+ ...$attrs,
173
+ as,
174
+ type,
175
+ disabled,
176
+ href,
177
+ navigate,
178
+ rel,
179
+ target,
180
+ isExternal
181
+ }"
266
182
  :class="resolveLinkClass({ route: linkRoute, isActive, isExactActive })"
183
+ :data-part="$attrs['data-part'] ?? 'base'"
267
184
  >
268
185
  <slot :active="isLinkActive({ route: linkRoute, isActive, isExactActive })">
269
186
  {{ props.label }}
@@ -275,20 +192,27 @@ function resolveLinkClass({ route, isActive, isExactActive }: any = {}) {
275
192
  v-else
276
193
  v-slot="{ href, navigate, route: linkRoute, isActive, isExactActive }"
277
194
  v-bind="linkProps"
278
- :to="to || '#'"
195
+ :to="isExternalLink ? '#' : to || '#'"
279
196
  custom
280
197
  >
281
198
  <template v-if="custom">
282
199
  <slot
283
200
  v-bind="{
284
- ...$attrs,
285
- as,
286
- type,
287
- disabled,
288
- href: to ? href : undefined,
289
- navigate,
290
- active: isLinkActive({ route: linkRoute, isActive, isExactActive }),
291
- }"
201
+ ...$attrs,
202
+ ...isExternalLink ? {
203
+ href: to || props.href,
204
+ target: props.target
205
+ } : {
206
+ href: to ? href : void 0,
207
+ target: void 0
208
+ },
209
+ as,
210
+ type,
211
+ disabled,
212
+ navigate,
213
+ active: isLinkActive({ route: linkRoute, isActive, isExactActive }),
214
+ isExternal: isExternalLink
215
+ }"
292
216
  >
293
217
  {{ props.label }}
294
218
  </slot>
@@ -296,15 +220,16 @@ function resolveLinkClass({ route, isActive, isExactActive }: any = {}) {
296
220
  <LinkBase
297
221
  v-else
298
222
  v-bind="{
299
- ...$attrs,
300
- as,
301
- type,
302
- disabled,
303
- href: to ? href : undefined,
304
- navigate,
305
- }"
223
+ ...$attrs,
224
+ as,
225
+ type,
226
+ disabled,
227
+ href: to ? href : void 0,
228
+ navigate
229
+ }"
306
230
  :is-external="isExternalLink"
307
231
  :class="resolveLinkClass({ route: linkRoute, isActive, isExactActive })"
232
+ :data-part="$attrs['data-part'] ?? 'base'"
308
233
  >
309
234
  <slot :active="isLinkActive({ route: linkRoute, isActive, isExactActive })">
310
235
  {{ props.label }}
@@ -316,14 +241,14 @@ function resolveLinkClass({ route, isActive, isExactActive }: any = {}) {
316
241
  <template v-if="props.custom">
317
242
  <slot
318
243
  v-bind="{
319
- ...$attrs,
320
- as,
321
- type,
322
- disabled,
323
- href: to || href,
324
- target: target || (isExternalLink ? '_blank' : undefined),
325
- active: false,
326
- }"
244
+ ...$attrs,
245
+ as,
246
+ type,
247
+ disabled,
248
+ href: to || href,
249
+ target: target || (isExternalLink ? '_blank' : void 0),
250
+ active: false
251
+ }"
327
252
  >
328
253
  {{ props.label }}
329
254
  </slot>
@@ -331,15 +256,16 @@ function resolveLinkClass({ route, isActive, isExactActive }: any = {}) {
331
256
  <LinkBase
332
257
  v-else
333
258
  v-bind="{
334
- ...$attrs,
335
- as,
336
- type,
337
- disabled,
338
- href: ((typeof to === 'string' ? to : href) as string),
339
- target: target || (isExternalLink ? '_blank' : undefined),
340
- }"
259
+ ...$attrs,
260
+ as,
261
+ type,
262
+ disabled,
263
+ href: typeof to === 'string' ? to : href,
264
+ target: target || (isExternalLink ? '_blank' : void 0)
265
+ }"
341
266
  :is-external="isExternalLink"
342
267
  :class="resolveLinkClass()"
268
+ :data-part="$attrs['data-part'] ?? 'base'"
343
269
  >
344
270
  <slot :active="false">
345
271
  {{ props.label }}
@@ -0,0 +1,95 @@
1
+ import type { PrimitiveProps } from 'reka-ui';
2
+ import type { ButtonHTMLAttributes } from 'vue';
3
+ import type { RouteLocationRaw, RouterLinkProps } from 'vue-router';
4
+ import type { link } from '../theme/index.js';
5
+ import type { ComponentAttrs } from '../types/index.js';
6
+ export interface LinkSlots {
7
+ default?: (props: {
8
+ active: boolean;
9
+ }) => any;
10
+ }
11
+ interface NuxtLinkProps extends Omit<RouterLinkProps, 'to'> {
12
+ /**
13
+ * Route Location the link should navigate to when clicked on.
14
+ */
15
+ to?: RouteLocationRaw;
16
+ /**
17
+ * An alias for `to`. If used with `to`, `href` will be ignored
18
+ */
19
+ href?: NuxtLinkProps['to'];
20
+ /**
21
+ * Forces the link to be considered as external (true) or internal (false). This is helpful to handle edge-cases
22
+ */
23
+ external?: boolean;
24
+ /**
25
+ * Where to display the linked URL, as the name for a browsing context.
26
+ */
27
+ target?: '_blank' | '_parent' | '_self' | '_top' | (string & {}) | null;
28
+ /**
29
+ * A rel attribute value to apply on the link. Defaults to "noopener noreferrer" for external links.
30
+ */
31
+ rel?: 'noopener' | 'noreferrer' | 'nofollow' | 'sponsored' | 'ugc' | (string & {}) | null;
32
+ /**
33
+ * If set to true, no rel attribute will be added to the link
34
+ */
35
+ noRel?: boolean;
36
+ /**
37
+ * A class to apply to links that have been prefetched.
38
+ */
39
+ prefetchedClass?: string;
40
+ /**
41
+ * When enabled will prefetch middleware, layouts and payloads of links in the viewport.
42
+ */
43
+ prefetch?: boolean;
44
+ /**
45
+ * Allows controlling when to prefetch links. By default, prefetch is triggered only on visibility.
46
+ */
47
+ prefetchOn?: 'visibility' | 'interaction' | Partial<{
48
+ visibility: boolean;
49
+ interaction: boolean;
50
+ }>;
51
+ /**
52
+ * Escape hatch to disable `prefetch` attribute.
53
+ */
54
+ noPrefetch?: boolean;
55
+ }
56
+ export interface LinkProps extends Omit<ComponentAttrs<typeof link>, 'ui'>, NuxtLinkProps {
57
+ /**
58
+ * The element or component this component should render as when not a link.
59
+ * @default "button"
60
+ */
61
+ as?: PrimitiveProps['as'];
62
+ /**
63
+ * The type of the button when not a link.
64
+ * @default "button"
65
+ */
66
+ type?: ButtonHTMLAttributes['type'];
67
+ label?: string;
68
+ disabled?: boolean;
69
+ /** Force the link to be active independent of the current route. */
70
+ active?: boolean;
71
+ /** Will only be active if the current route is an exact match. */
72
+ exact?: boolean;
73
+ /** Will only be active if the current route query is an exact match. */
74
+ exactQuery?: boolean | 'partial';
75
+ /** Will only be active if the current route hash is an exact match. */
76
+ exactHash?: boolean;
77
+ /** The class to apply when the link is inactive. */
78
+ inactiveClass?: string;
79
+ /** The class to apply when the link is disabled. */
80
+ disableClass?: string;
81
+ custom?: boolean;
82
+ underline?: boolean;
83
+ /** When `true`, only styles from `class`, `ui.active`, and `ui.inactive` will be applied. */
84
+ raw?: boolean;
85
+ }
86
+ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<LinkProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<LinkProps> & Readonly<{}>, {
87
+ type: "button" | "submit" | "reset";
88
+ as: import("reka-ui").AsTag | import("vue").Component;
89
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, LinkSlots>;
90
+ export default _default;
91
+ type __VLS_WithSlots<T, S> = T & {
92
+ new (): {
93
+ $slots: S;
94
+ };
95
+ };