Refactor #4739 - For Breadcrumb
parent
a6e06572d0
commit
ad9b437003
|
@ -13,10 +13,6 @@ export default {
|
|||
home: {
|
||||
type: null,
|
||||
default: null
|
||||
},
|
||||
exact: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
},
|
||||
style: BreadcrumbStyle,
|
||||
|
|
|
@ -134,6 +134,7 @@ export interface BreadcrumbProps {
|
|||
home?: MenuItem | undefined;
|
||||
/**
|
||||
* Whether to apply 'router-link-active-exact' class if route exactly matches the item path.
|
||||
* @deprecated since v3.40.0.
|
||||
* @defaultValue true
|
||||
*/
|
||||
exact?: boolean | undefined;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
<template>
|
||||
<nav :class="cx('root')" v-bind="ptm('root')" data-pc-name="breadcrumb">
|
||||
<ol :class="cx('menu')" v-bind="ptm('menu')">
|
||||
<BreadcrumbItem v-if="home" :item="home" :class="cx('home')" :templates="$slots" :exact="exact" :pt="pt" :unstyled="unstyled" v-bind="ptm('home')" />
|
||||
<BreadcrumbItem v-if="home" :item="home" :class="cx('home')" :templates="$slots" :pt="pt" :unstyled="unstyled" v-bind="ptm('home')" />
|
||||
<template v-for="(item, i) of model" :key="item.label + '_' + i">
|
||||
<li v-if="home || i !== 0" :class="cx('separator')" v-bind="ptm('separator')">
|
||||
<slot name="separator">
|
||||
<ChevronRightIcon aria-hidden="true" v-bind="ptm('separatorIcon')" />
|
||||
</slot>
|
||||
</li>
|
||||
<BreadcrumbItem :item="item" :index="i" :templates="$slots" :exact="exact" :pt="pt" :unstyled="unstyled" />
|
||||
<BreadcrumbItem :item="item" :index="i" :templates="$slots" :pt="pt" :unstyled="unstyled" />
|
||||
</template>
|
||||
</ol>
|
||||
</nav>
|
||||
|
@ -22,11 +22,6 @@ import BreadcrumbItem from './BreadcrumbItem.vue';
|
|||
export default {
|
||||
name: 'Breadcrumb',
|
||||
extends: BaseBreadcrumb,
|
||||
beforeMount() {
|
||||
if (!this.$slots.item) {
|
||||
console.warn('In future versions, vue-router support will be removed. Item templating should be used.');
|
||||
}
|
||||
},
|
||||
components: {
|
||||
BreadcrumbItem: BreadcrumbItem,
|
||||
ChevronRightIcon: ChevronRightIcon
|
||||
|
|
|
@ -1,14 +1,7 @@
|
|||
<template>
|
||||
<li v-if="visible()" :class="[cx('menuitem'), item.class]" v-bind="ptm('menuitem', ptmOptions)">
|
||||
<template v-if="!templates.item">
|
||||
<router-link v-if="item.to" v-slot="{ navigate, href, isActive, isExactActive }" :to="item.to" custom>
|
||||
<a :href="href" :class="cx('action', { isActive, isExactActive })" :aria-current="isCurrentUrl()" @click="onClick($event, navigate)" v-bind="ptm('action', ptmOptions)">
|
||||
<component v-if="templates.itemicon" :is="templates.itemicon" :item="item" :class="cx('icon')" />
|
||||
<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>
|
||||
</a>
|
||||
</router-link>
|
||||
<a v-else :href="item.url || '#'" :class="cx('action')" :target="item.target" :aria-current="isCurrentUrl()" @click="onClick" v-bind="ptm('action', ptmOptions)">
|
||||
<a :href="item.url || '#'" :class="cx('action')" :target="item.target" :aria-current="isCurrentUrl()" @click="onClick" v-bind="ptm('action', ptmOptions)">
|
||||
<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>
|
||||
|
@ -29,7 +22,6 @@ export default {
|
|||
props: {
|
||||
item: null,
|
||||
templates: null,
|
||||
exact: null,
|
||||
index: null
|
||||
},
|
||||
methods: {
|
||||
|
@ -40,10 +32,6 @@ export default {
|
|||
item: this.item
|
||||
});
|
||||
}
|
||||
|
||||
if (this.item.to && navigate) {
|
||||
navigate(event);
|
||||
}
|
||||
},
|
||||
visible() {
|
||||
return typeof this.item.visible === 'function' ? this.item.visible() : this.item.visible !== false;
|
||||
|
|
|
@ -42,13 +42,7 @@ const classes = {
|
|||
home: 'p-breadcrumb-home',
|
||||
separator: 'p-menuitem-separator',
|
||||
menuitem: ({ instance }) => ['p-menuitem', { 'p-disabled': instance.disabled() }],
|
||||
action: ({ props, isActive, isExactActive }) => [
|
||||
'p-menuitem-link',
|
||||
{
|
||||
'router-link-active': isActive,
|
||||
'router-link-active-exact': props.exact && isExactActive
|
||||
}
|
||||
],
|
||||
action: 'p-menuitem-link',
|
||||
icon: 'p-menuitem-icon',
|
||||
label: 'p-menuitem-text'
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue