lisichatbot 1.2.9 → 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 +84 -11
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -690,7 +690,7 @@ function renderMinMaxInputs(field, customConfig, existingData) {
|
|
|
690
690
|
minInput.min = customConfig.min !== undefined ? customConfig.min : 0;
|
|
691
691
|
minInput.max = customConfig.max !== undefined ? customConfig.max : 100;
|
|
692
692
|
minInput.value = showMinMax && existingData[0] !== undefined ? existingData[0] : '';
|
|
693
|
-
|
|
693
|
+
// Removed placeholder
|
|
694
694
|
|
|
695
695
|
if (showMinMax) {
|
|
696
696
|
console.log(` ✅ Pre-filled min: ${existingData[0]}`);
|
|
@@ -713,7 +713,7 @@ function renderMinMaxInputs(field, customConfig, existingData) {
|
|
|
713
713
|
maxInput.min = customConfig.min !== undefined ? customConfig.min : 0;
|
|
714
714
|
maxInput.max = customConfig.max !== undefined ? customConfig.max : 100;
|
|
715
715
|
maxInput.value = showMinMax && existingData[1] !== undefined ? existingData[1] : '';
|
|
716
|
-
|
|
716
|
+
// Removed placeholder
|
|
717
717
|
|
|
718
718
|
if (showMinMax) {
|
|
719
719
|
console.log(` ✅ Pre-filled max: ${existingData[1]}`);
|
|
@@ -760,6 +760,14 @@ function renderMinMaxInputs(field, customConfig, existingData) {
|
|
|
760
760
|
}
|
|
761
761
|
};
|
|
762
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
|
+
|
|
763
771
|
minInput.onfocus = () => {
|
|
764
772
|
selectCustomOption(field);
|
|
765
773
|
updateVisualFeedback();
|
|
@@ -832,8 +840,16 @@ function handleCustomSelectClick(element, field, customConfig) {
|
|
|
832
840
|
if (isCustom) {
|
|
833
841
|
// Show min/max inputs
|
|
834
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
|
+
|
|
835
846
|
if (rangeWrapper) {
|
|
847
|
+
console.log(' 📦 Current display:', rangeWrapper.style.display);
|
|
836
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!');
|
|
837
853
|
}
|
|
838
854
|
|
|
839
855
|
// Don't save data yet - wait for validation
|
|
@@ -845,12 +861,18 @@ function handleCustomSelectClick(element, field, customConfig) {
|
|
|
845
861
|
if (rangeWrapper) {
|
|
846
862
|
rangeWrapper.style.display = 'none';
|
|
847
863
|
|
|
848
|
-
// Clear input values
|
|
849
|
-
const minInput =
|
|
850
|
-
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"]`);
|
|
851
867
|
|
|
852
|
-
if (minInput)
|
|
853
|
-
|
|
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
|
+
}
|
|
854
876
|
|
|
855
877
|
// Reset visual feedback (background and ticks)
|
|
856
878
|
const minContainer = rangeWrapper.querySelector('[data-chat-element="single-select-custom-min"]');
|
|
@@ -1019,15 +1041,35 @@ function validateMinMax(field, customConfig) {
|
|
|
1019
1041
|
|
|
1020
1042
|
// Store as array [min, max]
|
|
1021
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
|
+
|
|
1022
1064
|
chatState.currentSelection = {
|
|
1023
1065
|
field,
|
|
1024
1066
|
value: [minValue, maxValue],
|
|
1025
|
-
name:
|
|
1067
|
+
name: displayName
|
|
1026
1068
|
};
|
|
1027
1069
|
|
|
1028
1070
|
console.log(`✅✅✅ ALL VALIDATION PASSED!`);
|
|
1029
1071
|
console.log(`💾 Data saved: chatState.data.${field} = [${minValue}, ${maxValue}]`);
|
|
1030
|
-
console.log(`💾
|
|
1072
|
+
console.log(`💾 Display name: "${displayName}"`);
|
|
1031
1073
|
console.log(`🟢 Next button: ENABLED\n`);
|
|
1032
1074
|
|
|
1033
1075
|
enableNextButton();
|
|
@@ -1330,14 +1372,34 @@ async function handleNext() {
|
|
|
1330
1372
|
|
|
1331
1373
|
// Add user message (only if selection was made)
|
|
1332
1374
|
if (chatState.currentSelection) {
|
|
1333
|
-
|
|
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);
|
|
1334
1396
|
|
|
1335
1397
|
// Save to history
|
|
1336
1398
|
chatState.history.push({
|
|
1337
1399
|
step: chatState.step,
|
|
1338
1400
|
field: chatState.currentSelection.field,
|
|
1339
1401
|
value: chatState.currentSelection.value,
|
|
1340
|
-
name:
|
|
1402
|
+
name: displayName
|
|
1341
1403
|
});
|
|
1342
1404
|
}
|
|
1343
1405
|
|
|
@@ -1493,6 +1555,17 @@ async function showNextStep() {
|
|
|
1493
1555
|
}, config.autoAdvanceDelay);
|
|
1494
1556
|
}
|
|
1495
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
|
+
|
|
1496
1569
|
// Always update edit icons at the end to ensure correct state
|
|
1497
1570
|
// Use setTimeout to ensure it runs after any DOM updates
|
|
1498
1571
|
setTimeout(() => {
|