export default function InputGroup(props: InputGroupProps) {
const { label, error, children: childrenProp } = props;
const [forId] = createSignal(`input-${Math.random().toString(36).substr(2, 9)}`);
const renderedChildren = children(() => childrenProp);
createEffect(() => {
const child = renderedChildren();
if (child?.props) {
child.props.id = forId();
}
});
return (
<>
<label for={forId()}>{label}</label>
{renderedChildren()}
<Show when={!!error}>
<p>{error}</p>
</Show>
</>
);
}
export default function InputGroup(props: InputGroupProps) {
const { label, error, children: childrenProp } = props;
const [forId] = createSignal(`input-${Math.random().toString(36).substr(2, 9)}`);
const renderedChildren = children(() => childrenProp);
createEffect(() => {
const child = renderedChildren();
if (child?.props) {
child.props.id = forId();
}
});
return (
<>
<label for={forId()}>{label}</label>
{renderedChildren()}
<Show when={!!error}>
<p>{error}</p>
</Show>
</>
);
}