@byyuurin/ui 0.0.10 → 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 (194) hide show
  1. package/README.md +2 -2
  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 +388 -364
  6. package/dist/runtime/components/Accordion.vue +38 -67
  7. package/dist/runtime/components/Accordion.vue.d.ts +52 -0
  8. package/dist/runtime/components/Alert.vue +37 -75
  9. package/dist/runtime/components/Alert.vue.d.ts +59 -0
  10. package/dist/runtime/components/App.vue +25 -40
  11. package/dist/runtime/components/App.vue.d.ts +24 -0
  12. package/dist/runtime/components/Avatar.vue +31 -51
  13. package/dist/runtime/components/Avatar.vue.d.ts +25 -0
  14. package/dist/runtime/components/AvatarGroup.vue +38 -69
  15. package/dist/runtime/components/AvatarGroup.vue.d.ts +27 -0
  16. package/dist/runtime/components/Badge.vue +25 -51
  17. package/dist/runtime/components/Badge.vue.d.ts +44 -0
  18. package/dist/runtime/components/Breadcrumb.vue +36 -74
  19. package/dist/runtime/components/Breadcrumb.vue.d.ts +52 -0
  20. package/dist/runtime/components/Button.vue +62 -51
  21. package/dist/runtime/components/Button.vue.d.ts +29 -0
  22. package/dist/runtime/components/ButtonGroup.vue +17 -37
  23. package/dist/runtime/components/ButtonGroup.vue.d.ts +26 -0
  24. package/dist/runtime/components/Calendar.vue +75 -110
  25. package/dist/runtime/components/Calendar.vue.d.ts +75 -0
  26. package/dist/runtime/components/Card.vue +25 -42
  27. package/dist/runtime/components/Card.vue.d.ts +30 -0
  28. package/dist/runtime/components/Carousel.vue +118 -225
  29. package/dist/runtime/components/Carousel.vue.d.ts +104 -0
  30. package/dist/runtime/components/Checkbox.vue +46 -73
  31. package/dist/runtime/components/Checkbox.vue.d.ts +56 -0
  32. package/dist/runtime/components/Chip.vue +31 -48
  33. package/dist/runtime/components/Chip.vue.d.ts +30 -0
  34. package/dist/runtime/components/Collapsible.vue +22 -30
  35. package/dist/runtime/components/Collapsible.vue.d.ts +26 -0
  36. package/dist/runtime/components/Drawer.vue +51 -101
  37. package/dist/runtime/components/Drawer.vue.d.ts +80 -0
  38. package/dist/runtime/components/DropdownMenu.vue +37 -115
  39. package/dist/runtime/components/DropdownMenu.vue.d.ts +99 -0
  40. package/dist/runtime/components/DropdownMenuContent.vue +81 -77
  41. package/dist/runtime/components/DropdownMenuContent.vue.d.ts +39 -0
  42. package/dist/runtime/components/Form.vue +140 -254
  43. package/dist/runtime/components/Form.vue.d.ts +78 -0
  44. package/dist/runtime/components/FormItem.vue +50 -89
  45. package/dist/runtime/components/FormItem.vue.d.ts +60 -0
  46. package/dist/runtime/components/Input.vue +79 -115
  47. package/dist/runtime/components/Input.vue.d.ts +64 -0
  48. package/dist/runtime/components/InputNumber.vue +74 -117
  49. package/dist/runtime/components/InputNumber.vue.d.ts +245 -0
  50. package/dist/runtime/components/Kbd.vue +18 -39
  51. package/dist/runtime/components/Kbd.vue.d.ts +28 -0
  52. package/dist/runtime/components/Link.vue +168 -257
  53. package/dist/runtime/components/Link.vue.d.ts +95 -0
  54. package/dist/runtime/components/LinkBase.vue +36 -54
  55. package/dist/runtime/components/LinkBase.vue.d.ts +28 -0
  56. package/dist/runtime/components/Modal.vue +49 -84
  57. package/dist/runtime/components/Modal.vue.d.ts +66 -0
  58. package/dist/runtime/components/OverlayProvider.vue +10 -14
  59. package/dist/runtime/components/OverlayProvider.vue.d.ts +2 -0
  60. package/dist/runtime/components/Pagination.vue +55 -121
  61. package/dist/runtime/components/Pagination.vue.d.ts +93 -0
  62. package/dist/runtime/components/PinInput.vue +49 -58
  63. package/dist/runtime/components/PinInput.vue.d.ts +35 -0
  64. package/dist/runtime/components/Popover.vue +39 -68
  65. package/dist/runtime/components/Popover.vue.d.ts +45 -0
  66. package/dist/runtime/components/Progress.vue +68 -120
  67. package/dist/runtime/components/Progress.vue.d.ts +54 -0
  68. package/dist/runtime/components/RadioGroup.vue +67 -125
  69. package/dist/runtime/components/RadioGroup.vue.d.ts +74 -0
  70. package/dist/runtime/components/ScrollArea.vue +31 -31
  71. package/dist/runtime/components/ScrollArea.vue.d.ts +17 -0
  72. package/dist/runtime/components/Select.vue +114 -204
  73. package/dist/runtime/components/Select.vue.d.ts +119 -0
  74. package/dist/runtime/components/Separator.vue +26 -44
  75. package/dist/runtime/components/Separator.vue.d.ts +27 -0
  76. package/dist/runtime/components/Skeleton.vue +12 -21
  77. package/dist/runtime/components/Skeleton.vue.d.ts +19 -0
  78. package/dist/runtime/components/Slider.vue +52 -74
  79. package/dist/runtime/components/Slider.vue.d.ts +36 -0
  80. package/dist/runtime/components/Switch.vue +51 -71
  81. package/dist/runtime/components/Switch.vue.d.ts +49 -0
  82. package/dist/runtime/components/Table.vue +108 -194
  83. package/dist/runtime/components/Table.vue.d.ts +148 -0
  84. package/dist/runtime/components/Tabs.vue +36 -81
  85. package/dist/runtime/components/Tabs.vue.d.ts +65 -0
  86. package/dist/runtime/components/Textarea.vue +77 -124
  87. package/dist/runtime/components/Textarea.vue.d.ts +60 -0
  88. package/dist/runtime/components/Toast.vue +47 -75
  89. package/dist/runtime/components/Toast.vue.d.ts +131 -0
  90. package/dist/runtime/components/ToastProvider.vue +65 -101
  91. package/dist/runtime/components/ToastProvider.vue.d.ts +38 -0
  92. package/dist/runtime/components/Tooltip.vue +36 -47
  93. package/dist/runtime/components/Tooltip.vue.d.ts +31 -0
  94. package/dist/runtime/composables/useAvatarGroup.d.ts +1 -1
  95. package/dist/runtime/composables/useButtonGroup.d.ts +2 -2
  96. package/dist/runtime/composables/useFormItem.d.ts +2 -2
  97. package/dist/runtime/composables/useKbd.d.ts +1 -1
  98. package/dist/runtime/composables/useLocale.d.ts +3 -3
  99. package/dist/runtime/composables/useTheme.d.ts +1 -1
  100. package/dist/runtime/composables/useToast.d.ts +1 -1
  101. package/dist/runtime/locale/en.d.ts +1 -1
  102. package/dist/runtime/locale/zh-tw.d.ts +1 -1
  103. package/dist/runtime/theme/accordion.d.ts +45 -51
  104. package/dist/runtime/theme/accordion.js +1 -1
  105. package/dist/runtime/theme/alert.d.ts +115 -121
  106. package/dist/runtime/theme/alert.js +1 -1
  107. package/dist/runtime/theme/avatar-group.d.ts +42 -48
  108. package/dist/runtime/theme/avatar-group.js +1 -1
  109. package/dist/runtime/theme/avatar.d.ts +46 -52
  110. package/dist/runtime/theme/avatar.js +1 -1
  111. package/dist/runtime/theme/badge.d.ts +60 -66
  112. package/dist/runtime/theme/badge.js +1 -1
  113. package/dist/runtime/theme/breadcrumb.d.ts +52 -58
  114. package/dist/runtime/theme/breadcrumb.js +1 -1
  115. package/dist/runtime/theme/button-group.d.ts +36 -42
  116. package/dist/runtime/theme/button.d.ts +162 -168
  117. package/dist/runtime/theme/button.js +1 -1
  118. package/dist/runtime/theme/calendar.d.ts +52 -50
  119. package/dist/runtime/theme/calendar.js +20 -3
  120. package/dist/runtime/theme/card.d.ts +52 -58
  121. package/dist/runtime/theme/card.js +1 -1
  122. package/dist/runtime/theme/carousel.d.ts +98 -104
  123. package/dist/runtime/theme/carousel.js +1 -1
  124. package/dist/runtime/theme/checkbox.d.ts +77 -83
  125. package/dist/runtime/theme/checkbox.js +1 -1
  126. package/dist/runtime/theme/chip.d.ts +50 -56
  127. package/dist/runtime/theme/chip.js +1 -1
  128. package/dist/runtime/theme/collapsible.d.ts +29 -35
  129. package/dist/runtime/theme/collapsible.js +1 -1
  130. package/dist/runtime/theme/drawer.d.ts +120 -126
  131. package/dist/runtime/theme/drawer.js +1 -1
  132. package/dist/runtime/theme/dropdown-menu.d.ts +55 -61
  133. package/dist/runtime/theme/dropdown-menu.js +1 -1
  134. package/dist/runtime/theme/form-item.d.ts +63 -69
  135. package/dist/runtime/theme/form-item.js +1 -1
  136. package/dist/runtime/theme/form.d.ts +1 -7
  137. package/dist/runtime/theme/input-number.d.ts +98 -104
  138. package/dist/runtime/theme/input-number.js +1 -1
  139. package/dist/runtime/theme/input.d.ts +153 -159
  140. package/dist/runtime/theme/input.js +1 -1
  141. package/dist/runtime/theme/kbd.d.ts +30 -36
  142. package/dist/runtime/theme/link.d.ts +37 -43
  143. package/dist/runtime/theme/modal.d.ts +36 -42
  144. package/dist/runtime/theme/modal.js +1 -1
  145. package/dist/runtime/theme/pagination.d.ts +71 -77
  146. package/dist/runtime/theme/pagination.js +1 -1
  147. package/dist/runtime/theme/pinInput.d.ts +80 -86
  148. package/dist/runtime/theme/pinInput.js +1 -1
  149. package/dist/runtime/theme/popover.d.ts +29 -35
  150. package/dist/runtime/theme/popover.js +1 -1
  151. package/dist/runtime/theme/progress.d.ts +163 -169
  152. package/dist/runtime/theme/progress.js +1 -1
  153. package/dist/runtime/theme/radio-group.d.ts +99 -105
  154. package/dist/runtime/theme/radio-group.js +1 -1
  155. package/dist/runtime/theme/scroll-area.d.ts +62 -68
  156. package/dist/runtime/theme/scroll-area.js +1 -1
  157. package/dist/runtime/theme/select.d.ts +165 -171
  158. package/dist/runtime/theme/select.js +1 -1
  159. package/dist/runtime/theme/separator.d.ts +62 -68
  160. package/dist/runtime/theme/separator.js +1 -1
  161. package/dist/runtime/theme/skeleton.d.ts +1 -7
  162. package/dist/runtime/theme/slider.d.ts +62 -68
  163. package/dist/runtime/theme/slider.js +1 -1
  164. package/dist/runtime/theme/switch.d.ts +111 -117
  165. package/dist/runtime/theme/switch.js +1 -1
  166. package/dist/runtime/theme/table.d.ts +75 -81
  167. package/dist/runtime/theme/table.js +1 -1
  168. package/dist/runtime/theme/tabs.d.ts +114 -120
  169. package/dist/runtime/theme/tabs.js +1 -1
  170. package/dist/runtime/theme/textarea.d.ts +76 -82
  171. package/dist/runtime/theme/textarea.js +1 -1
  172. package/dist/runtime/theme/toast-provider.d.ts +106 -112
  173. package/dist/runtime/theme/toast-provider.js +1 -1
  174. package/dist/runtime/theme/toast.d.ts +74 -80
  175. package/dist/runtime/theme/toast.js +1 -1
  176. package/dist/runtime/theme/tooltip.d.ts +35 -41
  177. package/dist/runtime/theme/tooltip.js +1 -1
  178. package/dist/runtime/types/utils.d.ts +5 -5
  179. package/dist/runtime/utils/link.d.ts +3 -5
  180. package/dist/runtime/utils/styler.d.ts +2 -2
  181. package/dist/runtime/utils/styler.js +2 -2
  182. package/dist/shared/ui.D1BTWZFB.mjs +5 -0
  183. package/dist/shared/ui.D1BTWZFB.mjs.map +1 -0
  184. package/dist/types.d.mts +1 -1
  185. package/dist/unocss.mjs +5 -4
  186. package/dist/unocss.mjs.map +1 -1
  187. package/dist/unplugin.mjs +1 -1
  188. package/dist/unplugin.mjs.map +1 -1
  189. package/dist/vite.mjs +1 -1
  190. package/package.json +77 -75
  191. package/dist/module.cjs +0 -5
  192. package/dist/shared/ui.3e7fad19.mjs +0 -5
  193. package/dist/shared/ui.3e7fad19.mjs.map +0 -1
  194. package/dist/types.d.ts +0 -1
