mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-30 11:47:55 +01:00
docs(define-shortcuts): update
This commit is contained in:
@@ -95,27 +95,6 @@ defineShortcuts({
|
|||||||
```
|
```
|
||||||
_`enter` shortcut will only trigger when `queryInput` is focused._
|
_`enter` shortcut will only trigger when `queryInput` is focused._
|
||||||
|
|
||||||
### `whenever`
|
|
||||||
|
|
||||||
Prop: `whenever?: WatchSource<boolean>[]`
|
|
||||||
|
|
||||||
`whenever` allows to add constraints on the shortcut triggering behavior. This array can contain `Ref<boolean>`, `ComputedRef<boolean>` or `() => boolean`.
|
|
||||||
|
|
||||||
```ts
|
|
||||||
defineShortcuts({
|
|
||||||
meta_k: {
|
|
||||||
usingInput: true,
|
|
||||||
handler: () => { isOpen.value = !isOpen.value }
|
|
||||||
},
|
|
||||||
escape: {
|
|
||||||
usingInput: true,
|
|
||||||
whenever: [isOpen],
|
|
||||||
handler: () => { isOpen.value = false }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
```
|
|
||||||
_`escape` shortcut will only trigger when `isOpen` is `true`._
|
|
||||||
|
|
||||||
### Simple shortcut
|
### Simple shortcut
|
||||||
|
|
||||||
In case the shortcut does not need any config, it can be written as a function.
|
In case the shortcut does not need any config, it can be written as a function.
|
||||||
|
|||||||
Reference in New Issue
Block a user