@truenas/ui-components 0.1.22 → 0.1.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": "@truenas/ui-components",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org",
6
6
  "access": "public"
@@ -4023,7 +4023,8 @@ interface TnThemeDefinition {
4023
4023
  *
4024
4024
  * Features:
4025
4025
  * - Signal-based reactive theme state
4026
- * - LocalStorage persistence (key: 'tn-theme')
4026
+ * - OS color scheme detection (prefers-color-scheme)
4027
+ * - LocalStorage persistence for explicit user choices (key: 'tn-theme')
4027
4028
  * - Automatic CSS class application to document root
4028
4029
  * - SSR-safe (checks for browser platform)
4029
4030
  *
@@ -4043,9 +4044,12 @@ interface TnThemeDefinition {
4043
4044
  * // Get current theme (signal)
4044
4045
  * const currentTheme = this.themeService.currentTheme();
4045
4046
  *
4046
- * // Set theme using enum (recommended)
4047
+ * // Set theme using enum (recommended) — persists to localStorage
4047
4048
  * this.themeService.setTheme(TnTheme.Blue);
4048
4049
  *
4050
+ * // Clear user preference and follow OS theme
4051
+ * this.themeService.clearPreference();
4052
+ *
4049
4053
  * // React to theme changes
4050
4054
  * effect(() => {
4051
4055
  * console.log('Theme changed to:', this.themeService.currentTheme()?.label);
@@ -4057,10 +4061,24 @@ interface TnThemeDefinition {
4057
4061
  declare class TnThemeService {
4058
4062
  private readonly platformId;
4059
4063
  private readonly isBrowser;
4064
+ private readonly destroyRef;
4060
4065
  /**
4061
4066
  * Internal signal holding the current theme enum value
4062
4067
  */
4063
4068
  private readonly currentThemeSignal;
4069
+ /**
4070
+ * Whether the user has explicitly selected a theme (vs OS-detected default).
4071
+ * When true, theme is persisted to localStorage and OS changes are ignored.
4072
+ */
4073
+ private readonly userSelected;
4074
+ /**
4075
+ * Reference to the prefers-color-scheme media query for cleanup
4076
+ */
4077
+ private colorSchemeQuery;
4078
+ /**
4079
+ * Bound listener reference for cleanup
4080
+ */
4081
+ private readonly colorSchemeListener;
4064
4082
  /**
4065
4083
  * Computed signal that returns the full theme definition for the current theme
4066
4084
  */
@@ -4069,6 +4087,10 @@ declare class TnThemeService {
4069
4087
  * Computed signal that returns the current theme's CSS class name
4070
4088
  */
4071
4089
  readonly currentThemeClass: _angular_core.Signal<string>;
4090
+ /**
4091
+ * Whether the current theme is based on OS preference (no explicit user choice)
4092
+ */
4093
+ readonly isUsingSystemTheme: _angular_core.Signal<boolean>;
4072
4094
  /**
4073
4095
  * All available theme definitions in the library (readonly array)
4074
4096
  */
@@ -4076,7 +4098,8 @@ declare class TnThemeService {
4076
4098
  constructor();
4077
4099
  /**
4078
4100
  * Set the current theme.
4079
- * Updates the signal, which triggers effects to apply CSS and save to localStorage.
4101
+ * Marks this as an explicit user choice, persists to localStorage,
4102
+ * and stops following OS color scheme changes.
4080
4103
  *
4081
4104
  * @param theme - The theme to set (use TnTheme enum)
4082
4105
  * @returns true if theme was found and set, false otherwise
@@ -4092,17 +4115,30 @@ declare class TnThemeService {
4092
4115
  */
4093
4116
  getCurrentTheme(): TnTheme;
4094
4117
  /**
4095
- * Reset theme to default
4118
+ * Reset theme to default by clearing user preference and reverting to OS detection.
4096
4119
  */
4097
4120
  resetToDefault(): void;
4121
+ /**
4122
+ * Clear user preference and revert to OS-based theme detection.
4123
+ * Removes the stored theme from localStorage and follows the OS color scheme.
4124
+ */
4125
+ clearPreference(): void;
4098
4126
  /**
4099
4127
  * Check if a theme exists
4100
4128
  */
4101
4129
  hasTheme(theme: TnTheme): boolean;
4102
4130
  /**
4103
- * Initialize theme from localStorage or use default
4131
+ * Initialize theme from localStorage or OS color scheme preference
4104
4132
  */
4105
4133
  private initializeTheme;
4134
+ /**
4135
+ * Detect OS color scheme preference and apply corresponding theme
4136
+ */
4137
+ private applySystemTheme;
4138
+ /**
4139
+ * Listen for OS color scheme changes and apply them when no user preference is set
4140
+ */
4141
+ private listenForColorSchemeChanges;
4106
4142
  /**
4107
4143
  * Apply theme CSS class to document root.
4108
4144
  * Removes all other theme classes first to avoid conflicts.
@@ -4125,6 +4161,10 @@ declare class TnThemeService {
4125
4161
  * Default theme used when no theme is set
4126
4162
  */
4127
4163
  declare const DEFAULT_THEME = TnTheme.Dark;
4164
+ /**
4165
+ * Light theme used when OS preference is light
4166
+ */
4167
+ declare const LIGHT_THEME = TnTheme.Blue;
4128
4168
  /**
4129
4169
  * localStorage key for storing the current theme name
4130
4170
  */
@@ -4139,5 +4179,5 @@ declare const TN_THEME_DEFINITIONS: readonly TnThemeDefinition[];
4139
4179
  */
4140
4180
  declare const THEME_MAP: Map<TnTheme, TnThemeDefinition>;
4141
4181
 
4142
- export { CommonShortcuts, DEFAULT_THEME, DiskIconComponent, DiskType, FileSizePipe, InputType, LinuxModifierKeys, LinuxShortcuts, ModifierKeys, QuickShortcuts, ShortcutBuilder, StripMntPrefixPipe, THEME_MAP, THEME_STORAGE_KEY, TN_THEME_DEFINITIONS, TnBannerActionDirective, TnBannerComponent, TnBannerHarness, TnBrandedSpinnerComponent, TnButtonComponent, TnButtonHarness, TnButtonToggleComponent, TnButtonToggleGroupComponent, TnCalendarComponent, TnCalendarHeaderComponent, TnCardComponent, TnCellDefDirective, TnCheckboxComponent, TnChipComponent, TnConfirmDialogComponent, TnDateInputComponent, TnDateRangeInputComponent, TnDialog, TnDialogHarness, TnDialogShellComponent, TnDialogTesting, TnDividerComponent, TnDividerDirective, TnEmptyComponent, TnEmptyHarness, TnExpansionPanelComponent, TnFilePickerComponent, TnFilePickerPopupComponent, TnFormFieldComponent, TnHeaderCellDefDirective, TnIconButtonComponent, TnIconButtonHarness, TnIconComponent, TnIconHarness, TnIconRegistryService, TnIconTesting, TnInputComponent, TnInputDirective, TnInputHarness, TnKeyboardShortcutComponent, TnKeyboardShortcutService, TnListAvatarDirective, TnListComponent, TnListIconDirective, TnListItemComponent, TnListItemLineDirective, TnListItemPrimaryDirective, TnListItemSecondaryDirective, TnListItemTitleDirective, TnListItemTrailingDirective, TnListOptionComponent, TnListSubheaderComponent, TnMenuActivateHoverDirective, TnMenuComponent, TnMenuTriggerDirective, TnMonthViewComponent, TnMultiYearViewComponent, TnNestedTreeNodeComponent, TnParticleProgressBarComponent, TnProgressBarComponent, TnRadioComponent, TnSelectComponent, TnSelectHarness, TnSelectionListComponent, TnSidePanelActionDirective, TnSidePanelComponent, TnSidePanelHarness, TnSidePanelHeaderActionDirective, TnSlideToggleComponent, TnSliderComponent, TnSliderThumbDirective, TnSliderWithLabelDirective, TnSpinnerComponent, TnSpriteLoaderService, TnStepComponent, TnStepperComponent, TnTabComponent, TnTabHarness, TnTabPanelComponent, TnTabPanelHarness, TnTableColumnDirective, TnTableComponent, TnTabsComponent, TnTabsHarness, TnTheme, TnThemeService, TnTimeInputComponent, TnTooltipComponent, TnTooltipDirective, TnTreeComponent, TnTreeFlatDataSource, TnTreeFlattener, TnTreeNodeComponent, TnTreeNodeOutletDirective, TruncatePathPipe, WindowsModifierKeys, WindowsShortcuts, createLucideLibrary, createShortcut, defaultSpriteBasePath, defaultSpriteConfigPath, libIconMarker, registerLucideIcons, setupLucideIntegration, tnIconMarker };
4182
+ export { CommonShortcuts, DEFAULT_THEME, DiskIconComponent, DiskType, FileSizePipe, InputType, LIGHT_THEME, LinuxModifierKeys, LinuxShortcuts, ModifierKeys, QuickShortcuts, ShortcutBuilder, StripMntPrefixPipe, THEME_MAP, THEME_STORAGE_KEY, TN_THEME_DEFINITIONS, TnBannerActionDirective, TnBannerComponent, TnBannerHarness, TnBrandedSpinnerComponent, TnButtonComponent, TnButtonHarness, TnButtonToggleComponent, TnButtonToggleGroupComponent, TnCalendarComponent, TnCalendarHeaderComponent, TnCardComponent, TnCellDefDirective, TnCheckboxComponent, TnChipComponent, TnConfirmDialogComponent, TnDateInputComponent, TnDateRangeInputComponent, TnDialog, TnDialogHarness, TnDialogShellComponent, TnDialogTesting, TnDividerComponent, TnDividerDirective, TnEmptyComponent, TnEmptyHarness, TnExpansionPanelComponent, TnFilePickerComponent, TnFilePickerPopupComponent, TnFormFieldComponent, TnHeaderCellDefDirective, TnIconButtonComponent, TnIconButtonHarness, TnIconComponent, TnIconHarness, TnIconRegistryService, TnIconTesting, TnInputComponent, TnInputDirective, TnInputHarness, TnKeyboardShortcutComponent, TnKeyboardShortcutService, TnListAvatarDirective, TnListComponent, TnListIconDirective, TnListItemComponent, TnListItemLineDirective, TnListItemPrimaryDirective, TnListItemSecondaryDirective, TnListItemTitleDirective, TnListItemTrailingDirective, TnListOptionComponent, TnListSubheaderComponent, TnMenuActivateHoverDirective, TnMenuComponent, TnMenuTriggerDirective, TnMonthViewComponent, TnMultiYearViewComponent, TnNestedTreeNodeComponent, TnParticleProgressBarComponent, TnProgressBarComponent, TnRadioComponent, TnSelectComponent, TnSelectHarness, TnSelectionListComponent, TnSidePanelActionDirective, TnSidePanelComponent, TnSidePanelHarness, TnSidePanelHeaderActionDirective, TnSlideToggleComponent, TnSliderComponent, TnSliderThumbDirective, TnSliderWithLabelDirective, TnSpinnerComponent, TnSpriteLoaderService, TnStepComponent, TnStepperComponent, TnTabComponent, TnTabHarness, TnTabPanelComponent, TnTabPanelHarness, TnTableColumnDirective, TnTableComponent, TnTabsComponent, TnTabsHarness, TnTheme, TnThemeService, TnTimeInputComponent, TnTooltipComponent, TnTooltipDirective, TnTreeComponent, TnTreeFlatDataSource, TnTreeFlattener, TnTreeNodeComponent, TnTreeNodeOutletDirective, TruncatePathPipe, WindowsModifierKeys, WindowsShortcuts, createLucideLibrary, createShortcut, defaultSpriteBasePath, defaultSpriteConfigPath, libIconMarker, registerLucideIcons, setupLucideIntegration, tnIconMarker };
4143
4183
  export type { BannerHarnessFilters, ButtonHarnessFilters, CalendarCell, ChipColor, CreateFolderEvent, DateRange, DialogHarnessFilters, EmptyHarnessFilters, FilePickerCallbacks, FilePickerError, FilePickerMode, FileSystemItem, IconButtonHarnessFilters, IconHarnessFilters, IconLibrary, IconLibraryType, IconResult, IconSize, IconSource, IconTestingMockOverrides, InputHarnessFilters, KeyCombination, LabelType, LucideIconOptions, MockIconRegistry, MockSpriteLoader, PathSegment, PlatformType, ProgressBarMode, ResolvedIcon, SelectHarnessFilters, ShortcutHandler, SidePanelHarnessFilters, SlideToggleColor, SpinnerMode, SpriteConfig, TabChangeEvent, TabHarnessFilters, TabPanelHarnessFilters, TabsHarnessFilters, TnBannerType, TnButtonToggleType, TnCardAction, TnCardControl, TnCardFooterLink, TnCardHeaderStatus, TnConfirmDialogData, TnDialogDefaults, TnDialogOpenTarget, TnEmptySize, TnFlatTreeNode, TnMenuItem, TnSelectOption, TnSelectOptionGroup, TnSelectionChange, TnTableDataSource, TnThemeDefinition, TooltipPosition, YearCell };