Conditional input widget

I have an input

viewof choice = Inputs.select(["Selection", "Text"], {label: "Input type", multiple: false})

I want a different widget to be displayed depending on that input.

{
  if (choice === "Selection") {
    viewof text = Inputs.select(["A","B"], {label: "Select text"});
  } else if (choice === "Text") {
    viewof text = Inputs.textarea({label: "Enter text", value: "Dummy text"});
  }
}
${text}

viewof and the cell name can only be declared at the start of a cell:

viewof text = {
  if (choice === "Selection") {
    return Inputs.select(["A","B"], {label: "Select text"});
  } else if (choice === "Text") {
    return Inputs.textarea({label: "Enter text", value: "Dummy text"});
  }
}