cloud-ide-element 1.1.70 → 1.1.71

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.
@@ -1,7 +1,7 @@
1
1
  import * as i1 from '@angular/common';
2
- import { CommonModule, NgTemplateOutlet } from '@angular/common';
2
+ import { CommonModule, isPlatformBrowser, NgTemplateOutlet } from '@angular/common';
3
3
  import * as i0 from '@angular/core';
4
- import { Pipe, Injectable, inject, ChangeDetectorRef, EventEmitter, ViewContainerRef, forwardRef, ViewChild, Output, Input, Component, ContentChildren, signal, DestroyRef, computed, effect, input, HostListener, ChangeDetectionStrategy, Directive, ElementRef, viewChild } from '@angular/core';
4
+ import { Pipe, Injectable, inject, ChangeDetectorRef, EventEmitter, ViewContainerRef, forwardRef, ViewChild, Output, Input, Component, ContentChildren, signal, DestroyRef, computed, effect, input, HostListener, ChangeDetectionStrategy, Directive, PLATFORM_ID, ElementRef, viewChild } from '@angular/core';
5
5
  import * as i2 from '@angular/forms';
6
6
  import { FormsModule, NG_VALUE_ACCESSOR, NG_VALIDATORS } from '@angular/forms';
7
7
  import { BehaviorSubject, Subject, debounceTime, distinctUntilChanged, takeUntil, Observable, retry, catchError, finalize, throwError, map, of } from 'rxjs';
@@ -8154,6 +8154,250 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImpor
8154
8154
  }]
8155
8155
  }], ctorParameters: () => [] });
8156
8156
 
