@ng-doc/app 15.12.0 → 15.13.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.
Files changed (70) hide show
  1. package/README.md +1 -1
  2. package/components/navbar/navbar.component.d.ts +9 -1
  3. package/components/root/root.component.d.ts +26 -2
  4. package/components/root/root.module.d.ts +3 -2
  5. package/esm2020/components/breadcrumb/breadcrumb.component.mjs +2 -2
  6. package/esm2020/components/navbar/navbar.component.mjs +20 -4
  7. package/esm2020/components/page/page.component.mjs +2 -2
  8. package/esm2020/components/root/root.component.mjs +49 -6
  9. package/esm2020/components/root/root.module.mjs +6 -5
  10. package/esm2020/components/search/search.component.mjs +3 -3
  11. package/esm2020/components/theme-toggle/theme-toggle.component.mjs +3 -3
  12. package/esm2020/constants/store-keys.mjs +2 -2
  13. package/esm2020/helpers/index.mjs +2 -1
  14. package/esm2020/helpers/is-dark-os-theme.mjs +7 -0
  15. package/esm2020/interfaces/application-config.mjs +1 -1
  16. package/esm2020/modules/root/ng-doc.module.mjs +6 -2
  17. package/esm2020/services/sidebar/sidebar.service.mjs +28 -24
  18. package/esm2020/services/theme/theme.service.mjs +61 -13
  19. package/fesm2015/ng-doc-app-components-breadcrumb.mjs +2 -2
  20. package/fesm2015/ng-doc-app-components-breadcrumb.mjs.map +1 -1
  21. package/fesm2015/ng-doc-app-components-navbar.mjs +19 -3
  22. package/fesm2015/ng-doc-app-components-navbar.mjs.map +1 -1
  23. package/fesm2015/ng-doc-app-components-page.mjs +2 -2
  24. package/fesm2015/ng-doc-app-components-page.mjs.map +1 -1
  25. package/fesm2015/ng-doc-app-components-root.mjs +52 -9
  26. package/fesm2015/ng-doc-app-components-root.mjs.map +1 -1
  27. package/fesm2015/ng-doc-app-components-search.mjs +2 -2
  28. package/fesm2015/ng-doc-app-components-search.mjs.map +1 -1
  29. package/fesm2015/ng-doc-app-components-theme-toggle.mjs +2 -2
  30. package/fesm2015/ng-doc-app-components-theme-toggle.mjs.map +1 -1
  31. package/fesm2015/ng-doc-app-constants.mjs +1 -1
  32. package/fesm2015/ng-doc-app-constants.mjs.map +1 -1
  33. package/fesm2015/ng-doc-app-helpers.mjs +8 -1
  34. package/fesm2015/ng-doc-app-helpers.mjs.map +1 -1
  35. package/fesm2015/ng-doc-app-modules-root.mjs +5 -1
  36. package/fesm2015/ng-doc-app-modules-root.mjs.map +1 -1
  37. package/fesm2015/ng-doc-app-services-sidebar.mjs +27 -23
  38. package/fesm2015/ng-doc-app-services-sidebar.mjs.map +1 -1
  39. package/fesm2015/ng-doc-app-services-theme.mjs +60 -12
  40. package/fesm2015/ng-doc-app-services-theme.mjs.map +1 -1
  41. package/fesm2020/ng-doc-app-components-breadcrumb.mjs +2 -2
  42. package/fesm2020/ng-doc-app-components-breadcrumb.mjs.map +1 -1
  43. package/fesm2020/ng-doc-app-components-navbar.mjs +19 -3
  44. package/fesm2020/ng-doc-app-components-navbar.mjs.map +1 -1
  45. package/fesm2020/ng-doc-app-components-page.mjs +2 -2
  46. package/fesm2020/ng-doc-app-components-page.mjs.map +1 -1
  47. package/fesm2020/ng-doc-app-components-root.mjs +52 -9
  48. package/fesm2020/ng-doc-app-components-root.mjs.map +1 -1
  49. package/fesm2020/ng-doc-app-components-search.mjs +2 -2
  50. package/fesm2020/ng-doc-app-components-search.mjs.map +1 -1
  51. package/fesm2020/ng-doc-app-components-theme-toggle.mjs +2 -2
  52. package/fesm2020/ng-doc-app-components-theme-toggle.mjs.map +1 -1
  53. package/fesm2020/ng-doc-app-constants.mjs +1 -1
  54. package/fesm2020/ng-doc-app-constants.mjs.map +1 -1
  55. package/fesm2020/ng-doc-app-helpers.mjs +8 -1
  56. package/fesm2020/ng-doc-app-helpers.mjs.map +1 -1
  57. package/fesm2020/ng-doc-app-modules-root.mjs +5 -1
  58. package/fesm2020/ng-doc-app-modules-root.mjs.map +1 -1
  59. package/fesm2020/ng-doc-app-services-sidebar.mjs +27 -23
  60. package/fesm2020/ng-doc-app-services-sidebar.mjs.map +1 -1
  61. package/fesm2020/ng-doc-app-services-theme.mjs +60 -12
  62. package/fesm2020/ng-doc-app-services-theme.mjs.map +1 -1
  63. package/helpers/index.d.ts +1 -0
  64. package/helpers/is-dark-os-theme.d.ts +4 -0
  65. package/interfaces/application-config.d.ts +11 -1
  66. package/package.json +3 -3
  67. package/services/sidebar/sidebar.service.d.ts +3 -10
  68. package/services/theme/theme.service.d.ts +23 -3
  69. package/styles/global.css +11 -2
  70. package/styles/main.css +6 -2
@@ -1 +1 @@
1
- {"version":3,"file":"ng-doc-app-modules-root.mjs","sources":["../../../../libs/app/modules/root/ng-doc.module.ts","../../../../libs/app/modules/root/ng-doc-app-modules-root.ts"],"sourcesContent":["import {OverlayModule} from '@angular/cdk/overlay';\nimport {HttpClientModule} from '@angular/common/http';\nimport {APP_INITIALIZER, ModuleWithProviders, NgModule, Optional} from '@angular/core';\nimport {NgDocRootModule} from '@ng-doc/app/components/root';\nimport {NG_DOC_DARK_PURPLE_THEME, NG_DOC_NIGHT_THEME, NG_DOC_STORE_THEME_KEY} from '@ng-doc/app/constants';\nimport {NgDocApplicationConfig, NgDocTheme} from '@ng-doc/app/interfaces';\nimport {NgDocStoreService} from '@ng-doc/app/services/store';\nimport {NgDocThemeService} from '@ng-doc/app/services/theme';\nimport {NG_DOC_DEFAULT_THEME_ID, NG_DOC_THEME} from '@ng-doc/app/tokens';\nimport {asArray} from '@ng-doc/core/helpers/as-array';\nimport {NgDocUiKitRootModule} from '@ng-doc/ui-kit/modules/root';\n\n@NgModule({\n\timports: [HttpClientModule, OverlayModule, NgDocUiKitRootModule.forRoot()],\n\texports: [NgDocRootModule, NgDocUiKitRootModule],\n})\nexport class NgDocModule {\n\tstatic forRoot(config?: NgDocApplicationConfig): ModuleWithProviders<NgDocModule> {\n\t\treturn {\n\t\t\tngModule: NgDocModule,\n\t\t\tproviders: [\n\t\t\t\t{provide: NG_DOC_THEME, useValue: NG_DOC_NIGHT_THEME, multi: true},\n\t\t\t\t{provide: NG_DOC_THEME, useValue: NG_DOC_DARK_PURPLE_THEME, multi: true},\n\t\t\t\t...asArray(config?.themes).map((theme: NgDocTheme) => ({\n\t\t\t\t\tprovide: NG_DOC_THEME,\n\t\t\t\t\tuseValue: theme,\n\t\t\t\t\tmulti: true,\n\t\t\t\t})),\n\t\t\t\t...asArray(config?.defaultThemeId).map((themeId: string) => ({\n\t\t\t\t\tprovide: NG_DOC_DEFAULT_THEME_ID,\n\t\t\t\t\tuseValue: themeId,\n\t\t\t\t})),\n\t\t\t\t{\n\t\t\t\t\tprovide: APP_INITIALIZER,\n\t\t\t\t\tuseFactory: (themeService: NgDocThemeService, store: NgDocStoreService, defaultThemeId: string) => {\n\t\t\t\t\t\treturn () => {\n\t\t\t\t\t\t\tconst themeId: string | null = store.get(NG_DOC_STORE_THEME_KEY);\n\n\t\t\t\t\t\t\treturn themeService.set(themeId ?? defaultThemeId);\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t\tmulti: true,\n\t\t\t\t\tdeps: [NgDocThemeService, NgDocStoreService, [new Optional(), NG_DOC_DEFAULT_THEME_ID]],\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;MAgBa,WAAW,CAAA;IACvB,OAAO,OAAO,CAAC,MAA+B,EAAA;QAC7C,OAAO;AACN,YAAA,QAAQ,EAAE,WAAW;AACrB,YAAA,SAAS,EAAE;gBACV,EAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,kBAAkB,EAAE,KAAK,EAAE,IAAI,EAAC;gBAClE,EAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,wBAAwB,EAAE,KAAK,EAAE,IAAI,EAAC;AACxE,gBAAA,GAAG,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAiB,MAAM;AACtD,oBAAA,OAAO,EAAE,YAAY;A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A,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAW,EAHb,OAAA,EAAA,CAAA,gBAAgB,EAAE,aAAa,EAAE,oBAAoB,CAAC,OAAO,EAAE,EAC/D,eAAe,EAAE,oBAAoB,CAAA,EAAA,CAAA,CAAA;2FAEnC,WAAW,EAAA,UAAA,EAAA,CAAA;kBAJvB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACT,OAAO,EAAE,CAAC,gBAAgB,EAAE,aAAa,EAAE,oBAAoB,CAAC,OAAO,EAAE,CAAC;AAC1E,oBAAA,OAAO,EAAE,CAAC,eAAe,EAAE,oBAAoB,CAAC;AAChD,iBAAA,CAAA;;;ACfD;;AAEG;;;;"}
1
+ {"version":3,"file":"ng-doc-app-modules-root.mjs","sources":["../../../../libs/app/modules/root/ng-doc.module.ts","../../../../libs/app/modules/root/ng-doc-app-modules-root.ts"],"sourcesContent":["import {OverlayModule} from '@angular/cdk/overlay';\nimport {HttpClientModule} from '@angular/common/http';\nimport {APP_INITIALIZER, ModuleWithProviders, NgModule, Optional} from '@angular/core';\nimport {NgDocRootModule} from '@ng-doc/app/components/root';\nimport {NG_DOC_DARK_PURPLE_THEME, NG_DOC_NIGHT_THEME, NG_DOC_STORE_THEME_KEY} from '@ng-doc/app/constants';\nimport {isDarkOsTheme} from '@ng-doc/app/helpers';\nimport {NgDocApplicationConfig, NgDocTheme} from '@ng-doc/app/interfaces';\nimport {NgDocStoreService} from '@ng-doc/app/services/store';\nimport {NgDocThemeService} from '@ng-doc/app/services/theme';\nimport {NG_DOC_DEFAULT_THEME_ID, NG_DOC_THEME} from '@ng-doc/app/tokens';\nimport {asArray} from '@ng-doc/core/helpers/as-array';\nimport {NgDocUiKitRootModule} from '@ng-doc/ui-kit/modules/root';\n\n@NgModule({\n\timports: [HttpClientModule, OverlayModule, NgDocUiKitRootModule.forRoot()],\n\texports: [NgDocRootModule, NgDocUiKitRootModule],\n})\nexport class NgDocModule {\n\tstatic forRoot(config?: NgDocApplicationConfig): ModuleWithProviders<NgDocModule> {\n\t\treturn {\n\t\t\tngModule: NgDocModule,\n\t\t\tproviders: [\n\t\t\t\t{provide: NG_DOC_THEME, useValue: NG_DOC_NIGHT_THEME, multi: true},\n\t\t\t\t{provide: NG_DOC_THEME, useValue: NG_DOC_DARK_PURPLE_THEME, multi: true},\n\t\t\t\t...asArray(config?.themes).map((theme: NgDocTheme) => ({\n\t\t\t\t\tprovide: NG_DOC_THEME,\n\t\t\t\t\tuseValue: theme,\n\t\t\t\t\tmulti: true,\n\t\t\t\t})),\n\t\t\t\t...asArray(config?.defaultThemeId).map((themeId: string) => ({\n\t\t\t\t\tprovide: NG_DOC_DEFAULT_THEME_ID,\n\t\t\t\t\tuseValue: themeId,\n\t\t\t\t})),\n\t\t\t\t{\n\t\t\t\t\tprovide: APP_INITIALIZER,\n\t\t\t\t\tuseFactory: (themeService: NgDocThemeService, store: NgDocStoreService, defaultThemeId: string | 'auto') => {\n\t\t\t\t\t\treturn () => {\n\t\t\t\t\t\t\tconst themeId: string | null = store.get(NG_DOC_STORE_THEME_KEY);\n\n\t\t\t\t\t\t\tif (defaultThemeId === 'auto' && !themeId) {\n\t\t\t\t\t\t\t\treturn themeService.set(isDarkOsTheme() ? NG_DOC_NIGHT_THEME.id : undefined, false);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn themeService.set(themeId ?? defaultThemeId, false);\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t\tmulti: true,\n\t\t\t\t\tdeps: [NgDocThemeService, NgDocStoreService, [new Optional(), NG_DOC_DEFAULT_THEME_ID]],\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;MAiBa,WAAW,CAAA;IACvB,OAAO,OAAO,CAAC,MAA+B,EAAA;QAC7C,OAAO;AACN,YAAA,QAAQ,EAAE,WAAW;AACrB,Y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ACvF,iBAAA;AACD,aAAA;SACD,CAAC;KACF;;wGAlCW,WAAW,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAAX,WAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAW,YAHb,gBAAgB,EAAE,aAAa,EAC/B,EAAA,CAAA,oBAAA,CAAA,EAAA,OAAA,EAAA,CAAA,eAAe,EAAE,oBAAoB,CAAA,EAAA,CAAA,CAAA;AAEnC,WAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAW,EAHb,OAAA,EAAA,CAAA,gBAAgB,EAAE,aAAa,EAAE,oBAAoB,CAAC,OAAO,EAAE,EAC/D,eAAe,EAAE,oBAAoB,CAAA,EAAA,CAAA,CAAA;2FAEnC,WAAW,EAAA,UAAA,EAAA,CAAA;kBAJvB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACT,OAAO,EAAE,CAAC,gBAAgB,EAAE,aAAa,EAAE,oBAAoB,CAAC,OAAO,EAAE,CAAC;AAC1E,oBAAA,OAAO,EAAE,CAAC,eAAe,EAAE,oBAAoB,CAAC;AAChD,iBAAA,CAAA;;;AChBD;;AAEG;;;;"}
@@ -9,8 +9,8 @@ import { NavigationEnd, Router } from '@angular/router';
9
9
  import * as i3 from '@ng-doc/ui-kit/services/scroll';
10
10
  import { NgDocScrollService } from '@ng-doc/ui-kit/services/scroll';
11
11
  import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
12
- import { BehaviorSubject, of } from 'rxjs';
13
- import { pluck, filter, startWith, switchMap } from 'rxjs/operators';
12
+ import { BehaviorSubject, combineLatest } from 'rxjs';
13
+ import { pluck, distinctUntilChanged, filter, debounceTime } from 'rxjs/operators';
14
14
 
15
15
  /**
16
16
  * Service for sidebar, it can be used to hide/show sidebar or to check if sidebar is collapsable.
@@ -22,39 +22,43 @@ let NgDocSidebarService = class NgDocSidebarService {
22
22
  this.router = router;
23
23
  this.scroll = scroll;
24
24
  this.breakpoints = [Breakpoints.XSmall, Breakpoints.Small];
25
- this.visible = new BehaviorSubject(false);
26
- this.observer = this.breakpointObserver.observe(this.breakpoints).pipe(pluck('matches'), untilDestroyed(this));
27
- this.router.events
28
- .pipe(filter((event) => event instanceof NavigationEnd && this.visible.value), startWith(null))
25
+ this.expanded = new BehaviorSubject(true);
26
+ this.observer = this.breakpointObserver
27
+ .observe(this.breakpoints)
28
+ .pipe(pluck('matches'), distinctUntilChanged(), untilDestroyed(this));
29
+ combineLatest([this.router.events, this.isMobileMode()])
30
+ .pipe(filter(([event, isMobileMode]) => event instanceof NavigationEnd && this.expanded.value && isMobileMode), debounceTime(10))
29
31
  .subscribe(() => this.hide());
32
+ this.isMobileMode()
33
+ .pipe(untilDestroyed(this))
34
+ .subscribe((isMobileMode) => {
35
+ if (isMobileMode) {
36
+ this.hide();
37
+ }
38
+ else {
39
+ this.show();
40
+ this.scroll.unblock();
41
+ }
42
+ });
30
43
  }
31
44
  /**
32
- * Indicates if sidebar can be collapsable.
33
- * You can use it to start showing a button in the navbar to show/hide sidebar.
34
- * This method uses media queries to check if sidebar is collapsable based on the current screen size.
45
+ * Indicates if sidebar is collapsable, based on the screen size.
35
46
  */
36
- isCollapsable() {
47
+ isMobileMode() {
37
48
  return this.observer;
38
49
  }
39
50
  /**
40
51
  * Indicates if sidebar is visible, based on the show/hide methods.
41
52
  */
42
- visibilityChanges() {
43
- return this.visible.asObservable();
44
- }
45
- /**
46
- * Indicates if sidebar is expanded, based on the show/hide methods and if sidebar is collapsable.
47
- * This method can be used to display backdrop when sidebar is expanded.
48
- */
49
53
  isExpanded() {
50
- return this.isCollapsable().pipe(switchMap((isCollapsable) => (isCollapsable ? this.visibilityChanges() : of(false))));
54
+ return this.expanded.asObservable();
51
55
  }
52
56
  /**
53
57
  * Show sidebar, and block scrolling.
54
58
  */
55
59
  show() {
56
- if (!this.visible.value) {
57
- this.visible.next(true);
60
+ if (!this.expanded.value) {
61
+ this.expanded.next(true);
58
62
  this.scroll.block();
59
63
  }
60
64
  }
@@ -62,8 +66,8 @@ let NgDocSidebarService = class NgDocSidebarService {
62
66
  * Hide sidebar, and unblock scrolling.
63
67
  */
64
68
  hide() {
65
- if (this.visible.value) {
66
- this.visible.next(false);
69
+ if (this.expanded.value) {
70
+ this.expanded.next(false);
67
71
  this.scroll.unblock();
68
72
  }
69
73
  }
@@ -71,7 +75,7 @@ let NgDocSidebarService = class NgDocSidebarService {
71
75
  * Toggle sidebar visibility.
72
76
  */
73
77
  toggle() {
74
- this.visible.value ? this.hide() : this.show();
78
+ this.expanded.value ? this.hide() : this.show();
75
79
  }
76
80
  };
77
81
  NgDocSidebarService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: NgDocSidebarService, deps: [{ token: DOCUMENT }, { token: i1.BreakpointObserver }, { token: i2.Router }, { token: i3.NgDocScrollService }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -1 +1 @@
1
- {"version":3,"file":"ng-doc-app-services-sidebar.mjs","sources":["../../../../libs/app/services/sidebar/sidebar.service.ts","../../../../libs/app/services/sidebar/ng-doc-app-services-sidebar.ts"],"sourcesContent":["import {BreakpointObserver, Breakpoints} from '@angular/cdk/layout';\nimport {DOCUMENT} from '@angular/common';\nimport {Inject, Injectable} from '@angular/core';\nimport {Event, NavigationEnd, Router} from '@angular/router';\nimport {NgDocScrollService} from '@ng-doc/ui-kit/services/scroll';\nimport {UntilDestroy, untilDestroyed} from '@ngneat/until-destroy';\nimport {BehaviorSubject, Observable, of} from 'rxjs';\nimport {filter, pluck, startWith, switchMap} from 'rxjs/operators';\n\n/**\n * Service for sidebar, it can be used to hide/show sidebar or to check if sidebar is collapsable.\n */\n@Injectable({\n\tprovidedIn: 'root',\n})\n@UntilDestroy()\nexport class NgDocSidebarService {\n\treadonly breakpoints: string[] = [Breakpoints.XSmall, Breakpoints.Small];\n\tprotected readonly observer: Observable<boolean>;\n\tprotected readonly visible: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);\n\n\tconstructor(\n\t\t@Inject(DOCUMENT)\n\t\tprotected readonly document: Document,\n\t\tprotected readonly breakpointObserver: BreakpointObserver,\n\t\tprotected readonly router: Router,\n\t\tprotected readonly scroll: NgDocScrollService,\n\t) {\n\t\tthis.observer = this.breakpointObserver.observe(this.breakpoints).pipe(pluck('matches'), untilDestroyed(this));\n\n\t\tthis.router.events\n\t\t\t.pipe(\n\t\t\t\tfilter((event: Event) => event instanceof NavigationEnd && this.visible.value),\n\t\t\t\tstartWith(null),\n\t\t\t)\n\t\t\t.subscribe(() => this.hide());\n\t}\n\n\t/**\n\t * Indicates if sidebar can be collapsable.\n\t * You can use it to start showing a button in the navbar to show/hide sidebar.\n\t * This method uses media queries to check if sidebar is collapsable based on the current screen size.\n\t */\n\tisCollapsable(): Observable<boolean> {\n\t\treturn this.observer;\n\t}\n\n\t/**\n\t * Indicates if sidebar is visible, based on the show/hide methods.\n\t */\n\tvisibilityChanges(): Observable<boolean> {\n\t\treturn this.visible.asObservable();\n\t}\n\n\t/**\n\t * Indicates if sidebar is expanded, based on the show/hide methods and if sidebar is collapsable.\n\t * This method can be used to display backdrop when sidebar is expanded.\n\t */\n\tisExpanded(): Observable<boolean> {\n\t\treturn this.isCollapsable().pipe(\n\t\t\tswitchMap((isCollapsable: boolean) => (isCollapsable ? this.visibilityChanges() : of(false))),\n\t\t);\n\t}\n\n\t/**\n\t * Show sidebar, and block scrolling.\n\t */\n\tshow(): void {\n\t\tif (!this.visible.value) {\n\t\t\tthis.visible.next(true);\n\t\t\tthis.scroll.block();\n\t\t}\n\t}\n\n\t/**\n\t * Hide sidebar, and unblock scrolling.\n\t */\n\thide(): void {\n\t\tif (this.visible.value) {\n\t\t\tthis.visible.next(false);\n\t\t\tthis.scroll.unblock();\n\t\t}\n\t}\n\n\t/**\n\t * Toggle sidebar visibility.\n\t */\n\ttoggle(): void {\n\t\tthis.visible.value ? this.hide() : this.show();\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;AASA;;AAEG;AAKU,IAAA,mBAAmB,GAAzB,MAAM,mBAAmB,CAAA;AAK/B,IAAA,WAAA,CAEoB,QAAkB,EAClB,kBAAsC,EACtC,MAAc,EACd,MAA0B,EAAA;QAH1B,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAU;QAClB,IAAkB,CAAA,kBAAA,GAAlB,kBAAkB,CAAoB;QACtC,IAAM,CAAA,MAAA,GAAN,MAAM,CAAQ;QACd,IAAM,CAAA,MAAA,GAAN,MAAM,CAAoB;QATrC,IAAW,CAAA,WAAA,GAAa,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;AAEtD,QAAA,IAAA,CAAA,OAAO,GAA6B,IAAI,eAAe,CAAU,KAAK,CAAC,CAAC;QAS1F,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;QAE/G,IAAI,CAAC,MAAM,CAAC,MAAM;aAChB,IAAI,CACJ,MAAM,CAAC,CAAC,KAAY,KAAK,KAAK,YAAY,aAAa,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAC9E,SAAS,CAAC,IAAI,CAAC,CACf;aACA,SAAS,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;KAC/B;AAED;;;;AAIG;IACH,aAAa,GAAA;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AAA,KAAA,EAAA,EAAA,CAAA,kBAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AANL,mBAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,mBAAmB,cAHnB,MAAM,EAAA,CAAA,CAAA;AAGN,mBAAmB,GAAA,UAAA,CAAA;AAD/B,IAAA,YAAY,EAAE;qCAQgB,QAAQ;QACE,kBAAkB;QAC9B,MAAM;QACN,kBAAkB,CAAA,CAAA;AAVlC,CAAA,EAAA,mBAAmB,CA0E/B,CAAA;2FA1EY,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAJ/B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACX,oBAAA,UAAU,EAAE,MAAM;AAClB,iBAAA,CAAA;;0BAQE,MAAM;2BAAC,QAAQ,CAAA;;;ACtBlB;;AAEG;;;;"}
1
+ {"version":3,"file":"ng-doc-app-services-sidebar.mjs","sources":["../../../../libs/app/services/sidebar/sidebar.service.ts","../../../../libs/app/services/sidebar/ng-doc-app-services-sidebar.ts"],"sourcesContent":["import {BreakpointObserver, Breakpoints} from '@angular/cdk/layout';\nimport {DOCUMENT} from '@angular/common';\nimport {Inject, Injectable} from '@angular/core';\nimport {Event, NavigationEnd, Router} from '@angular/router';\nimport {NgDocScrollService} from '@ng-doc/ui-kit/services/scroll';\nimport {UntilDestroy, untilDestroyed} from '@ngneat/until-destroy';\nimport {BehaviorSubject, combineLatest, Observable, of} from 'rxjs';\nimport {debounceTime, distinctUntilChanged, filter, pluck, share, startWith, switchMap, tap} from 'rxjs/operators';\n\n/**\n * Service for sidebar, it can be used to hide/show sidebar or to check if sidebar is collapsable.\n */\n@Injectable({\n\tprovidedIn: 'root',\n})\n@UntilDestroy()\nexport class NgDocSidebarService {\n\treadonly breakpoints: string[] = [Breakpoints.XSmall, Breakpoints.Small];\n\tprotected readonly observer: Observable<boolean>;\n\tprotected readonly expanded: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(true);\n\n\tconstructor(\n\t\t@Inject(DOCUMENT)\n\t\tprotected readonly document: Document,\n\t\tprotected readonly breakpointObserver: BreakpointObserver,\n\t\tprotected readonly router: Router,\n\t\tprotected readonly scroll: NgDocScrollService,\n\t) {\n\t\tthis.observer = this.breakpointObserver\n\t\t\t.observe(this.breakpoints)\n\t\t\t.pipe(pluck('matches'), distinctUntilChanged(), untilDestroyed(this));\n\n\t\tcombineLatest([this.router.events, this.isMobileMode()])\n\t\t\t.pipe(\n\t\t\t\tfilter(\n\t\t\t\t\t([event, isMobileMode]: [Event, boolean]) =>\n\t\t\t\t\t\tevent instanceof NavigationEnd && this.expanded.value && isMobileMode,\n\t\t\t\t),\n\t\t\t\tdebounceTime(10),\n\t\t\t)\n\t\t\t.subscribe(() => this.hide());\n\n\t\tthis.isMobileMode()\n\t\t\t.pipe(untilDestroyed(this))\n\t\t\t.subscribe((isMobileMode: boolean) => {\n\t\t\t\tif (isMobileMode) {\n\t\t\t\t\tthis.hide();\n\t\t\t\t} else {\n\t\t\t\t\tthis.show();\n\t\t\t\t\tthis.scroll.unblock();\n\t\t\t\t}\n\t\t\t});\n\t}\n\n\t/**\n\t * Indicates if sidebar is collapsable, based on the screen size.\n\t */\n\tisMobileMode(): Observable<boolean> {\n\t\treturn this.observer;\n\t}\n\n\t/**\n\t * Indicates if sidebar is visible, based on the show/hide methods.\n\t */\n\tisExpanded(): Observable<boolean> {\n\t\treturn this.expanded.asObservable();\n\t}\n\n\t/**\n\t * Show sidebar, and block scrolling.\n\t */\n\tshow(): void {\n\t\tif (!this.expanded.value) {\n\t\t\tthis.expanded.next(true);\n\t\t\tthis.scroll.block();\n\t\t}\n\t}\n\n\t/**\n\t * Hide sidebar, and unblock scrolling.\n\t */\n\thide(): void {\n\t\tif (this.expanded.value) {\n\t\t\tthis.expanded.next(false);\n\t\t\tthis.scroll.unblock();\n\t\t}\n\t}\n\n\t/**\n\t * Toggle sidebar visibility.\n\t */\n\ttoggle(): void {\n\t\tthis.expanded.value ? this.hide() : this.show();\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;AASA;;AAEG;AAKU,IAAA,mBAAmB,GAAzB,MAAM,mBAAmB,CAAA;AAK/B,IAAA,WAAA,CAEoB,QAAkB,EAClB,kBAAsC,EACtC,MAAc,EACd,MAA0B,EAAA;QAH1B,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAU;QAClB,IAAkB,CAAA,kBAAA,GAAlB,kBAAkB,CAAoB;QACtC,IAAM,CAAA,MAAA,GAAN,MAAM,CAAQ;QACd,IAAM,CAAA,MAAA,GAAN,MAAM,CAAoB;QATrC,IAAW,CAAA,WAAA,GAAa,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;AAEtD,QAAA,IAAA,CAAA,QAAQ,GAA6B,IAAI,eAAe,CAAU,IAAI,CAAC,CAAC;AAS1F,QAAA,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,kBAAkB;AACrC,aAAA,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC;AACzB,aAAA,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,oBAAoB,EAAE,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;AAEvE,QAAA,aAAa,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;AACtD,aAAA,IAAI,CACJ,MAAM,CACL,CAAC,CAAC,KAAK,EAAE,YAAY,CAAmB,KACvC,KAAK,YAAY,aAAa,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,YAAY,CACtE,EACD,YAAY,CAAC,EAAE,CAAC,CAChB;aACA,SAAS,CAAC,MA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AAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,mBAAmB,kBAMtB,QAAQ,EAAA,EAAA,EAAA,KAAA,EAAA,EAAA,CAAA,kBAAA,EAAA,EAAA,EAAA,KAAA,EAAA,EAAA,CAAA,MAAA,EAAA,EAAA,EAAA,KAAA,EAAA,EAAA,CAAA,kBAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AANL,mBAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,mBAAmB,cAHnB,MAAM,EAAA,CAAA,CAAA;AAGN,mBAAmB,GAAA,UAAA,CAAA;AAD/B,IAAA,YAAY,EAAE;qCAQgB,QAAQ;QACE,kBAAkB;QAC9B,MAAM;QACN,kBAAkB,CAAA,CAAA;AAVlC,CAAA,EAAA,mBAAmB,CA8E/B,CAAA;2FA9EY,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAJ/B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACX,oBAAA,UAAU,EAAE,MAAM;AAClB,iBAAA,CAAA;;0BAQE,MAAM;2BAAC,QAAQ,CAAA;;;ACtBlB;;AAEG;;;;"}
@@ -1,22 +1,51 @@
1
+ import { __decorate, __metadata } from 'tslib';
1
2
  import { DOCUMENT } from '@angular/common';
2
3
  import * as i0 from '@angular/core';
3
- import { Injectable, Inject } from '@angular/core';
4
- import { NG_DOC_STORE_THEME_KEY } from '@ng-doc/app/constants';
4
+ import { Injectable, Inject, Optional } from '@angular/core';
5
+ import { NG_DOC_NIGHT_THEME, NG_DOC_STORE_THEME_KEY } from '@ng-doc/app/constants';
5
6
  import * as i1 from '@ng-doc/app/services/store';
6
- import { NG_DOC_THEME } from '@ng-doc/app/tokens';
7
+ import { NgDocStoreService } from '@ng-doc/app/services/store';
8
+ import { NG_DOC_THEME, NG_DOC_DEFAULT_THEME_ID } from '@ng-doc/app/tokens';
9
+ import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
10
+ import { Subject, fromEvent } from 'rxjs';
11
+ import { takeUntil } from 'rxjs/operators';
7
12
 
8
- class NgDocThemeService {
9
- constructor(document, themes, store) {
13
+ /**
14
+ * Service for managing themes.
15
+ */
16
+ let NgDocThemeService = class NgDocThemeService {
17
+ constructor(document, themes, store, defaultThemeId) {
10
18
  this.document = document;
11
19
  this.themes = themes;
12
20
  this.store = store;
21
+ this.defaultThemeId = defaultThemeId;
13
22
  this.theme = undefined;
23
+ this.theme$ = new Subject();
24
+ this.disableAutoTheme$ = new Subject();
25
+ if (defaultThemeId === 'auto') {
26
+ fromEvent(window.matchMedia('(prefers-color-scheme: dark)'), 'change')
27
+ .pipe(takeUntil(this.disableAutoTheme$), untilDestroyed(this))
28
+ .subscribe((event) => this.set(event.matches ? NG_DOC_NIGHT_THEME.id : undefined, false));
29
+ }
14
30
  }
31
+ /**
32
+ * Returns the current theme.
33
+ */
15
34
  get currentTheme() {
16
35
  return this.theme;
17
36
  }
18
- set(id) {
37
+ /**
38
+ * Sets the theme by id.
39
+ *
40
+ * @param id Theme id.
41
+ * @param save Whether to save the theme in the store to restore it when the page is reloaded. (`true` by default)
42
+ */
43
+ set(id, save = true) {
19
44
  this.removeLink();
45
+ if (id === 'auto') {
46
+ return Promise.resolve();
47
+ }
48
+ save && this.disableAutoTheme$.next();
20
49
  if (id !== 'day' && id) {
21
50
  const theme = this.themes.find((theme) => theme.id === id);
22
51
  if (!theme) {
@@ -26,19 +55,29 @@ class NgDocThemeService {
26
55
  this.createLinkIfNoExists();
27
56
  if (this.linkElement) {
28
57
  this.linkElement.href = theme.path;
29
- this.store.set(NG_DOC_STORE_THEME_KEY, theme.id);
58
+ save && this.store.set(NG_DOC_STORE_THEME_KEY, theme.id);
30
59
  this.theme = theme;
31
60
  return new Promise((resolve, reject) => {
32
61
  if (this.linkElement) {
33
- this.linkElement.onload = resolve;
62
+ this.linkElement.onload = () => {
63
+ this.theme$.next(theme);
64
+ resolve();
65
+ };
34
66
  this.linkElement.onerror = reject;
35
67
  }
36
68
  });
37
69
  }
38
70
  }
39
- this.store.set(NG_DOC_STORE_THEME_KEY, 'day');
71
+ save && this.store.set(NG_DOC_STORE_THEME_KEY, 'day');
72
+ this.theme$.next(undefined);
40
73
  return Promise.resolve();
41
74
  }
75
+ /**
76
+ * Returns an observable that emits when the theme changes.
77
+ */
78
+ themeChanges() {
79
+ return this.theme$.asObservable();
80
+ }
42
81
  removeLink() {
43
82
  this.theme = undefined;
44
83
  this.linkElement?.remove();
@@ -52,9 +91,13 @@ class NgDocThemeService {
52
91
  this.document.getElementsByTagName('head')[0].appendChild(this.linkElement);
53
92
  }
54
93
  }
55
- }
56
- NgDocThemeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: NgDocThemeService, deps: [{ token: DOCUMENT }, { token: NG_DOC_THEME }, { token: i1.NgDocStoreService }], target: i0.ɵɵFactoryTarget.Injectable });
94
+ };
95
+ NgDocThemeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: NgDocThemeService, deps: [{ token: DOCUMENT }, { token: NG_DOC_THEME }, { token: i1.NgDocStoreService }, { token: NG_DOC_DEFAULT_THEME_ID, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
57
96
  NgDocThemeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: NgDocThemeService, providedIn: 'root' });
97
+ NgDocThemeService = __decorate([
98
+ UntilDestroy(),
99
+ __metadata("design:paramtypes", [Document, Array, NgDocStoreService, String])
100
+ ], NgDocThemeService);
58
101
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: NgDocThemeService, decorators: [{
59
102
  type: Injectable,
60
103
  args: [{
@@ -66,7 +109,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.4", ngImpor
66
109
  }] }, { type: undefined, decorators: [{
67
110
  type: Inject,
68
111
  args: [NG_DOC_THEME]
69
- }] }, { type: i1.NgDocStoreService }]; } });
112
+ }] }, { type: i1.NgDocStoreService }, { type: undefined, decorators: [{
113
+ type: Inject,
114
+ args: [NG_DOC_DEFAULT_THEME_ID]
115
+ }, {
116
+ type: Optional
117
+ }] }]; } });
70
118
 
71
119
  /**
72
120
  * Generated bundle index. Do not edit.
@@ -1 +1 @@
1
- {"version":3,"file":"ng-doc-app-services-theme.mjs","sources":["../../../../libs/app/services/theme/theme.service.ts","../../../../libs/app/services/theme/ng-doc-app-services-theme.ts"],"sourcesContent":["import {DOCUMENT} from '@angular/common';\nimport {Inject, Injectable} from '@angular/core';\nimport {NG_DOC_STORE_THEME_KEY} from '@ng-doc/app/constants';\nimport {NgDocTheme} from '@ng-doc/app/interfaces';\nimport {NgDocStoreService} from '@ng-doc/app/services/store';\nimport {NG_DOC_THEME} from '@ng-doc/app/tokens';\n\n@Injectable({\n\tprovidedIn: 'root',\n})\nexport class NgDocThemeService {\n\tprivate linkElement?: HTMLLinkElement;\n\tprivate theme: NgDocTheme | undefined = undefined;\n\n\tconstructor(\n\t\t@Inject(DOCUMENT)\n\t\tprivate readonly document: Document,\n\t\t@Inject(NG_DOC_THEME)\n\t\tprivate readonly themes: NgDocTheme[],\n\t\tprivate readonly store: NgDocStoreService,\n\t) {}\n\n\tget currentTheme(): NgDocTheme | undefined {\n\t\treturn this.theme;\n\t}\n\n\tset(id?: string): Promise<void> {\n\t\tthis.removeLink();\n\n\t\tif (id !== 'day' && id) {\n\t\t\tconst theme: NgDocTheme | undefined = this.themes.find((theme: NgDocTheme) => theme.id === id);\n\n\t\t\tif (!theme) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`Theme with id \"${id}\" is not registered. Make sure that you registered it in the root of your application.`,\n\t\t\t\t);\n\n\t\t\t\treturn Promise.resolve();\n\t\t\t}\n\n\t\t\tthis.createLinkIfNoExists();\n\n\t\t\tif (this.linkElement) {\n\t\t\t\tthis.linkElement.href = theme.path;\n\t\t\t\tthis.store.set(NG_DOC_STORE_THEME_KEY, theme.id);\n\t\t\t\tthis.theme = theme;\n\n\t\t\t\treturn new Promise<void>((resolve: () => void, reject: (err: Event | string) => void) => {\n\t\t\t\t\tif (this.linkElement) {\n\t\t\t\t\t\tthis.linkElement.onload = resolve;\n\t\t\t\t\t\tthis.linkElement.onerror = reject;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tthis.store.set(NG_DOC_STORE_THEME_KEY, 'day');\n\n\t\treturn Promise.resolve();\n\t}\n\n\tprivate removeLink(): void {\n\t\tthis.theme = undefined;\n\t\tthis.linkElement?.remove();\n\t\tthis.linkElement = undefined;\n\t}\n\tprivate createLinkIfNoExists(): void {\n\t\tif (!this.linkElement) {\n\t\t\tthis.linkElement = this.document.createElement('link');\n\t\t\tthis.linkElement.setAttribute('rel', 'stylesheet');\n\t\t\tthis.linkElement.setAttribute('type', 'text/css');\n\t\t\tthis.document.getElementsByTagName('head')[0].appendChild(this.linkElement);\n\t\t}\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;MAUa,iBAAiB,CAAA;AAI7B,IAAA,WAAA,CAEkB,QAAkB,EAElB,MAAoB,EACpB,KAAwB,EAAA;QAHxB,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAU;QAElB,IAAM,CAAA,MAAA,GAAN,MAAM,CAAc;QACpB,IAAK,CAAA,KAAA,GAAL,KAAK,CAAmB;QAPlC,IAAK,CAAA,KAAA,GAA2B,SAAS,CAAC;KAQ9C;AAEJ,IAAA,IAAI,YAAY,GAAA;QACf,OAAO,IAAI,CAAC,KAAK,CAAC;KAClB;AAED,IAAA,GAAG,CAAC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IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;KAC7B;IACO,oBAAoB,GAAA;AAC3B,QAAA,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACtB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YACvD,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;YACnD,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAClD,YAAA,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC5E,SAAA;KACD;;8GA9DW,iBAAiB,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAKpB,QAAQ,EAAA,EAAA,EAAA,KAAA,EAER,YAAY,EAAA,EAAA,EAAA,KAAA,EAAA,EAAA,CAAA,iBAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAPT,iBAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,iBAAiB,cAFjB,MAAM,EAAA,CAAA,CAAA;2FAEN,iBAAiB,EAAA,UAAA,EAAA,CAAA;kBAH7B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACX,oBAAA,UAAU,EAAE,MAAM;AAClB,iBAAA,CAAA;;0BAME,MAAM;2BAAC,QAAQ,CAAA;;0BAEf,MAAM;2BAAC,YAAY,CAAA;;;ACjBtB;;AAEG;;;;"}
1
+ {"version":3,"file":"ng-doc-app-services-theme.mjs","sources":["../../../../libs/app/services/theme/theme.service.ts","../../../../libs/app/services/theme/ng-doc-app-services-theme.ts"],"sourcesContent":["import {DOCUMENT} from '@angular/common';\nimport {Inject, Injectable, Optional} from '@angular/core';\nimport {NG_DOC_NIGHT_THEME, NG_DOC_STORE_THEME_KEY} from '@ng-doc/app/constants';\nimport {NgDocTheme} from '@ng-doc/app/interfaces';\nimport {NgDocStoreService} from '@ng-doc/app/services/store';\nimport {NG_DOC_DEFAULT_THEME_ID, NG_DOC_THEME} from '@ng-doc/app/tokens';\nimport {UntilDestroy, untilDestroyed} from '@ngneat/until-destroy';\nimport {from, fromEvent, Observable, Subject} from 'rxjs';\nimport {takeUntil} from 'rxjs/operators';\n\n/**\n * Service for managing themes.\n */\n@Injectable({\n\tprovidedIn: 'root',\n})\n@UntilDestroy()\nexport class NgDocThemeService {\n\tprivate linkElement?: HTMLLinkElement;\n\tprivate theme: NgDocTheme | undefined = undefined;\n\tprivate readonly theme$: Subject<NgDocTheme | undefined> = new Subject<NgDocTheme | undefined>();\n\tprivate readonly disableAutoTheme$: Subject<void> = new Subject<void>();\n\n\tconstructor(\n\t\t@Inject(DOCUMENT)\n\t\tprivate readonly document: Document,\n\t\t@Inject(NG_DOC_THEME)\n\t\tprivate readonly themes: NgDocTheme[],\n\t\tprivate readonly store: NgDocStoreService,\n\t\t@Inject(NG_DOC_DEFAULT_THEME_ID)\n\t\t@Optional()\n\t\tprivate readonly defaultThemeId?: string | 'auto',\n\t) {\n\t\tif (defaultThemeId === 'auto') {\n\t\t\tfromEvent<MediaQueryList>(window.matchMedia('(prefers-color-scheme: dark)'), 'change')\n\t\t\t\t.pipe(takeUntil(this.disableAutoTheme$), untilDestroyed(this))\n\t\t\t\t.subscribe((event: MediaQueryList) => this.set(event.matches ? NG_DOC_NIGHT_THEME.id : undefined, false))\n\t\t}\n\t}\n\n\t/**\n\t * Returns the current theme.\n\t */\n\tget currentTheme(): NgDocTheme | undefined {\n\t\treturn this.theme;\n\t}\n\n\t/**\n\t * Sets the theme by id.\n\t *\n\t * @param id Theme id.\n\t * @param save Whether to save the theme in the store to restore it when the page is reloaded. (`true` by default)\n\t */\n\tset(id?: string | 'auto', save: boolean = true): Promise<void> {\n\t\tthis.removeLink();\n\n\t\tif (id === 'auto') {\n\t\t\treturn Promise.resolve();\n\t\t}\n\n\t\tsave && this.disableAutoTheme$.next();\n\n\t\tif (id !== 'day' && id) {\n\t\t\tconst theme: NgDocTheme | undefined = this.themes.find((theme: NgDocTheme) => theme.id === id);\n\n\t\t\tif (!theme) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`Theme with id \"${id}\" is not registered. Make sure that you registered it in the root of your application.`,\n\t\t\t\t);\n\n\t\t\t\treturn Promise.resolve();\n\t\t\t}\n\n\t\t\tthis.createLinkIfNoExists();\n\n\t\t\tif (this.linkElement) {\n\t\t\t\tthis.linkElement.href = theme.path;\n\t\t\t\tsave && this.store.set(NG_DOC_STORE_THEME_KEY, theme.id);\n\t\t\t\tthis.theme = theme;\n\n\t\t\t\treturn new Promise<void>((resolve: () => void, reject: (err: Event | string) => void) => {\n\t\t\t\t\tif (this.linkElement) {\n\t\t\t\t\t\tthis.linkElement.onload = () => {\n\t\t\t\t\t\t\tthis.theme$.next(theme);\n\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t};\n\t\t\t\t\t\tthis.linkElement.onerror = reject;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tsave && this.store.set(NG_DOC_STORE_THEME_KEY, 'day');\n\n\t\tthis.theme$.next(undefined);\n\n\t\treturn Promise.resolve();\n\t}\n\n\t/**\n\t * Returns an observable that emits when the theme changes.\n\t */\n\tthemeChanges(): Observable<NgDocTheme | undefined> {\n\t\treturn this.theme$.asObservable();\n\t}\n\n\tprivate removeLink(): void {\n\t\tthis.theme = undefined;\n\t\tthis.linkElement?.remove();\n\t\tthis.linkElement = undefined;\n\t}\n\tprivate createLinkIfNoExists(): void {\n\t\tif (!this.linkElement) {\n\t\t\tthis.linkElement = this.document.createElement('link');\n\t\t\tthis.linkElement.setAttribute('rel', 'stylesheet');\n\t\t\tthis.linkElement.setAttribute('type', 'text/css');\n\t\t\tthis.document.getElementsByTagName('head')[0].appendChild(this.linkElement);\n\t\t}\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;AAUA;;AAEG;AAKU,IAAA,iBAAiB,GAAvB,MAAM,iBAAiB,CAAA;AAM7B,IAAA,WAAA,CAEkB,QAAkB,EAElB,MAAoB,EACpB,KAAwB,EAGxB,cAAgC,EAAA;QANhC,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAU;QAElB,IAAM,CAAA,MAAA,GAAN,MAAM,CAAc;QACpB,IAAK,CAAA,KAAA,GAAL,KAAK,CAAmB;QAGxB,IAAc,CAAA,cAAA,GAAd,cAAc,CAAkB;QAZ1C,IAAK,CAAA,KAAA,GAA2B,SAAS,CAAC;AACjC,QAAA,IAAA,CAAA,MAAM,GAAoC,IAAI,OAAO,EAA0B,CAAC;AAChF,QAAA,IAAA,CAAA,iBAAiB,GAAkB,IAAI,OAAO,EAAQ,CAAC;QAYvE,IAAI,cAAc,KAAK,MAAM,EAAE;YAC9B,SAAS,CAAiB,MAAM,CAAC,UAAU,CAAC,8BAA8B,CAAC,EAAE,QAAQ,CAAC;AACpF,iBAAA,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC;iBAC7D,SAAS,CAAC,CAAC,KAAqB,KAAK,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,GAAG,kBAAkB,CAAC,EAAE,GAAG,SAAS,EAAE,KAAK,CAAC,CAAC,CAAA;AAC1G,SAAA;KACD;AAED;;AAEG;AACH,IAAA,IAAI,YAAY,GAAA;QACf,OAAO,IAAI,CAAC,KAAK,CAAC;KAClB;AAED;;;;;AAKG;AACH,IAAA,GAAG,CAAC,EAAoB,EAAE,IAAA,GAAgB,IAAI,EAAA;QAC7C,IAA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AA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAZpB,iBAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,iBAAiB,cAHjB,MAAM,EAAA,CAAA,CAAA;AAGN,iBAAiB,GAAA,UAAA,CAAA;AAD7B,IAAA,YAAY,EAAE;AASc,IAAA,UAAA,CAAA,mBAAA,EAAA,CAAA,QAAQ,SAGX,iBAAiB,EAAA,MAAA,CAAA,CAAA;AAX9B,CAAA,EAAA,iBAAiB,CAsG7B,CAAA;2FAtGY,iBAAiB,EAAA,UAAA,EAAA,CAAA;kBAJ7B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACX,oBAAA,UAAU,EAAE,MAAM;AAClB,iBAAA,CAAA;;0BASE,MAAM;2BAAC,QAAQ,CAAA;;0BAEf,MAAM;2BAAC,YAAY,CAAA;;0BAGnB,MAAM;2BAAC,uBAAuB,CAAA;;0BAC9B,QAAQ;;;AC9BX;;AAEG;;;;"}
@@ -1,5 +1,6 @@
1
1
  export * from './as-boolean';
2
2
  export * from './generate-toc';
3
+ export * from './is-dark-os-theme';
3
4
  export * from './is-external-link';
4
5
  export * from './is-playground-property';
5
6
  export * from './provide-playground-demo';
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Check if the OS theme is dark
3
+ */
4
+ export declare function isDarkOsTheme(): boolean;
@@ -1,5 +1,15 @@
1
1
  import { NgDocTheme } from './theme';
2
+ /**
3
+ * NgDoc application config.
4
+ */
2
5
  export interface NgDocApplicationConfig {
6
+ /**
7
+ * List of themes that will be registered in the application and can be used via `NgDocThemeService`.
8
+ */
3
9
  themes?: NgDocTheme[];
4
- defaultThemeId?: string;
10
+ /**
11
+ * Default theme id.
12
+ * You can use `auto` to automatically select the theme based on the user's operating system settings.
13
+ */
14
+ defaultThemeId?: string | 'auto';
5
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-doc/app",
3
- "version": "15.12.0",
3
+ "version": "15.13.0",
4
4
  "peerDependencies": {
5
5
  "@angular/common": ">=15.0.0",
6
6
  "@angular/core": ">=15.0.0",
@@ -12,8 +12,8 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "tslib": "^2.3.0",
15
- "@ng-doc/core": "15.12.0",
16
- "@ng-doc/ui-kit": "15.12.0",
15
+ "@ng-doc/core": "15.13.0",
16
+ "@ng-doc/ui-kit": "15.13.0",
17
17
  "@orama/plugin-match-highlight": "1.0.0-beta.7",
18
18
  "highlight.js": "11.5.1",
19
19
  "js-beautify": "1.14.7"
@@ -13,22 +13,15 @@ export declare class NgDocSidebarService {
13
13
  protected readonly scroll: NgDocScrollService;
14
14
  readonly breakpoints: string[];
15
15
  protected readonly observer: Observable<boolean>;
16
- protected readonly visible: BehaviorSubject<boolean>;
16
+ protected readonly expanded: BehaviorSubject<boolean>;
17
17
  constructor(document: Document, breakpointObserver: BreakpointObserver, router: Router, scroll: NgDocScrollService);
18
18
  /**
19
- * Indicates if sidebar can be collapsable.
20
- * You can use it to start showing a button in the navbar to show/hide sidebar.
21
- * This method uses media queries to check if sidebar is collapsable based on the current screen size.
19
+ * Indicates if sidebar is collapsable, based on the screen size.
22
20
  */
23
- isCollapsable(): Observable<boolean>;
21
+ isMobileMode(): Observable<boolean>;
24
22
  /**
25
23
  * Indicates if sidebar is visible, based on the show/hide methods.
26
24
  */
27
- visibilityChanges(): Observable<boolean>;
28
- /**
29
- * Indicates if sidebar is expanded, based on the show/hide methods and if sidebar is collapsable.
30
- * This method can be used to display backdrop when sidebar is expanded.
31
- */
32
25
  isExpanded(): Observable<boolean>;
33
26
  /**
34
27
  * Show sidebar, and block scrolling.
@@ -1,17 +1,37 @@
1
1
  import { NgDocTheme } from '@ng-doc/app/interfaces';
2
2
  import { NgDocStoreService } from '@ng-doc/app/services/store';
3
+ import { Observable } from 'rxjs';
3
4
  import * as i0 from "@angular/core";
5
+ /**
6
+ * Service for managing themes.
7
+ */
4
8
  export declare class NgDocThemeService {
5
9
  private readonly document;
6
10
  private readonly themes;
7
11
  private readonly store;
12
+ private readonly defaultThemeId?;
8
13
  private linkElement?;
9
14
  private theme;
10
- constructor(document: Document, themes: NgDocTheme[], store: NgDocStoreService);
15
+ private readonly theme$;
16
+ private readonly disableAutoTheme$;
17
+ constructor(document: Document, themes: NgDocTheme[], store: NgDocStoreService, defaultThemeId?: string | undefined);
18
+ /**
19
+ * Returns the current theme.
20
+ */
11
21
  get currentTheme(): NgDocTheme | undefined;
12
- set(id?: string): Promise<void>;
22
+ /**
23
+ * Sets the theme by id.
24
+ *
25
+ * @param id Theme id.
26
+ * @param save Whether to save the theme in the store to restore it when the page is reloaded. (`true` by default)
27
+ */
28
+ set(id?: string | 'auto', save?: boolean): Promise<void>;
29
+ /**
30
+ * Returns an observable that emits when the theme changes.
31
+ */
32
+ themeChanges(): Observable<NgDocTheme | undefined>;
13
33
  private removeLink;
14
34
  private createLinkIfNoExists;
15
- static ɵfac: i0.ɵɵFactoryDeclaration<NgDocThemeService, never>;
35
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgDocThemeService, [null, null, null, { optional: true; }]>;
16
36
  static ɵprov: i0.ɵɵInjectableDeclaration<NgDocThemeService>;
17
37
  }
package/styles/global.css CHANGED
@@ -55,7 +55,7 @@ h6.ngde {
55
55
  font-weight: var(--ng-doc-font-weight);
56
56
  margin: calc(var(--ng-doc-base-gutter) * 9) 0 0;
57
57
  --ng-doc-line-height: 1.5rem;
58
- --ng-doc-font-weight: 700;
58
+ --ng-doc-font-weight: 800;
59
59
  overflow-wrap: anywhere;
60
60
  }
61
61
  h1.ngde + h1.ngde, h1.ngde + h2.ngde, h1.ngde + h3.ngde, h1.ngde + h4.ngde, h1.ngde + h5.ngde, h1.ngde + h6.ngde,
@@ -94,7 +94,7 @@ h6.ngde + h6.ngde {
94
94
 
95
95
  h1.ngde {
96
96
  --ng-doc-font-size: calc(var(--ng-doc-base-gutter) * 5);
97
- --ng-doc-line-height: calc(var(--ng-doc-base-gutter) * 6);
97
+ --ng-doc-line-height: calc(var(--ng-doc-base-gutter) * 5);
98
98
  --ng-doc-font-weight: 900;
99
99
  }
100
100
 
@@ -304,6 +304,8 @@ mark.ng-doc-mark {
304
304
  /* NgDocDot */
305
305
  --ng-doc-dot-size: calc(var(--ng-doc-base-gutter) / 2);
306
306
  --ng-doc-dot-background: var(--ng-doc-primary);
307
+ /* Sidenav */
308
+ --ng-doc-sidenav-width: 300px;
307
309
  }
308
310
 
309
311
  .ng-doc-tooltip {
@@ -695,6 +697,8 @@ mark.ng-doc-mark {
695
697
  --ng-doc-app-max-width: 1450px;
696
698
  --ng-doc-app-horizontal-padding: calc(var(--ng-doc-base-gutter) * 3);
697
699
  --ng-doc-code-background: var(--ng-doc-base-1);
700
+ --ng-doc-page-padding: calc(var(--ng-doc-base-gutter) * 3) var(--ng-doc-app-horizontal-padding);
701
+ --ng-doc-main-padding: var(--ng-doc-navbar-height) 0 0 0;
698
702
  --ng-doc-class-color: var(--ng-doc-pink-70);
699
703
  --ng-doc-class-background: var(--ng-doc-pink-10);
700
704
  --ng-doc-interface-color: var(--ng-doc-light-blue-90);
@@ -1069,6 +1073,7 @@ article ng-doc-playground {
1069
1073
 
1070
1074
  html {
1071
1075
  overflow-y: scroll;
1076
+ overflow-x: hidden;
1072
1077
  }
1073
1078
 
1074
1079
  html,
@@ -1116,3 +1121,7 @@ body {
1116
1121
  ::-webkit-scrollbar-thumb:hover {
1117
1122
  background: var(--ng-doc-base-8);
1118
1123
  }
1124
+
1125
+ ::selection {
1126
+ background: rgba(var(--ng-doc-primary-rgb), 0.2);
1127
+ }
package/styles/main.css CHANGED
@@ -55,7 +55,7 @@ h6.ngde {
55
55
  font-weight: var(--ng-doc-font-weight);
56
56
  margin: calc(var(--ng-doc-base-gutter) * 9) 0 0;
57
57
  --ng-doc-line-height: 1.5rem;
58
- --ng-doc-font-weight: 700;
58
+ --ng-doc-font-weight: 800;
59
59
  overflow-wrap: anywhere;
60
60
  }
61
61
  h1.ngde + h1.ngde, h1.ngde + h2.ngde, h1.ngde + h3.ngde, h1.ngde + h4.ngde, h1.ngde + h5.ngde, h1.ngde + h6.ngde,
@@ -94,7 +94,7 @@ h6.ngde + h6.ngde {
94
94
 
95
95
  h1.ngde {
96
96
  --ng-doc-font-size: calc(var(--ng-doc-base-gutter) * 5);
97
- --ng-doc-line-height: calc(var(--ng-doc-base-gutter) * 6);
97
+ --ng-doc-line-height: calc(var(--ng-doc-base-gutter) * 5);
98
98
  --ng-doc-font-weight: 900;
99
99
  }
100
100
 
@@ -304,6 +304,8 @@ mark.ng-doc-mark {
304
304
  /* NgDocDot */
305
305
  --ng-doc-dot-size: calc(var(--ng-doc-base-gutter) / 2);
306
306
  --ng-doc-dot-background: var(--ng-doc-primary);
307
+ /* Sidenav */
308
+ --ng-doc-sidenav-width: 300px;
307
309
  }
308
310
 
309
311
  .ng-doc-tooltip {
@@ -695,6 +697,8 @@ mark.ng-doc-mark {
695
697
  --ng-doc-app-max-width: 1450px;
696
698
  --ng-doc-app-horizontal-padding: calc(var(--ng-doc-base-gutter) * 3);
697
699
  --ng-doc-code-background: var(--ng-doc-base-1);
700
+ --ng-doc-page-padding: calc(var(--ng-doc-base-gutter) * 3) var(--ng-doc-app-horizontal-padding);
701
+ --ng-doc-main-padding: var(--ng-doc-navbar-height) 0 0 0;
698
702
  --ng-doc-class-color: var(--ng-doc-pink-70);
699
703
  --ng-doc-class-background: var(--ng-doc-pink-10);
700
704
  --ng-doc-interface-color: var(--ng-doc-light-blue-90);