lisichatbot 1.4.7 ā 1.4.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.
- package/package.json +1 -1
- package/src/index.js +68 -53
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -279,6 +279,10 @@ function renderMultiSelectDropdown(options, field) {
|
|
|
279
279
|
optionTemplate.remove();
|
|
280
280
|
tagTemplate.remove();
|
|
281
281
|
|
|
282
|
+
// ā
NEW: Hide dropdown options wrapper initially
|
|
283
|
+
optionsWrapper.style.display = 'none';
|
|
284
|
+
console.log(' š Dropdown options wrapper hidden initially');
|
|
285
|
+
|
|
282
286
|
// ā
Get existing data for pre-filling (edit mode)
|
|
283
287
|
const existingData = chatState.data[field] || [];
|
|
284
288
|
const selectedValues = new Set(existingData);
|
|
@@ -1890,77 +1894,88 @@ async function handleNext() {
|
|
|
1890
1894
|
const targetStep = chatState.returnToStep;
|
|
1891
1895
|
console.log(`\nš Returning to saved step ${targetStep} (edited step complete)`);
|
|
1892
1896
|
|
|
1893
|
-
// ā
|
|
1894
|
-
const
|
|
1895
|
-
const editedStepField = flowData.flow[currentStepIndex]?.input?.field;
|
|
1896
|
-
|
|
1897
|
-
console.log(` š Checking for dependent steps between ${currentStepIndex} and ${targetStep}`);
|
|
1897
|
+
// ā
Check if we should continue to next step or jump back
|
|
1898
|
+
const nextStep = chatState.step + 1;
|
|
1898
1899
|
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
const step = flowData.flow[i];
|
|
1900
|
+
if (nextStep < targetStep) {
|
|
1901
|
+
// There are steps between current and target
|
|
1902
|
+
const currentStepIndex = chatState.step;
|
|
1903
|
+
const editedStepField = flowData.flow[currentStepIndex]?.input?.field;
|
|
1904
1904
|
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1905
|
+
console.log(` š Checking if step ${nextStep} should be shown (between ${currentStepIndex} and ${targetStep})`);
|
|
1906
|
+
|
|
1907
|
+
// Check if the next step depends on the edited field
|
|
1908
|
+
const nextStepConfig = flowData.flow[nextStep];
|
|
1909
|
+
if (nextStepConfig && nextStepConfig.dependsOn) {
|
|
1910
|
+
const dependencies = Array.isArray(nextStepConfig.dependsOn) ? nextStepConfig.dependsOn : [nextStepConfig.dependsOn];
|
|
1908
1911
|
|
|
1909
1912
|
if (dependencies.includes(editedStepField)) {
|
|
1910
|
-
console.log(` š
|
|
1913
|
+
console.log(` š Step ${nextStep} depends on ${editedStepField} - checking shouldDisplay`);
|
|
1911
1914
|
|
|
1912
|
-
// Check
|
|
1913
|
-
if
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
if (typeof
|
|
1915
|
+
// Check shouldDisplay
|
|
1916
|
+
let shouldShow = true; // Default to true if no shouldDisplay
|
|
1917
|
+
|
|
1918
|
+
if (nextStepConfig.shouldDisplay) {
|
|
1919
|
+
if (typeof nextStepConfig.shouldDisplay === 'function') {
|
|
1917
1920
|
try {
|
|
1918
|
-
shouldShow = await
|
|
1919
|
-
console.log(` š Step ${
|
|
1921
|
+
shouldShow = await nextStepConfig.shouldDisplay(chatState.data);
|
|
1922
|
+
console.log(` š Step ${nextStep} shouldDisplay: ${shouldShow}`);
|
|
1920
1923
|
} catch (error) {
|
|
1921
|
-
console.error(`Error in shouldDisplay for step ${
|
|
1924
|
+
console.error(`Error in shouldDisplay for step ${nextStep}:`, error);
|
|
1925
|
+
shouldShow = false;
|
|
1922
1926
|
}
|
|
1923
|
-
} else if (typeof
|
|
1924
|
-
shouldShow =
|
|
1927
|
+
} else if (typeof nextStepConfig.shouldDisplay === 'boolean') {
|
|
1928
|
+
shouldShow = nextStepConfig.shouldDisplay;
|
|
1925
1929
|
}
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
if (shouldShow) {
|
|
1933
|
+
// Show this dependent step, keep returnToStep for later
|
|
1934
|
+
console.log(` ā
Step ${nextStep} should be shown - continuing to it (returnToStep=${targetStep} preserved)`);
|
|
1935
|
+
chatState.step = nextStep;
|
|
1926
1936
|
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1937
|
+
const allRangeWrappers = document.querySelectorAll('[data-chat-element="range-wrapper"]');
|
|
1938
|
+
allRangeWrappers.forEach(wrapper => {
|
|
1939
|
+
wrapper.style.display = 'none';
|
|
1940
|
+
});
|
|
1941
|
+
|
|
1942
|
+
updateEditIcons();
|
|
1943
|
+
await showNextStep();
|
|
1944
|
+
return;
|
|
1934
1945
|
} else {
|
|
1935
|
-
|
|
1936
|
-
console.log(` ā
Step ${i} has no shouldDisplay - showing it`);
|
|
1937
|
-
nextStepToShow = i;
|
|
1938
|
-
break;
|
|
1946
|
+
console.log(` āļø Step ${nextStep} shouldDisplay returned false - will check next step`);
|
|
1939
1947
|
}
|
|
1940
1948
|
}
|
|
1941
1949
|
}
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1950
|
+
|
|
1951
|
+
// Next step doesn't depend on edited field or shouldn't be shown
|
|
1952
|
+
// Continue to next step normally (it will check shouldDisplay in showNextStep)
|
|
1953
|
+
console.log(` ā”ļø Continuing to next step ${nextStep} (normal flow)`);
|
|
1954
|
+
chatState.step = nextStep;
|
|
1955
|
+
|
|
1956
|
+
const allRangeWrappers = document.querySelectorAll('[data-chat-element="range-wrapper"]');
|
|
1957
|
+
allRangeWrappers.forEach(wrapper => {
|
|
1958
|
+
wrapper.style.display = 'none';
|
|
1959
|
+
});
|
|
1960
|
+
|
|
1961
|
+
updateEditIcons();
|
|
1962
|
+
await showNextStep();
|
|
1963
|
+
return;
|
|
1948
1964
|
} else {
|
|
1949
|
-
//
|
|
1950
|
-
console.log(` āļø
|
|
1965
|
+
// Reached or passed target, clear returnToStep and go to target
|
|
1966
|
+
console.log(` āļø Reached target, returning to step ${targetStep}`);
|
|
1951
1967
|
chatState.returnToStep = null;
|
|
1952
1968
|
chatState.step = targetStep;
|
|
1969
|
+
|
|
1970
|
+
const allRangeWrappers = document.querySelectorAll('[data-chat-element="range-wrapper"]');
|
|
1971
|
+
allRangeWrappers.forEach(wrapper => {
|
|
1972
|
+
wrapper.style.display = 'none';
|
|
1973
|
+
});
|
|
1974
|
+
|
|
1975
|
+
updateEditIcons();
|
|
1976
|
+
await showNextStep();
|
|
1977
|
+
return;
|
|
1953
1978
|
}
|
|
1954
|
-
|
|
1955
|
-
const allRangeWrappers = document.querySelectorAll('[data-chat-element="range-wrapper"]');
|
|
1956
|
-
allRangeWrappers.forEach(wrapper => {
|
|
1957
|
-
wrapper.style.display = 'none';
|
|
1958
|
-
});
|
|
1959
|
-
console.log(' š Hidden all range-wrappers');
|
|
1960
|
-
|
|
1961
|
-
updateEditIcons();
|
|
1962
|
-
await showNextStep();
|
|
1963
|
-
return;
|
|
1964
1979
|
}
|
|
1965
1980
|
|
|
1966
1981
|
chatState.step++;
|