Skip to content

Commit 1505b73

Browse files
committed
migrated Select to .tsx
1 parent 4d1a044 commit 1505b73

File tree

3 files changed

+5
-84
lines changed

3 files changed

+5
-84
lines changed

components/Form/Select/Select.tsx

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
import {
2-
arrayOf,
3-
bool,
4-
func,
5-
number,
6-
object,
7-
objectOf,
8-
oneOfType,
9-
shape,
10-
string,
11-
} from 'prop-types';
121
import { ErrorMessage } from 'formik';
132
import Alert from 'components/Alert/Alert';
143
import Label from 'components/Form/Label/Label';
@@ -52,39 +41,6 @@ export type SelectPropsType = {
5241
isSearchable?: boolean;
5342
};
5443

55-
// Select.propTypes = {
56-
// field: shape({
57-
// name: string.isRequired,
58-
// value: oneOfType([string, number, bool, arrayOf(string), arrayOf(number), arrayOf(bool)])
59-
// .isRequired,
60-
// }).isRequired,
61-
// form: shape({
62-
// // TODO: Resolve why multiselects can end up with touched: { key: array }
63-
// // see ThemedReactSelect as well
64-
// // touched: objectOf(bool).isRequired,
65-
// touched: object.isRequired,
66-
// errors: objectOf(string).isRequired,
67-
// setFieldTouched: func.isRequired,
68-
// setFieldValue: func.isRequired,
69-
// }).isRequired,
70-
// hasValidationStyling: bool,
71-
// id: oneOfType([string, number]),
72-
// isLabelHidden: bool,
73-
// isMulti: bool,
74-
// isSearchable: bool,
75-
// label: string.isRequired,
76-
// options: arrayOf(shape({ label: string.isRequired, value: string.isRequired }).isRequired)
77-
// .isRequired,
78-
// };
79-
80-
// Select.defaultProps = {
81-
// hasValidationStyling: true,
82-
// id: undefined,
83-
// isLabelHidden: false,
84-
// isMulti: false,
85-
// isSearchable: true,
86-
// };
87-
8844
export default function Select({
8945
field: { name, value: fieldValue },
9046
form: { errors, setFieldTouched, setFieldValue, touched },

components/Form/Select/ThemedReactSelect.tsx

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// eslint-disable-next-line no-restricted-imports
22
import ReactSelect from 'react-select'; // the only spot this import is allowed
3-
4-
import { array, bool, oneOfType, string } from 'prop-types';
53
import {
64
primary,
75
rgbValuesPrimary,
@@ -10,29 +8,10 @@ import {
108
errorDeep,
119
} from 'common/styles/themeMap';
1210

13-
// ThemedReactSelect.propTypes = {
14-
// disabled: bool,
15-
// hasErrors: bool,
16-
// hasValidationStyling: bool,
17-
// id: string,
18-
// instanceId: string,
19-
// isMulti: bool,
20-
// isSearchable: bool,
21-
// // TODO: Resolve why multiselects can end up with touched: { key: array }
22-
// // see ThemedReactSelect as well
23-
// // isTouched: bool,
24-
// isTouched: oneOfType([array, bool]),
25-
// };
26-
2711
type OptionType = {
2812
[key: string]: any;
2913
};
3014

31-
// type OptionType = {
32-
// label: string
33-
// value: string
34-
// }
35-
3615
type OptionsType = OptionType[];
3716

3817
type ValueType = string | OptionType | OptionsType;
@@ -47,24 +26,11 @@ export type ThemedReactSelect = {
4726
isMulti?: boolean;
4827
isSearchable?: boolean;
4928
isTouched?: any[] | boolean;
50-
name?: string
51-
onBlur?: () => void
52-
onChange?: (selected: any) => void
29+
name?: string;
30+
onBlur?: () => void;
31+
onChange?: (selected: any) => void;
5332
value?: ValueType;
54-
}
55-
56-
// & React.InputHTMLAttributes<HTMLInputElement>;
57-
58-
// ThemedReactSelect.defaultProps = {
59-
// disabled: false,
60-
// hasErrors: false,
61-
// hasValidationStyling: true,
62-
// id: undefined,
63-
// instanceId: undefined,
64-
// isMulti: false,
65-
// isSearchable: true,
66-
// isTouched: false,
67-
// };
33+
};
6834

6935
function ThemedReactSelect({
7036
disabled = false,

components/Form/Select/__tests__/Select.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ import { Formik, Field } from 'formik';
22
import { fireEvent, render, waitFor } from '@testing-library/react';
33
import createSnapshotTest from 'test-utils/createSnapshotTest';
44
import { KEY_CODES } from 'test-utils/identifiers';
5-
65
import { LABEL } from 'common/constants/testIDs';
76
import Form from '../../Form';
87
import Select from '../Select';
98

10-
const getReactSelect = domElement => domElement.querySelector('[id^=react-select]');
9+
const getReactSelect = (domElement: any) => domElement.querySelector('[id^=react-select]');
1110

1211
describe('Select', () => {
1312
const name = 'someSelectName';

0 commit comments

Comments
 (0)