import { TranslatedString } from "@gnu-taler/taler-util"; import { Fragment, VNode, h } from "preact"; import { UIFormProps } from "./FormProvider.js"; import { LabelWithTooltipMaybeRequired } from "./InputLine.js"; import { useField } from "./useField.js"; export interface ChoiceS { label: TranslatedString; description?: TranslatedString; value: V; } export function InputChoiceStacked( props: { choices: ChoiceS[]; } & UIFormProps, ): VNode { const { choices, name, label, tooltip, help, placeholder, required, before, after, converter, } = props; const { value, onChange, state, isDirty } = useField(name); if (state.hidden) { return ; } return (
{choices.map((choice) => { // const currentValue = !converter // ? choice.value // : converter.fromStringUI(choice.value) ?? ""; let clazz = "border relative block cursor-pointer rounded-lg bg-white px-6 py-4 shadow-sm focus:outline-none sm:flex sm:justify-between"; if (choice.value === value) { clazz += " border-transparent border-indigo-600 ring-2 ring-indigo-600"; } else { clazz += " border-gray-300"; } return ( ); })}
{help && (

{help}

)}
); }