Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refact(KtTable): declare table emit types #940

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
},
]
}
}
Loading