mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-27 10:20:42 +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 { logicAnd, logicNot } from '@vueuse/math'
|
||||||
import { computed, onMounted, onBeforeUnmount } from 'vue'
|
import { computed, onMounted, onBeforeUnmount } from 'vue'
|
||||||
import { useShortcuts } from './useShortcuts'
|
import { useShortcuts } from './useShortcuts'
|
||||||
@@ -6,7 +6,7 @@ import { useShortcuts } from './useShortcuts'
|
|||||||
export interface ShortcutConfig {
|
export interface ShortcutConfig {
|
||||||
handler: Function
|
handler: Function
|
||||||
usingInput?: string | boolean
|
usingInput?: string | boolean
|
||||||
whenever?: Ref<Boolean>[]
|
whenever?: WatchSource<Boolean>[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ShortcutsConfig {
|
export interface ShortcutsConfig {
|
||||||
@@ -89,7 +89,7 @@ export const defineShortcuts = (config: ShortcutsConfig) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create shortcut computed
|
// Create shortcut computed
|
||||||
const conditions = []
|
const conditions: ComputedRef<Boolean>[] = []
|
||||||
if (!(shortcutConfig as ShortcutConfig).usingInput) {
|
if (!(shortcutConfig as ShortcutConfig).usingInput) {
|
||||||
conditions.push(logicNot(usingInput))
|
conditions.push(logicNot(usingInput))
|
||||||
} else if (typeof (shortcutConfig as ShortcutConfig).usingInput === 'string') {
|
} else if (typeof (shortcutConfig as ShortcutConfig).usingInput === 'string') {
|
||||||
|
|||||||
Reference in New Issue
Block a user