Refactor #3879 - For Inplace
parent
d119005ac9
commit
6467a7d9e7
|
@ -16,6 +16,12 @@ const InplaceProps = [
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: 'false',
|
default: 'false',
|
||||||
description: 'When present, it specifies that the element should be disabled.'
|
description: 'When present, it specifies that the element should be disabled.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'pt',
|
||||||
|
type: 'any',
|
||||||
|
default: 'null',
|
||||||
|
description: 'Uses to pass attributes to DOM elements inside the component.'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,61 @@
|
||||||
import { ButtonHTMLAttributes, HTMLAttributes, VNode } from 'vue';
|
import { ButtonHTMLAttributes, HTMLAttributes, VNode } from 'vue';
|
||||||
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
||||||
|
|
||||||
|
export declare type InplacePassThroughOptionType = InplacePassThroughAttributes | ((options: InplacePassThroughMethodOptions) => InplacePassThroughAttributes) | null | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom passthrough(pt) option method.
|
||||||
|
*/
|
||||||
|
export interface InplacePassThroughMethodOptions {
|
||||||
|
props: InplaceProps;
|
||||||
|
state: InplaceState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom passthrough(pt) options.
|
||||||
|
* @see {@link InplaceProps.pt}
|
||||||
|
*/
|
||||||
|
export interface InplacePassThroughOptions {
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the root's DOM element.
|
||||||
|
*/
|
||||||
|
root?: InplacePassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the display's DOM element.
|
||||||
|
*/
|
||||||
|
display?: InplacePassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the content's DOM element.
|
||||||
|
*/
|
||||||
|
content?: InplacePassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the close button's DOM element.
|
||||||
|
*/
|
||||||
|
closeButton?: InplacePassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the close icon's DOM element.
|
||||||
|
*/
|
||||||
|
closeIcon?: InplacePassThroughOptionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom passthrough attributes for each DOM elements
|
||||||
|
*/
|
||||||
|
export interface InplacePassThroughAttributes {
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines current inline state in Inplace component.
|
||||||
|
*/
|
||||||
|
export interface InplaceState {
|
||||||
|
/**
|
||||||
|
* Current active state as a boolean.
|
||||||
|
* @defaultValue false
|
||||||
|
*/
|
||||||
|
d_active: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines valid properties in Inplace component.
|
* Defines valid properties in Inplace component.
|
||||||
*/
|
*/
|
||||||
|
@ -42,6 +97,11 @@ export interface InplaceProps {
|
||||||
* Uses to pass all properties of the HTMLButtonElement to the close button.
|
* Uses to pass all properties of the HTMLButtonElement to the close button.
|
||||||
*/
|
*/
|
||||||
closeButtonProps?: ButtonHTMLAttributes | undefined;
|
closeButtonProps?: ButtonHTMLAttributes | undefined;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to DOM elements inside the component.
|
||||||
|
* @type {InplacePassThroughOptions}
|
||||||
|
*/
|
||||||
|
pt?: InplacePassThroughOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
<template>
|
<template>
|
||||||
<div v-focustrap :class="containerClass" aria-live="polite">
|
<div v-focustrap :class="containerClass" aria-live="polite" v-bind="ptm('root')">
|
||||||
<div v-if="!d_active" ref="display" :class="displayClass" :tabindex="$attrs.tabindex || '0'" role="button" @click="open" @keydown.enter="open" v-bind="displayProps">
|
<div v-if="!d_active" ref="display" :class="displayClass" :tabindex="$attrs.tabindex || '0'" role="button" @click="open" @keydown.enter="open" v-bind="{ ...displayProps, ...ptm('display') }">
|
||||||
<slot name="display"></slot>
|
<slot name="display"></slot>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="p-inplace-content">
|
<div v-else class="p-inplace-content" v-bind="ptm('content')">
|
||||||
<slot name="content"></slot>
|
<slot name="content"></slot>
|
||||||
<IPButton v-if="closable" :aria-label="closeAriaLabel" @click="close" v-bind="closeButtonProps">
|
<IPButton v-if="closable" :aria-label="closeAriaLabel" @click="close" v-bind="{ ...closeButtonProps, ...ptm('closeButton') }">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<slot name="closeicon">
|
<slot name="closeicon">
|
||||||
<component :is="closeIcon ? 'span' : 'TimesIcon'" :class="closeIcon"></component>
|
<component :is="closeIcon ? 'span' : 'TimesIcon'" :class="closeIcon" v-bind="ptm('closeIcon')"></component>
|
||||||
</slot>
|
</slot>
|
||||||
</template>
|
</template>
|
||||||
</IPButton>
|
</IPButton>
|
||||||
|
@ -17,12 +17,14 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import BaseComponent from 'primevue/basecomponent';
|
||||||
import Button from 'primevue/button';
|
import Button from 'primevue/button';
|
||||||
import FocusTrap from 'primevue/focustrap';
|
import FocusTrap from 'primevue/focustrap';
|
||||||
import TimesIcon from 'primevue/icons/times';
|
import TimesIcon from 'primevue/icons/times';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Inplace',
|
name: 'Inplace',
|
||||||
|
extends: BaseComponent,
|
||||||
emits: ['open', 'close', 'update:active'],
|
emits: ['open', 'close', 'update:active'],
|
||||||
props: {
|
props: {
|
||||||
closable: {
|
closable: {
|
||||||
|
|
Loading…
Reference in New Issue