@@ -1,230 +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()
61
+ return useRoute();
62
+ } catch {
63
+ return null;
129
64
  }
130
- catch {
131
- return null
132
- }
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
- if (props.target === '_blank')
172
- return true
173
-
174
- return typeof to === 'string' && hasProtocol(to, { acceptRelative: true })
175
- })
176
-
177
- function isLinkActive({ route: linkRoute, isActive, isExactActive }: any) {
178
- if (props.active !== undefined)
179
- return props.active
180
-
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;
181
102
  if (isExternalLink.value || !props.to)
182
- return false
183
-
184
- if (props.exactQuery === 'partial') {
103
+ return false;
104
+ if (props.exactQuery === "partial") {
185
105
  if (!isPartiallyEqual(linkRoute?.query, route.value?.query))
186
- return false
106
+ return false;
107
+ } else if (props.exactQuery === true && !isEqual(linkRoute?.query, route.value?.query)) {
108
+ return false;
187
109
  }
188
- else if (props.exactQuery === true && !isEqual(linkRoute?.query, route.value?.query)) {
189
- return false
190
- }
191
-
192
110
  if (props.exactHash && linkRoute?.hash !== route.value?.hash)
193
- return false
194
-
111
+ return false;
195
112
  if (props.exact && isExactActive)
196
- return true
197
-
113
+ return true;
198
114
  if (!props.exact && isActive)
199
- return true
200
-
201
- return false
115
+ return true;
116
+ return false;
202
117
  }
203
-
204
- const { theme, createStyler } = useTheme()
205
-
206
- function resolveLinkClass({ route, isActive, isExactActive }: any = {}) {
207
- const { link } = theme.value
208
- const active = isLinkActive({ route, isActive, isExactActive })
209
-
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 });
210
122
  if (props.raw)
