@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.
- package/README.md +2 -2
- 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 +388 -364
- package/dist/runtime/components/Accordion.vue +38 -67
- 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 +36 -74
- 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 -110
- 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 -225
- package/dist/runtime/components/Carousel.vue.d.ts +104 -0
- package/dist/runtime/components/Checkbox.vue +46 -73
- 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 +51 -101
- package/dist/runtime/components/Drawer.vue.d.ts +80 -0
- package/dist/runtime/components/DropdownMenu.vue +37 -115
- package/dist/runtime/components/DropdownMenu.vue.d.ts +99 -0
- package/dist/runtime/components/DropdownMenuContent.vue +81 -77
- package/dist/runtime/components/DropdownMenuContent.vue.d.ts +39 -0
- package/dist/runtime/components/Form.vue +140 -254
- package/dist/runtime/components/Form.vue.d.ts +78 -0
- package/dist/runtime/components/FormItem.vue +50 -89
- package/dist/runtime/components/FormItem.vue.d.ts +60 -0
- package/dist/runtime/components/Input.vue +79 -115
- package/dist/runtime/components/Input.vue.d.ts +64 -0
- package/dist/runtime/components/InputNumber.vue +74 -117
- 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 +168 -257
- 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 +49 -84
- 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 +49 -58
- 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 +67 -125
- 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 +114 -204
- 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 +52 -74
- package/dist/runtime/components/Slider.vue.d.ts +36 -0
- package/dist/runtime/components/Switch.vue +51 -71
- package/dist/runtime/components/Switch.vue.d.ts +49 -0
- package/dist/runtime/components/Table.vue +108 -194
- package/dist/runtime/components/Table.vue.d.ts +148 -0
- package/dist/runtime/components/Tabs.vue +36 -81
- package/dist/runtime/components/Tabs.vue.d.ts +65 -0
- package/dist/runtime/components/Textarea.vue +77 -124
- package/dist/runtime/components/Textarea.vue.d.ts +60 -0
- package/dist/runtime/components/Toast.vue +47 -75
- 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 +2 -2
- 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/useToast.d.ts +1 -1
- 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/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 +60 -66
- 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 +162 -168
- 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 -56
- 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 +120 -126
- package/dist/runtime/theme/drawer.js +1 -1
- package/dist/runtime/theme/dropdown-menu.d.ts +55 -61
- package/dist/runtime/theme/dropdown-menu.js +1 -1
- package/dist/runtime/theme/form-item.d.ts +63 -69
- package/dist/runtime/theme/form-item.js +1 -1
- package/dist/runtime/theme/form.d.ts +1 -7
- package/dist/runtime/theme/input-number.d.ts +98 -104
- package/dist/runtime/theme/input-number.js +1 -1
- package/dist/runtime/theme/input.d.ts +153 -159
- package/dist/runtime/theme/input.js +1 -1
- 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 +36 -42
- 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 +80 -86
- package/dist/runtime/theme/pinInput.js +1 -1
- package/dist/runtime/theme/popover.d.ts +29 -35
- package/dist/runtime/theme/popover.js +1 -1
- package/dist/runtime/theme/progress.d.ts +163 -169
- 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 +165 -171
- package/dist/runtime/theme/select.js +1 -1
- package/dist/runtime/theme/separator.d.ts +62 -68
- 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 -81
- package/dist/runtime/theme/table.js +1 -1
- package/dist/runtime/theme/tabs.d.ts +114 -120
- package/dist/runtime/theme/tabs.js +1 -1
- package/dist/runtime/theme/textarea.d.ts +76 -82
- package/dist/runtime/theme/textarea.js +1 -1
- package/dist/runtime/theme/toast-provider.d.ts +106 -112
- 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/utils.d.ts +5 -5
- package/dist/runtime/utils/link.d.ts +3 -5
- 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 +5 -4
- 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 +77 -75
- package/dist/module.cjs +0 -5
- package/dist/shared/ui.3e7fad19.mjs +0 -5
- package/dist/shared/ui.3e7fad19.mjs.map +0 -1
- package/dist/types.d.ts +0 -1
|
@@ -1,230 +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()
|
|
61
|
+
return useRoute();
|
|
62
|
+
} catch {
|
|
63
|
+
return null;
|
|
129
64
|
}
|
|
130
|
-
|
|
131
|
-
return null
|
|
132
|
-
}
|
|
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
|
-
|
|
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
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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 ?
|
|
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
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
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
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
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
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
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
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
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
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
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
|
+
};
|