1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from "react";
6 import { WithStyles, withStyles, ButtonBase, StyleRulesCallback, Theme, Popover, Card, Tooltip, IconButton } from "@material-ui/core";
7 import classnames from "classnames";
8 import { DefaultTransformOrigin } from "components/popover/helpers";
9 import { grey } from "@material-ui/core/colors";
10 import { TCheckedList } from "components/data-table/data-table";
12 export type CssRules = "root" | "icon" | "iconButton" | "disabled" | "optionsContainer" | "option";
14 const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
18 backgroundColor: grey[200],
21 color: theme.palette.text.primary,
29 color: theme.palette.text.primary,
34 color: theme.palette.text.primary,
53 backgroundColor: "rgba(0, 0, 0, 0.08)",
58 export type DataTableMultiselectOption = {
60 fn: (checkedList) => void;
63 export interface DataTableMultiselectProps {
66 options: DataTableMultiselectOption[];
67 checkedList: TCheckedList;
70 interface DataTableFMultiselectPopState {
71 anchorEl?: HTMLElement;
74 export const DataTableMultiselectPopover = withStyles(styles)(
75 class extends React.Component<DataTableMultiselectProps & WithStyles<CssRules>, DataTableFMultiselectPopState> {
76 state: DataTableFMultiselectPopState = {
79 icon = React.createRef<HTMLElement>();
82 const { classes, children, options, checkedList, disabled } = this.props;
87 title="Select Options"
90 className={classnames(classes.root)}
92 onClick={disabled ? () => {} : this.open}
98 classes={{ root: classes.iconButton }}
102 className={`${classnames(["fas fa-sort-down", classes.icon])}${disabled ? ` ${classes.disabled}` : ""}`}
103 data-fa-transform="shrink-3"
110 anchorEl={this.state.anchorEl}
111 open={!!this.state.anchorEl}
112 anchorOrigin={DefaultTransformOrigin}
113 transformOrigin={DefaultTransformOrigin}
117 <div className={classes.optionsContainer}>
119 options.map((option, i) => (
122 className={classes.option}
124 option.fn(checkedList);
139 this.setState({ anchorEl: this.icon.current || undefined });
143 this.setState(prev => ({