indicator-ui 0.0.80 → 0.0.82

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
@@ -6274,6 +6274,7 @@ __webpack_require__.r(__webpack_exports__);
6274
6274
 
6275
6275
  function useFormData(value) {
6276
6276
  const [formData, setFormData] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(value || {});
6277
+ const formDataRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(value || {});
6277
6278
  const setValue = (value, keyWay, options = { unionToArray: false }) => {
6278
6279
  setFormData(prevState => {
6279
6280
  let newValue = value;
@@ -6300,17 +6301,21 @@ function useFormData(value) {
6300
6301
  }
6301
6302
  }
6302
6303
  }
6303
- return { ...(0,_lib__WEBPACK_IMPORTED_MODULE_1__.setDeepValue)(prevState, newValue, { keysWay: keyWay }) };
6304
+ const newState = { ...(0,_lib__WEBPACK_IMPORTED_MODULE_1__.setDeepValue)(prevState, newValue, { keysWay: keyWay }) };
6305
+ formDataRef.current = newState;
6306
+ return newState;
6304
6307
  });
6305
6308
  };
6306
6309
  const getValue = (keyWay) => {
6307
- return (0,_lib__WEBPACK_IMPORTED_MODULE_1__.getDeepValue)(formData, keyWay);
6310
+ return (0,_lib__WEBPACK_IMPORTED_MODULE_1__.getDeepValue)(formDataRef.current, keyWay);
6308
6311
  };
6309
6312
  const resetForm = () => {
6310
6313
  setFormData(value || {});
6314
+ formDataRef.current = value || {};
6311
6315
  };
6312
6316
  const clearForm = () => {
6313
6317
  setFormData({});
6318
+ formDataRef.current = {};
6314
6319
  };
6315
6320
  const deleteArrayItem = (keyWay) => {
6316
6321
  const lastKeyWay = keyWay.length > 0 && keyWay[keyWay.length - 1] || undefined;
@@ -9370,22 +9375,6 @@ function RadioFieldItem({ option, onClick, active = false, disabled = false, cla
9370
9375
  }
9371
9376
 
9372
9377
 
9373
- /***/ }),
9374
-
9375
- /***/ "./src/ui/InputFields/SelectField/config/ScrollConfig.ts":
9376
- /*!***************************************************************!*\
9377
- !*** ./src/ui/InputFields/SelectField/config/ScrollConfig.ts ***!
9378
- \***************************************************************/
9379
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
9380
-
9381
- "use strict";
9382
- __webpack_require__.r(__webpack_exports__);
9383
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9384
- /* harmony export */ DELTA_SCROLL_END: () => (/* binding */ DELTA_SCROLL_END)
9385
- /* harmony export */ });
9386
- const DELTA_SCROLL_END = 1;
9387
-
9388
-
9389
9378
  /***/ }),
9390
9379
 
9391
9380
  /***/ "./src/ui/InputFields/SelectField/config/index.ts":
@@ -9397,10 +9386,11 @@ const DELTA_SCROLL_END = 1;
9397
9386
  "use strict";
9398
9387
  __webpack_require__.r(__webpack_exports__);
9399
9388
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9400
- /* harmony export */ DELTA_SCROLL_END: () => (/* reexport safe */ _ScrollConfig__WEBPACK_IMPORTED_MODULE_0__.DELTA_SCROLL_END)
9389
+ /* harmony export */ DELTA_SCROLL_END: () => (/* binding */ DELTA_SCROLL_END),
9390
+ /* harmony export */ SEARCHING_DELAY_TIME: () => (/* binding */ SEARCHING_DELAY_TIME)
9401
9391
  /* harmony export */ });
9402
- /* harmony import */ var _ScrollConfig__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ScrollConfig */ "./src/ui/InputFields/SelectField/config/ScrollConfig.ts");
9403
-
9392
+ const DELTA_SCROLL_END = 1;
9393
+ const SEARCHING_DELAY_TIME = 0.5 * 1000; // in ms
9404
9394
 
9405
9395
 
9406
9396
  /***/ }),
@@ -9580,6 +9570,7 @@ __webpack_require__.r(__webpack_exports__);
9580
9570
  /* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../styles */ "./src/ui/InputFields/SelectField/styles/index.ts");
9581
9571
  /* harmony import */ var _SelectModalWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./SelectModalWindow */ "./src/ui/InputFields/SelectField/ui/SelectModalWindow.tsx");
9582
9572
  /* harmony import */ var _ui__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/ui */ "./src/ui/index.ts");
