Skip to content

drop isMutableSelect attr down and add babel/runtime new item to plugins #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -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}]]
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
117 changes: 64 additions & 53 deletions src/components/SelectSearchBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { Options, Selected, Callback } from '../types';
type SelectSearchBaseProps = {
// config
id: string,
isMultipleSelect: boolean,

// appearance
label: string,
Expand Down Expand Up @@ -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 (
<div className={`${prefix}__wrapper`}>
<div className={`${prefix}__label`}>
Expand All @@ -65,67 +74,69 @@ class SelectSearchBase extends Component {
))}
</div>

<input
type="text"
className={`${prefix}__search-input`}
autoFocus
onChange={this.handleSearch}
onClick={this.handleSearch}
placeholder={placeholder}
value={searchTerm}
/>
{isMultipleSelect || optionsAvailable ?
<input
type="text"
className={`${prefix}__search-input`}
autoFocus
onChange={this.handleSearch}
onClick={this.handleSearch}
placeholder={placeholder}
value={searchTerm}
/>
: null }
</div>


{isOpen && options
?
<div
className={`${prefix}__open-wrapper`}
onScroll={handleScroll}
>
{options.map(option => (
<div
key={`${option.get('id')}--option`}
className={`${prefix}__option-container`}
>
<input
id={`${option.get('id')}--option`}
className={`${prefix}__option-checkbox`}
type="checkbox"
checked={selected.has(option.get('id'))}
onChange={handleOptionClick(option)}
/>

{useImages
?
<label
htmlFor={`${option.get('id')}--option`}
className={`${prefix}__search-option-bar`}
>
<img
src={option.get('src')} alt={option.get('display')}
className={`${prefix}__search-option-bar-image`}
/>
<div className={`${prefix}__search-option-bar-text`}>
{option.get('display')}
</div>
</label>
:
<label
htmlFor={`${option.get('id')}--option`}
className={`${prefix}__search-option-bar`}
>
<div className={`${prefix}__search-option-bar-text`}>
{option.get('display')}
</div>
</label>
?
<div
className={`${prefix}__open-wrapper`}
onScroll={handleScroll}
>
{options.map(option => (
<div
key={`${option.get('id')}--option`}
className={`${prefix}__option-container`}
>
<input
id={`${option.get('id')}--option`}
className={`${prefix}__option-checkbox`}
type="checkbox"
checked={selected.has(option.get('id'))}
onChange={handleOptionClick(option)}
/>

{useImages
?
<label
htmlFor={`${option.get('id')}--option`}
className={`${prefix}__search-option-bar`}
>
<img
src={option.get('src')} alt={option.get('display')}
className={`${prefix}__search-option-bar-image`}
/>
<div className={`${prefix}__search-option-bar-text`}>
{option.get('display')}
</div>
</label>
:
<label
htmlFor={`${option.get('id')}--option`}
className={`${prefix}__search-option-bar`}
>
<div className={`${prefix}__search-option-bar-text`}>
{option.get('display')}
</div>
</label>
}


</div>
</div>
))}
</div>
:
</div>
:
null
}

Expand Down
2 changes: 2 additions & 0 deletions src/components/SelectSearchConnected.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import type { Options, Selected, Callback } from '../types';
type SelectSearchConnectedProps = {
// config
id: string,
isMultipleSelect: boolean,

// appearance
label: string,
Expand Down Expand Up @@ -109,6 +110,7 @@ export class SelectSearchConnectedComponent extends Component {
return (
<SelectSearchBase
id={this.props.id}
isMultipleSelect={this.props.isMultipleSelect}
label={this.props.label}
prefix={this.props.prefix}
placeholder={this.props.placeholder}
Expand Down
27 changes: 27 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
# yarn lockfile v1


"@babel/runtime@^7.5.5":
version "7.5.5"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.5.5.tgz#74fba56d35efbeca444091c7850ccd494fd2f132"
dependencies:
regenerator-runtime "^0.13.2"

abab@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.3.tgz#b81de5f7274ec4e756d797cd834f303642724e5d"
Expand Down Expand Up @@ -804,6 +810,12 @@ babel-plugin-transform-regenerator@^6.22.0:
dependencies:
regenerator-transform "0.9.8"

babel-plugin-transform-runtime@^6.23.0:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-runtime/-/babel-plugin-transform-runtime-6.23.0.tgz#88490d446502ea9b8e7efb0fe09ec4d99479b1ee"
dependencies:
babel-runtime "^6.22.0"

babel-plugin-transform-strict-mode@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.22.0.tgz#e008df01340fdc87e959da65991b7e05970c8c7c"
Expand Down Expand Up @@ -911,6 +923,13 @@ babel-runtime@^6.18.0, babel-runtime@^6.22.0:
core-js "^2.4.0"
regenerator-runtime "^0.10.0"

babel-runtime@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe"
dependencies:
core-js "^2.4.0"
regenerator-runtime "^0.11.0"

babel-template@^6.16.0, babel-template@^6.23.0:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.23.0.tgz#04d4f270adbb3aa704a8143ae26faa529238e638"
Expand Down Expand Up @@ -3653,6 +3672,14 @@ regenerator-runtime@^0.10.0:
version "0.10.1"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.1.tgz#257f41961ce44558b18f7814af48c17559f9faeb"

regenerator-runtime@^0.11.0:
version "0.11.1"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9"

regenerator-runtime@^0.13.2:
version "0.13.3"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz#7cf6a77d8f5c6f60eb73c5fc1955b2ceb01e6bf5"

regenerator-transform@0.9.8:
version "0.9.8"
resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.9.8.tgz#0f88bb2bc03932ddb7b6b7312e68078f01026d6c"
Expand Down