Skip to content

Commit

Permalink
refact(KtTable): declare table emit types
Browse files Browse the repository at this point in the history
  • Loading branch information
Isokaeder committed Jun 20, 2024
1 parent aeaff40 commit 893a884
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/kotti-ui/source/kotti-table/logic/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class TableStore {
}
}

emit(event: any, ...args: any) {
emit<T extends keyof Store.Emits>(event: T, ...args: Store.Emits[T]) {
this.table.$emit(event, ...args)
}
}
29 changes: 29 additions & 0 deletions packages/kotti-ui/source/kotti-table/logic/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,33 @@ export module Store {
) => void
? P
: never

export type Emits = {
columnsChange: [
Pick<State['_columnsArray'][0], 'prop' | 'order' | 'hidden'>[],
]
expandChange: [State['expanded']]
expand: [any, boolean]
hiddenChange: [State['hiddenColumns']]
orderChange: [
// Likely can be refactored to KottiTable.Column.Ordered[]
Pick<State['_columnsArray'][0], 'prop' | 'order'>[],
]
selectionChange: [State['selection']]
select: [State['selection'], any]
selectAll: [State['selection']]
sortChange: [
{
// Likely can be refactored to KottiTable.Column.Sorted[]
sortedColumns: Pick<
State['sortedColumns'],
'prop' | 'sortOrder' | 'sortBy'
>[]
column: any
prop: any // Likely string
sortBy: any // Likely KottiTable.SortBy | string
sortOrder: any // Likely KottiTable.SortOrder
},
]
}
}

0 comments on commit 893a884

Please sign in to comment.