@fluid-topics/ft-reader-content 1.1.82 → 1.1.83
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.
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
data-item-index="${t}">
|
|
41
41
|
${o?(()=>{let l=this.renderItem(e,t);return typeof l=="string"?(0,Q.unsafeHTML)(l):l})():x.nothing}
|
|
42
42
|
</div>
|
|
43
|
-
`}prepareRenderIfNeeded(e){let t=this.renderApprovalTimeouts[e]!=null;this.inRenderRange(e)&&!t&&(this.renderApprovalTimeouts[e]=setTimeout(()=>{this.inRenderRange(e)?this.renderedIndexes.add(e):this.renderApprovalTimeouts[e]=void 0,this.requestUpdate()},300))}inRenderRange(e){return e>=this.visibleItems[0]-this.renderBeforeFirst&&e<=Te(this.visibleItems)+this.renderAfterLast}resetScroll(e=!0){var t;if(this.shouldRestoreScroll=!1,this.intersectionObserver.disconnect(),this.visibleItems=[],this.scrolledToTarget=!1,this.internalScroll&&this.scrollable!==this.internalScrollable)this.scrollable=this.internalScrollable;else if(!this.internalScroll&&e){(t=this.itemsContainer)===null||t===void 0||t.dispatchEvent(new Event("find-scrollable-parent",{composed:!0}));return}let r=this.resolveScrollToIndex();this.renderedIndexes.add(r),this.scrollToTarget(r),this.scrollDoneDebouncer.run(()=>{this.ensureScrollToTarget&&r>=0&&this.scrollDebouncer.run(()=>{Math.abs(this.scrollable.scrollTop-this.getOffset(r))>5&&this.scrollToTarget(r)},500),this.scrollToTarget(r),this.scrolledToTarget=!0,this.shouldRestoreScroll=!0,this.resetIntersectionObserver()})}resolveScrollToIndex(){var e;let t=(e=this.scrollToIndex)!==null&&e!==void 0?e:this.scrollToItem?this.items.indexOf(this.scrollToItem):-1;return t>=this.items.length?-1:t}getItem(e){var t,r,o;return(r=(t=this.shadowRoot)===null||t===void 0?void 0:t.querySelector(`#item-${e}`))!==null&&r!==void 0?r:(o=this.shadowRoot)===null||o===void 0?void 0:o.querySelector("#item-0")}scrollToTarget(e){e<=0?(this.scrollable.scrollTop=0,this.scrollRestorationOffset=-this.getOffset(e)):(this.scrollable.scrollTop=this.getOffset(e),this.scrollRestorationOffset=0),this.scrollRestorationItem=e>=0?e:void 0}getOffset(e){var t;let r=0,o=typeof e=="number"?this.getItem(e):e;for(;o&&o.offsetParent!==this.scrollable.offsetParent;)r+=o.offsetTop,o=o.offsetParent;return r+((t=o?.offsetTop)!==null&&t!==void 0?t:0)-this.scrollable.offsetTop}appendItems(...e){this.items=[...this.items,...e]}prependItems(...e){this.items=[...e,...this.items]}connectedCallback(){super.connectedCallback(),setTimeout(()=>{this.mutationObserver.disconnect(),this.mutationObserver.observe(this.itemsContainer,{childList:!0}),this.resetScroll()},0)}disconnectedCallback(){super.disconnectedCallback(),this.scrollable=void 0,this.intersectionObserver.disconnect(),this.mutationObserver.disconnect(),this.shouldRestoreScroll=!1}findScrollableParent(e){var t;e.stopPropagation();let r,o;for(let i of e.composedPath()){let l=i,n=this.elementCanScroll(l);if(n&&l.clientHeight&&l.clientHeight<l.scrollHeight){r=l;break}else n&&o==null&&(o=l)}this.scrollable=(t=r??o)!==null&&t!==void 0?t:document.body,this.resetScroll(!1)}elementCanScroll(e){try{return["auto","scroll"].includes(getComputedStyle(e).overflowY)}catch{return!1}}resetIntersectionObserver(){this.intersectionObserver.disconnect(),this.intersectionObserver=new IntersectionObserver(this.onVisibilityChange,{root:this.scrollable,rootMargin:"-8px",threshold:[0,.01,.1,1]}),this.onMutation()}searchFirstVisibleItem(e,t,r,o){if(r=r??0,o=o??t.length-1,o<=r)return t[r];let i=Math.floor((o-r)/2)+r,l=t[i],n=this.getOffset(l);return n>e?this.searchFirstVisibleItem(e,t,r,i-1):n+l.clientHeight<e?this.searchFirstVisibleItem(e,t,i+1,o):l}get shouldRestoreScroll(){return this._shouldRestoreScroll}set shouldRestoreScroll(e){let t=e&&!this._shouldRestoreScroll;this._shouldRestoreScroll=e,t&&requestAnimationFrame(this.scrollAdjustment)}update(e){super.update(e),e.has("items")&&(this.renderedIndexes=new Set,this.renderApprovalTimeouts=[]),((e.has("scrollToItem")||e.has("scrollToIndex"))&&(this.scrollToItem!=null||this.scrollToIndex!=null)||e.has("internalScroll"))&&this.resetScroll()}updated(e){super.updated(e),(e.has("visibleItems")||e.has("items"))&&this.onVisibleItemsChange(),e.has("scrolledToTarget")&&this.scrolledToTarget&&(this.scrollToItem!=null||this.scrollToIndex!=null)&&this.dispatchEvent(new P)}onVisibleItemsChange(){this.visibleItems.every((t,r)=>this.visibleItems[r+1]==null||t+1===this.visibleItems[r+1])||(0,d.deepEqual)(this.visibleItems,this.lastNotOkVisibleItems)?(this.resetVisibleItemsDebouncer.cancel(),this.dispatchVisibleItemsEvent()):this.resetVisibleItemsDebouncer.run(()=>{this.lastNotOkVisibleItems=[...this.visibleItems],this.visibleItems=[],this.resetIntersectionObserver()})}dispatchVisibleItemsEvent(){var e;(e=this.cancelableDispatchEvent)===null||e===void 0||e.cancel(),this.cancelableDispatchEvent=(0,d.cancelable)((0,d.waitUntil)(()=>!this.scrolling)),this.cancelableDispatchEvent.then(()=>this.dispatchEvent(new L(this.visibleItems,this.visibleItems.map(t=>this.items[t])))).catch(()=>null)}};c.styles=J;p([(0,h.property)({type:Array})],c.prototype,"items",void 0);p([(0,h.property)({attribute:!1})],c.prototype,"renderItem",void 0);p([(0,h.property)({attribute:!1})],c.prototype,"getItemKey",void 0);p([(0,h.property)({type:Object})],c.prototype,"scrollToItem",void 0);p([(0,h.property)({type:Number})],c.prototype,"scrollToIndex",void 0);p([(0,h.property)({type:Boolean})],c.prototype,"internalScroll",void 0);p([(0,h.property)({type:Number})],c.prototype,"renderBeforeFirst",void 0);p([(0,h.property)({type:Number})],c.prototype,"renderAfterLast",void 0);p([(0,h.property)({type:Boolean})],c.prototype,"ensureScrollToTarget",void 0);p([(0,h.state)({hasChanged(s,e){return s!=null&&e==null||s.length!==e.length||s[0]!==e[0]}})],c.prototype,"visibleItems",void 0);p([(0,h.query)(".scrollable")],c.prototype,"internalScrollable",void 0);p([(0,h.query)(".items-container")],c.prototype,"itemsContainer",void 0);p([(0,h.state)()],c.prototype,"scrolledToTarget",void 0);p([(0,h.state)()],c.prototype,"scrolling",void 0);p([(0,h.state)({hasChanged:
|
|
43
|
+
`}prepareRenderIfNeeded(e){let t=this.renderApprovalTimeouts[e]!=null;this.inRenderRange(e)&&!t&&(this.renderApprovalTimeouts[e]=setTimeout(()=>{this.inRenderRange(e)?this.renderedIndexes.add(e):this.renderApprovalTimeouts[e]=void 0,this.requestUpdate()},300))}inRenderRange(e){return e>=this.visibleItems[0]-this.renderBeforeFirst&&e<=Te(this.visibleItems)+this.renderAfterLast}resetScroll(e=!0){var t;if(this.shouldRestoreScroll=!1,this.intersectionObserver.disconnect(),this.visibleItems=[],this.scrolledToTarget=!1,this.internalScroll&&this.scrollable!==this.internalScrollable)this.scrollable=this.internalScrollable;else if(!this.internalScroll&&e){(t=this.itemsContainer)===null||t===void 0||t.dispatchEvent(new Event("find-scrollable-parent",{composed:!0}));return}let r=this.resolveScrollToIndex();this.renderedIndexes.add(r),this.scrollToTarget(r),this.scrollDoneDebouncer.run(()=>{this.ensureScrollToTarget&&r>=0&&this.scrollDebouncer.run(()=>{Math.abs(this.scrollable.scrollTop-this.getOffset(r))>5&&this.scrollToTarget(r)},500),this.scrollToTarget(r),this.scrolledToTarget=!0,this.shouldRestoreScroll=!0,this.resetIntersectionObserver()})}resolveScrollToIndex(){var e;let t=(e=this.scrollToIndex)!==null&&e!==void 0?e:this.scrollToItem?this.items.indexOf(this.scrollToItem):-1;return t>=this.items.length?-1:t}getItem(e){var t,r,o;return(r=(t=this.shadowRoot)===null||t===void 0?void 0:t.querySelector(`#item-${e}`))!==null&&r!==void 0?r:(o=this.shadowRoot)===null||o===void 0?void 0:o.querySelector("#item-0")}scrollToTarget(e){e<=0?(this.scrollable.scrollTop=0,this.scrollRestorationOffset=-this.getOffset(e)):(this.scrollable.scrollTop=this.getOffset(e),this.scrollRestorationOffset=0),this.scrollRestorationItem=e>=0?e:void 0}getOffset(e){var t;let r=0,o=typeof e=="number"?this.getItem(e):e;for(;o&&o.offsetParent!==this.scrollable.offsetParent;)r+=o.offsetTop,o=o.offsetParent;return r+((t=o?.offsetTop)!==null&&t!==void 0?t:0)-this.scrollable.offsetTop}appendItems(...e){this.items=[...this.items,...e]}prependItems(...e){this.items=[...e,...this.items]}connectedCallback(){super.connectedCallback(),setTimeout(()=>{this.mutationObserver.disconnect(),this.mutationObserver.observe(this.itemsContainer,{childList:!0}),this.resetScroll()},0)}disconnectedCallback(){super.disconnectedCallback(),this.scrollable=void 0,this.intersectionObserver.disconnect(),this.mutationObserver.disconnect(),this.shouldRestoreScroll=!1}findScrollableParent(e){var t;e.stopPropagation();let r,o;for(let i of e.composedPath()){let l=i,n=this.elementCanScroll(l);if(n&&l.clientHeight&&l.clientHeight<l.scrollHeight){r=l;break}else n&&o==null&&(o=l)}this.scrollable=(t=r??o)!==null&&t!==void 0?t:document.body,this.resetScroll(!1)}elementCanScroll(e){try{return["auto","scroll"].includes(getComputedStyle(e).overflowY)}catch{return!1}}resetIntersectionObserver(){this.intersectionObserver.disconnect(),this.intersectionObserver=new IntersectionObserver(this.onVisibilityChange,{root:this.scrollable,rootMargin:"-8px",threshold:[0,.01,.1,1]}),this.onMutation()}searchFirstVisibleItem(e,t,r,o){if(r=r??0,o=o??t.length-1,o<=r)return t[r];let i=Math.floor((o-r)/2)+r,l=t[i],n=this.getOffset(l);return n>e?this.searchFirstVisibleItem(e,t,r,i-1):n+l.clientHeight<e?this.searchFirstVisibleItem(e,t,i+1,o):l}get shouldRestoreScroll(){return this._shouldRestoreScroll}set shouldRestoreScroll(e){let t=e&&!this._shouldRestoreScroll;this._shouldRestoreScroll=e,t&&requestAnimationFrame(this.scrollAdjustment)}update(e){super.update(e),e.has("items")&&(this.renderedIndexes=new Set,this.renderApprovalTimeouts=[]),((e.has("scrollToItem")||e.has("scrollToIndex"))&&(this.scrollToItem!=null||this.scrollToIndex!=null)||e.has("internalScroll"))&&this.resetScroll()}updated(e){super.updated(e),(e.has("visibleItems")||e.has("items"))&&this.onVisibleItemsChange(),e.has("scrolledToTarget")&&this.scrolledToTarget&&(this.scrollToItem!=null||this.scrollToIndex!=null)&&this.dispatchEvent(new P)}onVisibleItemsChange(){this.visibleItems.every((t,r)=>this.visibleItems[r+1]==null||t+1===this.visibleItems[r+1])||(0,d.deepEqual)(this.visibleItems,this.lastNotOkVisibleItems)?(this.resetVisibleItemsDebouncer.cancel(),this.dispatchVisibleItemsEvent()):this.resetVisibleItemsDebouncer.run(()=>{this.lastNotOkVisibleItems=[...this.visibleItems],this.visibleItems=[],this.resetIntersectionObserver()})}dispatchVisibleItemsEvent(){var e;(e=this.cancelableDispatchEvent)===null||e===void 0||e.cancel(),this.cancelableDispatchEvent=(0,d.cancelable)((0,d.waitUntil)(()=>!this.scrolling)),this.cancelableDispatchEvent.then(()=>this.dispatchEvent(new L(this.visibleItems,this.visibleItems.map(t=>this.items[t])))).catch(()=>null)}};c.styles=J;p([(0,h.property)({type:Array})],c.prototype,"items",void 0);p([(0,h.property)({attribute:!1})],c.prototype,"renderItem",void 0);p([(0,h.property)({attribute:!1})],c.prototype,"getItemKey",void 0);p([(0,h.property)({type:Object})],c.prototype,"scrollToItem",void 0);p([(0,h.property)({type:Number})],c.prototype,"scrollToIndex",void 0);p([(0,h.property)({type:Boolean})],c.prototype,"internalScroll",void 0);p([(0,h.property)({type:Number})],c.prototype,"renderBeforeFirst",void 0);p([(0,h.property)({type:Number})],c.prototype,"renderAfterLast",void 0);p([(0,h.property)({type:Boolean})],c.prototype,"ensureScrollToTarget",void 0);p([(0,h.state)({hasChanged(s,e){return s!=null&&e==null||s.length!==e.length||s[0]!==e[0]}})],c.prototype,"visibleItems",void 0);p([(0,h.query)(".scrollable")],c.prototype,"internalScrollable",void 0);p([(0,h.query)(".items-container")],c.prototype,"itemsContainer",void 0);p([(0,h.state)()],c.prototype,"scrolledToTarget",void 0);p([(0,h.state)()],c.prototype,"scrolling",void 0);p([(0,h.state)({hasChanged:d.hasChanged})],c.prototype,"renderedIndexes",void 0);(0,X.customElement)("ft-infinite-scroll")(c);var ee=a(u()),Be={},te=ee.css`
|
|
44
44
|
`;var le=a(m());var ie=a(u()),w=a(y());var re=a(u());var oe=re.css`
|
|
45
45
|
`;var se=a(m()),A=function(s,e,t,r){var o=arguments.length,i=o<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(s,e,t,r);else for(var n=s.length-1;n>=0;n--)(l=s[n])&&(i=(o<3?l(i):o>3?l(e,t,i):l(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i},v=class extends I{constructor(){super(...arguments),this.disableContextInteractions=!1,this.registeredComponents=[]}render(){return ie.html`
|
|
46
46
|
<article id=${this.tocId}>
|