react-select-async-paginate
Advanced tools
Comparing version 0.3.4 to 0.3.5
import _extends from "@babel/runtime/helpers/extends"; | ||
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; | ||
import _objectSpread from "@babel/runtime/helpers/objectSpread"; | ||
import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
@@ -13,2 +12,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; | ||
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { keys.push.apply(keys, Object.getOwnPropertySymbols(object)); } if (enumerableOnly) keys = keys.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
import React, { Component } from 'react'; | ||
@@ -42,3 +46,3 @@ import PropTypes from 'prop-types'; | ||
_defineProperty(_assertThisInitialized(_this), "onMenuOpen", | ||
_defineProperty(_assertThisInitialized(_this), "handleScrolledToBottom", | ||
/*#__PURE__*/ | ||
@@ -48,3 +52,3 @@ _asyncToGenerator( | ||
_regeneratorRuntime.mark(function _callee() { | ||
var optionsCache; | ||
var inputValue, optionsCache, currentOptions; | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -54,13 +58,15 @@ while (1) { | ||
case 0: | ||
inputValue = _this.props.inputValue; | ||
optionsCache = _this.state.optionsCache; | ||
currentOptions = optionsCache[inputValue]; | ||
if (optionsCache['']) { | ||
_context.next = 4; | ||
if (!currentOptions) { | ||
_context.next = 6; | ||
break; | ||
} | ||
_context.next = 4; | ||
_context.next = 6; | ||
return _this.loadOptions(); | ||
case 4: | ||
case 6: | ||
case "end": | ||
@@ -73,9 +79,27 @@ return _context.stop(); | ||
_defineProperty(_assertThisInitialized(_this), "handleInputChange", | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref2 = _asyncToGenerator( | ||
var options = props.options, | ||
defaultOptions = props.defaultOptions; | ||
var initialOptions = defaultOptions === true ? null : defaultOptions instanceof Array ? defaultOptions : options; | ||
var initialOptionsCache = initialOptions ? { | ||
'': { | ||
isFirstLoad: false, | ||
isLoading: false, | ||
options: initialOptions, | ||
hasMore: true, | ||
additional: props.additional | ||
} | ||
} : {}; | ||
_this.state = { | ||
optionsCache: initialOptionsCache | ||
}; | ||
return _this; | ||
} | ||
_createClass(AsyncPaginateBase, [{ | ||
key: "componentDidMount", | ||
value: function () { | ||
var _componentDidMount = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
_regeneratorRuntime.mark(function _callee2(search) { | ||
var optionsCache; | ||
_regeneratorRuntime.mark(function _callee2() { | ||
var defaultOptions; | ||
return _regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
@@ -85,5 +109,5 @@ while (1) { | ||
case 0: | ||
optionsCache = _this.state.optionsCache; | ||
defaultOptions = this.props.defaultOptions; | ||
if (optionsCache[search]) { | ||
if (!(defaultOptions === true)) { | ||
_context2.next = 4; | ||
@@ -94,3 +118,3 @@ break; | ||
_context2.next = 4; | ||
return _this.loadOptions(); | ||
return this.loadOptions(); | ||
@@ -102,56 +126,12 @@ case 4: | ||
} | ||
}, _callee2); | ||
}, _callee2, this); | ||
})); | ||
return function (_x) { | ||
return _ref2.apply(this, arguments); | ||
}; | ||
}()); | ||
_defineProperty(_assertThisInitialized(_this), "handleScrolledToBottom", | ||
/*#__PURE__*/ | ||
_asyncToGenerator( | ||
/*#__PURE__*/ | ||
_regeneratorRuntime.mark(function _callee3() { | ||
var inputValue, optionsCache, currentOptions; | ||
return _regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
inputValue = _this.props.inputValue; | ||
optionsCache = _this.state.optionsCache; | ||
currentOptions = optionsCache[inputValue]; | ||
if (!currentOptions) { | ||
_context3.next = 6; | ||
break; | ||
} | ||
_context3.next = 6; | ||
return _this.loadOptions(); | ||
case 6: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
}, _callee3); | ||
}))); | ||
var initialOptionsCache = props.options ? { | ||
'': { | ||
isFirstLoad: false, | ||
isLoading: false, | ||
options: props.options, | ||
hasMore: true, | ||
additional: props.additional | ||
function componentDidMount() { | ||
return _componentDidMount.apply(this, arguments); | ||
} | ||
} : {}; | ||
_this.state = { | ||
optionsCache: initialOptionsCache | ||
}; | ||
return _this; | ||
} | ||
_createClass(AsyncPaginateBase, [{ | ||
return componentDidMount; | ||
}() | ||
}, { | ||
key: "componentDidUpdate", | ||
@@ -179,2 +159,37 @@ value: function componentDidUpdate(oldProps) { | ||
}, { | ||
key: "onMenuOpen", | ||
value: function () { | ||
var _onMenuOpen = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
_regeneratorRuntime.mark(function _callee3() { | ||
var optionsCache; | ||
return _regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
optionsCache = this.state.optionsCache; | ||
if (optionsCache['']) { | ||
_context3.next = 4; | ||
break; | ||
} | ||
_context3.next = 4; | ||
return this.loadOptions(); | ||
case 4: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
}, _callee3, this); | ||
})); | ||
function onMenuOpen() { | ||
return _onMenuOpen.apply(this, arguments); | ||
} | ||
return onMenuOpen; | ||
}() | ||
}, { | ||
key: "getInitialCache", | ||
@@ -192,2 +207,37 @@ value: function getInitialCache() { | ||
}, { | ||
key: "handleInputChange", | ||
value: function () { | ||
var _handleInputChange = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
_regeneratorRuntime.mark(function _callee4(search) { | ||
var optionsCache; | ||
return _regeneratorRuntime.wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
optionsCache = this.state.optionsCache; | ||
if (optionsCache[search]) { | ||
_context4.next = 4; | ||
break; | ||
} | ||
_context4.next = 4; | ||
return this.loadOptions(); | ||
case 4: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
} | ||
}, _callee4, this); | ||
})); | ||
function handleInputChange(_x) { | ||
return _handleInputChange.apply(this, arguments); | ||
} | ||
return handleInputChange; | ||
}() | ||
}, { | ||
key: "loadOptions", | ||
@@ -197,8 +247,8 @@ value: function () { | ||
/*#__PURE__*/ | ||
_regeneratorRuntime.mark(function _callee4() { | ||
_regeneratorRuntime.mark(function _callee5() { | ||
var inputValue, optionsCache, currentOptions, debounceTimeout, newInputValue, hasError, additional, options, hasMore, _loadOptions2, response, newAdditional, reduceOptions; | ||
return _regeneratorRuntime.wrap(function _callee4$(_context4) { | ||
return _regeneratorRuntime.wrap(function _callee5$(_context5) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
switch (_context5.prev = _context5.next) { | ||
case 0: | ||
@@ -210,10 +260,10 @@ inputValue = this.props.inputValue; | ||
if (!(currentOptions.isLoading || !currentOptions.hasMore)) { | ||
_context4.next = 5; | ||
_context5.next = 5; | ||
break; | ||
} | ||
return _context4.abrupt("return"); | ||
return _context5.abrupt("return"); | ||
case 5: | ||
_context4.next = 7; | ||
_context5.next = 7; | ||
return this.setState(function (prevState) { | ||
@@ -231,7 +281,7 @@ return { | ||
if (!(debounceTimeout > 0)) { | ||
_context4.next = 16; | ||
_context5.next = 16; | ||
break; | ||
} | ||
_context4.next = 11; | ||
_context5.next = 11; | ||
return sleep(debounceTimeout); | ||
@@ -243,7 +293,7 @@ | ||
if (!(inputValue !== newInputValue)) { | ||
_context4.next = 16; | ||
_context5.next = 16; | ||
break; | ||
} | ||
_context4.next = 15; | ||
_context5.next = 15; | ||
return this.setState(function (prevState) { | ||
@@ -258,12 +308,12 @@ return { | ||
case 15: | ||
return _context4.abrupt("return"); | ||
return _context5.abrupt("return"); | ||
case 16: | ||
_context4.prev = 16; | ||
_context5.prev = 16; | ||
_loadOptions2 = this.props.loadOptions; | ||
_context4.next = 20; | ||
_context5.next = 20; | ||
return _loadOptions2(inputValue, currentOptions.options, currentOptions.additional); | ||
case 20: | ||
response = _context4.sent; | ||
response = _context5.sent; | ||
options = response.options; | ||
@@ -273,8 +323,8 @@ hasMore = response.hasMore; | ||
hasError = false; | ||
_context4.next = 30; | ||
_context5.next = 30; | ||
break; | ||
case 27: | ||
_context4.prev = 27; | ||
_context4.t0 = _context4["catch"](16); | ||
_context5.prev = 27; | ||
_context5.t0 = _context5["catch"](16); | ||
hasError = true; | ||
@@ -284,7 +334,7 @@ | ||
if (!hasError) { | ||
_context4.next = 35; | ||
_context5.next = 35; | ||
break; | ||
} | ||
_context4.next = 33; | ||
_context5.next = 33; | ||
return this.setState(function (prevState) { | ||
@@ -299,3 +349,3 @@ return { | ||
case 33: | ||
_context4.next = 39; | ||
_context5.next = 39; | ||
break; | ||
@@ -306,3 +356,3 @@ | ||
reduceOptions = this.props.reduceOptions; | ||
_context4.next = 39; | ||
_context5.next = 39; | ||
return this.setState(function (prevState) { | ||
@@ -322,6 +372,6 @@ return { | ||
case "end": | ||
return _context4.stop(); | ||
return _context5.stop(); | ||
} | ||
} | ||
}, _callee4, this, [[16, 27]]); | ||
}, _callee5, this, [[16, 27]]); | ||
})); | ||
@@ -372,2 +422,3 @@ | ||
options: PropTypes.arrayOf(PropTypes.object), | ||
defaultOptions: PropTypes.oneOfType([PropTypes.bool, PropTypes.arrayOf(PropTypes.object)]), | ||
// eslint-disable-next-line react/forbid-prop-types | ||
@@ -389,2 +440,3 @@ additional: PropTypes.any, | ||
options: null, | ||
defaultOptions: false, | ||
additional: null, | ||
@@ -391,0 +443,0 @@ reduceOptions: defaultReduceOptions, |
@@ -1,3 +0,7 @@ | ||
import _objectSpread from "@babel/runtime/helpers/objectSpread"; | ||
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { keys.push.apply(keys, Object.getOwnPropertySymbols(object)); } if (enumerableOnly) keys = keys.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
var reduceGroupedOptions = function reduceGroupedOptions(prevOptions, loadedOptions) { | ||
@@ -4,0 +8,0 @@ var res = prevOptions.slice(); |
@@ -16,4 +16,2 @@ "use strict"; | ||
var _objectSpread6 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); | ||
@@ -49,2 +47,6 @@ | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { keys.push.apply(keys, Object.getOwnPropertySymbols(object)); } if (enumerableOnly) keys = keys.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
var MenuList = (0, _wrapMenuList["default"])(_reactSelect.components.MenuList); | ||
@@ -71,3 +73,3 @@ exports.MenuList = MenuList; | ||
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(AsyncPaginateBase).call(this, props)); | ||
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onMenuOpen", | ||
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleScrolledToBottom", | ||
/*#__PURE__*/ | ||
@@ -77,3 +79,3 @@ (0, _asyncToGenerator2["default"])( | ||
_regenerator["default"].mark(function _callee() { | ||
var optionsCache; | ||
var inputValue, optionsCache, currentOptions; | ||
return _regenerator["default"].wrap(function _callee$(_context) { | ||
@@ -83,13 +85,15 @@ while (1) { | ||
case 0: | ||
inputValue = _this.props.inputValue; | ||
optionsCache = _this.state.optionsCache; | ||
currentOptions = optionsCache[inputValue]; | ||
if (optionsCache['']) { | ||
_context.next = 4; | ||
if (!currentOptions) { | ||
_context.next = 6; | ||
break; | ||
} | ||
_context.next = 4; | ||
_context.next = 6; | ||
return _this.loadOptions(); | ||
case 4: | ||
case 6: | ||
case "end": | ||
@@ -101,9 +105,27 @@ return _context.stop(); | ||
}))); | ||
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleInputChange", | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref2 = (0, _asyncToGenerator2["default"])( | ||
var options = props.options, | ||
defaultOptions = props.defaultOptions; | ||
var initialOptions = defaultOptions === true ? null : defaultOptions instanceof Array ? defaultOptions : options; | ||
var initialOptionsCache = initialOptions ? { | ||
'': { | ||
isFirstLoad: false, | ||
isLoading: false, | ||
options: initialOptions, | ||
hasMore: true, | ||
additional: props.additional | ||
} | ||
} : {}; | ||
_this.state = { | ||
optionsCache: initialOptionsCache | ||
}; | ||
return _this; | ||
} | ||
(0, _createClass2["default"])(AsyncPaginateBase, [{ | ||
key: "componentDidMount", | ||
value: function () { | ||
var _componentDidMount = (0, _asyncToGenerator2["default"])( | ||
/*#__PURE__*/ | ||
_regenerator["default"].mark(function _callee2(search) { | ||
var optionsCache; | ||
_regenerator["default"].mark(function _callee2() { | ||
var defaultOptions; | ||
return _regenerator["default"].wrap(function _callee2$(_context2) { | ||
@@ -113,5 +135,5 @@ while (1) { | ||
case 0: | ||
optionsCache = _this.state.optionsCache; | ||
defaultOptions = this.props.defaultOptions; | ||
if (optionsCache[search]) { | ||
if (!(defaultOptions === true)) { | ||
_context2.next = 4; | ||
@@ -122,3 +144,3 @@ break; | ||
_context2.next = 4; | ||
return _this.loadOptions(); | ||
return this.loadOptions(); | ||
@@ -130,54 +152,12 @@ case 4: | ||
} | ||
}, _callee2); | ||
}, _callee2, this); | ||
})); | ||
return function (_x) { | ||
return _ref2.apply(this, arguments); | ||
}; | ||
}()); | ||
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleScrolledToBottom", | ||
/*#__PURE__*/ | ||
(0, _asyncToGenerator2["default"])( | ||
/*#__PURE__*/ | ||
_regenerator["default"].mark(function _callee3() { | ||
var inputValue, optionsCache, currentOptions; | ||
return _regenerator["default"].wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
inputValue = _this.props.inputValue; | ||
optionsCache = _this.state.optionsCache; | ||
currentOptions = optionsCache[inputValue]; | ||
if (!currentOptions) { | ||
_context3.next = 6; | ||
break; | ||
} | ||
_context3.next = 6; | ||
return _this.loadOptions(); | ||
case 6: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
}, _callee3); | ||
}))); | ||
var initialOptionsCache = props.options ? { | ||
'': { | ||
isFirstLoad: false, | ||
isLoading: false, | ||
options: props.options, | ||
hasMore: true, | ||
additional: props.additional | ||
function componentDidMount() { | ||
return _componentDidMount.apply(this, arguments); | ||
} | ||
} : {}; | ||
_this.state = { | ||
optionsCache: initialOptionsCache | ||
}; | ||
return _this; | ||
} | ||
(0, _createClass2["default"])(AsyncPaginateBase, [{ | ||
return componentDidMount; | ||
}() | ||
}, { | ||
key: "componentDidUpdate", | ||
@@ -205,2 +185,37 @@ value: function componentDidUpdate(oldProps) { | ||
}, { | ||
key: "onMenuOpen", | ||
value: function () { | ||
var _onMenuOpen = (0, _asyncToGenerator2["default"])( | ||
/*#__PURE__*/ | ||
_regenerator["default"].mark(function _callee3() { | ||
var optionsCache; | ||
return _regenerator["default"].wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
optionsCache = this.state.optionsCache; | ||
if (optionsCache['']) { | ||
_context3.next = 4; | ||
break; | ||
} | ||
_context3.next = 4; | ||
return this.loadOptions(); | ||
case 4: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
}, _callee3, this); | ||
})); | ||
function onMenuOpen() { | ||
return _onMenuOpen.apply(this, arguments); | ||
} | ||
return onMenuOpen; | ||
}() | ||
}, { | ||
key: "getInitialCache", | ||
@@ -218,2 +233,37 @@ value: function getInitialCache() { | ||
}, { | ||
key: "handleInputChange", | ||
value: function () { | ||
var _handleInputChange = (0, _asyncToGenerator2["default"])( | ||
/*#__PURE__*/ | ||
_regenerator["default"].mark(function _callee4(search) { | ||
var optionsCache; | ||
return _regenerator["default"].wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
optionsCache = this.state.optionsCache; | ||
if (optionsCache[search]) { | ||
_context4.next = 4; | ||
break; | ||
} | ||
_context4.next = 4; | ||
return this.loadOptions(); | ||
case 4: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
} | ||
}, _callee4, this); | ||
})); | ||
function handleInputChange(_x) { | ||
return _handleInputChange.apply(this, arguments); | ||
} | ||
return handleInputChange; | ||
}() | ||
}, { | ||
key: "loadOptions", | ||
@@ -223,8 +273,8 @@ value: function () { | ||
/*#__PURE__*/ | ||
_regenerator["default"].mark(function _callee4() { | ||
_regenerator["default"].mark(function _callee5() { | ||
var inputValue, optionsCache, currentOptions, debounceTimeout, newInputValue, hasError, additional, options, hasMore, _loadOptions2, response, newAdditional, reduceOptions; | ||
return _regenerator["default"].wrap(function _callee4$(_context4) { | ||
return _regenerator["default"].wrap(function _callee5$(_context5) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
switch (_context5.prev = _context5.next) { | ||
case 0: | ||
@@ -236,13 +286,13 @@ inputValue = this.props.inputValue; | ||
if (!(currentOptions.isLoading || !currentOptions.hasMore)) { | ||
_context4.next = 5; | ||
_context5.next = 5; | ||
break; | ||
} | ||
return _context4.abrupt("return"); | ||
return _context5.abrupt("return"); | ||
case 5: | ||
_context4.next = 7; | ||
_context5.next = 7; | ||
return this.setState(function (prevState) { | ||
return { | ||
optionsCache: (0, _objectSpread6["default"])({}, prevState.optionsCache, (0, _defineProperty2["default"])({}, inputValue, (0, _objectSpread6["default"])({}, currentOptions, { | ||
optionsCache: _objectSpread({}, prevState.optionsCache, (0, _defineProperty2["default"])({}, inputValue, _objectSpread({}, currentOptions, { | ||
isLoading: true | ||
@@ -257,7 +307,7 @@ }))) | ||
if (!(debounceTimeout > 0)) { | ||
_context4.next = 16; | ||
_context5.next = 16; | ||
break; | ||
} | ||
_context4.next = 11; | ||
_context5.next = 11; | ||
return sleep(debounceTimeout); | ||
@@ -269,10 +319,10 @@ | ||
if (!(inputValue !== newInputValue)) { | ||
_context4.next = 16; | ||
_context5.next = 16; | ||
break; | ||
} | ||
_context4.next = 15; | ||
_context5.next = 15; | ||
return this.setState(function (prevState) { | ||
return { | ||
optionsCache: (0, _objectSpread6["default"])({}, prevState.optionsCache, (0, _defineProperty2["default"])({}, inputValue, (0, _objectSpread6["default"])({}, prevState.optionsCache[inputValue], { | ||
optionsCache: _objectSpread({}, prevState.optionsCache, (0, _defineProperty2["default"])({}, inputValue, _objectSpread({}, prevState.optionsCache[inputValue], { | ||
isLoading: false | ||
@@ -284,12 +334,12 @@ }))) | ||
case 15: | ||
return _context4.abrupt("return"); | ||
return _context5.abrupt("return"); | ||
case 16: | ||
_context4.prev = 16; | ||
_context5.prev = 16; | ||
_loadOptions2 = this.props.loadOptions; | ||
_context4.next = 20; | ||
_context5.next = 20; | ||
return _loadOptions2(inputValue, currentOptions.options, currentOptions.additional); | ||
case 20: | ||
response = _context4.sent; | ||
response = _context5.sent; | ||
options = response.options; | ||
@@ -299,8 +349,8 @@ hasMore = response.hasMore; | ||
hasError = false; | ||
_context4.next = 30; | ||
_context5.next = 30; | ||
break; | ||
case 27: | ||
_context4.prev = 27; | ||
_context4.t0 = _context4["catch"](16); | ||
_context5.prev = 27; | ||
_context5.t0 = _context5["catch"](16); | ||
hasError = true; | ||
@@ -310,10 +360,10 @@ | ||
if (!hasError) { | ||
_context4.next = 35; | ||
_context5.next = 35; | ||
break; | ||
} | ||
_context4.next = 33; | ||
_context5.next = 33; | ||
return this.setState(function (prevState) { | ||
return { | ||
optionsCache: (0, _objectSpread6["default"])({}, prevState.optionsCache, (0, _defineProperty2["default"])({}, inputValue, (0, _objectSpread6["default"])({}, currentOptions, { | ||
optionsCache: _objectSpread({}, prevState.optionsCache, (0, _defineProperty2["default"])({}, inputValue, _objectSpread({}, currentOptions, { | ||
isLoading: false | ||
@@ -325,3 +375,3 @@ }))) | ||
case 33: | ||
_context4.next = 39; | ||
_context5.next = 39; | ||
break; | ||
@@ -332,6 +382,6 @@ | ||
reduceOptions = this.props.reduceOptions; | ||
_context4.next = 39; | ||
_context5.next = 39; | ||
return this.setState(function (prevState) { | ||
return { | ||
optionsCache: (0, _objectSpread6["default"])({}, prevState.optionsCache, (0, _defineProperty2["default"])({}, inputValue, (0, _objectSpread6["default"])({}, currentOptions, { | ||
optionsCache: _objectSpread({}, prevState.optionsCache, (0, _defineProperty2["default"])({}, inputValue, _objectSpread({}, currentOptions, { | ||
options: reduceOptions(currentOptions.options, options, newAdditional), | ||
@@ -348,6 +398,6 @@ hasMore: !!hasMore, | ||
case "end": | ||
return _context4.stop(); | ||
return _context5.stop(); | ||
} | ||
} | ||
}, _callee4, this, [[16, 27]]); | ||
}, _callee5, this, [[16, 27]]); | ||
})); | ||
@@ -379,3 +429,3 @@ | ||
options: currentOptions.options, | ||
components: (0, _objectSpread6["default"])({ | ||
components: _objectSpread({ | ||
MenuList: MenuList | ||
@@ -397,2 +447,3 @@ }, components), | ||
options: _propTypes["default"].arrayOf(_propTypes["default"].object), | ||
defaultOptions: _propTypes["default"].oneOfType([_propTypes["default"].bool, _propTypes["default"].arrayOf(_propTypes["default"].object)]), | ||
// eslint-disable-next-line react/forbid-prop-types | ||
@@ -413,2 +464,3 @@ additional: _propTypes["default"].any, | ||
options: null, | ||
defaultOptions: false, | ||
additional: null, | ||
@@ -415,0 +467,0 @@ reduceOptions: _defaultReduceOptions["default"], |
@@ -10,4 +10,8 @@ "use strict"; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { keys.push.apply(keys, Object.getOwnPropertySymbols(object)); } if (enumerableOnly) keys = keys.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
var reduceGroupedOptions = function reduceGroupedOptions(prevOptions, loadedOptions) { | ||
@@ -37,3 +41,3 @@ var res = prevOptions.slice(); | ||
res[groupIndex] = (0, _objectSpread2["default"])({}, res[groupIndex], { | ||
res[groupIndex] = _objectSpread({}, res[groupIndex], { | ||
options: res[groupIndex].options.concat(group.options) | ||
@@ -40,0 +44,0 @@ }); |
{ | ||
"name": "react-select-async-paginate", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"description": "Wrapper above react-select that supports pagination on menu scroll", | ||
@@ -28,3 +28,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@babel/runtime": "^7.4.5", | ||
"@babel/runtime": "^7.5.4", | ||
"prop-types": "^15.7.2" | ||
@@ -31,0 +31,0 @@ }, |
@@ -13,3 +13,6 @@ [![NPM](https://img.shields.io/npm/v/react-select-async-paginate.svg)](https://www.npmjs.com/package/react-select-async-paginate) | ||
- [Multi](https://codesandbox.io/s/2323yrlo9r) | ||
- [Creatable](https://codesandbox.io/s/5ycdz) | ||
- [Creatable with adding new options](https://codesandbox.io/s/6pznz) | ||
- [Initial options](https://codesandbox.io/s/q111nqw9j) | ||
- [Autoload](https://codesandbox.io/s/v8pkw) | ||
- [Debounce](https://codesandbox.io/s/5y2xq39v5k) | ||
@@ -16,0 +19,0 @@ - [Request by page number](https://codesandbox.io/s/10r1k12vk7) |
63117
1345
298
Updated@babel/runtime@^7.5.4