impact-chatbot 2.3.10 → 2.3.11

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.
@@ -18,7 +18,10 @@ export declare const buildFilterOptionsPayload: (filterConfig: any, existingFilt
18
18
  filter_type: string;
19
19
  dimension: any;
20
20
  display_type: any;
21
- check_configuration: any[];
21
+ check_configuration: {
22
+ checkAll: boolean;
23
+ meta: {};
24
+ }[];
22
25
  is_mandatory: any;
23
26
  extra: {};
24
27
  values: any;
@@ -35,7 +35,7 @@ export declare const findTextNodeAtPosition: (editorRef: any, position: any) =>
35
35
  * @param {boolean} isStage1 - Whether this is stage 1 (filter only) or stage 2 (with values)
36
36
  * @returns {HTMLSpanElement} Mention span element
37
37
  */
38
- export declare const createMentionSpan: (text: any, filterName: any, values: any, groupId: any, isStage1?: boolean) => HTMLSpanElement;
38
+ export declare const createMentionSpan: (text: any, filterName: any, values: any, groupId: any, isStage1?: boolean, checkAll?: boolean) => HTMLSpanElement;
39
39
  /**
40
40
  * Create +N count badge
41
41
  * @param {number} count - Hidden count
@@ -68,6 +68,7 @@ export declare const getAllMentions: (editorRef: any) => {
68
68
  filterName: any;
69
69
  stage: any;
70
70
  values: any;
71
+ checkAll: boolean;
71
72
  text: any;
72
73
  }[];
73
74
  /**
package/dist/index.cjs.js CHANGED
@@ -7910,10 +7910,10 @@ const buildFilterOptionsPayload = (filterConfig, existingFilters = [], filterOpt
7910
7910
  filter_type: "cascaded",
7911
7911
  dimension: fullFilterConfig?.dimension || "product",
7912
7912
  display_type: fullFilterConfig?.display_type || "dropdown",
7913
- check_configuration: [],
7913
+ check_configuration: mention.checkAll ? [{ checkAll: true, meta: {} }] : [],
7914
7914
  is_mandatory: fullFilterConfig?.is_mandatory || false,
7915
7915
  extra: {},
7916
- values: mention.values || [],
7916
+ values: mention.checkAll ? [] : (mention.values || []),
7917
7917
  attribute_name: attributeName,
7918
7918
  operator: "in",
7919
7919
  display_order: fullFilterConfig?.display_order || 0,
@@ -8063,7 +8063,7 @@ const findTextNodeAtPosition = (editorRef, position) => {
8063
8063
  * @param {boolean} isStage1 - Whether this is stage 1 (filter only) or stage 2 (with values)
8064
8064
  * @returns {HTMLSpanElement} Mention span element
8065
8065
  */
8066
- const createMentionSpan = (text, filterName, values, groupId, isStage1 = false) => {
8066
+ const createMentionSpan = (text, filterName, values, groupId, isStage1 = false, checkAll = false) => {
8067
8067
  const mentionSpan = document.createElement("span");
8068
8068
  mentionSpan.className = "mention-highlight";
8069
8069
  mentionSpan.contentEditable = "false";
@@ -8073,6 +8073,9 @@ const createMentionSpan = (text, filterName, values, groupId, isStage1 = false)
8073
8073
  if (values && values.length > 0) {
8074
8074
  mentionSpan.setAttribute("data-values", JSON.stringify(values));
8075
8075
  }
8076
+ if (checkAll) {
8077
+ mentionSpan.setAttribute("data-check-all", "true");
8078
+ }
8076
8079
  mentionSpan.textContent = text;
8077
8080
  return mentionSpan;
8078
8081
  };
@@ -8174,6 +8177,7 @@ const getAllMentions = (editorRef) => {
8174
8177
  filterName: span.getAttribute("data-filter-name"),
8175
8178
  stage: span.getAttribute("data-stage"),
8176
8179
  values: JSON.parse(span.getAttribute("data-values") || "[]"),
8180
+ checkAll: span.getAttribute("data-check-all") === "true",
8177
8181
  text: span.textContent,
8178
8182
  }));
