@astral-frontend/components
Advanced tools
Comparing version 0.3.14 to 0.3.15
@@ -0,0 +0,0 @@ import _extends from "@babel/runtime/helpers/extends"; |
@@ -12,5 +12,5 @@ import "core-js/modules/es.symbol"; | ||
import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
import "regenerator-runtime/runtime"; | ||
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; | ||
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose"; | ||
@@ -29,5 +29,7 @@ | ||
var AsyncAutocomplete = function AsyncAutocomplete(_ref) { | ||
var fetchOptions = _ref.fetchOptions, | ||
var isLoadingDefaultOptions = _ref.loading, | ||
defaultOptions = _ref.defaultOptions, | ||
fetchOptions = _ref.fetchOptions, | ||
inputValueThrottleTimeout = _ref.inputValueThrottleTimeout, | ||
props = _objectWithoutPropertiesLoose(_ref, ["fetchOptions", "inputValueThrottleTimeout"]); | ||
props = _objectWithoutPropertiesLoose(_ref, ["loading", "defaultOptions", "fetchOptions", "inputValueThrottleTimeout"]); | ||
@@ -46,2 +48,13 @@ var _React$useState = React.useState(false), | ||
var setFormattingOptions = function setFormattingOptions(newOptions) { | ||
// TODO: #28808 | ||
setOptions(function (prevOptions) { | ||
return newOptions.reduce(function (acc, newOption) { | ||
var _objectSpread2; | ||
return _objectSpread({}, acc, (_objectSpread2 = {}, _objectSpread2[newOption.key] = newOption, _objectSpread2)); | ||
}, prevOptions); | ||
}); | ||
}; | ||
var handleInputChange = React.useCallback(throttle( | ||
@@ -52,3 +65,3 @@ /*#__PURE__*/ | ||
/*#__PURE__*/ | ||
_regeneratorRuntime.mark(function _callee(event, inputValue) { | ||
_regeneratorRuntime.mark(function _callee(event, searchString) { | ||
var newOptions; | ||
@@ -61,16 +74,9 @@ return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
_context.next = 3; | ||
return fetchOptions(inputValue); | ||
return fetchOptions(searchString); | ||
case 3: | ||
newOptions = _context.sent; | ||
setLoading(false); // TODO: #28808 | ||
setLoading(false); | ||
setFormattingOptions(newOptions); | ||
setOptions(function (prevOptions) { | ||
return newOptions.reduce(function (acc, newOption) { | ||
var _objectSpread2; | ||
return _objectSpread({}, acc, (_objectSpread2 = {}, _objectSpread2[newOption.key] = newOption, _objectSpread2)); | ||
}, prevOptions); | ||
}); | ||
case 6: | ||
@@ -88,5 +94,10 @@ case "end": | ||
}(), inputValueThrottleTimeout), [open]); | ||
React.useEffect(function () { | ||
if (!isLoadingDefaultOptions && defaultOptions) { | ||
setFormattingOptions(defaultOptions); | ||
} | ||
}, [isLoadingDefaultOptions]); | ||
return React.createElement(Autocomplete, _extends({}, props, { | ||
options: Object.values(options), | ||
loading: open && loading, | ||
loading: open && (isLoadingDefaultOptions || loading), | ||
open: open, | ||
@@ -104,6 +115,14 @@ onOpen: function onOpen() { | ||
AsyncAutocomplete.defaultProps = { | ||
loading: false, | ||
defaultOptions: null, | ||
inputValueThrottleTimeout: INPUT_VALUE_THROTTLE_TIMEOUT | ||
}; | ||
AsyncAutocomplete.propTypes = { | ||
loading: PropTypes.bool, | ||
inputValueThrottleTimeout: PropTypes.number, | ||
defaultOptions: PropTypes.shape({ | ||
key: PropTypes.string, | ||
label: PropTypes.string, | ||
value: PropTypes.any | ||
}), | ||
@@ -110,0 +129,0 @@ /** |
@@ -0,0 +0,0 @@ import "core-js/modules/es.symbol"; |
@@ -0,0 +0,0 @@ import _extends from "@babel/runtime/helpers/extends"; |
@@ -0,0 +0,0 @@ import "core-js/modules/es.symbol"; |
@@ -0,0 +0,0 @@ import React from 'react'; |
@@ -1,1 +0,1 @@ | ||
{"name":"@astral-frontend/components","version":"0.3.14","main":"./index.js","dependencies":{"@astral-frontend/core":"^0.1.0","@astral-frontend/fonts":"^0.2.0","@astral-frontend/icons":"^0.1.0","@astral-frontend/styles":"^0.1.5","@bugsnag/plugin-react":"^6.0.0","@material-ui/lab":"^4.0.0-alpha.32","classnames":"^2.2.6","downshift":"^3.3.5","intro.js":"2.9.3","intro.js-react":"0.2.0","lodash-es":"^4.17.11","match-sorter":"^4.0.2","prop-types":"^15.7.2","react-js-pagination":"^3.0.2","react-text-mask":"^5.4.3"},"peerDependencies":{"react":"^16.8.0","react-dom":"^16.8.0"},"sideEffects":["*.css"],"publishConfig":{"registry":"https://registry.npmjs.org"}} | ||
{"name":"@astral-frontend/components","version":"0.3.15","main":"./index.js","dependencies":{"@astral-frontend/core":"^0.1.0","@astral-frontend/fonts":"^0.2.0","@astral-frontend/icons":"^0.1.0","@astral-frontend/styles":"^0.1.5","@bugsnag/plugin-react":"^6.0.0","@material-ui/lab":"^4.0.0-alpha.32","classnames":"^2.2.6","downshift":"^3.3.5","intro.js":"2.9.3","intro.js-react":"0.2.0","lodash-es":"^4.17.11","match-sorter":"^4.0.2","prop-types":"^15.7.2","react-js-pagination":"^3.0.2","react-text-mask":"^5.4.3"},"peerDependencies":{"react":"^16.8.0","react-dom":"^16.8.0"},"sideEffects":["*.css"],"publishConfig":{"registry":"https://registry.npmjs.org"}} |
Sorry, the diff of this file is not supported yet
126079
3223