lisichatbot 1.2.7 ā 1.2.8
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 +50 -9
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -676,6 +676,9 @@ function renderMinMaxInputs(field, customConfig, existingData) {
|
|
|
676
676
|
// Clone and setup min input
|
|
677
677
|
const minClone = minTemplate.cloneNode(true);
|
|
678
678
|
minClone.style.display = '';
|
|
679
|
+
minClone.style.marginRight = '16px'; // Gap between min and max
|
|
680
|
+
minClone.style.width = 'auto'; // Don't stretch
|
|
681
|
+
minClone.style.flex = '0 0 auto'; // Don't grow or shrink
|
|
679
682
|
minClone.setAttribute('data-field', field);
|
|
680
683
|
|
|
681
684
|
const minInput = minClone.querySelector('[data-chat-input-element="input"]');
|
|
@@ -696,6 +699,8 @@ function renderMinMaxInputs(field, customConfig, existingData) {
|
|
|
696
699
|
// Clone and setup max input
|
|
697
700
|
const maxClone = maxTemplate.cloneNode(true);
|
|
698
701
|
maxClone.style.display = '';
|
|
702
|
+
maxClone.style.width = 'auto'; // Don't stretch
|
|
703
|
+
maxClone.style.flex = '0 0 auto'; // Don't grow or shrink
|
|
699
704
|
maxClone.setAttribute('data-field', field);
|
|
700
705
|
|
|
701
706
|
const maxInput = maxClone.querySelector('[data-chat-input-element="input"]');
|
|
@@ -884,11 +889,16 @@ function handleCustomSelectClick(element, field, customConfig) {
|
|
|
884
889
|
}
|
|
885
890
|
|
|
886
891
|
function validateMinMax(field, customConfig) {
|
|
892
|
+
console.log(`\nš === VALIDATING MIN/MAX for field: ${field} ===`);
|
|
893
|
+
|
|
887
894
|
const minInput = document.querySelector(`[data-field="${field}"][data-input-type="min"] [data-chat-input-element="input"]`);
|
|
888
895
|
const maxInput = document.querySelector(`[data-field="${field}"][data-input-type="max"] [data-chat-input-element="input"]`);
|
|
889
896
|
const errorDiv = document.querySelector(`[data-chat-element="range-error"][data-field="${field}"]`);
|
|
890
897
|
|
|
891
|
-
if (!minInput || !maxInput)
|
|
898
|
+
if (!minInput || !maxInput) {
|
|
899
|
+
console.log('ā Min or Max input not found');
|
|
900
|
+
return { valid: false, error: null };
|
|
901
|
+
}
|
|
892
902
|
|
|
893
903
|
const minValue = parseFloat(minInput.value);
|
|
894
904
|
const maxValue = parseFloat(maxInput.value);
|
|
@@ -898,6 +908,14 @@ function validateMinMax(field, customConfig) {
|
|
|
898
908
|
const minConstraint = customConfig.min !== undefined ? customConfig.min : 0;
|
|
899
909
|
const maxConstraint = customConfig.max !== undefined ? customConfig.max : 100;
|
|
900
910
|
|
|
911
|
+
console.log(`š Input values:
|
|
912
|
+
Min input value: "${minInput.value}" (filled: ${minFilled}, parsed: ${minValue})
|
|
913
|
+
Max input value: "${maxInput.value}" (filled: ${maxFilled}, parsed: ${maxValue})`);
|
|
914
|
+
|
|
915
|
+
console.log(`š Constraints:
|
|
916
|
+
Min constraint: >= ${minConstraint}
|
|
917
|
+
Max constraint: <= ${maxConstraint}`);
|
|
918
|
+
|
|
901
919
|
// Helper to show error in div and clear data
|
|
902
920
|
const showErrorDiv = (message) => {
|
|
903
921
|
if (errorDiv) {
|
|
@@ -907,6 +925,7 @@ function validateMinMax(field, customConfig) {
|
|
|
907
925
|
// Clear the data when validation fails
|
|
908
926
|
delete chatState.data[field];
|
|
909
927
|
chatState.currentSelection = null;
|
|
928
|
+
console.log(`šļø Data cleared for field: ${field}`);
|
|
910
929
|
};
|
|
911
930
|
|
|
912
931
|
// Helper to hide error div
|
|
@@ -922,7 +941,7 @@ function validateMinMax(field, customConfig) {
|
|
|
922
941
|
if (minFilled && !maxFilled) {
|
|
923
942
|
const error = config.customRangeErrors.maxRequired;
|
|
924
943
|
showErrorDiv(error);
|
|
925
|
-
console.log(
|
|
944
|
+
console.log(`ā FAIL: Only min filled`);
|
|
926
945
|
disableNextButton();
|
|
927
946
|
return { valid: false, error };
|
|
928
947
|
}
|
|
@@ -930,7 +949,7 @@ function validateMinMax(field, customConfig) {
|
|
|
930
949
|
if (!minFilled && maxFilled) {
|
|
931
950
|
const error = config.customRangeErrors.minRequired;
|
|
932
951
|
showErrorDiv(error);
|
|
933
|
-
console.log(
|
|
952
|
+
console.log(`ā FAIL: Only max filled`);
|
|
934
953
|
disableNextButton();
|
|
935
954
|
return { valid: false, error };
|
|
936
955
|
}
|
|
@@ -938,9 +957,9 @@ function validateMinMax(field, customConfig) {
|
|
|
938
957
|
// 2. Check if both are empty
|
|
939
958
|
if (!minFilled && !maxFilled) {
|
|
940
959
|
hideErrorDiv();
|
|
941
|
-
// Clear data when both empty
|
|
942
960
|
delete chatState.data[field];
|
|
943
961
|
chatState.currentSelection = null;
|
|
962
|
+
console.log(`ā¹ļø Both empty - waiting for input`);
|
|
944
963
|
disableNextButton();
|
|
945
964
|
return { valid: false, error: null };
|
|
946
965
|
}
|
|
@@ -949,37 +968,43 @@ function validateMinMax(field, customConfig) {
|
|
|
949
968
|
if (isNaN(minValue) || isNaN(maxValue)) {
|
|
950
969
|
const error = config.customRangeErrors.bothRequired;
|
|
951
970
|
showErrorDiv(error);
|
|
952
|
-
console.log(
|
|
971
|
+
console.log(`ā FAIL: Invalid numbers (min: ${minValue}, max: ${maxValue})`);
|
|
953
972
|
disableNextButton();
|
|
954
973
|
return { valid: false, error };
|
|
955
974
|
}
|
|
956
975
|
|
|
957
976
|
// 4. Check min constraint
|
|
977
|
+
console.log(`š Checking: ${minValue} < ${minConstraint}?`);
|
|
958
978
|
if (minValue < minConstraint) {
|
|
959
979
|
const error = config.customRangeErrors.minBelowConstraint.replace('{min}', minConstraint);
|
|
960
980
|
showErrorDiv(error);
|
|
961
|
-
console.log(
|
|
981
|
+
console.log(`ā FAIL: Min (${minValue}) < constraint (${minConstraint})`);
|
|
962
982
|
disableNextButton();
|
|
963
983
|
return { valid: false, error };
|
|
964
984
|
}
|
|
985
|
+
console.log(`ā
PASS: Min (${minValue}) >= constraint (${minConstraint})`);
|
|
965
986
|
|
|
966
987
|
// 5. Check max constraint
|
|
988
|
+
console.log(`š Checking: ${maxValue} > ${maxConstraint}?`);
|
|
967
989
|
if (maxValue > maxConstraint) {
|
|
968
990
|
const error = config.customRangeErrors.maxAboveConstraint.replace('{max}', maxConstraint);
|
|
969
991
|
showErrorDiv(error);
|
|
970
|
-
console.log(
|
|
992
|
+
console.log(`ā FAIL: Max (${maxValue}) > constraint (${maxConstraint})`);
|
|
971
993
|
disableNextButton();
|
|
972
994
|
return { valid: false, error };
|
|
973
995
|
}
|
|
996
|
+
console.log(`ā
PASS: Max (${maxValue}) <= constraint (${maxConstraint})`);
|
|
974
997
|
|
|
975
998
|
// 6. Check min < max
|
|
999
|
+
console.log(`š Checking: ${minValue} >= ${maxValue}?`);
|
|
976
1000
|
if (minValue >= maxValue) {
|
|
977
1001
|
const error = config.customRangeErrors.minGreaterThanMax;
|
|
978
1002
|
showErrorDiv(error);
|
|
979
|
-
console.log(
|
|
1003
|
+
console.log(`ā FAIL: Min (${minValue}) >= Max (${maxValue})`);
|
|
980
1004
|
disableNextButton();
|
|
981
1005
|
return { valid: false, error };
|
|
982
1006
|
}
|
|
1007
|
+
console.log(`ā
PASS: Min (${minValue}) < Max (${maxValue})`);
|
|
983
1008
|
|
|
984
1009
|
// All valid! Hide error and save data as array
|
|
985
1010
|
hideErrorDiv();
|
|
@@ -992,7 +1017,11 @@ function validateMinMax(field, customConfig) {
|
|
|
992
1017
|
name: `${minValue}-${maxValue}`
|
|
993
1018
|
};
|
|
994
1019
|
|
|
995
|
-
console.log(
|
|
1020
|
+
console.log(`ā
ā
ā
ALL VALIDATION PASSED!`);
|
|
1021
|
+
console.log(`š¾ Data saved: chatState.data.${field} = [${minValue}, ${maxValue}]`);
|
|
1022
|
+
console.log(`š¾ Current selection: ${minValue}-${maxValue}`);
|
|
1023
|
+
console.log(`š¢ Next button: ENABLED\n`);
|
|
1024
|
+
|
|
996
1025
|
enableNextButton();
|
|
997
1026
|
return { valid: true, error: null };
|
|
998
1027
|
}
|
|
@@ -1215,14 +1244,24 @@ async function handleNext() {
|
|
|
1215
1244
|
const field = currentStep.input.field;
|
|
1216
1245
|
const customConfig = currentStep.input.custom;
|
|
1217
1246
|
|
|
1247
|
+
console.log(`\nšÆ === HANDLE NEXT: Checking single-select-custom validation ===`);
|
|
1248
|
+
console.log(`Field: ${field}`);
|
|
1249
|
+
console.log(`Custom config:`, customConfig);
|
|
1250
|
+
|
|
1218
1251
|
// Check if custom range was selected (data is array)
|
|
1219
1252
|
const selectedValue = chatState.data[field];
|
|
1220
1253
|
const isCustomRange = Array.isArray(selectedValue);
|
|
1221
1254
|
|
|
1255
|
+
console.log(`Selected value:`, selectedValue);
|
|
1256
|
+
console.log(`Is custom range (array)? ${isCustomRange}`);
|
|
1257
|
+
|
|
1222
1258
|
if (isCustomRange && customConfig) {
|
|
1223
1259
|
// Validate the custom range one more time before proceeding
|
|
1260
|
+
console.log(`š Running final validation before proceeding...`);
|
|
1224
1261
|
const validation = validateMinMax(field, customConfig);
|
|
1225
1262
|
|
|
1263
|
+
console.log(`Validation result:`, validation);
|
|
1264
|
+
|
|
1226
1265
|
if (!validation.valid) {
|
|
1227
1266
|
// If there's an error message, show it
|
|
1228
1267
|
if (validation.error) {
|
|
@@ -1251,6 +1290,8 @@ async function handleNext() {
|
|
|
1251
1290
|
|
|
1252
1291
|
return; // Stop here, don't proceed
|
|
1253
1292
|
}
|
|
1293
|
+
|
|
1294
|
+
console.log('ā
Validation passed, proceeding to next step');
|
|
1254
1295
|
} else if (customConfig && chatState.currentSelection && chatState.currentSelection.value === customConfig.value) {
|
|
1255
1296
|
// User selected the custom option but hasn't entered valid min/max yet
|
|
1256
1297
|
console.log(' ā ļø Custom option selected but no valid range entered');
|