mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-10 01:12:37 +00:00
Add passthrough(pt) option to Panel
This commit is contained in:
parent
37952b363b
commit
ff178ac9d3
3 changed files with 205 additions and 2 deletions
73
components/lib/panel/Panel.d.ts
vendored
73
components/lib/panel/Panel.d.ts
vendored
|
@ -10,6 +10,8 @@
|
|||
import { ButtonHTMLAttributes, VNode } from 'vue';
|
||||
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
||||
|
||||
export declare type PanelPassThroughOptionType = PanelPassThroughAttributes | ((options: { props: PanelProps; state: PanelState }) => PanelPassThroughAttributes) | null | undefined;
|
||||
|
||||
/**
|
||||
* Custom toggle event.
|
||||
* @see {@link PanelEmits.toggle}
|
||||
|
@ -25,6 +27,62 @@ export interface PanelToggleEvent {
|
|||
value: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom passthrough(pt) options.
|
||||
* @see {@link PanelProps.pt}
|
||||
*/
|
||||
export interface PanelPassThroughOptions {
|
||||
/**
|
||||
* Uses to pass attributes to the root's DOM element.
|
||||
*/
|
||||
root?: PanelPassThroughOptionType;
|
||||
/**
|
||||
* Uses to pass attributes to the header's DOM element.
|
||||
*/
|
||||
header?: PanelPassThroughOptionType;
|
||||
/**
|
||||
* Uses to pass attributes to the title's DOM element.
|
||||
*/
|
||||
title?: PanelPassThroughOptionType;
|
||||
/**
|
||||
* Uses to pass attributes to the title's DOM element.
|
||||
*/
|
||||
icons?: PanelPassThroughOptionType;
|
||||
/**
|
||||
* Uses to pass attributes to the toggler's DOM element.
|
||||
*/
|
||||
toggler?: PanelPassThroughOptionType;
|
||||
/**
|
||||
* Uses to pass attributes to the headericon's DOM element.
|
||||
*/
|
||||
headericon?: PanelPassThroughOptionType;
|
||||
/**
|
||||
* Uses to pass attributes to the toggleablecontent's DOM element.
|
||||
*/
|
||||
toggleablecontent?: PanelPassThroughOptionType;
|
||||
/**
|
||||
* Uses to pass attributes to the content's DOM element.
|
||||
*/
|
||||
content?: PanelPassThroughOptionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom passthrough attributes for each DOM elements
|
||||
*/
|
||||
export interface PanelPassThroughAttributes {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines current inline states in Panel component.
|
||||
*/
|
||||
export interface PanelState {
|
||||
/**
|
||||
* Current collapsed state as a boolean
|
||||
*/
|
||||
d_collapsed: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines valid properties in Panel component.
|
||||
*/
|
||||
|
@ -47,6 +105,11 @@ export interface PanelProps {
|
|||
* Uses to pass the custom value to read for the button inside the component.
|
||||
*/
|
||||
toggleButtonProps?: ButtonHTMLAttributes | undefined;
|
||||
/**
|
||||
* Uses to pass attributes to DOM elements inside the component.
|
||||
* @type {PanelPassThroughOptions}
|
||||
*/
|
||||
pt?: PanelPassThroughOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,6 +128,16 @@ export interface PanelSlots {
|
|||
* Custom icons template.
|
||||
*/
|
||||
icons(): VNode[];
|
||||
/**
|
||||
* Custom header icon template of panel.
|
||||
* @param {Object} scope - header icon slot's params.
|
||||
*/
|
||||
headericon(scope: {
|
||||
/**
|
||||
* Collapsed state as a boolean
|
||||
*/
|
||||
collapsed: boolean;
|
||||
}): VNode[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
v-ripple
|
||||
type="button"
|
||||
role="button"
|
||||
class="p-panel-toggler p-link"
|
||||
class="p-panel-header-icon p-panel-toggler p-link"
|
||||
:aria-label="buttonAriaLabel"
|
||||
:aria-controls="ariaId + '_content'"
|
||||
:aria-expanded="!d_collapsed"
|
||||
|
@ -20,7 +20,9 @@
|
|||
@keydown="onKeyDown"
|
||||
v-bind="{ ...toggleButtonProps, ...ptm('toggler') }"
|
||||
>
|
||||
<span :class="['p-panel-header-icon', { 'pi pi-minus': !d_collapsed, 'pi pi-plus': d_collapsed }]" v-bind="ptm('headericon')"></span>
|
||||
<slot name="headericon" :collapsed="d_collapsed">
|
||||
<span :class="{ 'pi pi-minus': !d_collapsed, 'pi pi-plus': d_collapsed }" v-bind="ptm('headericon')"></span>
|
||||
</slot>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue