lisichatbot 1.2.8 → 1.3.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.
- package/package.json +1 -1
- package/src/index.js +100 -19
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -671,14 +671,15 @@ function renderMinMaxInputs(field, customConfig, existingData) {
|
|
|
671
671
|
Array.isArray(existingData) &&
|
|
672
672
|
existingData.length === 2;
|
|
673
673
|
|
|
674
|
-
rangeWrapper.style.display = showMinMax ? '' : 'none';
|
|
674
|
+
rangeWrapper.style.display = showMinMax ? 'flex' : 'none'; // Keep flex when visible!
|
|
675
675
|
|
|
676
676
|
// Clone and setup min input
|
|
677
677
|
const minClone = minTemplate.cloneNode(true);
|
|
678
678
|
minClone.style.display = '';
|
|
679
|
-
minClone.style.marginRight = '16px'; //
|
|
679
|
+
minClone.style.marginRight = '16px'; // Horizontal gap
|
|
680
|
+
minClone.style.marginBottom = '12px'; // Bottom margin if wraps
|
|
680
681
|
minClone.style.width = 'auto'; // Don't stretch
|
|
681
|
-
minClone.style.flex = '
|
|
682
|
+
minClone.style.flex = 'none'; // Don't grow or shrink
|
|
682
683
|
minClone.setAttribute('data-field', field);
|
|
683
684
|
|
|
684
685
|
const minInput = minClone.querySelector('[data-chat-input-element="input"]');
|
|
@@ -689,7 +690,7 @@ function renderMinMaxInputs(field, customConfig, existingData) {
|
|
|
689
690
|
minInput.min = customConfig.min !== undefined ? customConfig.min : 0;
|
|
690
691
|
minInput.max = customConfig.max !== undefined ? customConfig.max : 100;
|
|
691
692
|
minInput.value = showMinMax && existingData[0] !== undefined ? existingData[0] : '';
|
|
692
|
-
|
|
693
|
+
// Removed placeholder
|
|
693
694
|
|
|
694
695
|
if (showMinMax) {
|
|
695
696
|
console.log(` ✅ Pre-filled min: ${existingData[0]}`);
|
|
@@ -699,8 +700,9 @@ function renderMinMaxInputs(field, customConfig, existingData) {
|
|
|
699
700
|
// Clone and setup max input
|
|
700
701
|
const maxClone = maxTemplate.cloneNode(true);
|
|
701
702
|
maxClone.style.display = '';
|
|
703
|
+
maxClone.style.marginBottom = '12px'; // Bottom margin if wraps
|
|
702
704
|
maxClone.style.width = 'auto'; // Don't stretch
|
|
703
|
-
maxClone.style.flex = '
|
|
705
|
+
maxClone.style.flex = 'none'; // Don't grow or shrink
|
|
704
706
|
maxClone.setAttribute('data-field', field);
|
|
705
707
|
|
|
706
708
|
const maxInput = maxClone.querySelector('[data-chat-input-element="input"]');
|
|
@@ -711,7 +713,7 @@ function renderMinMaxInputs(field, customConfig, existingData) {
|
|
|
711
713
|
maxInput.min = customConfig.min !== undefined ? customConfig.min : 0;
|
|
712
714
|
maxInput.max = customConfig.max !== undefined ? customConfig.max : 100;
|
|
713
715
|
maxInput.value = showMinMax && existingData[1] !== undefined ? existingData[1] : '';
|
|
714
|
-
|
|
716
|
+
// Removed placeholder
|
|
715
717
|
|
|
716
718
|
if (showMinMax) {
|
|
717
719
|
console.log(` ✅ Pre-filled max: ${existingData[1]}`);
|
|
@@ -758,6 +760,14 @@ function renderMinMaxInputs(field, customConfig, existingData) {
|
|
|
758
760
|
}
|
|
759
761
|
};
|
|
760
762
|
|
|
763
|
+
// Apply visual feedback immediately if pre-filled
|
|
764
|
+
if (showMinMax) {
|
|
765
|
+
updateVisualFeedback();
|
|
766
|
+
// Also run validation to set currentSelection
|
|
767
|
+
validateMinMax(field, customConfig);
|
|
768
|
+
console.log(' ✅ Applied visual feedback for pre-filled values');
|
|
769
|
+
}
|
|
770
|
+
|
|
761
771
|
minInput.onfocus = () => {
|
|
762
772
|
selectCustomOption(field);
|
|
763
773
|
updateVisualFeedback();
|
|
@@ -801,7 +811,7 @@ function selectCustomOption(field) {
|
|
|
801
811
|
// Show min/max inputs
|
|
802
812
|
const rangeWrapper = document.querySelector(`[data-chat-element="range-wrapper"][data-field="${field}"]`);
|
|
803
813
|
if (rangeWrapper) {
|
|
804
|
-
rangeWrapper.style.display = '';
|
|
814
|
+
rangeWrapper.style.display = 'flex'; // Keep flex!
|
|
805
815
|
}
|
|
806
816
|
}
|
|
807
817
|
|
|
@@ -830,8 +840,16 @@ function handleCustomSelectClick(element, field, customConfig) {
|
|
|
830
840
|
if (isCustom) {
|
|
831
841
|
// Show min/max inputs
|
|
832
842
|
const rangeWrapper = document.querySelector(`[data-chat-element="range-wrapper"][data-field="${field}"]`);
|
|
843
|
+
console.log(' 📦 Looking for rangeWrapper:', `[data-chat-element="range-wrapper"][data-field="${field}"]`);
|
|
844
|
+
console.log(' 📦 Found rangeWrapper:', rangeWrapper);
|
|
845
|
+
|
|
833
846
|
if (rangeWrapper) {
|
|
834
|
-
rangeWrapper.style.display
|
|
847
|
+
console.log(' 📦 Current display:', rangeWrapper.style.display);
|
|
848
|
+
rangeWrapper.style.display = 'flex'; // Keep flex!
|
|
849
|
+
console.log(' ✅ Set rangeWrapper display to flex');
|
|
850
|
+
console.log(' 📦 New display:', rangeWrapper.style.display);
|
|
851
|
+
} else {
|
|
852
|
+
console.log(' ❌ rangeWrapper not found!');
|
|
835
853
|
}
|
|
836
854
|
|
|
837
855
|
// Don't save data yet - wait for validation
|
|
@@ -843,12 +861,18 @@ function handleCustomSelectClick(element, field, customConfig) {
|
|
|
843
861
|
if (rangeWrapper) {
|
|
844
862
|
rangeWrapper.style.display = 'none';
|
|
845
863
|
|
|
846
|
-
// Clear input values
|
|
847
|
-
const minInput =
|
|
848
|
-
const maxInput =
|
|
864
|
+
// Clear input values - fixed selectors
|
|
865
|
+
const minInput = document.querySelector(`[data-field="${field}"][data-input-type="min"][data-chat-input-element="input"]`);
|
|
866
|
+
const maxInput = document.querySelector(`[data-field="${field}"][data-input-type="max"][data-chat-input-element="input"]`);
|
|
849
867
|
|
|
850
|
-
if (minInput)
|
|
851
|
-
|
|
868
|
+
if (minInput) {
|
|
869
|
+
minInput.value = '';
|
|
870
|
+
console.log(' 🧹 Cleared min input');
|
|
871
|
+
}
|
|
872
|
+
if (maxInput) {
|
|
873
|
+
maxInput.value = '';
|
|
874
|
+
console.log(' 🧹 Cleared max input');
|
|
875
|
+
}
|
|
852
876
|
|
|
853
877
|
// Reset visual feedback (background and ticks)
|
|
854
878
|
const minContainer = rangeWrapper.querySelector('[data-chat-element="single-select-custom-min"]');
|
|
@@ -891,12 +915,18 @@ function handleCustomSelectClick(element, field, customConfig) {
|
|
|
891
915
|
function validateMinMax(field, customConfig) {
|
|
892
916
|
console.log(`\n🔍 === VALIDATING MIN/MAX for field: ${field} ===`);
|
|
893
917
|
|
|
894
|
-
|
|
895
|
-
const
|
|
918
|
+
// Fixed selectors - input has all attributes on it directly
|
|
919
|
+
const minInput = document.querySelector(`[data-field="${field}"][data-input-type="min"][data-chat-input-element="input"]`);
|
|
920
|
+
const maxInput = document.querySelector(`[data-field="${field}"][data-input-type="max"][data-chat-input-element="input"]`);
|
|
896
921
|
const errorDiv = document.querySelector(`[data-chat-element="range-error"][data-field="${field}"]`);
|
|
897
922
|
|
|
898
923
|
if (!minInput || !maxInput) {
|
|
899
924
|
console.log('❌ Min or Max input not found');
|
|
925
|
+
console.log(' Tried selectors:');
|
|
926
|
+
console.log(` Min: [data-field="${field}"][data-input-type="min"][data-chat-input-element="input"]`);
|
|
927
|
+
console.log(` Max: [data-field="${field}"][data-input-type="max"][data-chat-input-element="input"]`);
|
|
928
|
+
console.log(' Found min:', minInput);
|
|
929
|
+
console.log(' Found max:', maxInput);
|
|
900
930
|
return { valid: false, error: null };
|
|
901
931
|
}
|
|
902
932
|
|
|
@@ -1011,15 +1041,35 @@ function validateMinMax(field, customConfig) {
|
|
|
1011
1041
|
|
|
1012
1042
|
// Store as array [min, max]
|
|
1013
1043
|
chatState.data[field] = [minValue, maxValue];
|
|
1044
|
+
|
|
1045
|
+
// Get the current step's input config for formatting
|
|
1046
|
+
const currentStep = flowData.flow[chatState.step];
|
|
1047
|
+
const inputConfig = currentStep?.input || {};
|
|
1048
|
+
const valueType = inputConfig.selectedInputValueType;
|
|
1049
|
+
const prefix = inputConfig.selectedInputPrefix || '';
|
|
1050
|
+
const suffix = inputConfig.selectedInputSuffix || '';
|
|
1051
|
+
|
|
1052
|
+
// Format display name
|
|
1053
|
+
let displayName = `${minValue}-${maxValue}`;
|
|
1054
|
+
if (valueType === 'arrayRange') {
|
|
1055
|
+
const formattedMin = minValue.toLocaleString();
|
|
1056
|
+
const formattedMax = maxValue.toLocaleString();
|
|
1057
|
+
displayName = `${formattedMin} - ${formattedMax}`;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
// Add prefix and suffix with spaces
|
|
1061
|
+
if (prefix) displayName = `${prefix} ${displayName}`;
|
|
1062
|
+
if (suffix) displayName = `${displayName} ${suffix}`;
|
|
1063
|
+
|
|
1014
1064
|
chatState.currentSelection = {
|
|
1015
1065
|
field,
|
|
1016
1066
|
value: [minValue, maxValue],
|
|
1017
|
-
name:
|
|
1067
|
+
name: displayName
|
|
1018
1068
|
};
|
|
1019
1069
|
|
|
1020
1070
|
console.log(`✅✅✅ ALL VALIDATION PASSED!`);
|
|
1021
1071
|
console.log(`💾 Data saved: chatState.data.${field} = [${minValue}, ${maxValue}]`);
|
|
1022
|
-
console.log(`💾
|
|
1072
|
+
console.log(`💾 Display name: "${displayName}"`);
|
|
1023
1073
|
console.log(`🟢 Next button: ENABLED\n`);
|
|
1024
1074
|
|
|
1025
1075
|
enableNextButton();
|
|
@@ -1322,14 +1372,34 @@ async function handleNext() {
|
|
|
1322
1372
|
|
|
1323
1373
|
// Add user message (only if selection was made)
|
|
1324
1374
|
if (chatState.currentSelection) {
|
|
1325
|
-
|
|
1375
|
+
// Get the step's input config
|
|
1376
|
+
const inputConfig = currentStep.input || {};
|
|
1377
|
+
const valueType = inputConfig.selectedInputValueType;
|
|
1378
|
+
const prefix = inputConfig.selectedInputPrefix || '';
|
|
1379
|
+
const suffix = inputConfig.selectedInputSuffix || '';
|
|
1380
|
+
|
|
1381
|
+
let displayName = chatState.currentSelection.name;
|
|
1382
|
+
|
|
1383
|
+
// Format based on valueType
|
|
1384
|
+
if (valueType === 'arrayRange' && Array.isArray(chatState.currentSelection.value)) {
|
|
1385
|
+
const [min, max] = chatState.currentSelection.value;
|
|
1386
|
+
const formattedMin = min.toLocaleString();
|
|
1387
|
+
const formattedMax = max.toLocaleString();
|
|
1388
|
+
displayName = `${formattedMin} - ${formattedMax}`;
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
// Add prefix and suffix with spaces
|
|
1392
|
+
if (prefix) displayName = `${prefix} ${displayName}`;
|
|
1393
|
+
if (suffix) displayName = `${displayName} ${suffix}`;
|
|
1394
|
+
|
|
1395
|
+
addMessage(displayName, 'user', false, chatState.step);
|
|
1326
1396
|
|
|
1327
1397
|
// Save to history
|
|
1328
1398
|
chatState.history.push({
|
|
1329
1399
|
step: chatState.step,
|
|
1330
1400
|
field: chatState.currentSelection.field,
|
|
1331
1401
|
value: chatState.currentSelection.value,
|
|
1332
|
-
name:
|
|
1402
|
+
name: displayName
|
|
1333
1403
|
});
|
|
1334
1404
|
}
|
|
1335
1405
|
|
|
@@ -1485,6 +1555,17 @@ async function showNextStep() {
|
|
|
1485
1555
|
}, config.autoAdvanceDelay);
|
|
1486
1556
|
}
|
|
1487
1557
|
|
|
1558
|
+
// Handle nextButtonDisplay - default is true
|
|
1559
|
+
const showNextButton = nextStep.nextButtonDisplay !== false;
|
|
1560
|
+
if (elements.nextButton) {
|
|
1561
|
+
if (showNextButton) {
|
|
1562
|
+
elements.nextButton.style.display = '';
|
|
1563
|
+
} else {
|
|
1564
|
+
elements.nextButton.style.display = 'none';
|
|
1565
|
+
console.log(' 🙈 Next button hidden (nextButtonDisplay: false)');
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1488
1569
|
// Always update edit icons at the end to ensure correct state
|
|
1489
1570
|
// Use setTimeout to ensure it runs after any DOM updates
|
|
1490
1571
|
setTimeout(() => {
|