You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
fms/components/elements/option/index.tsx

33 lines
922 B

import styles from './styles.module.css'
import {useContext} from "react";
import Context, {ContextInterface} from "../command/context";
export interface OptionInterface {
name: string,
description: string | null,
default: any,
value: any,
shortcut: string | null,
isArray: boolean,
isNegatable: boolean,
isValueOptional: boolean,
isValueRequired: boolean
acceptValue: boolean
}
export default function Option(option: OptionInterface) {
let {optionList: ol, setOptionList} = useContext<ContextInterface>(Context)
let onInput = (event: any) => {
let temp = {
...ol
}
temp[option.name] = event.target.value
setOptionList(temp)
}
return (
<span>
{option.shortcut ? '-' : '--'}{option.shortcut || option.name} {option.acceptValue && <input onInput={onInput} type="text"/>}&nbsp;
</span>
)
}