UNPKG

azure-devops-ui

Version:

React components for building web UI in Azure DevOps

1 lines 1.89 kB
import{__extends}from"tslib";import"../../CommonImports";import"../../Core/core.css";import*as React from"react";import{TimerManagement}from"../../Core/TimerManagement";import{FILTER_CHANGE_EVENT}from"../../Utilities/Filter";var FilterBarItem=function(r){function t(t){var e=r.call(this,t)||this;return e._onFilterChanged=function(t){t.hasOwnProperty(e.props.filterItemKey)&&e.onFilterChanged(t[e.props.filterItemKey])},e._setFilterValue=function(t){e.props.filter&&e.props.filter.setFilterItemState(e.props.filterItemKey,t)},e.timerManagement=new TimerManagement,e}return __extends(t,r),t.prototype.UNSAFE_componentWillMount=function(){var t;this.props.filter&&(t=this.props.filter.getFilterItemState(this.props.filterItemKey),this.setState({value:t&&t.value,operator:t&&t.operator}),t=this.getThrottleWait(),this.throttledSetFilterValue=t?this.timerManagement.debounce(this._setFilterValue,t,{leading:!1,trailing:!0}):this._setFilterValue)},t.prototype.UNSAFE_componentWillReceiveProps=function(t){var e;t.filter&&(e=t.filter.getFilterItemState(t.filterItemKey),this.props.setKey===t.setKey&&(0!==this.getThrottleWait()||t.filter.filterItemStatesAreEqual(t.filterItemKey,e,this.state))||this.setState({value:e&&e.value,operator:e&&e.operator}))},t.prototype.componentDidMount=function(){this.props.filter&&this.props.filter.subscribe(this._onFilterChanged,FILTER_CHANGE_EVENT)},t.prototype.componentWillUnmount=function(){this.props.filter&&this.props.filter.unsubscribe(this._onFilterChanged,FILTER_CHANGE_EVENT),this.timerManagement.dispose()},t.prototype.onFilterChanged=function(t){this.setState({value:t&&t.value,operator:t&&t.operator})},t.prototype.getThrottleWait=function(){return 0},t.prototype.setFilterValue=function(t){this.getThrottleWait()&&this.setState({value:t&&t.value,operator:t&&t.operator}),this.throttledSetFilterValue(t)},t}(React.Component);export{FilterBarItem};