File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
resources/js/components/ui/Context Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 11<script setup>
22import { ContextMenuItem } from ' reka-ui' ;
3- import { useSlots } from ' vue' ;
3+ import { computed , useSlots } from ' vue' ;
44import Icon from ' ../Icon/Icon.vue' ;
55import { cva } from ' cva' ;
6+ import { Link } from " @inertiajs/vue3" ;
67
78const props = defineProps ({
9+ /** The element or component this component should render as */
10+ as: { type: String , default: null },
811 /** The URL to link to */
912 href: { type: String , default: null },
1013 /** When `href` is provided, this prop controls the link's `target` attribute */
@@ -19,6 +22,11 @@ const props = defineProps({
1922
2023const slots = useSlots ();
2124const hasDefaultSlot = !! slots .default ;
25+ const tag = computed (() => {
26+ if (props .as ) return props .as ;
27+ if (! props .href ) return ' div' ;
28+ return props .target === ' _blank' ? ' a' : Link;
29+ });
2230
2331const classes = cva ({
2432 base: [
@@ -51,7 +59,7 @@ const iconClasses = cva({
5159 <ContextMenuItem
5260 :class =" classes"
5361 data-ui-context-item
54- :as =" href ? 'a' : 'div' "
62+ :as =" tag "
5563 :href
5664 :target
5765 >
You can’t perform that action at this time.
0 commit comments