New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-select-plus

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-select-plus - npm Package Compare versions

Comparing version 1.0.0-rc.3.patch1 to 1.0.0-rc.3.patch10

yarn.lock

41

HISTORY.md

@@ -1,3 +0,42 @@

## v1.0.0-rc / 2016-09-04
# React-Select-Plus
## v1.0.0-rc.3 / 2017-02-01
* added; `arrowRenderer` prop, thanks [Brian Vaughn](https://github.com/bvaughn)
* added; child-function support to `Async` and `Creatable` components so that they can compose each other (or future HOCs), thanks [Brian Vaughn](https://github.com/bvaughn)
* added; `asyncCreatable` HOC that combines `Async` and `Creatable` so they can be used together, thanks [Brian Vaughn](https://github.com/bvaughn)
* added; undocumented arguments for `menuRenderer`, thanks [Julian Krispel-Samsel](https://github.com/juliankrispel)
* fixed; Do not focus and open menu when disabled, thanks [nhducit](https://github.com/nhducit)
* fixed; Scrolling with arrow-keys is not working correctly, thanks [Damian Pieczynski](https://github.com/piecyk)
* added; "select all text" functionality `Shift+Home|Del`, thanks [Damian Pieczynski](https://github.com/piecyk)
* added; support for `boolean` values, thanks [Aaron Hardy](https://github.com/Aaronius)
* fixed; Remove duplicated `promptTextCreator` field from readme, thanks [Jih-Chi Lee](https://github.com/jihchi)
* fixed; Adding back ref that was removed in rc2, thanks [Martin Jujou](https://github.com/jooj123)
* fixed; `Creatable` component doesn't allow input key down handling, thanks [Ivan Leonenko](https://github.com/IvanLeonenko)
* added; Allow react nodes to be passed as loadingPlaceholder, thanks [Daniel Heath](https://github.com/DanielHeath)
* fixed; IE8 compatibility issues, thanks [Kirill Mesnyankin](https://github.com/strayiker)
* improved; Allow users to specify noResultsText, thanks [Daniel Heath](https://github.com/DanielHeath)
* added; Only remove options if a loading placeholder is available, thanks [Daniel Heath](https://github.com/DanielHeath)
* fixed; firefox display items in two rows due to reflow, thanks [Daniel Heath](https://github.com/DanielHeath)
* fixed; `Creatable` readme typo, thanks [Ben](https://github.com/rockingskier)
* fixed; explain way to implement `allowCreate` functionality with `Creatable` to readme, thanks [mayerwin](https://github.com/mayerwin)
* added; delete key removes an item when there is no input, thanks [forum-is](https://github.com/forum-is)
* added; `onNewOptionClick` handler for `Creatable`, thanks [Lee Siong Chan](https://github.com/leesiongchan)
* fixed; `onInputChange` consistent for `Creatable`, thanks [Lee Siong Chan](https://github.com/leesiongchan)
* fixed; `menuRenderer` is treated consistently between `Creatable` and `Select`, thanks [Brian Vaughn](https://github.com/bvaughn)
* fixed; `asyncCreatable` options parsing will not parse undefined values into props, thanks [Romain Dardour](https://github.com/unity)
* added; pass `inputProps` to `inputRenderer`, thanks [Alec Winograd](https://github.com/awinograd)
* fixed; no exception when clearing an Async field that is not set to multi, thanks [Patrik Stutz](https://github.com/VanCoding)
* added; allow rendering a custom clear component, thanks [Conor Hastings](https://github.com/conorhastings)
* fixed; document `ignoreAccents`, thanks [Domenico Matteo](https://github.com/dmatteo)
* fixed; arrowing up or down in `Select` with 0 options does not throw type error, thanks [Alex Howard](https://github.com/thezanke)
* fixed; `Creatable` handles null children prop, thanks [Jack Coulter](https://github.com/jscinoz)
* added; provide `isOpen` to arrowRenderer, thanks [Kuan](https://github.com/khankuan)
* fixed; re-added the `focus()` method on `Select.Async`, thanks, [Maarten Claes](https://github.com/mcls)
* fixed; focus the next available option after a selection, not the top option, thanks [Nicolas Raynaud](https://github.com/nraynaud)
Note there has also been a breaking change to the props for the `Async` component: both `minimumInput` and `searchingText` have been removed. See #1226 for more details. Apologies for doing this in an RC release, but we had to trade off between resolving some important bugs and breaking the API, and figured it was better to do this before declaring 1.0.0 stable.
## v1.0.0-rc.1 / 2016-09-04
* fixed; reset value to `[]` when `multi=true`, thanks [Michael Williamson](https://github.com/mwilliamson)

@@ -4,0 +43,0 @@ * added; pass index to `renderLabel` method, thanks [nhducit](https://github.com/nhducit)

24

lib/Async.js

@@ -42,2 +42,3 @@ 'use strict';

loadOptions: _react2['default'].PropTypes.func.isRequired, // callback to load options asynchronously; (inputValue: string, callback: Function): ?Promise
multi: _react2['default'].PropTypes.bool, // multi-value input
options: _react.PropTypes.array.isRequired, // array of options

@@ -174,15 +175,26 @@ placeholder: _react2['default'].PropTypes.oneOfType([// field placeholder, displayed when there's no value (shared with Select)

var newInputValue = inputValue;
if (onInputChange) {
var value = onInputChange(newInputValue);
// Note: != used deliberately here to catch undefined and null
if (value != null && typeof value !== 'object') {
newInputValue = '' + value;
}
}
var transformedInputValue = newInputValue;
if (ignoreAccents) {
inputValue = (0, _utilsStripDiacritics2['default'])(inputValue);
transformedInputValue = (0, _utilsStripDiacritics2['default'])(transformedInputValue);
}
if (ignoreCase) {
inputValue = inputValue.toLowerCase();
transformedInputValue = transformedInputValue.toLowerCase();
}
if (onInputChange) {
onInputChange(inputValue);
}
this.loadOptions(transformedInputValue);
return this.loadOptions(inputValue);
// Return new input value, but without applying toLowerCase() to avoid modifying the user's view case of the input while typing.
return newInputValue;
}

@@ -189,0 +201,0 @@ }, {

@@ -28,2 +28,6 @@ 'use strict';

focus: function focus() {
this.select.focus();
},
render: function render() {

@@ -46,2 +50,3 @@ var _this = this;

ref: function (ref) {
_this.select = ref;
creatableProps.ref(ref);

@@ -48,0 +53,0 @@ asyncProps.ref(ref);

@@ -226,2 +226,6 @@ 'use strict';

focus: function focus() {
this.select.focus();
},
render: function render() {

@@ -228,0 +232,0 @@ var _this = this;

@@ -53,2 +53,6 @@ /*!

var _utilsStripDiacritics = require('./utils/stripDiacritics');
var _utilsStripDiacritics2 = _interopRequireDefault(_utilsStripDiacritics);
var _Async = require('./Async');

@@ -121,2 +125,3 @@

addLabelText: _react2['default'].PropTypes.string, // placeholder displayed when you want to add a label on a multi-value input
'aria-describedby': _react2['default'].PropTypes.string, // HTML ID(s) of element(s) that should be used to describe this input (for assistive tech)
'aria-label': _react2['default'].PropTypes.string, // Aria label (for assistive tech)

@@ -249,3 +254,3 @@ 'aria-labelledby': _react2['default'].PropTypes.string, // HTML ID of an element that should be used as the label (for assistive tech)

isFocused: false,
isOpen: false,
isOpen: this.props.isOpen != null ? this.props.isOpen : false,
isPseudoFocused: false,

@@ -281,2 +286,6 @@ required: false

if (!nextProps.isOpen && this.props.isOpen) {
this.closeMenu();
}
if (nextProps.required) {

@@ -311,2 +320,4 @@ this.setState({

}
var paddingTop = parseInt(window.getComputedStyle(menuNode, null).paddingTop, 10);
if (menuNode.scrollTop <= paddingTop) menuNode.scrollTop = 0;
this.hasScrolledToOption = true;

@@ -459,3 +470,3 @@ } else if (!this.state.isOpen) {

// otherwise, focus the input and open the menu
this._openAfterFocus = true;
this._openAfterFocus = this.props.openOnFocus;
this.focus();

@@ -1005,2 +1016,3 @@ }

'aria-activedescendant': isOpen ? this._instancePrefix + '-option-' + focusedOptionIndex : this._instancePrefix + '-value',
'aria-describedby': this.props['aria-describedby'],
'aria-labelledby': this.props['aria-labelledby'],

@@ -1237,3 +1249,10 @@ 'aria-label': this.props['aria-label'],

if (focusedOption && !focusedOption.disabled) {
var focusedOptionIndex = options.indexOf(focusedOption);
var focusedOptionIndex = -1;
options.some(function (option, index) {
var isOptionEqual = option.value === focusedOption.value;
if (isOptionEqual) {
focusedOptionIndex = index;
}
return isOptionEqual;
});
if (focusedOptionIndex !== -1) {

@@ -1288,3 +1307,2 @@ return focusedOptionIndex;

var isOpen = typeof this.props.isOpen === 'boolean' ? this.props.isOpen : this.state.isOpen;
if (this.props.multi && !options.length && valueArray.length && !this.state.inputValue) isOpen = false;
var focusedOptionIndex = this.getFocusableOptionIndex(valueArray[0]);

@@ -1357,3 +1375,5 @@

Select.stripDiacritics = _utilsStripDiacritics2['default'];
exports['default'] = Select;
module.exports = exports['default'];
{
"name": "react-select-plus",
"version": "1.0.0-rc.3.patch1",
"version": "1.0.0-rc.3.patch10",
"description": "A fork of react-select with support for option groups",

@@ -15,3 +15,3 @@ "main": "lib/Select.js",

"classnames": "^2.2.4",
"react-input-autosize": "^1.1.0"
"react-input-autosize": "1.1.0"
},

@@ -18,0 +18,0 @@ "devDependencies": {

@@ -72,15 +72,15 @@ React-Select-Plus

var options = [
{ value: 'one', label: 'One' },
{ value: 'two', label: 'Two' }
{ value: 'one', label: 'One' },
{ value: 'two', label: 'Two' }
];
function logChange(val) {
console.log("Selected: " + val);
console.log("Selected: " + val);
}
<Select
name="form-field-name"
value="one"
options={options}
onChange={logChange}
name="form-field-name"
value="one"
options={options}
onChange={logChange}
/>

@@ -108,4 +108,4 @@ ```

var options = [
{ value: 'one', label: 'One' },
{ value: 'two', label: 'Two', clearableValue: false }
{ value: 'one', label: 'One' },
{ value: 'two', label: 'Two', clearableValue: false }
];

@@ -131,13 +131,13 @@ ```

var getOptions = function(input, callback) {
setTimeout(function() {
callback(null, {
options: [
{ value: 'one', label: 'One' },
{ value: 'two', label: 'Two' }
],
// CAREFUL! Only set this to true when there are no more options,
// or more specific queries will not be sent to the server.
complete: true
});
}, 500);
setTimeout(function() {
callback(null, {
options: [
{ value: 'one', label: 'One' },
{ value: 'two', label: 'Two' }
],
// CAREFUL! Only set this to true when there are no more options,
// or more specific queries will not be sent to the server.
complete: true
});
}, 500);
};

@@ -165,4 +165,4 @@

* const json = [
* { value: 'one', label: 'One' },
* { value: 'two', label: 'Two' }
* { value: 'one', label: 'One' },
* { value: 'two', label: 'Two' }
* ]

@@ -181,5 +181,5 @@ */

<Select.Async
name="form-field-name"
value="one"
loadOptions={getOptions}
name="form-field-name"
value="one"
loadOptions={getOptions}
/>

@@ -199,4 +199,4 @@ ```

name="form-field-name"
isLoading={isLoadingExternally}
...
isLoading={isLoadingExternally}
...
/>

@@ -221,11 +221,11 @@ ```

Property | Type | Description
| Property | Type | Description
:---|:---|:---
`children` | function | Child function responsible for creating the inner Select component. This component can be used to compose HOCs (eg Creatable and Async). Expected signature: `(props: Object): PropTypes.element` |
`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` |
`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` |
`newOptionCreator` | function | Factory to create new option. Expected signature: `({ label: string, labelKey: string, valueKey: string }): Object` |
`onNewOptionClick` | function | new option click handler, it calls when new option has been selected. `function(option) {}` |
`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` |
`promptTextCreator` | function | Factory for overriding default option creator prompt label. By default it will read 'Create option "{label}"'. Expected signature: `(label: String): String` |
| `children` | function | Child function responsible for creating the inner Select component. This component can be used to compose HOCs (eg Creatable and Async). Expected signature: `(props: Object): PropTypes.element` |
| `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` |
| `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` |
| `newOptionCreator` | function | Factory to create new option. Expected signature: `({ label: string, labelKey: string, valueKey: string }): Object` |
| `onNewOptionClick` | function | new option click handler, it calls when new option has been selected. `function(option) {}` |
| `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` |
| `promptTextCreator` | function | Factory for overriding default option creator prompt label. By default it will read 'Create option "{label}"'. Expected signature: `(label: String): String` |

@@ -308,3 +308,3 @@ ### Combining Async and Creatable

function cleanInput(inputValue) {
// Strip all non-number characters from the input
// Strip all non-number characters from the input
return inputValue.replace(/[^0-9]/g, "");

@@ -326,16 +326,16 @@ }

function onInputKeyDown(event) {
switch (event.keyCode) {
case 9: // TAB
// Extend default TAB behavior by doing something here
break;
case 13: // ENTER
// Override default ENTER behavior by doing stuff here and then preventing default
event.preventDefault();
break;
}
switch (event.keyCode) {
case 9: // TAB
// Extend default TAB behavior by doing something here
break;
case 13: // ENTER
// Override default ENTER behavior by doing stuff here and then preventing default
event.preventDefault();
break;
}
}
<Select
{...otherProps}
onInputKeyDown={onInputKeyDown}
{...otherProps}
onInputKeyDown={onInputKeyDown}
/>

@@ -347,60 +347,60 @@ ```

Property | Type | Default | Description
:-----------------------|:--------------|:--------------|:--------------------------------
addLabelText | string | 'Add "{label}"?' | text to display when `allowCreate` is true
arrowRenderer | func | undefined | Renders a custom drop-down arrow to be shown in the right-hand side of the select: `arrowRenderer({ onMouseDown, isOpen })`
autoBlur | bool | false | Blurs the input element after a selection has been made. Handy for lowering the keyboard on mobile devices
autofocus | bool | undefined | autofocus the component on mount
autoload | bool | true | whether to auto-load the default async options set
autosize | bool | true | If enabled, the input will expand as the length of its value increases
backspaceRemoves | bool | true | whether pressing backspace removes the last item when there is no input value
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
cache | bool | true | enables the options cache for `asyncOptions` (default: `true`)
className | string | undefined | className for the outer element
clearable | bool | true | should it be possible to reset value
clearAllText | string | 'Clear all' | title for the "clear" control when `multi` is true
clearRenderer | func | undefined | Renders a custom clear to be shown in the right-hand side of the select when clearable true: `clearRenderer()`
clearValueText | string | 'Clear value' | title for the "clear" control
resetValue | any | null | value to use when you clear the control
deleteRemoves | bool | true | whether pressing delete key removes the last item when there is no input value
delimiter | string | ',' | delimiter to use to join multiple values
disabled | bool | false | whether the Select is disabled or not
filterOption | func | undefined | method to filter a single option: `function(option, filterString)`
filterOptions | func | undefined | method to filter the options array: `function([options], filterString, [values])`
ignoreAccents | bool | true | whether to strip accents when filtering
ignoreCase | bool | true | whether to perform case-insensitive filtering
inputProps | object | {} | custom attributes for the Input (in the Select-control) e.g: `{'data-foo': 'bar'}`
isLoading | bool | false | whether the Select is loading externally or not (such as options being loaded)
joinValues | bool | false | join multiple values into a single hidden input using the `delimiter`
labelKey | string | 'label' | the option property to use for the label
loadOptions | func | undefined | function that returns a promise or calls a callback with the options: `function(input, [callback])`
matchPos | string | 'any' | (any, start) match the start or entire string when filtering
matchProp | string | 'any' | (any, label, value) which option property to filter on
menuBuffer | number | 0 | buffer of px between the base of the dropdown and the viewport to shift if menu doesnt fit in viewport
menuRenderer | func | undefined | Renders a custom menu with options; accepts the following named parameters: `menuRenderer({ focusedOption, focusOption, options, selectValue, valueArray })`
multi | bool | undefined | multi-value input
name | string | undefined | field name, for hidden `<input />` tag
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)
onBlur | func | undefined | onBlur handler: `function(event) {}`
onBlurResetsInput | bool | true | whether to clear input on blur or not
onChange | func | undefined | onChange handler: `function(newValue) {}`
onClose | func | undefined | handler for when the menu closes: `function () {}`
onCloseResetsInput | bool | true | whether to clear input when closing the menu through the arrow
onFocus | func | undefined | onFocus handler: `function(event) {}`
onInputChange | func | undefined | onInputChange handler: `function(inputValue) {}`
onInputKeyDown | func | undefined | input keyDown handler; call `event.preventDefault()` to override default `Select` behavior: `function(event) {}`
onOpen | func | undefined | handler for when the menu opens: `function () {}`
onValueClick | func | undefined | onClick handler for value labels: `function (value, event) {}`
openOnFocus | bool | false | open the options menu when the input gets focus (requires searchable = true)
optionRenderer | func | undefined | function which returns a custom way to render the options in the menu
options | array | undefined | array of options
placeholder | string\|node | 'Select ...' | field placeholder, displayed when there's no value
renderInvalidValues | bool | false | if a `value` does not match any `options`, render it anyway
scrollMenuIntoView | bool | true | whether the viewport will shift to display the entire menu when engaged
searchable | bool | true | whether to enable searching feature or not
searchPromptText | string\|node | 'Type to search' | label to prompt for search input
tabSelectsValue | bool | true | whether to select the currently focused value when the `[tab]` key is pressed
value | any | undefined | initial field value
valueKey | string | 'value' | the option property to use for the value
valueRenderer | func | undefined | function which returns a custom way to render the value selected `function (option) {}`
| Property | Type | Default | Description |
|:---|:---|:---|:---|
| addLabelText | string | 'Add "{label}"?' | text to display when `allowCreate` is true |
arrowRenderer | func | undefined | Renders a custom drop-down arrow to be shown in the right-hand side of the select: `arrowRenderer({ onMouseDown, isOpen })` |
| autoBlur | bool | false | Blurs the input element after a selection has been made. Handy for lowering the keyboard on mobile devices |
| autofocus | bool | undefined | autofocus the component on mount |
| autoload | bool | true | whether to auto-load the default async options set |
| autosize | bool | true | If enabled, the input will expand as the length of its value increases |
| backspaceRemoves | bool | true | whether pressing backspace removes the last item when there is no input value |
| 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 |
| cache | bool | true | enables the options cache for `asyncOptions` (default: `true`) |
| className | string | undefined | className for the outer element |
| clearable | bool | true | should it be possible to reset value |
| clearAllText | string | 'Clear all' | title for the "clear" control when `multi` is true |
| clearRenderer | func | undefined | Renders a custom clear to be shown in the right-hand side of the select when clearable true: `clearRenderer()` |
| clearValueText | string | 'Clear value' | title for the "clear" control |
| resetValue | any | null | value to use when you clear the control |
| deleteRemoves | bool | true | whether pressing delete key removes the last item when there is no input value |
| delimiter | string | ',' | delimiter to use to join multiple values |
| disabled | bool | false | whether the Select is disabled or not |
| filterOption | func | undefined | method to filter a single option: `function(option, filterString)` |
| filterOptions | func | undefined | method to filter the options array: `function([options], filterString, [values])` |
| ignoreAccents | bool | true | whether to strip accents when filtering |
| ignoreCase | bool | true | whether to perform case-insensitive filtering |
| inputProps | object | {} | custom attributes for the Input (in the Select-control) e.g: `{'data-foo': 'bar'}` |
| isLoading | bool | false | whether the Select is loading externally or not (such as options being loaded) |
| joinValues | bool | false | join multiple values into a single hidden input using the `delimiter` |
| labelKey | string | 'label' | the option property to use for the label |
| loadOptions | func | undefined | function that returns a promise or calls a callback with the options: `function(input, [callback])` |
| matchPos | string | 'any' | (any, start) match the start or entire string when filtering |
| matchProp | string | 'any' | (any, label, value) which option property to filter on |
| menuBuffer | number | 0 | buffer of px between the base of the dropdown and the viewport to shift if menu doesnt fit in viewport |
| menuRenderer | func | undefined | Renders a custom menu with options; accepts the following named parameters: `menuRenderer({ focusedOption, focusOption, options, selectValue, valueArray })` |
| multi | bool | undefined | multi-value input |
| name | string | undefined | field name, for hidden `<input />` tag |
| 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) |
| onBlur | func | undefined | onBlur handler: `function(event) {}` |
| onBlurResetsInput | bool | true | whether to clear input on blur or not |
| onChange | func | undefined | onChange handler: `function(newValue) {}` |
| onClose | func | undefined | handler for when the menu closes: `function () {}` |
| onCloseResetsInput | bool | true | whether to clear input when closing the menu through the arrow |
| onFocus | func | undefined | onFocus handler: `function(event) {}` |
| onInputChange | func | undefined | onInputChange handler: `function(inputValue) {}` |
| onInputKeyDown | func | undefined | input keyDown handler; call `event.preventDefault()` to override default `Select` behavior: `function(event) {}` |
| onOpen | func | undefined | handler for when the menu opens: `function () {}` |
| onValueClick | func | undefined | onClick handler for value labels: `function (value, event) {}` |
| openOnFocus | bool | false | open the options menu when the input gets focus (requires searchable = true) |
| optionRenderer | func | undefined | function which returns a custom way to render the options in the menu |
| options | array | undefined | array of options |
| placeholder | string\|node | 'Select ...' | field placeholder, displayed when there's no value |
| scrollMenuIntoView | bool | true | whether the viewport will shift to display the entire menu when engaged |
| searchable | bool | true | whether to enable searching feature or not |
| searchPromptText | string\|node | 'Type to search' | label to prompt for search input |
| loadingPlaceholder | string\|node | 'Loading...' | label to prompt for loading search result |
| tabSelectsValue | bool | true | whether to select the currently focused value when the `[tab]` key is pressed |
| value | any | undefined | initial field value |
| valueKey | string | 'value' | the option property to use for the value |
| valueRenderer | func | undefined | function which returns a custom way to render the value selected `function (option) {}` |

@@ -407,0 +407,0 @@ ### Methods

@@ -16,2 +16,3 @@ import React, { Component, PropTypes } from 'react';

loadOptions: React.PropTypes.func.isRequired, // callback to load options asynchronously; (inputValue: string, callback: Function): ?Promise
multi: React.PropTypes.bool, // multi-value input
options: PropTypes.array.isRequired, // array of options

@@ -142,16 +143,26 @@ placeholder: React.PropTypes.oneOfType([ // field placeholder, displayed when there's no value (shared with Select)

const { ignoreAccents, ignoreCase, onInputChange } = this.props;
let newInputValue = inputValue;
if (onInputChange) {
const value = onInputChange(newInputValue);
// Note: != used deliberately here to catch undefined and null
if (value != null && typeof value !== 'object') {
newInputValue = '' + value;
}
}
let transformedInputValue = newInputValue;
if (ignoreAccents) {
inputValue = stripDiacritics(inputValue);
transformedInputValue = stripDiacritics(transformedInputValue);
}
if (ignoreCase) {
inputValue = inputValue.toLowerCase();
transformedInputValue = transformedInputValue.toLowerCase();
}
if (onInputChange) {
onInputChange(inputValue);
}
this.loadOptions(transformedInputValue);
return this.loadOptions(inputValue);
// Return new input value, but without applying toLowerCase() to avoid modifying the user's view case of the input while typing.
return newInputValue;
}

@@ -158,0 +169,0 @@

@@ -16,2 +16,6 @@ import React from 'react';

focus () {
this.select.focus();
},
render () {

@@ -30,2 +34,3 @@ return (

ref={(ref) => {
this.select = ref;
creatableProps.ref(ref);

@@ -32,0 +37,0 @@ asyncProps.ref(ref);

@@ -206,2 +206,6 @@ import React from 'react';

focus () {
this.select.focus();
},
render () {

@@ -208,0 +212,0 @@ const {

@@ -16,2 +16,3 @@ /*!

import defaultClearRenderer from './utils/defaultClearRenderer';
import stripDiacritics from './utils/stripDiacritics';

@@ -68,2 +69,3 @@ import Async from './Async';

addLabelText: React.PropTypes.string, // placeholder displayed when you want to add a label on a multi-value input
'aria-describedby': React.PropTypes.string, // HTML ID(s) of element(s) that should be used to describe this input (for assistive tech)
'aria-label': React.PropTypes.string, // Aria label (for assistive tech)

@@ -196,3 +198,3 @@ 'aria-labelledby': React.PropTypes.string, // HTML ID of an element that should be used as the label (for assistive tech)

isFocused: false,
isOpen: false,
isOpen: this.props.isOpen != null ? this.props.isOpen : false,
isPseudoFocused: false,

@@ -228,2 +230,6 @@ required: false,

if (!nextProps.isOpen && this.props.isOpen) {
this.closeMenu();
}
if (nextProps.required) {

@@ -250,3 +256,3 @@ this.setState({

let focusedOptionParent = focusedOptionNode.parentElement;
let menuNode = ReactDOM.findDOMNode(this.menu);
let menuNode = ReactDOM.findDOMNode(this.menu);
if (focusedOptionPreviousSibling) {

@@ -258,3 +264,5 @@ menuNode.scrollTop = focusedOptionPreviousSibling.offsetTop;

menuNode.scrollTop = focusedOptionNode.offsetTop;
}
}
const paddingTop = parseInt(window.getComputedStyle(menuNode, null).paddingTop, 10);
if (menuNode.scrollTop <= paddingTop) menuNode.scrollTop = 0;
this.hasScrolledToOption = true;

@@ -408,3 +416,3 @@ } else if (!this.state.isOpen) {

// otherwise, focus the input and open the menu
this._openAfterFocus = true;
this._openAfterFocus = this.props.openOnFocus;
this.focus();

@@ -912,2 +920,3 @@ }

'aria-activedescendant': isOpen ? this._instancePrefix + '-option-' + focusedOptionIndex : this._instancePrefix + '-value',
'aria-describedby': this.props['aria-describedby'],
'aria-labelledby': this.props['aria-labelledby'],

@@ -1143,3 +1152,10 @@ 'aria-label': this.props['aria-label'],

if (focusedOption && !focusedOption.disabled) {
const focusedOptionIndex = options.indexOf(focusedOption);
let focusedOptionIndex = -1;
options.some((option, index) => {
const isOptionEqual = option.value === focusedOption.value;
if (isOptionEqual) {
focusedOptionIndex = index;
}
return isOptionEqual;
});
if (focusedOptionIndex !== -1) {

@@ -1182,3 +1198,2 @@ return focusedOptionIndex;

let isOpen = typeof this.props.isOpen === 'boolean' ? this.props.isOpen : this.state.isOpen;
if (this.props.multi && !options.length && valueArray.length && !this.state.inputValue) isOpen = false;
const focusedOptionIndex = this.getFocusableOptionIndex(valueArray[0]);

@@ -1248,2 +1263,4 @@

Select.stripDiacritics = stripDiacritics;
export default Select;

@@ -436,2 +436,11 @@ 'use strict';

});
it('should change the value when onInputChange returns a value', () => {
const onInputChange = sinon.stub().returns('2');
const instance = createControl({
onInputChange,
});
typeSearchText('1');
return expect(filterInputNode.value, 'to equal', '2');
});
});

@@ -438,0 +447,0 @@

@@ -62,2 +62,15 @@ 'use strict';

});
describe('.focus()', () => {
beforeEach(() => {
createControl({});
TestUtils.Simulate.blur(filterInputNode);
});
it('focuses the search input', () => {
expect(filterInputNode, 'not to equal', document.activeElement);
creatableInstance.focus();
expect(filterInputNode, 'to equal', document.activeElement);
});
});
});

@@ -240,2 +240,15 @@ 'use strict';

});
describe('.focus()', () => {
beforeEach(() => {
createControl({});
TestUtils.Simulate.blur(filterInputNode);
});
it('focuses the search input', () => {
expect(filterInputNode, 'not to equal', document.activeElement);
creatableInstance.focus();
expect(filterInputNode, 'to equal', document.activeElement);
});
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc