@fluid-topics/ft-reader-toc 0.3.17 → 0.3.19

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.
@@ -65,7 +65,7 @@ export class FtReaderToc extends FtReaderComponent {
65
65
  ${this.hideIfEmpty && this.empty ? html `
66
66
  <style>
67
67
  :host {
68
- display: none;
68
+ display: none !important;
69
69
  }
70
70
  </style>
71
71
  ` : nothing}
@@ -83,14 +83,16 @@ export class FtReaderToc extends FtReaderComponent {
83
83
  return this.toc;
84
84
  }
85
85
  renderNode(node) {
86
- var _a, _b;
86
+ var _a, _b, _c, _d;
87
87
  const shouldSplit = !this.isCurrentPageToc && this.splitToc && node.page != null && !node.page.onItsOwn;
88
88
  const isHighlighted = !this.isCurrentPageToc && this.splitToc ? ((_a = this.currentPage) === null || _a === void 0 ? void 0 : _a.rootTocId) === node.tocId : (_b = this.visibleTopics) === null || _b === void 0 ? void 0 : _b.includes(node.tocId);
89
89
  const isExpanded = this.expanded || this.manuallyExpandedNodes.has(node.tocId) || (this.automaticallyExpandedNodes.has(node.tocId) && !this.manuallyCollapsedNodes.has(node.tocId));
90
90
  const canDisplayChildren = (this.isCurrentPageToc || !shouldSplit) && node.children.length > 0;
91
91
  const displayToggle = canDisplayChildren && !this.expanded;
92
+ const currentPageDepth = this.isCurrentPageToc ? ((_d = (_c = this.currentPage) === null || _c === void 0 ? void 0 : _c.breadcrumb.length) !== null && _d !== void 0 ? _d : 0) + 1 : 0;
93
+ const tabNumber = node.depth - 1 - currentPageDepth;
92
94
  const styles = {
93
- "padding-left": `calc( ${FtReaderTocCssVariables.tabulationSize} * ${node.depth - 1} + 4px)` // +4px for padding before button
95
+ "padding-left": `calc( ${FtReaderTocCssVariables.tabulationSize} * ${tabNumber} + 4px)` // +4px for padding before button
94
96
  };
95
97
  return html `
96
98
  <div class="ft-reader-toc--node ${isHighlighted ? "ft-reader-toc--node-highlighted" : ""}">
@@ -613,7 +613,7 @@ const G=Symbol.for(""),K=t=>{if((null==t?void 0:t.r)===G)return null==t?void 0:t
613
613
  ${this.hideIfEmpty&&this.empty?e.html`
614
614
  <style>
615
615
  :host {
616
- display: none;
616
+ display: none !important;
617
617
  }
618
618
  </style>
619
619
  `:e.nothing}
@@ -621,17 +621,17 @@ const G=Symbol.for(""),K=t=>{if((null==t?void 0:t.r)===G)return null==t?void 0:t
621
621
  <ft-size-watcher @change=${this.onViewportSizeChange}></ft-size-watcher>
622
622
  ${o.repeat(null!==(t=this.getToc())&&void 0!==t?t:[],(t=>t.tocId),(t=>this.renderNode(t)))}
623
623
  </div>
624
- `}getToc(){var t;return this.isCurrentPageToc?this.splitToc?null===(t=this.currentPage)||void 0===t?void 0:t.toc:void 0:this.toc}renderNode(t){var i,n;const r=!this.isCurrentPageToc&&this.splitToc&&null!=t.page&&!t.page.onItsOwn,a=!this.isCurrentPageToc&&this.splitToc?(null===(i=this.currentPage)||void 0===i?void 0:i.rootTocId)===t.tocId:null===(n=this.visibleTopics)||void 0===n?void 0:n.includes(t.tocId),l=this.expanded||this.manuallyExpandedNodes.has(t.tocId)||this.automaticallyExpandedNodes.has(t.tocId)&&!this.manuallyCollapsedNodes.has(t.tocId),h=(this.isCurrentPageToc||!r)&&t.children.length>0,p=h&&!this.expanded,f={"padding-left":`calc( ${le.tabulationSize} * ${t.depth-1} + 4px)`};return e.html`
625
- <div class="ft-reader-toc--node ${a?"ft-reader-toc--node-highlighted":""}">
626
- <div class="ft-reader-toc--link-container" data-depth="${t.depth}" style=${s.styleMap(f)}>
624
+ `}getToc(){var t;return this.isCurrentPageToc?this.splitToc?null===(t=this.currentPage)||void 0===t?void 0:t.toc:void 0:this.toc}renderNode(t){var i,n,r,a;const l=!this.isCurrentPageToc&&this.splitToc&&null!=t.page&&!t.page.onItsOwn,h=!this.isCurrentPageToc&&this.splitToc?(null===(i=this.currentPage)||void 0===i?void 0:i.rootTocId)===t.tocId:null===(n=this.visibleTopics)||void 0===n?void 0:n.includes(t.tocId),p=this.expanded||this.manuallyExpandedNodes.has(t.tocId)||this.automaticallyExpandedNodes.has(t.tocId)&&!this.manuallyCollapsedNodes.has(t.tocId),f=(this.isCurrentPageToc||!l)&&t.children.length>0,d=f&&!this.expanded,c=this.isCurrentPageToc?(null!==(a=null===(r=this.currentPage)||void 0===r?void 0:r.breadcrumb.length)&&void 0!==a?a:0)+1:0,u=t.depth-1-c,g={"padding-left":`calc( ${le.tabulationSize} * ${u} + 4px)`};return e.html`
625
+ <div class="ft-reader-toc--node ${h?"ft-reader-toc--node-highlighted":""}">
626
+ <div class="ft-reader-toc--link-container" data-depth="${t.depth}" style=${s.styleMap(g)}>
627
627
  <div class="ft-reader-toc--toggle-container">
628
- ${p?e.html`
628
+ ${d?e.html`
629
629
  <ft-button round hideTooltip
630
630
  ?dense=${this.viewportSize!==te.S}
631
- label="${this.labelResolver.resolve(l?"collapse":"expand",t.title)}"
631
+ label="${this.labelResolver.resolve(p?"collapse":"expand",t.title)}"
632
632
  iconVariant="${this.iconVariant}"
633
- icon="${l?this.collapseIcon:this.expandIcon}"
634
- @click=${()=>this.manuallyToggle(t.tocId,l)}
633
+ icon="${p?this.collapseIcon:this.expandIcon}"
634
+ @click=${()=>this.manuallyToggle(t.tocId,p)}
635
635
  data-expand-node="${t.tocId}"
636
636
  >
637
637
  </ft-button>
@@ -643,9 +643,9 @@ const G=Symbol.for(""),K=t=>{if((null==t?void 0:t.r)===G)return null==t?void 0:t
643
643
  <ft-typography variant="body2">${t.title}</ft-typography>
644
644
  </ft-reader-internal-link>
645
645
  </div>
646
- ${h?e.html`
646
+ ${f?e.html`
647
647
  <div class="ft-reader-toc--node-children">
648
- ${l?o.repeat(t.children,(t=>t.tocId),(t=>this.renderNode(t))):e.nothing}
648
+ ${p?o.repeat(t.children,(t=>t.tocId),(t=>this.renderNode(t))):e.nothing}
649
649
  </div>
650
650
  `:e.nothing}
651
651
  </div>
@@ -39,7 +39,7 @@ if(!ShadowRoot.prototype.createElement){const t=window.HTMLElement,e=window.cust
39
39
  * @license
40
40
  * Copyright 2021 Google LLC
41
41
  * SPDX-License-Identifier: BSD-3-Clause
42
- */var a;const l=null!=(null===(a=window.HTMLSlotElement)||void 0===a?void 0:a.prototype.assignedElements)?(t,e)=>t.assignedElements(e):(t,e)=>t.assignedNodes(e).filter((t=>t.nodeType===Node.ELEMENT_NODE));const h=t=>e=>{window.customElements.get(t)||window.customElements.define(t,e)};function c(t,e){const i=()=>JSON.parse(JSON.stringify(t));return o({type:Object,converter:{fromAttribute:t=>{if(null==t)return i();try{return JSON.parse(t)}catch{return i()}},toAttribute:t=>JSON.stringify(t)},...null!=e?e:{}})}function p(t,e){if(t===e)return!0;if(t&&e&&"object"==typeof t&&"object"==typeof e){if(t.constructor!==e.constructor)return!1;var i,o,n;if(Array.isArray(t)){if((i=t.length)!=e.length)return!1;for(o=i;0!=o--;)if(!p(t[o],e[o]))return!1;return!0}if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(o of t.entries())if(!e.has(o[0]))return!1;for(o of t.entries())if(!p(o[1],e.get(o[0])))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(o of t.entries())if(!e.has(o[0]))return!1;return!0}if(t.constructor===RegExp)return t.source===e.source&&t.flags===e.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();if((i=(n=Object.keys(t)).length)!==Object.keys(e).length)return!1;for(o=i;0!=o--;)if(!Object.prototype.hasOwnProperty.call(e,n[o]))return!1;for(o=i;0!=o--;){var r=n[o];if(!p(t[r],e[r]))return!1}return!0}return t!=t&&e!=e}
42
+ */var a;const l=null!=(null===(a=window.HTMLSlotElement)||void 0===a?void 0:a.prototype.assignedElements)?(t,e)=>t.assignedElements(e):(t,e)=>t.assignedNodes(e).filter((t=>t.nodeType===Node.ELEMENT_NODE));const h=t=>e=>{window.customElements.get(t)||window.customElements.define(t,e)};function c(t,e){const i=()=>JSON.parse(JSON.stringify(t));return o({type:Object,converter:{fromAttribute:t=>{if(null==t)return i();try{return JSON.parse(t)}catch{return i()}},toAttribute:t=>JSON.stringify(t)},...null!=e?e:{}})}function p(t,e){try{return function(t,e){if(t===e)return!0;if(t&&e&&"object"==typeof t&&"object"==typeof e){if(t.constructor!==e.constructor)return!1;var i,o,n;if(Array.isArray(t)){if((i=t.length)!=e.length)return!1;for(o=i;0!=o--;)if(!p(t[o],e[o]))return!1;return!0}if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(o of t.entries())if(!e.has(o[0]))return!1;for(o of t.entries())if(!p(o[1],e.get(o[0])))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(o of t.entries())if(!e.has(o[0]))return!1;return!0}if(t.constructor===RegExp)return t.source===e.source&&t.flags===e.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();if((i=(n=Object.keys(t)).length)!==Object.keys(e).length)return!1;for(o=i;0!=o--;)if(!Object.prototype.hasOwnProperty.call(e,n[o]))return!1;for(o=i;0!=o--;){var r=n[o];if(!p(t[r],e[r]))return!1}return!0}return t!=t&&e!=e}(t,e)}catch(t){return!1}}
43
43
  /**
44
44
  * @license
45
45
  * Copyright 2019 Google LLC
@@ -734,7 +734,7 @@ function(t,e,i){let o,n=t;return"object"==typeof t?(n=t.slot,o=t):o={flatten:e},
734
734
  ${this.hideIfEmpty&&this.empty?Z`
735
735
  <style>
736
736
  :host {
737
- display: none;
737
+ display: none !important;
738
738
  }
739
739
  </style>
740
740
  `:J}
@@ -742,17 +742,17 @@ function(t,e,i){let o,n=t;return"object"==typeof t?(n=t.slot,o=t):o={flatten:e},
742
742
  <ft-size-watcher @change=${this.onViewportSizeChange}></ft-size-watcher>
743
743
  ${Lt(null!==(t=this.getToc())&&void 0!==t?t:[],(t=>t.tocId),(t=>this.renderNode(t)))}
744
744
  </div>
745
- `}getToc(){var t;return this.isCurrentPageToc?this.splitToc?null===(t=this.currentPage)||void 0===t?void 0:t.toc:void 0:this.toc}renderNode(t){var e,i;const o=!this.isCurrentPageToc&&this.splitToc&&null!=t.page&&!t.page.onItsOwn,n=!this.isCurrentPageToc&&this.splitToc?(null===(e=this.currentPage)||void 0===e?void 0:e.rootTocId)===t.tocId:null===(i=this.visibleTopics)||void 0===i?void 0:i.includes(t.tocId),r=this.expanded||this.manuallyExpandedNodes.has(t.tocId)||this.automaticallyExpandedNodes.has(t.tocId)&&!this.manuallyCollapsedNodes.has(t.tocId),s=(this.isCurrentPageToc||!o)&&t.children.length>0,a=s&&!this.expanded,l={"padding-left":`calc( ${ho.tabulationSize} * ${t.depth-1} + 4px)`};return Z`
746
- <div class="ft-reader-toc--node ${n?"ft-reader-toc--node-highlighted":""}">
747
- <div class="ft-reader-toc--link-container" data-depth="${t.depth}" style=${It(l)}>
745
+ `}getToc(){var t;return this.isCurrentPageToc?this.splitToc?null===(t=this.currentPage)||void 0===t?void 0:t.toc:void 0:this.toc}renderNode(t){var e,i,o,n;const r=!this.isCurrentPageToc&&this.splitToc&&null!=t.page&&!t.page.onItsOwn,s=!this.isCurrentPageToc&&this.splitToc?(null===(e=this.currentPage)||void 0===e?void 0:e.rootTocId)===t.tocId:null===(i=this.visibleTopics)||void 0===i?void 0:i.includes(t.tocId),a=this.expanded||this.manuallyExpandedNodes.has(t.tocId)||this.automaticallyExpandedNodes.has(t.tocId)&&!this.manuallyCollapsedNodes.has(t.tocId),l=(this.isCurrentPageToc||!r)&&t.children.length>0,h=l&&!this.expanded,c=this.isCurrentPageToc?(null!==(n=null===(o=this.currentPage)||void 0===o?void 0:o.breadcrumb.length)&&void 0!==n?n:0)+1:0,p=t.depth-1-c,d={"padding-left":`calc( ${ho.tabulationSize} * ${p} + 4px)`};return Z`
746
+ <div class="ft-reader-toc--node ${s?"ft-reader-toc--node-highlighted":""}">
747
+ <div class="ft-reader-toc--link-container" data-depth="${t.depth}" style=${It(d)}>
748
748
  <div class="ft-reader-toc--toggle-container">
749
- ${a?Z`
749
+ ${h?Z`
750
750
  <ft-button round hideTooltip
751
751
  ?dense=${this.viewportSize!==eo.S}
752
- label="${this.labelResolver.resolve(r?"collapse":"expand",t.title)}"
752
+ label="${this.labelResolver.resolve(a?"collapse":"expand",t.title)}"
753
753
  iconVariant="${this.iconVariant}"
754
- icon="${r?this.collapseIcon:this.expandIcon}"
755
- @click=${()=>this.manuallyToggle(t.tocId,r)}
754
+ icon="${a?this.collapseIcon:this.expandIcon}"
755
+ @click=${()=>this.manuallyToggle(t.tocId,a)}
756
756
  data-expand-node="${t.tocId}"
757
757
  >
758
758
  </ft-button>
@@ -764,9 +764,9 @@ function(t,e,i){let o,n=t;return"object"==typeof t?(n=t.slot,o=t):o={flatten:e},
764
764
  <ft-typography variant="body2">${t.title}</ft-typography>
765
765
  </ft-reader-internal-link>
766
766
  </div>
767
- ${s?Z`
767
+ ${l?Z`
768
768
  <div class="ft-reader-toc--node-children">
769
- ${r?Lt(t.children,(t=>t.tocId),(t=>this.renderNode(t))):J}
769
+ ${a?Lt(t.children,(t=>t.tocId),(t=>this.renderNode(t))):J}
770
770
  </div>
771
771
  `:J}
772
772
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-reader-toc",
3
- "version": "0.3.17",
3
+ "version": "0.3.19",
4
4
  "description": "Main table of content for integrated reader",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,12 +19,12 @@
19
19
  "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
20
  },
21
21
  "dependencies": {
22
- "@fluid-topics/ft-icon": "0.3.17",
23
- "@fluid-topics/ft-reader-context": "0.3.17",
24
- "@fluid-topics/ft-size-watcher": "0.3.17",
25
- "@fluid-topics/ft-typography": "0.3.17",
26
- "@fluid-topics/ft-wc-utils": "0.3.17",
22
+ "@fluid-topics/ft-icon": "0.3.19",
23
+ "@fluid-topics/ft-reader-context": "0.3.19",
24
+ "@fluid-topics/ft-size-watcher": "0.3.19",
25
+ "@fluid-topics/ft-typography": "0.3.19",
26
+ "@fluid-topics/ft-wc-utils": "0.3.19",
27
27
  "lit": "2.2.8"
28
28
  },
29
- "gitHead": "35c3683874910a6b132930ac8f7dd1ede0294f28"
29
+ "gitHead": "675c2ceb687246109347352e64772e8ebad2cc17"
30
30
  }