@evergis/react 4.0.68 → 4.0.72

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/react.esm.js CHANGED
@@ -10657,6 +10657,7 @@ const TextFilter = ({ type, filter }) => {
10657
10657
  eqlParameters,
10658
10658
  });
10659
10659
  const { value, setValue, onChange, options, setOptions } = useAutoCompleteControl();
10660
+ const isFreeTextInput = useMemo(() => !variants && (!searchFilter?.attributeAlias || !searchFilter?.attributeValue), [variants, searchFilter?.attributeAlias, searchFilter?.attributeValue]);
10660
10661
  const setFilterValue = useCallback(newValue => {
10661
10662
  changeFilters({
10662
10663
  [filterName]: {
@@ -10674,18 +10675,21 @@ const TextFilter = ({ type, filter }) => {
10674
10675
  setValue(multiSelect ? "" : lastSelected?.text || "");
10675
10676
  }, [multiSelect, setFilterValue, setValue]);
10676
10677
  const onBlur = useCallback(() => {
10677
- if (variants) {
10678
- setFilterValue([value]);
10678
+ if (isFreeTextInput) {
10679
+ setFilterValue(value || "");
10680
+ }
10681
+ else if (variants) {
10682
+ setFilterValue(value ? [value] : []);
10679
10683
  }
10680
10684
  else {
10681
10685
  setOptions([]);
10682
10686
  }
10683
- }, [variants, setFilterValue, value, setOptions]);
10687
+ }, [isFreeTextInput, variants, setFilterValue, value, setOptions]);
10684
10688
  const onKeyUp = useCallback(e => {
10685
10689
  if (e.key === "Enter") {
10686
- setFilterValue([value]);
10690
+ setFilterValue(isFreeTextInput ? value || "" : value ? [value] : []);
10687
10691
  }
10688
- }, [setFilterValue, value]);
10692
+ }, [isFreeTextInput, setFilterValue, value]);
10689
10693
  const { asyncCallback, loadNext } = useAsyncAutocomplete({
10690
10694
  options,
10691
10695
  setOptions: variants ? () => { } : setOptions,
@@ -10737,7 +10741,7 @@ const TextFilter = ({ type, filter }) => {
10737
10741
  }, [filterName, filters]);
10738
10742
  if (!configFilter)
10739
10743
  return null;
10740
- return (jsx(TextFilterContainer, { children: jsx(AutoComplete, { value: value, placeholder: placeholder, options: variants || options, zIndex: 100, width: width ? `${width}px` : "17.25rem", menuHeight: height ? `${height}px` : "10rem", withInfiniteScroll: !variants, infiniteScrollProps: variants ? undefined : infiniteScrollProps, multiSelect: multiSelect, selected: selected, setOptions: variants ? undefined : setOptions, onChange: onChange, onSelect: onSelect, onGetInnerRef: ref => (suggestRef.current = ref), asyncCallback: variants ? undefined : search, onBlur: onBlur, onKeyUp: variants && !variants.length ? onKeyUp : undefined }) }));
10744
+ return (jsx(TextFilterContainer, { children: jsx(AutoComplete, { value: value, placeholder: placeholder, options: variants || options, zIndex: 100, width: width ? `${width}px` : "17.25rem", menuHeight: height ? `${height}px` : "10rem", withInfiniteScroll: !variants, infiniteScrollProps: variants ? undefined : infiniteScrollProps, multiSelect: multiSelect, selected: selected, setOptions: variants ? undefined : setOptions, onChange: onChange, onSelect: onSelect, onGetInnerRef: ref => (suggestRef.current = ref), asyncCallback: variants ? undefined : search, onBlur: onBlur, onKeyUp: isFreeTextInput || (variants && !variants.length) ? onKeyUp : undefined }) }));
10741
10745
  };
10742
10746
 
10743
10747
  const getListOptions = (items, filterName, configFilters) => {
@@ -12181,7 +12185,7 @@ const useChartData = ({ element, type }) => {
12181
12185
  ]);
12182
12186
  const [data, setData] = useState(fetchedData);
12183
12187
  useEffect(() => {
12184
- if (!loading && fetchedData?.length) {
12188
+ if (!loading) {
12185
12189
  setData(fetchedData);
12186
12190
  }
12187
12191
  }, [loading, fetchedData]);