diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-05-02 11:12:28 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-05-02 22:07:54 +0900 |
commit | e69497fab457df486b2a7068bdd0283505461f8b (patch) | |
tree | f1cb4111bae89160d4238df9057493a50acacc39 /src/settings/components/form/PropertiesForm.tsx | |
parent | c059bf8be3b302173f2cab0d22a434aea4a6e0bd (diff) |
Types src/settings
Diffstat (limited to 'src/settings/components/form/PropertiesForm.tsx')
-rw-r--r-- | src/settings/components/form/PropertiesForm.tsx | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/settings/components/form/PropertiesForm.tsx b/src/settings/components/form/PropertiesForm.tsx index 979fdd8..0be5f5c 100644 --- a/src/settings/components/form/PropertiesForm.tsx +++ b/src/settings/components/form/PropertiesForm.tsx @@ -1,8 +1,20 @@ import './PropertiesForm.scss'; import React from 'react'; -import PropTypes from 'prop-types'; -class PropertiesForm extends React.Component { +interface Props { + types: {[key: string]: string}; + value: {[key: string]: any}; + onChange: (value: any) => void; + onBlur: () => void; +} + +class PropertiesForm extends React.Component<Props> { + public static defaultProps: Props = { + types: {}, + value: {}, + onChange: () => {}, + onBlur: () => {}, + }; render() { let types = this.props.types; @@ -12,13 +24,15 @@ class PropertiesForm extends React.Component { { Object.keys(types).map((name) => { let type = types[name]; - let inputType = null; + let inputType = ''; if (type === 'string') { inputType = 'text'; } else if (type === 'number') { inputType = 'number'; } else if (type === 'boolean') { inputType = 'checkbox'; + } else { + return null; } return <div key={name} className='form-properties-form-row'> <label> @@ -37,7 +51,7 @@ class PropertiesForm extends React.Component { </div>; } - bindValue(e) { + bindValue(e: React.ChangeEvent<HTMLInputElement>) { let name = e.target.name; let next = { ...this.props.value }; if (e.target.type.toLowerCase() === 'checkbox') { @@ -52,14 +66,4 @@ class PropertiesForm extends React.Component { } } -PropertiesForm.propTypes = { - value: PropTypes.objectOf(PropTypes.any), - onChange: PropTypes.func, -}; - -PropertiesForm.defaultProps = { - value: {}, - onChange: () => {}, -}; - export default PropertiesForm; |