2022-09-06 12:03:37 +00:00
|
|
|
<template>
|
2023-07-24 14:18:43 +00:00
|
|
|
<li v-if="visible()" :class="[cx('menuitem'), item.class]" v-bind="ptm('menuitem', ptmOptions)">
|
2023-08-29 15:00:47 +00:00
|
|
|
<template v-if="!templates.item">
|
2023-11-08 12:47:48 +00:00
|
|
|
<a :href="item.url || '#'" :class="cx('action')" :target="item.target" :aria-current="isCurrentUrl()" @click="onClick" v-bind="ptm('action', ptmOptions)">
|
2023-07-24 14:18:43 +00:00
|
|
|
<component v-if="templates && templates.itemicon" :is="templates.itemicon" :item="item" :class="cx('icon', ptmOptions)" />
|
|
|
|
<span v-else-if="item.icon" :class="[cx('icon'), item.icon]" v-bind="ptm('icon', ptmOptions)" />
|
|
|
|
<span v-if="item.label" :class="cx('label')" v-bind="ptm('label', ptmOptions)">{{ label() }}</span>
|
2022-09-06 12:03:37 +00:00
|
|
|
</a>
|
|
|
|
</template>
|
2023-08-30 13:28:00 +00:00
|
|
|
<component v-else :is="templates.item" :item="item" :label="label()" :props="getMenuItemProps"></component>
|
2022-09-06 12:03:37 +00:00
|
|
|
</li>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-05-30 09:59:17 +00:00
|
|
|
import BaseComponent from 'primevue/basecomponent';
|
2023-08-29 15:00:47 +00:00
|
|
|
import { mergeProps } from 'vue';
|
2023-04-26 09:57:16 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
export default {
|
|
|
|
name: 'BreadcrumbItem',
|
2023-07-04 06:29:36 +00:00
|
|
|
hostName: 'Breadcrumb',
|
2023-05-30 09:59:17 +00:00
|
|
|
extends: BaseComponent,
|
2022-09-06 12:03:37 +00:00
|
|
|
props: {
|
|
|
|
item: null,
|
2023-04-17 05:42:20 +00:00
|
|
|
templates: null,
|
2023-04-27 14:11:40 +00:00
|
|
|
index: null
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2023-11-17 10:17:59 +00:00
|
|
|
onClick(event) {
|
2022-09-06 12:03:37 +00:00
|
|
|
if (this.item.command) {
|
|
|
|
this.item.command({
|
|
|
|
originalEvent: event,
|
|
|
|
item: this.item
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
visible() {
|
2022-09-14 11:26:01 +00:00
|
|
|
return typeof this.item.visible === 'function' ? this.item.visible() : this.item.visible !== false;
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
2022-12-08 11:04:25 +00:00
|
|
|
disabled() {
|
|
|
|
return typeof this.item.disabled === 'function' ? this.item.disabled() : this.item.disabled;
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
label() {
|
2022-09-14 11:26:01 +00:00
|
|
|
return typeof this.item.label === 'function' ? this.item.label() : this.item.label;
|
2022-12-08 11:04:25 +00:00
|
|
|
},
|
|
|
|
isCurrentUrl() {
|
|
|
|
const { to, url } = this.item;
|
2023-08-29 15:00:47 +00:00
|
|
|
const lastPath = typeof window !== 'undefined' ? window.location.pathname : '';
|
2022-12-08 11:04:25 +00:00
|
|
|
|
|
|
|
return to === lastPath || url === lastPath ? 'page' : undefined;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
2023-07-24 14:18:43 +00:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
ptmOptions() {
|
|
|
|
return {
|
|
|
|
context: {
|
|
|
|
item: this.item,
|
|
|
|
index: this.index
|
|
|
|
}
|
|
|
|
};
|
2023-08-29 15:00:47 +00:00
|
|
|
},
|
|
|
|
getMenuItemProps() {
|
|
|
|
return {
|
|
|
|
action: mergeProps(
|
|
|
|
{
|
|
|
|
class: this.cx('action'),
|
|
|
|
'aria-current': this.isCurrentUrl(),
|
|
|
|
onClick: ($event) => this.onClick($event)
|
|
|
|
},
|
|
|
|
this.ptm('action', this.ptmOptions)
|
|
|
|
),
|
|
|
|
icon: mergeProps(
|
|
|
|
{
|
|
|
|
class: [this.cx('icon'), this.item.icon]
|
|
|
|
},
|
|
|
|
this.ptm('icon', this.ptmOptions)
|
|
|
|
),
|
|
|
|
label: mergeProps(
|
|
|
|
{
|
|
|
|
class: this.cx('label')
|
|
|
|
},
|
|
|
|
this.ptm('label', this.ptmOptions)
|
|
|
|
)
|
|
|
|
};
|
2023-07-24 14:18:43 +00:00
|
|
|
}
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
</script>
|