import { useStore } from "@tanstack/vue-form" import { computed, type Ref } from "vue" import type { OmegaFormApi, OmegaFormState } from "./types" export function getOmegaStore< To, From, K extends keyof OmegaFormState = keyof OmegaFormState >( form: OmegaFormApi, subscribe?: K[] ): Ref< K[] extends undefined[] ? Record : Pick, K> > { return computed(() => { // eslint-disable-next-line @typescript-eslint/no-explicit-any if (!subscribe) return {} as any const state = useStore(form.store, (state) => { const result = {} as Pick, K> for (const key of subscribe) { result[key] = state[key] } return result }) return state.value // eslint-disable-next-line @typescript-eslint/no-explicit-any }) as any // Type assertion needed due to Vue's computed typing limitations }