@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.
- package/README.md +2 -5
- package/dist/module.json +3 -3
- package/dist/module.mjs +1 -1
- package/dist/module.mjs.map +1 -1
- package/dist/runtime/app/injections.d.ts +9323 -3
- package/dist/runtime/app/injections.js +35 -0
- package/dist/runtime/components/Accordion.vue +36 -69
- package/dist/runtime/components/Accordion.vue.d.ts +52 -0
- package/dist/runtime/components/Alert.vue +37 -75
- package/dist/runtime/components/Alert.vue.d.ts +59 -0
- package/dist/runtime/components/App.vue +25 -40
- package/dist/runtime/components/App.vue.d.ts +24 -0
- package/dist/runtime/components/Avatar.vue +31 -51
- package/dist/runtime/components/Avatar.vue.d.ts +25 -0
- package/dist/runtime/components/AvatarGroup.vue +38 -69
- package/dist/runtime/components/AvatarGroup.vue.d.ts +27 -0
- package/dist/runtime/components/Badge.vue +25 -51
- package/dist/runtime/components/Badge.vue.d.ts +44 -0
- package/dist/runtime/components/Breadcrumb.vue +35 -77
- package/dist/runtime/components/Breadcrumb.vue.d.ts +52 -0
- package/dist/runtime/components/Button.vue +62 -51
- package/dist/runtime/components/Button.vue.d.ts +29 -0
- package/dist/runtime/components/ButtonGroup.vue +17 -37
- package/dist/runtime/components/ButtonGroup.vue.d.ts +26 -0
- package/dist/runtime/components/Calendar.vue +75 -101
- package/dist/runtime/components/Calendar.vue.d.ts +75 -0
- package/dist/runtime/components/Card.vue +25 -42
- package/dist/runtime/components/Card.vue.d.ts +30 -0
- package/dist/runtime/components/Carousel.vue +118 -223
- package/dist/runtime/components/Carousel.vue.d.ts +104 -0
- package/dist/runtime/components/Checkbox.vue +49 -71
- package/dist/runtime/components/Checkbox.vue.d.ts +56 -0
- package/dist/runtime/components/Chip.vue +31 -48
- package/dist/runtime/components/Chip.vue.d.ts +30 -0
- package/dist/runtime/components/Collapsible.vue +22 -30
- package/dist/runtime/components/Collapsible.vue.d.ts +26 -0
- package/dist/runtime/components/Drawer.vue +52 -102
- package/dist/runtime/components/Drawer.vue.d.ts +80 -0
- package/dist/runtime/components/DropdownMenu.vue +65 -0
- package/dist/runtime/components/DropdownMenu.vue.d.ts +99 -0
- package/dist/runtime/components/DropdownMenuContent.vue +192 -0
- package/dist/runtime/components/DropdownMenuContent.vue.d.ts +39 -0
- package/dist/runtime/components/Form.vue +197 -0
- package/dist/runtime/components/Form.vue.d.ts +78 -0
- package/dist/runtime/components/FormItem.vue +90 -0
- package/dist/runtime/components/FormItem.vue.d.ts +60 -0
- package/dist/runtime/components/Input.vue +93 -115
- package/dist/runtime/components/Input.vue.d.ts +64 -0
- package/dist/runtime/components/InputNumber.vue +81 -116
- package/dist/runtime/components/InputNumber.vue.d.ts +245 -0
- package/dist/runtime/components/Kbd.vue +18 -39
- package/dist/runtime/components/Kbd.vue.d.ts +28 -0
- package/dist/runtime/components/Link.vue +170 -244
- package/dist/runtime/components/Link.vue.d.ts +95 -0
- package/dist/runtime/components/LinkBase.vue +36 -54
- package/dist/runtime/components/LinkBase.vue.d.ts +28 -0
- package/dist/runtime/components/Modal.vue +50 -85
- package/dist/runtime/components/Modal.vue.d.ts +66 -0
- package/dist/runtime/components/OverlayProvider.vue +10 -14
- package/dist/runtime/components/OverlayProvider.vue.d.ts +2 -0
- package/dist/runtime/components/Pagination.vue +55 -121
- package/dist/runtime/components/Pagination.vue.d.ts +93 -0
- package/dist/runtime/components/PinInput.vue +57 -57
- package/dist/runtime/components/PinInput.vue.d.ts +35 -0
- package/dist/runtime/components/Popover.vue +39 -68
- package/dist/runtime/components/Popover.vue.d.ts +45 -0
- package/dist/runtime/components/Progress.vue +68 -120
- package/dist/runtime/components/Progress.vue.d.ts +54 -0
- package/dist/runtime/components/RadioGroup.vue +75 -129
- package/dist/runtime/components/RadioGroup.vue.d.ts +74 -0
- package/dist/runtime/components/ScrollArea.vue +31 -31
- package/dist/runtime/components/ScrollArea.vue.d.ts +17 -0
- package/dist/runtime/components/Select.vue +119 -199
- package/dist/runtime/components/Select.vue.d.ts +119 -0
- package/dist/runtime/components/Separator.vue +26 -44
- package/dist/runtime/components/Separator.vue.d.ts +27 -0
- package/dist/runtime/components/Skeleton.vue +12 -21
- package/dist/runtime/components/Skeleton.vue.d.ts +19 -0
- package/dist/runtime/components/Slider.vue +54 -71
- package/dist/runtime/components/Slider.vue.d.ts +36 -0
- package/dist/runtime/components/Switch.vue +54 -68
- package/dist/runtime/components/Switch.vue.d.ts +49 -0
- package/dist/runtime/components/Table.vue +113 -186
- package/dist/runtime/components/Table.vue.d.ts +148 -0
- package/dist/runtime/components/Tabs.vue +35 -79
- package/dist/runtime/components/Tabs.vue.d.ts +65 -0
- package/dist/runtime/components/Textarea.vue +82 -123
- package/dist/runtime/components/Textarea.vue.d.ts +60 -0
- package/dist/runtime/components/Toast.vue +51 -76
- package/dist/runtime/components/Toast.vue.d.ts +131 -0
- package/dist/runtime/components/ToastProvider.vue +65 -101
- package/dist/runtime/components/ToastProvider.vue.d.ts +38 -0
- package/dist/runtime/components/Tooltip.vue +36 -47
- package/dist/runtime/components/Tooltip.vue.d.ts +31 -0
- package/dist/runtime/composables/useAvatarGroup.d.ts +1 -1
- package/dist/runtime/composables/useButtonGroup.d.ts +2 -2
- package/dist/runtime/composables/useFormItem.d.ts +27 -0
- package/dist/runtime/composables/useFormItem.js +64 -0
- package/dist/runtime/composables/useKbd.d.ts +1 -1
- package/dist/runtime/composables/useLocale.d.ts +3 -3
- package/dist/runtime/composables/useTheme.d.ts +1 -1
- package/dist/runtime/composables/useTheme.js +2 -1
- package/dist/runtime/composables/useToast.d.ts +1 -1
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.js +3 -0
- package/dist/runtime/locale/en.d.ts +1 -1
- package/dist/runtime/locale/zh-tw.d.ts +1 -1
- package/dist/runtime/theme/accordion.d.ts +45 -51
- package/dist/runtime/theme/accordion.js +1 -1
- package/dist/runtime/theme/alert.d.ts +115 -121
- package/dist/runtime/theme/alert.js +1 -1
- package/dist/runtime/theme/app.d.ts +1 -0
- package/dist/runtime/theme/app.js +2 -1
- package/dist/runtime/theme/avatar-group.d.ts +42 -48
- package/dist/runtime/theme/avatar-group.js +1 -1
- package/dist/runtime/theme/avatar.d.ts +46 -52
- package/dist/runtime/theme/avatar.js +1 -1
- package/dist/runtime/theme/badge.d.ts +63 -93
- package/dist/runtime/theme/badge.js +1 -1
- package/dist/runtime/theme/breadcrumb.d.ts +52 -58
- package/dist/runtime/theme/breadcrumb.js +1 -1
- package/dist/runtime/theme/button-group.d.ts +36 -42
- package/dist/runtime/theme/button.d.ts +165 -117
- package/dist/runtime/theme/button.js +1 -1
- package/dist/runtime/theme/calendar.d.ts +52 -50
- package/dist/runtime/theme/calendar.js +20 -3
- package/dist/runtime/theme/card.d.ts +52 -58
- package/dist/runtime/theme/card.js +1 -1
- package/dist/runtime/theme/carousel.d.ts +98 -104
- package/dist/runtime/theme/carousel.js +1 -1
- package/dist/runtime/theme/checkbox.d.ts +77 -83
- package/dist/runtime/theme/checkbox.js +1 -1
- package/dist/runtime/theme/chip.d.ts +50 -89
- package/dist/runtime/theme/chip.js +1 -1
- package/dist/runtime/theme/collapsible.d.ts +29 -35
- package/dist/runtime/theme/collapsible.js +1 -1
- package/dist/runtime/theme/drawer.d.ts +131 -102
- package/dist/runtime/theme/drawer.js +1 -1
- package/dist/runtime/theme/dropdown-menu.d.ts +65 -0
- package/dist/runtime/theme/dropdown-menu.js +83 -0
- package/dist/runtime/theme/form-item.d.ts +70 -0
- package/dist/runtime/theme/form-item.js +34 -0
- package/dist/runtime/theme/form.d.ts +2 -0
- package/dist/runtime/theme/form.js +7 -0
- package/dist/runtime/theme/index.d.ts +3 -0
- package/dist/runtime/theme/index.js +3 -0
- package/dist/runtime/theme/input-number.d.ts +100 -126
- package/dist/runtime/theme/input-number.js +1 -1
- package/dist/runtime/theme/input.d.ts +153 -131
- package/dist/runtime/theme/input.js +3 -3
- package/dist/runtime/theme/kbd.d.ts +30 -36
- package/dist/runtime/theme/link.d.ts +37 -43
- package/dist/runtime/theme/modal.d.ts +35 -69
- package/dist/runtime/theme/modal.js +1 -1
- package/dist/runtime/theme/pagination.d.ts +71 -77
- package/dist/runtime/theme/pagination.js +1 -1
- package/dist/runtime/theme/pinInput.d.ts +82 -88
- package/dist/runtime/theme/pinInput.js +2 -2
- package/dist/runtime/theme/popover.d.ts +29 -35
- package/dist/runtime/theme/popover.js +1 -1
- package/dist/runtime/theme/progress.d.ts +167 -109
- package/dist/runtime/theme/progress.js +1 -1
- package/dist/runtime/theme/radio-group.d.ts +99 -105
- package/dist/runtime/theme/radio-group.js +1 -1
- package/dist/runtime/theme/scroll-area.d.ts +62 -68
- package/dist/runtime/theme/scroll-area.js +1 -1
- package/dist/runtime/theme/select.d.ts +168 -158
- package/dist/runtime/theme/select.js +3 -2
- package/dist/runtime/theme/separator.d.ts +64 -85
- package/dist/runtime/theme/separator.js +1 -1
- package/dist/runtime/theme/skeleton.d.ts +1 -7
- package/dist/runtime/theme/slider.d.ts +62 -68
- package/dist/runtime/theme/slider.js +1 -1
- package/dist/runtime/theme/switch.d.ts +111 -117
- package/dist/runtime/theme/switch.js +1 -1
- package/dist/runtime/theme/table.d.ts +75 -78
- package/dist/runtime/theme/table.js +3 -2
- package/dist/runtime/theme/tabs.d.ts +116 -139
- package/dist/runtime/theme/tabs.js +1 -1
- package/dist/runtime/theme/textarea.d.ts +78 -90
- package/dist/runtime/theme/textarea.js +2 -2
- package/dist/runtime/theme/toast-provider.d.ts +110 -131
- package/dist/runtime/theme/toast-provider.js +1 -1
- package/dist/runtime/theme/toast.d.ts +74 -80
- package/dist/runtime/theme/toast.js +1 -1
- package/dist/runtime/theme/tooltip.d.ts +35 -41
- package/dist/runtime/theme/tooltip.js +1 -1
- package/dist/runtime/types/components.d.ts +3 -0
- package/dist/runtime/types/form.d.ts +45 -0
- package/dist/runtime/types/form.js +0 -0
- package/dist/runtime/types/index.d.ts +5 -2
- package/dist/runtime/types/index.js +1 -0
- package/dist/runtime/types/utils.d.ts +37 -16
- package/dist/runtime/utils/extend-theme.js +15 -4
- package/dist/runtime/utils/form.d.ts +5 -0
- package/dist/runtime/utils/form.js +24 -0
- package/dist/runtime/utils/index.d.ts +2 -0
- package/dist/runtime/utils/index.js +4 -0
- package/dist/runtime/utils/link.d.ts +4 -28
- package/dist/runtime/utils/link.js +10 -3
- package/dist/runtime/utils/styler.d.ts +2 -2
- package/dist/runtime/utils/styler.js +2 -2
- package/dist/shared/ui.D1BTWZFB.mjs +5 -0
- package/dist/shared/ui.D1BTWZFB.mjs.map +1 -0
- package/dist/types.d.mts +1 -1
- package/dist/unocss.mjs +7 -6
- package/dist/unocss.mjs.map +1 -1
- package/dist/unplugin.mjs +1 -1
- package/dist/unplugin.mjs.map +1 -1
- package/dist/vite.mjs +1 -1
- package/package.json +78 -74
- package/dist/module.cjs +0 -5
- package/dist/shared/ui.1a1f119c.mjs +0 -5
- package/dist/shared/ui.1a1f119c.mjs.map +0 -1
- package/dist/types.d.ts +0 -1
|
@@ -1,224 +1,140 @@
|
|
|
1
|
-
<script
|
|
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
|
|
91
|
-
import { reactiveOmit } from
|
|
92
|
-
import { diff, isEqual } from
|
|
93
|
-
import { useForwardProps } from
|
|
94
|
-
import { hasProtocol } from
|
|
95
|
-
import { computed, getCurrentInstance, resolveComponent } from
|
|
96
|
-
import { useNuxtApp, useRoute } from
|
|
97
|
-
import { useTheme } from
|
|
98
|
-
import LinkBase from
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
type:
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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 !!
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
const
|
|
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(
|
|
119
|
-
RouterLink: hasRouter.value ? resolveComponent(
|
|
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
|
-
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
...
|
|
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 ===
|
|
154
|
-
filtered.add(q.key)
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
-
|
|
172
|
-
})
|
|
173
|
-
|
|
174
|
-
function isLinkActive({ route: linkRoute, isActive, isExactActive }
|
|
175
|
-
if (props.active !==
|
|
176
|
-
return props.active
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
|
|
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
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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 ?
|
|
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
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
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
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
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
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
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
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
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
|
+
};
|