lisichatbot 1.9.0 → 1.9.2
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 +15 -11
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -873,6 +873,7 @@ function renderCustomSelectOptions(options, field, customConfig) {
|
|
|
873
873
|
optionsWrapper.style.gap = '8px';
|
|
874
874
|
|
|
875
875
|
let hasPreselectedOption = false; // ✅ Track if any option is pre-selected
|
|
876
|
+
let hasMatchingNormalOption = false; // ✅ Track if a normal option matches
|
|
876
877
|
|
|
877
878
|
options.forEach((option, index) => {
|
|
878
879
|
const optionName = option.name || option;
|
|
@@ -883,8 +884,8 @@ function renderCustomSelectOptions(options, field, customConfig) {
|
|
|
883
884
|
const clone = existingOption.cloneNode(true);
|
|
884
885
|
clone.style.display = '';
|
|
885
886
|
|
|
887
|
+
// ✅ Check if this option matches existingData (works for arrays and primitives)
|
|
886
888
|
const shouldBeChecked = existingData !== undefined &&
|
|
887
|
-
!Array.isArray(existingData) &&
|
|
888
889
|
JSON.stringify(existingData) === JSON.stringify(optionValue);
|
|
889
890
|
|
|
890
891
|
if (shouldBeChecked) {
|
|
@@ -892,6 +893,7 @@ function renderCustomSelectOptions(options, field, customConfig) {
|
|
|
892
893
|
clone.style.backgroundColor = config.selectedBackground;
|
|
893
894
|
console.log(` ✅ Pre-selected: ${optionName}`);
|
|
894
895
|
hasPreselectedOption = true; // ✅ Mark that we have a pre-selection
|
|
896
|
+
hasMatchingNormalOption = true; // ✅ A normal option matched
|
|
895
897
|
} else {
|
|
896
898
|
clone.classList.remove('cf-checked');
|
|
897
899
|
clone.style.backgroundColor = 'transparent';
|
|
@@ -969,7 +971,7 @@ function renderCustomSelectOptions(options, field, customConfig) {
|
|
|
969
971
|
}
|
|
970
972
|
|
|
971
973
|
elements.messages.appendChild(optionsWrapper);
|
|
972
|
-
renderMinMaxInputs(field, customConfig, existingData);
|
|
974
|
+
renderMinMaxInputs(field, customConfig, existingData, hasMatchingNormalOption);
|
|
973
975
|
|
|
974
976
|
// ✅ Very aggressive scrolling to ensure all options are visible
|
|
975
977
|
scrollToBottom();
|
|
@@ -1033,7 +1035,7 @@ function renderCustomSelectOptions(options, field, customConfig) {
|
|
|
1033
1035
|
}
|
|
1034
1036
|
}
|
|
1035
1037
|
|
|
1036
|
-
function renderMinMaxInputs(field, customConfig, existingData) {
|
|
1038
|
+
function renderMinMaxInputs(field, customConfig, existingData, hasMatchingNormalOption = false) {
|
|
1037
1039
|
if (!elements.messages || !customConfig) return;
|
|
1038
1040
|
|
|
1039
1041
|
const minSelector = '[data-chat-element="single-select-custom-min"]';
|
|
@@ -1057,12 +1059,14 @@ function renderMinMaxInputs(field, customConfig, existingData) {
|
|
|
1057
1059
|
rangeWrapper.setAttribute('data-field', field);
|
|
1058
1060
|
rangeWrapper.style.marginBottom = '16px';
|
|
1059
1061
|
rangeWrapper.style.display = 'flex';
|
|
1060
|
-
rangeWrapper.style.gap = '
|
|
1062
|
+
rangeWrapper.style.gap = '8px'; // ✅ Changed from 0px to 8px
|
|
1061
1063
|
rangeWrapper.style.flexWrap = 'wrap';
|
|
1062
1064
|
|
|
1065
|
+
// ✅ Only show min/max inputs if existingData is a range AND no normal option matched
|
|
1063
1066
|
const showMinMax = existingData !== undefined &&
|
|
1064
1067
|
Array.isArray(existingData) &&
|
|
1065
|
-
existingData.length === 2
|
|
1068
|
+
existingData.length === 2 &&
|
|
1069
|
+
!hasMatchingNormalOption; // ✅ Don't show if a normal option already matched
|
|
1066
1070
|
|
|
1067
1071
|
rangeWrapper.style.display = showMinMax ? 'flex' : 'none';
|
|
1068
1072
|
|
|
@@ -1188,7 +1192,7 @@ function renderMinMaxInputs(field, customConfig, existingData) {
|
|
|
1188
1192
|
}
|
|
1189
1193
|
|
|
1190
1194
|
updateVisualFeedback();
|
|
1191
|
-
validateMinMax
|
|
1195
|
+
// ✅ Removed validateMinMax - errors only show on Next button click
|
|
1192
1196
|
};
|
|
1193
1197
|
|
|
1194
1198
|
maxInput.onchange = () => {
|
|
@@ -1207,7 +1211,7 @@ function renderMinMaxInputs(field, customConfig, existingData) {
|
|
|
1207
1211
|
}
|
|
1208
1212
|
|
|
1209
1213
|
updateVisualFeedback();
|
|
1210
|
-
validateMinMax
|
|
1214
|
+
// ✅ Removed validateMinMax - errors only show on Next button click
|
|
1211
1215
|
};
|
|
1212
1216
|
}
|
|
1213
1217
|
}
|
|
@@ -1418,8 +1422,8 @@ function handleCustomSelectClick(element, field, customConfig) {
|
|
|
1418
1422
|
}
|
|
1419
1423
|
}
|
|
1420
1424
|
|
|
1421
|
-
function validateMinMax(field, customConfig) {
|
|
1422
|
-
console.log(`\n🔍 === VALIDATING MIN/MAX for field: ${field} ===`);
|
|
1425
|
+
function validateMinMax(field, customConfig, showErrors = false) {
|
|
1426
|
+
console.log(`\n🔍 === VALIDATING MIN/MAX for field: ${field} (showErrors: ${showErrors}) ===`);
|
|
1423
1427
|
|
|
1424
1428
|
const errors = config.customRangeErrors;
|
|
1425
1429
|
|
|
@@ -1452,7 +1456,7 @@ function validateMinMax(field, customConfig) {
|
|
|
1452
1456
|
Max constraint: <= ${maxConstraint}`);
|
|
1453
1457
|
|
|
1454
1458
|
const showErrorDiv = (message) => {
|
|
1455
|
-
if (errorDiv) {
|
|
1459
|
+
if (showErrors && errorDiv) { // ✅ Only show error if showErrors is true
|
|
1456
1460
|
errorDiv.textContent = message;
|
|
1457
1461
|
errorDiv.style.display = 'block';
|
|
1458
1462
|
}
|
|
@@ -2057,7 +2061,7 @@ async function handleNext() {
|
|
|
2057
2061
|
if (isCustomOptionSelected && customConfig) {
|
|
2058
2062
|
console.log(`🔄 Running final validation before proceeding...`);
|
|
2059
2063
|
|
|
2060
|
-
const validation = validateMinMax(field, customConfig);
|
|
2064
|
+
const validation = validateMinMax(field, customConfig, true); // ✅ Show errors on Next click
|
|
2061
2065
|
|
|
2062
2066
|
console.log(`Validation result:`, validation);
|
|
2063
2067
|
|