@rolster/react-components 18.15.12 → 18.15.13

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/cjs/index.js CHANGED
@@ -2075,7 +2075,6 @@ function useListControl({ suggestions, formControl }) {
2075
2075
  });
2076
2076
  const collection = require$$0.useRef(new components.ListCollection([]));
2077
2077
  const position = require$$0.useRef(0);
2078
- const changeInternal = require$$0.useRef(false);
2079
2078
  const protectedValue = require$$0.useRef();
2080
2079
  require$$0.useEffect(() => {
2081
2080
  function onCloseSuggestions({ target }) {
@@ -2088,17 +2087,13 @@ function useListControl({ suggestions, formControl }) {
2088
2087
  };
2089
2088
  }, []);
2090
2089
  require$$0.useEffect(() => {
2091
- formControl?.touch();
2090
+ state.visible && formControl?.touch();
2092
2091
  setState((state) => ({
2093
2092
  ...state,
2094
2093
  higher: components.locationListCanTop(contentRef.current, listRef.current)
2095
2094
  }));
2096
2095
  }, [state.visible]);
2097
2096
  require$$0.useEffect(() => {
2098
- if (changeInternal.current) {
2099
- changeInternal.current = false;
2100
- return;
2101
- }
2102
2097
  collection.current = new components.ListCollection(suggestions);
2103
2098
  refresh(collection.current, formControl?.value);
2104
2099
  }, [suggestions, formControl?.value]);
@@ -2108,12 +2103,13 @@ function useListControl({ suggestions, formControl }) {
2108
2103
  }
2109
2104
  const element = collection.find(state);
2110
2105
  if (element) {
2106
+ protectedValue.current = undefined;
2111
2107
  return setValue(element.description);
2112
2108
  }
2113
2109
  if (!refreshProtected(collection)) {
2114
2110
  protectedValue.current = state;
2115
2111
  setValue('');
2116
- setFormState(undefined);
2112
+ setFormValue(undefined);
2117
2113
  }
2118
2114
  }
2119
2115
  function refreshProtected(collection) {
@@ -2133,11 +2129,8 @@ function useListControl({ suggestions, formControl }) {
2133
2129
  function setValue(value) {
2134
2130
  setState((state) => ({ ...state, value }));
2135
2131
  }
2136
- function setFormState(value) {
2137
- if (formControl) {
2138
- changeInternal.current = true;
2139
- formControl.setValue(value);
2140
- }
2132
+ function setFormValue(value) {
2133
+ formControl?.setValue(value);
2141
2134
  }
2142
2135
  function setVisible(visible) {
2143
2136
  setState((state) => ({ ...state, visible }));
@@ -2169,7 +2162,7 @@ function useListControl({ suggestions, formControl }) {
2169
2162
  navigationElement,
2170
2163
  navigationInput,
2171
2164
  setFocused,
2172
- setFormState,
2165
+ setFormValue,
2173
2166
  setValue,
2174
2167
  setVisible
2175
2168
  };
@@ -2186,7 +2179,7 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
2186
2179
  previous: null
2187
2180
  });
2188
2181
  const listControl = useListControl({ suggestions, formControl });
2189
- const { inputRef, navigationElement, navigationInput, setFocused, setFormState, setValue, setVisible } = listControl;
2182
+ const { inputRef, navigationElement, navigationInput, setFocused, setFormValue, setValue, setVisible } = listControl;
2190
2183
  require$$0.useEffect(() => {
2191
2184
  refreshCoincidences(pattern, true);
2192
2185
  }, [suggestions]);
@@ -2221,7 +2214,7 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
2221
2214
  function onClickAction() {
2222
2215
  setVisible(false);
2223
2216
  setValue('');
2224
- setFormState(undefined);
2217
+ setFormValue(undefined);
2225
2218
  onValue && onValue(undefined);
2226
2219
  }
2227
2220
  function onClickBackdrop() {
@@ -2243,7 +2236,7 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
2243
2236
  onSelect(value);
2244
2237
  }
2245
2238
  else {
2246
- setFormState(value);
2239
+ setFormValue(value);
2247
2240
  setValue(description);
2248
2241
  }
2249
2242
  onValue && onValue(value);
@@ -2490,7 +2483,7 @@ function RlsFieldDateRange({ children, date: datePicker, disabled, formControl,
2490
2483
 
2491
2484
  function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
2492
2485
  const listControl = useListControl({ suggestions, formControl });
2493
- const { inputRef, visible, navigationElement, navigationInput, setFocused, setFormState, setValue, setVisible } = listControl;
2486
+ const { inputRef, visible, navigationElement, navigationInput, setFocused, setFormValue, setValue, setVisible } = listControl;
2494
2487
  function onFocusInput() {
2495
2488
  setFocused(true);
2496
2489
  }
@@ -2539,7 +2532,7 @@ function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
2539
2532
  onSelect(value);
2540
2533
  }
2541
2534
  else {
2542
- setFormState(value);
2535
+ setFormValue(value);
2543
2536
  setValue(description);
2544
2537
  }
2545
2538
  onValue && onValue(value);