Fixed #6522 - For TieredMenu
parent
ee1b6260d7
commit
0c57108f89
|
@ -18,6 +18,10 @@ export default {
|
|||
type: [String, Object],
|
||||
default: 'body'
|
||||
},
|
||||
breakpoint: {
|
||||
type: String,
|
||||
default: '960px'
|
||||
},
|
||||
autoZIndex: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
|
|
|
@ -226,6 +226,11 @@ export interface TieredMenuProps {
|
|||
* @defaultValue false
|
||||
*/
|
||||
popup?: boolean | undefined;
|
||||
/**
|
||||
* The breakpoint to define the maximum width boundary.
|
||||
* @defaultValue 960px
|
||||
*/
|
||||
breakpoint?: string | undefined;
|
||||
/**
|
||||
* A valid query selector or an HTMLElement to specify where the overlay gets attached.
|
||||
* @defaultValue body
|
||||
|
|
|
@ -57,6 +57,7 @@ export default {
|
|||
inheritAttrs: false,
|
||||
emits: ['focus', 'blur', 'before-show', 'before-hide', 'hide', 'show'],
|
||||
outsideClickListener: null,
|
||||
matchMediaListener: null,
|
||||
scrollHandler: null,
|
||||
resizeListener: null,
|
||||
target: null,
|
||||
|
@ -72,7 +73,9 @@ export default {
|
|||
activeItemPath: [],
|
||||
visible: !this.popup,
|
||||
submenuVisible: false,
|
||||
dirty: false
|
||||
dirty: false,
|
||||
query: null,
|
||||
queryMatches: false
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
|
@ -93,10 +96,12 @@ export default {
|
|||
},
|
||||
mounted() {
|
||||
this.id = this.id || UniqueComponentId();
|
||||
this.bindMatchMediaListener();
|
||||
},
|
||||
beforeUnmount() {
|
||||
this.unbindOutsideClickListener();
|
||||
this.unbindResizeListener();
|
||||
this.unbindMatchMediaListener();
|
||||
|
||||
if (this.scrollHandler) {
|
||||
this.scrollHandler.destroy();
|
||||
|
@ -498,6 +503,26 @@ export default {
|
|||
this.resizeListener = null;
|
||||
}
|
||||
},
|
||||
bindMatchMediaListener() {
|
||||
if (!this.matchMediaListener) {
|
||||
const query = matchMedia(`(max-width: ${this.breakpoint})`);
|
||||
|
||||
this.query = query;
|
||||
this.queryMatches = query.matches;
|
||||
|
||||
this.matchMediaListener = () => {
|
||||
this.queryMatches = query.matches;
|
||||
};
|
||||
|
||||
this.query.addEventListener('change', this.matchMediaListener);
|
||||
}
|
||||
},
|
||||
unbindMatchMediaListener() {
|
||||
if (this.matchMediaListener) {
|
||||
this.query.removeEventListener('change', this.matchMediaListener);
|
||||
this.matchMediaListener = null;
|
||||
}
|
||||
},
|
||||
isItemMatched(processedItem) {
|
||||
return this.isValidItem(processedItem) && this.getProccessedItemLabel(processedItem)?.toLocaleLowerCase().startsWith(this.searchValue.toLocaleLowerCase());
|
||||
},
|
||||
|
|
|
@ -126,6 +126,47 @@ const theme = ({ dt }) => `
|
|||
.p-tieredmenu-enter-active {
|
||||
transition: opacity 250ms;
|
||||
}
|
||||
|
||||
.p-tieredmenu-mobile {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.p-tieredmenu-mobile .p-tieredmenu-button {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.p-tieredmenu-mobile .p-tieredmenu-root-list > .p-tieredmenu-item > .p-tieredmenu-item-content > .p-tieredmenu-item-link {
|
||||
padding: ${dt('tieredmenu.item.padding')};
|
||||
}
|
||||
|
||||
.p-tieredmenu-mobile .p-tieredmenu-root-list .p-tieredmenu-separator {
|
||||
border-top: 1px solid ${dt('tieredmenu.separator.border.color')};
|
||||
}
|
||||
|
||||
.p-tieredmenu-mobile .p-tieredmenu-root-list > .p-tieredmenu-item > .p-tieredmenu-item-content .p-tieredmenu-submenu-icon {
|
||||
margin-left: auto;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.p-tieredmenu-mobile .p-tieredmenu-root-list > .p-tieredmenu-item-active > .p-tieredmenu-item-content .p-tieredmenu-submenu-icon {
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
|
||||
.p-tieredmenu-mobile .p-tieredmenu-submenu .p-tieredmenu-submenu-icon {
|
||||
transition: transform 0.2s;
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.p-tieredmenu-mobile .p-tieredmenu-item-active > .p-tieredmenu-item-content .p-tieredmenu-submenu-icon {
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
|
||||
.p-tieredmenu-mobile .p-tieredmenu-submenu {
|
||||
position: static;
|
||||
box-shadow: none;
|
||||
border: 0 none;
|
||||
padding-left: ${dt('tieredmenu.submenu.mobile.indent')};
|
||||
}
|
||||
`;
|
||||
|
||||
const inlineStyles = {
|
||||
|
@ -133,10 +174,12 @@ const inlineStyles = {
|
|||
};
|
||||
|
||||
const classes = {
|
||||
root: ({ instance, props }) => [
|
||||
root: ({ props, instance }) => [
|
||||
'p-tieredmenu p-component',
|
||||
{
|
||||
'p-tieredmenu-overlay': props.popup
|
||||
'p-tieredmenu-overlay': props.popup,
|
||||
'p-tieredmenu-mobile': instance.queryMatches,
|
||||
'p-tieredmenu-mobile-active': instance.mobileActive
|
||||
}
|
||||
],
|
||||
start: 'p-tieredmenu-start',
|
||||
|
|
|
@ -26,6 +26,9 @@ export default {
|
|||
activeColor: '{navigation.item.icon.active.color}'
|
||||
}
|
||||
},
|
||||
submenu: {
|
||||
mobileIndent: '1rem'
|
||||
},
|
||||
submenuLabel: {
|
||||
padding: '{navigation.submenu.label.padding}',
|
||||
fontWeight: '{navigation.submenu.label.font.weight}',
|
||||
|
|
|
@ -26,6 +26,9 @@ export default {
|
|||
activeColor: '{navigation.item.icon.active.color}'
|
||||
}
|
||||
},
|
||||
submenu: {
|
||||
mobileIndent: '1.25rem'
|
||||
},
|
||||
submenuIcon: {
|
||||
size: '{navigation.submenu.icon.size}',
|
||||
color: '{navigation.submenu.icon.color}',
|
||||
|
|
|
@ -26,6 +26,9 @@ export default {
|
|||
activeColor: '{navigation.item.icon.active.color}'
|
||||
}
|
||||
},
|
||||
submenu: {
|
||||
mobileIndent: '1rem'
|
||||
},
|
||||
submenuLabel: {
|
||||
padding: '{navigation.submenu.label.padding}',
|
||||
fontWeight: '{navigation.submenu.label.font.weight}',
|
||||
|
|
|
@ -26,6 +26,9 @@ export default {
|
|||
activeColor: '{navigation.item.icon.active.color}'
|
||||
}
|
||||
},
|
||||
submenu: {
|
||||
mobileIndent: '1rem'
|
||||
},
|
||||
submenuLabel: {
|
||||
padding: '{navigation.submenu.label.padding}',
|
||||
fontWeight: '{navigation.submenu.label.font.weight}',
|
||||
|
|
Loading…
Reference in New Issue