Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-select-search

Package Overview
Dependencies
Maintainers
1
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-select-search - npm Package Compare versions

Comparing version 3.0.2 to 3.0.3

21

dist/cjs/lib/getOption.js

@@ -15,4 +15,23 @@ "use strict";

var newValue = value === null && options.length ? options[0].value : value; // eslint-disable-next-line eqeqeq
var newValue = value;
if (newValue === null && options.length) {
var i = 0;
var defaultOption = options[0];
while (defaultOption && defaultOption.disabled) {
if (options.length < i) {
defaultOption = false;
}
i += 1;
defaultOption = options[i];
}
if (defaultOption) {
newValue = defaultOption.value;
}
} // eslint-disable-next-line eqeqeq
return options.find(function (o) {

@@ -19,0 +38,0 @@ return o.value == newValue;

35

dist/cjs/lib/getOptions.js

@@ -13,9 +13,8 @@ "use strict";

function getOptions(value, oldValue, options, multiple) {
var newOption = (0, _getOption["default"])(value, options);
if (!multiple) {
return newOption || oldValue;
return (0, _getOption["default"])(value, options) || oldValue;
}
var newOptions = (0, _valuteToArray["default"])(oldValue).map(function (o) {
var oldOptions = (0, _valuteToArray["default"])(oldValue);
var newOptions = (0, _valuteToArray["default"])(value).map(function (o) {
return (0, _getOption["default"])(o, options);

@@ -26,18 +25,22 @@ }).filter(function (o) {

if (!newOption) {
if (!oldOptions.length) {
return newOptions;
} // eslint-disable-next-line eqeqeq
}
if (!newOptions.length) {
return oldOptions;
}
var optionIndex = newOptions.findIndex(function (o) {
return o.value == newOption.value;
newOptions.forEach(function (newOption) {
var optionIndex = oldOptions.findIndex(function (o) {
return o.value == newOption.value;
});
if (optionIndex >= 0) {
oldOptions.splice(optionIndex, 1);
} else {
oldOptions.push(newOption);
}
});
if (optionIndex >= 0) {
newOptions.splice(optionIndex, 1);
} else {
newOptions.push(newOption);
}
return newOptions;
return oldOptions;
}

@@ -7,3 +7,7 @@ "use strict";

function valueToArray(value) {
return !Array.isArray(value) ? [value] : value;
if (!value) {
return [];
}
return !Array.isArray(value) ? [value] : [].concat(value);
}

@@ -7,5 +7,24 @@ import isOption from './isOption';

const newValue = value === null && options.length ? options[0].value : value; // eslint-disable-next-line eqeqeq
let newValue = value;
if (newValue === null && options.length) {
let i = 0;
let defaultOption = options[0];
while (defaultOption && defaultOption.disabled) {
if (options.length < i) {
defaultOption = false;
}
i += 1;
defaultOption = options[i];
}
if (defaultOption) {
newValue = defaultOption.value;
}
} // eslint-disable-next-line eqeqeq
return options.find(o => o.value == newValue);
}
import valueToArray from './valuteToArray';
import getOption from './getOption';
export default function getOptions(value, oldValue, options, multiple) {
const newOption = getOption(value, options);
if (!multiple) {
return newOption || oldValue;
return getOption(value, options) || oldValue;
}
const newOptions = valueToArray(oldValue).map(o => getOption(o, options)).filter(o => o !== null && o !== undefined);
const oldOptions = valueToArray(oldValue);
const newOptions = valueToArray(value).map(o => getOption(o, options)).filter(o => o !== null && o !== undefined);
if (!newOption) {
if (!oldOptions.length) {
return newOptions;
} // eslint-disable-next-line eqeqeq
}
if (!newOptions.length) {
return oldOptions;
}
const optionIndex = newOptions.findIndex(o => o.value == newOption.value);
newOptions.forEach(newOption => {
const optionIndex = oldOptions.findIndex(o => o.value == newOption.value);
if (optionIndex >= 0) {
newOptions.splice(optionIndex, 1);
} else {
newOptions.push(newOption);
}
return newOptions;
if (optionIndex >= 0) {
oldOptions.splice(optionIndex, 1);
} else {
oldOptions.push(newOption);
}
});
return oldOptions;
}
export default function valueToArray(value) {
return !Array.isArray(value) ? [value] : value;
if (!value) {
return [];
}
return !Array.isArray(value) ? [value] : [...value];
}
{
"name": "react-select-search",
"version": "3.0.2",
"version": "3.0.3",
"description": "Lightweight select component for React",

@@ -38,5 +38,5 @@ "main": "dist/esm/index.js",

"peerDependencies": {
"prop-types": "^15.7.2",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"prop-types": "^15.7.2"
"react-dom": "^17.0.1"
},

@@ -81,5 +81,2 @@ "devDependencies": {

},
"dependencies": {
"fuse.js": "^3.4.5"
},
"optionalDependencies": {

@@ -86,0 +83,0 @@ "fuse.js": "^3.4.5"

@@ -96,2 +96,3 @@ import {

ref?:Ref<Component>
emptyMessage?:string
}

@@ -98,0 +99,0 @@

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