Refactor #3885 - For OverlayPanel
parent
d8c6920efd
commit
02c1df8932
|
@ -46,6 +46,12 @@ const OverlayPanelProps = [
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: 'undefined',
|
default: 'undefined',
|
||||||
description: 'Display a custom close icon for the message.'
|
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,57 @@
|
||||||
import { VNode } from 'vue';
|
import { VNode } from 'vue';
|
||||||
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
||||||
|
|
||||||
|
export declare type OverlayPanelPassThroughOptionType = OverlayPanelPassThroughAttributes | ((options: OverlayPanelPassThroughMethodOptions) => OverlayPanelPassThroughAttributes) | null | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom passthrough(pt) option method.
|
||||||
|
*/
|
||||||
|
export interface OverlayPanelPassThroughMethodOptions {
|
||||||
|
props: OverlayPanelProps;
|
||||||
|
state: OverlayPanelState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom passthrough(pt) options.
|
||||||
|
* @see {@link OverlayPanelProps.pt}
|
||||||
|
*/
|
||||||
|
export interface OverlayPanelPassThroughOptions {
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the root's DOM element.
|
||||||
|
*/
|
||||||
|
root?: OverlayPanelPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the content's DOM element.
|
||||||
|
*/
|
||||||
|
content?: OverlayPanelPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the close button's DOM element.
|
||||||
|
*/
|
||||||
|
closeButton?: OverlayPanelPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the close icon's DOM element.
|
||||||
|
*/
|
||||||
|
closeIcon?: OverlayPanelPassThroughOptionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom passthrough attributes for each DOM elements
|
||||||
|
*/
|
||||||
|
export interface OverlayPanelPassThroughAttributes {
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines current inline state in OverlayPanel component.
|
||||||
|
*/
|
||||||
|
export interface OverlayPanelState {
|
||||||
|
/**
|
||||||
|
* Current visible state as a boolean.
|
||||||
|
* @defaultValue false
|
||||||
|
*/
|
||||||
|
visible: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OverlayPanel breakpoint metadata.
|
* OverlayPanel breakpoint metadata.
|
||||||
*/
|
*/
|
||||||
|
@ -70,6 +121,11 @@ export interface OverlayPanelProps {
|
||||||
* @deprecated since v3.27.0. Use 'closeicon' slot.
|
* @deprecated since v3.27.0. Use 'closeicon' slot.
|
||||||
*/
|
*/
|
||||||
closeIcon?: string | undefined;
|
closeIcon?: string | undefined;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to DOM elements inside the component.
|
||||||
|
* @type {OverlayPanelPassThroughOptions}
|
||||||
|
*/
|
||||||
|
pt?: OverlayPanelPassThroughOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
<template>
|
<template>
|
||||||
<Portal :appendTo="appendTo">
|
<Portal :appendTo="appendTo">
|
||||||
<transition name="p-overlaypanel" @enter="onEnter" @leave="onLeave" @after-leave="onAfterLeave">
|
<transition name="p-overlaypanel" @enter="onEnter" @leave="onLeave" @after-leave="onAfterLeave">
|
||||||
<div v-if="visible" :ref="containerRef" v-focustrap role="dialog" :class="containerClass" :aria-modal="visible" @click="onOverlayClick" v-bind="$attrs">
|
<div v-if="visible" :ref="containerRef" v-focustrap role="dialog" :class="containerClass" :aria-modal="visible" @click="onOverlayClick" v-bind="{ ...$attrs, ...ptm('root') }">
|
||||||
<div class="p-overlaypanel-content" @click="onContentClick" @mousedown="onContentClick" @keydown="onContentKeydown">
|
<div class="p-overlaypanel-content" @click="onContentClick" @mousedown="onContentClick" @keydown="onContentKeydown" v-bind="ptm('content')">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
<button v-if="showCloseIcon" v-ripple class="p-overlaypanel-close p-link" :aria-label="closeAriaLabel" type="button" autofocus @click="hide" @keydown="onButtonKeydown">
|
<button v-if="showCloseIcon" v-ripple class="p-overlaypanel-close p-link" :aria-label="closeAriaLabel" type="button" autofocus @click="hide" @keydown="onButtonKeydown" v-bind="ptm('closeButton')">
|
||||||
<slot name="closeicon">
|
<slot name="closeicon">
|
||||||
<component :is="closeIcon ? 'span' : 'TimesIcon'" :class="['p-overlaypanel-close-icon ', closeIcon]"></component>
|
<component :is="closeIcon ? 'span' : 'TimesIcon'" :class="['p-overlaypanel-close-icon ', closeIcon]" v-bind="ptm('closeIcon')"></component>
|
||||||
</slot>
|
</slot>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -16,6 +16,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import BaseComponent from 'primevue/basecomponent';
|
||||||
import FocusTrap from 'primevue/focustrap';
|
import FocusTrap from 'primevue/focustrap';
|
||||||
import TimesIcon from 'primevue/icons/times';
|
import TimesIcon from 'primevue/icons/times';
|
||||||
import OverlayEventBus from 'primevue/overlayeventbus';
|
import OverlayEventBus from 'primevue/overlayeventbus';
|
||||||
|
@ -25,6 +26,7 @@ import { ConnectedOverlayScrollHandler, DomHandler, UniqueComponentId, ZIndexUti
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'OverlayPanel',
|
name: 'OverlayPanel',
|
||||||
|
extends: BaseComponent,
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
emits: ['show', 'hide'],
|
emits: ['show', 'hide'],
|
||||||
props: {
|
props: {
|
||||||
|
|
Loading…
Reference in New Issue