0
owncast/web/pages/components/config/form-textfield.tsx

65 lines
1.2 KiB
TypeScript
Raw Normal View History

2020-12-26 18:04:23 -08:00
/*
2020-12-26 19:44:09 -08:00
- auto saves ,ajax call (submit when blur or onEnter)
2020-12-26 18:04:23 -08:00
- set default text
- show error state/confirm states
- show info
- label
- min/max length
- populate with curren val (from local sstate)
load page,
get all config vals,
save to local state/context.
read vals from there.
update vals to state, andthru api.
*/
2020-12-26 19:44:09 -08:00
import React from 'react';
import { Form, Input } from 'antd';
2020-12-26 18:04:23 -08:00
2020-12-26 19:44:09 -08:00
interface TextFieldProps {
onSubmit: (value: string) => void;
label: string;
defaultValue: string;
value: string;
helpInfo: string;
maxLength: number;
type: string;
}
2020-12-26 18:04:23 -08:00
2020-12-26 19:44:09 -08:00
// // do i need this?
// export const initialProps: TextFieldProps = {
// }
export const TEXTFIELD_TYPE_TEXT = 'default';
export const TEXTFIELD_TYPE_PASSWORD = 'password'; //Input.Password
export const TEXTFIELD_TYPE_NUMBER = 'numeric';
export default function TextField(props: TextFieldProps) {
const {
label,
defaultValue,
value,
onSubmit,
helpInfo,
maxLength,
type,
} = props;
return (
<div className="textfield">
<Form.Item
label={label}
hasFeedback
validateStatus="error"
help="Should be combination of numbers & alphabets"
>
<Input placeholder="Owncast" value={value} />
</Form.Item>
</div>
);
}