Refactor #3797 - DeferredContent updates

pull/3841/head
Tuğçe Küçükoğlu 2023-03-24 18:29:46 +03:00
parent 02307960ec
commit f5f92807c5
3 changed files with 63 additions and 2 deletions

View File

@ -1,3 +1,12 @@
const DeferredContentProps = [
{
name: 'pt',
type: 'any',
default: 'null',
description: 'Uses to pass attributes to DOM elements inside the component.'
}
];
const DeferredContentEvents = [ const DeferredContentEvents = [
{ {
name: 'load', name: 'load',
@ -16,6 +25,7 @@ module.exports = {
deferredcontent: { deferredcontent: {
name: 'DeferredContent', name: 'DeferredContent',
description: 'DeferredContent postpones the loading the content that is initially not in the viewport until it becomes visible on scroll.', description: 'DeferredContent postpones the loading the content that is initially not in the viewport until it becomes visible on scroll.',
props: DeferredContentProps,
events: DeferredContentEvents events: DeferredContentEvents
} }
}; };

View File

@ -10,7 +10,55 @@
import { VNode } from 'vue'; import { VNode } from 'vue';
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
export interface DeferredContentProps {} export declare type DeferredContentPassThroughOptionType = DeferredContentPassThroughAttributes | ((options: DeferredContentPassThroughMethodOptions) => DeferredContentPassThroughAttributes) | null | undefined;
/**
* Custom passthrough(pt) option method.
*/
export interface DeferredContentPassThroughMethodOptions {
props: DeferredContentProps;
state: DeferredContentState;
}
/**
* Custom passthrough(pt) options.
* @see {@link DeferredContentProps.pt}
*/
export interface DeferredContentPassThroughOptions {
/**
* Uses to pass attributes to the root's DOM element.
*/
root?: DeferredContentPassThroughOptionType;
}
/**
* Custom passthrough attributes for each DOM elements
*/
export interface DeferredContentPassThroughAttributes {
[key: string]: any;
}
/**
* Defines current inline state in DeferredContent component.
*/
export interface DeferredContentState {
/**
* Current loaded state as a boolean.
* @defaultValue false
*/
loaded?: boolean;
}
/**
* Defines valid props in DeferredContent component.
*/
export interface DeferredContentProps {
/**
* Uses to pass attributes to DOM elements inside the component.
* @type {DeferredContentPassThroughOptions}
*/
pt?: DeferredContentPassThroughOptions;
}
/** /**
* Defines valid slots in DeferredContent component. * Defines valid slots in DeferredContent component.

View File

@ -1,12 +1,15 @@
<template> <template>
<div ref="container"> <div ref="container" v-bind="ptm('root')">
<slot v-if="loaded"></slot> <slot v-if="loaded"></slot>
</div> </div>
</template> </template>
<script> <script>
import ComponentBase from 'primevue/base';
export default { export default {
name: 'DeferredContent', name: 'DeferredContent',
extends: ComponentBase,
emits: ['load'], emits: ['load'],
data() { data() {
return { return {