diff --git a/.babelrc b/.babelrc index c2e3f9c..419ff8e 100644 --- a/.babelrc +++ b/.babelrc @@ -1,4 +1,4 @@ { "presets": ["es2015", "react", "stage-1"], - "plugins": ["transform-async-to-generator", "transform-flow-strip-types"] + "plugins": ["transform-async-to-generator", "transform-flow-strip-types", ["transform-runtime", {"polyfill": false}]] } diff --git a/package.json b/package.json index 23a15ce..8fda07f 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "author": "Daniel Moi", "license": "Apache-2.0", "dependencies": { + "@babel/runtime": "^7.5.5", "classnames": "^2.2.5", "immutable": "^3.8.1", "react": "^15.4.2", @@ -35,6 +36,7 @@ "babel-plugin-istanbul": "^4.0.0", "babel-plugin-transform-async-to-generator": "^6.24.1", "babel-plugin-transform-flow-strip-types": "^6.22.0", + "babel-plugin-transform-runtime": "^6.23.0", "babel-preset-es2015": "^6.22.0", "babel-preset-react": "^6.23.0", "babel-preset-stage-1": "^6.22.0", diff --git a/src/components/SelectSearchBase.js b/src/components/SelectSearchBase.js index d8cbfb6..d96fcdc 100644 --- a/src/components/SelectSearchBase.js +++ b/src/components/SelectSearchBase.js @@ -6,6 +6,7 @@ import type { Options, Selected, Callback } from '../types'; type SelectSearchBaseProps = { // config id: string, + isMultipleSelect: boolean, // appearance label: string, @@ -41,11 +42,19 @@ class SelectSearchBase extends Component { prefix, handleScroll, useImages, + isMultipleSelect, searchTerm = '', } = this.props; const selectedLength = (selected && selected.size) || (selected && selected.length); + let optionsAvailable = !!options; + if (!isMultipleSelect) { + if (selectedLength === 1) { + optionsAvailable = false; + } + } + return (
@@ -65,67 +74,69 @@ class SelectSearchBase extends Component { ))}
- + {isMultipleSelect || optionsAvailable ? + + : null }
{isOpen && options - ? -
- {options.map(option => ( -
- - - {useImages - ? - - : - + ? +
+ {options.map(option => ( +
+ + + {useImages + ? + + : + } -
+
))} -
- : +
+ : null } diff --git a/src/components/SelectSearchConnected.js b/src/components/SelectSearchConnected.js index 5ad8d8a..a91a6c0 100644 --- a/src/components/SelectSearchConnected.js +++ b/src/components/SelectSearchConnected.js @@ -17,6 +17,7 @@ import type { Options, Selected, Callback } from '../types'; type SelectSearchConnectedProps = { // config id: string, + isMultipleSelect: boolean, // appearance label: string, @@ -109,6 +110,7 @@ export class SelectSearchConnectedComponent extends Component { return (