You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-10
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,4 @@
1
1
React-Select-Plus
2
-
=================
3
2
4
3
A Select control for [React](http://facebook.github.io/react/index.html) based on [JedWatson/React-Select](https://github.com/JedWatson/react-select/).
5
4
@@ -86,6 +85,12 @@ function logChange(val) {
86
85
/>
87
86
```
88
87
88
+
### Custom classNames
89
+
90
+
You can provide a custom `className` prop to the `<Select>` component, which will be added to the base `.Select` className for the outer container.
91
+
92
+
The built-in Options renderer also support custom classNames, just add a `className` property to objects in the `options` array.
93
+
89
94
### Multiselect options
90
95
91
96
You can enable multi-value selection by setting `multi={true}`. In this mode:
@@ -95,7 +100,7 @@ You can enable multi-value selection by setting `multi={true}`. In this mode:
95
100
* The values of the selected items are joined using the `delimiter` prop to create the input value when `joinValues` is true
96
101
* A simple value, if provided, will be split using the `delimiter` prop
97
102
* The `onChange` event provides an array of selected options _or_ a comma-separated string of values (eg `"1,2,3"`) if `simpleValue` is true
98
-
* By default, only options in the `options` array can be selected. Setting `allowCreate` to true allows new options to be created if they do not already exist. *NOTE:*`allowCreate` is not implemented in `1.0.0-beta`, if you need this option please stay on `0.9.x`.
103
+
* By default, only options in the `options` array can be selected. Use the `Creatable` Component (which wraps `Select`) to allow new options to be created if they do not already exist. Hitting comma (','), ENTER or TAB will add a new option. Versions `0.9.x` and below provided a boolean attribute on the `Select` Component (`allowCreate`) to achieve the same functionality. It is no longer available starting with version `1.0.0`.
99
104
* By default, selected options can be cleared. To disable the possibility of clearing a particular option, add `clearableValue: false` to that option:
100
105
```javascript
101
106
var options = [
@@ -213,8 +218,8 @@ Property | Type | Description
213
218
`isOptionUnique` | function | Searches for any matching option within the set of options. This function prevents duplicate options from being created. By default this is a basic, case-sensitive comparison of label and value. Expected signature: `({ option: Object, options: Array, labelKey: string, valueKey: string }): boolean` |
214
219
`isValidNewOption` | function | Determines if the current input text represents a valid option. By default any non-empty string will be considered valid. Expected signature: `({ label: string }): boolean` |
215
220
`newOptionCreator` | function | Factory to create new option. Expected signature: `({ label: string, labelKey: string, valueKey: string }): Object` |
`shouldKeyDownEventCreateNewOption` | function | Decides if a keyDown event (eg its `keyCode`) should result in the creation of a new option. ENTER, TAB and comma keys create new options by dfeault. Expected signature: `({ keyCode: number }): boolean` |
221
+
`onNewOptionClick` | function | new option click handler, it calls when new option has been selected. `function(option) {}` |
222
+
`shouldKeyDownEventCreateNewOption` | function | Decides if a keyDown event (eg its `keyCode`) should result in the creation of a new option. ENTER, TAB and comma keys create new options by default. Expected signature: `({ keyCode: number }): boolean` |
218
223
`promptTextCreator` | function | Factory for overriding default option creator prompt label. By default it will read 'Create option "{label}"'. Expected signature: `(label: String): String` |
219
224
220
225
### Combining Async and Creatable
@@ -242,16 +247,18 @@ You can control how options are filtered with the following properties:
242
247
*`matchPos`: `"start"` or `"any"`: whether to match the text entered at the start or any position in the option value
243
248
*`matchProp`: `"label"`, `"value"` or `"any"`: whether to match the value, label or both values of each option when filtering
244
249
*`ignoreCase`: `Boolean`: whether to ignore case or match the text exactly when filtering
250
+
*`ignoreAccents`: `Boolean`: whether to ignore accents on characters like ø or å
245
251
246
252
`matchProp` and `matchPos` both default to `"any"`.
247
253
`ignoreCase` defaults to `true`.
254
+
`ignoreAccents` defaults to `true`.
248
255
249
256
#### Advanced filters
250
257
251
258
You can also completely replace the method used to filter either a single option, or the entire options array (allowing custom sort mechanisms, etc.)
addLabelText | string | 'Add "{label}"?' | text to display when `allowCreate` is true
331
-
arrowRenderer | func | undefined | Renders a custom drop-down arrow to be shown in the right-hand side of the select: `arrowRenderer({ onMouseDown })`
341
+
arrowRenderer | func | undefined | Renders a custom drop-down arrow to be shown in the right-hand side of the select: `arrowRenderer({ onMouseDown, isOpen })`
332
342
autoBlur | bool | false | Blurs the input element after a selection has been made. Handy for lowering the keyboard on mobile devices
333
343
autofocus | bool | undefined | autofocus the component on mount
334
344
autoload | bool | true | whether to auto-load the default async options set
335
345
autosize | bool | true | If enabled, the input will expand as the length of its value increases
336
346
backspaceRemoves | bool | true | whether pressing backspace removes the last item when there is no input value
347
+
backspaceToRemoveMessage | string | 'Press backspace to remove {last label}' | prompt shown in input when at least one option in a multiselect is shown, set to '' to clear
337
348
cache | bool | true | enables the options cache for `asyncOptions` (default: `true`)
338
349
className | string | undefined | className for the outer element
339
350
clearable | bool | true | should it be possible to reset value
340
351
clearAllText | string | 'Clear all' | title for the "clear" control when `multi` is true
352
+
clearRenderer | func | undefined | Renders a custom clear to be shown in the right-hand side of the select when clearable true: `clearRenderer()`
341
353
clearValueText | string | 'Clear value' | title for the "clear" control
342
354
resetValue | any | null | value to use when you clear the control
355
+
deleteRemoves | bool | true | whether pressing delete key removes the last item when there is no input value
343
356
delimiter | string | ',' | delimiter to use to join multiple values
344
357
disabled | bool | false | whether the Select is disabled or not
345
358
filterOption | func | undefined | method to filter a single option: `function(option, filterString)`
346
359
filterOptions | func | undefined | method to filter the options array: `function([options], filterString, [values])`
360
+
ignoreAccents | bool | true | whether to strip accents when filtering
inputProps | object | {} | custom attributes for the Input (in the Select-control) e.g: `{'data-foo': 'bar'}`
349
363
isLoading | bool | false | whether the Select is loading externally or not (such as options being loaded)
@@ -356,12 +370,12 @@ function onInputKeyDown(event) {
356
370
menuRenderer | func | undefined | Renders a custom menu with options; accepts the following named parameters: `menuRenderer({ focusedOption, focusOption, options, selectValue, valueArray })`
357
371
multi | bool | undefined | multi-value input
358
372
name | string | undefined | field name, for hidden `<input />` tag
359
-
noResultsText | string | 'No results found' | placeholder displayed when there are no matching search results or a falsy value to hide it
373
+
noResultsText | string | 'No results found' | placeholder displayed when there are no matching search results or a falsy value to hide it (can also be a react component)
0 commit comments