@forcecalendar/interface 1.0.21 → 1.0.23

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forcecalendar/interface",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "type": "module",
5
5
  "description": "Official interface layer for forceCalendar Core - Enterprise calendar components",
6
6
  "main": "dist/force-calendar-interface.umd.js",
@@ -31,6 +31,7 @@ export class ForceCalendar extends BaseComponent {
31
31
  this.currentView = null;
32
32
  this._hasRendered = false; // Track if initial render is complete
33
33
  this._cachedStyles = null; // Cache styles to avoid recreation
34
+ this._busUnsubscribers = [];
34
35
  }
35
36
 
36
37
  initialize() {
@@ -53,25 +54,29 @@ export class ForceCalendar extends BaseComponent {
53
54
  }
54
55
 
55
56
  setupEventListeners() {
57
+ // Clean up any existing subscriptions before re-subscribing
58
+ this._busUnsubscribers.forEach(unsub => unsub());
59
+ this._busUnsubscribers = [];
60
+
56
61
  // Navigation events
57
- eventBus.on('navigation:*', (data, event) => {
62
+ this._busUnsubscribers.push(eventBus.on('navigation:*', (data, event) => {
58
63
  this.emit('calendar-navigate', { action: event.split(':')[1], ...data });
59
- });
64
+ }));
60
65
 
61
66
  // View change events
62
- eventBus.on('view:changed', (data) => {
67
+ this._busUnsubscribers.push(eventBus.on('view:changed', (data) => {
63
68
  this.emit('calendar-view-change', data);
64
- });
69
+ }));
65
70
 
66
71
  // Event management events
67
- eventBus.on('event:*', (data, event) => {
72
+ this._busUnsubscribers.push(eventBus.on('event:*', (data, event) => {
68
73
  this.emit(`calendar-event-${event.split(':')[1]}`, data);
69
- });
74
+ }));
70
75
 
71
76
  // Date selection events
72
- eventBus.on('date:selected', (data) => {
77
+ this._busUnsubscribers.push(eventBus.on('date:selected', (data) => {
73
78
  this.emit('calendar-date-select', data);
74
- });
79
+ }));
75
80
  }
76
81
 
77
82
  handleStateChange(newState, oldState) {
@@ -88,10 +93,14 @@ export class ForceCalendar extends BaseComponent {
88
93
  const errorChanged = newState.error !== oldState?.error;
89
94
 
90
95
  // For loading/error state changes, do full re-render (rare)
91
- if (loadingChanged || errorChanged) {
96
+ if (errorChanged) {
92
97
  this.render();
93
98
  return;
94
99
  }
100
+ if (loadingChanged) {
101
+ this._updateLoadingState(newState.loading);
102
+ return;
103
+ }
95
104
 
96
105
  // Update local view reference if needed
97
106
  if (viewChanged) {
@@ -179,15 +188,31 @@ export class ForceCalendar extends BaseComponent {
179
188
  }
180
189
  }
181
190
 
191
+ /**
192
+ * Toggle loading overlay without rebuilding the component tree.
193
+ */
194
+ _updateLoadingState(isLoading) {
195
+ const loadingEl = this.$('.fc-loading');
196
+ const viewContainer = this.$('.fc-view-container');
197
+ if (loadingEl) {
198
+ loadingEl.style.display = isLoading ? 'flex' : 'none';
199
+ }
200
+ if (viewContainer) {
201
+ viewContainer.style.display = isLoading ? 'none' : 'flex';
202
+ }
203
+ }
204
+
182
205
  mount() {
206
+ this.currentView = this.stateManager.getView();
183
207
  super.mount();
184
- this.loadView(this.stateManager.getView());
185
208
  }
186
209
 
187
210
  loadView(viewType) {
188
- // Views are already registered at the top of the file
211
+ if (!viewType || this.currentView === viewType) return;
189
212
  this.currentView = viewType;
190
- this.render();
213
+ this._switchView();
214
+ this._updateViewButtons();
215
+ this._updateTitle();
191
216
  }
192
217
 
193
218
  getStyles() {
@@ -632,16 +657,13 @@ export class ForceCalendar extends BaseComponent {
632
657
  </header>
633
658
 
634
659
  <div class="fc-body">
635
- ${loading ? `
636
- <div class="fc-loading">
637
- <div class="fc-spinner"></div>
638
- <span>Loading...</span>
639
- </div>
640
- ` : `
641
- <div class="fc-view-container">
642
- ${this.renderView()}
643
- </div>
644
- `}
660
+ <div class="fc-loading" style="display: ${loading ? 'flex' : 'none'};">
661
+ <div class="fc-spinner"></div>
662
+ <span>Loading...</span>
663
+ </div>
664
+ <div class="fc-view-container" style="display: ${loading ? 'none' : 'flex'};">
665
+ ${this.renderView()}
666
+ </div>
645
667
  </div>
646
668
 
647
669
  <forcecal-event-form id="event-modal"></forcecal-event-form>
@@ -857,10 +879,12 @@ export class ForceCalendar extends BaseComponent {
857
879
  }
858
880
 
859
881
  destroy() {
882
+ this._busUnsubscribers.forEach(unsub => unsub());
883
+ this._busUnsubscribers = [];
884
+
860
885
  if (this.stateManager) {
861
886
  this.stateManager.destroy();
862
887
  }
863
- eventBus.clear();
864
888
  super.cleanup();
865
889
  }
866
890
  }
@@ -868,4 +892,4 @@ export class ForceCalendar extends BaseComponent {
868
892
  // Register component
869
893
  if (!customElements.get('forcecal-main')) {
870
894
  customElements.define('forcecal-main', ForceCalendar);
871
- }
895
+ }