Huakun Shen 7a3b6f3983
fix: listview action menu (#64)
* refactor: add a valibot schema for package registry validation

* fix: list view action menu

* chore: bump version to 0.1.16 in package.json

* refactor: extract supabase package from api

* ci: remove NODE_OPTIONS from build step and improve error handling in getLatestNpmPkgVersion function
2025-01-18 02:26:23 -05:00

45 lines
1.3 KiB
TypeScript

import { findAllArgsInLink } from "@/cmds/quick-links"
import { Action as ActionSchema, CmdTypeEnum } from "@kksh/api/models"
import type { AppState } from "@kksh/types"
import type { CmdValue } from "@kksh/ui/types"
import { derived, get, writable, type Writable } from "svelte/store"
export const defaultAppState: AppState = {
searchTerm: "",
highlightedCmd: "",
loadingBar: false,
defaultAction: "",
actionPanel: undefined
}
interface AppStateAPI {
clearSearchTerm: () => void
get: () => AppState
setLoadingBar: (loadingBar: boolean) => void
setDefaultAction: (defaultAction: string | null) => void
setActionPanel: (actionPanel?: ActionSchema.ActionPanel) => void
}
function createAppState(): Writable<AppState> & AppStateAPI {
const store = writable<AppState>(defaultAppState)
return {
...store,
get: () => get(store),
clearSearchTerm: () => {
store.update((state) => ({ ...state, searchTerm: "" }))
},
setLoadingBar: (loadingBar: boolean) => {
store.update((state) => ({ ...state, loadingBar }))
},
setDefaultAction: (defaultAction: string | null) => {
store.update((state) => ({ ...state, defaultAction }))
},
setActionPanel: (actionPanel?: ActionSchema.ActionPanel) => {
store.update((state) => ({ ...state, actionPanel }))
}
}
}
export const appState = createAppState()