UNPKG

azure-devops-ui

Version:

React components for building web UI in Azure DevOps

24 lines (23 loc) 1.03 kB
import "../../CommonImports"; import "../../Core/core.css"; import * as React from "react"; import { UncheckedObserver } from "./Observer"; export class SelectionObserver extends React.Component { constructor() { super(...arguments); this.onSelectionChanged = (value, action) => { let shouldUpdate = false; if (action === "select" && this.props.onSelect) { shouldUpdate = this.props.onSelect(value); } if ((action === "select" || action === "unselect" || action === "set") && this.props.onSelectionChanged) { shouldUpdate = this.props.onSelectionChanged(this.props.selection.value, action); } return shouldUpdate; }; } render() { const selectionObservable = { observableValue: this.props.selection, filter: this.onSelectionChanged }; return React.createElement(UncheckedObserver, { selectionObservable: selectionObservable }, this.props.children); } }