lisichatbot 1.9.3 → 1.9.5

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +17 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisichatbot",
3
- "version": "1.9.3",
3
+ "version": "1.9.5",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
package/src/index.js CHANGED
@@ -930,9 +930,11 @@ function renderCustomSelectOptions(options, field, customConfig) {
930
930
  const customClone = existingOption.cloneNode(true);
931
931
  customClone.style.display = '';
932
932
 
933
+ // ✅ Only select custom if existingData is a range AND no normal option matched
933
934
  const isCustomSelected = existingData !== undefined &&
934
935
  Array.isArray(existingData) &&
935
- existingData.length === 2;
936
+ existingData.length === 2 &&
937
+ !hasMatchingNormalOption; // ✅ Don't select if normal option matched
936
938
 
937
939
  if (isCustomSelected) {
938
940
  customClone.classList.add('cf-checked');
@@ -2139,7 +2141,7 @@ async function handleNext() {
2139
2141
  // ✅ Pass showMessage as third parameter
2140
2142
  const result = await currentStep.onNext(
2141
2143
  chatState.currentSelection ? chatState.currentSelection.value : null,
2142
- chatState.data,
2144
+ { ...chatState.data, chatMode: chatState.chatMode }, // ✅ Include chatMode in data
2143
2145
  showMessage // ✅ NEW: Third parameter
2144
2146
  );
2145
2147
 
@@ -2451,7 +2453,9 @@ async function handleNext() {
2451
2453
  if (nextStepConfig.shouldDisplay) {
2452
2454
  if (typeof nextStepConfig.shouldDisplay === 'function') {
2453
2455
  try {
2454
- shouldShow = await nextStepConfig.shouldDisplay(chatState.data);
2456
+ shouldShow = await nextStepConfig.shouldDisplay(
2457
+ { ...chatState.data, chatMode: chatState.chatMode } // ✅ Include chatMode
2458
+ );
2455
2459
  console.log(` 🔍 Step ${nextStep} shouldDisplay: ${shouldShow}`);
2456
2460
  } catch (error) {
2457
2461
  console.error(`Error in shouldDisplay for step ${nextStep}:`, error);
@@ -2615,7 +2619,9 @@ async function showNextStep() {
2615
2619
  if (typeof nextStep.shouldDisplay === 'function') {
2616
2620
  // Custom function
2617
2621
  try {
2618
- shouldShow = await nextStep.shouldDisplay(chatState.data);
2622
+ shouldShow = await nextStep.shouldDisplay(
2623
+ { ...chatState.data, chatMode: chatState.chatMode } // ✅ Include chatMode
2624
+ );
2619
2625
  console.log(` 🔍 shouldDisplay function returned: ${shouldShow}`);
2620
2626
  } catch (error) {
2621
2627
  console.error('Error in shouldDisplay function:', error);
@@ -2654,7 +2660,10 @@ async function showNextStep() {
2654
2660
  };
2655
2661
 
2656
2662
  // ✅ Pass showMessage as second parameter
2657
- const result = await nextStep.onStart(chatState.data, showMessage);
2663
+ const result = await nextStep.onStart(
2664
+ { ...chatState.data, chatMode: chatState.chatMode }, // ✅ Include chatMode in data
2665
+ showMessage
2666
+ );
2658
2667
 
2659
2668
  // ✅ Still support showMessage in return object for backwards compatibility
2660
2669
  if (result && typeof result === 'object' && result.showMessage) {
@@ -2940,7 +2949,9 @@ async function showNextStep() {
2940
2949
  if (typeof nextStep.message === 'function') {
2941
2950
  // ✅ Message as function: message: (data) => `Hello ${data.name}`
2942
2951
  try {
2943
- messageToDisplay = nextStep.message(chatState.data);
2952
+ messageToDisplay = nextStep.message(
2953
+ { ...chatState.data, chatMode: chatState.chatMode } // ✅ Include chatMode
2954
+ );
2944
2955
  console.log(` 💬 Dynamic message (function): "${messageToDisplay}"`);
2945
2956
  } catch (error) {
2946
2957
  console.error('Error in message function:', error);