Toolbar pt updates

pull/3841/head
Bahadır Sofuoğlu 2023-03-28 15:20:20 +03:00
parent 9753f2ba72
commit 917b09a67b
3 changed files with 57 additions and 4 deletions

View File

@ -4,6 +4,12 @@ const ToolbarProps = [
type: 'string', type: 'string',
default: 'null', default: 'null',
description: 'Defines a string value that labels an interactive element.' description: 'Defines a string value that labels an interactive element.'
},
{
name: 'pt',
type: 'any',
default: 'null',
description: 'Uses to pass attributes to DOM elements inside the component.'
} }
]; ];

View File

@ -10,6 +10,46 @@
import { VNode } from 'vue'; import { VNode } from 'vue';
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
export declare type ToolbarPassThroughOptionType = ToolbarPassThroughAttributes | ((options: ToolbarPassThroughMethodOptions) => ToolbarPassThroughAttributes) | null | undefined;
/**
* Custom passthrough(pt) option method.
*/
export interface ToolbarPassThroughMethodOptions {
props: ToolbarProps;
}
/**
* Custom passthrough(pt) options.
* @see {@link ToolbarProps.pt}
*/
export interface ToolbarPassThroughOptions {
/**
* Uses to pass attributes to the root's DOM element.
*/
root?: ToolbarPassThroughOptionType;
/**
* Uses to pass attributes to the groupleft's DOM element.
*/
groupleft?: ToolbarPassThroughOptionType;
/**
* Uses to pass attributes to the groupcenter's DOM element.
*/
groupcenter?: ToolbarPassThroughOptionType;
/**
* Uses to pass attributes to the groupright's DOM element.
*/
groupright?: ToolbarPassThroughOptionType;
}
/**
* Custom passthrough attributes for each DOM elements
*/
export interface ToolbarPassThroughAttributes {
[key: string]: any;
}
/** /**
* Defines valid properties in Toolbar component. * Defines valid properties in Toolbar component.
*/ */
@ -18,6 +58,11 @@ export interface ToolbarProps {
* Defines a string value that labels an interactive element. * Defines a string value that labels an interactive element.
*/ */
'aria-labelledby'?: string | undefined; 'aria-labelledby'?: string | undefined;
/**
* Uses to pass attributes to DOM elements inside the component.
* @type {ToolbarPassThroughOptions}
*/
pt?: ToolbarPassThroughOptions;
} }
/** /**

View File

@ -1,20 +1,22 @@
<template> <template>
<div class="p-toolbar p-component" role="toolbar" :aria-labelledby="ariaLabelledby"> <div class="p-toolbar p-component" role="toolbar" :aria-labelledby="ariaLabelledby" v-bind="ptm('root')">
<div class="p-toolbar-group-start p-toolbar-group-left"> <div class="p-toolbar-group-start p-toolbar-group-left" v-bind="ptm('groupleft')">
<slot name="start"></slot> <slot name="start"></slot>
</div> </div>
<div class="p-toolbar-group-center"> <div class="p-toolbar-group-center" v-bind="ptm('groupcenter')">
<slot name="center"></slot> <slot name="center"></slot>
</div> </div>
<div class="p-toolbar-group-end p-toolbar-group-right"> <div class="p-toolbar-group-end p-toolbar-group-right" v-bind="ptm('groupright')">
<slot name="end"></slot> <slot name="end"></slot>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import ComponentBase from 'primevue/base';
export default { export default {
name: 'Toolbar', name: 'Toolbar',
extends: ComponentBase,
props: { props: {
'aria-labelledby': { 'aria-labelledby': {
type: String, type: String,