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

react-select-async-paginate

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-select-async-paginate - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

es/__tests__/index-test.js

179

lib/index.js

@@ -1,33 +0,40 @@

'use strict';
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _objectSpread5 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread"));
var _react = require('react');
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _react2 = _interopRequireDefault(_react);
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _propTypes = require('prop-types');
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _propTypes2 = _interopRequireDefault(_propTypes);
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _reactSelect = require('react-select');
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
var _react = _interopRequireWildcard(require("react"));
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _propTypes = _interopRequireDefault(require("prop-types"));
var _reactSelect = require("react-select");
var initialCache = {

@@ -39,13 +46,13 @@ options: [],

var AsyncPaginate = function (_Component) {
_inherits(AsyncPaginate, _Component);
var AsyncPaginate =
/*#__PURE__*/
function (_Component) {
(0, _inherits2.default)(AsyncPaginate, _Component);
function AsyncPaginate(props) {
var _this2 = this;
var _this;
_classCallCheck(this, AsyncPaginate);
var _this = _possibleConstructorReturn(this, (AsyncPaginate.__proto__ || Object.getPrototypeOf(AsyncPaginate)).call(this, props));
_this.onMenuClose = function () {
(0, _classCallCheck2.default)(this, AsyncPaginate);
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(AsyncPaginate).call(this, props));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)), "onMenuClose", function () {
_this.setState({

@@ -55,7 +62,10 @@ search: '',

});
};
_this.onMenuOpen = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
});
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)), "onMenuOpen",
/*#__PURE__*/
(0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee() {
var optionsCache;
return regeneratorRuntime.wrap(function _callee$(_context) {
return _regenerator.default.wrap(function _callee$(_context) {
while (1) {

@@ -81,13 +91,16 @@ switch (_context.prev = _context.next) {

case 6:
case 'end':
case "end":
return _context.stop();
}
}
}, _callee, _this2);
}));
_this.onInputChange = function () {
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(search) {
}, _callee, this);
})));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)), "onInputChange",
/*#__PURE__*/
function () {
var _ref2 = (0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee2(search) {
var optionsCache;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
return _regenerator.default.wrap(function _callee2$(_context2) {
while (1) {

@@ -113,7 +126,7 @@ switch (_context2.prev = _context2.next) {

case 6:
case 'end':
case "end":
return _context2.stop();
}
}
}, _callee2, _this2);
}, _callee2, this);
}));

