Fixed #1836 - For DataView
parent
9a9ae8660b
commit
35cf13b8dc
|
@ -1,42 +1,208 @@
|
||||||
import { VNode } from 'vue';
|
import { VNode } from 'vue';
|
||||||
|
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
||||||
|
|
||||||
interface DataViewProps {
|
type DataViewLayoutType = 'list' | 'grid';
|
||||||
value?: any[];
|
|
||||||
layout?: string;
|
type DataTablePositionType = 'top' | 'bottom' | 'both';
|
||||||
rows?: number;
|
|
||||||
first?: number;
|
type DataViewSortFieldType = string | ((item: any) => string);
|
||||||
totalRecords?: number;
|
|
||||||
paginator?: boolean;
|
export interface DataViewPageEvent {
|
||||||
paginatorPosition?: string;
|
/**
|
||||||
alwaysShowPaginator?: boolean;
|
* New page number
|
||||||
paginatorTemplate?: string;
|
*/
|
||||||
pageLinkSize?: number;
|
page: number;
|
||||||
rowsPerPageOptions?: number[];
|
/**
|
||||||
currentPageReportTemplate?: string;
|
* Index of first record
|
||||||
sortField?: string | ((item: any) => any);
|
*/
|
||||||
sortOrder?: number;
|
first: number;
|
||||||
lazy?: boolean;
|
/**
|
||||||
|
* Number of rows to display in new page
|
||||||
|
*/
|
||||||
|
rows: number;
|
||||||
|
/**
|
||||||
|
* Total number of pages
|
||||||
|
*/
|
||||||
|
pageCount: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DataViewSlotInterface {
|
export interface DataViewProps {
|
||||||
data: any;
|
/**
|
||||||
index: number;
|
* An array of objects to display.
|
||||||
|
*/
|
||||||
|
value?: any[] | undefined;
|
||||||
|
/**
|
||||||
|
* Layout of the items, valid values are "list" and "grid".
|
||||||
|
* @see DataViewLayoutType
|
||||||
|
* Default value is 'list'.
|
||||||
|
*/
|
||||||
|
layout?: DataViewLayoutType;
|
||||||
|
/**
|
||||||
|
* Number of rows to display per page.
|
||||||
|
* Default value is 0.
|
||||||
|
*/
|
||||||
|
rows?: number | undefined;
|
||||||
|
/**
|
||||||
|
* Index of the first record to render.
|
||||||
|
* Default value is 0.
|
||||||
|
*/
|
||||||
|
first?: number | undefined;
|
||||||
|
/**
|
||||||
|
* Number of total records, defaults to length of value when not defined.
|
||||||
|
*/
|
||||||
|
totalRecords?: number | undefined;
|
||||||
|
/**
|
||||||
|
* When specified as true, enables the pagination.
|
||||||
|
*/
|
||||||
|
paginator?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* Position of the paginator, options are "top","bottom" or "both".
|
||||||
|
* @see DataTablePositionType
|
||||||
|
* Default value is 'bottom'.
|
||||||
|
*/
|
||||||
|
paginatorPosition?: DataTablePositionType;
|
||||||
|
/**
|
||||||
|
* Whether to show it even there is only one page.
|
||||||
|
* Default value is true.
|
||||||
|
*/
|
||||||
|
alwaysShowPaginator?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* Template of the paginator. It can be customized using the template property using the predefined keys, default value is "FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown". Here are the available elements that can be placed inside a paginator in any order.
|
||||||
|
*
|
||||||
|
* - FirstPageLink
|
||||||
|
* - PrevPageLink
|
||||||
|
* - PageLinks
|
||||||
|
* - NextPageLink
|
||||||
|
* - LastPageLink
|
||||||
|
* - RowsPerPageDropdown
|
||||||
|
* - JumpToPageDropdown
|
||||||
|
* - JumpToPageInput
|
||||||
|
* - CurrentPageReport
|
||||||
|
*/
|
||||||
|
paginatorTemplate?: string | undefined;
|
||||||
|
/**
|
||||||
|
* Number of page links to display.
|
||||||
|
* Default value is 5.
|
||||||
|
*/
|
||||||
|
pageLinkSize?: number | undefined;
|
||||||
|
/**
|
||||||
|
* Array of integer values to display inside rows per page dropdown.
|
||||||
|
*/
|
||||||
|
rowsPerPageOptions?: number[] | undefined;
|
||||||
|
/**
|
||||||
|
* Template of the current page report element. It displays information about the pagination state. Default value is ({currentPage} of {totalPages}) whereas available placeholders are the following;
|
||||||
|
*
|
||||||
|
* - {currentPage}
|
||||||
|
* - {totalPages}
|
||||||
|
* - {rows}
|
||||||
|
* - {first}
|
||||||
|
* - {last}
|
||||||
|
* - {totalRecords}
|
||||||
|
*/
|
||||||
|
currentPageReportTemplate?: string | undefined;
|
||||||
|
/**
|
||||||
|
* Property name or a getter function of data to use in sorting by default.
|
||||||
|
* @see DataViewSortFieldType
|
||||||
|
*/
|
||||||
|
sortField?: DataViewSortFieldType;
|
||||||
|
/**
|
||||||
|
* Order to sort the data by default.
|
||||||
|
*/
|
||||||
|
sortOrder?: number | undefined;
|
||||||
|
/**
|
||||||
|
* Defines if data is loaded and interacted with in lazy manner.
|
||||||
|
*/
|
||||||
|
lazy?: boolean | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare class DataView {
|
export interface DataViewSlots {
|
||||||
$props: DataViewProps;
|
/**
|
||||||
$emit(eventName: 'update:first', value: number): this;
|
* Custom header template.
|
||||||
$emit(eventName: 'update:rows', value: number): this;
|
*/
|
||||||
$emit(eventName: 'page', event: Event): this;
|
header: () => VNode[];
|
||||||
$slots: {
|
/**
|
||||||
header: VNode[];
|
* Custom footer template.
|
||||||
paginatorstart: VNode[];
|
*/
|
||||||
paginatorend: VNode[];
|
footer: () => VNode[];
|
||||||
list: DataViewSlotInterface;
|
/**
|
||||||
grid: DataViewSlotInterface;
|
* Custom empty template.
|
||||||
empty: VNode[];
|
*/
|
||||||
footer: VNode[];
|
empty: () => VNode[];
|
||||||
|
/**
|
||||||
|
* Custom paginator start template.
|
||||||
|
*/
|
||||||
|
paginatorstart: () => VNode[];
|
||||||
|
/**
|
||||||
|
* Custom paginator end template.
|
||||||
|
*/
|
||||||
|
paginatorend: () => VNode[];
|
||||||
|
/**
|
||||||
|
* Custom list template.
|
||||||
|
* @param {Object} scope - list slot's params.
|
||||||
|
*/
|
||||||
|
list: (scope: {
|
||||||
|
/**
|
||||||
|
* Value of the component
|
||||||
|
*/
|
||||||
|
data: any;
|
||||||
|
/**
|
||||||
|
* Index of the grid
|
||||||
|
*/
|
||||||
|
index: number;
|
||||||
|
}) => VNode[];
|
||||||
|
/**
|
||||||
|
* Custom list template.
|
||||||
|
* @param {Object} scope - list slot's params.
|
||||||
|
*/
|
||||||
|
grid: (scope: {
|
||||||
|
/**
|
||||||
|
* Value of the component
|
||||||
|
*/
|
||||||
|
data: any;
|
||||||
|
/**
|
||||||
|
* Index of the grid
|
||||||
|
*/
|
||||||
|
index: number;
|
||||||
|
}) => VNode[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare type DataViewEmits = {
|
||||||
|
/**
|
||||||
|
* Emitted when the first changes.
|
||||||
|
* @param {number} value - New value.
|
||||||
|
*/
|
||||||
|
'update:first': (value: number) => void;
|
||||||
|
/**
|
||||||
|
* Emitted when the rows changes.
|
||||||
|
* @param {number} value - New value.
|
||||||
|
*/
|
||||||
|
'update:rows': (value: number) => void;
|
||||||
|
/**
|
||||||
|
* Callback to invoke when page changes, the event object contains information about the new state.
|
||||||
|
* @param {DataViewPageEvent} event - Custom page event.
|
||||||
|
*/
|
||||||
|
'page': (event: DataViewPageEvent) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare class DataView extends ClassComponent<DataViewProps, DataViewSlots, DataViewEmits> { }
|
||||||
|
|
||||||
|
declare module '@vue/runtime-core' {
|
||||||
|
interface GlobalComponents {
|
||||||
|
DataView: GlobalComponentConstructor<DataView>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* DataView displays data in grid or list layout with pagination and sorting features.
|
||||||
|
*
|
||||||
|
* Helper API:
|
||||||
|
*
|
||||||
|
* - PrimeFlex
|
||||||
|
*
|
||||||
|
* Demos:
|
||||||
|
*
|
||||||
|
* - [DataView](https://www.primefaces.org/primevue/showcase/#/dataview)
|
||||||
|
*
|
||||||
|
*/
|
||||||
export default DataView;
|
export default DataView;
|
||||||
|
|
Loading…
Reference in New Issue