ngx-dev-toolbar 2.0.9 → 2.1.0

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.
@@ -3,7 +3,7 @@ import * as i0 from "@angular/core";
3
3
  export declare class DevToolbarIconComponent {
4
4
  private readonly stateService;
5
5
  name: import("@angular/core").InputSignal<IconName>;
6
- fill: import("@angular/core").Signal<"#000000" | "#FFFFFF">;
6
+ fill: import("@angular/core").Signal<"#FFFFFF" | "#000000">;
7
7
  static ɵfac: i0.ɵɵFactoryDeclaration<DevToolbarIconComponent, never>;
8
8
  static ɵcmp: i0.ɵɵComponentDeclaration<DevToolbarIconComponent, "ndt-icon", never, { "name": { "alias": "name"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
9
9
  }
@@ -13,6 +13,12 @@ export declare class DevToolbarStateService {
13
13
  */
14
14
  readonly delay: import("@angular/core").Signal<number>;
15
15
  readonly config: import("@angular/core").Signal<DevToolbarConfig>;
16
+ /**
17
+ * Indicates if the toolbar is enabled based on config.
18
+ * When disabled, toolbar UI won't render and services won't return forced values.
19
+ * @default true
20
+ */
21
+ readonly isEnabled: import("@angular/core").Signal<boolean>;
16
22
  setVisibility(isVisible: boolean): void;
17
23
  setTheme(theme: 'light' | 'dark'): void;
18
24
  setActiveTool(toolId: string | null): void;
@@ -35,6 +35,12 @@ class DevToolbarStateService {
35
35
  */
36
36
  this.delay = computed(() => this.state().delay);
37
37
  this.config = computed(() => this.state().config);
38
+ /**
39
+ * Indicates if the toolbar is enabled based on config.
40
+ * When disabled, toolbar UI won't render and services won't return forced values.
41
+ * @default true
42
+ */
43
+ this.isEnabled = computed(() => this.state().config.enabled ?? true);
38
44
  }
39
45
  // State updates
40
46
  setVisibility(isVisible) {
@@ -2457,6 +2463,7 @@ class DevToolbarInternalAppFeaturesService {
2457
2463
  constructor() {
2458
2464
  this.STORAGE_KEY = 'app-features';
2459
2465
  this.storageService = inject(DevToolsStorageService);
2466
+ this.stateService = inject(DevToolbarStateService);
2460
2467
  this.appFeaturesSubject = new BehaviorSubject([]);
2461
2468
  this.forcedFeaturesSubject = new BehaviorSubject({
2462
2469
  enabled: [],
@@ -2519,7 +2526,13 @@ class DevToolbarInternalAppFeaturesService {
2519
2526
  * Get observable stream of features that have forced overrides
2520
2527
  */
2521
2528
  getForcedFeatures() {
2522
- return this.features$.pipe(map((features) => features.filter((feature) => feature.isForced)));
2529
+ return this.features$.pipe(map((features) => {
2530
+ // If toolbar is disabled, return empty array (no forced values)
2531
+ if (!this.stateService.isEnabled()) {
2532
+ return [];
2533
+ }
2534
+ return features.filter((feature) => feature.isForced);
2535
+ }));
2523
2536
  }
2524
2537
  /**
2525
2538
  * Force a feature to enabled or disabled state.
@@ -2602,6 +2615,10 @@ class DevToolbarInternalAppFeaturesService {
2602
2615
  * @returns Features with merged forced state
2603
2616
  */
2604
2617
  mergeForcedState(appFeatures, forcedState) {
2618
+ // If toolbar is disabled, return app features without overrides
2619
+ if (!this.stateService.isEnabled()) {
2620
+ return appFeatures;
2621
+ }
2605
2622
  return appFeatures.map((feature) => {
2606
2623
  const isInEnabled = forcedState.enabled.includes(feature.id);
2607
2624
  const isInDisabled = forcedState.disabled.includes(feature.id);
@@ -2905,6 +2922,7 @@ class DevToolbarInternalFeatureFlagService {
2905
2922
  constructor() {
2906
2923
  this.STORAGE_KEY = 'feature-flags';
2907
2924
  this.storageService = inject(DevToolsStorageService);
2925
+ this.stateService = inject(DevToolbarStateService);
2908
2926
  this.appFlags$ = new BehaviorSubject([]);
2909
2927
  this.forcedFlagsSubject = new BehaviorSubject({
2910
2928
  enabled: [],
@@ -2915,6 +2933,10 @@ class DevToolbarInternalFeatureFlagService {
2915
2933
  this.appFlags$,
2916
2934
  this.forcedFlags$,
2917
2935
  ]).pipe(map(([appFlags, { enabled, disabled }]) => {
2936
+ // If toolbar is disabled, return app flags without overrides
2937
+ if (!this.stateService.isEnabled()) {
2938
+ return appFlags;
2939
+ }
2918
2940
  return appFlags.map((flag) => {
2919
2941
  const isForced = enabled.includes(flag.id) || disabled.includes(flag.id);
2920
2942
  return {
@@ -2939,7 +2961,13 @@ class DevToolbarInternalFeatureFlagService {
2939
2961
  return this.appFlags$.asObservable();
2940
2962
  }
2941
2963
  getForcedFlags() {
2942
- return this.flags$.pipe(map((flags) => flags.filter((flag) => flag.isForced)));
2964
+ return this.flags$.pipe(map((flags) => {
2965
+ // If toolbar is disabled, return empty array (no forced values)
2966
+ if (!this.stateService.isEnabled()) {
2967
+ return [];
2968
+ }
2969
+ return flags.filter((flag) => flag.isForced);
2970
+ }));
2943
2971
  }
2944
2972
  setFlag(flagId, isEnabled) {
2945
2973
  const { enabled, disabled } = this.forcedFlagsSubject.value;
@@ -3580,6 +3608,7 @@ class DevToolbarInternalLanguageService {
3580
3608
  constructor() {
3581
3609
  this.STORAGE_KEY = 'language';
3582
3610
  this.storageService = inject(DevToolsStorageService);
3611
+ this.stateService = inject(DevToolbarStateService);
3583
3612
  this.languages$ = new BehaviorSubject([]);
3584
3613
  this.forcedLanguage$ = new BehaviorSubject(null);
3585
3614
  this.languages = toSignal(this.languages$, { initialValue: [] });
@@ -3596,7 +3625,13 @@ class DevToolbarInternalLanguageService {
3596
3625
  this.storageService.set(this.STORAGE_KEY, language);
3597
3626
  }
3598
3627
  getForcedLanguage() {
3599
- return this.forcedLanguage$.pipe(map((language) => (language ? [language] : [])));
3628
+ return this.forcedLanguage$.pipe(map((language) => {
3629
+ // If toolbar is disabled, return empty array (no forced values)
3630
+ if (!this.stateService.isEnabled()) {
3631
+ return [];
3632
+ }
3633
+ return language ? [language] : [];
3634
+ }));
3600
3635
  }
3601
3636
  removeForcedLanguage() {
3602
3637
  this.forcedLanguage$.next(null);
@@ -3711,6 +3746,7 @@ class DevToolbarInternalPermissionsService {
3711
3746
  constructor() {
3712
3747
  this.STORAGE_KEY = 'permissions';
3713
3748
  this.storageService = inject(DevToolsStorageService);
3749
+ this.stateService = inject(DevToolbarStateService);
3714
3750
  this.appPermissions$ = new BehaviorSubject([]);
3715
3751
  this.forcedStateSubject = new BehaviorSubject({
3716
3752
  granted: [],
@@ -3721,6 +3757,10 @@ class DevToolbarInternalPermissionsService {
3721
3757
  this.appPermissions$,
3722
3758
  this.forcedState$,
3723
3759
  ]).pipe(map(([appPermissions, { granted, denied }]) => {
3760
+ // If toolbar is disabled, return app permissions without overrides
3761
+ if (!this.stateService.isEnabled()) {
3762
+ return appPermissions;
3763
+ }
3724
3764
  return appPermissions.map((permission) => {
3725
3765
  const isForced = granted.includes(permission.id) || denied.includes(permission.id);
3726
3766
  return {
@@ -3766,7 +3806,13 @@ class DevToolbarInternalPermissionsService {
3766
3806
  this.storageService.set(this.STORAGE_KEY, newState);
3767
3807
  }
3768
3808
  getForcedPermissions() {
3769
- return this.permissions$.pipe(map((permissions) => permissions.filter((permission) => permission.isForced)));
3809
+ return this.permissions$.pipe(map((permissions) => {
3810
+ // If toolbar is disabled, return empty array (no forced values)
3811
+ if (!this.stateService.isEnabled()) {
3812
+ return [];
3813
+ }
3814
+ return permissions.filter((permission) => permission.isForced);
3815
+ }));
3770
3816
  }
3771
3817
  /**
3772
3818
  * Apply a preset permissions state, replacing the current forced state.
@@ -5028,33 +5074,35 @@ class DevToolbarComponent {
5028
5074
  }
5029
5075
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.7", ngImport: i0, type: DevToolbarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
5030
5076
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.7", type: DevToolbarComponent, isStandalone: true, selector: "ndt-toolbar", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
5031
- <div
5032
- aria-label="Developer tools"
5033
- role="toolbar"
5034
- class="ndt-toolbar"
5035
- [@toolbarState]="state.isVisible() ? 'visible' : 'hidden'"
5036
- [attr.data-theme]="state.theme()"
5037
- [class.ndt-toolbar--active]="state.isVisible()"
5038
- (mouseenter)="onMouseEnter()"
5039
- >
5040
- <ndt-home-tool />
5041
- <ng-content />
5042
- @if (config().showLanguageTool ?? false) {
5043
- <ndt-language-tool />
5044
- }
5045
- @if (config().showPresetsTool ?? false) {
5046
- <ndt-presets-tool />
5047
- }
5048
- @if (config().showAppFeaturesTool ?? false) {
5049
- <ndt-app-features-tool />
5050
- }
5051
- @if (config().showPermissionsTool ?? false) {
5052
- <ndt-permissions-tool />
5053
- }
5054
- @if (config().showFeatureFlagsTool ?? false) {
5055
- <ndt-feature-flags-tool />
5056
- }
5057
- </div>
5077
+ @if (config().enabled ?? true) {
5078
+ <div
5079
+ aria-label="Developer tools"
5080
+ role="toolbar"
5081
+ class="ndt-toolbar"
5082
+ [@toolbarState]="state.isVisible() ? 'visible' : 'hidden'"
5083
+ [attr.data-theme]="state.theme()"
5084
+ [class.ndt-toolbar--active]="state.isVisible()"
5085
+ (mouseenter)="onMouseEnter()"
5086
+ >
5087
+ <ndt-home-tool />
5088
+ <ng-content />
5089
+ @if (config().showLanguageTool ?? false) {
5090
+ <ndt-language-tool />
5091
+ }
5092
+ @if (config().showPresetsTool ?? false) {
5093
+ <ndt-presets-tool />
5094
+ }
5095
+ @if (config().showAppFeaturesTool ?? false) {
5096
+ <ndt-app-features-tool />
5097
+ }
5098
+ @if (config().showPermissionsTool ?? false) {
5099
+ <ndt-permissions-tool />
5100
+ }
5101
+ @if (config().showFeatureFlagsTool ?? false) {
5102
+ <ndt-feature-flags-tool />
5103
+ }
5104
+ </div>
5105
+ }
5058
5106
  `, isInline: true, styles: [":host{display:contents;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol,\"Noto Color Emoji\"}.ndt-toolbar{--ndt-border-radius-small: 4px;--ndt-border-radius-medium: 8px;--ndt-border-radius-large: 12px;--ndt-transition-default: all .2s ease-out;--ndt-transition-smooth: all .2s ease-in-out;--ndt-bg-primary: rgb(255, 255, 255);--ndt-bg-gradient: linear-gradient(180deg, rgb(243, 244, 246) 0%, rgba(243, 244, 246, .88) 100%);--ndt-text-primary: rgb(17, 24, 39);--ndt-text-secondary: rgb(55, 65, 81);--ndt-text-muted: rgb(107, 114, 128);--ndt-border-primary: #e5e7eb;--ndt-border-subtle: rgba(17, 24, 39, .1);--ndt-hover-bg: rgba(17, 24, 39, .05);--ndt-hover-danger: rgb(239, 68, 68);--ndt-shadow-toolbar: 0 2px 8px rgba(156, 163, 175, .2);--ndt-shadow-tooltip: 0 0 0 1px rgba(17, 24, 39, .05), 0 4px 8px rgba(107, 114, 128, .15), 0 2px 4px rgba(107, 114, 128, .1);--ndt-shadow-window: 0px 0px 0px 0px rgba(156, 163, 175, .1), 0px 1px 2px 0px rgba(156, 163, 175, .12), 0px 4px 4px 0px rgba(156, 163, 175, .1), 0px 10px 6px 0px rgba(156, 163, 175, .08), 0px 17px 7px 0px rgba(156, 163, 175, .05), 0px 26px 7px 0px rgba(156, 163, 175, .02);--ndt-spacing-xs: 4px;--ndt-spacing-sm: 6px;--ndt-spacing-md: 12px;--ndt-spacing-lg: 16px;--ndt-window-padding: 16px;--ndt-font-size-xxs: .65rem;--ndt-font-size-xs: .75rem;--ndt-font-size-sm: .875rem;--ndt-font-size-md: 1rem;--ndt-font-size-lg: 1.25rem;--ndt-font-size-xl: 2rem;--ndt-background-secondary: var(--ndt-bg-primary);--ndt-background-hover: var(--ndt-hover-bg);--ndt-primary: #df30d4;--ndt-primary-rgb: 223, 48, 212;--ndt-text-on-primary: rgb(255, 255, 255);--ndt-border-color: var(--ndt-border-primary);--ndt-note-background: rgb(219, 234, 254);--ndt-note-border: rgba(37, 99, 235, .2);--ndt-warning-background: rgb(254, 249, 195);--ndt-warning-border: rgba(202, 138, 4, .2);--ndt-error-background: rgb(254, 226, 226);--ndt-error-border: rgba(220, 38, 38, .2);position:fixed;bottom:0;left:50%;z-index:999999;transform:translate(-50%);display:flex;pointer-events:auto;background:var(--ndt-bg-primary);border:1px solid var(--ndt-border-primary);border-radius:9999px;box-shadow:var(--ndt-shadow-toolbar);height:40px;overflow:hidden}.ndt-toolbar--active{opacity:1}h1,h2,h3,h4,h5{font-weight:600;color:var(--ndt-text-primary);margin:0}h1{font-size:var(--ndt-font-size-xl)}h2{font-size:var(--ndt-font-size-lg)}h3{font-size:var(--ndt-font-size-md)}h4{font-size:var(--ndt-font-size-sm)}h5{font-size:var(--ndt-font-size-xs)}hr{border:1px solid var(--ndt-border-subtle);margin:1em 0}p{line-height:1.5em;margin:0}\n"], dependencies: [{ kind: "component", type: DevToolbarHomeToolComponent, selector: "ndt-home-tool", inputs: ["badge"] }, { kind: "component", type: DevToolbarLanguageToolComponent, selector: "ndt-language-tool" }, { kind: "component", type: DevToolbarFeatureFlagsToolComponent, selector: "ndt-feature-flags-tool" }, { kind: "component", type: DevToolbarAppFeaturesToolComponent, selector: "ndt-app-features-tool" }, { kind: "component", type: DevToolbarPermissionsToolComponent, selector: "ndt-permissions-tool" }, { kind: "component", type: DevToolbarPresetsToolComponent, selector: "ndt-presets-tool" }], animations: [
5059
5107
  trigger('toolbarState', [
5060
5108
  state('hidden', style({
@@ -5079,33 +5127,35 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.7", ngImpor
5079
5127
  DevToolbarPermissionsToolComponent,
5080
5128
  DevToolbarPresetsToolComponent,
5081
5129
  ], template: `
5082
- <div
5083
- aria-label="Developer tools"
5084
- role="toolbar"
5085
- class="ndt-toolbar"
5086
- [@toolbarState]="state.isVisible() ? 'visible' : 'hidden'"
5087
- [attr.data-theme]="state.theme()"
5088
- [class.ndt-toolbar--active]="state.isVisible()"
5089
- (mouseenter)="onMouseEnter()"
5090
- >
5091
- <ndt-home-tool />
5092
- <ng-content />
5093
- @if (config().showLanguageTool ?? false) {
5094
- <ndt-language-tool />
5095
- }
5096
- @if (config().showPresetsTool ?? false) {
5097
- <ndt-presets-tool />
5098
- }
5099
- @if (config().showAppFeaturesTool ?? false) {
5100
- <ndt-app-features-tool />
5101
- }
5102
- @if (config().showPermissionsTool ?? false) {
5103
- <ndt-permissions-tool />
5104
- }
5105
- @if (config().showFeatureFlagsTool ?? false) {
5106
- <ndt-feature-flags-tool />
5107
- }
5108
- </div>
5130
+ @if (config().enabled ?? true) {
5131
+ <div
5132
+ aria-label="Developer tools"
5133
+ role="toolbar"
5134
+ class="ndt-toolbar"
5135
+ [@toolbarState]="state.isVisible() ? 'visible' : 'hidden'"
5136
+ [attr.data-theme]="state.theme()"
5137
+ [class.ndt-toolbar--active]="state.isVisible()"
5138
+ (mouseenter)="onMouseEnter()"
5139
+ >
5140
+ <ndt-home-tool />
5141
+ <ng-content />
5142
+ @if (config().showLanguageTool ?? false) {
5143
+ <ndt-language-tool />
5144
+ }
5145
+ @if (config().showPresetsTool ?? false) {
5146
+ <ndt-presets-tool />
5147
+ }
5148
+ @if (config().showAppFeaturesTool ?? false) {
5149
+ <ndt-app-features-tool />
5150
+ }
5151
+ @if (config().showPermissionsTool ?? false) {
5152
+ <ndt-permissions-tool />
5153
+ }
5154
+ @if (config().showFeatureFlagsTool ?? false) {
5155
+ <ndt-feature-flags-tool />
5156
+ }
5157
+ </div>
5158
+ }
5109
5159
  `, animations: [
5110
5160
  trigger('toolbarState', [
5111
5161
  state('hidden', style({