lisichatbot 1.2.7 → 1.2.9

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 +63 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisichatbot",
3
- "version": "1.2.7",
3
+ "version": "1.2.9",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
package/src/index.js CHANGED
@@ -671,11 +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'; // Horizontal gap
680
+ minClone.style.marginBottom = '12px'; // Bottom margin if wraps
681
+ minClone.style.width = 'auto'; // Don't stretch
682
+ minClone.style.flex = 'none'; // Don't grow or shrink
679
683
  minClone.setAttribute('data-field', field);
680
684
 
681
685
  const minInput = minClone.querySelector('[data-chat-input-element="input"]');
@@ -696,6 +700,9 @@ function renderMinMaxInputs(field, customConfig, existingData) {
696
700
  // Clone and setup max input
697
701
  const maxClone = maxTemplate.cloneNode(true);
698
702
  maxClone.style.display = '';
703
+ maxClone.style.marginBottom = '12px'; // Bottom margin if wraps
704
+ maxClone.style.width = 'auto'; // Don't stretch
705
+ maxClone.style.flex = 'none'; // Don't grow or shrink
699
706
  maxClone.setAttribute('data-field', field);
700
707
 
701
708
  const maxInput = maxClone.querySelector('[data-chat-input-element="input"]');
@@ -796,7 +803,7 @@ function selectCustomOption(field) {
796
803
  // Show min/max inputs
797
804
  const rangeWrapper = document.querySelector(`[data-chat-element="range-wrapper"][data-field="${field}"]`);
798
805
  if (rangeWrapper) {
799
- rangeWrapper.style.display = '';
806
+ rangeWrapper.style.display = 'flex'; // Keep flex!
800
807
  }
801
808
  }
802
809
 
@@ -826,7 +833,7 @@ function handleCustomSelectClick(element, field, customConfig) {
826
833
  // Show min/max inputs
827
834
  const rangeWrapper = document.querySelector(`[data-chat-element="range-wrapper"][data-field="${field}"]`);
828
835
  if (rangeWrapper) {
829
- rangeWrapper.style.display = '';
836
+ rangeWrapper.style.display = 'flex'; // Keep flex!
830
837
  }
831
838
 
832
839
  // Don't save data yet - wait for validation
@@ -884,11 +891,22 @@ function handleCustomSelectClick(element, field, customConfig) {
884
891
  }
885
892
 
886
893
  function validateMinMax(field, customConfig) {
887
- const minInput = document.querySelector(`[data-field="${field}"][data-input-type="min"] [data-chat-input-element="input"]`);
888
- const maxInput = document.querySelector(`[data-field="${field}"][data-input-type="max"] [data-chat-input-element="input"]`);
894
+ console.log(`\nšŸ” === VALIDATING MIN/MAX for field: ${field} ===`);
895
+
896
+ // Fixed selectors - input has all attributes on it directly
897
+ const minInput = document.querySelector(`[data-field="${field}"][data-input-type="min"][data-chat-input-element="input"]`);
898
+ const maxInput = document.querySelector(`[data-field="${field}"][data-input-type="max"][data-chat-input-element="input"]`);
889
899
  const errorDiv = document.querySelector(`[data-chat-element="range-error"][data-field="${field}"]`);
890
900
 
891
- if (!minInput || !maxInput) return { valid: false, error: null };
901
+ if (!minInput || !maxInput) {
902
+ console.log('āŒ Min or Max input not found');
903
+ console.log(' Tried selectors:');
904
+ console.log(` Min: [data-field="${field}"][data-input-type="min"][data-chat-input-element="input"]`);
905
+ console.log(` Max: [data-field="${field}"][data-input-type="max"][data-chat-input-element="input"]`);
906
+ console.log(' Found min:', minInput);
907
+ console.log(' Found max:', maxInput);
908
+ return { valid: false, error: null };
909
+ }
892
910
 
893
911
  const minValue = parseFloat(minInput.value);
894
912
  const maxValue = parseFloat(maxInput.value);
@@ -898,6 +916,14 @@ function validateMinMax(field, customConfig) {
898
916
  const minConstraint = customConfig.min !== undefined ? customConfig.min : 0;
899
917
  const maxConstraint = customConfig.max !== undefined ? customConfig.max : 100;
900
918
 
919
+ console.log(`šŸ“Š Input values:
920
+ Min input value: "${minInput.value}" (filled: ${minFilled}, parsed: ${minValue})
921
+ Max input value: "${maxInput.value}" (filled: ${maxFilled}, parsed: ${maxValue})`);
922
+
923
+ console.log(`šŸ“ Constraints:
924
+ Min constraint: >= ${minConstraint}
925
+ Max constraint: <= ${maxConstraint}`);
926
+
901
927
  // Helper to show error in div and clear data
902
928
  const showErrorDiv = (message) => {
903
929
  if (errorDiv) {
@@ -907,6 +933,7 @@ function validateMinMax(field, customConfig) {
907
933
  // Clear the data when validation fails
908
934
  delete chatState.data[field];
909
935
  chatState.currentSelection = null;
936
+ console.log(`šŸ—‘ļø Data cleared for field: ${field}`);
910
937
  };
911
938
 
912
939
  // Helper to hide error div
@@ -922,7 +949,7 @@ function validateMinMax(field, customConfig) {
922
949
  if (minFilled && !maxFilled) {
923
950
  const error = config.customRangeErrors.maxRequired;
924
951
  showErrorDiv(error);
925
- console.log(' āŒ Validation error:', error);
952
+ console.log(`āŒ FAIL: Only min filled`);
926
953
  disableNextButton();
927
954
  return { valid: false, error };
928
955
  }
@@ -930,7 +957,7 @@ function validateMinMax(field, customConfig) {
930
957
  if (!minFilled && maxFilled) {
931
958
  const error = config.customRangeErrors.minRequired;
932
959
  showErrorDiv(error);
933
- console.log(' āŒ Validation error:', error);
960
+ console.log(`āŒ FAIL: Only max filled`);
934
961
  disableNextButton();
935
962
  return { valid: false, error };
936
963
  }
@@ -938,9 +965,9 @@ function validateMinMax(field, customConfig) {
938
965
  // 2. Check if both are empty
939
966
  if (!minFilled && !maxFilled) {
940
967
  hideErrorDiv();
941
- // Clear data when both empty
942
968
  delete chatState.data[field];
943
969
  chatState.currentSelection = null;
970
+ console.log(`ā„¹ļø Both empty - waiting for input`);
944
971
  disableNextButton();
945
972
  return { valid: false, error: null };
946
973
  }
@@ -949,37 +976,43 @@ function validateMinMax(field, customConfig) {
949
976
  if (isNaN(minValue) || isNaN(maxValue)) {
950
977
  const error = config.customRangeErrors.bothRequired;
951
978
  showErrorDiv(error);
952
- console.log(' āŒ Validation error:', error);
979
+ console.log(`āŒ FAIL: Invalid numbers (min: ${minValue}, max: ${maxValue})`);
953
980
  disableNextButton();
954
981
  return { valid: false, error };
955
982
  }
956
983
 
957
984
  // 4. Check min constraint
985
+ console.log(`šŸ” Checking: ${minValue} < ${minConstraint}?`);
958
986
  if (minValue < minConstraint) {
959
987
  const error = config.customRangeErrors.minBelowConstraint.replace('{min}', minConstraint);
960
988
  showErrorDiv(error);
961
- console.log(' āŒ Validation error:', error);
989
+ console.log(`āŒ FAIL: Min (${minValue}) < constraint (${minConstraint})`);
962
990
  disableNextButton();
963
991
  return { valid: false, error };
964
992
  }
993
+ console.log(`āœ… PASS: Min (${minValue}) >= constraint (${minConstraint})`);
965
994
 
966
995
  // 5. Check max constraint
996
+ console.log(`šŸ” Checking: ${maxValue} > ${maxConstraint}?`);
967
997
  if (maxValue > maxConstraint) {
968
998
  const error = config.customRangeErrors.maxAboveConstraint.replace('{max}', maxConstraint);
969
999
  showErrorDiv(error);
970
- console.log(' āŒ Validation error:', error);
1000
+ console.log(`āŒ FAIL: Max (${maxValue}) > constraint (${maxConstraint})`);
971
1001
  disableNextButton();
972
1002
  return { valid: false, error };
973
1003
  }
1004
+ console.log(`āœ… PASS: Max (${maxValue}) <= constraint (${maxConstraint})`);
974
1005
 
975
1006
  // 6. Check min < max
1007
+ console.log(`šŸ” Checking: ${minValue} >= ${maxValue}?`);
976
1008
  if (minValue >= maxValue) {
977
1009
  const error = config.customRangeErrors.minGreaterThanMax;
978
1010
  showErrorDiv(error);
979
- console.log(' āŒ Validation error:', error);
1011
+ console.log(`āŒ FAIL: Min (${minValue}) >= Max (${maxValue})`);
980
1012
  disableNextButton();
981
1013
  return { valid: false, error };
982
1014
  }
1015
+ console.log(`āœ… PASS: Min (${minValue}) < Max (${maxValue})`);
983
1016
 
984
1017
  // All valid! Hide error and save data as array
985
1018
  hideErrorDiv();
@@ -992,7 +1025,11 @@ function validateMinMax(field, customConfig) {
992
1025
  name: `${minValue}-${maxValue}`
993
1026
  };
994
1027
 
995
- console.log(' āœ… Range valid - stored as array:', [minValue, maxValue]);
1028
+ console.log(`āœ…āœ…āœ… ALL VALIDATION PASSED!`);
1029
+ console.log(`šŸ’¾ Data saved: chatState.data.${field} = [${minValue}, ${maxValue}]`);
1030
+ console.log(`šŸ’¾ Current selection: ${minValue}-${maxValue}`);
1031
+ console.log(`🟢 Next button: ENABLED\n`);
1032
+
996
1033
  enableNextButton();
997
1034
  return { valid: true, error: null };
998
1035
  }
@@ -1215,14 +1252,24 @@ async function handleNext() {
1215
1252
  const field = currentStep.input.field;
1216
1253
  const customConfig = currentStep.input.custom;
1217
1254
 
1255
+ console.log(`\nšŸŽÆ === HANDLE NEXT: Checking single-select-custom validation ===`);
1256
+ console.log(`Field: ${field}`);
1257
+ console.log(`Custom config:`, customConfig);
1258
+
1218
1259
  // Check if custom range was selected (data is array)
1219
1260
  const selectedValue = chatState.data[field];
1220
1261
  const isCustomRange = Array.isArray(selectedValue);
1221
1262
 
1263
+ console.log(`Selected value:`, selectedValue);
1264
+ console.log(`Is custom range (array)? ${isCustomRange}`);
1265
+
1222
1266
  if (isCustomRange && customConfig) {
1223
1267
  // Validate the custom range one more time before proceeding
1268
+ console.log(`šŸ”„ Running final validation before proceeding...`);
1224
1269
  const validation = validateMinMax(field, customConfig);
1225
1270
 
1271
+ console.log(`Validation result:`, validation);
1272
+
1226
1273
  if (!validation.valid) {
1227
1274
  // If there's an error message, show it
1228
1275
  if (validation.error) {
@@ -1251,6 +1298,8 @@ async function handleNext() {
1251
1298
 
1252
1299
  return; // Stop here, don't proceed
1253
1300
  }
1301
+
1302
+ console.log('āœ… Validation passed, proceeding to next step');
1254
1303
  } else if (customConfig && chatState.currentSelection && chatState.currentSelection.value === customConfig.value) {
1255
1304
  // User selected the custom option but hasn't entered valid min/max yet
1256
1305
  console.log(' āš ļø Custom option selected but no valid range entered');