lisichatbot 1.6.0 → 1.6.1
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 +46 -28
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -293,7 +293,8 @@ function renderMultiSelectDropdown(options, field) {
|
|
|
293
293
|
// ✅ Get existing data for pre-filling (edit mode)
|
|
294
294
|
// ✅ NEW: Check if prefill is disabled for this step
|
|
295
295
|
const currentStep = flowData.flow[chatState.step];
|
|
296
|
-
const
|
|
296
|
+
const hasOverride = chatState.prefillOverrideFields && chatState.prefillOverrideFields.includes(field);
|
|
297
|
+
const disablePrefill = currentStep?.disableInputValuePrefill === true && !hasOverride;
|
|
297
298
|
|
|
298
299
|
const existingData = disablePrefill ? [] : (chatState.data[field] || []);
|
|
299
300
|
const selectedValues = new Set(existingData);
|
|
@@ -301,8 +302,8 @@ function renderMultiSelectDropdown(options, field) {
|
|
|
301
302
|
if (disablePrefill) {
|
|
302
303
|
console.log(`⏭️ Pre-fill disabled for ${field} - starting fresh`);
|
|
303
304
|
} else {
|
|
304
|
-
if (
|
|
305
|
-
console.log(` 🔓 Pre-fill override active
|
|
305
|
+
if (hasOverride) {
|
|
306
|
+
console.log(` 🔓 Pre-fill override active for ${field}:`, Array.from(selectedValues));
|
|
306
307
|
} else {
|
|
307
308
|
console.log(`📝 Pre-filling selections for ${field}:`, Array.from(selectedValues));
|
|
308
309
|
}
|
|
@@ -556,15 +557,16 @@ function renderOptions(options, field, isSingleSelect = true) {
|
|
|
556
557
|
|
|
557
558
|
// ✅ NEW: Check if prefill is disabled for this step
|
|
558
559
|
const currentStep = flowData.flow[chatState.step];
|
|
559
|
-
const
|
|
560
|
+
const hasOverride = chatState.prefillOverrideFields && chatState.prefillOverrideFields.includes(field);
|
|
561
|
+
const disablePrefill = currentStep?.disableInputValuePrefill === true && !hasOverride;
|
|
560
562
|
|
|
561
563
|
const existingData = disablePrefill ? (isSingleSelect ? null : []) : chatState.data[field];
|
|
562
564
|
|
|
563
565
|
if (disablePrefill) {
|
|
564
566
|
console.log(`⏭️ Pre-fill disabled for ${field} - starting fresh`);
|
|
565
567
|
} else {
|
|
566
|
-
if (
|
|
567
|
-
console.log(` 🔓 Pre-fill override active
|
|
568
|
+
if (hasOverride) {
|
|
569
|
+
console.log(` 🔓 Pre-fill override active for ${field}:`, existingData);
|
|
568
570
|
} else {
|
|
569
571
|
console.log(`📝 Pre-filling ${field}:`, existingData);
|
|
570
572
|
}
|
|
@@ -694,15 +696,16 @@ function renderColorOptions(options, field) {
|
|
|
694
696
|
|
|
695
697
|
// ✅ NEW: Check if prefill is disabled for this step
|
|
696
698
|
const currentStep = flowData.flow[chatState.step];
|
|
697
|
-
const
|
|
699
|
+
const hasOverride = chatState.prefillOverrideFields && chatState.prefillOverrideFields.includes(field);
|
|
700
|
+
const disablePrefill = currentStep?.disableInputValuePrefill === true && !hasOverride;
|
|
698
701
|
|
|
699
702
|
const existingData = disablePrefill ? [] : chatState.data[field];
|
|
700
703
|
|
|
701
704
|
if (disablePrefill) {
|
|
702
705
|
console.log(`⏭️ Pre-fill disabled for ${field} (color) - starting fresh`);
|
|
703
706
|
} else {
|
|
704
|
-
if (
|
|
705
|
-
console.log(` 🔓 Pre-fill override active
|
|
707
|
+
if (hasOverride) {
|
|
708
|
+
console.log(` 🔓 Pre-fill override active for ${field} (color):`, existingData);
|
|
706
709
|
} else {
|
|
707
710
|
console.log(`📝 Pre-filling ${field} (color):`, existingData);
|
|
708
711
|
}
|
|
@@ -829,15 +832,16 @@ function renderCustomSelectOptions(options, field, customConfig) {
|
|
|
829
832
|
|
|
830
833
|
// ✅ NEW: Check if prefill is disabled for this step
|
|
831
834
|
const currentStep = flowData.flow[chatState.step];
|
|
832
|
-
const
|
|
835
|
+
const hasOverride = chatState.prefillOverrideFields && chatState.prefillOverrideFields.includes(field);
|
|
836
|
+
const disablePrefill = currentStep?.disableInputValuePrefill === true && !hasOverride;
|
|
833
837
|
|
|
834
838
|
const existingData = disablePrefill ? null : chatState.data[field];
|
|
835
839
|
|
|
836
840
|
if (disablePrefill) {
|
|
837
841
|
console.log(`⏭️ Pre-fill disabled for ${field} (custom) - starting fresh`);
|
|
838
842
|
} else {
|
|
839
|
-
if (
|
|
840
|
-
console.log(` 🔓 Pre-fill override active
|
|
843
|
+
if (hasOverride) {
|
|
844
|
+
console.log(` 🔓 Pre-fill override active for ${field} (custom):`, existingData);
|
|
841
845
|
} else {
|
|
842
846
|
console.log(`📝 Pre-filling ${field} (custom):`, existingData);
|
|
843
847
|
}
|
|
@@ -1455,15 +1459,16 @@ function renderTextInput(field, inputType = 'text', inputConfig = {}) {
|
|
|
1455
1459
|
|
|
1456
1460
|
// ✅ NEW: Check if prefill is disabled for this step
|
|
1457
1461
|
const currentStep = flowData.flow[chatState.step];
|
|
1458
|
-
const
|
|
1462
|
+
const hasOverride = chatState.prefillOverrideFields && chatState.prefillOverrideFields.includes(field);
|
|
1463
|
+
const disablePrefill = currentStep?.disableInputValuePrefill === true && !hasOverride;
|
|
1459
1464
|
|
|
1460
1465
|
const existingValue = disablePrefill ? null : chatState.data[field];
|
|
1461
1466
|
|
|
1462
1467
|
if (disablePrefill) {
|
|
1463
1468
|
console.log(`⏭️ Pre-fill disabled for ${field} - starting fresh`);
|
|
1464
1469
|
} else {
|
|
1465
|
-
if (
|
|
1466
|
-
console.log(` 🔓 Pre-fill override active
|
|
1470
|
+
if (hasOverride) {
|
|
1471
|
+
console.log(` 🔓 Pre-fill override active for ${field}:`, existingValue);
|
|
1467
1472
|
} else {
|
|
1468
1473
|
console.log(`📝 Pre-filling ${field}:`, existingValue);
|
|
1469
1474
|
}
|
|
@@ -2091,8 +2096,9 @@ async function handleNext() {
|
|
|
2091
2096
|
console.log(` → Set ${key}:`, result.prefillData[key]);
|
|
2092
2097
|
});
|
|
2093
2098
|
|
|
2094
|
-
// ✅ Store
|
|
2095
|
-
chatState.
|
|
2099
|
+
// ✅ Store which fields should override disableInputValuePrefill
|
|
2100
|
+
chatState.prefillOverrideFields = Object.keys(result.prefillData);
|
|
2101
|
+
console.log(` 🔓 Override active for fields:`, chatState.prefillOverrideFields);
|
|
2096
2102
|
}
|
|
2097
2103
|
|
|
2098
2104
|
chatState.step = targetStepIndex;
|
|
@@ -2122,8 +2128,9 @@ async function handleNext() {
|
|
|
2122
2128
|
console.log(` → Set ${key}:`, result.prefillData[key]);
|
|
2123
2129
|
});
|
|
2124
2130
|
|
|
2125
|
-
// ✅ Store
|
|
2126
|
-
chatState.
|
|
2131
|
+
// ✅ Store which fields should override disableInputValuePrefill
|
|
2132
|
+
chatState.prefillOverrideFields = Object.keys(result.prefillData);
|
|
2133
|
+
console.log(` 🔓 Override active for fields:`, chatState.prefillOverrideFields);
|
|
2127
2134
|
}
|
|
2128
2135
|
|
|
2129
2136
|
chatState.step = targetStep;
|
|
@@ -2580,8 +2587,9 @@ async function showNextStep() {
|
|
|
2580
2587
|
console.log(` → Set ${key}:`, result.prefillData[key]);
|
|
2581
2588
|
});
|
|
2582
2589
|
|
|
2583
|
-
// ✅ Store
|
|
2584
|
-
chatState.
|
|
2590
|
+
// ✅ Store which fields should override disableInputValuePrefill
|
|
2591
|
+
chatState.prefillOverrideFields = Object.keys(result.prefillData);
|
|
2592
|
+
console.log(` 🔓 Override active for fields:`, chatState.prefillOverrideFields);
|
|
2585
2593
|
}
|
|
2586
2594
|
|
|
2587
2595
|
chatState.step = targetStepIndex;
|
|
@@ -2611,8 +2619,9 @@ async function showNextStep() {
|
|
|
2611
2619
|
console.log(` → Set ${key}:`, result.prefillData[key]);
|
|
2612
2620
|
});
|
|
2613
2621
|
|
|
2614
|
-
// ✅ Store
|
|
2615
|
-
chatState.
|
|
2622
|
+
// ✅ Store which fields should override disableInputValuePrefill
|
|
2623
|
+
chatState.prefillOverrideFields = Object.keys(result.prefillData);
|
|
2624
|
+
console.log(` 🔓 Override active for fields:`, chatState.prefillOverrideFields);
|
|
2616
2625
|
}
|
|
2617
2626
|
|
|
2618
2627
|
chatState.step = targetStep;
|
|
@@ -2815,11 +2824,20 @@ async function showNextStep() {
|
|
|
2815
2824
|
}
|
|
2816
2825
|
}
|
|
2817
2826
|
|
|
2818
|
-
// ✅
|
|
2819
|
-
// This ensures
|
|
2820
|
-
if (chatState.
|
|
2821
|
-
|
|
2822
|
-
chatState.
|
|
2827
|
+
// ✅ Remove current field from prefillOverride list after rendering
|
|
2828
|
+
// This ensures override only applies to fields specified in prefillData
|
|
2829
|
+
if (chatState.prefillOverrideFields && chatState.prefillOverrideFields.length > 0) {
|
|
2830
|
+
const currentField = nextStep.input?.field;
|
|
2831
|
+
if (currentField && chatState.prefillOverrideFields.includes(currentField)) {
|
|
2832
|
+
chatState.prefillOverrideFields = chatState.prefillOverrideFields.filter(f => f !== currentField);
|
|
2833
|
+
console.log(` 🔓 Removed ${currentField} from override list. Remaining:`, chatState.prefillOverrideFields);
|
|
2834
|
+
|
|
2835
|
+
// Clear the list entirely if empty
|
|
2836
|
+
if (chatState.prefillOverrideFields.length === 0) {
|
|
2837
|
+
console.log(` 🔓 All override fields processed - clearing list`);
|
|
2838
|
+
delete chatState.prefillOverrideFields;
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2823
2841
|
}
|
|
2824
2842
|
|
|
2825
2843
|
setTimeout(() => {
|