lisichatbot 1.5.9 → 1.6.0

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 +95 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisichatbot",
3
- "version": "1.5.9",
3
+ "version": "1.6.0",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
package/src/index.js CHANGED
@@ -293,7 +293,7 @@ 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 disablePrefill = currentStep?.disableInputValuePrefill === true;
296
+ const disablePrefill = currentStep?.disableInputValuePrefill === true && !chatState.prefillOverride;
297
297
 
298
298
  const existingData = disablePrefill ? [] : (chatState.data[field] || []);
299
299
  const selectedValues = new Set(existingData);
@@ -301,7 +301,11 @@ function renderMultiSelectDropdown(options, field) {
301
301
  if (disablePrefill) {
302
302
  console.log(`⏭️ Pre-fill disabled for ${field} - starting fresh`);
303
303
  } else {
304
- console.log(`📝 Pre-filling selections for ${field}:`, Array.from(selectedValues));
304
+ if (chatState.prefillOverride) {
305
+ console.log(` 🔓 Pre-fill override active - filling ${field}:`, Array.from(selectedValues));
306
+ } else {
307
+ console.log(`📝 Pre-filling selections for ${field}:`, Array.from(selectedValues));
308
+ }
305
309
  }
306
310
 
307
311
  const allOptions = [];
@@ -552,14 +556,18 @@ function renderOptions(options, field, isSingleSelect = true) {
552
556
 
553
557
  // ✅ NEW: Check if prefill is disabled for this step
554
558
  const currentStep = flowData.flow[chatState.step];
555
- const disablePrefill = currentStep?.disableInputValuePrefill === true;
559
+ const disablePrefill = currentStep?.disableInputValuePrefill === true && !chatState.prefillOverride;
556
560
 
557
561
  const existingData = disablePrefill ? (isSingleSelect ? null : []) : chatState.data[field];
558
562
 
559
563
  if (disablePrefill) {
560
564
  console.log(`⏭️ Pre-fill disabled for ${field} - starting fresh`);
561
565
  } else {
562
- console.log(`📝 Pre-filling ${field}:`, existingData);
566
+ if (chatState.prefillOverride) {
567
+ console.log(` 🔓 Pre-fill override active - filling ${field}:`, existingData);
568
+ } else {
569
+ console.log(`📝 Pre-filling ${field}:`, existingData);
570
+ }
563
571
  }
564
572
 
565
573
  const optionsWrapper = document.createElement('div');
@@ -686,14 +694,18 @@ function renderColorOptions(options, field) {
686
694
 
687
695
  // ✅ NEW: Check if prefill is disabled for this step
688
696
  const currentStep = flowData.flow[chatState.step];
689
- const disablePrefill = currentStep?.disableInputValuePrefill === true;
697
+ const disablePrefill = currentStep?.disableInputValuePrefill === true && !chatState.prefillOverride;
690
698
 
691
699
  const existingData = disablePrefill ? [] : chatState.data[field];
692
700
 
693
701
  if (disablePrefill) {
694
702
  console.log(`⏭️ Pre-fill disabled for ${field} (color) - starting fresh`);
695
703
  } else {
696
- console.log(`📝 Pre-filling ${field} (color):`, existingData);
704
+ if (chatState.prefillOverride) {
705
+ console.log(` 🔓 Pre-fill override active - filling ${field} (color):`, existingData);
706
+ } else {
707
+ console.log(`📝 Pre-filling ${field} (color):`, existingData);
708
+ }
697
709
  }
698
710
 
699
711
  const optionsWrapper = document.createElement('div');
@@ -817,14 +829,18 @@ function renderCustomSelectOptions(options, field, customConfig) {
817
829
 
818
830
  // ✅ NEW: Check if prefill is disabled for this step
819
831
  const currentStep = flowData.flow[chatState.step];
820
- const disablePrefill = currentStep?.disableInputValuePrefill === true;
832
+ const disablePrefill = currentStep?.disableInputValuePrefill === true && !chatState.prefillOverride;
821
833
 
822
834
  const existingData = disablePrefill ? null : chatState.data[field];
823
835
 
824
836
  if (disablePrefill) {
825
837
  console.log(`⏭️ Pre-fill disabled for ${field} (custom) - starting fresh`);
826
838
  } else {
827
- console.log(`📝 Pre-filling ${field} (custom):`, existingData);
839
+ if (chatState.prefillOverride) {
840
+ console.log(` 🔓 Pre-fill override active - filling ${field} (custom):`, existingData);
841
+ } else {
842
+ console.log(`📝 Pre-filling ${field} (custom):`, existingData);
843
+ }
828
844
  }
829
845
 
830
846
  const optionsWrapper = document.createElement('div');
@@ -1439,14 +1455,18 @@ function renderTextInput(field, inputType = 'text', inputConfig = {}) {
1439
1455
 
1440
1456
  // ✅ NEW: Check if prefill is disabled for this step
1441
1457
  const currentStep = flowData.flow[chatState.step];
1442
- const disablePrefill = currentStep?.disableInputValuePrefill === true;
1458
+ const disablePrefill = currentStep?.disableInputValuePrefill === true && !chatState.prefillOverride;
1443
1459
 
1444
1460
  const existingValue = disablePrefill ? null : chatState.data[field];
1445
1461
 
1446
1462
  if (disablePrefill) {
1447
1463
  console.log(`⏭️ Pre-fill disabled for ${field} - starting fresh`);
1448
1464
  } else {
1449
- console.log(`📝 Pre-filling ${field}:`, existingValue);
1465
+ if (chatState.prefillOverride) {
1466
+ console.log(` 🔓 Pre-fill override active - filling ${field}:`, existingValue);
1467
+ } else {
1468
+ console.log(`📝 Pre-filling ${field}:`, existingValue);
1469
+ }
1450
1470
  }
1451
1471
 
1452
1472
  const hasValidation = inputType === 'number' &&
@@ -2060,6 +2080,21 @@ async function handleNext() {
2060
2080
 
2061
2081
  if (targetStepIndex !== -1) {
2062
2082
  console.log(` ✅ Found step "${stepName}" at index ${targetStepIndex}`);
2083
+
2084
+ // ✅ NEW: Handle prefillData to override disableInputValuePrefill
2085
+ if (result.prefillData && typeof result.prefillData === 'object') {
2086
+ console.log(` 📝 Pre-filling data for jump:`, result.prefillData);
2087
+
2088
+ // Merge prefillData into chatState.data
2089
+ Object.keys(result.prefillData).forEach(key => {
2090
+ chatState.data[key] = result.prefillData[key];
2091
+ console.log(` → Set ${key}:`, result.prefillData[key]);
2092
+ });
2093
+
2094
+ // ✅ Store prefill override flag
2095
+ chatState.prefillOverride = true;
2096
+ }
2097
+
2063
2098
  chatState.step = targetStepIndex;
2064
2099
  chatState.currentSelection = null;
2065
2100
  disableNextButton();
@@ -2077,6 +2112,20 @@ async function handleNext() {
2077
2112
  const targetStep = result.goToStep;
2078
2113
 
2079
2114
  if (targetStep >= 0 && targetStep < flowData.flow.length) {
2115
+ // ✅ NEW: Handle prefillData to override disableInputValuePrefill
2116
+ if (result.prefillData && typeof result.prefillData === 'object') {
2117
+ console.log(` 📝 Pre-filling data for jump:`, result.prefillData);
2118
+
2119
+ // Merge prefillData into chatState.data
2120
+ Object.keys(result.prefillData).forEach(key => {
2121
+ chatState.data[key] = result.prefillData[key];
2122
+ console.log(` → Set ${key}:`, result.prefillData[key]);
2123
+ });
2124
+
2125
+ // ✅ Store prefill override flag
2126
+ chatState.prefillOverride = true;
2127
+ }
2128
+
2080
2129
  chatState.step = targetStep;
2081
2130
  chatState.currentSelection = null;
2082
2131
  disableNextButton();
@@ -2520,6 +2569,21 @@ async function showNextStep() {
2520
2569
 
2521
2570
  if (targetStepIndex !== -1) {
2522
2571
  console.log(` ✅ Found step "${stepName}" at index ${targetStepIndex}`);
2572
+
2573
+ // ✅ NEW: Handle prefillData to override disableInputValuePrefill
2574
+ if (result.prefillData && typeof result.prefillData === 'object') {
2575
+ console.log(` 📝 Pre-filling data for jump:`, result.prefillData);
2576
+
2577
+ // Merge prefillData into chatState.data
2578
+ Object.keys(result.prefillData).forEach(key => {
2579
+ chatState.data[key] = result.prefillData[key];
2580
+ console.log(` → Set ${key}:`, result.prefillData[key]);
2581
+ });
2582
+
2583
+ // ✅ Store prefill override flag
2584
+ chatState.prefillOverride = true;
2585
+ }
2586
+
2523
2587
  chatState.step = targetStepIndex;
2524
2588
  chatState.currentSelection = null;
2525
2589
  disableNextButton();
@@ -2537,6 +2601,20 @@ async function showNextStep() {
2537
2601
  const targetStep = result.goToStep;
2538
2602
 
2539
2603
  if (targetStep >= 0 && targetStep < flowData.flow.length) {
2604
+ // ✅ NEW: Handle prefillData to override disableInputValuePrefill
2605
+ if (result.prefillData && typeof result.prefillData === 'object') {
2606
+ console.log(` 📝 Pre-filling data for jump:`, result.prefillData);
2607
+
2608
+ // Merge prefillData into chatState.data
2609
+ Object.keys(result.prefillData).forEach(key => {
2610
+ chatState.data[key] = result.prefillData[key];
2611
+ console.log(` → Set ${key}:`, result.prefillData[key]);
2612
+ });
2613
+
2614
+ // ✅ Store prefill override flag
2615
+ chatState.prefillOverride = true;
2616
+ }
2617
+
2540
2618
  chatState.step = targetStep;
2541
2619
  chatState.currentSelection = null;
2542
2620
  disableNextButton();
@@ -2737,6 +2815,13 @@ async function showNextStep() {
2737
2815
  }
2738
2816
  }
2739
2817
 
2818
+ // ✅ Clear prefillOverride flag after rendering this step
2819
+ // This ensures it only applies to the first step after goToStep with prefillData
2820
+ if (chatState.prefillOverride) {
2821
+ console.log(` 🔓 Clearing prefill override flag`);
2822
+ chatState.prefillOverride = false;
2823
+ }
2824
+
2740
2825
  setTimeout(() => {
2741
2826
  updateEditIcons();
2742
2827
  }, 10);