indicator-ui 0.0.62 → 0.0.64

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, onBottomScroll, 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)([]);
@@ -9539,17 +9538,24 @@ function SelectField({ value, onChange, options = [], placeholder, isError, sear
9539
9538
  }
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
  };
9541
+ const processLoadMoreOptions = async () => {
9542
+ let requestPromise = requestPromiseRef.current;
9543
+ if (requestPromise !== undefined)
9544
+ return;
9545
+ requestPromise = loadMoreOptions && loadMoreOptions(optionsState?.length || 0, searchingString);
9546
+ requestPromiseRef.current = requestPromise;
9547
+ const newOptions = await requestPromise;
9548
+ if (newOptions !== undefined) {
9549
+ setOptionsState(prevState => {
9550
+ requestPromiseRef.current = undefined;
9551
+ return [...prevState, ...newOptions];
9552
+ });
9553
+ }
9554
+ };
9542
9555
  const onScrollToBottom = async () => {
9556
+ onBottomScroll && onBottomScroll();
9543
9557
  if (loadMoreOptions) {
9544
- const requestPromise = requestPromiseRef.current;
9545
- if (requestPromise === undefined) {
9546
- requestPromiseRef.current = loadMoreOptions(optionsState?.length || 0, searchingString);
9547
- }
9548
- const newOptions = await requestPromiseRef.current;
9549
- requestPromiseRef.current = undefined;
9550
- if (newOptions !== undefined) {
9551
- setOptionsState(prevState => [...prevState, ...newOptions]);
9552
- }
9558
+ processLoadMoreOptions();
9553
9559
  }
9554
9560
  };
9555
9561
  return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", { className: className?.selectField, children: [getViewField(), (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_ui__WEBPACK_IMPORTED_MODULE_6__.ModalWindowWrapper, { isShow: isShowModalWindow, setIsShow: setIsShowModalWindow, additionElements: [inputRef.current], className: className?.modalWindow, children: (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_SelectModalWindow__WEBPACK_IMPORTED_MODULE_5__["default"], { value: value, options: optionsState, onChange: handleChange, afterElement: selectModalWindowAfterElement, onScrollToBottom: onScrollToBottom, className: className }) })] }));