Refactor #5682 - For Dock, Menubar

pull/5701/head
tugcekucukoglu 2024-05-06 13:32:30 +03:00
parent 5353635407
commit 89b4e1a76a
4 changed files with 49 additions and 11 deletions

View File

@ -274,12 +274,23 @@ export interface DockSlots {
props: DockRouterBindProps; props: DockRouterBindProps;
}): VNode[]; }): VNode[];
/** /**
* @deprecated since v4.0. Use 'itemicon' slot.
* Custom icon content. * Custom icon content.
* @param {Object} scope - icon slot's params. * @param {Object} scope - item icon slot's params.
*/ */
icon(scope: { icon(scope: {
/** /**
* Custom content for icon. * Custom content for item icon.
*/
item: MenuItem;
}): VNode[];
/**
* Custom icon content.
* @param {Object} scope - item icon slot's params.
*/
itemicon(scope: {
/**
* Custom content for item icon.
*/ */
item: MenuItem; item: MenuItem;
}): VNode[]; }): VNode[];

View File

@ -40,10 +40,11 @@
aria-hidden="true" aria-hidden="true"
v-bind="getPTOptions('itemLink', processedItem, index)" v-bind="getPTOptions('itemLink', processedItem, index)"
> >
<template v-if="!templates['icon']"> <!-- TODO: icon deprecated since v4.0-->
<template v-if="!templates['icon'] && !templates['itemicon']">
<span v-ripple :class="[cx('itemIcon'), processedItem.icon]" v-bind="getPTOptions('itemIcon', processedItem, index)"></span> <span v-ripple :class="[cx('itemIcon'), processedItem.icon]" v-bind="getPTOptions('itemIcon', processedItem, index)"></span>
</template> </template>
<component v-else :is="templates['icon']" :item="processedItem" :class="cx('itemIcon')"></component> <component v-else :is="templates['icon'] || templates['itemicon']" :item="processedItem" :class="cx('itemIcon')"></component>
</a> </a>
</template> </template>
<component v-else :is="templates['item']" :item="processedItem" :index="index" :label="processedItem.label" :props="getMenuItemProps(processedItem, index)"></component> <component v-else :is="templates['item']" :item="processedItem" :index="index" :label="processedItem.label" :props="getMenuItemProps(processedItem, index)"></component>

View File

@ -97,7 +97,7 @@ export interface MenubarPassThroughOptions {
/** /**
* Used to pass attributes to the mobile menu button icon's DOM element. * Used to pass attributes to the mobile menu button icon's DOM element.
*/ */
menubuttonicon?: MenubarPassThroughOptionType; buttonicon?: MenubarPassThroughOptionType;
/** /**
* Used to pass attributes to the submenu's DOM element. * Used to pass attributes to the submenu's DOM element.
*/ */
@ -318,6 +318,7 @@ export interface MenubarSlots {
hasSubmenu: boolean; hasSubmenu: boolean;
}): VNode[]; }): VNode[];
/** /**
* @deprecated since v4.0. use 'button' slot instead.
* Custom menu button template on responsive mode. * Custom menu button template on responsive mode.
* @param {Object} scope - menu button slot's params. * @param {Object} scope - menu button slot's params.
*/ */
@ -337,14 +338,37 @@ export interface MenubarSlots {
toggleCallback: () => void; toggleCallback: () => void;
}): VNode[]; }): VNode[];
/** /**
* Custom popup icon template on responsive mode. * Custom menu button template on responsive mode.
* @deprecated since v3.42.0. Use 'menubuttonicon' slot instead. * @param {Object} scope - menu button slot's params.
*/ */
popupicon(): VNode[]; button(scope: {
/**
* Current id state as a string
*/
id: string;
/**
* Style class of component
*/
class: string;
/**
*
* Toggle event
*/
toggleCallback: () => void;
}): VNode[];
/** /**
* @deprecated since v4.0. use 'buttonicon' slot instead.
* Custom menu button icon template on responsive mode. * Custom menu button icon template on responsive mode.
*/ */
menubuttonicon(): VNode[]; menubuttonicon(): VNode[];
/**
* Custom submenu icon template.
* @param {Object} scope - submenuicon slot's params.
*/
/**
* Custom menu button icon template on responsive mode.
*/
buttonicon(): VNode[];
/** /**
* Custom submenu icon template. * Custom submenu icon template.
* @param {Object} scope - submenuicon slot's params. * @param {Object} scope - submenuicon slot's params.

View File

@ -3,7 +3,8 @@
<div v-if="$slots.start" :class="cx('start')" v-bind="ptm('start')"> <div v-if="$slots.start" :class="cx('start')" v-bind="ptm('start')">
<slot name="start"></slot> <slot name="start"></slot>
</div> </div>
<slot :id="id" name="menubutton" :class="cx('button')" :toggleCallback="(event) => menuButtonClick(event)"> <slot :id="id" :name="$slots.button ? 'button' : 'menubutton'" :class="cx('button')" :toggleCallback="(event) => menuButtonClick(event)">
<!-- TODO: menubutton deprecated since v4.0-->
<a <a
v-if="model && model.length > 0" v-if="model && model.length > 0"
ref="menubutton" ref="menubutton"
@ -18,8 +19,9 @@
@keydown="menuButtonKeydown($event)" @keydown="menuButtonKeydown($event)"
v-bind="{ ...buttonProps, ...ptm('button') }" v-bind="{ ...buttonProps, ...ptm('button') }"
> >
<slot name="menubuttonicon"> <!-- TODO: menubuttonicon deprecated since v4.0-->
<BarsIcon v-bind="ptm('menubuttonicon')" /> <slot :name="$slots.buttonicon ? 'buttonicon' : 'menubuttonicon'">
<BarsIcon v-bind="ptm('buttonicon')" />
</slot> </slot>
</a> </a>
</slot> </slot>