UNPKG

2.1 kBTypeScriptView Raw
1import * as React from 'react';
2import Select from 'react-select';
3import makeAnimated from 'react-select/lib/animated';
4
5import Colors from '../Colors';
6import TextHelper from '../TextHelper';
7import Sizes from '../Sizes';
8
9export interface IProps {
10 options?: any;
11 loadOptions?: Object[];
12 placeholder?: string;
13 onChange?: (e?: any) => any;
14 isDisabled?: boolean;
15 cacheOptions?: boolean;
16 defaultOptions?: boolean;
17 async?: boolean;
18 value?: any;
19 noOptionsMessage?: any;
20}
21
22const selectStyles = {
23 control: (styles: Object) => ({
24 ...styles,
25 border: '0 none',
26 borderRadius: 0,
27 outline: 0,
28 boxShadow: '0 none',
29 borderBottom: `1px solid ${Colors.codGray}`,
30 backgroundColor: 'transparent',
31 padding: 0,
32 fontFamily: TextHelper.fontVariant('medium'),
33 }),
34 option: () => ({
35 marginBottom: `${Sizes.s4}px`,
36 cursor: 'pointer',
37 }),
38 multiValue: () => ({
39 backgroundColor: Colors.mongeral,
40 borderRadius: '20px',
41 color: 'white',
42 display: 'flex',
43 marginRight: '10px',
44 marginBottom: `${Sizes.s1}px`,
45 padding: `${Sizes.s1}px ${Sizes.s2}px`,
46 }),
47 clearIndicator: () => ({
48 display: 'none',
49 }),
50 dropdownIndicator: () => ({
51 display: 'none',
52 }),
53 indicatorSeparator: () => ({
54 display: 'none',
55 }),
56 multiValueLabel: (styles: Object) => ({
57 ...styles,
58 color: 'white',
59 }),
60 menu: (styles: Object) => ({
61 ...styles,
62 border: '0 none',
63 borderRadius: 0,
64 marginTop: 0,
65 boxShadow: `0 3px 6px 0 ${Colors.line}`,
66 borderTop: `1px solid ${Colors.codGray}`,
67 padding: `${Sizes.s4}px ${Sizes.s4}px 0`,
68 zIndex: 9999,
69 }),
70 menuList: (styles: Object, {}) => ({
71 ...styles,
72 fontFamily: TextHelper.fontVariant('medium'),
73 height: '215px',
74 }),
75 valueContainer: (styles: Object, {}) => ({
76 ...styles,
77 padding: 0,
78 }),
79};
80
81export default class MultiSelect extends React.PureComponent<IProps> {
82 render () {
83 return (
84 <Select
85 {...this.props}
86 components={makeAnimated()}
87 styles={selectStyles}
88 isMulti
89 />
90 );
91 }
92}