indicator-ui 0.0.62 → 0.0.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -9478,11 +9478,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
9478
9478
|
|
|
9479
9479
|
|
|
9480
9480
|
|
|
9481
|
-
function SelectField({ value, onChange, options = [], placeholder, isError, searching, required = false, multiple = false, disabled = false, offOptionsSyncing = true, offInitLoadMoreOptions = false, autoClose = false, onBlur, selectModalWindowAfterElement, loadMoreOptions, className = _styles__WEBPACK_IMPORTED_MODULE_4__.SelectFieldStyle, }) {
|
|
9481
|
+
function SelectField({ value, onChange, options = [], placeholder, isError, searching, required = false, multiple = false, disabled = false, offOptionsSyncing = true, offInitLoadMoreOptions = false, autoClose = false, onBlur, selectModalWindowAfterElement, loadMoreOptions, moreOptions, className = _styles__WEBPACK_IMPORTED_MODULE_4__.SelectFieldStyle, }) {
|
|
9482
9482
|
const [isFocus, setIsFocus] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(false);
|
|
9483
9483
|
const [searchingString, setSearchingString] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)('');
|
|
9484
9484
|
const [isShowModalWindow, setIsShowModalWindow] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(false);
|
|
9485
|
-
const optionsCounter = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)(options.length);
|
|
9486
9485
|
const requestPromiseRef = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)(undefined);
|
|
9487
9486
|
// Добавляем кэширование выбранных options
|
|
9488
9487
|
const optionsCacheRef = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)([]);
|
|
@@ -9540,15 +9539,25 @@ function SelectField({ value, onChange, options = [], placeholder, isError, sear
|
|
|
9540
9539
|
return (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_FlexField__WEBPACK_IMPORTED_MODULE_2__.FlexField, { value: (0,_lib__WEBPACK_IMPORTED_MODULE_3__.getStringValue)(value, optionsCacheRef.current), isError: isError, disabled: disabled, placeholder: placeholder, notInput: true, onClick: () => setIsShowModalWindow(true), dropdown: true, dropdownState: isShowModalWindow, ref: inputRef });
|
|
9541
9540
|
};
|
|
9542
9541
|
const onScrollToBottom = async () => {
|
|
9543
|
-
if (loadMoreOptions) {
|
|
9542
|
+
if (loadMoreOptions || moreOptions) {
|
|
9544
9543
|
const requestPromise = requestPromiseRef.current;
|
|
9545
9544
|
if (requestPromise === undefined) {
|
|
9546
|
-
|
|
9545
|
+
if (loadMoreOptions) {
|
|
9546
|
+
requestPromiseRef.current = loadMoreOptions(optionsState?.length || 0, searchingString);
|
|
9547
|
+
}
|
|
9548
|
+
else {
|
|
9549
|
+
requestPromiseRef.current = moreOptions(optionsState || [], searchingString);
|
|
9550
|
+
}
|
|
9547
9551
|
}
|
|
9548
9552
|
const newOptions = await requestPromiseRef.current;
|
|
9549
9553
|
requestPromiseRef.current = undefined;
|
|
9550
9554
|
if (newOptions !== undefined) {
|
|
9551
|
-
setOptionsState(prevState =>
|
|
9555
|
+
setOptionsState(prevState => {
|
|
9556
|
+
if (loadMoreOptions)
|
|
9557
|
+
return [...prevState, ...newOptions];
|
|
9558
|
+
else
|
|
9559
|
+
return newOptions;
|
|
9560
|
+
});
|
|
9552
9561
|
}
|
|
9553
9562
|
}
|
|
9554
9563
|
};
|