diff --git a/package.json b/package.json
index c6dd1c0..92afbf2 100644
--- a/package.json
+++ b/package.json
@@ -27,15 +27,15 @@
},
"devDependencies": {
"@iconify/svelte": "^3.1.0",
- "@playwright/test": "^1.31.0",
+ "@playwright/test": "^1.31.1",
"@sveltejs/adapter-static": "^2.0.1",
- "@sveltejs/kit": "^1.8.3",
+ "@sveltejs/kit": "^1.9.2",
"@sveltejs/package": "2.0.2",
- "@sveltejs/vite-plugin-svelte": "^2.0.2",
- "@typescript-eslint/eslint-plugin": "^5.53.0",
- "@typescript-eslint/parser": "^5.53.0",
- "@vitest/coverage-c8": "^0.28.5",
- "eslint": "^8.34.0",
+ "@sveltejs/vite-plugin-svelte": "^2.0.3",
+ "@typescript-eslint/eslint-plugin": "^5.54.0",
+ "@typescript-eslint/parser": "^5.54.0",
+ "@vitest/coverage-c8": "^0.29.2",
+ "eslint": "^8.35.0",
"eslint-plugin-svelte3": "^4.0.0",
"hastscript": "^7.2.0",
"highlight.js": "^11.7.0",
@@ -46,14 +46,14 @@
"prettier-plugin-svelte": "^2.9.0",
"rehype-autolink-headings": "^6.1.1",
"rehype-slug": "^5.1.0",
- "svelte-check": "^3.0.3",
+ "svelte-check": "^3.0.4",
"svelte-preprocess": "^5.0.1",
"svelte-toc": "^0.5.2",
"svelte-zoo": "^0.3.4",
- "svelte2tsx": "^0.6.1",
+ "svelte2tsx": "^0.6.2",
"typescript": "^4.9.5",
"vite": "^4.1.4",
- "vitest": "^0.28.5"
+ "vitest": "^0.29.2"
},
"keywords": [
"svelte",
diff --git a/src/lib/MultiSelect.svelte b/src/lib/MultiSelect.svelte
index 9bb829b..6e26108 100644
--- a/src/lib/MultiSelect.svelte
+++ b/src/lib/MultiSelect.svelte
@@ -461,7 +461,6 @@
+ import { goto } from '$app/navigation'
+ import { tick } from 'svelte/internal'
+ import Select from '.'
+
+ export let routes: string[] | { label: string; route: string }[]
+ export let trigger: string = `k`
+
+ let open = false
+ let dialog: HTMLDialogElement
+ let input: HTMLInputElement
+
+ async function toggle(event: KeyboardEvent) {
+ if (event.key === trigger && event.metaKey && !open) {
+ // open on cmd+k
+ open = true
+ await tick() // wait for dialog to open and input to be mounted
+ input?.focus()
+ } else if (event.key === `Escape` && open) {
+ // close on escape
+ open = false
+ }
+ }
+
+ function close_if_outside(event: MouseEvent) {
+ if (open && !dialog?.contains(event.target as Node)) {
+ open = false
+ }
+ }
+
+ function move(
+ event: CustomEvent<{ option: string | { label: string; route: string } }>
+ ) {
+ const { option } = event.detail
+ if (typeof option == `object`) goto(option.route)
+ else goto(option)
+ open = false
+ }
+
+
+