From 85d1aac4cd70e79d5ab64684dea09e92b17ed2c2 Mon Sep 17 00:00:00 2001 From: muhamedsalih-tw <104364298+muhamedsalih-tw@users.noreply.github.com> Date: Tue, 1 Nov 2022 06:42:12 +0530 Subject: Transform ChangeServer components tree to typescript (#725) --- src/components/ui/Select.js | 101 -------------------------------------------- 1 file changed, 101 deletions(-) delete mode 100644 src/components/ui/Select.js (limited to 'src/components/ui/Select.js') diff --git a/src/components/ui/Select.js b/src/components/ui/Select.js deleted file mode 100644 index ca5ec9964..000000000 --- a/src/components/ui/Select.js +++ /dev/null @@ -1,101 +0,0 @@ -import { createRef, Component } from 'react'; -import PropTypes from 'prop-types'; -import { observer } from 'mobx-react'; -import { Field } from 'mobx-react-form'; -import classnames from 'classnames'; - -// Can this file be merged into the './select/index.tsx' file? -class Select extends Component { - static propTypes = { - field: PropTypes.instanceOf(Field).isRequired, - className: PropTypes.string, - showLabel: PropTypes.bool, - disabled: PropTypes.bool, - multiple: PropTypes.bool, - }; - - static defaultProps = { - className: null, - showLabel: true, - disabled: false, - multiple: false, - }; - - constructor(props) { - super(props); - - this.element = createRef(); - } - - multipleChange() { - const element = this.element.current; - - const result = []; - const options = element && element.options; - - for (const option of options) { - if (option.selected) { - result.push(option.value || option.text); - } - } - - const { field } = this.props; - field.value = result; - } - - render() { - const { field, className, showLabel, disabled, multiple } = this.props; - - let selected = field.value; - - if (multiple) { - if (typeof field.value === 'string' && field.value.slice(0, 1) === '[') { - // Value is JSON encoded - selected = JSON.parse(field.value); - } else if (typeof field.value === 'object') { - selected = field.value; - } else { - selected = [field.value]; - } - } - - return ( -
- {field.label && showLabel && ( - - )} - - {field.error &&
{field.error}
} -
- ); - } -} - -export default observer(Select); -- cgit v1.2.3-70-g09d2