forked from JedWatson/react-select
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstyles.js
106 lines (98 loc) · 2.83 KB
/
styles.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// @flow
import {
containerCSS,
indicatorsContainerCSS,
valueContainerCSS,
} from './components/containers';
import { css as controlCSS } from './components/Control';
import { groupCSS, groupHeadingCSS } from './components/Group';
import {
clearIndicatorCSS,
dropdownIndicatorCSS,
loadingIndicatorCSS,
indicatorSeparatorCSS,
} from './components/indicators';
import { inputCSS } from './components/Input';
import { placeholderCSS } from './components/Placeholder';
import { optionCSS } from './components/Option';
import {
menuCSS,
menuListCSS,
menuPortalCSS,
noOptionsMessageCSS,
loadingMessageCSS,
} from './components/Menu';
import { css as singleValueCSS } from './components/SingleValue';
import {
multiValueCSS,
multiValueLabelCSS,
multiValueRemoveCSS,
} from './components/MultiValue';
type Props = { [key: string]: any };
export type Styles = {
clearIndicator?: Props => {},
container?: Props => {},
control?: Props => {},
dropdownIndicator?: Props => {},
group?: Props => {},
groupHeading?: Props => {},
indicatorsContainer?: Props => {},
indicatorSeparator?: Props => {},
input?: Props => {},
loadingIndicator?: Props => {},
loadingMessageCSS?: Props => {},
menu?: Props => {},
menuList?: Props => {},
menuPortal?: Props => {},
multiValue?: Props => {},
multiValueLabel?: Props => {},
multiValueRemove?: Props => {},
noOptionsMessageCSS?: Props => {},
option?: Props => {},
placeholder?: Props => {},
singleValue?: Props => {},
valueContainer: Props => {},
};
export type StylesConfig = $Shape<Styles>;
export type GetStyles = (string, Props) => {};
export const defaultStyles: Styles = {
clearIndicator: clearIndicatorCSS,
container: containerCSS,
control: controlCSS,
dropdownIndicator: dropdownIndicatorCSS,
group: groupCSS,
groupHeading: groupHeadingCSS,
indicatorsContainer: indicatorsContainerCSS,
indicatorSeparator: indicatorSeparatorCSS,
input: inputCSS,
loadingIndicator: loadingIndicatorCSS,
loadingMessage: loadingMessageCSS,
menu: menuCSS,
menuList: menuListCSS,
menuPortal: menuPortalCSS,
multiValue: multiValueCSS,
multiValueLabel: multiValueLabelCSS,
multiValueRemove: multiValueRemoveCSS,
noOptionsMessage: noOptionsMessageCSS,
option: optionCSS,
placeholder: placeholderCSS,
singleValue: singleValueCSS,
valueContainer: valueContainerCSS,
};
// Merge Utility
// Allows consumers to extend a base Select with additional styles
export function mergeStyles(source: Object, target: Object = {}) {
// initialize with source styles
const styles = { ...source };
// massage in target styles
Object.keys(target).forEach(key => {
if (source[key]) {
styles[key] = (rsCss, props) => {
return target[key](source[key](rsCss, props), props);
};
} else {
styles[key] = target[key];
}
});
return styles;
}