-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Hi there, thanks so much for this project -- it's doing exactly what I wanted in a keyboard handler/interface!
As a feature request, please add the action
type (maybe as CommandAction
) to the default exports for the project.
Use case:
-
I'm making a fairly complex editor with actions for several "modes" -- e.g. some actions when viewing, additional actions when editing -- as well as "global" actions that apply to both.
-
As such, I'm declaring various sets of "actions" in a separate
.ts
file:
file: AppActions.ts
import { type CommandAction } from "svelte-command-palette"
export const GlobalActions: CommandAction[] = [...]
export const ViewActions: CommandAction[] = [...]
export const EditActions: CommandAction[] = [...]
-
^^^ note the
type CommandAction
above -- this is the actual feature request. -
Then combining the sets in components as necessary:
file: SomeComponent.svelte
<script lang="ts">
import CommandPalette, { defineActions, type CommandAction } from "svelte-command-palette"
import { GlobalActions, ViewActions } from "./AppActions"
const commands = defineActions([...GlobalActions, ...ViewActions])
</script>
<CommandPalette {commands} />
Workaround
For now, I can more-or-less "look up" the type by doing:
type CommandActions = Parameters<typeof defineActions>[0]
but that feels like a hack.
Thanks again!