@use-ui/bootstrap3
Advanced tools
Comparing version 1.0.21 to 1.0.22
@@ -68,3 +68,2 @@ "use strict"; | ||
function Select(_a) { | ||
var _this = this; | ||
var field = _a.field, topic = _a.topic, params = _a.params, _b = _a.map, map = _b === void 0 ? function (i) { return i; } : _b, options = _a.options, _c = _a.onSelect, onSelect = _c === void 0 ? function () { } : _c, style = _a.style, right = _a.right, placeholder = _a.placeholder, clear = _a.clear, indicatorSeparator = _a.indicatorSeparator, multi = _a.multi, disabled = _a.disabled, className = _a.className, id = _a.id, label = _a.label, other = __rest(_a, ["field", "topic", "params", "map", "options", "onSelect", "style", "right", "placeholder", "clear", "indicatorSeparator", "multi", "disabled", "className", "id", "label"]); | ||
@@ -82,23 +81,2 @@ if (!options && !topic) { | ||
var selectedValues = field.getValue() ? (multi ? field.getValue().split(",") : [field.getValue()]) : []; | ||
// if params changed - 1) update defaultOptions 2) update cached options | ||
react_1.useEffect(function () { | ||
(function () { return __awaiter(_this, void 0, void 0, function () { | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
if (!(selectedValues.length && !!topic)) return [3 /*break*/, 2]; | ||
_a = setDefaultOptions; | ||
return [4 /*yield*/, loadOptions(null, selectedValues)]; | ||
case 1: | ||
_a.apply(void 0, [_b.sent()]); | ||
return [3 /*break*/, 3]; | ||
case 2: | ||
setDefaultOptions(true); | ||
_b.label = 3; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); })(); | ||
}, [JSON.stringify(params)]); | ||
function loadOptions(search, values) { | ||
@@ -146,9 +124,12 @@ return __awaiter(this, void 0, void 0, function () { | ||
var initialRender = react_1.useRef(true); | ||
// reset value on topic param change | ||
// on topic param change: | ||
// 1. reset value | ||
// 2. re-load options, update defaultOptions & cached | ||
react_1.useEffect(function () { | ||
// if it's not the first change - set value to empty | ||
if (!initialRender.current) { | ||
field.setValue(""); | ||
loadOptions(null, selectedValues).then(setDefaultOptions); | ||
} | ||
else { | ||
setDefaultOptions(true); | ||
initialRender.current = false; | ||
@@ -178,3 +159,3 @@ } | ||
}); | ||
// key contains defaultOptions b/c we would like to update need to update defaultOptions on topic params change | ||
// key contains defaultOptions b/c we would like to update defaultOptions on topic params change | ||
return (React.createElement(FormGroup_1.FormGroup, { label: label, invalidFeedback: field.getError(), style: style }, | ||
@@ -181,0 +162,0 @@ React.createElement(async_1.default, { className: ("select " + (className || "")).trim(), key: JSON.stringify(options) + "-" + JSON.stringify(defaultOptions), ref: ref, styles: __assign(__assign({}, styles), { indicatorSeparator: !indicatorSeparator |
{ | ||
"name": "@use-ui/bootstrap3", | ||
"version": "1.0.21", | ||
"version": "1.0.22", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62858
1429