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