Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getTableComponent(numCols: number, numRows: number, columnProps?: any, tableProps?: any) {
// combine table overrides
const getCellClipboardData = (row: number, col: number) => {
return Utils.toBase26Alpha(col) + (row + 1);
};
const tablePropsWithDefaults = { numRows, getCellClipboardData, enableFocusedCell: true, ...tableProps };
// combine column overrides
const columnPropsWithDefaults = {
cellRenderer: (rowIndex: number, columnIndex: number) => {
return {Utils.toBase26Alpha(columnIndex) + (rowIndex + 1)};
},
...columnProps,
};
const columns = Utils.times(numCols, index => {
return ;
});
return {columns}<table></table>;
}
private renderColumns() {
return Utils.times(this.state.numCols, columnIndex => {
return (
);
});
}
"scrollToRegionType",
REGION_CARDINALITIES,
this.getRegionCardinalityLabel,
this.handleRegionCardinalityChange,
);
const scrollToRowSelectMenu = this.renderSelectMenu(
"Row",
"scrollToRowIndex",
Utils.times(this.state.numRows, rowIndex => rowIndex),
rowIndex => `${rowIndex + 1}`,
this.handleNumberStateChange,
);
const scrollToColumnSelectMenu = this.renderSelectMenu(
"Column",
"scrollToColumnIndex",
Utils.times(this.state.numCols, columnIndex => columnIndex),
columnIndex => this.store.getColumnName(columnIndex),
this.handleNumberStateChange,
);
const ROW_MENU_CARDINALITIES = [RegionCardinality.CELLS, RegionCardinality.FULL_ROWS];
const COLUMN_MENU_CARDINALITIES = [RegionCardinality.CELLS, RegionCardinality.FULL_COLUMNS];
const shouldShowRowSelectMenu = contains(ROW_MENU_CARDINALITIES, scrollToRegionType);
const shouldShowColumnSelectMenu = contains(COLUMN_MENU_CARDINALITIES, scrollToRegionType);
return (
<div>
{scrollToRegionTypeSelectMenu}
<div>
{shouldShowRowSelectMenu ? scrollToRowSelectMenu : undefined}
{shouldShowColumnSelectMenu ? scrollToColumnSelectMenu : undefined}</div></div>
public render() {
const { children, depth, enabled, rootClassName, branchClassName } = this.props;
let elements = children;
if (enabled) {
Utils.times(depth, (i: number) => {
elements = [
<div>
{elements}
</div>,
];
});
}
return <div>{elements}</div>;
}
}
private renderScrollToSection() {
const { scrollToRegionType } = this.state;
const scrollToRegionTypeSelectMenu = this.renderSelectMenu(
"Region type",
"scrollToRegionType",
REGION_CARDINALITIES,
this.getRegionCardinalityLabel,
this.handleRegionCardinalityChange,
);
const scrollToRowSelectMenu = this.renderSelectMenu(
"Row",
"scrollToRowIndex",
Utils.times(this.state.numRows, rowIndex => rowIndex),
rowIndex => `${rowIndex + 1}`,
this.handleNumberStateChange,
);
const scrollToColumnSelectMenu = this.renderSelectMenu(
"Column",
"scrollToColumnIndex",
Utils.times(this.state.numCols, columnIndex => columnIndex),
columnIndex => this.store.getColumnName(columnIndex),
this.handleNumberStateChange,
);
const ROW_MENU_CARDINALITIES = [RegionCardinality.CELLS, RegionCardinality.FULL_ROWS];
const COLUMN_MENU_CARDINALITIES = [RegionCardinality.CELLS, RegionCardinality.FULL_COLUMNS];
const shouldShowRowSelectMenu = contains(ROW_MENU_CARDINALITIES, scrollToRegionType);
const shouldShowColumnSelectMenu = contains(COLUMN_MENU_CARDINALITIES, scrollToRegionType);