@nuxt/ui 3.0.0-alpha.12 → 3.0.0-alpha.13
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/.nuxt/ui/accordion.ts +2 -2
- package/.nuxt/ui/alert.ts +46 -36
- package/.nuxt/ui/avatar-group.ts +1 -1
- package/.nuxt/ui/avatar.ts +3 -3
- package/.nuxt/ui/badge.ts +37 -28
- package/.nuxt/ui/breadcrumb.ts +5 -5
- package/.nuxt/ui/button.ts +42 -42
- package/.nuxt/ui/calendar.ts +15 -15
- package/.nuxt/ui/card.ts +27 -1
- package/.nuxt/ui/carousel.ts +2 -2
- package/.nuxt/ui/checkbox.ts +18 -18
- package/.nuxt/ui/chip.ts +8 -8
- package/.nuxt/ui/color-picker.ts +2 -2
- package/.nuxt/ui/command-palette.ts +12 -12
- package/.nuxt/ui/container.ts +1 -1
- package/.nuxt/ui/context-menu.ts +32 -32
- package/.nuxt/ui/drawer.ts +72 -11
- package/.nuxt/ui/dropdown-menu.ts +33 -33
- package/.nuxt/ui/form-field.ts +6 -6
- package/.nuxt/ui/input-menu.ts +41 -41
- package/.nuxt/ui/input-number.ts +20 -20
- package/.nuxt/ui/input.ts +23 -23
- package/.nuxt/ui/kbd.ts +4 -4
- package/.nuxt/ui/link.ts +3 -3
- package/.nuxt/ui/modal.ts +5 -5
- package/.nuxt/ui/navigation-menu.ts +77 -78
- package/.nuxt/ui/pin-input.ts +20 -20
- package/.nuxt/ui/popover.ts +2 -2
- package/.nuxt/ui/progress.ts +17 -17
- package/.nuxt/ui/radio-group.ts +20 -20
- package/.nuxt/ui/select-menu.ts +33 -32
- package/.nuxt/ui/select.ts +31 -31
- package/.nuxt/ui/separator.ts +8 -8
- package/.nuxt/ui/skeleton.ts +1 -1
- package/.nuxt/ui/slideover.ts +4 -4
- package/.nuxt/ui/slider.ts +16 -16
- package/.nuxt/ui/stepper.ts +18 -18
- package/.nuxt/ui/switch.ts +20 -20
- package/.nuxt/ui/table.ts +16 -16
- package/.nuxt/ui/tabs.ts +33 -33
- package/.nuxt/ui/textarea.ts +23 -23
- package/.nuxt/ui/toast.ts +42 -32
- package/.nuxt/ui/toaster.ts +4 -4
- package/.nuxt/ui/tooltip.ts +2 -2
- package/.nuxt/ui.css +90 -0
- package/README.md +2 -2
- package/cli/package.json +1 -1
- package/cli/templates.mjs +1 -1
- package/dist/client/devtools/200.html +1 -1
- package/dist/client/devtools/404.html +1 -1
- package/dist/client/devtools/_nuxt/CG6Dc4jp.js +1 -0
- package/dist/client/devtools/_nuxt/{DYuJNiSW.js → DrNJgD08.js} +1 -1
- package/dist/client/devtools/_nuxt/{DLmPhbaq.js → ElqrUh1r.js} +1 -1
- package/dist/client/devtools/_nuxt/builds/latest.json +1 -1
- package/dist/client/devtools/_nuxt/builds/meta/255c8d0b-7281-4d74-b4b6-ec96e6721aa0.json +1 -0
- package/dist/client/devtools/_nuxt/entry.Hn8drx4g.css +1 -0
- package/dist/client/devtools/_nuxt/error-404.Dew7w9Ee.css +1 -0
- package/dist/client/devtools/_nuxt/error-500.Dep59i31.css +1 -0
- package/dist/client/devtools/_nuxt/mC2e7kOs.js +57 -0
- package/dist/client/devtools/index.html +1 -1
- package/dist/devtools/runtime/examples/CardExample.vue +3 -3
- package/dist/devtools/runtime/examples/CollapsibleExample.vue +1 -1
- package/dist/devtools/runtime/examples/ContainerExample.vue +1 -1
- package/dist/devtools/runtime/examples/ContextMenuExample.vue +1 -1
- package/dist/devtools/runtime/examples/PopoverExample.vue +1 -1
- package/dist/devtools/runtime/examples/TooltipExample.vue +1 -1
- package/dist/module.cjs +2 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +2 -1
- package/dist/runtime/components/Alert.vue +13 -10
- package/dist/runtime/components/App.vue +3 -3
- package/dist/runtime/components/Avatar.vue +1 -1
- package/dist/runtime/components/Badge.vue +5 -1
- package/dist/runtime/components/Calendar.vue +2 -1
- package/dist/runtime/components/Card.vue +6 -2
- package/dist/runtime/components/CommandPalette.vue +46 -39
- package/dist/runtime/components/ContextMenu.vue +8 -0
- package/dist/runtime/components/ContextMenuContent.vue +4 -2
- package/dist/runtime/components/Drawer.vue +7 -1
- package/dist/runtime/components/DropdownMenu.vue +8 -0
- package/dist/runtime/components/DropdownMenuContent.vue +4 -2
- package/dist/runtime/components/InputNumber.vue +3 -2
- package/dist/runtime/components/Modal.vue +15 -1
- package/dist/runtime/components/NavigationMenu.vue +31 -11
- package/dist/runtime/components/SelectMenu.vue +62 -60
- package/dist/runtime/components/Slideover.vue +15 -1
- package/dist/runtime/components/Stepper.vue +1 -1
- package/dist/runtime/components/Table.vue +94 -16
- package/dist/runtime/components/Textarea.vue +2 -1
- package/dist/runtime/components/Toast.vue +26 -14
- package/dist/runtime/components/Toaster.vue +2 -2
- package/dist/runtime/composables/useToast.d.ts +5 -4
- package/dist/runtime/composables/useToast.js +2 -2
- package/dist/runtime/index.css +1 -1
- package/dist/runtime/locale/az.d.ts +2 -0
- package/dist/runtime/locale/az.js +54 -0
- package/dist/runtime/locale/bn.d.ts +2 -0
- package/dist/runtime/locale/bn.js +54 -0
- package/dist/runtime/locale/index.d.ts +3 -0
- package/dist/runtime/locale/index.js +3 -0
- package/dist/runtime/plugins/colors.js +1 -1
- package/dist/runtime/types/index.d.ts +1 -0
- package/dist/runtime/types/index.js +1 -0
- package/dist/runtime/types/utils.d.ts +5 -0
- package/dist/runtime/vue/components/Link.vue +75 -16
- package/dist/shared/{ui.ClMXjgLK.cjs → ui.C5FzRWM5.cjs} +471 -364
- package/dist/shared/{ui.CENZ17mM.mjs → ui.DCZM2pl8.mjs} +467 -364
- package/dist/unplugin.cjs +44 -20
- package/dist/unplugin.d.cts +10 -0
- package/dist/unplugin.d.mts +10 -0
- package/dist/unplugin.d.ts +10 -0
- package/dist/unplugin.mjs +43 -19
- package/dist/vite.cjs +3 -2
- package/dist/vite.d.cts +2 -0
- package/dist/vite.d.mts +2 -0
- package/dist/vite.d.ts +2 -0
- package/dist/vite.mjs +3 -2
- package/package.json +60 -33
- package/dist/client/devtools/_nuxt/CgoQwOTV.js +0 -57
- package/dist/client/devtools/_nuxt/builds/meta/3184ffe2-7577-4441-af98-fe6e81c30e3a.json +0 -1
- package/dist/client/devtools/_nuxt/entry.ChJczkiN.css +0 -1
- package/dist/client/devtools/_nuxt/error-404.DyY3rYaL.css +0 -1
- package/dist/client/devtools/_nuxt/error-500.D_1PCaJh.css +0 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type { ToastProps } from '../types';
|
|
2
|
-
|
|
1
|
+
import type { ToastProps, ToastEmits } from '../types';
|
|
2
|
+
import type { EmitsToProps } from '../types/utils';
|
|
3
|
+
export interface Toast extends Omit<ToastProps, 'defaultOpen'>, EmitsToProps<ToastEmits> {
|
|
3
4
|
id: string | number;
|
|
4
|
-
|
|
5
|
+
onClick?: (toast: Toast) => void;
|
|
5
6
|
}
|
|
6
7
|
export declare function useToast(): {
|
|
7
8
|
toasts: import("vue").Ref<Toast[], Toast[]>;
|
|
8
|
-
add: (toast: Partial<Toast>) =>
|
|
9
|
+
add: (toast: Partial<Toast>) => Toast;
|
|
9
10
|
update: (id: string | number, toast: Omit<Partial<Toast>, "id">) => void;
|
|
10
11
|
remove: (id: string | number) => void;
|
|
11
12
|
clear: () => void;
|
|
@@ -18,14 +18,14 @@ export function useToast() {
|
|
|
18
18
|
}
|
|
19
19
|
running.value = false;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
function add(toast) {
|
|
22
22
|
const body = {
|
|
23
23
|
id: generateId(),
|
|
24
24
|
open: true,
|
|
25
25
|
...toast
|
|
26
26
|
};
|
|
27
27
|
queue.push(body);
|
|
28
|
-
|
|
28
|
+
processQueue();
|
|
29
29
|
return body;
|
|
30
30
|
}
|
|
31
31
|
function update(id, toast) {
|
package/dist/runtime/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@import "./keyframes.css";@variant light (&:where(.light, .light *));@variant dark (&:where(.dark, .dark *));@layer base{body{@apply antialiased text-
|
|
1
|
+
@import "#build/ui.css";@import "./keyframes.css";@variant light (&:where(.light, .light *));@variant dark (&:where(.dark, .dark *));@layer base{body{@apply antialiased text-(--ui-text) bg-(--ui-bg) scheme-light dark:scheme-dark}.light,:root{--ui-text-dimmed:var(--ui-color-neutral-400);--ui-text-muted:var(--ui-color-neutral-500);--ui-text-toned:var(--ui-color-neutral-600);--ui-text:var(--ui-color-neutral-700);--ui-text-highlighted:var(--ui-color-neutral-900);--ui-bg:var(--color-white);--ui-bg-muted:var(--ui-color-neutral-50);--ui-bg-elevated:var(--ui-color-neutral-100);--ui-bg-accented:var(--ui-color-neutral-200);--ui-bg-inverted:var(--ui-color-neutral-900);--ui-border:var(--ui-color-neutral-200);--ui-border-muted:var(--ui-color-neutral-200);--ui-border-accented:var(--ui-color-neutral-300);--ui-border-inverted:var(--ui-color-neutral-900);--ui-radius:var(--radius-sm);--ui-container:var(--container-7xl)}.dark{--ui-text-dimmed:var(--ui-color-neutral-500);--ui-text-muted:var(--ui-color-neutral-400);--ui-text-toned:var(--ui-color-neutral-300);--ui-text:var(--ui-color-neutral-200);--ui-text-highlighted:var(--color-white);--ui-bg:var(--ui-color-neutral-900);--ui-bg-muted:var(--ui-color-neutral-800);--ui-bg-elevated:var(--ui-color-neutral-800);--ui-bg-accented:var(--ui-color-neutral-700);--ui-bg-inverted:var(--color-white);--ui-border:var(--ui-color-neutral-800);--ui-border-muted:var(--ui-color-neutral-700);--ui-border-accented:var(--ui-color-neutral-700);--ui-border-inverted:var(--color-white)}}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { defineLocale } from "../composables/defineLocale.js";
|
|
2
|
+
export default defineLocale({
|
|
3
|
+
name: "Az\u0259rbaycanca",
|
|
4
|
+
code: "az",
|
|
5
|
+
messages: {
|
|
6
|
+
inputMenu: {
|
|
7
|
+
noMatch: "Uy\u011Fun m\u0259lumat tap\u0131lmad\u0131",
|
|
8
|
+
noData: "M\u0259lumat yoxdur",
|
|
9
|
+
create: '"{label}" yarat'
|
|
10
|
+
},
|
|
11
|
+
calendar: {
|
|
12
|
+
prevYear: "\u018Fvv\u0259lki il",
|
|
13
|
+
nextYear: "N\xF6vb\u0259ti il",
|
|
14
|
+
prevMonth: "\u018Fvv\u0259lki ay",
|
|
15
|
+
nextMonth: "N\xF6vb\u0259ti ay"
|
|
16
|
+
},
|
|
17
|
+
inputNumber: {
|
|
18
|
+
increment: "Art\u0131r",
|
|
19
|
+
decrement: "Azalt"
|
|
20
|
+
},
|
|
21
|
+
commandPalette: {
|
|
22
|
+
placeholder: "\u018Fmr daxil edin v\u0259 ya axtar\u0131n...",
|
|
23
|
+
noMatch: "Uy\u011Fun m\u0259lumat tap\u0131lmad\u0131",
|
|
24
|
+
noData: "M\u0259lumat yoxdur",
|
|
25
|
+
close: "Ba\u011Fla"
|
|
26
|
+
},
|
|
27
|
+
selectMenu: {
|
|
28
|
+
noMatch: "Uy\u011Fun m\u0259lumat tap\u0131lmad\u0131",
|
|
29
|
+
noData: "M\u0259lumat yoxdur",
|
|
30
|
+
create: '"{label}" yarat',
|
|
31
|
+
search: "Axtar..."
|
|
32
|
+
},
|
|
33
|
+
toast: {
|
|
34
|
+
close: "Ba\u011Fla"
|
|
35
|
+
},
|
|
36
|
+
carousel: {
|
|
37
|
+
prev: "\u018Fvv\u0259lki",
|
|
38
|
+
next: "N\xF6vb\u0259ti",
|
|
39
|
+
goto: "Slayd {slide} ke\xE7"
|
|
40
|
+
},
|
|
41
|
+
modal: {
|
|
42
|
+
close: "Ba\u011Fla"
|
|
43
|
+
},
|
|
44
|
+
slideover: {
|
|
45
|
+
close: "Ba\u011Fla"
|
|
46
|
+
},
|
|
47
|
+
alert: {
|
|
48
|
+
close: "Ba\u011Fla"
|
|
49
|
+
},
|
|
50
|
+
table: {
|
|
51
|
+
noData: "M\u0259lumat yoxdur"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { defineLocale } from "../composables/defineLocale.js";
|
|
2
|
+
export default defineLocale({
|
|
3
|
+
name: "\u09AC\u09BE\u0982\u09B2\u09BE",
|
|
4
|
+
code: "bn",
|
|
5
|
+
messages: {
|
|
6
|
+
inputMenu: {
|
|
7
|
+
noMatch: "\u0995\u09CB\u09A8 \u09AE\u09BF\u09B2 \u09AA\u09BE\u0993\u09AF\u09BC\u09BE \u09AF\u09BE\u09AF\u09BC\u09A8\u09BF",
|
|
8
|
+
noData: "\u0995\u09CB\u09A8 \u09A4\u09A5\u09CD\u09AF \u09A8\u09C7\u0987",
|
|
9
|
+
create: '"{label}" \u09A4\u09C8\u09B0\u09BF \u0995\u09B0\u09C1\u09A8'
|
|
10
|
+
},
|
|
11
|
+
calendar: {
|
|
12
|
+
prevYear: "\u09AA\u09C2\u09B0\u09CD\u09AC\u09AC\u09B0\u09CD\u09A4\u09C0 \u09AC\u099B\u09B0",
|
|
13
|
+
nextYear: "\u09AA\u09B0\u09AC\u09B0\u09CD\u09A4\u09C0 \u09AC\u099B\u09B0",
|
|
14
|
+
prevMonth: "\u09AA\u09C2\u09B0\u09CD\u09AC\u09AC\u09B0\u09CD\u09A4\u09C0 \u09AE\u09BE\u09B8",
|
|
15
|
+
nextMonth: "\u09AA\u09B0\u09AC\u09B0\u09CD\u09A4\u09C0 \u09AE\u09BE\u09B8"
|
|
16
|
+
},
|
|
17
|
+
inputNumber: {
|
|
18
|
+
increment: "\u09AC\u09C3\u09A6\u09CD\u09A7\u09BF \u0995\u09B0\u09C1\u09A8",
|
|
19
|
+
decrement: "\u09B9\u09CD\u09B0\u09BE\u09B8 \u0995\u09B0\u09C1\u09A8"
|
|
20
|
+
},
|
|
21
|
+
commandPalette: {
|
|
22
|
+
placeholder: "\u0995\u09AE\u09BE\u09A8\u09CD\u09A1 \u099F\u09BE\u0987\u09AA \u0995\u09B0\u09C1\u09A8 \u09AC\u09BE \u0985\u09A8\u09C1\u09B8\u09A8\u09CD\u09A7\u09BE\u09A8 \u0995\u09B0\u09C1\u09A8...",
|
|
23
|
+
noMatch: "\u0995\u09CB\u09A8 \u09AE\u09BF\u09B2 \u09AA\u09BE\u0993\u09AF\u09BC\u09BE \u09AF\u09BE\u09AF\u09BC\u09A8\u09BF",
|
|
24
|
+
noData: "\u0995\u09CB\u09A8 \u09A4\u09A5\u09CD\u09AF \u09A8\u09C7\u0987",
|
|
25
|
+
close: "\u09AC\u09A8\u09CD\u09A7 \u0995\u09B0\u09C1\u09A8"
|
|
26
|
+
},
|
|
27
|
+
selectMenu: {
|
|
28
|
+
noMatch: "\u0995\u09CB\u09A8 \u09AE\u09BF\u09B2 \u09AA\u09BE\u0993\u09AF\u09BC\u09BE \u09AF\u09BE\u09AF\u09BC\u09A8\u09BF",
|
|
29
|
+
noData: "\u0995\u09CB\u09A8 \u09A4\u09A5\u09CD\u09AF \u09A8\u09C7\u0987",
|
|
30
|
+
create: '"{label}" \u09A4\u09C8\u09B0\u09BF \u0995\u09B0\u09C1\u09A8',
|
|
31
|
+
search: "\u0985\u09A8\u09C1\u09B8\u09A8\u09CD\u09A7\u09BE\u09A8 \u0995\u09B0\u09C1\u09A8..."
|
|
32
|
+
},
|
|
33
|
+
toast: {
|
|
34
|
+
close: "\u09AC\u09A8\u09CD\u09A7 \u0995\u09B0\u09C1\u09A8"
|
|
35
|
+
},
|
|
36
|
+
carousel: {
|
|
37
|
+
prev: "\u09AA\u09C2\u09B0\u09CD\u09AC\u09AC\u09B0\u09CD\u09A4\u09C0",
|
|
38
|
+
next: "\u09AA\u09B0\u09AC\u09B0\u09CD\u09A4\u09C0",
|
|
39
|
+
goto: "\u09B8\u09CD\u09B2\u09BE\u0987\u09A1 {slide} \u098F \u09AF\u09BE\u09A8"
|
|
40
|
+
},
|
|
41
|
+
modal: {
|
|
42
|
+
close: "\u09AC\u09A8\u09CD\u09A7 \u0995\u09B0\u09C1\u09A8"
|
|
43
|
+
},
|
|
44
|
+
slideover: {
|
|
45
|
+
close: "\u09AC\u09A8\u09CD\u09A7 \u0995\u09B0\u09C1\u09A8"
|
|
46
|
+
},
|
|
47
|
+
alert: {
|
|
48
|
+
close: "\u09AC\u09A8\u09CD\u09A7 \u0995\u09B0\u09C1\u09A8"
|
|
49
|
+
},
|
|
50
|
+
table: {
|
|
51
|
+
noData: "\u0995\u09CB\u09A8 \u09A4\u09A5\u09CD\u09AF \u09A8\u09C7\u0987"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { default as ar } from './ar';
|
|
2
|
+
export { default as az } from './az';
|
|
3
|
+
export { default as bn } from './bn';
|
|
2
4
|
export { default as cs } from './cs';
|
|
3
5
|
export { default as da } from './da';
|
|
4
6
|
export { default as de } from './de';
|
|
@@ -13,6 +15,7 @@ export { default as hi } from './hi';
|
|
|
13
15
|
export { default as id } from './id';
|
|
14
16
|
export { default as it } from './it';
|
|
15
17
|
export { default as ja } from './ja';
|
|
18
|
+
export { default as km } from './km';
|
|
16
19
|
export { default as ko } from './ko';
|
|
17
20
|
export { default as nb_no } from './nb_no';
|
|
18
21
|
export { default as nl } from './nl';
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { default as ar } from "./ar.js";
|
|
2
|
+
export { default as az } from "./az.js";
|
|
3
|
+
export { default as bn } from "./bn.js";
|
|
2
4
|
export { default as cs } from "./cs.js";
|
|
3
5
|
export { default as da } from "./da.js";
|
|
4
6
|
export { default as de } from "./de.js";
|
|
@@ -13,6 +15,7 @@ export { default as hi } from "./hi.js";
|
|
|
13
15
|
export { default as id } from "./id.js";
|
|
14
16
|
export { default as it } from "./it.js";
|
|
15
17
|
export { default as ja } from "./ja.js";
|
|
18
|
+
export { default as km } from "./km.js";
|
|
16
19
|
export { default as ko } from "./ko.js";
|
|
17
20
|
export { default as nb_no } from "./nb_no.js";
|
|
18
21
|
export { default as nl } from "./nl.js";
|
|
@@ -5,7 +5,7 @@ export default defineNuxtPlugin(() => {
|
|
|
5
5
|
const nuxtApp = useNuxtApp();
|
|
6
6
|
const shades = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
|
|
7
7
|
function generateShades(key, value) {
|
|
8
|
-
return `${shades.map((shade) => `--ui-color-${key}-${shade}: var(--color-${value}-${shade});`).join("\n ")}`;
|
|
8
|
+
return `${shades.map((shade) => `--ui-color-${key}-${shade}: var(--color-${value === "neutral" ? "old-neutral" : value}-${shade});`).join("\n ")}`;
|
|
9
9
|
}
|
|
10
10
|
function generateColor(key, shade) {
|
|
11
11
|
return `--ui-${key}: var(--ui-color-${key}-${shade});`;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { VNode } from 'vue';
|
|
1
2
|
export interface TightMap<O = any> {
|
|
2
3
|
[key: string]: TightMap | O;
|
|
3
4
|
}
|
|
@@ -20,3 +21,7 @@ export type SelectItemKey<T> = T extends Record<string, any> ? keyof T : string;
|
|
|
20
21
|
export type SelectModelValueEmits<T, V, M extends boolean = false, DV = T> = {
|
|
21
22
|
'update:modelValue': [payload: SelectModelValue<T, V, M, DV>];
|
|
22
23
|
};
|
|
24
|
+
export type StringOrVNode = string | VNode | (() => VNode);
|
|
25
|
+
export type EmitsToProps<T> = {
|
|
26
|
+
[K in keyof T as `on${Capitalize<string & K>}`]: T[K] extends [...args: infer Args] ? (...args: Args) => void : never;
|
|
27
|
+
};
|
|
@@ -90,7 +90,7 @@ export interface LinkSlots {
|
|
|
90
90
|
</script>
|
|
91
91
|
|
|
92
92
|
<script setup lang="ts">
|
|
93
|
-
import { computed } from 'vue'
|
|
93
|
+
import { computed, getCurrentInstance } from 'vue'
|
|
94
94
|
import { isEqual, diff } from 'ohash'
|
|
95
95
|
import { useForwardProps } from 'reka-ui'
|
|
96
96
|
import { reactiveOmit } from '@vueuse/core'
|
|
@@ -109,7 +109,22 @@ const props = withDefaults(defineProps<LinkProps>(), {
|
|
|
109
109
|
})
|
|
110
110
|
defineSlots<LinkSlots>()
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
// Check if vue-router is available by checking for the injection key
|
|
113
|
+
const hasRouter = computed(() => {
|
|
114
|
+
const app = getCurrentInstance()?.appContext.app
|
|
115
|
+
return !!(app?.config?.globalProperties?.$router)
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
// Only try to get route if router exists
|
|
119
|
+
const route = computed(() => {
|
|
120
|
+
if (!hasRouter.value) return null
|
|
121
|
+
try {
|
|
122
|
+
return useRoute()
|
|
123
|
+
} catch {
|
|
124
|
+
return null
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
|
|
113
128
|
const routerLinkProps = useForwardProps(reactiveOmit(props, 'as', 'type', 'disabled', 'active', 'exact', 'exactQuery', 'exactHash', 'activeClass', 'inactiveClass', 'to', 'raw', 'class'))
|
|
114
129
|
|
|
115
130
|
const ui = computed(() => tv({
|
|
@@ -132,24 +147,27 @@ function isPartiallyEqual(item1: any, item2: any) {
|
|
|
132
147
|
return isEqual(item1, item2, { excludeKeys: key => diffedKeys.includes(key) })
|
|
133
148
|
}
|
|
134
149
|
|
|
135
|
-
const isExternal = computed(() =>
|
|
150
|
+
const isExternal = computed(() => {
|
|
151
|
+
if (!props.to) return false
|
|
152
|
+
return typeof props.to === 'string' && hasProtocol(props.to, { acceptRelative: true })
|
|
153
|
+
})
|
|
136
154
|
|
|
137
155
|
function isLinkActive({ route: linkRoute, isActive, isExactActive }: any) {
|
|
138
156
|
if (props.active !== undefined) {
|
|
139
157
|
return props.active
|
|
140
158
|
}
|
|
141
159
|
|
|
142
|
-
if (!props.to) {
|
|
160
|
+
if (!props.to || !route.value) {
|
|
143
161
|
return false
|
|
144
162
|
}
|
|
145
163
|
|
|
146
164
|
if (props.exactQuery === 'partial') {
|
|
147
|
-
if (!isPartiallyEqual(linkRoute.query, route.query)) return false
|
|
165
|
+
if (!isPartiallyEqual(linkRoute.query, route.value.query)) return false
|
|
148
166
|
} else if (props.exactQuery === true) {
|
|
149
|
-
if (!isEqual(linkRoute.query, route.query)) return false
|
|
167
|
+
if (!isEqual(linkRoute.query, route.value.query)) return false
|
|
150
168
|
}
|
|
151
169
|
|
|
152
|
-
if (props.exactHash && linkRoute.hash !== route.hash) {
|
|
170
|
+
if (props.exactHash && linkRoute.hash !== route.value.hash) {
|
|
153
171
|
return false
|
|
154
172
|
}
|
|
155
173
|
|
|
@@ -173,10 +191,51 @@ function resolveLinkClass({ route, isActive, isExactActive }: any) {
|
|
|
173
191
|
|
|
174
192
|
return ui.value({ class: props.class, active, disabled: props.disabled })
|
|
175
193
|
}
|
|
194
|
+
|
|
195
|
+
// Handle navigation without vue-router
|
|
196
|
+
const handleNavigation = (href: string) => {
|
|
197
|
+
if (isExternal.value) {
|
|
198
|
+
window.location.href = href
|
|
199
|
+
} else {
|
|
200
|
+
window.location.pathname = href
|
|
201
|
+
}
|
|
202
|
+
}
|
|
176
203
|
</script>
|
|
177
204
|
|
|
178
205
|
<template>
|
|
179
|
-
<
|
|
206
|
+
<template v-if="hasRouter">
|
|
207
|
+
<RouterLink v-slot="{ href, navigate, route: linkRoute, isActive, isExactActive }" v-bind="routerLinkProps" :to="to || '#'" custom>
|
|
208
|
+
<template v-if="custom">
|
|
209
|
+
<slot
|
|
210
|
+
v-bind="{
|
|
211
|
+
...$attrs,
|
|
212
|
+
as,
|
|
213
|
+
type,
|
|
214
|
+
disabled,
|
|
215
|
+
href: to ? (isExternal ? to as string : href) : undefined,
|
|
216
|
+
navigate,
|
|
217
|
+
active: isLinkActive({ route: linkRoute, isActive, isExactActive })
|
|
218
|
+
}"
|
|
219
|
+
/>
|
|
220
|
+
</template>
|
|
221
|
+
<ULinkBase
|
|
222
|
+
v-else
|
|
223
|
+
v-bind="{
|
|
224
|
+
...$attrs,
|
|
225
|
+
as,
|
|
226
|
+
type,
|
|
227
|
+
disabled,
|
|
228
|
+
href: to ? (isExternal ? to as string : href) : undefined,
|
|
229
|
+
navigate
|
|
230
|
+
}"
|
|
231
|
+
:class="resolveLinkClass({ route: linkRoute, isActive, isExactActive })"
|
|
232
|
+
>
|
|
233
|
+
<slot :active="isLinkActive({ route: linkRoute, isActive, isExactActive })" />
|
|
234
|
+
</ULinkBase>
|
|
235
|
+
</RouterLink>
|
|
236
|
+
</template>
|
|
237
|
+
|
|
238
|
+
<template v-else>
|
|
180
239
|
<template v-if="custom">
|
|
181
240
|
<slot
|
|
182
241
|
v-bind="{
|
|
@@ -184,9 +243,9 @@ function resolveLinkClass({ route, isActive, isExactActive }: any) {
|
|
|
184
243
|
as,
|
|
185
244
|
type,
|
|
186
245
|
disabled,
|
|
187
|
-
href: to
|
|
188
|
-
navigate,
|
|
189
|
-
active:
|
|
246
|
+
href: to,
|
|
247
|
+
navigate: () => to && handleNavigation(to as string),
|
|
248
|
+
active: false
|
|
190
249
|
}"
|
|
191
250
|
/>
|
|
192
251
|
</template>
|
|
@@ -197,12 +256,12 @@ function resolveLinkClass({ route, isActive, isExactActive }: any) {
|
|
|
197
256
|
as,
|
|
198
257
|
type,
|
|
199
258
|
disabled,
|
|
200
|
-
href:
|
|
201
|
-
navigate
|
|
259
|
+
href: (to as string)
|
|
202
260
|
}"
|
|
203
|
-
:class="
|
|
261
|
+
:class="ui({ class: props.class, disabled })"
|
|
262
|
+
@click="to && handleNavigation(to as string)"
|
|
204
263
|
>
|
|
205
|
-
<slot :active="
|
|
264
|
+
<slot :active="false" />
|
|
206
265
|
</ULinkBase>
|
|
207
|
-
</
|
|
266
|
+
</template>
|
|
208
267
|
</template>
|