Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 547x 132x | import { Row, Col } from "@canonical/react-components";
import { SyntheticEvent } from "react";
export type ListingInputFieldProps = {
label: string;
name: string;
value: string | undefined;
helpText?: string;
maxLength?: number;
placeholder?: string;
handleInputChange: (
e: SyntheticEvent<HTMLInputElement> & {
target: HTMLInputElement;
}
) => void;
};
function ListingInputField({
label,
name,
value,
helpText,
maxLength,
placeholder,
handleInputChange,
}: ListingInputFieldProps) {
return (
<Row className="p-form__group p-form-validation">
<Col size={2}>
<label htmlFor={name}>{label}:</label>
</Col>
<Col size={8} className="col-x-large-6">
<div className="p-form__control">
<input
type="text"
className="p-form-validation__input"
id={name}
name={name}
required
maxLength={maxLength}
placeholder={placeholder}
value={value || ""}
onChange={(e) => {
handleInputChange(e);
}}
/>
{helpText && <p className="p-form-help-text">{helpText}</p>}
</div>
</Col>
</Row>
);
}
export default ListingInputField;
|