mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 20:19:34 +01:00
chore(defineShortcuts): config prop whenever more flexible (#149)
This commit is contained in:
committed by
GitHub
parent
8830d848fd
commit
b85a8e7203
@@ -1,4 +1,4 @@
|
||||
import type { Ref, ComputedRef } from 'vue'
|
||||
import type { ComputedRef, WatchSource } from 'vue'
|
||||
import { logicAnd, logicNot } from '@vueuse/math'
|
||||
import { computed, onMounted, onBeforeUnmount } from 'vue'
|
||||
import { useShortcuts } from './useShortcuts'
|
||||
@@ -6,7 +6,7 @@ import { useShortcuts } from './useShortcuts'
|
||||
export interface ShortcutConfig {
|
||||
handler: Function
|
||||
usingInput?: string | boolean
|
||||
whenever?: Ref<Boolean>[]
|
||||
whenever?: WatchSource<Boolean>[]
|
||||
}
|
||||
|
||||
export interface ShortcutsConfig {
|
||||
@@ -89,7 +89,7 @@ export const defineShortcuts = (config: ShortcutsConfig) => {
|
||||
}
|
||||
|
||||
// Create shortcut computed
|
||||
const conditions = []
|
||||
const conditions: ComputedRef<Boolean>[] = []
|
||||
if (!(shortcutConfig as ShortcutConfig).usingInput) {
|
||||
conditions.push(logicNot(usingInput))
|
||||
} else if (typeof (shortcutConfig as ShortcutConfig).usingInput === 'string') {
|
||||
|
||||
Reference in New Issue
Block a user