211
- return [props.class, active ? props.activeClass : props.inactiveClass]
212
-
123
+ return [props.class, active ? props.activeClass : props.inactiveClass];
213
124
  const styler = createStyler({
214
125
  ...link,
215
126
  variants: {
216
127
  ...link.variants,
217
128
  active: {
218
129
  true: [link.variants.active.true, props.activeClass],
219
- false: [link.variants.active.false, props.inactiveClass],
130
+ false: [link.variants.active.false, props.inactiveClass]
220
131
  },
221
132
  disabled: {
222
- true: [link.variants.disabled.true, props.disableClass],
223
- },
224
- },
225
- })
226
-
227
- return styler({ ...props, active })
133
+ true: [link.variants.disabled.true, props.disableClass]
134
+ }
135
+ }
136
+ });
137
+ return styler({ ...props, active }).base();
228
138
  }
229
139
  </script>
230
140
 
@@ -235,23 +145,23 @@ function resolveLinkClass({ route, isActive, isExactActive }: any = {}) {
235
145
  v-if="hasNuxtLink"
236
146
  v-slot="{ href, navigate, route: linkRoute, rel, target, isExternal, isActive, isExactActive }"
237
147
  v-bind="linkProps"
238
- :href="to ? undefined : href"
148
+ :href="to ? void 0 : href"
239
149
  custom
240
150
  >
241
151
  <template v-if="custom">
242
152
  <slot
243
153
  v-bind="{
244
- ...$attrs,
245
- as,
246
- type,
247
- disabled,
248
- href,
249
- navigate,
250
- rel,
251
- target,
252
- isExternal,
253
- active: isLinkActive({ route: linkRoute, isActive, isExactActive }),
254
- }"
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
+ }"
255
165
  >