8157
+ /**
8158
+ * CIDE Element Library - Theme Service
8159
+ * Independent theme management for the element library
8160
+ * Can be used standalone without parent application theme dependencies
8161
+ */
8162
+ class CideThemeService {
8163
+ platformId = inject(PLATFORM_ID);
8164
+ isBrowser;
8165
+ currentTheme$ = new BehaviorSubject('light');
8166
+ effectiveTheme$ = new BehaviorSubject('light');
8167
+ config = {
8168
+ theme: 'light',
8169
+ targetElement: null,
8170
+ persistPreference: true,
8171
+ storageKey: 'cide-theme',
8172
+ useDataAttribute: true,
8173
+ useClassName: true
8174
+ };
8175
+ constructor() {
8176
+ this.isBrowser = isPlatformBrowser(this.platformId);
8177
+ if (this.isBrowser) {
8178
+ this.config.targetElement = document.documentElement;
8179
+ }
8180
+ }
8181
+ /**
8182
+ * Initialize the theme service with configuration
8183
+ * This should be called once in the application, typically in main.ts or app config
8184
+ */
8185
+ initialize(config) {
8186
+ if (!this.isBrowser) {
8187
+ return;
8188
+ }
8189
+ // Merge configuration
8190
+ if (config) {
8191
+ this.config = {
8192
+ ...this.config,
8193
+ ...config,
8194
+ targetElement: config.targetElement || document.documentElement
8195
+ };
8196
+ }
8197
+ // Load saved theme preference
8198
+ const savedTheme = this.loadThemePreference();
8199
+ const initialTheme = savedTheme || this.config.theme;
8200
+ // Apply initial theme
8201
+ this.setTheme(initialTheme);
8202
+ // Listen for system theme changes if theme is set to 'auto'
8203
+ if (initialTheme === 'auto') {
8204
+ this.listenToSystemTheme();
8205
+ }
8206
+ }
8207
+ /**
8208
+ * Set the current theme
8209
+ */
8210
+ setTheme(theme) {
8211
+ if (!this.isBrowser) {
8212
+ return;
8213
+ }
8214
+ this.currentTheme$.next(theme);
8215
+ // Save preference if persistence is enabled
8216
+ if (this.config.persistPreference) {
8217
+ this.saveThemePreference(theme);
8218
+ }
8219
+ // Determine effective theme
8220
+ let effectiveTheme;
8221
+ if (theme === 'auto') {
8222
+ effectiveTheme = this.getSystemTheme();
8223
+ this.listenToSystemTheme();
8224
+ }
8225
+ else {
8226
+ effectiveTheme = theme;
8227
+ }
8228
+ this.effectiveTheme$.next(effectiveTheme);
8229
+ this.applyTheme(effectiveTheme);
8230
+ }
8231
+ /**
8232
+ * Get the current theme preference
8233
+ */
8234
+ getCurrentTheme() {
8235
+ return this.currentTheme$.value;
8236
+ }
8237
+ /**
8238
+ * Get the effective theme (actual theme being displayed)
8239
+ */
8240
+ getEffectiveTheme() {
8241
+ return this.effectiveTheme$.value;
8242
+ }
8243
+ /**
8244
+ * Observable for current theme changes
8245
+ */
8246
+ getCurrentTheme$() {
8247
+ return this.currentTheme$.asObservable();
8248
+ }
8249
+ /**
8250
+ * Observable for effective theme changes
8251
+ */
8252
+ getEffectiveTheme$() {
8253
+ return this.effectiveTheme$.asObservable();
8254
+ }
8255
+ /**
8256
+ * Toggle between light and dark themes
8257
+ */
8258
+ toggleTheme() {
8259
+ const currentEffective = this.effectiveTheme$.value;
8260
+ const newTheme = currentEffective === 'light' ? 'dark' : 'light';
8261
+ this.setTheme(newTheme);
8262
+ }
8263
+ /**
8264
+ * Check if dark mode is currently active
8265
+ */
8266
+ isDarkMode() {
8267
+ return this.effectiveTheme$.value === 'dark';
8268
+ }
8269
+ /**
8270
+ * Apply theme to target element
8271
+ */
8272
+ applyTheme(theme) {
8273
+ if (!this.isBrowser || !this.config.targetElement) {
8274
+ return;
8275
+ }
8276
+ const element = this.config.targetElement;
8277
+ // Apply data-theme attribute
8278
+ if (this.config.useDataAttribute) {
8279
+ element.setAttribute('data-theme', theme);
8280
+ }
8281
+ // Apply class name
8282
+ if (this.config.useClassName) {
8283
+ if (theme === 'dark') {
8284
+ element.classList.add('dark-mode');
8285
+ element.classList.remove('light-mode');
8286
+ }
8287
+ else {
8288
+ element.classList.add('light-mode');
8289
+ element.classList.remove('dark-mode');
8290
+ }
8291
+ }
8292
+ // Also apply to body for better compatibility
8293
+ if (element === document.documentElement && document.body) {
8294
+ if (this.config.useDataAttribute) {
8295
+ document.body.setAttribute('data-theme', theme);
8296
+ }
8297
+ if (this.config.useClassName) {
8298
+ if (theme === 'dark') {
8299
+ document.body.classList.add('dark-mode');
8300
+ document.body.classList.remove('light-mode');
8301
+ }
8302
+ else {
8303
+ document.body.classList.add('light-mode');
8304
+ document.body.classList.remove('dark-mode');
8305
+ }
8306
+ }
8307
+ }
8308
+ }
8309
+ /**
8310
+ * Get system theme preference
8311
+ */
8312
+ getSystemTheme() {
8313
+ if (!this.isBrowser) {
8314
+ return 'light';
8315
+ }
8316
+ if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
8317
+ return 'dark';
8318
+ }
8319
+ return 'light';
8320
+ }
8321
+ /**
8322
+ * Listen to system theme changes
8323
+ */
8324
+ listenToSystemTheme() {
8325
+ if (!this.isBrowser || !window.matchMedia) {
8326
+ return;
8327
+ }
8328
+ const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
8329
+ const handler = (e) => {
8330
+ if (this.currentTheme$.value === 'auto') {
8331
+ const effectiveTheme = e.matches ? 'dark' : 'light';
8332
+ this.effectiveTheme$.next(effectiveTheme);
8333
+ this.applyTheme(effectiveTheme);
8334
+ }
8335
+ };
8336
+ // Modern browsers
8337
+ if (mediaQuery.addEventListener) {
8338
+ mediaQuery.addEventListener('change', handler);
8339
+ }
8340
+ else if (mediaQuery.addListener) {
8341
+ // Legacy browsers
8342
+ mediaQuery.addListener(handler);
8343
+ }
8344
+ }
8345
+ /**
8346
+ * Save theme preference to localStorage
8347
+ */
8348
+ saveThemePreference(theme) {
8349
+ if (!this.isBrowser) {
8350
+ return;
8351
+ }
8352
+ try {
8353
+ localStorage.setItem(this.config.storageKey, theme);
8354
+ }
8355
+ catch (error) {
8356
+ console.warn('Failed to save theme preference to localStorage:', error);
8357
+ }
8358
+ }
8359
+ /**
8360
+ * Load theme preference from localStorage
8361
+ */
8362
+ loadThemePreference() {
8363
+ if (!this.isBrowser) {
8364
+ return null;
8365
+ }
8366
+ try {
8367
+ const saved = localStorage.getItem(this.config.storageKey);
8368
+ if (saved && ['light', 'dark', 'auto'].includes(saved)) {
8369
+ return saved;
8370
+ }
8371
+ }
8372
+ catch (error) {
8373
+ console.warn('Failed to load theme preference from localStorage:', error);
8374
+ }
8375
+ return null;
8376
+ }
8377
+ /**
8378
+ * Clear saved theme preference
8379
+ */
8380
+ clearThemePreference() {
8381
+ if (!this.isBrowser) {
8382
+ return;
8383
+ }
8384
+ try {
8385
+ localStorage.removeItem(this.config.storageKey);
8386
+ }
8387
+ catch (error) {
8388
+ console.warn('Failed to clear theme preference from localStorage:', error);
8389
+ }
8390
+ }
8391
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: CideThemeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
8392
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: CideThemeService, providedIn: 'root' });
8393
+ }
8394
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: CideThemeService, decorators: [{
8395
+ type: Injectable,
8396
+ args: [{
8397
+ providedIn: 'root'
8398
+ }]
8399
+ }], ctorParameters: () => [] });
8400
+
8157
8401
  /**
8158
8402
  * Directive to display images from file manager by ID
8159
8403
  * Usage: <img cideEleFileImage [fileId]="yourFileId" [altText]="'Image'" class="your-css-classes" />
@@ -13476,5 +13720,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImpor
13476
13720
  * Generated bundle index. Do not edit.
13477
13721
  */
