lisichatbot 1.5.9 → 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 +113 -10
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,7 +302,11 @@ function renderMultiSelectDropdown(options, field) {
|
|
|
301
302
|
if (disablePrefill) {
|
|
302
303
|
console.log(`⏭️ Pre-fill disabled for ${field} - starting fresh`);
|
|
303
304
|
} else {
|
|
304
|
-
|
|
305
|
+
if (hasOverride) {
|
|
306
|
+
console.log(` 🔓 Pre-fill override active for ${field}:`, Array.from(selectedValues));
|
|
307
|
+
} else {
|
|
308
|
+
console.log(`📝 Pre-filling selections for ${field}:`, Array.from(selectedValues));
|
|
309
|
+
}
|
|
305
310
|
}
|
|
306
311
|
|
|
307
312
|
const allOptions = [];
|
|
@@ -552,14 +557,19 @@ function renderOptions(options, field, isSingleSelect = true) {
|
|
|
552
557
|
|
|
553
558
|
// ✅ NEW: Check if prefill is disabled for this step
|
|
554
559
|
const currentStep = flowData.flow[chatState.step];
|
|
555
|
-
const
|
|
560
|
+
const hasOverride = chatState.prefillOverrideFields && chatState.prefillOverrideFields.includes(field);
|
|
561
|
+
const disablePrefill = currentStep?.disableInputValuePrefill === true && !hasOverride;
|
|
556
562
|
|
|
557
563
|
const existingData = disablePrefill ? (isSingleSelect ? null : []) : chatState.data[field];
|
|
558
564
|
|
|
559
565
|
if (disablePrefill) {
|
|
560
566
|
console.log(`⏭️ Pre-fill disabled for ${field} - starting fresh`);
|
|
561
567
|
} else {
|
|
562
|
-
|
|
568
|
+
if (hasOverride) {
|
|
569
|
+
console.log(` 🔓 Pre-fill override active for ${field}:`, existingData);
|
|
570
|
+
} else {
|
|
571
|
+
console.log(`📝 Pre-filling ${field}:`, existingData);
|
|
572
|
+
}
|
|
563
573
|
}
|
|
564
574
|
|
|
565
575
|
const optionsWrapper = document.createElement('div');
|
|
@@ -686,14 +696,19 @@ function renderColorOptions(options, field) {
|
|
|
686
696
|
|
|
687
697
|
// ✅ NEW: Check if prefill is disabled for this step
|
|
688
698
|
const currentStep = flowData.flow[chatState.step];
|
|
689
|
-
const
|
|
699
|
+
const hasOverride = chatState.prefillOverrideFields && chatState.prefillOverrideFields.includes(field);
|
|
700
|
+
const disablePrefill = currentStep?.disableInputValuePrefill === true && !hasOverride;
|
|
690
701
|
|
|
691
702
|
const existingData = disablePrefill ? [] : chatState.data[field];
|
|
692
703
|
|
|
693
704
|
if (disablePrefill) {
|
|
694
705
|
console.log(`⏭️ Pre-fill disabled for ${field} (color) - starting fresh`);
|
|
695
706
|
} else {
|
|
696
|
-
|
|
707
|
+
if (hasOverride) {
|
|
708
|
+
console.log(` 🔓 Pre-fill override active for ${field} (color):`, existingData);
|
|
709
|
+
} else {
|
|
710
|
+
console.log(`📝 Pre-filling ${field} (color):`, existingData);
|
|
711
|
+
}
|
|
697
712
|
}
|
|
698
713
|
|
|
699
714
|
const optionsWrapper = document.createElement('div');
|
|
@@ -817,14 +832,19 @@ function renderCustomSelectOptions(options, field, customConfig) {
|
|
|
817
832
|
|
|
818
833
|
// ✅ NEW: Check if prefill is disabled for this step
|
|
819
834
|
const currentStep = flowData.flow[chatState.step];
|
|
820
|
-
const
|
|
835
|
+
const hasOverride = chatState.prefillOverrideFields && chatState.prefillOverrideFields.includes(field);
|
|
836
|
+
const disablePrefill = currentStep?.disableInputValuePrefill === true && !hasOverride;
|
|
821
837
|
|
|
822
838
|
const existingData = disablePrefill ? null : chatState.data[field];
|
|
823
839
|
|
|
824
840
|
if (disablePrefill) {
|
|
825
841
|
console.log(`⏭️ Pre-fill disabled for ${field} (custom) - starting fresh`);
|
|
826
842
|
} else {
|
|
827
|
-
|
|
843
|
+
if (hasOverride) {
|
|
844
|
+
console.log(` 🔓 Pre-fill override active for ${field} (custom):`, existingData);
|
|
845
|
+
} else {
|
|
846
|
+
console.log(`📝 Pre-filling ${field} (custom):`, existingData);
|
|
847
|
+
}
|
|
828
848
|
}
|
|
829
849
|
|
|
830
850
|
const optionsWrapper = document.createElement('div');
|
|
@@ -1439,14 +1459,19 @@ function renderTextInput(field, inputType = 'text', inputConfig = {}) {
|
|
|
1439
1459
|
|
|
1440
1460
|
// ✅ NEW: Check if prefill is disabled for this step
|
|
1441
1461
|
const currentStep = flowData.flow[chatState.step];
|
|
1442
|
-
const
|
|
1462
|
+
const hasOverride = chatState.prefillOverrideFields && chatState.prefillOverrideFields.includes(field);
|
|
1463
|
+
const disablePrefill = currentStep?.disableInputValuePrefill === true && !hasOverride;
|
|
1443
1464
|
|
|
1444
1465
|
const existingValue = disablePrefill ? null : chatState.data[field];
|
|
1445
1466
|
|
|
1446
1467
|
if (disablePrefill) {
|
|
1447
1468
|
console.log(`⏭️ Pre-fill disabled for ${field} - starting fresh`);
|
|
1448
1469
|
} else {
|
|
1449
|
-
|
|
1470
|
+
if (hasOverride) {
|
|
1471
|
+
console.log(` 🔓 Pre-fill override active for ${field}:`, existingValue);
|
|
1472
|
+
} else {
|
|
1473
|
+
console.log(`📝 Pre-filling ${field}:`, existingValue);
|
|
1474
|
+
}
|
|
1450
1475
|
}
|
|
1451
1476
|
|
|
1452
1477
|
const hasValidation = inputType === 'number' &&
|
|
@@ -2060,6 +2085,22 @@ async function handleNext() {
|
|
|
2060
2085
|
|
|
2061
2086
|
if (targetStepIndex !== -1) {
|
|
2062
2087
|
console.log(` ✅ Found step "${stepName}" at index ${targetStepIndex}`);
|
|
2088
|
+
|
|
2089
|
+
// ✅ NEW: Handle prefillData to override disableInputValuePrefill
|
|
2090
|
+
if (result.prefillData && typeof result.prefillData === 'object') {
|
|
2091
|
+
console.log(` 📝 Pre-filling data for jump:`, result.prefillData);
|
|
2092
|
+
|
|
2093
|
+
// Merge prefillData into chatState.data
|
|
2094
|
+
Object.keys(result.prefillData).forEach(key => {
|
|
2095
|
+
chatState.data[key] = result.prefillData[key];
|
|
2096
|
+
console.log(` → Set ${key}:`, result.prefillData[key]);
|
|
2097
|
+
});
|
|
2098
|
+
|
|
2099
|
+
// ✅ Store which fields should override disableInputValuePrefill
|
|
2100
|
+
chatState.prefillOverrideFields = Object.keys(result.prefillData);
|
|
2101
|
+
console.log(` 🔓 Override active for fields:`, chatState.prefillOverrideFields);
|
|
2102
|
+
}
|
|
2103
|
+
|
|
2063
2104
|
chatState.step = targetStepIndex;
|
|
2064
2105
|
chatState.currentSelection = null;
|
|
2065
2106
|
disableNextButton();
|
|
@@ -2077,6 +2118,21 @@ async function handleNext() {
|
|
|
2077
2118
|
const targetStep = result.goToStep;
|
|
2078
2119
|
|
|
2079
2120
|
if (targetStep >= 0 && targetStep < flowData.flow.length) {
|
|
2121
|
+
// ✅ NEW: Handle prefillData to override disableInputValuePrefill
|
|
2122
|
+
if (result.prefillData && typeof result.prefillData === 'object') {
|
|
2123
|
+
console.log(` 📝 Pre-filling data for jump:`, result.prefillData);
|
|
2124
|
+
|
|
2125
|
+
// Merge prefillData into chatState.data
|
|
2126
|
+
Object.keys(result.prefillData).forEach(key => {
|
|
2127
|
+
chatState.data[key] = result.prefillData[key];
|
|
2128
|
+
console.log(` → Set ${key}:`, result.prefillData[key]);
|
|
2129
|
+
});
|
|
2130
|
+
|
|
2131
|
+
// ✅ Store which fields should override disableInputValuePrefill
|
|
2132
|
+
chatState.prefillOverrideFields = Object.keys(result.prefillData);
|
|
2133
|
+
console.log(` 🔓 Override active for fields:`, chatState.prefillOverrideFields);
|
|
2134
|
+
}
|
|
2135
|
+
|
|
2080
2136
|
chatState.step = targetStep;
|
|
2081
2137
|
chatState.currentSelection = null;
|
|
2082
2138
|
disableNextButton();
|
|
@@ -2520,6 +2576,22 @@ async function showNextStep() {
|
|
|
2520
2576
|
|
|
2521
2577
|
if (targetStepIndex !== -1) {
|
|
2522
2578
|
console.log(` ✅ Found step "${stepName}" at index ${targetStepIndex}`);
|
|
2579
|
+
|
|
2580
|
+
// ✅ NEW: Handle prefillData to override disableInputValuePrefill
|
|
2581
|
+
if (result.prefillData && typeof result.prefillData === 'object') {
|
|
2582
|
+
console.log(` 📝 Pre-filling data for jump:`, result.prefillData);
|
|
2583
|
+
|
|
2584
|
+
// Merge prefillData into chatState.data
|
|
2585
|
+
Object.keys(result.prefillData).forEach(key => {
|
|
2586
|
+
chatState.data[key] = result.prefillData[key];
|
|
2587
|
+
console.log(` → Set ${key}:`, result.prefillData[key]);
|
|
2588
|
+
});
|
|
2589
|
+
|
|
2590
|
+
// ✅ Store which fields should override disableInputValuePrefill
|
|
2591
|
+
chatState.prefillOverrideFields = Object.keys(result.prefillData);
|
|
2592
|
+
console.log(` 🔓 Override active for fields:`, chatState.prefillOverrideFields);
|
|
2593
|
+
}
|
|
2594
|
+
|
|
2523
2595
|
chatState.step = targetStepIndex;
|
|
2524
2596
|
chatState.currentSelection = null;
|
|
2525
2597
|
disableNextButton();
|
|
@@ -2537,6 +2609,21 @@ async function showNextStep() {
|
|
|
2537
2609
|
const targetStep = result.goToStep;
|
|
2538
2610
|
|
|
2539
2611
|
if (targetStep >= 0 && targetStep < flowData.flow.length) {
|
|
2612
|
+
// ✅ NEW: Handle prefillData to override disableInputValuePrefill
|
|
2613
|
+
if (result.prefillData && typeof result.prefillData === 'object') {
|
|
2614
|
+
console.log(` 📝 Pre-filling data for jump:`, result.prefillData);
|
|
2615
|
+
|
|
2616
|
+
// Merge prefillData into chatState.data
|
|
2617
|
+
Object.keys(result.prefillData).forEach(key => {
|
|
2618
|
+
chatState.data[key] = result.prefillData[key];
|
|
2619
|
+
console.log(` → Set ${key}:`, result.prefillData[key]);
|
|
2620
|
+
});
|
|
2621
|
+
|
|
2622
|
+
// ✅ Store which fields should override disableInputValuePrefill
|
|
2623
|
+
chatState.prefillOverrideFields = Object.keys(result.prefillData);
|
|
2624
|
+
console.log(` 🔓 Override active for fields:`, chatState.prefillOverrideFields);
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2540
2627
|
chatState.step = targetStep;
|
|
2541
2628
|
chatState.currentSelection = null;
|
|
2542
2629
|
disableNextButton();
|
|
@@ -2737,6 +2824,22 @@ async function showNextStep() {
|
|
|
2737
2824
|
}
|
|
2738
2825
|
}
|
|
2739
2826
|
|
|
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
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
|
|
2740
2843
|
setTimeout(() => {
|
|
2741
2844
|
updateEditIcons();
|
|
2742
2845
|
}, 10);
|