Merge pull request #7214 from SamVanini/feat/7194-add-datatable-generics

feat(datatable): Added generics to type data and newData #7194
pull/6937/merge
Tuğçe Küçükoğlu 2025-02-07 10:03:26 +03:00 committed by GitHub
commit d2d861a6ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 36 additions and 36 deletions

View File

@ -73,11 +73,11 @@ export interface DataTableSharedPassThroughMethodOptions {
/** /**
* Custom datatable export metadata. * Custom datatable export metadata.
*/ */
export interface DataTableExportFunctionOptions { export interface DataTableExportFunctionOptions<T = any> {
/** /**
* Row data * Row data
*/ */
data: any; data: T;
/** /**
* Column Field * Column Field
*/ */
@ -300,7 +300,7 @@ export interface DataTableFilterEvent extends DataTableSortEvent {
* Custom row click event. * Custom row click event.
* @see {@link DataTableEmitsOptions['row-click']} * @see {@link DataTableEmitsOptions['row-click']}
*/ */
export interface DataTableRowClickEvent { export interface DataTableRowClickEvent<T = any> {
/** /**
* Browser event. * Browser event.
*/ */
@ -308,7 +308,7 @@ export interface DataTableRowClickEvent {
/** /**
* Selected row data. * Selected row data.
*/ */
data: any; data: T;
/** /**
* Row index. * Row index.
*/ */
@ -333,7 +333,7 @@ export interface DataTableRowContextMenuEvent extends DataTableRowClickEvent {}
* Custom row select event. * Custom row select event.
* @see {@link DataTableEmitsOptions['row-select']} * @see {@link DataTableEmitsOptions['row-select']}
*/ */
export interface DataTableRowSelectEvent { export interface DataTableRowSelectEvent<T = any> {
/** /**
* Browser event * Browser event
*/ */
@ -341,7 +341,7 @@ export interface DataTableRowSelectEvent {
/** /**
* Selected row data * Selected row data
*/ */
data: any; data: T;
/** /**
* Row index * Row index
*/ */
@ -363,7 +363,7 @@ export interface DataTableRowUnselectEvent extends DataTableRowSelectEvent {}
* Custom row select all event. * Custom row select all event.
* @see {@link DataTableEmitsOptions['row-select-all']} * @see {@link DataTableEmitsOptions['row-select-all']}
*/ */
export interface DataTableRowSelectAllEvent { export interface DataTableRowSelectAllEvent<T = any> {
/** /**
* Browser event * Browser event
*/ */
@ -371,7 +371,7 @@ export interface DataTableRowSelectAllEvent {
/** /**
* Selected dataset * Selected dataset
*/ */
data: any; data: T;
} }
/** /**
@ -461,7 +461,7 @@ export interface DataTableRowReorderEvent {
* Custom row expand event. * Custom row expand event.
* @see {@link DataTableEmitsOptions['row-expand']} * @see {@link DataTableEmitsOptions['row-expand']}
*/ */
export interface DataTableRowExpandEvent { export interface DataTableRowExpandEvent<T = any> {
/** /**
* Browser event * Browser event
*/ */
@ -469,7 +469,7 @@ export interface DataTableRowExpandEvent {
/** /**
* Expanded row data * Expanded row data
*/ */
data: any; data: T;
} }
/** /**
@ -483,7 +483,7 @@ export interface DataTableRowCollapseEvent extends DataTableRowExpandEvent {}
* Custom cell edit init event. * Custom cell edit init event.
* @see {@link DataTableEmitsOptions['cell-edit-init']} * @see {@link DataTableEmitsOptions['cell-edit-init']}
*/ */
export interface DataTableCellEditInitEvent { export interface DataTableCellEditInitEvent<T = any> {
/** /**
* Browser event * Browser event
*/ */
@ -491,7 +491,7 @@ export interface DataTableCellEditInitEvent {
/** /**
* Row data to edit. * Row data to edit.
*/ */
data: any; data: T;
/** /**
* Field name of the row data. * Field name of the row data.
*/ */
@ -513,7 +513,7 @@ export interface DataTableCellEditCancelEvent extends DataTableCellEditInitEvent
* Custom cell edit complete event. * Custom cell edit complete event.
* @see {@link DataTableEmitsOptions['cell-edit-complete']} * @see {@link DataTableEmitsOptions['cell-edit-complete']}
*/ */
export interface DataTableCellEditCompleteEvent { export interface DataTableCellEditCompleteEvent<T = any> {
/** /**
* Browser event * Browser event
*/ */
@ -521,11 +521,11 @@ export interface DataTableCellEditCompleteEvent {
/** /**
* Row data to edit. * Row data to edit.
*/ */
data: any; data: T;
/** /**
* New row data after editing. * New row data after editing.
*/ */
newData: any; newData: T;
/** /**
* Field value of row data to edit. * Field value of row data to edit.
*/ */
@ -552,7 +552,7 @@ export interface DataTableCellEditCompleteEvent {
* Custom row edit init event. * Custom row edit init event.
* @see {@link DataTableEmitsOptions['row-edit-init']} * @see {@link DataTableEmitsOptions['row-edit-init']}
*/ */
export interface DataTableRowEditInitEvent { export interface DataTableRowEditInitEvent<T = any> {
/** /**
* Browser event * Browser event
*/ */
@ -560,11 +560,11 @@ export interface DataTableRowEditInitEvent {
/** /**
* Row data to edit. * Row data to edit.
*/ */
data: any; data: T;
/** /**
* New row data after editing. * New row data after editing.
*/ */
newData: any; newData: T;
/** /**
* Field name of the row data. * Field name of the row data.
*/ */
@ -580,14 +580,14 @@ export interface DataTableRowEditInitEvent {
* @see {@link DataTableEmitsOptions['row-edit-save']} * @see {@link DataTableEmitsOptions['row-edit-save']}
* @extends DataTableRowEditInitEvent * @extends DataTableRowEditInitEvent
*/ */
export interface DataTableRowEditSaveEvent extends DataTableRowEditInitEvent {} export interface DataTableRowEditSaveEvent<T = any> extends DataTableRowEditInitEvent<T> {}
/** /**
* Custom row edit cancel event. * Custom row edit cancel event.
* @see {@link DataTableEmitsOptions['row-edit-cancel']} * @see {@link DataTableEmitsOptions['row-edit-cancel']}
* @extends DataTableRowEditCancelEvent * @extends DataTableRowEditCancelEvent
*/ */
export interface DataTableRowEditCancelEvent extends DataTableRowEditInitEvent {} export interface DataTableRowEditCancelEvent<T = any> extends DataTableRowEditInitEvent<T> {}
/** /**
* Custom state event. * Custom state event.
@ -880,7 +880,7 @@ export interface DataTableContext {
/** /**
* Defines valid properties in DataTable component. * Defines valid properties in DataTable component.
*/ */
export interface DataTableProps { export interface DataTableProps<T = any> {
/** /**
* An array of objects to display. * An array of objects to display.
*/ */
@ -1013,7 +1013,7 @@ export interface DataTableProps {
/** /**
* An array of fields as string or function to use in global filtering. * An array of fields as string or function to use in global filtering.
*/ */
globalFilterFields?: (string | ((data: any) => string))[] | undefined; globalFilterFields?: (string | ((data: T) => string))[] | undefined;
/** /**
* Locale to use in filtering. The default locale is the host environment's current locale. * Locale to use in filtering. The default locale is the host environment's current locale.
*/ */
@ -1021,7 +1021,7 @@ export interface DataTableProps {
/** /**
* Selected row in single mode or an array of values in multiple mode. * Selected row in single mode or an array of values in multiple mode.
*/ */
selection?: any[] | any | undefined; selection?: T[] | T | undefined;
/** /**
* Specifies the selection mode. * Specifies the selection mode.
*/ */
@ -1129,18 +1129,18 @@ export interface DataTableProps {
/** /**
* A collection of rows to represent the current editing data in row edit mode. * A collection of rows to represent the current editing data in row edit mode.
*/ */
editingRows?: any[] | DataTableEditingRows; editingRows?: T[] | DataTableEditingRows;
/** /**
* A function that takes the row data as a parameter and returns a string to apply a particular class for the row. * A function that takes the row data as a parameter and returns a string to apply a particular class for the row.
* The return value is added to the row's :classes array (see Vue.js class bindings). * The return value is added to the row's :classes array (see Vue.js class bindings).
*/ */
rowClass?: (data: any) => string | object | undefined; rowClass?: (data: T) => string | object | undefined;
/** /**
* A function that takes the row data as a parameter and returns the inline style object for the corresponding row. * A function that takes the row data as a parameter and returns the inline style object for the corresponding row.
* The function may also return an array of style objects which will be merged. * The function may also return an array of style objects which will be merged.
* The return value of this function is directly applied as a Vue.js style-binding on the table row. * The return value of this function is directly applied as a Vue.js style-binding on the table row.
*/ */
rowStyle?: (data: any) => object | object[] | undefined; rowStyle?: (data: T) => object | object[] | undefined;
/** /**
* When specified, enables horizontal and/or vertical scrolling. * When specified, enables horizontal and/or vertical scrolling.
* @defaultValue false * @defaultValue false
@ -1253,7 +1253,7 @@ export interface DataTableProps {
/** /**
* Defines valid slots in DataTable component. * Defines valid slots in DataTable component.
*/ */
export interface DataTableSlots { export interface DataTableSlots<T = any> {
/** /**
* Custom header template. * Custom header template.
*/ */
@ -1274,7 +1274,7 @@ export interface DataTableSlots {
/** /**
* Row data * Row data
*/ */
data: any; data: T;
/** /**
* Row index * Row index
*/ */
@ -1288,7 +1288,7 @@ export interface DataTableSlots {
/** /**
* Row data * Row data
*/ */
data: any; data: T;
/** /**
* Row index * Row index
*/ */
@ -1307,7 +1307,7 @@ export interface DataTableSlots {
/** /**
* Row data * Row data
*/ */
data: any; data: T;
/** /**
* Row index * Row index
*/ */
@ -1471,7 +1471,7 @@ export interface DataTableSlots {
/** /**
* Defines valid emits in Datatable component. * Defines valid emits in Datatable component.
*/ */
export interface DataTableEmitsOptions { export interface DataTableEmitsOptions<T = any> {
/** /**
* Emitted when the first changes. * Emitted when the first changes.
* @param {number} value - New value. * @param {number} value - New value.
@ -1501,7 +1501,7 @@ export interface DataTableEmitsOptions {
* Emitted when the selection changes. * Emitted when the selection changes.
* @param {*} value - New value. * @param {*} value - New value.
*/ */
'update:selection'(value: any[] | any | undefined): void; 'update:selection'(value: T[] | T | undefined): void;
/** /**
* Emitted when the contextMenuSelection changes. * Emitted when the contextMenuSelection changes.
* @param {*} value - New value. * @param {*} value - New value.
@ -1511,12 +1511,12 @@ export interface DataTableEmitsOptions {
* Emitted when the expandedRows changes. * Emitted when the expandedRows changes.
* @param {DataTableExpandedRows} value - New value. * @param {DataTableExpandedRows} value - New value.
*/ */
'update:expandedRows'(value: any[] | DataTableExpandedRows): void; 'update:expandedRows'(value: T[] | DataTableExpandedRows): void;
/** /**
* Emitted when the expandedRowGroups changes. * Emitted when the expandedRowGroups changes.
* @param {DataTableExpandedRows} value - New value. * @param {DataTableExpandedRows} value - New value.
*/ */
'update:expandedRowGroups'(value: any[] | DataTableExpandedRows): void; 'update:expandedRowGroups'(value: T[] | DataTableExpandedRows): void;
/** /**
* Emitted when the filters changes. * Emitted when the filters changes.
* @param {DataTableFilterMeta} value - New value. * @param {DataTableFilterMeta} value - New value.
@ -1526,7 +1526,7 @@ export interface DataTableEmitsOptions {
* Emitted when the editingRows changes. * Emitted when the editingRows changes.
* @param {DataTableEditingRows} value - New value. * @param {DataTableEditingRows} value - New value.
*/ */
'update:editingRows'(value: any[] | DataTableEditingRows): void; 'update:editingRows'(value: T[] | DataTableEditingRows): void;
/** /**
* Callback to invoke on pagination. Sort and Filter information is also available for lazy loading implementation. * Callback to invoke on pagination. Sort and Filter information is also available for lazy loading implementation.
* @param {DataTablePageEvent} event - Custom page event. * @param {DataTablePageEvent} event - Custom page event.
@ -1546,7 +1546,7 @@ export interface DataTableEmitsOptions {
* Callback to invoke after filtering, sorting, pagination and cell editing to pass the rendered value. * Callback to invoke after filtering, sorting, pagination and cell editing to pass the rendered value.
* @param {*} value - Value displayed by the table. * @param {*} value - Value displayed by the table.
*/ */
'value-change'(value: any[]): void; 'value-change'(value: T[]): void;
/** /**
* Callback to invoke when a row is clicked. * Callback to invoke when a row is clicked.
* @param {DataTableRowClickEvent} event - Custom row click event. * @param {DataTableRowClickEvent} event - Custom row click event.