256
166
  {{ props.label }}
257
167
  </slot>
@@ -259,17 +169,18 @@ function resolveLinkClass({ route, isActive, isExactActive }: any = {}) {
259
169
  <LinkBase
260
170
  v-else
261
171
  v-bind="{
262
- ...$attrs,
263
- as,
264
- type,
265
- disabled,
266
- href,
267
- navigate,
268
- rel,
269
- target,
270
- isExternal,
271
- }"
172
+ ...$attrs,
173
+ as,
174
+ type,
175
+ disabled,
176
+ href,
177
+ navigate,
178
+ rel,
179
+ target,
180
+ isExternal
181
+ }"
272
182
  :class="resolveLinkClass({ route: linkRoute, isActive, isExactActive })"
183
+ :data-part="$attrs['data-part'] ?? 'base'"
273
184
  >
274
185
  <slot :active="isLinkActive({ route: linkRoute, isActive, isExactActive })">
275
186
  {{ props.label }}
@@ -287,23 +198,21 @@ function resolveLinkClass({ route, isActive, isExactActive }: any = {}) {
287
198
  <template v-if="custom">
288
199
  <slot
289
200
  v-bind="{
290
- ...$attrs,
291
- ...isExternalLink
292
- ? {
293
- href: to || props.href,
294
- target: props.target,
295
- }
296
- : {
297
- href: to ? href : undefined,
298
- target: undefined,
299
- },
300
- as,
301
- type,
302
- disabled,
303
- navigate,
304
- active: isLinkActive({ route: linkRoute, isActive, isExactActive }),
305
- isExternal: isExternalLink,
306
- }"
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
+ }"
307
216
  >