13478
13722
 
13479
- export { CapitalizePipe, CideCoreFileManagerService, CideEleBreadcrumbComponent, CideEleButtonComponent, CideEleConfirmationModalComponent, CideEleDataGridComponent, CideEleDropdownComponent, CideEleFileImageDirective, CideEleFileInputComponent, CideEleFileManagerService, CideEleFloatingContainerComponent, CideEleFloatingContainerDynamicDirective, CideEleFloatingContainerManagerComponent, CideEleFloatingContainerService, CideEleFloatingFeaturesService, CideEleFloatingFileUploaderComponent, CideEleFloatingFileUploaderService, CideEleGlobalNotificationsComponent, CideEleJsonEditorComponent, CideEleResizerDirective, CideEleSkeletonLoaderComponent, CideEleTabComponent, CideEleToastNotificationComponent, CideElementsService, CideFormFieldErrorComponent, CideIconComponent, CideInputComponent, CideSelectComponent, CideSelectOptionComponent, CideSpinnerComponent, CideTextareaComponent, ConfirmationService, CoreFileManagerInsertUpdatePayload, DEFAULT_GRID_CONFIG, DropdownManagerService, ExportService, ICoreCyfmSave, KeyboardShortcutService, MFileManager, NotificationApiService, NotificationService, PortalService, TooltipDirective, WebSocketNotificationService, cidePath, hostManagerRoutesUrl, notificationRoutesUrl };
13723
+ export { CapitalizePipe, CideCoreFileManagerService, CideEleBreadcrumbComponent, CideEleButtonComponent, CideEleConfirmationModalComponent, CideEleDataGridComponent, CideEleDropdownComponent, CideEleFileImageDirective, CideEleFileInputComponent, CideEleFileManagerService, CideEleFloatingContainerComponent, CideEleFloatingContainerDynamicDirective, CideEleFloatingContainerManagerComponent, CideEleFloatingContainerService, CideEleFloatingFeaturesService, CideEleFloatingFileUploaderComponent, CideEleFloatingFileUploaderService, CideEleGlobalNotificationsComponent, CideEleJsonEditorComponent, CideEleResizerDirective, CideEleSkeletonLoaderComponent, CideEleTabComponent, CideEleToastNotificationComponent, CideElementsService, CideFormFieldErrorComponent, CideIconComponent, CideInputComponent, CideSelectComponent, CideSelectOptionComponent, CideSpinnerComponent, CideTextareaComponent, CideThemeService, ConfirmationService, CoreFileManagerInsertUpdatePayload, DEFAULT_GRID_CONFIG, DropdownManagerService, ExportService, ICoreCyfmSave, KeyboardShortcutService, MFileManager, NotificationApiService, NotificationService, PortalService, TooltipDirective, WebSocketNotificationService, cidePath, hostManagerRoutesUrl, notificationRoutesUrl };
13480
13724
  //# sourceMappingURL=cloud-ide-element.mjs.map