impact-chatbot 2.3.69 → 2.3.70

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.cjs.js CHANGED
@@ -6764,6 +6764,7 @@ const SliderContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6764
6764
 
6765
6765
  const INITIAL_DISPLAY_COUNT = 100;
6766
6766
  const LOAD_MORE_COUNT = 100;
6767
+ const SEARCH_DISPLAY_LIMIT = 500;
6767
6768
  const formatOption = (option) => ({
6768
6769
  ...option,
6769
6770
  label: replaceSpecialCharacter(option.label.toString()),
@@ -6781,6 +6782,8 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6781
6782
  const [isAllSelected, setIsAllSelected] = React.useState(false);
6782
6783
  const [initialOptions, setInitialOptions] = React.useState([]);
6783
6784
  const allOptionsRef = React.useRef([]);
6785
+ const isSearchActiveRef = React.useRef(false);
6786
+ const searchTermRef = React.useRef("");
6784
6787
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
6785
6788
  const heirarchyKeyValuePairs = reactRedux.useSelector((state) => state.smartBotReducer.heirarchyKeyValuePairs);
6786
6789
  const dispatch = reactRedux.useDispatch();
@@ -6873,6 +6876,40 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6873
6876
  setCurrentOptions(initialSlice);
6874
6877
  }
6875
6878
  }, [isCascading]);
