Refactor #3879 - For Tag
parent
8f923ad130
commit
85ecc09e14
|
@ -22,6 +22,12 @@ const TagProps = [
|
|||
type: 'string',
|
||||
default: 'null',
|
||||
description: 'Icon of the tag to display next to the value.'
|
||||
},
|
||||
{
|
||||
name: 'pt',
|
||||
type: 'any',
|
||||
default: 'null',
|
||||
description: 'Uses to pass attributes to DOM elements inside the component.'
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
@ -10,6 +10,41 @@
|
|||
import { VNode } from 'vue';
|
||||
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
||||
|
||||
export declare type TagPassThroughOptionType = TagPassThroughAttributes | ((options: TagPassThroughMethodOptions) => TagPassThroughAttributes) | null | undefined;
|
||||
|
||||
/**
|
||||
* Custom passthrough(pt) option method.
|
||||
*/
|
||||
export interface TagPassThroughMethodOptions {
|
||||
props: TagProps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom passthrough(pt) options.
|
||||
* @see {@link TagProps.pt}
|
||||
*/
|
||||
export interface TagPassThroughOptions {
|
||||
/**
|
||||
* Uses to pass attributes to the root's DOM element.
|
||||
*/
|
||||
root?: TagPassThroughOptionType;
|
||||
/**
|
||||
* Uses to pass attributes to the icon's DOM element.
|
||||
*/
|
||||
icon?: TagPassThroughOptionType;
|
||||
/**
|
||||
* Uses to pass attributes to the value's DOM element.
|
||||
*/
|
||||
value?: TagPassThroughOptionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom passthrough attributes for each DOM elements
|
||||
*/
|
||||
export interface TagPassThroughAttributes {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines valid properties in Tag component.
|
||||
*/
|
||||
|
@ -32,6 +67,11 @@ export interface TagProps {
|
|||
* @deprecated since v3.27.0. Use 'icon' slot.
|
||||
*/
|
||||
icon?: string | undefined;
|
||||
/**
|
||||
* Uses to pass attributes to DOM elements inside the component.
|
||||
* @type {TagPassThroughOptions}
|
||||
*/
|
||||
pt?: TagPassThroughOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
<template>
|
||||
<span :class="containerClass">
|
||||
<component v-if="$slots.icon" :is="$slots.icon" class="p-tag-icon" />
|
||||
<span v-else-if="icon" :class="iconClass"></span>
|
||||
<span :class="containerClass" v-bind="ptm('root')">
|
||||
<component v-if="$slots.icon" :is="$slots.icon" class="p-tag-icon" v-bind="ptm('icon')" />
|
||||
<span v-else-if="icon" :class="iconClass" v-bind="ptm('icon')"></span>
|
||||
<slot>
|
||||
<span class="p-tag-value">{{ value }}</span>
|
||||
<span class="p-tag-value" v-bind="ptm('value')">{{ value }}</span>
|
||||
</slot>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import BaseComponent from 'primevue/basecomponent';
|
||||
|
||||
export default {
|
||||
name: 'Tag',
|
||||
extends: BaseComponent,
|
||||
props: {
|
||||
value: null,
|
||||
severity: null,
|
||||
|
|
Loading…
Reference in New Issue