9573
+ /* harmony import */ var _ui_InputFields_SelectField_config__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @/ui/InputFields/SelectField/config */ "./src/ui/InputFields/SelectField/config/index.ts");
9583
9574
 
9584
9575
 
9585
9576
 
@@ -9587,7 +9578,8 @@ __webpack_require__.r(__webpack_exports__);
9587
9578
 
9588
9579
 
9589
9580
 
9590
- 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, }) {
9581
+
9582
+ 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, ...props }) {
9591
9583
  const [isFocus, setIsFocus] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(false);
9592
9584
  const [searchingString, setSearchingString] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)('');
9593
9585
  const [isShowModalWindow, setIsShowModalWindow] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(false);
@@ -9596,6 +9588,15 @@ function SelectField({ value, onChange, options = [], placeholder, isError, sear
9596
9588
  const optionsCacheRef = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)([]);
9597
9589
  const [optionsState, setOptionsState] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(options);
9598
9590
  const inputRef = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)(null);
9591
+ const searchingTimeoutRef = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)(null);
9592
+ (0,react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(() => {
9593
+ return () => {
9594
+ // Отчистка таймаута для searching
9595
+ if (searchingTimeoutRef.current != null) {
9596
+ clearTimeout(searchingTimeoutRef.current);
9597
+ }
9598
+ };
9599
+ }, []);
9599
9600
  (0,react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(() => {
9600
9601
  if (!offInitLoadMoreOptions) {
9601
9602
  onScrollToBottom();
@@ -9620,22 +9621,27 @@ function SelectField({ value, onChange, options = [], placeholder, isError, sear
9620
9621
  else {
9621
9622
  if (data.length > 1 && !multiple) {
9622
9623
  onChange && onChange([data[data.length - 1]]);
9623
- if (autoClose) {
9624
- setIsShowModalWindow(false);
9625
- onBlur && onBlur();
9626
- }
9627
9624
  }
9628
9625
  else {
9629
9626
  onChange && onChange(data);
9630
9627
  }
9631
9628
  }
9629
+ if (autoClose) {
9630
+ setIsShowModalWindow(false);
9631
+ // onBlur && onBlur()
9632
+ }
9632
9633
  };
9633
9634
  const getViewField = () => {
9634
9635
  if (searching !== undefined) {
9635
9636
  return (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_FlexField__WEBPACK_IMPORTED_MODULE_2__.FlexField, { value: isFocus ? searchingString : (0,_lib__WEBPACK_IMPORTED_MODULE_3__.getStringValue)(value, optionsCacheRef.current), onChange: (searchString) => {
9636
9637
  if (isFocus) {
9637
9638
  setSearchingString(searchString);
9638
- searching(searchString, optionsState).then((newOptions) => newOptions !== undefined && setOptionsState(newOptions));
9639
+ if (searchingTimeoutRef.current != null) {
9640
+ clearTimeout(searchingTimeoutRef.current);
9641
+ }
9642
+ searchingTimeoutRef.current = setTimeout(() => {
9643
+ searching(searchString, optionsState).then((newOptions) => newOptions !== undefined && setOptionsState(newOptions));
9644
+ }, _ui_InputFields_SelectField_config__WEBPACK_IMPORTED_MODULE_7__.SEARCHING_DELAY_TIME);
9639
9645
  }
9640
9646
  }, disabled: disabled, onFocus: () => {
9641
9647
  setIsShowModalWindow(true);
@@ -9644,9 +9650,9 @@ function SelectField({ value, onChange, options = [], placeholder, isError, sear
9644
9650
  }, onBlur: () => {
9645
9651
  setIsFocus(false);
9646
9652
  onBlur && onBlur();
9647
- }, onDropdownClick: () => setIsShowModalWindow(prevState => !prevState), isError: isError, placeholder: placeholder, dropdown: true, dropdownState: isShowModalWindow, ref: inputRef });
9653
+ }, onDropdownClick: () => setIsShowModalWindow(prevState => !prevState), isError: isError, placeholder: placeholder, dropdown: true, dropdownState: isShowModalWindow, ref: inputRef, ...props });
9648
9654
  }
9649
- 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(prevState => !prevState), dropdown: true, dropdownState: isShowModalWindow, ref: inputRef });
9655
+ 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(prevState => !prevState), dropdown: true, dropdownState: isShowModalWindow, ref: inputRef, ...props });
9650
9656
  };
9651
9657
  const processLoadMoreOptions = async () => {
9652
9658
  if (requestPromiseRef.current)