6879
+ // Custom search handler: searches ALL options (not just the loaded chunk)
6880
+ // Supports comma-separated values for multi-search
6881
+ const handleSearch = React.useCallback((event) => {
6882
+ const rawInput = event?.target?.value || "";
6883
+ searchTermRef.current = rawInput;
6884
+ const trimmed = rawInput.trim();
6885
+ if (!trimmed) {
6886
+ // Reset to initial lazy-loaded chunk
6887
+ isSearchActiveRef.current = false;
6888
+ const resetSlice = formatSlice(allOptionsRef.current, 0, INITIAL_DISPLAY_COUNT);
6889
+ setCurrentOptions(resetSlice);
6890
+ setInitialOptions(resetSlice);
6891
+ setIsAllSelected(false);
6892
+ return;
6893
+ }
6894
+ isSearchActiveRef.current = true;
6895
+ // Parse comma-separated terms
6896
+ const terms = trimmed
6897
+ .split(",")
6898
+ .map((t) => t.trim().toLowerCase())
6899
+ .filter(Boolean);
6900
+ // Search across ALL options, not just the loaded chunk
6901
+ const allRaw = allOptionsRef.current;
6902
+ const filtered = allRaw.filter((option) => {
6903
+ const labelLower = option.label?.toString().toLowerCase() || "";
6904
+ const valueLower = option.value?.toString().toLowerCase() || "";
6905
+ return terms.some((term) => labelLower.includes(term) || valueLower.includes(term));
6906
+ });
6907
+ // Format and cap the results to avoid UI freeze
6908
+ const formatted = filtered.slice(0, SEARCH_DISPLAY_LIMIT).map(formatOption);
6909
+ setCurrentOptions(formatted);
6910
+ setInitialOptions(formatted);
6911
+ setIsAllSelected(false);
6912
+ }, []);
6876
6913
  return (jsxRuntime.jsx("div", { style: { width: "100%", marginTop: "10px" }, children: jsxRuntime.jsx(impactUiV3.Select, { currentOptions: currentOptions, setCurrentOptions: setCurrentOptions, label: heirarchyKeyValuePairs[paramName] || label, labelOrientation: labelOrientation,
6877
6914
  // inputPosition={inputPosition}
6878
6915
  // header={header}
@@ -6894,6 +6931,11 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6894
6931
  }
6895
6932
  }, handleChange: (selected) => onChange(selected), isCloseWhenClickOutside: true, setIsOpen: (open) => {
6896
6933
  setIsOpen(open);
6934
+ // When dropdown closes after a filtered select-all on a subset,
6935
+ // reset the isAllSelected flag so scroll-to-load-more doesn't auto-select more items
6936
+ if (!open && isAllSelected && currentSelectedOptions.length < allOptionsRef.current.length) {
6937
+ setIsAllSelected(false);
6938
+ }
6897
6939
  if (isCascading) {
6898
6940
  if (open) {
6899
6941
  // Lazy fetch: trigger cross-filter API call when dropdown opens for the first time
@@ -6920,7 +6962,10 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6920
6962
  }
6921
6963
  }
6922
6964
  }
6923
- }, isOpen: isOpen, selectedOptions: currentSelectedOptions, setSelectedOptions: setCurrentSelectedOptions, initialOptions: initialOptions, isMulti: isMulti, isSelectAll: isAllSelected, setIsSelectAll: setIsAllSelected, toggleSelectAll: true, isLoading: isCascading ? crossFilterCtx.loadingMap[paramName] : false, emptyMessage: isCascading && crossFilterCtx.loadingMap[paramName] ? "Loading values..." : "No options available", isWithSearch: isMulti ? true : false, onMenuScrollToBottom: () => {
6965
+ }, isOpen: isOpen, selectedOptions: currentSelectedOptions, setSelectedOptions: setCurrentSelectedOptions, initialOptions: initialOptions, isMulti: isMulti, isSelectAll: isAllSelected, setIsSelectAll: setIsAllSelected, toggleSelectAll: true, isLoading: isCascading ? crossFilterCtx.loadingMap[paramName] : false, emptyMessage: isCascading && crossFilterCtx.loadingMap[paramName] ? "Loading values..." : "No options available", isWithSearch: isMulti ? true : false, onSearch: handleSearch, onMenuScrollToBottom: () => {
6966
+ // Only allow scroll-to-load-more when NOT in search mode
6967
+ if (isSearchActiveRef.current)
6968
+ return;
6924
6969
  const allRaw = allOptionsRef.current;
6925
6970
  if (allRaw.length > 0 && currentOptions.length < allRaw.length) {
6926
6971
  const nextCount = Math.min(currentOptions.length + LOAD_MORE_COUNT, allRaw.length);
@@ -6934,33 +6979,53 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6934
6979
  }
6935
6980
  }, onSelectAll: (e) => {
6936
6981
  if (e && e.target.checked) {
6937
- setCurrentSelectedOptions([...currentOptions]);
6982
+ // When search is active, select only the filtered/visible options
6983
+ // When no search is active, select ALL options from the full dataset
6984
+ let optionsToSelect;
6985
+ let valuesToDispatch;
6986
+ if (isSearchActiveRef.current) {
6987
+ optionsToSelect = [...currentOptions];
6988
+ valuesToDispatch = currentOptions.map((opt) => opt.value);
6989
+ }
6990
+ else {
6991
+ optionsToSelect = allOptionsRef.current.map(formatOption);
6992
+ valuesToDispatch = allOptionsRef.current.map((opt) => opt.value);
6993
+ }
6994
+ setCurrentSelectedOptions(optionsToSelect);
6938
6995
  setIsAllSelected(true);
6939
- const allValues = allOptionsRef.current.map((opt) => opt.value);
6940
6996
  dispatch(smartBotActions.setChatbotContext({
6941
6997
  ...chatbotContext,
6942
6998
  [bodyText?.paramName]: {
6943
6999
  ...chatbotContext?.[bodyText?.paramName],
6944
- [bodyText?.paramName]: allValues,
7000
+ [bodyText?.paramName]: valuesToDispatch,
6945
7001
  updated: true,
6946
7002
  },
6947
7003
  }));
6948
- dispatch(smartBotActions.setPersistedFormValues({ [formKey]: currentOptions }));
7004
+ dispatch(smartBotActions.setPersistedFormValues({ [formKey]: optionsToSelect }));
6949
7005
  // Notify cross-filter context if cascading is active
6950
7006
  if (isCascading) {
6951
- crossFilterCtx.onFilterChange(paramName, allValues);
7007
+ crossFilterCtx.onFilterChange(paramName, valuesToDispatch);
6952
7008
  }
6953
7009
  }
6954
7010
  else {
6955
7011
  setCurrentSelectedOptions([]);
6956
7012
  setIsAllSelected(false);
7013
+ dispatch(smartBotActions.setChatbotContext({
7014
+ ...chatbotContext,
7015
+ [bodyText?.paramName]: {
7016
+ ...chatbotContext?.[bodyText?.paramName],
7017
+ [bodyText?.paramName]: [],
7018
+ updated: true,
7019
+ },
7020
+ }));
7021
+ dispatch(smartBotActions.setPersistedFormValues({ [formKey]: [] }));
6957
7022
  // Notify cross-filter context of deselection
6958
7023
  if (isCascading) {
6959
7024
  crossFilterCtx.onFilterChange(paramName, []);
6960
7025
  }
6961
7026
  }
6962
- }, customPlaceholderAfterSelect: isAllSelected && allOptionsRef.current.length > 0
6963
- ? allOptionsRef.current.length
7027
+ }, customPlaceholderAfterSelect: currentSelectedOptions.length > 0
7028
+ ? currentSelectedOptions.length
6964
7029
  : null }) }));
6965
7030
  };
6966
7031