@@ -124,8 +137,11 @@

};
}();
_this.onMenuScrollToBottom = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
}());
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)), "onMenuScrollToBottom",
/*#__PURE__*/
(0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee3() {
var _this$state, search, optionsCache, currentOptions;
return regeneratorRuntime.wrap(function _callee3$(_context3) {
return _regenerator.default.wrap(function _callee3$(_context3) {
while (1) {

@@ -146,10 +162,8 @@ switch (_context3.prev = _context3.next) {

case 5:
case 'end':
case "end":
return _context3.stop();
}
}
}, _callee3, _this2);
}));
}, _callee3, this);
})));
var initialOptionsCache = props.options ? {

@@ -162,3 +176,2 @@ '': {

} : {};
_this.state = {

@@ -172,8 +185,7 @@ search: '',

_createClass(AsyncPaginate, [{
key: 'componentDidUpdate',
(0, _createClass2.default)(AsyncPaginate, [{
key: "componentDidUpdate",
value: function componentDidUpdate(oldProps) {
var cacheUniq = this.props.cacheUniq;
if (oldProps.cacheUniq !== cacheUniq) {

@@ -186,12 +198,14 @@ this.setState({

}, {
key: 'loadOptions',
key: "loadOptions",
value: function () {
var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
var _state, search, optionsCache, currentOptions, _loadOptions, _ref5, options, hasMore;
var _loadOptions = (0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee4() {
var _this$state2, search, optionsCache, currentOptions, _loadOptions2, _ref4, options, hasMore;
return regeneratorRuntime.wrap(function _callee4$(_context4) {
return _regenerator.default.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_state = this.state, search = _state.search, optionsCache = _state.optionsCache;
_this$state2 = this.state, search = _this$state2.search, optionsCache = _this$state2.optionsCache;
currentOptions = optionsCache[search] || initialCache;

@@ -204,3 +218,3 @@

return _context4.abrupt('return');
return _context4.abrupt("return");

@@ -212,3 +226,3 @@ case 4:

search: search,
optionsCache: _extends({}, prevState.optionsCache, _defineProperty({}, search, _extends({}, currentOptions, {
optionsCache: (0, _objectSpread5.default)({}, prevState.optionsCache, (0, _defineProperty2.default)({}, search, (0, _objectSpread5.default)({}, currentOptions, {
isLoading: true

@@ -221,14 +235,14 @@ })))

_context4.prev = 6;
_loadOptions = this.props.loadOptions;
_loadOptions2 = this.props.loadOptions;
_context4.next = 10;
return _loadOptions(search, currentOptions.options);
return _loadOptions2(search, currentOptions.options);
case 10:
_ref5 = _context4.sent;
options = _ref5.options;
hasMore = _ref5.hasMore;
_ref4 = _context4.sent;
options = _ref4.options;
hasMore = _ref4.hasMore;
_context4.next = 15;
return this.setState(function (prevState) {
return {
optionsCache: _extends({}, prevState.optionsCache, _defineProperty({}, search, _extends({}, currentOptions, {
optionsCache: (0, _objectSpread5.default)({}, prevState.optionsCache, (0, _defineProperty2.default)({}, search, (0, _objectSpread5.default)({}, currentOptions, {
options: currentOptions.options.concat(options),

@@ -247,7 +261,7 @@ hasMore: !!hasMore,

_context4.prev = 17;
_context4.t0 = _context4['catch'](6);
_context4.t0 = _context4["catch"](6);
_context4.next = 21;
return this.setState(function (prevState) {
return {
optionsCache: _extends({}, prevState.optionsCache, _defineProperty({}, search, _extends({}, currentOptions, {
optionsCache: (0, _objectSpread5.default)({}, prevState.optionsCache, (0, _defineProperty2.default)({}, search, (0, _objectSpread5.default)({}, currentOptions, {
isLoading: false

@@ -259,3 +273,3 @@ })))

case 21:
case 'end':
case "end":
return _context4.stop();

@@ -268,3 +282,3 @@ }

function loadOptions() {
return _ref4.apply(this, arguments);
return _loadOptions.apply(this, arguments);
}

@@ -275,14 +289,11 @@

}, {
key: 'render',
key: "render",
value: function render() {
var selectRef = this.props.selectRef;
var _state2 = this.state,
search = _state2.search,
optionsCache = _state2.optionsCache,
menuIsOpen = _state2.menuIsOpen;
var _this$state3 = this.state,
search = _this$state3.search,
optionsCache = _this$state3.optionsCache,
menuIsOpen = _this$state3.menuIsOpen;
var currentOptions = optionsCache[search] || initialCache;
return _react2.default.createElement(_reactSelect.SelectBase, _extends({}, this.props, {
return _react.default.createElement(_reactSelect.SelectBase, (0, _extends2.default)({}, this.props, {
inputValue: search,

@@ -300,18 +311,18 @@ menuIsOpen: menuIsOpen,

}]);
return AsyncPaginate;
}(_react.Component);
AsyncPaginate.propTypes = {
loadOptions: _propTypes2.default.func.isRequired,
(0, _defineProperty2.default)(AsyncPaginate, "propTypes", {
loadOptions: _propTypes.default.func.isRequired,
// eslint-disable-next-line react/forbid-prop-types
cacheUniq: _propTypes2.default.any,
selectRef: _propTypes2.default.func,
options: _propTypes2.default.arrayOf(_propTypes2.default.object)
};
AsyncPaginate.defaultProps = {
cacheUniq: _propTypes.default.any,
selectRef: _propTypes.default.func,
options: _propTypes.default.arrayOf(_propTypes.default.object)
});
(0, _defineProperty2.default)(AsyncPaginate, "defaultProps", {
cacheUniq: null,
selectRef: function selectRef() {},
options: null
};
exports.default = AsyncPaginate;
});
var _default = AsyncPaginate;
exports.default = _default;
{
"name": "react-select-async-paginate",
"version": "0.2.0",
"version": "0.2.1",
"description": "Wrapper above react-select that supports pagination on menu scroll",
"main": "lib/index.js",
"module": "es/index.js",
"repository": "git@github.com:vtaits/react-select-async-paginate.git",

@@ -10,3 +11,5 @@ "author": "Vadim Taits",

"scripts": {
"build": "babel src --out-dir lib --ignore __tests__",
"build": "yarn build:cjs && yarn build:es",
"build:cjs": "cross-env BABEL_ENV=cjs babel src --out-dir lib --ignore \"src/js/**/__tests__\"",
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es --ignore \"src/js/**/__tests__\"",
"lint": "eslint src --ext .js,.jsx",

@@ -20,26 +23,30 @@ "test:unit": "jest",

"react": "^15.0.0 || ^16.0.0",
"react-select": "^1.0.0 || ^2.0.0"
"react-select": "^2.0.0"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-eslint": "^8.2.6",
"babel-jest": "^23.4.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"eslint": "^5.2.0",
"eslint-config-airbnb": "^17.0.0",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-jest": "^21.18.0",
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-react": "^7.10.0",
"jest": "^23.4.1",
"@babel/cli": "^7.2.3",
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.2.3",
"@babel/plugin-transform-runtime": "^7.2.0",
"@babel/preset-env": "^7.2.3",
"@babel/preset-react": "^7.0.0",
"babel-core": "^7.0.0-bridge",
"babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0",
"cross-env": "^5.2.0",
"enzyme": "^3.8.0",
"enzyme-adapter-react-16": "^1.7.1",
"eslint": "^5.10.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jest": "^22.1.2",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-react": "^7.11.1",
"jest": "^23.6.0",
"prop-types": "^15.6.2",
"raf": "^3.4.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-select": "^2.0.0",
"react-test-renderer": "^16.4.1"
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-select": "^2.1.2",
"react-test-renderer": "^16.7.0"
},

@@ -54,3 +61,6 @@ "jest": {

]
},
"dependencies": {
"@babel/runtime": "^7.2.0"
}
}

@@ -60,3 +60,2 @@ [![NPM](https://img.shields.io/npm/v/react-select-async-paginate.svg)](https://www.npmjs.com/package/react-select-async-paginate)

```
import 'react-select/dist/react-select.css';
import AsyncPaginate from 'react-select-async-paginate';

@@ -63,0 +62,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