308
217
  {{ props.label }}
309
218
  </slot>
@@ -311,15 +220,16 @@ function resolveLinkClass({ route, isActive, isExactActive }: any = {}) {
311
220
  <LinkBase
312
221
  v-else
313
222
  v-bind="{
314
- ...$attrs,
315
- as,
316
- type,
317
- disabled,
318
- href: to ? href : undefined,
319
- navigate,
320
- }"
223
+ ...$attrs,
224
+ as,
225
+ type,
226
+ disabled,
227
+ href: to ? href : void 0,
228
+ navigate
229
+ }"
321
230
  :is-external="isExternalLink"
322
231
  :class="resolveLinkClass({ route: linkRoute, isActive, isExactActive })"
232
+ :data-part="$attrs['data-part'] ?? 'base'"
323
233
  >
324
234
  <slot :active="isLinkActive({ route: linkRoute, isActive, isExactActive })">
325
235
  {{ props.label }}
@@ -331,14 +241,14 @@ function resolveLinkClass({ route, isActive, isExactActive }: any = {}) {
331
241
  <template v-if="props.custom">
332
242
  <slot
333
243
  v-bind="{
334
- ...$attrs,
335
- as,
336
- type,
337
- disabled,
338
- href: to || href,
339
- target: target || (isExternalLink ? '_blank' : undefined),
340
- active: false,
341
- }"
244
+ ...$attrs,
245
+ as,
246
+ type,
247
+ disabled,
248
+ href: to || href,
249
+ target: target || (isExternalLink ? '_blank' : void 0),
250
+ active: false
251
+ }"
342
252
  >
343
253
  {{ props.label }}
344
254
  </slot>
@@ -346,15 +256,16 @@ function resolveLinkClass({ route, isActive, isExactActive }: any = {}) {
346
256
  <LinkBase
347
257
  v-else
348
258
  v-bind="{
349
- ...$attrs,
350
- as,
351
- type,
352
- disabled,
353
- href: ((typeof to === 'string' ? to : href) as string),
354
- target: target || (isExternalLink ? '_blank' : undefined),
355
- }"
259
+ ...$attrs,
260
+ as,
261
+ type,
262
+ disabled,
263
+ href: typeof to === 'string' ? to : href,
264
+ target: target || (isExternalLink ? '_blank' : void 0)
265
+ }"
356
266
  :is-external="isExternalLink"
357
267
  :class="resolveLinkClass()"
268
+ :data-part="$attrs['data-part'] ?? 'base'"
358
269
  >
359
270
  <slot :active="false">
360
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
+ };