diff --git a/dist/index.js b/dist/index.js index 851570f..ee2db06 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1 +1 @@ -"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var React=require("react"),React__default=_interopDefault(React);function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var l=0;l>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var r=arguments[1],i=0;i>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var r=arguments[1],i=0;i { style, multiple, tabIndex, + disabled, } = props; const cssClass = isSelected ? 'option selected' : 'option'; const body = isDataObject(item, labelKey, valueKey) ? item[labelKey] : item; const inputType = multiple ? 'checkbox' : 'radio'; - const select = () => selectValue(item); + const select = () => !disabled && selectValue(item); return (
{ onClick={select} onKeyPress={e => { e.preventDefault(); - selectValue(item); + if (!disabled) { + selectValue(item); + } }} > { return { @@ -179,6 +180,7 @@ class Picky extends React.PureComponent { render, tabIndex, renderList, + disabled, } = this.props; if (renderList) { return renderList({ @@ -188,6 +190,7 @@ class Picky extends React.PureComponent { tabIndex, getIsSelected: this.isItemSelected, selectValue: this.selectValue, + disabled, }); } return items.map((item, index) => { @@ -205,6 +208,7 @@ class Picky extends React.PureComponent { labelKey: labelKey, valueKey: valueKey, multiple: multiple, + disabled, }); } else { // Render a simple option @@ -218,6 +222,7 @@ class Picky extends React.PureComponent { valueKey={valueKey} multiple={multiple} tabIndex={tabIndex} + disabled={disabled} id={this.state.id + '-option-' + index} /> ); @@ -281,7 +286,11 @@ class Picky extends React.PureComponent { if (this.node && this.node.contains(e.target) && keepOpen) { return; } - if (this.filter && this.filter.filterInput && this.filter.filterInput.contains(e.target)) { + if ( + this.filter && + this.filter.filterInput && + this.filter.filterInput.contains(e.target) + ) { return; } this.toggleDropDown(); @@ -344,6 +353,7 @@ class Picky extends React.PureComponent { dropdownHeight, renderSelectAll, filterPlaceholder, + disabled, } = this.props; const { open } = this.state; let ariaOwns = ''; @@ -369,7 +379,10 @@ class Picky extends React.PureComponent {