Refactor #3911 - For Message
parent
c7bc9450f8
commit
6ec5a5c8b3
|
@ -34,6 +34,12 @@ const MessageProps = [
|
|||
type: 'string',
|
||||
default: 'undefined',
|
||||
description: 'Display a custom close icon for the message.'
|
||||
},
|
||||
{
|
||||
name: 'pt',
|
||||
type: 'any',
|
||||
default: 'null',
|
||||
description: 'Uses to pass attributes to DOM elements inside the component.'
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
@ -10,6 +10,65 @@
|
|||
import { ButtonHTMLAttributes, VNode } from 'vue';
|
||||
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
||||
|
||||
export declare type MessagePassThroughOptionType = MessagePassThroughAttributes | ((options: MessagePassThroughMethodOptions) => MessagePassThroughAttributes) | null | undefined;
|
||||
|
||||
/**
|
||||
* Custom passthrough(pt) option method.
|
||||
*/
|
||||
export interface MessagePassThroughMethodOptions {
|
||||
props: MessageProps;
|
||||
state: MessageState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom passthrough(pt) options.
|
||||
* @see {@link MessageProps.pt}
|
||||
*/
|
||||
export interface MessagePassThroughOptions {
|
||||
/**
|
||||
* Uses to pass attributes to the root's DOM element.
|
||||
*/
|
||||
root?: MessagePassThroughOptionType;
|
||||
/**
|
||||
* Uses to pass attributes to the wrapper's DOM element.
|
||||
*/
|
||||
wrapper?: MessagePassThroughOptionType;
|
||||
/**
|
||||
* Uses to pass attributes to the icon's DOM element.
|
||||
*/
|
||||
icon?: MessagePassThroughOptionType;
|
||||
/**
|
||||
* Uses to pass attributes to the text's DOM element.
|
||||
*/
|
||||
text?: MessagePassThroughOptionType;
|
||||
/**
|
||||
* Uses to pass attributes to the button's DOM element.
|
||||
*/
|
||||
button?: MessagePassThroughOptionType;
|
||||
/**
|
||||
* Uses to pass attributes to the button icon's DOM element.
|
||||
*/
|
||||
buttonIcon?: MessagePassThroughOptionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom passthrough attributes for each DOM elements
|
||||
*/
|
||||
export interface MessagePassThroughAttributes {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines current inline state in Message component.
|
||||
*/
|
||||
export interface MessageState {
|
||||
/**
|
||||
* Current visible state as a boolean.
|
||||
* @defaultValue false
|
||||
*/
|
||||
visible: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines valid properties in Message component.
|
||||
*/
|
||||
|
@ -45,7 +104,6 @@ export interface MessageProps {
|
|||
closeIcon?: string | undefined;
|
||||
/**
|
||||
* Uses to pass all properties of the HTMLButtonElement to the close button.
|
||||
* @deprecated since v3.26.0. Use 'pt' property.
|
||||
*/
|
||||
closeButtonProps?: ButtonHTMLAttributes | undefined;
|
||||
}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
<template>
|
||||
<transition name="p-message" appear>
|
||||
<div v-show="visible" :class="containerClass" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="p-message-wrapper">
|
||||
<div v-show="visible" :class="containerClass" role="alert" aria-live="assertive" aria-atomic="true" v-bind="ptm('root')">
|
||||
<div class="p-message-wrapper" v-bind="ptm('wrapper')">
|
||||
<slot name="messageicon" class="p-message-icon">
|
||||
<component :is="icon ? 'span' : iconComponent" :class="['p-message-icon', icon]"></component>
|
||||
<component :is="icon ? 'span' : iconComponent" :class="['p-message-icon', icon]" v-bind="ptm('icon')"></component>
|
||||
</slot>
|
||||
<div class="p-message-text">
|
||||
<div class="p-message-text" v-bind="ptm('text')">
|
||||
<slot></slot>
|
||||
</div>
|
||||
<button v-if="closable" v-ripple class="p-message-close p-link" :aria-label="closeAriaLabel" type="button" @click="close($event)" v-bind="closeButtonProps">
|
||||
<button v-if="closable" v-ripple class="p-message-close p-link" :aria-label="closeAriaLabel" type="button" @click="close($event)" v-bind="{ ...closeButtonProps, ...ptm('button') }">
|
||||
<slot name="closeicon" class="p-message-close-icon">
|
||||
<i v-if="closeIcon" :class="['p-message-close-icon', closeIcon]" />
|
||||
<TimesIcon v-else class="p-message-close-icon" />
|
||||
<i v-if="closeIcon" :class="['p-message-close-icon', closeIcon]" v-bind="ptm('buttonIcon')" />
|
||||
<TimesIcon v-else class="p-message-close-icon" v-bind="ptm('buttonIcon')" />
|
||||
</slot>
|
||||
</button>
|
||||
</div>
|
||||
|
@ -20,6 +20,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import BaseComponent from 'primevue/basecomponent';
|
||||
import CheckIcon from 'primevue/icons/check';
|
||||
import ExclamationTriangleIcon from 'primevue/icons/exclamationtriangle';
|
||||
import InfoCircleIcon from 'primevue/icons/infocircle';
|
||||
|
@ -29,6 +30,7 @@ import Ripple from 'primevue/ripple';
|
|||
|
||||
export default {
|
||||
name: 'Message',
|
||||
extends: BaseComponent,
|
||||
emits: ['close'],
|
||||
props: {
|
||||
severity: {
|
||||
|
|
Loading…
Reference in New Issue