| 307 | |
| 308 | // eslint-disable-next-line @typescript-eslint/ban-types |
| 309 | export class MutableTable extends React.Component<{}, IMutableTableState> { |
| 310 | private store = new DenseGridMutableStore<any>(); |
| 311 | |
| 312 | private tableInstance: Table; |
| 313 | private stateStore: LocalStore<IMutableTableState>; |
| 314 | |
| 315 | private refHandlers = { |
| 316 | table: (ref: Table) => (this.tableInstance = ref), |
| 317 | }; |
| 318 | |
| 319 | public constructor(props: any, context?: any) { |
| 320 | super(props, context); |
| 321 | this.stateStore = new LocalStore<IMutableTableState>("BP_TABLE_MUTABLE_TABLE_DEV_PREVIEW", true); |
| 322 | this.state = this.stateStore.getWithDefaults(DEFAULT_STATE); |
| 323 | } |
| 324 | |
| 325 | // React Lifecycle |
| 326 | // =============== |
| 327 | |
| 328 | public render() { |
| 329 | const layoutBoundary = this.state.enableLayoutBoundary; |
| 330 | return ( |
| 331 | <div className="container"> |
| 332 | <SlowLayoutStack |
| 333 | depth={SLOW_LAYOUT_STACK_DEPTH} |
| 334 | enabled={this.state.enableSlowLayout} |
| 335 | rootClassName={classNames("table", { "is-inline": this.state.showInline })} |
| 336 | branchClassName={"layout-passthrough-fill"} |
| 337 | > |
| 338 | <div className={layoutBoundary ? "layout-boundary" : "layout-passthrough-fill"}> |
| 339 | {this.renderTable()} |
| 340 | </div> |
| 341 | </SlowLayoutStack> |
| 342 | {this.renderSidebar()} |
| 343 | </div> |
| 344 | ); |
| 345 | } |
| 346 | |
| 347 | public componentWillMount() { |
| 348 | this.resetCellContent(); |
| 349 | } |
| 350 | |
| 351 | public componentDidMount() { |
| 352 | this.syncFocusStyle(); |
| 353 | } |
| 354 | |
| 355 | // eslint-disable-next-line @typescript-eslint/ban-types |
| 356 | public componentWillUpdate(_nextProps: {}, nextState: IMutableTableState) { |
| 357 | if ( |
| 358 | nextState.cellContent !== this.state.cellContent || |
| 359 | nextState.numRows !== this.state.numRows || |
| 360 | nextState.numCols !== this.state.numCols |
| 361 | ) { |
| 362 | this.resetCellContent(nextState); |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | public componentDidUpdate() { |
nothing calls this directly
no test coverage detected