/
index.js
312 lines (240 loc) · 7.16 KB
/
index.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
// @flow
import React, { Fragment } from 'react';
import { Helmet } from 'react-helmet';
import md from '../../markdown/renderer';
import PrettyProps, { Prop } from 'pretty-proptypes';
const Props = props => (
<PrettyProps
heading=""
components={{
Button: ({ isCollapsed, ...rest }) => (
<button {...rest}>
{isCollapsed ? 'Hide Prop Shape' : 'Show Prop Shape'}
</button>
),
}}
{...props}
/>
);
export default function Api() {
return (
<Fragment>
<Helmet>
<title>API - React Select</title>
<meta
name="description"
content="The react-select property API documentation."
/>
</Helmet>
{md`
# API
## Prop Types
### Internal Types
You'll see these in the public props below:
~~~js
type OptionType = { [string]: any }
type OptionsType = Array<OptionType>
type GroupType = {
[string]: any, // group label
options: OptionsType,
}
type ValueType = OptionType | OptionsType | null | void
type CommonProps = {
clearValue: () => void,
getStyles: (string, any) => {},
getValue: () => ValueType,
hasValue: boolean,
isMulti: boolean,
options: OptionsType,
selectOption: OptionType => void,
selectProps: any,
setValue: (ValueType, ActionTypes) => void,
}
// passed as the second argument to \`onChange\`
type ActionTypes = | 'clear' | 'create-option' | 'deselect-option' | 'pop-value' | 'remove-value' | 'select-option' | 'set-value'
~~~
Even when commonProps are not listed in the prop types below, a custom component
will still have access to them.
## Select Props
These base props are those available to be passed to all select variants.
${(
<Props
props={require('!!extract-react-types-loader!../../PropTypes/Select')}
overrides={{
components: props => (
<Prop
{...props}
shapeComponent={() => null}
type="All Components Object"
/>
),
}}
/>
)}
## Async props
These props are included with in both the Async and AsyncCreatable select. For
more on using async selects, see the [async select documentation](/async)
${(<Props props={require('!!extract-react-types-loader!../../PropTypes/Async')} />)}
## Creatable props
These props are included with in both the Creatable and AsyncCreatable select. For
more on using creatable selects, see the [creatable select documentation](/creatable)
${(
<Props
props={require('!!extract-react-types-loader!../../PropTypes/Creatable')}
/>
)}
## Replacing Components
React-Select allows you to augment layout and functionality by replacing
the default components with your own, using the \`components\`
property. These components are given all the current props and state
letting you achieve anything you dream up. For more information in replacing
components see [the components documentation](/components)
### Inner Ref
Some components are passed an innerRef property to facilitate for internally
managed behaviour within the base select. This should be assigned to the
ref property of the relevant dom element.
i.e.
~~~
const CustomOptionComponent = ({ innerProps, innerRef }) =>
(<div ref={innerRef} {...innerProps} />)
~~~
### Inner Props
All functional properties that the component needs are provided in
\`innerProps\` which you must spread.
## Components
**IMPORTANT NOTE** The below props are provided automatically by \`react-select\`
when these components are passed into the \`components\` object above. Knowing
their API is most necessary if you intend to provide your own components, to
understand what information they will be handed.
### ClearIndicator
${(
<Props
props={require('!!extract-react-types-loader!../../PropTypes/components/ClearIndicator')}
/>
)}
### Control
${(
<Props
props={require('!!extract-react-types-loader!../../PropTypes/components/Control')}
/>
)}
### DropdownIndicator
${(
<Props
props={require('!!extract-react-types-loader!../../PropTypes/components/DropdownIndicator')}
/>
)}
### Group
${(
<Props
props={require('!!extract-react-types-loader!../../PropTypes/components/Group')}
/>
)}
### GroupHeading
Group Heading can be any component.
### IndicatorsContainer
${(
<Props
props={require('!!extract-react-types-loader!../../PropTypes/components/IndicatorsContainer')}
/>
)}
### IndicatorSeparator
${(
<Props
props={require('!!extract-react-types-loader!../../PropTypes/components/IndicatorsSeparator')}
/>
)}
### Input
${(
<Props
props={require('!!extract-react-types-loader!../../PropTypes/components/Input')}
/>
)}
### LoadingIndicator
${(
<Props
props={require('!!extract-react-types-loader!../../PropTypes/components/LoadingIndicator')}
/>
)}
### Menu
${(
<Props
props={require('!!extract-react-types-loader!../../PropTypes/components/Menu')}
/>
)}
### MenuList
${(
<Props
props={require('!!extract-react-types-loader!../../PropTypes/components/MenuList')}
/>
)}
### LoadingMessage
${(
<Props
props={require('!!extract-react-types-loader!../../PropTypes/components/LoadingMessage')}
/>
)}
### NoOptionsMessage
${(
<Props
props={require('!!extract-react-types-loader!../../PropTypes/components/NoOptionsMessage')}
/>
)}
### MultiValue
${(
<Props
props={require('!!extract-react-types-loader!../../PropTypes/components/MultiValue')}
/>
)}
### MultiValueContainer
${(
<Props
props={require('!!extract-react-types-loader!../../PropTypes/components/MultiValueContainer')}
/>
)}
### MultiValueLabel
${(
<Props
props={require('!!extract-react-types-loader!../../PropTypes/components/MultiValueLabel')}
/>
)}
### MultiValueRemove
${(
<Props
props={require('!!extract-react-types-loader!../../PropTypes/components/MultiValueRemove')}
/>
)}
### Option
${(
<Props
props={require('!!extract-react-types-loader!../../PropTypes/components/Option')}
/>
)}
### Placeholder
${(
<Props
props={require('!!extract-react-types-loader!../../PropTypes/components/Placeholder')}
/>
)}
### SelectContainer
${(
<Props
props={require('!!extract-react-types-loader!../../PropTypes/components/SelectContainer')}
/>
)}
### SingleValue
${(
<Props
props={require('!!extract-react-types-loader!../../PropTypes/components/SingleValue')}
/>
)}
### ValueContainer
${(
<Props
props={require('!!extract-react-types-loader!../../PropTypes/components/ValueContainer')}
/>
)}
`}
</Fragment>
);
}