8179
8183
  };
@@ -8219,13 +8223,10 @@ const formatMentionDisplay = (filterName, values, maxVisible = 3) => {
8219
8223
  return `@${filterName}::`;
8220
8224
  }
8221
8225
  const visibleValues = values.slice(0, maxVisible);
8222
- const hiddenCount = values.length - maxVisible;
8226
+ values.length - maxVisible;
8223
8227
  // Decode any special character codes for display purposes only.
8224
8228
  const displayVisibleValues = visibleValues.map((v) => replaceSpecialCharacter(String(v)));
8225
8229
  let display = `@${filterName}::${displayVisibleValues.join(",")}`;
8226
- if (hiddenCount > 0) {
8227
- display += `,+${hiddenCount}`;
8228
- }
8229
8230
  return display;
8230
8231
  };
8231
8232
  /**
@@ -8374,6 +8375,10 @@ const ChatbotInput = (props) => {
8374
8375
  const isInsertingMentionRef = React.useRef(false);
8375
8376
  const isTransitioningStageRef = React.useRef(false);
8376
8377
  const shouldClearCacheRef = React.useRef(false);
8378
+ const allFilterValuesRef = React.useRef([]);
8379
+ const windowStartRef = React.useRef(0);
8380
+ const INITIAL_DISPLAY_COUNT = 500;
8381
+ const LOAD_MORE_COUNT = 100;
8377
8382
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
8378
8383
  // Date range picker state
8379
8384
  const [showDateRangePicker, setShowDateRangePicker] = React.useState(false);
@@ -8863,6 +8868,7 @@ const ChatbotInput = (props) => {
8863
8868
  filterConfig?.name ||
8864
8869
  mention.filterName,
8865
8870
  values: mention.values,
8871
+ checkAll: mention.checkAll || false,
8866
8872
  };
8867
8873
  });
8868
8874
  };
@@ -8936,7 +8942,16 @@ const ChatbotInput = (props) => {
8936
8942
  // Fetch values for Stage 2 (with existing filters for cascading)
8937
8943
  fetchFilterValues(filterConfig, existingFilters, filterOptions).then((valueOptions) => {
8938
8944
  setIsLoadingValues(false);
8939
- setCurrentOptions(valueOptions || []);
8945
+ const allValues = valueOptions || [];
8946
+ windowStartRef.current = 0;
8947
+ if (allValues.length > 2000) {
8948
+ allFilterValuesRef.current = allValues;
8949
+ setCurrentOptions(allValues.slice(0, INITIAL_DISPLAY_COUNT));
8950
+ }
8951
+ else {
8952
+ allFilterValuesRef.current = [];
8953
+ setCurrentOptions(allValues);
8954
+ }
8940
8955
  // Update dropdown position again after values are loaded (DOM might have shifted)
8941
8956
  if (mentionStartPos !== null) {
8942
8957
  updateDropdownPosition(mentionStartPos);
@@ -9029,6 +9044,7 @@ const ChatbotInput = (props) => {
9029
9044
  }
9030
9045
  // Determine if this filter is multi-select
9031
9046
  selectedFilter.isMulti !== false; // Default to true
9047
+ const isCheckAll = isAllSelected && allFilterValuesRef.current.length > 0;
9032
9048
  // Format mention text (decoded for display only)
9033
9049
  const mentionText = formatMentionDisplay(filterName, values, MAX_VISIBLE);
9034
9050
  // Create fragment
@@ -9036,12 +9052,15 @@ const ChatbotInput = (props) => {
9036
9052
  // Create mention span
9037
9053
  values.slice(0, MAX_VISIBLE);
9038
9054
  const hiddenValues = values.slice(MAX_VISIBLE);
9039
- const mentionSpan = createMentionSpan(mentionText, filterName, values, currentMentionGroupId, false // Stage 2
9040
- );
9055
+ const mentionSpan = createMentionSpan(mentionText, filterName, values, currentMentionGroupId, false, // Stage 2
9056
+ isCheckAll);
9041
9057
  fragment.appendChild(mentionSpan);
9042
9058
  // Add count badge if needed
9043
9059
  if (hiddenValues.length > 0) {
9044
- const countBadge = createCountBadge(hiddenValues.length, hiddenValues, currentMentionGroupId);
9060
+ const badgeCount = isCheckAll
9061
+ ? allFilterValuesRef.current.length - MAX_VISIBLE
9062
+ : hiddenValues.length;
9063
+ const countBadge = createCountBadge(badgeCount, hiddenValues, currentMentionGroupId);
9045
9064
  fragment.appendChild(countBadge);
9046
9065
  }
9047
9066
  // Add space to fragment
@@ -9626,7 +9645,28 @@ const ChatbotInput = (props) => {
9626
9645
  // Stage 2: Value selection with dropdown - use Select
9627
9646
  jsxRuntime.jsx(impactUiV3.Select, { currentOptions: currentOptions.length > 0 ? currentOptions : [], setCurrentOptions: setCurrentOptions, initialOptions: currentOptions.length > 0 ? currentOptions : [], placeholder: isLoadingValues
9628
9647
  ? "Loading values..."
9629
- : "Select values...", handleChange: handleMentionSelect, isOpen: isSelectOpen, setIsOpen: setIsSelectOpen, selectedOptions: selectedOptions, setSelectedOptions: setSelectedOptions, isCloseWhenClickOutside: false, isWithSearch: true, isSelectAll: !isLoadingValues ? isAllSelected : false, setIsSelectAll: setIsAllSelected, toggleSelectAll: !isLoadingValues, isMulti: selectedFilter?.is_multiple_selection !== false, disabled: isLoadingValues, isLoading: isLoadingValues, emptyMessage: isLoadingValues ? "Loading values..." : "No options available" })) })), showDateRangePicker && (jsxRuntime.jsx("div", { className: "mention-select-wrapper", ref: dateRangePickerRef, style: {
9648
+ : "Select values...", handleChange: handleMentionSelect, isOpen: isSelectOpen, setIsOpen: setIsSelectOpen, selectedOptions: selectedOptions, setSelectedOptions: setSelectedOptions, isCloseWhenClickOutside: false, isWithSearch: true, onMenuScrollToBottom: () => {
9649
+ const allValues = allFilterValuesRef.current;
9650
+ if (allValues.length > 0 && currentOptions.length < allValues.length) {
9651
+ const nextCount = Math.min(currentOptions.length + LOAD_MORE_COUNT, allValues.length);
9652
+ const nextOptions = allValues.slice(0, nextCount);
9653
+ setCurrentOptions(nextOptions);
9654
+ if (isAllSelected) {
9655
+ setSelectedOptions(nextOptions);
9656
+ }
9657
+ }
9658
+ }, onSelectAll: (e) => {
9659
+ if (e && e.target.checked) {
9660
+ setSelectedOptions([...currentOptions]);
9661
+ setIsAllSelected(true);
9662
+ }
9663
+ else {
9664
+ setSelectedOptions([]);
9665
+ setIsAllSelected(false);
9666
+ }
9667
+ }, customPlaceholderAfterSelect: isAllSelected && allFilterValuesRef.current.length > 0
9668
+ ? allFilterValuesRef.current.length
9669
+ : null, isSelectAll: !isLoadingValues ? isAllSelected : false, setIsSelectAll: setIsAllSelected, toggleSelectAll: !isLoadingValues, isMulti: selectedFilter?.is_multiple_selection !== false, disabled: isLoadingValues, isLoading: isLoadingValues, emptyMessage: isLoadingValues ? "Loading values..." : "No options available" })) })), showDateRangePicker && (jsxRuntime.jsx("div", { className: "mention-select-wrapper", ref: dateRangePickerRef, style: {
9630
9670
  position: "fixed",
9631
9671
  top: `680px`,
9632
9672
  left: `${dropdownPosition.left}px`,