Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
useEffect(() => {
selectionMode;
if (innerDivRef.current) {
innerDivRef.current.classList = '';
innerDivRef.current.classList.add(classes.tbody);
if (selectionMode === TableSelectionMode.SINGLE_SELECT || selectionMode === TableSelectionMode.MULTI_SELECT) {
innerDivRef.current.classList.add(classes.selectable);
}
if (alternateRowColor) {
innerDivRef.current.classList.add(classes.alternateRowColor);
}
}
}, [
innerDivRef.current,
rowProps.onClick = (e) => {
if (row.isGrouped) {
return;
}
row.toggleRowSelected();
if (typeof onRowSelected === 'function') {
onRowSelected(Event.of(null, e, { row, isSelected: !row.isSelected }));
}
if (selectionMode === TableSelectionMode.SINGLE_SELECT) {
instance.selectedFlatRows.forEach(({ id }) => {
instance.toggleRowSelected(id, false);
});
}
};
if (row.isSelected) {
export const treeTable = () => {
return (
('selectionMode', TableSelectionMode, TableSelectionMode.SINGLE_SELECT)}
onRowSelected={action('onRowSelected')}
onSort={action('onSort')}
onRowExpandChange={action('onRowExpandChange')}
subRowsKey={text('subRowsKey', 'subRows')}
selectedRowIds={object('selectedRowIds', { 3: true })}
isTreeTable={boolean('isTreeTable', true)}
/>
);
};
treeTable.story = {
hooks.getRowProps.push((passedRowProps, { instance, row }) => {
const { classes, selectionMode, onRowSelected } = instance.webComponentsReactProperties;
let className = classes.tr;
if (row.isGrouped) {
className += ` ${classes.tableGroupHeader}`;
}
const rowProps: any = {
...passedRowProps,
className,
role: 'row'
};
if ([TableSelectionMode.SINGLE_SELECT, TableSelectionMode.MULTI_SELECT].includes(selectionMode)) {
rowProps.onClick = (e) => {
if (row.isGrouped) {
return;
}
row.toggleRowSelected();
if (typeof onRowSelected === 'function') {
onRowSelected(Event.of(null, e, { row, isSelected: !row.isSelected }));
}
if (selectionMode === TableSelectionMode.SINGLE_SELECT) {
instance.selectedFlatRows.forEach(({ id }) => {
instance.toggleRowSelected(id, false);
});
}