@fluid-topics/ft-reader-toc 1.2.16 → 1.2.17

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,8 +1,11 @@
1
1
  import { PropertyValues, TemplateResult } from "lit";
2
- import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
3
- import { FtReaderComponent } from "@fluid-topics/ft-reader-context/build/registration";
2
+ import { ElementDefinitionsMap, ParametrizedLabelResolver } from "@fluid-topics/ft-wc-utils";
3
+ import { FtReaderComponent, FtReaderPage, FtReaderTocNode } from "@fluid-topics/ft-reader-context/build/registration";
4
4
  import { FtIconVariants } from "@fluid-topics/ft-icon";
5
+ import { FtSizeCategory } from "@fluid-topics/ft-size-watcher";
5
6
  import { FtReaderTocLabels, FtReaderTocProperties } from "./ft-reader-toc.properties";
7
+ import { FtPagesTocNode } from "@fluid-topics/ft-reader-context/build/store/model";
8
+ type TocNode = FtReaderTocNode | FtPagesTocNode;
6
9
  export declare class FtReaderToc extends FtReaderComponent implements FtReaderTocProperties {
7
10
  static elementDefinitions: ElementDefinitionsMap;
8
11
  static styles: import("lit").CSSResult;
@@ -25,19 +28,19 @@ export declare class FtReaderToc extends FtReaderComponent implements FtReaderTo
25
28
  scope: FtReaderTocProperties["scope"];
26
29
  empty: boolean;
27
30
  labels: FtReaderTocLabels;
28
- private labelResolver;
29
- private toc?;
30
- private currentPage?;
31
- private highlightedTocIds?;
32
- private automaticallyExpandedNodes;
33
- private manuallyExpandedNodes;
34
- private manuallyCollapsedNodes;
35
- private expandAll;
36
- private viewportSize;
37
- private nodesToExpandExist;
31
+ labelResolver: ParametrizedLabelResolver<FtReaderTocLabels>;
32
+ toc?: Array<TocNode>;
33
+ currentPage?: FtReaderPage;
34
+ highlightedTocIds?: string[];
35
+ automaticallyExpandedNodes: Set<string>;
36
+ manuallyExpandedNodes: Set<string>;
37
+ manuallyCollapsedNodes: Set<string>;
38
+ expandAll: boolean;
39
+ viewportSize: FtSizeCategory;
40
+ nodesToExpandExist: boolean;
38
41
  get isCurrentPageToc(): boolean;
39
- protected update(changedProperties: PropertyValues): void;
40
- protected contentAvailableCallback(props: PropertyValues): void;
42
+ protected update(changedProperties: PropertyValues<FtReaderToc>): void;
43
+ protected contentAvailableCallback(props: PropertyValues<FtReaderToc>): void;
41
44
  protected render(): TemplateResult<1>;
42
45
  private renderExpandCollapseAll;
43
46
  private renderNode;
@@ -48,3 +51,4 @@ export declare class FtReaderToc extends FtReaderComponent implements FtReaderTo
48
51
  private getExpandCollapseAllTooltipPosition;
49
52
  private getLeafNodeIcon;
50
53
  }
