@skyux/docs-tools 13.0.0-alpha.7 → 13.0.0-alpha.8

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,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { input, ChangeDetectionStrategy, Component, NgModule, inject, Injectable, Directive, booleanAttribute, ViewEncapsulation, computed, signal, makeEnvironmentProviders, Pipe, ElementRef, numberAttribute, InjectionToken, DestroyRef, ChangeDetectorRef, contentChild, effect } from '@angular/core';
2
+ import { input, ChangeDetectionStrategy, Component, NgModule, inject, Injectable, Directive, booleanAttribute, ViewEncapsulation, computed, signal, makeEnvironmentProviders, Pipe, ElementRef, numberAttribute, InjectionToken, DestroyRef, DOCUMENT, effect, ChangeDetectorRef, contentChild } from '@angular/core';
3
3
  import * as i5 from '@skyux/core';
4
4
  import { SkyAppWindowRef, SkyIdModule, SkyHelpService, SkyTrimModule, SkyScrollableHostService, SkyMediaQueryService, SkyLogService } from '@skyux/core';
5
5
  import { SkyToastService } from '@skyux/toast';
@@ -1022,6 +1022,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.5", ngImpor
1022
1022
  * @internal
1023
1023
  */
1024
1024
  class SkyDocsTableOfContentsPageComponent {
1025
+ #anchors;
1026
+ #destroyRef;
1027
+ #elementRef;
1028
+ #scrollableHostSvc;
1029
+ #activeAnchorIdOnScroll;
1030
+ #scrollOffset;
1031
+ #routeFragment;
1032
+ #doc;
1025
1033
  constructor() {
1026
1034
  this.#anchors = toSignal(inject(SkyDocsHeadingAnchorService).anchorsChange);
1027
1035
  this.#destroyRef = inject(DestroyRef);
@@ -1043,13 +1051,17 @@ class SkyDocsTableOfContentsPageComponent {
1043
1051
  return link;
1044
1052
  }) ?? []);
1045
1053
  });
1054
+ this.#routeFragment = toSignal(inject(ActivatedRoute).fragment);
1055
+ this.#doc = inject(DOCUMENT);
1056
+ effect(() => {
1057
+ const fragment = this.#routeFragment();
1058
+ const links = this.links();
1059
+ if (fragment &&
1060
+ links.some((link) => link.anchorId === fragment && !link.active)) {
1061
+ setTimeout(() => this.#doc.getElementById(fragment)?.scrollIntoView());
1062
+ }
1063
+ });
1046
1064
  }
1047
- #anchors;
1048
- #destroyRef;
1049
- #elementRef;
1050
- #scrollableHostSvc;
1051
- #activeAnchorIdOnScroll;
1052
- #scrollOffset;
1053
1065
  ngAfterViewInit() {
1054
1066
  const scrollEl = this.#scrollableHostSvc.getScrollableHost(this.#elementRef);
1055
1067
  this.#scrollOffset = this.#getScrollOffset(scrollEl);
@@ -1098,7 +1110,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.5", ngImpor
1098
1110
  args: [{ changeDetection: ChangeDetectionStrategy.OnPush, host: {
1099
1111
  '[class.sky-docs-toc-page-with-links]': 'links().length > 0',
1100
1112
  }, imports: [SkyDocsTableOfContentsComponent], selector: 'sky-docs-toc-page', template: "@if (links().length > 0) {\n <div class=\"sky-docs-toc-menu\">\n <sky-docs-toc [headingText]=\"menuHeadingText()\" [links]=\"links()\" />\n </div>\n}\n<div class=\"sky-docs-toc-body\">\n <ng-content />\n</div>\n", styles: [":host{display:flex;align-items:flex-start;flex-direction:row-reverse;gap:40px}:host(:not(.sky-docs-toc-page-with-links)) .sky-docs-toc-body{width:100%}:host(.sky-docs-toc-page-with-links) .sky-docs-toc-body{min-width:50%;flex:1}:host(.sky-docs-toc-page-with-links) .sky-docs-toc-menu{position:sticky;top:var(--sky-viewport-top);flex-shrink:1;max-width:40%;min-width:20%}\n"] }]
1101
- }] });
1113
+ }], ctorParameters: () => [] });
1102
1114
 
1103
1115
  /**
1104
1116
  * @internal