Files
triggershell/src/lib/config/ui-control-map.ts
T

22 lines
649 B
TypeScript
Raw Normal View History

2026-08-15 18:37:30 +02:00
import type { ControlType, VariableConfig } from "./schema";
/** Resolves the effective shadcn control for a variable: explicit `control` wins, otherwise a type-based default. */
export function resolveControl(variable: VariableConfig): ControlType {
if (variable.control) return variable.control;
switch (variable.type) {
case "string":
if (variable.secret) return "password";
if (variable.multiline) return "textarea";
return "text";
case "number":
return "number";
case "boolean":
return "checkbox";
case "enum":
return "select";
case "multiselect":
return "multiselect";
}
}