From 9c2d39313fd4d82c9cab5a65f3b5b88fe90b9033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Fri, 2 Jun 2023 14:10:18 +0300 Subject: [PATCH] Refactor #3983 - For DataTable --- components/lib/column/Column.d.ts | 49 +++++++++++---------- components/lib/columngroup/ColumnGroup.d.ts | 11 +++++ components/lib/datatable/BodyCell.vue | 41 +++++++++-------- components/lib/datatable/DataTable.d.ts | 4 +- components/lib/datatable/FooterCell.vue | 17 +++++-- components/lib/datatable/HeaderCell.vue | 27 ++++++++---- components/lib/datatable/TableBody.vue | 2 +- components/lib/datatable/TableFooter.vue | 28 ++++++++---- components/lib/datatable/TableHeader.vue | 40 ++++++++++++----- components/lib/row/Row.d.ts | 11 +++++ 10 files changed, 152 insertions(+), 78 deletions(-) diff --git a/components/lib/column/Column.d.ts b/components/lib/column/Column.d.ts index 7cbe89a5b..5d11ee453 100755 --- a/components/lib/column/Column.d.ts +++ b/components/lib/column/Column.d.ts @@ -23,9 +23,8 @@ export declare type ColumnPassThroughOptionType = ColumnPassThroughAttributes | */ export interface ColumnPassThroughMethodOptions { props: ColumnProps; - state: ColumnState; - context: ColumnContext; parent: DataTablePassThroughOptions; + context: ColumnContext; } /** @@ -348,27 +347,6 @@ export interface ColumnState { rowGroupHeaderStyleObject: object; } -/** - * Defines current options in Column component. - */ -export interface ColumnContext { - /** - * Current checked state of row as a boolean. - * @defaultValue false - */ - checked: boolean; - /** - * Current focused state of row as a boolean. - * @defaultValue false - */ - focused: boolean; - /** - * Current disabled state of row as a boolean. - * @defaultValue false - */ - disabled: boolean; -} - /** * Defines valid properties in Column component. */ @@ -579,6 +557,31 @@ export interface ColumnProps { unstyled?: boolean; } +/** + * Defines current options in Column component. + */ +export interface ColumnContext { + /** + * Current index of the column. + */ + index: number; + /** + * Current checked state of row as a boolean. + * @defaultValue false + */ + checked: boolean; + /** + * Current focused state of row as a boolean. + * @defaultValue false + */ + focused: boolean; + /** + * Current disabled state of row as a boolean. + * @defaultValue false + */ + disabled: boolean; +} + /** * Defines valid slots in Column component. */ diff --git a/components/lib/columngroup/ColumnGroup.d.ts b/components/lib/columngroup/ColumnGroup.d.ts index 443c3c055..65360f7cf 100755 --- a/components/lib/columngroup/ColumnGroup.d.ts +++ b/components/lib/columngroup/ColumnGroup.d.ts @@ -16,6 +16,7 @@ export declare type ColumnGroupPassThroughOptionType = ColumnGroupPassThroughAtt export interface ColumnGroupPassThroughMethodOptions { props: ColumnGroupProps; parent: DataTablePassThroughOptions; + context: ColumnGroupContext; } /** @@ -56,6 +57,16 @@ export interface ColumnGroupProps { unstyled?: boolean; } +/** + * Defines current options in ColumnGroup component. + */ +export interface ColumnGroupContext { + /** + * Current type of the column group. + */ + type: string; +} + /** * Defines valid slots in ColumnGroup component. */ diff --git a/components/lib/datatable/BodyCell.vue b/components/lib/datatable/BodyCell.vue index 2aacba596..7dba51f84 100755 --- a/components/lib/datatable/BodyCell.vue +++ b/components/lib/datatable/BodyCell.vue @@ -1,5 +1,5 @@ @@ -202,17 +202,22 @@ export default { columnProp(prop) { return ObjectUtils.getVNodeProp(this.column, prop); }, - getColumnPTOptions(column, key) { - return this.ptmo(this.getColumnProp(column), key, { - props: column.props, + getColumnPT(key) { + const columnMetaData = { + props: this.column.props, parent: { props: this.$props, state: this.$data + }, + context: { + index: this.index } - }); + }; + + return { ...this.ptm(`column.${key}`, { column: columnMetaData }), ...this.ptmo(this.getColumnProp(), key, columnMetaData) }; }, - getColumnProp(column) { - return column.props && column.props.pt ? column.props.pt : undefined; //@todo + getColumnProp() { + return this.column.props && this.column.props.pt ? this.column.props.pt : undefined; }, resolveFieldData() { return ObjectUtils.resolveFieldData(this.rowData, this.field); diff --git a/components/lib/datatable/DataTable.d.ts b/components/lib/datatable/DataTable.d.ts index 486cec708..278f921d7 100755 --- a/components/lib/datatable/DataTable.d.ts +++ b/components/lib/datatable/DataTable.d.ts @@ -596,9 +596,9 @@ export interface DataTablePassThroughOptions { */ rowgroupHeader?: DataTablePassThroughOptionType; /** - * Uses to pass attributes to the row's DOM element. + * Uses to pass attributes to the body row's DOM element. */ - row?: DataTablePassThroughOptionType; + bodyRow?: DataTablePassThroughOptionType; /** * Uses to pass attributes to the row expansion's DOM element. */ diff --git a/components/lib/datatable/FooterCell.vue b/components/lib/datatable/FooterCell.vue index 19907519e..5d9bf4def 100644 --- a/components/lib/datatable/FooterCell.vue +++ b/components/lib/datatable/FooterCell.vue @@ -1,5 +1,5 @@