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