lisichatbot 2.0.7 → 2.0.9
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/package.json +1 -1
- package/src/index.js +52 -25
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -320,8 +320,9 @@ function renderMultiSelectDropdown(options, field) {
|
|
|
320
320
|
// ✅ NEW: Check if prefill is disabled for this step
|
|
321
321
|
const currentStep = flowData.flow[chatState.step];
|
|
322
322
|
const hasOverride = chatState.prefillOverrideFields && chatState.prefillOverrideFields.includes(field);
|
|
323
|
-
const
|
|
324
|
-
|
|
323
|
+
const isEditing = chatState.returnToStep !== null && chatState.returnToStep !== undefined;
|
|
324
|
+
const disablePrefill = currentStep?.disableInputValuePrefill === true && !hasOverride && !isEditing;
|
|
325
|
+
|
|
325
326
|
const existingData = disablePrefill ? [] : (chatState.data[field] || []);
|
|
326
327
|
const selectedValues = new Set(existingData);
|
|
327
328
|
|
|
@@ -621,14 +622,15 @@ function renderOptions(options, field, isSingleSelect = true) {
|
|
|
621
622
|
// ✅ NEW: Check if prefill is disabled for this step
|
|
622
623
|
const currentStep = flowData.flow[chatState.step];
|
|
623
624
|
const hasOverride = chatState.prefillOverrideFields && chatState.prefillOverrideFields.includes(field);
|
|
624
|
-
const
|
|
625
|
-
|
|
625
|
+
const isEditing = chatState.returnToStep !== null && chatState.returnToStep !== undefined;
|
|
626
|
+
const disablePrefill = currentStep?.disableInputValuePrefill === true && !hasOverride && !isEditing;
|
|
627
|
+
|
|
626
628
|
const existingData = disablePrefill ? (isSingleSelect ? null : []) : chatState.data[field];
|
|
627
|
-
|
|
629
|
+
|
|
628
630
|
if (disablePrefill) {
|
|
629
631
|
console.log(`⏭️ Pre-fill disabled for ${field} - starting fresh`);
|
|
630
632
|
} else {
|
|
631
|
-
if (hasOverride) {
|
|
633
|
+
if (hasOverride || isEditing) {
|
|
632
634
|
console.log(` 🔓 Pre-fill override active for ${field}:`, existingData);
|
|
633
635
|
} else {
|
|
634
636
|
console.log(`📝 Pre-filling ${field}:`, existingData);
|
|
@@ -761,14 +763,15 @@ function renderColorOptions(options, field) {
|
|
|
761
763
|
// ✅ NEW: Check if prefill is disabled for this step
|
|
762
764
|
const currentStep = flowData.flow[chatState.step];
|
|
763
765
|
const hasOverride = chatState.prefillOverrideFields && chatState.prefillOverrideFields.includes(field);
|
|
764
|
-
const
|
|
765
|
-
|
|
766
|
+
const isEditing = chatState.returnToStep !== null && chatState.returnToStep !== undefined;
|
|
767
|
+
const disablePrefill = currentStep?.disableInputValuePrefill === true && !hasOverride && !isEditing;
|
|
768
|
+
|
|
766
769
|
const existingData = disablePrefill ? [] : chatState.data[field];
|
|
767
|
-
|
|
770
|
+
|
|
768
771
|
if (disablePrefill) {
|
|
769
772
|
console.log(`⏭️ Pre-fill disabled for ${field} (color) - starting fresh`);
|
|
770
773
|
} else {
|
|
771
|
-
if (hasOverride) {
|
|
774
|
+
if (hasOverride || isEditing) {
|
|
772
775
|
console.log(` 🔓 Pre-fill override active for ${field} (color):`, existingData);
|
|
773
776
|
} else {
|
|
774
777
|
console.log(`📝 Pre-filling ${field} (color):`, existingData);
|
|
@@ -898,9 +901,19 @@ function renderCustomSelectOptions(options, field, customConfig) {
|
|
|
898
901
|
// ✅ NEW: Check if prefill is disabled for this step
|
|
899
902
|
const currentStep = flowData.flow[chatState.step];
|
|
900
903
|
const hasOverride = chatState.prefillOverrideFields && chatState.prefillOverrideFields.includes(field);
|
|
901
|
-
const
|
|
904
|
+
const isEditing = chatState.returnToStep !== null && chatState.returnToStep !== undefined;
|
|
905
|
+
const disablePrefill = currentStep?.disableInputValuePrefill === true && !hasOverride && !isEditing;
|
|
906
|
+
|
|
907
|
+
console.log(`\n🔍 === PREFILL DEBUG for field: ${field} ===`);
|
|
908
|
+
console.log(` disableInputValuePrefill:`, currentStep?.disableInputValuePrefill);
|
|
909
|
+
console.log(` prefillOverrideFields:`, chatState.prefillOverrideFields);
|
|
910
|
+
console.log(` hasOverride:`, hasOverride);
|
|
911
|
+
console.log(` isEditing:`, isEditing);
|
|
912
|
+
console.log(` disablePrefill:`, disablePrefill);
|
|
913
|
+
console.log(` chatState.data[${field}]:`, chatState.data[field]);
|
|
902
914
|
|
|
903
915
|
const existingData = disablePrefill ? null : chatState.data[field];
|
|
916
|
+
console.log(` ✅ existingData:`, existingData);
|
|
904
917
|
|
|
905
918
|
if (disablePrefill) {
|
|
906
919
|
console.log(`⏭️ Pre-fill disabled for ${field} (custom) - starting fresh`);
|
|
@@ -944,15 +957,17 @@ function renderCustomSelectOptions(options, field, customConfig) {
|
|
|
944
957
|
const shouldBeChecked = existingData !== undefined &&
|
|
945
958
|
JSON.stringify(existingData) === JSON.stringify(optionValue);
|
|
946
959
|
|
|
960
|
+
console.log(` 🔍 Option "${optionName}": existingData=${JSON.stringify(existingData)} vs optionValue=${JSON.stringify(optionValue)} → shouldBeChecked=${shouldBeChecked}`);
|
|
961
|
+
|
|
947
962
|
if (shouldBeChecked) {
|
|
948
963
|
clone.classList.add('cf-checked');
|
|
949
|
-
clone.style.
|
|
964
|
+
clone.style.setProperty('background-color', config.selectedBackground, 'important'); // ✅ Use !important
|
|
950
965
|
console.log(` ✅ Pre-selected: ${optionName}`);
|
|
951
966
|
hasPreselectedOption = true; // ✅ Mark that we have a pre-selection
|
|
952
967
|
hasMatchingNormalOption = true; // ✅ A normal option matched
|
|
953
968
|
} else {
|
|
954
969
|
clone.classList.remove('cf-checked');
|
|
955
|
-
clone.style.
|
|
970
|
+
clone.style.setProperty('background-color', 'transparent', 'important'); // ✅ Use !important
|
|
956
971
|
}
|
|
957
972
|
|
|
958
973
|
clone.setAttribute('data-chat-element', 'single-select-input');
|
|
@@ -971,7 +986,7 @@ function renderCustomSelectOptions(options, field, customConfig) {
|
|
|
971
986
|
|
|
972
987
|
const tickIcon = clone.querySelector('[data-chat-input-element="tick-icon"]');
|
|
973
988
|
if (tickIcon) {
|
|
974
|
-
tickIcon.style.display
|
|
989
|
+
tickIcon.style.setProperty('display', shouldBeChecked ? 'block' : 'none', 'important'); // ✅ Use !important
|
|
975
990
|
}
|
|
976
991
|
|
|
977
992
|
const textElement = clone.querySelector('[data-chat-input-element="text"]');
|
|
@@ -994,12 +1009,12 @@ function renderCustomSelectOptions(options, field, customConfig) {
|
|
|
994
1009
|
|
|
995
1010
|
if (isCustomSelected) {
|
|
996
1011
|
customClone.classList.add('cf-checked');
|
|
997
|
-
customClone.style.
|
|
1012
|
+
customClone.style.setProperty('background-color', config.selectedBackground, 'important'); // ✅ Use !important
|
|
998
1013
|
console.log(` ✅ Pre-selected: Custom Range [${existingData[0]}, ${existingData[1]}]`);
|
|
999
1014
|
hasPreselectedOption = true; // ✅ Mark that custom is pre-selected
|
|
1000
1015
|
} else {
|
|
1001
1016
|
customClone.classList.remove('cf-checked');
|
|
1002
|
-
customClone.style.
|
|
1017
|
+
customClone.style.setProperty('background-color', 'transparent', 'important'); // ✅ Use !important
|
|
1003
1018
|
}
|
|
1004
1019
|
|
|
1005
1020
|
customClone.setAttribute('data-chat-element', 'single-select-input');
|
|
@@ -1017,7 +1032,7 @@ function renderCustomSelectOptions(options, field, customConfig) {
|
|
|
1017
1032
|
|
|
1018
1033
|
const customTickIcon = customClone.querySelector('[data-chat-input-element="tick-icon"]');
|
|
1019
1034
|
if (customTickIcon) {
|
|
1020
|
-
customTickIcon.style.display
|
|
1035
|
+
customTickIcon.style.setProperty('display', isCustomSelected ? 'block' : 'none', 'important'); // ✅ Use !important
|
|
1021
1036
|
}
|
|
1022
1037
|
|
|
1023
1038
|
const customTextElement = customClone.querySelector('[data-chat-input-element="text"]');
|
|
@@ -1066,7 +1081,7 @@ function renderCustomSelectOptions(options, field, customConfig) {
|
|
|
1066
1081
|
// ✅ FIX: Enable Next button if option is pre-selected
|
|
1067
1082
|
if (hasPreselectedOption) {
|
|
1068
1083
|
// Set currentSelection
|
|
1069
|
-
const isCustomSelected = Array.isArray(existingData) && existingData.length === 2;
|
|
1084
|
+
const isCustomSelected = Array.isArray(existingData) && existingData.length === 2 && !hasMatchingNormalOption;
|
|
1070
1085
|
|
|
1071
1086
|
if (isCustomSelected) {
|
|
1072
1087
|
// Custom range selected - currentSelection will be set by validateMinMax
|
|
@@ -1677,8 +1692,9 @@ function renderTextInput(field, inputType = 'text', inputConfig = {}) {
|
|
|
1677
1692
|
// ✅ NEW: Check if prefill is disabled for this step
|
|
1678
1693
|
const currentStep = flowData.flow[chatState.step];
|
|
1679
1694
|
const hasOverride = chatState.prefillOverrideFields && chatState.prefillOverrideFields.includes(field);
|
|
1680
|
-
const
|
|
1681
|
-
|
|
1695
|
+
const isEditing = chatState.returnToStep !== null && chatState.returnToStep !== undefined;
|
|
1696
|
+
const disablePrefill = currentStep?.disableInputValuePrefill === true && !hasOverride && !isEditing;
|
|
1697
|
+
|
|
1682
1698
|
const existingValue = disablePrefill ? null : chatState.data[field];
|
|
1683
1699
|
|
|
1684
1700
|
if (disablePrefill) {
|
|
@@ -2632,7 +2648,12 @@ async function handleNext() {
|
|
|
2632
2648
|
});
|
|
2633
2649
|
|
|
2634
2650
|
updateEditIcons();
|
|
2635
|
-
|
|
2651
|
+
|
|
2652
|
+
if (chatState.step >= flowData.flow.length) {
|
|
2653
|
+
handleCompletion();
|
|
2654
|
+
} else {
|
|
2655
|
+
await showNextStep();
|
|
2656
|
+
}
|
|
2636
2657
|
return;
|
|
2637
2658
|
}
|
|
2638
2659
|
}
|
|
@@ -2679,6 +2700,12 @@ function findNextAccessibleStep(currentStep) {
|
|
|
2679
2700
|
}
|
|
2680
2701
|
|
|
2681
2702
|
async function showNextStep() {
|
|
2703
|
+
// ✅ FIX: Bounds check - if step is out of range, trigger completion
|
|
2704
|
+
if (chatState.step >= flowData.flow.length) {
|
|
2705
|
+
handleCompletion();
|
|
2706
|
+
return;
|
|
2707
|
+
}
|
|
2708
|
+
|
|
2682
2709
|
const nextStep = flowData.flow[chatState.step];
|
|
2683
2710
|
|
|
2684
2711
|
// ✅ NEW: Clean up any previously injected elements (from addElements)
|
|
@@ -3412,16 +3439,16 @@ function handleCompletion() {
|
|
|
3412
3439
|
|
|
3413
3440
|
if (typeof window !== 'undefined') {
|
|
3414
3441
|
const event = new CustomEvent('conversationalFlowComplete', {
|
|
3415
|
-
detail: {
|
|
3416
|
-
data: chatState.data,
|
|
3417
|
-
history: chatState.history
|
|
3442
|
+
detail: {
|
|
3443
|
+
data: { ...chatState.data },
|
|
3444
|
+
history: [...chatState.history]
|
|
3418
3445
|
}
|
|
3419
3446
|
});
|
|
3420
3447
|
window.dispatchEvent(event);
|
|
3421
3448
|
}
|
|
3422
3449
|
|
|
3423
3450
|
if (flowData.onComplete && typeof flowData.onComplete === 'function') {
|
|
3424
|
-
flowData.onComplete(chatState.data);
|
|
3451
|
+
flowData.onComplete({ ...chatState.data });
|
|
3425
3452
|
}
|
|
3426
3453
|
}
|
|
3427
3454
|
|