diff --git a/src/runtime/components/Table.vue b/src/runtime/components/Table.vue
index 1773d276..f50001cc 100644
--- a/src/runtime/components/Table.vue
+++ b/src/runtime/components/Table.vue
@@ -165,6 +165,7 @@ export interface TableProps extends TableOption
*/
facetedOptions?: FacetedOptions
onSelect?: (row: TableRow, e?: Event) => void
+ onContextmenu?: ((e: Event, row: TableRow) => void) | Array<((e: Event, row: TableRow) => void)>
class?: any
ui?: Table['slots']
}
@@ -313,7 +314,7 @@ function valueUpdater>(updaterOrValue: T, ref: Ref) {
ref.value = typeof updaterOrValue === 'function' ? updaterOrValue(ref.value) : updaterOrValue
}
-function handleRowSelect(row: TableRow, e: Event) {
+function onRowSelect(e: Event, row: TableRow) {
if (!props.onSelect) {
return
}
@@ -326,9 +327,22 @@ function handleRowSelect(row: TableRow, e: Event) {
e.preventDefault()
e.stopPropagation()
+ // FIXME: `e` should be the first argument for consistency
props.onSelect(row, e)
}
+function onRowContextmenu(e: Event, row: TableRow) {
+ if (!props.onContextmenu) {
+ return
+ }
+
+ if (Array.isArray(props.onContextmenu)) {
+ props.onContextmenu.forEach(fn => fn(e, row))
+ } else {
+ props.onContextmenu(e, row)
+ }
+}
+
watch(
() => props.data, () => {
data.value = props.data ? [...props.data] : []
@@ -382,7 +396,7 @@ defineExpose({
|