54
+ export {};
@@ -70,7 +70,7 @@ class FtReaderToc extends FtReaderComponent {
70
70
  if (this.scrollCurrentTopicIntoView && props.has("highlightedTocIds") && this.highlightedTocIds && ((_a = this.highlightedTocIds) === null || _a === void 0 ? void 0 : _a.length) > 0) {
71
71
  const target = (_b = this.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector(`[tocId="${this.highlightedTocIds[0]}"]`);
72
72
  if (target) {
73
- scrollHelper.scrollIntoViewIfPossible(target, { behavior: "smooth", position: .25 });
73
+ scrollHelper.scrollIntoViewIfPossible(target, { behavior: "instant", position: .25 });
74
74
  }
75
75
  }
76
76
  }
@@ -298,7 +298,7 @@ __decorate([
298
298
  selector: (s, self) => {
299
299
  var _a, _b;
300
300
  return ((_a = s.paginationConfiguration) === null || _a === void 0 ? void 0 : _a.splitCurrentPageToc) && !self.isCurrentPageToc
301
- ? [(_b = s.currentPage) === null || _b === void 0 ? void 0 : _b.rootTocId]
301
+ ? (((_b = s.currentPage) === null || _b === void 0 ? void 0 : _b.rootTocId) ? [s.currentPage.rootTocId] : [])
302
302
  : s.visibleTopics;
303
303
  }
304
304
  })
@@ -1178,7 +1178,7 @@ Also for action icons.`,r.colorGray200),contentGlobalSubtle:t.extend("--ft-conte
1178
1178
  .ft-reader-toc-expand-collapse-all-justify ft-button {
1179
1179
  flex-grow: 1;
1180
1180
  }
1181
- `;var A=function(e,o,a,n){var l=arguments.length,c=l<3?o:n===null?n=Object.getOwnPropertyDescriptor(o,a):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")c=Reflect.decorate(e,o,a,n);else for(var p=e.length-1;p>=0;p--)(s=e[p])&&(c=(l<3?s(c):l>3?s(o,a,c):s(o,a))||c);return l>3&&c&&Object.defineProperty(o,a,c),c},N=class extends Gt{constructor(){super(...arguments),this.expanded=!1,this.iconVariant=at.fluid_topics,this.collapseIcon="MINUS",this.expandIcon="PLUS",this.leafNodeIconVariant=at.fluid_topics,this.leafNodeIcon="DOT",this.expandCollapseAll=!1,this.expandCollapseAllHideLabel=!1,this.expandCollapseAllTrailingIcon=!1,this.expandCollapseAllAlignment="left",this.expandCollapseAllHideIcon=!1,this.collapseAllIcon="ICON_COLLAPSE",this.expandAllIcon="ICON_EXPAND",this.autoCollapse=!1,this.scrollCurrentTopicIntoView=!1,this.scope="pages",this.empty=!0,this.labels={},this.labelResolver=new q.ParametrizedLabelResolver(mo,{}),this.automaticallyExpandedNodes=new Set,this.manuallyExpandedNodes=new Set,this.manuallyCollapsedNodes=new Set,this.expandAll=!1,this.viewportSize=ot.M,this.nodesToExpandExist=!1}get isCurrentPageToc(){return this.scope==="current-page"}update(o){var a,n,l;super.update(o),o.has("toc")&&(this.nodesToExpandExist=((a=this.toc)!==null&&a!==void 0?a:[]).some(c=>c.children.length>0)),o.has("labels")&&(this.labelResolver=new q.ParametrizedLabelResolver(mo,this.labels)),o.has("highlightedTocIds")&&!this.expanded&&(this.automaticallyExpandedNodes=this.buildAutomaticallyExpandedNodes((n=this.highlightedTocIds)!==null&&n!==void 0?n:[])),this.empty=((l=this.toc)!==null&&l!==void 0?l:[]).length===0}contentAvailableCallback(o){var a,n;if(super.contentAvailableCallback(o),this.scrollCurrentTopicIntoView&&o.has("highlightedTocIds")&&this.highlightedTocIds&&((a=this.highlightedTocIds)===null||a===void 0?void 0:a.length)>0){let l=(n=this.shadowRoot)===null||n===void 0?void 0:n.querySelector(`[tocId="${this.highlightedTocIds[0]}"]`);l&&q.scrollHelper.scrollIntoViewIfPossible(l,{behavior:"smooth",position:.25})}}render(){var o;let a={"ft-reader-toc":!0,"ft-reader-toc-mobile":this.viewportSize===ot.S,"ft-reader-toc-desktop":this.viewportSize!==ot.S,"ft-reader-toc-loaded":this.currentPage!=null,"ft-reader-toc-expanded":this.expanded};return st.html`
1181
+ `;var A=function(e,o,a,n){var l=arguments.length,c=l<3?o:n===null?n=Object.getOwnPropertyDescriptor(o,a):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")c=Reflect.decorate(e,o,a,n);else for(var p=e.length-1;p>=0;p--)(s=e[p])&&(c=(l<3?s(c):l>3?s(o,a,c):s(o,a))||c);return l>3&&c&&Object.defineProperty(o,a,c),c},N=class extends Gt{constructor(){super(...arguments),this.expanded=!1,this.iconVariant=at.fluid_topics,this.collapseIcon="MINUS",this.expandIcon="PLUS",this.leafNodeIconVariant=at.fluid_topics,this.leafNodeIcon="DOT",this.expandCollapseAll=!1,this.expandCollapseAllHideLabel=!1,this.expandCollapseAllTrailingIcon=!1,this.expandCollapseAllAlignment="left",this.expandCollapseAllHideIcon=!1,this.collapseAllIcon="ICON_COLLAPSE",this.expandAllIcon="ICON_EXPAND",this.autoCollapse=!1,this.scrollCurrentTopicIntoView=!1,this.scope="pages",this.empty=!0,this.labels={},this.labelResolver=new q.ParametrizedLabelResolver(mo,{}),this.automaticallyExpandedNodes=new Set,this.manuallyExpandedNodes=new Set,this.manuallyCollapsedNodes=new Set,this.expandAll=!1,this.viewportSize=ot.M,this.nodesToExpandExist=!1}get isCurrentPageToc(){return this.scope==="current-page"}update(o){var a,n,l;super.update(o),o.has("toc")&&(this.nodesToExpandExist=((a=this.toc)!==null&&a!==void 0?a:[]).some(c=>c.children.length>0)),o.has("labels")&&(this.labelResolver=new q.ParametrizedLabelResolver(mo,this.labels)),o.has("highlightedTocIds")&&!this.expanded&&(this.automaticallyExpandedNodes=this.buildAutomaticallyExpandedNodes((n=this.highlightedTocIds)!==null&&n!==void 0?n:[])),this.empty=((l=this.toc)!==null&&l!==void 0?l:[]).length===0}contentAvailableCallback(o){var a,n;if(super.contentAvailableCallback(o),this.scrollCurrentTopicIntoView&&o.has("highlightedTocIds")&&this.highlightedTocIds&&((a=this.highlightedTocIds)===null||a===void 0?void 0:a.length)>0){let l=(n=this.shadowRoot)===null||n===void 0?void 0:n.querySelector(`[tocId="${this.highlightedTocIds[0]}"]`);l&&q.scrollHelper.scrollIntoViewIfPossible(l,{behavior:"instant",position:.25})}}render(){var o;let a={"ft-reader-toc":!0,"ft-reader-toc-mobile":this.viewportSize===ot.S,"ft-reader-toc-desktop":this.viewportSize!==ot.S,"ft-reader-toc-loaded":this.currentPage!=null,"ft-reader-toc-expanded":this.expanded};return st.html`
1182
1182
  <div class=${(0,Qa.classMap)(a)}>
1183
1183
  <ft-size-watcher @change=${this.onViewportSizeChange}></ft-size-watcher>
1184
1184
  ${this.renderExpandCollapseAll()}
@@ -1238,7 +1238,7 @@ Also for action icons.`,r.colorGray200),contentGlobalSubtle:t.extend("--ft-conte
1238
1238
  part="leaf-node-icon"
1239
1239
  .variant="${this.leafNodeIconVariant}"
1240
1240
  .value="${this.leafNodeIcon}"></ft-icon>
1241
- `}};N.elementDefinitions={"ft-button":ft,"ft-icon":Q,"ft-reader-internal-link":dt,"ft-size-watcher":it,"ft-typography":rt};N.styles=qa;A([(0,I.property)({type:Boolean})],N.prototype,"expanded",void 0);A([(0,I.property)()],N.prototype,"iconVariant",void 0);A([(0,I.property)()],N.prototype,"collapseIcon",void 0);A([(0,I.property)()],N.prototype,"expandIcon",void 0);A([(0,I.property)()],N.prototype,"leafNodeIconVariant",void 0);A([(0,I.property)()],N.prototype,"leafNodeIcon",void 0);A([(0,I.property)({type:Boolean})],N.prototype,"expandCollapseAll",void 0);A([(0,I.property)({type:Boolean})],N.prototype,"expandCollapseAllHideLabel",void 0);A([(0,I.property)({type:Boolean})],N.prototype,"expandCollapseAllTrailingIcon",void 0);A([(0,I.property)()],N.prototype,"expandCollapseAllAlignment",void 0);A([(0,I.property)({type:Boolean})],N.prototype,"expandCollapseAllHideIcon",void 0);A([(0,I.property)()],N.prototype,"expandCollapseAllIconVariant",void 0);A([(0,I.property)()],N.prototype,"collapseAllIcon",void 0);A([(0,I.property)()],N.prototype,"expandAllIcon",void 0);A([(0,I.property)({type:Boolean})],N.prototype,"autoCollapse",void 0);A([(0,I.property)({type:Boolean})],N.prototype,"scrollCurrentTopicIntoView",void 0);A([(0,I.property)()],N.prototype,"scope",void 0);A([(0,I.property)({type:Boolean,reflect:!0})],N.prototype,"empty",void 0);A([(0,q.jsonProperty)({})],N.prototype,"labels",void 0);A([(0,q.redux)({selector:(e,o)=>{var a,n,l;return o.isCurrentPageToc?!((a=e.paginationConfiguration)===null||a===void 0)&&a.splitCurrentPageToc?(n=e.currentPage)===null||n===void 0?void 0:n.toc:void 0:!((l=e.paginationConfiguration)===null||l===void 0)&&l.splitCurrentPageToc?e.pagesToc:e.toc}})],N.prototype,"toc",void 0);A([(0,q.redux)()],N.prototype,"currentPage",void 0);A([(0,q.redux)({selector:(e,o)=>{var a,n;return!((a=e.paginationConfiguration)===null||a===void 0)&&a.splitCurrentPageToc&&!o.isCurrentPageToc?[(n=e.currentPage)===null||n===void 0?void 0:n.rootTocId]:e.visibleTopics}})],N.prototype,"highlightedTocIds",void 0);A([(0,I.state)({hasChanged:q.hasChanged})],N.prototype,"automaticallyExpandedNodes",void 0);A([(0,I.state)({hasChanged:q.hasChanged})],N.prototype,"manuallyExpandedNodes",void 0);A([(0,I.state)({hasChanged:q.hasChanged})],N.prototype,"manuallyCollapsedNodes",void 0);A([(0,I.state)()],N.prototype,"expandAll",void 0);A([(0,I.state)()],N.prototype,"viewportSize",void 0);(0,tn.customElement)("ft-reader-toc")(N);})();
1241
+ `}};N.elementDefinitions={"ft-button":ft,"ft-icon":Q,"ft-reader-internal-link":dt,"ft-size-watcher":it,"ft-typography":rt};N.styles=qa;A([(0,I.property)({type:Boolean})],N.prototype,"expanded",void 0);A([(0,I.property)()],N.prototype,"iconVariant",void 0);A([(0,I.property)()],N.prototype,"collapseIcon",void 0);A([(0,I.property)()],N.prototype,"expandIcon",void 0);A([(0,I.property)()],N.prototype,"leafNodeIconVariant",void 0);A([(0,I.property)()],N.prototype,"leafNodeIcon",void 0);A([(0,I.property)({type:Boolean})],N.prototype,"expandCollapseAll",void 0);A([(0,I.property)({type:Boolean})],N.prototype,"expandCollapseAllHideLabel",void 0);A([(0,I.property)({type:Boolean})],N.prototype,"expandCollapseAllTrailingIcon",void 0);A([(0,I.property)()],N.prototype,"expandCollapseAllAlignment",void 0);A([(0,I.property)({type:Boolean})],N.prototype,"expandCollapseAllHideIcon",void 0);A([(0,I.property)()],N.prototype,"expandCollapseAllIconVariant",void 0);A([(0,I.property)()],N.prototype,"collapseAllIcon",void 0);A([(0,I.property)()],N.prototype,"expandAllIcon",void 0);A([(0,I.property)({type:Boolean})],N.prototype,"autoCollapse",void 0);A([(0,I.property)({type:Boolean})],N.prototype,"scrollCurrentTopicIntoView",void 0);A([(0,I.property)()],N.prototype,"scope",void 0);A([(0,I.property)({type:Boolean,reflect:!0})],N.prototype,"empty",void 0);A([(0,q.jsonProperty)({})],N.prototype,"labels",void 0);A([(0,q.redux)({selector:(e,o)=>{var a,n,l;return o.isCurrentPageToc?!((a=e.paginationConfiguration)===null||a===void 0)&&a.splitCurrentPageToc?(n=e.currentPage)===null||n===void 0?void 0:n.toc:void 0:!((l=e.paginationConfiguration)===null||l===void 0)&&l.splitCurrentPageToc?e.pagesToc:e.toc}})],N.prototype,"toc",void 0);A([(0,q.redux)()],N.prototype,"currentPage",void 0);A([(0,q.redux)({selector:(e,o)=>{var a,n;return!((a=e.paginationConfiguration)===null||a===void 0)&&a.splitCurrentPageToc&&!o.isCurrentPageToc?!((n=e.currentPage)===null||n===void 0)&&n.rootTocId?[e.currentPage.rootTocId]:[]:e.visibleTopics}})],N.prototype,"highlightedTocIds",void 0);A([(0,I.state)({hasChanged:q.hasChanged})],N.prototype,"automaticallyExpandedNodes",void 0);A([(0,I.state)({hasChanged:q.hasChanged})],N.prototype,"manuallyExpandedNodes",void 0);A([(0,I.state)({hasChanged:q.hasChanged})],N.prototype,"manuallyCollapsedNodes",void 0);A([(0,I.state)()],N.prototype,"expandAll",void 0);A([(0,I.state)()],N.prototype,"viewportSize",void 0);(0,tn.customElement)("ft-reader-toc")(N);})();
1242
1242
  /*! Bundled license information:
1243
1243
 
1244
1244
  lit-html/lit-html.js: