lisichatbot 1.0.1 → 1.0.2

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 +20 -24
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisichatbot",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
package/src/index.js CHANGED
@@ -388,11 +388,13 @@ function handleCompletion() {
388
388
  // INITIALIZATION
389
389
  // =============================================================================
390
390
 
391
- function init(containerId, flowConfig) {
392
- // Get container
393
- elements.container = document.getElementById(containerId);
391
+ function init(flowName, flowConfig) {
392
+ // Find container by data-chat-element="chat-wrapper"
393
+ elements.container = document.querySelector('[data-chat-element="chat-wrapper"]');
394
+
394
395
  if (!elements.container) {
395
- console.error('Container not found:', containerId);
396
+ console.error('Container with data-chat-element="chat-wrapper" not found');
397
+ console.error('Please add <div data-chat-element="chat-wrapper"></div> to your HTML');
396
398
  return null;
397
399
  }
398
400
 
@@ -410,28 +412,21 @@ function init(containerId, flowConfig) {
410
412
  chatState.history = [];
411
413
  chatState.currentSelection = null;
412
414
 
413
- // Create UI with data-chat-element attributes
415
+ // Clear existing content and create structure
414
416
  elements.container.innerHTML = `
415
- <div class="cf-wrapper" data-chat-element="chat-wrapper">
416
- <div class="cf-messages"
417
- id="cfMessages"
418
- data-chat-element="messages-container"></div>
419
- <div class="cf-bottom"
420
- data-chat-element="navigation-bottom">
421
- <button id="cfNextBtn"
422
- class="cf-next-btn"
423
- data-chat-element="next-button"
424
- style="opacity: 0.5; cursor: not-allowed;"
425
- disabled>
426
- Next →
427
- </button>
428
- </div>
417
+ <div data-chat-element="messages-container"></div>
418
+ <div data-chat-element="navigation-bottom">
419
+ <button data-chat-element="next-button"
420
+ style="opacity: 0.5; cursor: not-allowed;"
421
+ disabled>
422
+ Next →
423
+ </button>
429
424
  </div>
430
425
  `;
431
426
 
432
- // Get elements
433
- elements.messages = document.getElementById('cfMessages');
434
- elements.nextBtn = document.getElementById('cfNextBtn');
427
+ // Get elements by data-chat-element
428
+ elements.messages = elements.container.querySelector('[data-chat-element="messages-container"]');
429
+ elements.nextBtn = elements.container.querySelector('[data-chat-element="next-button"]');
435
430
 
436
431
  // Add event listener
437
432
  if (elements.nextBtn) {
@@ -446,12 +441,13 @@ function init(containerId, flowConfig) {
446
441
  // Start
447
442
  showNextStep();
448
443
 
449
- console.log('✅ Conversational Flow Builder initialized with custom attributes');
444
+ console.log(`✅ Flow "${flowName}" initialized`);
450
445
 
451
446
  return {
452
447
  getState,
453
448
  reset,
454
- goToStep
449
+ goToStep,
450
+ editStep
455
451
  };
456
452
  }
457
453