azure-devops-ui
Version:
React components for building web UI in Azure DevOps
1 lines • 2.08 kB
JavaScript
import"../../CommonImports";import"../../Core/core.css";import"./Tree.css";import"./TreeExpand.css";import*as React from"react";import{FixedHeightList}from"../../List";import{UncheckedObserver}from"../../Observer";class FixedHeightTree extends React.Component{constructor(){super(...arguments),this.list=React.createRef(),this.onActivateExpand=(e,t)=>{!e.defaultPrevented&&t.data.underlyingItem.childItems&&(this.props.onToggle&&this.props.onToggle(e,t.data),e.preventDefault())},this.renderRow=(t,r,e)=>{if(!this.props.renderRow||!e.data)return React.createElement("div",null);const s={ariaRowOffset:e.ariaRowOffset,eventDispatch:e.eventDispatch,data:e.data,itemProvider:this.props.itemProvider,listProps:e.listProps,onFocusItem:e.onFocusItem};return React.createElement(UncheckedObserver,{data:r.underlyingItem.data},e=>{return e.data?(r.onToggle=r.underlyingItem.childItems?this.props.onToggle:void 0,(r.underlyingItem.data.renderRow||this.props.renderRow)(t,r,s)):(e=this.props["renderLoadingRow"],e?e(t,s):React.createElement("div",{className:"bolt-list-row-loading"},React.createElement("div",{className:"shimmer shimmer-line",style:{width:80*Math.random()+20+"%"}}," ")))})}}render(){var{role:e="tree"}=this.props;return React.createElement(FixedHeightList,{className:this.props.className,eventDispatch:this.props.eventDispatch,focuszoneProps:this.props.focuszoneProps,id:this.props.id,itemProvider:this.props.itemProvider,maxHeight:this.props.maxHeight,onActivate:this.onActivateExpand,onFocus:this.props.onFocus,onSelect:this.props.onSelect,pageSize:this.props.pageSize,renderRow:this.renderRow,role:e,rowHeight:this.props.rowHeight,ref:this.list,selection:this.props.selection,singleClickActivation:this.props.singleClickActivation||!0,width:this.props.width||"100%"})}getFocusIndex(){return this.list.current?this.list.current.getFocusIndex():-1}getStats(){return this.list.current?this.list.current.getStats():{firstMaterialized:-1,lastMaterialized:-1}}scrollIntoView(e,t){if(this.list.current)return this.list.current.scrollIntoView(e,t)}}export{FixedHeightTree};