1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-02 22:52:21 +01:00

25 lines
768 B
TypeScript
Raw Normal View History

import { BaseSyntheticEvent, ReactNode } from 'react';
import * as React from 'react';
2021-01-26 11:37:05 +01:00
2021-07-01 12:34:10 +02:00
type inputType = string|number|readonly string [];
2021-01-26 11:37:05 +01:00
interface LabelledInputProps {
id: string,
2021-06-08 16:32:19 +02:00
type?: 'text' | 'date' | 'password' | 'url' | 'time' | 'tel' | 'search' | 'number' | 'month' | 'email' | 'datetime-local' | 'week',
label: string | ReactNode,
2021-07-01 12:34:10 +02:00
value: inputType,
2021-06-08 16:32:19 +02:00
onChange: (event: BaseSyntheticEvent) => void
2021-01-26 11:37:05 +01:00
}
/**
* This component shows input field with its label, styled
*/
2021-01-26 11:37:05 +01:00
export const LabelledInput: React.FC<LabelledInputProps> = ({ id, type, label, value, onChange }) => {
return (
<div className="labelled-input">
<label htmlFor={id}>{label}</label>
<input id={id} type={type} value={value} onChange={onChange} />
2021-01-26 11:37:05 +01:00
</div>
);
2021-07-01 12:34:10 +02:00
};