lisichatbot 1.3.2 ā 1.3.3
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 +30 -17
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -922,6 +922,9 @@ function handleCustomSelectClick(element, field, customConfig) {
|
|
|
922
922
|
function validateMinMax(field, customConfig) {
|
|
923
923
|
console.log(`\nš === VALIDATING MIN/MAX for field: ${field} ===`);
|
|
924
924
|
|
|
925
|
+
// Always use global config errors
|
|
926
|
+
const errors = config.customRangeErrors;
|
|
927
|
+
|
|
925
928
|
// Fixed selectors - input has all attributes on it directly
|
|
926
929
|
const minInput = document.querySelector(`[data-field="${field}"][data-input-type="min"][data-chat-input-element="input"]`);
|
|
927
930
|
const maxInput = document.querySelector(`[data-field="${field}"][data-input-type="max"][data-chat-input-element="input"]`);
|
|
@@ -976,7 +979,7 @@ function validateMinMax(field, customConfig) {
|
|
|
976
979
|
|
|
977
980
|
// 1. Check if only one is filled
|
|
978
981
|
if (minFilled && !maxFilled) {
|
|
979
|
-
const error =
|
|
982
|
+
const error = errors.maxRequired;
|
|
980
983
|
showErrorDiv(error);
|
|
981
984
|
console.log(`ā FAIL: Only min filled`);
|
|
982
985
|
disableNextButton();
|
|
@@ -984,7 +987,7 @@ function validateMinMax(field, customConfig) {
|
|
|
984
987
|
}
|
|
985
988
|
|
|
986
989
|
if (!minFilled && maxFilled) {
|
|
987
|
-
const error =
|
|
990
|
+
const error = errors.minRequired;
|
|
988
991
|
showErrorDiv(error);
|
|
989
992
|
console.log(`ā FAIL: Only max filled`);
|
|
990
993
|
disableNextButton();
|
|
@@ -1003,7 +1006,7 @@ function validateMinMax(field, customConfig) {
|
|
|
1003
1006
|
|
|
1004
1007
|
// 3. Check if values are valid numbers
|
|
1005
1008
|
if (isNaN(minValue) || isNaN(maxValue)) {
|
|
1006
|
-
const error =
|
|
1009
|
+
const error = errors.bothRequired;
|
|
1007
1010
|
showErrorDiv(error);
|
|
1008
1011
|
console.log(`ā FAIL: Invalid numbers (min: ${minValue}, max: ${maxValue})`);
|
|
1009
1012
|
disableNextButton();
|
|
@@ -1013,7 +1016,7 @@ function validateMinMax(field, customConfig) {
|
|
|
1013
1016
|
// 4. Check min constraint
|
|
1014
1017
|
console.log(`š Checking: ${minValue} < ${minConstraint}?`);
|
|
1015
1018
|
if (minValue < minConstraint) {
|
|
1016
|
-
const error =
|
|
1019
|
+
const error = errors.minBelowConstraint.replace('{min}', minConstraint);
|
|
1017
1020
|
showErrorDiv(error);
|
|
1018
1021
|
console.log(`ā FAIL: Min (${minValue}) < constraint (${minConstraint})`);
|
|
1019
1022
|
disableNextButton();
|
|
@@ -1024,7 +1027,7 @@ function validateMinMax(field, customConfig) {
|
|
|
1024
1027
|
// 5. Check max constraint
|
|
1025
1028
|
console.log(`š Checking: ${maxValue} > ${maxConstraint}?`);
|
|
1026
1029
|
if (maxValue > maxConstraint) {
|
|
1027
|
-
const error =
|
|
1030
|
+
const error = errors.maxAboveConstraint.replace('{max}', maxConstraint);
|
|
1028
1031
|
showErrorDiv(error);
|
|
1029
1032
|
console.log(`ā FAIL: Max (${maxValue}) > constraint (${maxConstraint})`);
|
|
1030
1033
|
disableNextButton();
|
|
@@ -1035,7 +1038,7 @@ function validateMinMax(field, customConfig) {
|
|
|
1035
1038
|
// 6. Check min < max
|
|
1036
1039
|
console.log(`š Checking: ${minValue} >= ${maxValue}?`);
|
|
1037
1040
|
if (minValue >= maxValue) {
|
|
1038
|
-
const error =
|
|
1041
|
+
const error = errors.minGreaterThanMax;
|
|
1039
1042
|
showErrorDiv(error);
|
|
1040
1043
|
console.log(`ā FAIL: Min (${minValue}) >= Max (${maxValue})`);
|
|
1041
1044
|
disableNextButton();
|
|
@@ -1380,6 +1383,7 @@ async function handleNext() {
|
|
|
1380
1383
|
if (isCustomRange && customConfig) {
|
|
1381
1384
|
// Validate the custom range one more time before proceeding
|
|
1382
1385
|
console.log(`š Running final validation before proceeding...`);
|
|
1386
|
+
|
|
1383
1387
|
const validation = validateMinMax(field, customConfig);
|
|
1384
1388
|
|
|
1385
1389
|
console.log(`Validation result:`, validation);
|
|
@@ -1690,7 +1694,7 @@ function handleCompletion() {
|
|
|
1690
1694
|
// INITIALIZATION
|
|
1691
1695
|
// =============================================================================
|
|
1692
1696
|
|
|
1693
|
-
function init(flowName, flowConfig) {
|
|
1697
|
+
function init(flowName, flowConfig, options = {}) {
|
|
1694
1698
|
// Find container by data-chat-element="chat-wrapper"
|
|
1695
1699
|
elements.container = document.querySelector('[data-chat-element="chat-wrapper"]');
|
|
1696
1700
|
|
|
@@ -1705,10 +1709,24 @@ function init(flowName, flowConfig) {
|
|
|
1705
1709
|
Object.assign(config, flowConfig.config);
|
|
1706
1710
|
}
|
|
1707
1711
|
|
|
1712
|
+
// Merge customRangeErrors - priority: options param > flow object > defaults
|
|
1713
|
+
// 1. First, try flow object customRangeErrors
|
|
1714
|
+
if (flowConfig.customRangeErrors) {
|
|
1715
|
+
console.log('ā
Using custom range errors from flow object');
|
|
1716
|
+
Object.assign(config.customRangeErrors, flowConfig.customRangeErrors);
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
// 2. Then, options parameter (overrides flow object if both provided)
|
|
1720
|
+
if (options.customRangeErrors) {
|
|
1721
|
+
console.log('ā
Using custom range errors from options parameter');
|
|
1722
|
+
Object.assign(config.customRangeErrors, options.customRangeErrors);
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1708
1725
|
console.log('ā
Flow initialized:', {
|
|
1709
1726
|
flowName,
|
|
1710
1727
|
selectedBackground: config.selectedBackground,
|
|
1711
|
-
autoAdvanceDelay: config.autoAdvanceDelay
|
|
1728
|
+
autoAdvanceDelay: config.autoAdvanceDelay,
|
|
1729
|
+
customRangeErrors: config.customRangeErrors
|
|
1712
1730
|
});
|
|
1713
1731
|
|
|
1714
1732
|
// Store flow data
|
|
@@ -1835,15 +1853,10 @@ function editStep(stepNumber) {
|
|
|
1835
1853
|
// Clear history from this step forward
|
|
1836
1854
|
chatState.history = chatState.history.filter(h => h.step < stepNumber);
|
|
1837
1855
|
|
|
1838
|
-
console.log(`
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
if (step.input && step.input.field) {
|
|
1843
|
-
console.log(` Deleting field: ${step.input.field}`);
|
|
1844
|
-
delete chatState.data[step.input.field];
|
|
1845
|
-
}
|
|
1846
|
-
});
|
|
1856
|
+
console.log(` ā
Keeping ALL data intact for editing (no data deleted)`);
|
|
1857
|
+
console.log(` Current data:`, chatState.data);
|
|
1858
|
+
// Don't delete any data - keep everything for pre-filling
|
|
1859
|
+
// Data will be replaced when user submits the edited step
|
|
1847
1860
|
|
|
1848
1861
|
console.log(` Calling goToStep(${stepNumber})...`);
|
|
1849
1862
|
// Go to that step
|