azure-devops-ui
Version:
React components for building web UI in Azure DevOps
1 lines • 1.48 kB
JavaScript
import*as React from"react";import{ObservableValue}from"../Core/Observable";var BaseMasterDetailsContext=function(e,t){var a=this;this.hideDetailsPanel=new ObservableValue(!1),this.getCurrentLayer=function(){return a.payload},this.getStack=function(){return a.payloadStack},this.push=function(e){a.payloadStack.push(e),e.onPushed&&e.onPushed(a),a.payload.value=a.payloadStack[a.payloadStack.length-1]},this.pop=function(){var e=a.payloadStack.pop();return e&&e.onPopped&&e.onPopped(a),0<a.payloadStack.length?a.payload.value=a.payloadStack[a.payloadStack.length-1]:a.onExit(),e},this.setDetailsPanelVisbility=function(e){a.hideDetailsPanel.value=!e},this.payload=new ObservableValue(e),this.payloadStack=[e],this.onExit=t,e.onPushed&&e.onPushed(this)},MasterDetailsContext=React.createContext(new BaseMasterDetailsContext({key:"",masterPanelContent:{},detailsContent:{renderContent:function(){return React.createElement("div",null)}},selectedMasterItem:new ObservableValue(null)},function(){}));function bindSelectionToObservable(e,t,a){var n=t.value.findIndex(function(e){return e===a.value});0<=n&&e.select(n),e.subscribe(function(e){e[0]&&(e=e[0].beginIndex,a.value=t.value[e])})}function createChildLayer(e,t,a,n,l,o,s){return{key:e,masterPanelContent:t,detailsContent:a,selectedMasterItem:new ObservableValue(n),parentItem:l.selectedMasterItem.value,onPushed:o,ariaLabel:s}}export{BaseMasterDetailsContext,MasterDetailsContext,bindSelectionToObservable,createChildLayer};