@aakash58/chatbot 1.0.44 → 1.0.45

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.
@@ -587,14 +587,52 @@ class ThemeService {
587
587
  theme = this._theme.asReadonly();
588
588
  _activeTheme = signal('light-theme', ...(ngDevMode ? [{ debugName: "_activeTheme" }] : []));
589
589
  activeTheme = this._activeTheme.asReadonly();
590
+ themeObserver;
590
591
  constructor(rendererFactory, overlay) {
591
592
  this.overlay = overlay;
592
593
  this.renderer = rendererFactory.createRenderer(null, null);
593
- // Default to light theme
594
- this.setTheme('light');
594
+ // Detect theme from parent app
595
+ this.detectParentTheme();
596
+ // Watch for theme changes in parent app
597
+ this.watchParentTheme();
595
598
  }
596
599
  /**
597
- * Set theme from parent application
600
+ * Detect theme from parent app's body/html classes
601
+ */
602
+ detectParentTheme() {
603
+ const body = document.body;
604
+ const html = document.documentElement;
605
+ // Check for common theme class patterns
606
+ const isDark = body.classList.contains('dark') ||
607
+ body.classList.contains('dark-theme') ||
608
+ body.classList.contains('dark-mode') ||
609
+ html.classList.contains('dark') ||
610
+ html.classList.contains('dark-theme') ||
611
+ html.classList.contains('dark-mode') ||
612
+ body.getAttribute('data-theme') === 'dark' ||
613
+ html.getAttribute('data-theme') === 'dark';
614
+ const detectedTheme = isDark ? 'dark' : 'light';
615
+ this.setTheme(detectedTheme);
616
+ }
617
+ /**
618
+ * Watch for theme changes in parent app using MutationObserver
619
+ */
620
+ watchParentTheme() {
621
+ this.themeObserver = new MutationObserver(() => {
622
+ this.detectParentTheme();
623
+ });
624
+ // Watch body and html for class/attribute changes
625
+ this.themeObserver.observe(document.body, {
626
+ attributes: true,
627
+ attributeFilter: ['class', 'data-theme'],
628
+ });
629
+ this.themeObserver.observe(document.documentElement, {
630
+ attributes: true,
631
+ attributeFilter: ['class', 'data-theme'],
632
+ });
633
+ }
634
+ /**
635
+ * Set theme (can be called manually or from parent app input)
598
636
  * @param mode 'light' or 'dark'
599
637
  */
600
638
  setTheme(mode) {
@@ -619,6 +657,12 @@ class ThemeService {
619
657
  this.renderer.addClass(el, theme);
620
658
  });
621
659
  }
660
+ /**
661
+ * Clean up observer on destroy
662
+ */
663
+ ngOnDestroy() {
664
+ this.themeObserver?.disconnect();
665
+ }
622
666
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: ThemeService, deps: [{ token: i0.RendererFactory2 }, { token: i1.OverlayContainer }], target: i0.ɵɵFactoryTarget.Injectable });
623
667
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: ThemeService, providedIn: 'root' });
624
668
  }