lisichatbot 1.9.9 → 2.0.1
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 +33 -5
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -35,6 +35,7 @@ let config = {
|
|
|
35
35
|
autoAdvanceDelay: 2000,
|
|
36
36
|
enableAnimations: true,
|
|
37
37
|
showCancelButton: false, // ✅ NEW: Control cancel button visibility
|
|
38
|
+
nextButtonText: null, // ✅ NEW: Global next button text (null = use original)
|
|
38
39
|
customRangeErrors: {
|
|
39
40
|
minRequired: 'Minimum value is required',
|
|
40
41
|
maxRequired: 'Maximum value is required',
|
|
@@ -283,6 +284,7 @@ function renderMultiSelectDropdown(options, field) {
|
|
|
283
284
|
const optionTemplate = clone.querySelector('[data-chat-input-element="dropdown-option-wrapper"]');
|
|
284
285
|
const tagsContainer = clone.querySelector('[data-chat-input-element="tags-container"]');
|
|
285
286
|
const tagTemplate = clone.querySelector('[data-chat-input-element="tag-wrapper"]');
|
|
287
|
+
const dropdownInput = clone.querySelector('[data-chat-input-element="dropdown-input"]'); // ✅ NEW
|
|
286
288
|
|
|
287
289
|
if (!dropdown || !optionsWrapper || !searchBar || !optionsContainer || !optionTemplate || !tagsContainer || !tagTemplate) {
|
|
288
290
|
console.error('Multi-select dropdown: Missing required elements');
|
|
@@ -293,7 +295,8 @@ function renderMultiSelectDropdown(options, field) {
|
|
|
293
295
|
optionsContainer: !!optionsContainer,
|
|
294
296
|
optionTemplate: !!optionTemplate,
|
|
295
297
|
tagsContainer: !!tagsContainer,
|
|
296
|
-
tagTemplate: !!tagTemplate
|
|
298
|
+
tagTemplate: !!tagTemplate,
|
|
299
|
+
dropdownInput: !!dropdownInput // ✅ NEW
|
|
297
300
|
});
|
|
298
301
|
return;
|
|
299
302
|
}
|
|
@@ -316,6 +319,17 @@ function renderMultiSelectDropdown(options, field) {
|
|
|
316
319
|
const existingData = disablePrefill ? [] : (chatState.data[field] || []);
|
|
317
320
|
const selectedValues = new Set(existingData);
|
|
318
321
|
|
|
322
|
+
// ✅ NEW: Set initial dropdown-input visibility based on pre-filled data
|
|
323
|
+
if (dropdownInput) {
|
|
324
|
+
if (existingData.length > 0) {
|
|
325
|
+
dropdownInput.style.display = 'none';
|
|
326
|
+
console.log(` 🙈 Dropdown input hidden initially (${existingData.length} pre-filled selection${existingData.length === 1 ? '' : 's'})`);
|
|
327
|
+
} else {
|
|
328
|
+
dropdownInput.style.display = '';
|
|
329
|
+
console.log(` 👁️ Dropdown input visible initially (no pre-filled selections)`);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
319
333
|
if (disablePrefill) {
|
|
320
334
|
console.log(`⏭️ Pre-fill disabled for ${field} - starting fresh`);
|
|
321
335
|
} else {
|
|
@@ -537,11 +551,25 @@ function renderMultiSelectDropdown(options, field) {
|
|
|
537
551
|
enableNextButton();
|
|
538
552
|
}
|
|
539
553
|
}
|
|
554
|
+
|
|
555
|
+
// ✅ NEW: Re-render tags to update dropdown-input visibility
|
|
556
|
+
renderTags(field, options, tagsContainer, tagTemplate, optionsContainer);
|
|
540
557
|
};
|
|
541
558
|
}
|
|
542
559
|
|
|
543
560
|
tagsContainer.appendChild(tagEl);
|
|
544
561
|
});
|
|
562
|
+
|
|
563
|
+
// ✅ NEW: Show/hide dropdown-input based on tag count
|
|
564
|
+
if (dropdownInput) {
|
|
565
|
+
if (selections.length > 0) {
|
|
566
|
+
dropdownInput.style.display = 'none';
|
|
567
|
+
console.log(` 🙈 Dropdown input hidden (${selections.length} tag${selections.length === 1 ? '' : 's'} displayed)`);
|
|
568
|
+
} else {
|
|
569
|
+
dropdownInput.style.display = '';
|
|
570
|
+
console.log(` 👁️ Dropdown input visible (no tags)`);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
545
573
|
}
|
|
546
574
|
|
|
547
575
|
// ✅ Initial tag render if pre-filled (edit mode)
|
|
@@ -3189,9 +3217,9 @@ async function showNextStep() {
|
|
|
3189
3217
|
// Step-level override takes highest priority
|
|
3190
3218
|
buttonText = nextStep.nextButtonText;
|
|
3191
3219
|
console.log(` 📝 Next button text: "${buttonText}" (step-level)`);
|
|
3192
|
-
} else if (
|
|
3220
|
+
} else if (config.nextButtonText) {
|
|
3193
3221
|
// Global config nextButtonText
|
|
3194
|
-
buttonText =
|
|
3222
|
+
buttonText = config.nextButtonText;
|
|
3195
3223
|
console.log(` 📝 Next button text: "${buttonText}" (global config)`);
|
|
3196
3224
|
} else {
|
|
3197
3225
|
// Fall back to original
|
|
@@ -3200,7 +3228,7 @@ async function showNextStep() {
|
|
|
3200
3228
|
}
|
|
3201
3229
|
|
|
3202
3230
|
nextBtnTextElement.textContent = buttonText;
|
|
3203
|
-
} else if (nextStep.nextButtonText ||
|
|
3231
|
+
} else if (nextStep.nextButtonText || config.nextButtonText) {
|
|
3204
3232
|
console.warn(` ⚠️ nextButtonText specified but next-button-text element not found`);
|
|
3205
3233
|
console.warn(' Add <span data-chat-element="next-button-text">Next</span> inside your next-button');
|
|
3206
3234
|
}
|
|
@@ -3322,7 +3350,7 @@ function init(flowName, flowConfig, options = {}) {
|
|
|
3322
3350
|
selectedBackground: config.selectedBackground,
|
|
3323
3351
|
autoAdvanceDelay: config.autoAdvanceDelay,
|
|
3324
3352
|
showCancelButton: config.showCancelButton,
|
|
3325
|
-
nextButtonText:
|
|
3353
|
+
nextButtonText: config.nextButtonText || 'not set',
|
|
3326
3354
|
customRangeErrors: config.customRangeErrors
|
|
3327
3355
|
});
|
|
3328
3356
|
|