| 29 | import shouldComponentUpdate from './shouldComponentUpdate'; |
| 30 | |
| 31 | export default class Table extends Component< |
| 32 | SanitizedAndDerivedProps, |
| 33 | StandaloneState |
| 34 | > { |
| 35 | constructor(props: SanitizedAndDerivedProps) { |
| 36 | super(props); |
| 37 | |
| 38 | this.state = { |
| 39 | workFilter: { |
| 40 | value: props.filter_query, |
| 41 | map: this.filterMap( |
| 42 | new Map<string, SingleColumnSyntaxTree>(), |
| 43 | props.filter_action.operator, |
| 44 | props.filter_query, |
| 45 | props.visibleColumns |
| 46 | ) |
| 47 | }, |
| 48 | rawFilterQuery: '', |
| 49 | scrollbarWidth: 0 |
| 50 | }; |
| 51 | } |
| 52 | |
| 53 | UNSAFE_componentWillReceiveProps(nextProps: SanitizedAndDerivedProps) { |
| 54 | this.setState(state => { |
| 55 | const { |
| 56 | applyFocus: currentApplyFocus, |
| 57 | workFilter: {map: currentMap, value} |
| 58 | } = state; |
| 59 | |
| 60 | const nextState: Partial<StandaloneState> = {}; |
| 61 | |
| 62 | // state for filter |
| 63 | if (nextProps.filter_query !== this.props.filter_query) { |
| 64 | if (value !== nextProps.filter_query) { |
| 65 | const map = this.filterMap( |
| 66 | currentMap, |
| 67 | nextProps.filter_action.operator, |
| 68 | nextProps.filter_query, |
| 69 | nextProps.visibleColumns |
| 70 | ); |
| 71 | |
| 72 | if (map !== currentMap) { |
| 73 | nextState.workFilter = {map, value}; |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | // state for applying focus |
| 79 | if (nextProps.active_cell !== this.props.active_cell) { |
| 80 | nextState.applyFocus = true; |
| 81 | } else if (nextProps.loading_state !== this.props.loading_state) { |
| 82 | const activeElement = document.activeElement as HTMLElement; |
| 83 | const tdElement = DOM.getFirstParentOfType(activeElement, 'td'); |
| 84 | const tableElement = DOM.getParentById( |
| 85 | tdElement, |
| 86 | this.props.id |
| 87 | ); |
| 88 |
nothing calls this directly
no test coverage detected
searching dependent graphs…