import type { AnyModel } from "@yaakapp-internal/models"; import { patchModel } from "@yaakapp-internal/models"; import { SettingRow, type SettingRowBaseProps, SettingRowBoolean, SettingRowNumber, SettingRowSelect, SettingRowText, SettingSelectControl, } from "@yaakapp-internal/ui"; import { SelectFile } from "../SelectFile"; export type { SettingRowBaseProps, SettingSnippetLanguage } from "@yaakapp-internal/ui"; export { SettingCommand, SettingOverrideRow, SettingRow, SettingRowBoolean, SettingRowNumber, SettingRowSelect, SettingRowText, SettingSelectControl, SettingSnippet, SettingsList, SettingsSection, SettingValue, } from "@yaakapp-internal/ui"; type ModelKeyOfValue = { [K in keyof T]-?: T[K] extends V ? K : never; }[keyof T]; export function ModelSettingRowBoolean>({ model, modelKey, ...props }: { model: M; modelKey: K; } & Omit[0], "checked" | "onChange">) { return ( patchModel(model, { [modelKey]: value } as Partial)} {...props} /> ); } export function ModelSettingRowNumber>({ model, modelKey, ...props }: { model: M; modelKey: K; } & Omit[0], "name" | "onChange" | "value">) { return ( patchModel(model, { [modelKey]: value } as Partial)} {...props} /> ); } export function ModelSettingRowText>({ model, modelKey, ...props }: { model: M; modelKey: K; } & Omit[0], "name" | "onChange" | "value">) { return ( patchModel(model, { [modelKey]: value } as Partial)} {...props} /> ); } export function SettingRowFile({ buttonClassName, controlClassName = "min-w-0 max-w-[min(32rem,45vw)]", directory, filePath, nameOverride, noun, onChange, size = "xs", title, ...props }: { buttonClassName?: string; directory?: boolean; filePath: string | null; nameOverride?: string | null; noun?: string; onChange: (filePath: string | null) => void | Promise; size?: Parameters[0]["size"]; } & SettingRowBaseProps) { return ( onChange(filePath)} /> ); } export function SettingRowDirectory({ noun = "Directory", ...props }: Omit[0], "directory">) { return ; } export function ModelSettingSelectControl< M extends AnyModel, K extends ModelKeyOfValue, V extends M[K] & string, >({ model, modelKey, ...props }: { model: M; modelKey: K; } & Omit>[0], "name" | "onChange" | "value">) { return ( patchModel(model, { [modelKey]: value } as Partial)} {...props} /> ); } export function ModelSettingRowSelect< M extends AnyModel, K extends ModelKeyOfValue, V extends M[K] & string, >({ model, modelKey, ...props }: { model: M; modelKey: K; } & Omit>[0], "name" | "onChange" | "value">) { return ( patchModel(model, { [modelKey]: value } as Partial)} {...props} /> ); }